<?php include('include/auth.php');?>
<!doctype html>
<html class="fixed dark">
<?php 
    $fid=$_GET['id'];
    $car=$_GET['car'];
	include('include/head.php');
    $sql2 = $db2->query("SELECT * FROM fleet WHERE fleet.fleet_id='$fid' ") or die(mysql_error());
    $row3 = mysqli_fetch_array( $sql2 );
		?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rome/3.0.2/rome.css"
    integrity="sha512-TAAJeGIyqkrJ4o4ZkIPesmqNKH9zowoRBGHkHUf1s4vWeII8Dv3NayKIq8Hws02HWT3OpocxeSaOQEQo9SH7ZQ=="
    crossorigin="anonymous" />

<body>
    <style>
        .ecommerce-timeline:before {

            box-shadow: none !important;
        }

        .ecommerce-timeline:after {

            box-shadow: none !important;
        }

        .editbutton {
            position: absolute;
            right: 15px;
            top: 10px;
        }

        .editnotes {
            position: absolute;
            right: 15px;
            bottom: 10px;
        }

        .rd-container-attachment {
            z-index: 10002;
            zoom: 100%
        }

        .modal {
            max-width: 90%;
        }

        .form-group+.form-group {
            border-top: none;
            padding-top: 16px;
            padding-top: 0rem;
        }
    </style>
    <?php
 	
    ///check whether data with the name usename has been submitted
    if (isset($_POST['lic_num'])) {
        //variables to hold our submitted data with post
    
      
	$lic_num = $_POST['lic_num'];
   // $lic_loc = $_POST['lic_loc'];
  //  $road_tax = $_POST['road_tax'];
    $color = $_POST['color'];
$active = $_POST['active'];
$notes = $_POST['notes'];
// $fleet_sold= $_POST['fleet_sold'];
// $fleet_sold_date= $_POST['fleet_sold_date'];
// $fleet_kteo= $_POST['fleet_kteo'];
// $fleet_insurance_from= $_POST['fleet_insurance_from'];
//$fleet_ins_company= $_POST['fleet_ins_company'];
//$fleet_insurance_until= $_POST['fleet_insurance_until'];
//$fleet_last_service= $_POST['fleet_last_service'];
//$fleet_last_serv_km= $_POST['fleet_last_serv_km'];
//$fleet_next_service= $_POST['fleet_next_service'];
//$fleet_next_serv_km= $_POST['fleet_next_serv_km'];

//$fleet_sold_date= \DateTime::createFromFormat('d-m-Y H:i', $fleet_sold_date)->getTimestamp(); 
//$fleet_kteo= \DateTime::createFromFormat('d-m-Y H:i', $fleet_kteo)->getTimestamp(); 
//$fleet_insurance_from= \DateTime::createFromFormat('d-m-Y H:i', $fleet_insurance_from)->getTimestamp(); 
//$fleet_insurance_until= \DateTime::createFromFormat('d-m-Y H:i', $fleet_insurance_until)->getTimestamp(); 
//$fleet_last_service= \DateTime::createFromFormat('d-m-Y H:i', $fleet_last_service)->getTimestamp(); 
//$fleet_next_service= \DateTime::createFromFormat('d-m-Y H:i', $fleet_next_service)->getTimestamp(); 
//$road_tax= \DateTime::createFromFormat('d-m-Y H:i', $road_tax)->getTimestamp(); 

$lic_num = $db2->real_escape_string($lic_num);
$color = $db2->real_escape_string($color);
$notes = $db2->real_escape_string($notes);
//$fleet_ins_company = $db2->real_escape_string($fleet_ins_company);            
    
        //our sql statement that we will execute

        //  $sql = "UPDATE fleet SET lic_num='$lic_num',  lic_loc='$lic_loc', road_tax='$road_tax', color='$color', notes='$notes', active='$active', fleet_sold='$fleet_sold', fleet_sold_date='$fleet_sold_date', fleet_kteo='$fleet_kteo',fleet_insurance_from='$fleet_insurance_from', fleet_ins_company='$fleet_ins_company',fleet_insurance_until='$fleet_insurance_until', fleet_last_service='$fleet_last_service', fleet_last_serv_km='$fleet_last_serv_km', fleet_next_service='$fleet_next_service', fleet_next_serv_km='$fleet_next_serv_km' WHERE fleet.fleet_id='$fid' ";
        
        $sql = "UPDATE fleet SET lic_num='$lic_num', color='$color', notes='$notes', active='$active' WHERE fleet.fleet_id='$fid' ";
        
                            
        if ($db2->query($sql) === TRUE) {
       echo "<div class='alert alert-success'>Record Updated Succesfully</div>";
              exit;
    } else {
        echo "<div class='alert alert-danger'>Error updating record: </div>" . $db2->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><?php echo $row3['lic_num'];?> </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 <?php echo $row3['lic_num'];?></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="editfleet-details.php?id=<?php echo $fid;?>"
                    method="post" name="form1">

                    <div class="row">
                        <div class="col-xl-12 mb-4 ">
                            <div class="card card ">
                                <div class="card-header">
                                    <h2 class="card-title">EDIT <?php echo $row3['lic_num'];?></h2>
                                </div>
                                <div class="card-body">



                                    <div class="form-row">
                                        <div class="form-group col-xl-3 mb-3">
                                            <label>Vehicle Model</label>
                                            <input type="text" class="form-control form-control" name="car" disabled
                                                value="<?php echo  $car;?>" />
                                        </div>
                                        <div class="form-group col-xl-3 mb-3">
                                            <label>License Plate</label>
                                            <input type="text" class="form-control form-control" name="lic_num"
                                                value="<?php echo $row3['lic_num'];?>" />
                                        </div>
                                       <!-- <div class="form-group col-xl-2 mb-3">
                                            <label>Plate Status</label>
                                            <select class="form-control populate" name="lic_loc">
                                                <option value="1"
                                                    <?php if ($row3['lic_loc']=="1"){ echo "selected";} else {};?>>ON Vehicle
                                                </option>
                                                <option value="0"
                                                    <?php if ($row3['lic_loc']=="0"){ echo "selected";} else {};?>>OFF Vehicle
                                                </option>
                                            </select>
                                        </div>
                                        <div class="form-group col-xl-2 mb-3">
                                            <label>Road Tax</label>
                                            <input class="form-control" type="text" name="road_tax"
                                                id="road_tax" value="<?php if($row3['road_tax']==0) {echo "Not Set";} else {echo date('d/m/Y', $row3['road_tax']);}  ?>">
                                        </div>-->
                                        <div class="form-group col-xl-4 mb-3">
                                            <label>Active</label>
                                            <select class="form-control populate" name="active">
                                                <option value="1"
                                                    <?php if ($row3['active']=="1"){ echo "selected";} else {};?>>Yes
                                                </option>
                                                <option value="0"
                                                    <?php if ($row3['active']=="0"){ echo "selected";} else {};?>>No
                                                </option>
                                            </select>
                                        </div>
                                        <div class="form-group col-xl-2 mb-3">
                                            <label>Color</label>
                                            <input type="text" class="form-control form-control" name="color"
                                                value="<?php echo $row3['color'];?>" />
                                        </div>


                                    </div>
                                    <div class="form-row">
                                        
                                       <!-- <div class="form-group col-xl-4 mb-3">
                                            <label>Vehicle Sold</label>
                                            <select class="form-control populate" name="fleet_sold">
                                                <option value="1"
                                                    <?php if ($row3['fleet_sold']=="1"){ echo "selected";} else {};?>>
                                                    Yes
                                                </option>
                                                <option value="0"
                                                    <?php if ($row3['fleet_sold']=="0"){ echo "selected";} else {};?>>No
                                                </option>
                                            </select>
                                        </div>
                                        <div class="form-group col-xl-4 mb-1">
                                            <label>Sold Date</label>
                                            <input class="form-control" type="text" name="fleet_sold_date"
                                                id="fleet_sold_date" value="<?php if($row3['fleet_sold_date']==NULL) {echo "Not Sold";} else {echo date('d/m/Y', $row3['fleet_sold_date']);}  ?>">
                                        </div>

                                    </div>
                                    <div class="form-row">
                                    <div class="form-group col-xl-3 mb-1">
                                            <label>KTEO</label>
                                            <input class="form-control" type="text" name="fleet_kteo"
                                                id="fleet_kteo" value="<?php if($row3['fleet_kteo']==0) {echo "Not Set";} else { echo date('d/m/Y', $row3['fleet_kteo']);}  ?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Insurance Company</label>
                                            <input class="form-control" type="text" name="fleet_ins_company"
                                                id="fleet_ins_company" value="<?php if($row3['fleet_ins_company']==0) {echo "Not Set";} else {  echo $row3['fleet_ins_company'];}?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Insurance from</label>
                                            <input class="form-control" type="text" name="fleet_insurance_from"
                                                id="fleet_insurance_from" value="<?php if($row3['fleet_insurance_from']==NULL) {echo "Not Set";} else { echo date('d/m/Y', $row3['fleet_insurance_from']); }  ?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Insurance Until</label>
                                            <input class="form-control" type="text" name="fleet_insurance_until"
                                                id="fleet_insurance_until" value="<?php if($row3['fleet_insurance_until']==NULL) {echo "Not Set";} else {echo date('d/m/Y', $row3['fleet_insurance_until']);}  ?>">
                                        </div>
                                        
                                    </div>
                                    <div class="form-row">
                                    <div class="form-group col-xl-3 mb-1">
                                            <label>Last Service</label>
                                            <input class="form-control" type="text" name="fleet_last_service"
                                                id="fleet_last_service" value="<?php if($row3['fleet_last_service']==NULL) {echo "Not Set";} else {echo date('d/m/Y', $row3['fleet_last_service']);}  ?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Last Service KM</label>
                                            <input class="form-control" type="text" name="fleet_last_serv_km"
                                                id="fleet_last_serv_km" value="<?php if($row3['fleet_last_serv_km']==NULL) {echo "Not Set";} else { echo $row3['fleet_last_serv_km'];}?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Next Service</label>
                                            <input class="form-control" type="text" name="fleet_next_service"
                                                id="fleet_next_service" value="<?php if($row3['fleet_next_service']==NULL) {echo "Not Set";} else { echo date('d/m/Y', $row3['fleet_next_service']);}  ?>">
                                        </div>
                                        <div class="form-group col-xl-3 mb-1">
                                            <label>Next Service KM</label>
                                            <input class="form-control" type="text" name="fleet_next_serv_km"
                                                id="fleet_next_serv_km" value="<?php if($row3['fleet_next_serv_km']==NULL) {echo "Not Set";} else {echo $row3['fleet_next_serv_km'];}?>">
                                        </div>
                                    </div>-->
                                    <div class="form-row">
                                        <div class="form-group col-xl-12 mb-3">
                                            <label>Notes</label>
                                            <textarea class="form-control" name="notes" rows="10" 
                                                id="notes"><?php echo $row3['notes'];?></textarea>
                                        </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="fleet.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(fleet_sold_date, options);
        rome(fleet_kteo, options);
        rome(fleet_insurance_from, options);
        rome(fleet_insurance_until, options);
        rome(fleet_last_service, options);
        rome(fleet_next_service, options);
        rome(road_tax, options);
    </script>
</body>

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