<?php
$title='';
$id='';
$driver_name='';
$driver_father_name='';
$dob='';
$driver_contact_no='';
$address='';
$experience='';
$driver_license_no='';
$dl_renewal_date='';
$table='vehicle_driver';

if(isset($data)){
    $id=$data;
    $get_driver_info=$this->TransportModel->get_item_data($id,$table);
    if($get_driver_info){
        foreach($get_driver_info as $driver_info){
            $title='Update Vehicle Driver';
            $id=$data;
            $driver_name=$driver_info['driver_name'];
            $driver_father_name=$driver_info['driver_father_name'];
            $dob=$driver_info['dob'];
            $driver_contact_no=$driver_info['driver_contact_no'];
            $address=$driver_info['address'];
            $experience=$driver_info['experience'];
            $driver_license_no=$driver_info['driver_license_no'];
            $dl_renewal_date=$driver_info['dl_renewal_date'];
        }
    }

}else{
    $title='Add New Vehicle Driver';
}
?>

<style>
    .tab-item-1{margin-bottom:15px;}
    .tab-item-1 li a{font-weight:600;}
</style>
<div class="container mt-3 mb-3 pt-3 pb-3 bg-white">
    <div class="row">
        <div class="col-sm-8">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome">Home</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Transport">Transport</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Transport/drivers">Vehicle Drivers</a></li>
                <li class="breadcrumb-item">Add New Vehicle Driver</li>
            </ul>
            <div class="">
                <ul class="nav nav-tabs tab-item-1">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">Add New Vehicle Driver</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="<?php echo base_url();?>Transport/drivers">Vehicle Drivers</a>
                    </li>
                </ul>
                <form method="post" action="#" enctype="multipart/form-data">
                    <?php 
                    if($success){
                        ?>
                        <div class="alert alert-success"><?php echo $success;?></div>
                        <?php
                    }
                    
                    if($error){
                    ?>
                    <div class="alert alert-danger"><?php echo $error;?></div>    
                    <?php
                    }
                    
                    ?>
                    
                    <div class="form-group">
                        <label>Driver Name</label>
                        <input type="hidden" name="id" value="<?php echo $id;?>">
                        <input type="text" class="form-control" name="driver_name" placeholder="Driver's Name" value="<?php if($driver_name){echo $driver_name;} ?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Father's Name</label>
                        <input type="text" class="form-control" name="driver_father_name" placeholder="Father's Name" value="<?php if($driver_father_name){echo $driver_father_name;} ?>">
                    </div>
                    
                    <div class="form-group">
                        <label>D.O.B.</label>
                        <input type="date" name="dob" class="form-control" value="<?php if($dob){echo $dob; }?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Mobile Number</label>
                        <input type="text" name="driver_contact_no" class="form-control" placeholder="Mobile Number" value="<?php if($driver_contact_no){echo $driver_contact_no;} ?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Address</label>
                        <textarea name="address" class="form-control" placeholder="Address"><?php if($address){echo $address;}?></textarea>
                    </div>
                    <div class="form-group">
                        <label>Total Driving Experience</label>
                        <input type="number" class="form-control" name="experience" placeholder="Total Driving Experience In Years" value="<?php if($experience){echo $experience;}?>">
                    </div>

                    <div class="form-group">
                        <label>Driving License Number</label>
                        <input type="text" name="driver_license_no" class="form-control" placeholder="Driving License Number" value="<?php if($driver_license_no){echo $driver_license_no;} ?>">
                    </div>
                    
                    <div class="form-group">
                        <label>DL Renewal Date</label>
                        <input type="date" class="form-control" name="dl_renewal_date" placeholer="Driving License Renewal Date" value="<?php if($dl_renewal_date){echo $dl_renewal_date;}?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Profile Picture</label>
                        <input type="file" class="form-control p-1" name="driver_profile_picture">
                    </div>
                    
                    <div class="form-group">
                        <label>Driving License</label>
                        <input type="file" name="driving_license_copy" class="form-control p-1" >
                    </div>
                    
                    <div class="form-group">
                        <label>Staff Type</label>
                        <select class="form-control" name="staff_type" required>
                            <option value="">-- Select Driving Staff --</option>
                            <option value="Driving Staff">Driving Staff</option>
                            <option value="Assistance Staff">Assistance Staff</option>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <button class="btn btn-sm btn-success" type="submit" name="add_new_driver"><?php echo $title;?></button>
                    </div>
                    
                </form>
            </div>
            
        </div>
        <div class="col-sm-4">
            <?php $this->load->view('erp/transport/quick-links');?>
        </div>
    </div>
</div>