<?php
$table='transport_vehicle';
$id='';
$vehicle_number='';
$vehicle_model='';
$rcnumber='';
$vehicle_componey='';
$no_of_seats='';
$vehicle_driver='';
$assistance_driver='';
$vehicle_owner_name='';
$vehicle_owner_contact_number='';
$vehicle_owner_address='';
if(isset($data)){
    $id=$data;
    $get_vehicle_data=$this->TransportModel->get_item_data($data,$table);
    if($get_vehicle_data){
        foreach($get_vehicle_data as $vehicle_data){
            $vehicle_number=$vehicle_data['vehicle_number'];
            $vehicle_model=$vehicle_data['vehicle_model'];
            $rcnumber=$vehicle_data['vehicle_rc_number'];
            $vehicle_componey=$vehicle_data['vehicle_componey'];
            $no_of_seats=$vehicle_data['number_of_seats'];
            $vehicle_driver=$vehicle_data['driver_on_duty'];
            $assistance_driver=$vehicle_data['assistance_driver'];
            
            $vehicle_owner_name=$vehicle_data['vehicle_owner_name'];
            $vehicle_owner_contact_number=$vehicle_data['vehicle_owner_contact_number'];
            $vehicle_owner_address=$vehicle_data['vehicle_owner_address'];
        }
    }
    // echo $data;
}

?>

<style>
    .form-group{width:100% !important;margin-top:10px;}
</style>

<div class="container mt-3 mb-3 pt-3 pb-3 bg-white">
    <div class="row">
        <div class="col-sm-12">
            
            <ul class="breadcrumb">
                <li class="breadcrumb-item">Home</li>
                <li class="breadcrumb-item">Transport</li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Transport/vehicles">Vehicles</a></li>
                <li class="breadcrumb-item">Add New Vehicle</li>
            </ul>
            
        </div>
        <div class="col-sm-8">
            <ul class="nav nav-tabs tab-item-1">
                <li class="nav-item">
                    <a class="nav-link active" href="#">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle-fill" viewBox="0 0 16 16">
                            <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/>
                        </svg>  Add New Vehicle
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo base_url();?>Transport/vehicles">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ol" viewBox="0 0 16 16">
                            <path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5z"/>
                            <path d="M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317 0-.185-.158-.31-.361-.31-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309.254 0 .424-.145.422-.35-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844.583 0 .96.326.96.756 0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508 0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338v.041zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635V5z"/>
                        </svg>
                        Vehicles</a>
                </li>
            </ul>
            
            <button class="btn btn-block bg-silver" style="background:silver;font-weight:600;">
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-node-plus-fill" viewBox="0 0 16 16">
                    <path d="M11 13a5 5 0 1 0-4.975-5.5H4A1.5 1.5 0 0 0 2.5 6h-1A1.5 1.5 0 0 0 0 7.5v1A1.5 1.5 0 0 0 1.5 10h1A1.5 1.5 0 0 0 4 8.5h2.025A5 5 0 0 0 11 13zm.5-7.5v2h2a.5.5 0 0 1 0 1h-2v2a.5.5 0 0 1-1 0v-2h-2a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 1 0z"/>
                </svg>  Add New Vehicle
            </button>
            <form method="post" action="#">
                <?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 clas="form-group">
                    <label>Vehicle Number</label>
                    <input type="hidden" name="id" value="<?php echo $id;?>" >
                    <input type="text" class="form-control" name="vehicle_number" placeholder="Vehicle Number" value="<?php if($vehicle_number){echo $vehicle_number;}?>">
                </div>
                    
                <div class="form-group">
                    <label>Vehicle Model </label>
                    <input type="text" name="vehicle_model" class="form-control" placeholder="Vehicle Model" value="<?php if($vehicle_model){echo $vehicle_model;}?>">
                </div>
                
                <div class="form-group">
                    <label>R. C. No. </label>
                    <input type="text" name="rcnumber" class="form-control" placeholder="R. C. No." value="<?php if($rcnumber){echo $rcnumber;}?>">
                </div>
                
                <div class="form-group">
                    <label>Vehicle Componey	</label>
                    <input type="text" name="vehicle_componey" class="form-control" placeholder="Vehicle Componey" value="<?php if($vehicle_componey){ echo $vehicle_componey;}?>">
                </div>
                
                <div class="form-group">
                    <label>No Of Seats</label>
                    <input type="number" name="no_of_seats" class="form-control" placeholder="No of seats" value="<?php if($no_of_seats){echo $no_of_seats;}?>">
                </div>
                
                <div class="form-group">
                    <label></label>
                    <input type="text" name="vehicle_owner_name" value="<?php if($vehicle_owner_name){echo $vehicle_owner_name;} ?>" class="form-control" placeholder="Enter vehicle owner name">
                </div>
                
                <div class="form-group">
                    <label></label>
                    <input type="text" name="vehicle_owner_contact_number" value="<?php if($vehicle_owner_contact_number){echo $vehicle_owner_contact_number;}?>" class="form-control" placeholder="Vehicle owner contact number">
                </div>
                
                <div class="form-group">
                    <label></label>
                    <textarea name="vehicle_owner_address" class="form-control" placeholder="Vehicle Owner Address"><?php if($vehicle_owner_address){echo $vehicle_owner_address;}?></textarea>
                </div>
                
                <div class="form-group">
                    <label>Driving Staff</label>
                    <select class="form-control" name="vehicle_driver">
                        <option value="">-- Select driver on duty --</option>
                        <?php
                        $drivers_table='vehicle_driver';
                        $all_drivers=$this->TransportModel->get_data($drivers_table);
                        if($all_drivers){
                            foreach($all_drivers as $drivers){
                                if($drivers['status'] ==1 && $drivers['is_deleted'] ==0 && $drivers['staff_type'] =='Driving Staff'){
                        ?>
                        <option value="<?php echo $drivers['id'];?>" <?php if($vehicle_driver == $drivers['id']){echo "selected";}?> ><?php echo $drivers['driver_name']; ?></option>
                        <?php
                                }
                            }
                        }
                        
                        ?>
                    </select>
                </div>
                
                <div class="form-group">
                    <label>Assitance on Vehicle</label>
                    <select class="form-control" name="assistance_driver">
                        <option value="">-- Select Assitance on Vehicle --</option>
                        <?php
                        if($all_drivers){
                            foreach($all_drivers as $drivers){
                                if($drivers['status'] ==1 && $drivers['is_deleted'] ==0 && $drivers['staff_type'] =='Assistance Staff'){
                        ?>
                        <option value="<?php echo $drivers['id'];?>" <?php if($assistance_driver == $drivers['id']){echo "selected";}?> ><?php echo $drivers['driver_name']; ?></option>
                        <?php
                                }
                            }
                        }
                        ?>
                        
                    </select>
                </div>
                
                <div class="form-group">
                    <button type="submit" name="add_new_vehicle" class="btn btn-sm btn-success">Add New Vehicle</button>
                </div>
                
            </form>
        </div>
        <div class="col-sm-4">
            <?php $this->load->view('erp/transport/quick-links');?>
        </div>
        
    </div>
</div>