<?php require_once('header.php'); 
$uuid=$fn->gen_uuid();
if(isset($_POST['form1'])) {
    
    $statement = $pdo->prepare("UPDATE tbl_transporter SET `bank` = ? ,`ifsc` = ? ,`ac_no` = ? ,`pan_no` = ?, transport_name=?,driver_mobile_no=?,vechicle_no=?,vechicle_type=?,ftl_date=?,
    advance_percentage=?,status=?,alter_no=?,driver_name=? WHERE id=?");
    

	$resultss = $statement->execute(array($_POST['bank'],$_POST['ifsc'],$_POST['ac_no'],$_POST['pan_no'],$_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'],$_REQUEST['id']));
    
    
	if($resultss){
	    $success_message = 'Transporter Details Is Updated Successfully';

	}else{
	    
	    $error_message = 'Something Went Wrong Pls Check The Transporter 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-map-marker"></i> Update Transporter Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
	         <a href="transporter-list.php" class="btn btn-warning btn-sm"><i class="fa fa-arrow-left"></i> Back to Transporter List</a>
		</div>
	</div> 
	
	<?php
if(!isset($_REQUEST['id'])) {
	header('location: logout.php');
	exit;
} else {
	// Check the id is valid or not
	$statement = $pdo->prepare("SELECT * FROM tbl_transporter WHERE id=?");
	$statement->execute(array($_REQUEST['id']));
	$total = $statement->rowCount();
	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
	if( $total == 0 ) {
		header('location: logout.php');
		exit;
	}
}
?>
	
	
	<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>Transporter name<span style='color:red;'>*</span></label>
						            <input type="text" name="transport_name" id="transport_name" value="<?=$result[0]['transport_name']?>" class="form-control">
						        </div>
						        <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" value="<?=$result[0]['driver_name']?>" 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" value="<?=$result[0]['vechicle_no']?>" class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Mobile No.<span style='color:red;'>*</span></label>
						            <input type="text" name="driver_mobile_no" id="driver_mobile_no" value="<?=$result[0]['driver_mobile_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="<?=$result[0]['advance_percentage']?>" class="form-control">
						        </div>
				
						        <div class="col-md-3" style="margin-top: 10px;" hidden>
						            <label>DATE<span style='color:red;'>*</span></label>
						            <input type="date" name="ftl_date" id="ftl_date" value="<?=$result[0]['ftl_date']?>" class="form-control">
						        </div>
						        
					          <div class="col-md-3" style="margin-top: 10px;">
						            <label>Bank<span style='color:red;'>*</span></label>
						            <input type="text" value="<?=$result[0]['bank']?>" name="bank" id="bank"  class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>IFSC<span style='color:red;'>*</span></label>
						            <input type="text" value="<?=$result[0]['ifsc']?>" name="ifsc" id="ifsc"  class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>AC No.<span style='color:red;'>*</span></label>
						            <input type="text" value="<?=$result[0]['ac_no']?>" name="ac_no" id="ac_no"  class="form-control">
						        </div>
						        <div class="col-md-3" style="margin-top: 10px;">
						            <label>Pan No.<span style='color:red;'>*</span></label>
						            <input type="text" value="<?=$result[0]['pan_no']?>" name="pan_no" id="pan_no"  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 Transporter Details"></center>
        							</div>
        						</div>
						        			        
						 </div>
					</div>
				</div>
		    </form>
		</div>
	</div>
</section>



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