<?php include('include/auth.php'); 
if (isset($_GET['stationid2'])  && $_GET['stationid2']!=0) {
    $stationid2=$_GET['stationid2'];
}
else {
    $stationid2='0';
}


?>
<!doctype html>
<html class="fixed dark">
<?php 
	$pagerole="lists";
	include('include/head.php');
    if (isset($_GET['id'])  && $_GET['id']!='0') {
        $fid=$_GET['id'];
       
    }
    else {
        $fid2=$_GET['webid'];
        $sql = $db2->query("SELECT * FROM jostj_vikrentcar_orders WHERE jostj_vikrentcar_orders.webid='$fid2' ") or die(mysql_error());
    $row = mysqli_fetch_array( $sql );
    $fid=$row['id'];
    
    }
?>

<body>
    <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 Contract Type</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 Contract Type</span></li>
                        </ol>

                        <a class="sidebar-right-toggle" data-open="sidebar-right"><i
                                class="fas fa-chevron-left"></i></a>
                    </div>
                </header>
                <h3>Select Contract Type</h3>
                
					<div class="row text-center">
                
					<div class="col-md-6 p-2">
							<a class="m-2 btn   btn-primary" href="newcontract.php?id=<?php echo $fid;?>">Paper Contract</a>
						</div>
                        
						<div class="col-md-6 p-2">
							
                            <?php if($stationid==0){?>
                          <label>Station</label>
                        <select data-plugin-selectTwo class="form-control populate" id=station
                            onChange="window.location.href=this.value">
                            <option
                                value="" disabled selected
                               >
                                Select Station</option>
                            <?php $sqlinst = $db2->query("SELECT * FROM jostj_vikrentcar_stations ") or die(mysql_error()); 
					 while($rowinst = mysqli_fetch_array($sqlinst)) {
                        
                         ?>
                            <option
                                value="?<?php echo http_build_query(array_merge($_GET, array("stationid2"=>$rowinst['station_id'])))?>"
                                <?php if($stationid2==$rowinst['station_id']) { echo "selected";} ?>>
                                <?php echo $rowinst['station_name'];?></option>
                            <?php } ?>

                        </select>

                        
                    
                    <?php }
                     
                     else {$stationid2=$stationid;} 
                     
                     if($stationid2==0)
                     {
                        $buttclass="disabled";
                    }
                     else {
                        $sqlmaxmc = $db2->query("SELECT MAX(econtract_num) AS maxmc FROM econtract WHERE econtract.econtract_statid=$stationid2") or die(mysql_error());
                        $rowmaxmc = mysqli_fetch_array( $sqlmaxmc );
                        $nextnumber=$rowmaxmc[0]+1;
                        $sql2 = $db2->query("SELECT * FROM jostj_vikrentcar_stations WHERE jostj_vikrentcar_stations.station_id=$stationid2 ") or die(mysql_error());
    $row2 = mysqli_fetch_array( $sql2 ); 
     
                        $mcode=$row2['station_contprefix']."-".$nextnumber;
                     }
                     ?>
                    <a class="m-2 btn   btn-primary <?php echo $buttclass;?>" id="econtract" href="newcontract.php?id=<?php echo $fid;?>&contnum=<?php echo $mcode;?>&prefix=<?php echo $row2['station_contprefix'];?>&cnum=<?php echo $nextnumber;?>">e-Contract</a>
						</div>
                     
						
						
					
						
					
						
						
						
						
					</div>
                <!-- 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/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables/media/js/dataTables.bootstrap4.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/dataTables.buttons.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.bootstrap4.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.html5.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.print.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/JSZip-2.5.0/jszip.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/pdfmake-0.1.32/pdfmake.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/pdfmake-0.1.32/vfs_fonts.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>


</body>

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