<?php require_once('header.php'); 
$uuid=$fn->gen_uuid();

if(isset($_POST['form1'])) {

	$statement = $pdo->prepare("INSERT INTO `tbl_transporter`(`transport_name`, `driver_mobile_no`, `vechicle_no`, `vechicle_type`, `ftl_date`, 
	`advance_percentage`, `status`,`alter_no`,`driver_name`) VALUES (?,?,?,?,?,
	?,?,?,?)");
	$result = $statement->execute(array($_POST['transport_name'],$_POST['driver_mobile_no'],$_POST['vechicle_no'],$_POST['vechicle_type'],$_POST['ftl_date'],
	$_POST['advance_percentage'],'1',$_POST['alter_no'],$_POST['driver_name']));
	
	$ftl_id = $pdo->lastInsertId();
	if($result){
	    $success_message = 'Transport Details is added successfully!';
	    
	    
        unset($_POST['vechicle_no']);unset($_POST['transport_name']);unset($_POST['driver_mobile_no']);unset($_POST['vechicle_type']);unset($_POST['ftl_date']);
    	unset($_POST['advance_percentage']);unset($_POST['alter_no']);

	}else{
	    
	    $error_message = 'Something Went Wrong Pls Check The FTL Booking Add Details';
	    
	}
	
}	
			
	
?>

<section class="content-header" style="background-color: white;">
	    
	<div class="row">
	    <div class="col-md-12">
			<?php if($error_message): ?>
			<div class="callout callout-danger">
				<p>
					<?php echo $error_message; ?>
				</p>
			</div>
			<?php endif; ?>

			<?php if($success_message): ?>
			<div class="callout callout-success">
				<p><?php echo $success_message; ?></p>
				
			</div>
			<?php endif; ?>
		</div>
		<div class="col-md-4" style="text-align: left;">
			<h4><i class="fa fa-truck"></i> Vehicle Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
	         <a href="drivers-list.php" class="btn btn-warning btn-sm"><i class="fa fa-arrow-left"></i> Back to Vehicle List</a>
		</div>
	</div> 
	<div class="row">
		<div class="col-md-12">
		    <form class="form-horizontal" action="" method="post" id="add_form" enctype="multipart/form-data">
		        <div class="box box-warning" style="box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;">
					<div class="box-body">
					    <div class="row" style="margin: 20px 0px;">
						        
						        
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Driver Name<span style='color:red;'>*</span></label>
						            <input type="text" name="driver_name" id="driver_name" class="form-control">
						        </div>
						        
						        
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Driver Mobile No<span style='color:red;'>*</span></label>
						            <input type="text" name="driver_mobile_no" id="driver_mobile_no" class="form-control">
						        </div>
						        
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Driver Alter Mobile No<span style='color:red;'>*</span></label>
						            <input type="text" name="driver_alter_mobile_no" id="driver_alter_mobile_no" class="form-control">
						        </div>
						        
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>VEHICLE NO<span style='color:red;'>*</span></label>
						            <input type="text" name="vechicle_no" id="vechicle_no" class="form-control">
						        </div>
						        
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>VEHICLE TYPE<span style='color:red;'>*</span></label>
						            <input type="text" name="vechicle_type" id="vechicle_type" class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>DATE<span style='color:red;'>*</span></label>
						            <input type="date" name="ftl_date" id="ftl_date" value="<?=date('Y-m-d')?>" class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label class="optional">Alter No</label>
						            <input type="number" name="alter_no" id="alter_no"  class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Advance Percentage<span style='color:red;'>*</span></label>
						            <input type="number" name="advance_percentage" id="advance_percentage" value="2" class="form-control">
						        </div>
						        
						       
						        <div class="form-group">
        							<div class="col-sm-12">
        							    <br>
        								<center><input type="submit" id="submit" class="btn btn-success btn-sm" name="form1" value="Save Transport Details"></center>
        							</div>
        						</div>
						        			        
						 </div>
					</div>
				</div>
		    </form>
		</div>
	</div>
</section>



<?php require_once('footer.php'); ?>