<?php include('include/auth.php');?>
<!doctype html>
<html class="fixed dark">
<?php 
	$pagerole="user";
	 $fid=$_GET['id'];

	include('include/head.php');
	$sql1 = $db2->query("SELECT * FROM api_partner WHERE api_partner.api_partner_id='$fid' ") or die(mysql_error());
$row = mysqli_fetch_array( $sql1 );
    
		?>

<body>
<?php

///check whether data with the name usename has been submitted
   if (isset($_POST['api_partner_name'])) {
  //variables to hold our submitted data with post

  $api_partner_name = $_POST['api_partner_name'];
 $api_partner_contact = $_POST['api_partner_contact'];
       $api_partner_mail = $_POST['api_partner_mail'];
       $api_partner_markup = $_POST['api_partner_markup'];
       $api_partner_rate_type = $_POST['api_partner_rate_type'];
        $availability_mode = $_POST['availability_mode'];
       $api_partner_charge_type = $_POST['api_partner_charge_type'];
       $api_partner_name =$db2->real_escape_string($api_partner_name);		
       $api_partner_contact =$db2->real_escape_string($api_partner_contact);	
       $api_partner_mail =$db2->real_escape_string($api_partner_mail);	
//our sql statement that we will execute
$sql = "UPDATE api_partner SET api_partner_name='$api_partner_name',  api_partner_contact='$api_partner_contact', availability_mode='$availability_mode', api_partner_mail='$api_partner_mail' , api_partner_markup='$api_partner_markup',  api_partner_rate_type='$api_partner_rate_type', api_partner_charge_type='$api_partner_charge_type'  WHERE api_partner.api_partner_id='$fid' ";

        
if ($db2->query($sql) === TRUE) {
echo "<div class='alert alert-success'>Record Updated Succesfully</div><script>"; echo "window.history.go(-2);";
echo "</script>";;
exit;}
else {
echo "<div class='alert alert-danger'>Error updating record: </div>" . $db->error;
}

$db2->close();
    
}?>
    <section class="body">

        <!-- start: header -->
        <header class="header">
            <div class="logo-container">
                <a href="../3.0.0" class="logo">
                    <img src="img/logo-light.png" width="75" height="35" alt="Web Voyage" />
                </a>
                <div class="d-md-none toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html"
                    data-fire-event="sidebar-left-opened">
                    <i class="fas fa-bars" aria-label="Toggle sidebar"></i>
                </div>
            </div>

            <!-- start: search & user box -->
            <div class="header-right">
                <?php include('include/search.php');?>


                <span class="separator"></span>
                <?php include('include/notifications.php');?>


                <span class="separator"></span>
                <?php include('include/userbox.php');?>

            </div>
            <!-- end: search & user box -->
        </header>
        <!-- end: header -->

        <div class="inner-wrapper">
            <!-- start: sidebar -->
            <?php include('include/nav.php');?>
            <!-- end: sidebar -->

            <section role="main" class="content-body">
                <header class="page-header">
                    <h2>EDIT API Partner </h2>

                    <div class="right-wrapper text-right">
                        <ol class="breadcrumbs">
                            <li>
                                <a href="index.php">
                                    <i class="fas fa-home"></i>
                                </a>
                            </li>
                            <li><span>WV Admin</span></li>
                            <li><span>EDIT API Partner</span></li>
                        </ol>

                        <a class="sidebar-right-toggle" data-open="sidebar-right"><i
                                class="fas fa-chevron-left"></i></a>
                    </div>
                </header>

                               <!-- start: page -->
                <form class="order-details action-buttons-fixed" action="editapipartner.php?id=<?php echo $fid;?>"
                    method="post" name="form1">

                    <div class="row">
                        <div class="col-xl-4 mb-4 ">
                            <div class="card card ">
                                <div class="card-header">
                                    <h2 class="card-title">Contact Info</h2>
                                </div>
                                <div class="card-body">


                                    <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Name</label>
                                            <input type="text" class="form-control form-control" name="api_partner_name"
                                                value="<?php echo $row['api_partner_name'];?>" />
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Contact</label>
                                            <input type="text" class="form-control form-control" name="api_partner_contact"
                                                value="<?php echo $row['api_partner_contact'];?>" />
                                        </div>

                                    </div>


                                    <div class="form-row">

                                        <div class="form-group col-xl-12 mb-3">
                                            <label>E-mail</label>
                                            <input type="text" class="form-control form-control" name="api_partner_mail"
                                                value="<?php echo  $row['api_partner_mail'];?>" />
                                        </div>
                                    </div>

                                   
                                </div>
                            </div>

                        </div>
                        <div class="col-xl-4 mb-4 ">
                            <div class="card card ">
                                <div class="card-header">
                                    <h2 class="card-title">Rates Info</h2>
                                </div>
                                <div class="card-body">


                                    <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Rates Type</label>
                                            <select data-plugin-selectTwo class="form-control populate"
                                                        id="api_partner_rate_type" name="api_partner_rate_type">
                                                        <?php 
                                                        $sql22 = "SELECT * FROM  api_rate_types ";
                                                        $result2 = mysqli_query($db2,$sql22);

                                                        while($row2 = mysqli_fetch_array($result2)) {?>
                                                        <option value="<?php echo $row2['api_rate_type_id'];?>"
                                                            <?php if($row['api_partner_rate_type']==$row2['api_rate_type_id']){ echo"selected";}?>>
                                                            <?php echo $row2['api_rate_type_name'];?> </option>
                                                          <?php } ?>
                                                            
                                                    </select>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Charge Type</label>
                                            <select data-plugin-selectTwo class="form-control populate"
                                                        id="api_partner_charge_type" name="api_partner_charge_type">
                                                        <?php 
                                                        $sql23 = "SELECT * FROM  api_charge_types ";
                                                        $result23 = mysqli_query($db2,$sql23);

                                                        while($row23 = mysqli_fetch_array($result23)) {?>
                                                        <option value="<?php echo $row23['api_charge_types_id'];?>"
                                                            <?php if($row['api_partner_charge_type']==$row23['api_charge_types_id']){ echo"selected";}?>>
                                                            <?php echo $row23['api_charge_types_name'];?> </option>
                                                          <?php } ?>
                                                            
                                                    </select>
                                            
                                            
                                        </div>

                                    </div>


                                    <div class="form-row">

                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Marku up (0-99)</label>
                                            <input type="text" class="form-control form-control" name="api_partner_markup"
                                                value="<?php echo  $row['api_partner_markup'];?>" />
                                               
                                        </div>
                                    </div>
      <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Availability Mode</label>
                                            <select data-plugin-selectTwo class="form-control populate"
                                                        id="availability_mode" name="availability_mode">
                                                        
                                                        <option value="1" <?php if($row['availability_mode']==1){ echo"selected";}?>>Stop Sales </option>
                                                          <option value="2" <?php if($row['availability_mode']==2){ echo"selected";}?>>Real Availability </option>
                                                          <option value="3" <?php if($row['availability_mode']==3){ echo"selected";}?>>Stop Sales & Real Availability </option>
                                                            <option value="4" <?php if($row['availability_mode']==4){ echo"selected";}?>>Free Sales </option>
                                                    </select>
                                        </div>

                                    </div>
                                   
                                </div>
                            </div>

                        </div>
                        <div class="col-xl-4 mb-4 ">
                            <div class="card card ">
                                <div class="card-header">
                                    <h2 class="card-title">Connection Info</h2>
                                </div>
                                <div class="card-body">

                                <p>Username: <?php echo $row['api_partner_user'];?></p> 
    <p>Password: <?php echo $row['api_partner_pass'];?></p> 
    <p>API KEY: <?php echo $row['api_partner_key'];?></p> 
    <p>IP: <?php echo $row['api_partner_ip'];?></p> 
                                   
                                 


                                   

                                   
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="row action-buttons">

                        <div class="col-12 col-md-auto">
                            <button type="submit"
                                class="submit-button btn btn-primary btn-px-4 py-3 d-flex align-items-center font-weight-semibold line-height-1"
                                data-loading-text="Loading...">
                                <i class="bx bx-save text-4 mr-2"></i> Save
                            </button>
                        </div>

                        <div class="col-12 col-md-auto px-md-0 mt-3 mt-md-0">
                            <a href="apipartner.php"
                                class="cancel-button btn btn-light btn-px-4 py-3 d-flex align-items-center font-weight-semibold line-height-1">Return</a>
                        </div>

                    </div>

                </form>
                <!-- end: page -->
            </section>
        </div>

        <?php include('include/aside.php');?>

    </section>


    <!-- Vendor -->
    <script src="vendor/jquery/jquery.js"></script>
    <script src="vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
    <script src="vendor/popper/umd/popper.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.js"></script>
    <script src="vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="vendor/common/common.js"></script>
    <script src="vendor/nanoscroller/nanoscroller.js"></script>
    <script src="vendor/magnific-popup/jquery.magnific-popup.js"></script>
    <script src="vendor/jquery-placeholder/jquery.placeholder.js"></script>

    <!-- Specific Page Vendor -->
    <script src="vendor/select2/js/select2.js"></script>
    <script src="vendor/pnotify/pnotify.custom.js"></script>

    <!--(remove-empty-lines-end)-->

    <!-- Theme Base, Components and Settings -->
    <script src="js/theme.js"></script>

    <!-- Theme Custom -->
    <script src="js/custom.js"></script>

    <!-- Theme Initialization Files -->
    <script src="js/theme.init.js"></script>

    <!-- Examples -->
    <script src="js/examples/examples.header.menu.js"></script>
    <script src="js/examples/examples.ecommerce.orders.detail.js"></script>


</body>

</html>
<?php include('include/footer.php');?>