<?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_stopsales LEFT JOIN api_partner ON api_partner.api_partner_id=api_stopsales.api_stopsales_partner_id  WHERE api_stopsales.api_stopsales_id='$fid' ") or die(mysql_error());
$row = mysqli_fetch_array( $sql1 );
    $pid=$row['api_stopsales_partner_id'];
		?>

<body>
<?php

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

    $api_stopsales_from = $_POST['api_stopsales_from'];
   $api_stopsales_to = $_POST['api_stopsales_to'];
         $api_stopsales_acriss_code = $_POST['api_stopsales_acriss_code'];
  $api_stopsales_partner_id = $_POST['api_stopsales_partner_id'];
  $api_stopsales_acriss_code =$db2->real_escape_string($api_stopsales_acriss_code);	

$api_stopsales_from= \DateTime::createFromFormat('d-m-Y H:i', $api_stopsales_from)->getTimestamp(); 
$api_stopsales_to= \DateTime::createFromFormat('d-m-Y H:i', $api_stopsales_to)->getTimestamp(); 
//our sql statement that we will execute

$sql = "INSERT INTO `api_stopsales` (`api_stopsales_id`, `api_stopsales_from`,`api_stopsales_to`, `api_stopsales_acriss_code`, `api_stopsales_partner_id`) VALUES (NULL,  '$api_stopsales_from','$api_stopsales_to', '$api_stopsales_acriss_code','$api_stopsales_partner_id')";

        
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="index.php" 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>NEW Single API Stop Sale </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>NEW Single API Stop Sale</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="newapistopsale.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">Partner</h2>
                                </div>
                                <div class="card-body">


                                    <div class="form-row">
                                        <div class="form-group col-xl-6 mb-3">
                                            <label>Partner</label>
                                            <select data-plugin-selectTwo class="form-control populate"
                                                        id="api_stopsales_partner_id" name="api_stopsales_partner_id">
                                                        <?php 
                                                        $sql23 = "SELECT * FROM  api_partner ";
                                                        $result23 = mysqli_query($db2,$sql23);

                                                        while($row23 = mysqli_fetch_array($result23)) {?>
                                                        <option value="<?php echo $row23['api_partner_id'];?>"
                                                         >
                                                            <?php echo $row23['api_partner_name'];?> </option>
                                                           <?php } ?>                                                    
                                                            
                                                    </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">Vehicle</h2>
                                </div>
                                <div class="card-body">


                                    <div class="form-row">
                                        <div class="form-group col-xl-6 mb-3">
                                            <label>Acriss Code</label>
                                            <select data-plugin-selectTwo class="form-control populate"
                                                        id="api_stopsales_acriss_code" name="api_stopsales_acriss_code">
                                                        <?php 
                                                        $sql33 = "SELECT DISTINCT(api_fleet_acriss) FROM  api_fleet";
                                                        $result33 = mysqli_query($db2,$sql33);

                                                        while($row33 = mysqli_fetch_array($result33)) {?>
                                                        <option value="<?php echo $row33['api_fleet_acriss'];?>"
                                                            >
                                                            <?php echo $row33['api_fleet_acriss'];?> </option>
                                                           <?php } ?>            
                                                            
                                                    </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">Dates</h2>
                                </div>
                                <div class="card-body">
                                <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Starting From:</label>
                                            <input type="text"  class="form-control" name="api_stopsales_from" id="api_stopsales_from" 
                                                />
                                        </div>
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Ending To:</label>
                                            <input type="text" class="form-control form-control" name="api_stopsales_to" id="api_stopsales_to"
                                                />
                                        </div>
                                    </div>
                                  
                                   
                                 


                                   

                                   
                                </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>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rome/3.0.2/rome.standalone.min.js" integrity="sha512-cJ4aSZY0xBXrcH65MOwCloQAiTNCBm2F8/KlcBTlczgn4txZkT7h3YSXULN06pkUnsySMEg5BU4QCHAr97U7ng==" crossorigin="anonymous"></script>
<script>
		
	
		const options = {
  "appendTo": document.body,
  "autoClose": true,
  "autoHideOnBlur": true,
  "autoHideOnClick": true,
  "date": true,
  "dateValidator": Function.prototype,
  "dayFormat": "DD",
  "initialValue": null,
  "inputFormat": "DD-MM-YYYY HH:mm",
  "invalidate": true,
  "max": null,
  "min": null,
  "monthFormat": "MMMM YYYY",
  "monthsInCalendar": 1,
  "required": false,
  "strictParse": false,
  "styles": {
    "back": "rd-back",
    "container": "rd-container",
    "date": "rd-date",
    "dayBody": "rd-days-body",
    "dayBodyElem": "rd-day-body",
    "dayConcealed": "rd-day-concealed",
    "dayDisabled": "rd-day-disabled",
    "dayHead": "rd-days-head",
    "dayHeadElem": "rd-day-head",
    "dayRow": "rd-days-row",
    "dayTable": "rd-days",
    "month": "rd-month",
    "next": "rd-next",
    "positioned": "rd-container-attachment",
    "selectedDay": "rd-day-selected",
    "selectedTime": "rd-time-selected",
    "time": "rd-time",
    "timeList": "rd-time-list",
    "timeOption": "rd-time-option"
  },
  "time": true,
  "timeFormat": "HH:mm",
  "timeInterval": 900,
  "timeValidator": Function.prototype,
  "weekdayFormat": "min",
  "weekStart": moment().weekday(0).day()
}
	rome(api_stopsales_from,options);	
	rome(api_stopsales_to,options);
	
		</script>

</body>

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