<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>





<div id="page-wrapper" >
          <div id="page-inner">

			<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Transport</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>

                        

                        <table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Transport

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->





<script src="assets/js/jquery.js"></script>



<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

		

		$('button:submit').prop('disabled', true);

		

	});

	

});	



</script>   

								

										

                                        

<?php



if(isset($_GET['id']))

{



$id=$_GET['id'];



if(isset($_POST['submit']))

{



$id=$_POST['id'];



$vehicleno = $_POST['vehicleno'];



$width = $_POST['width'];



$height = $_POST['height'];



$loadingcapacity=$_POST['loadingcapacity'];



$name=$_POST['name'];



$phone=$_POST['phone'];



// now we insert it into the database



$date=date('Y-m-d',strtotime($date));



if($vehicleno)

{ 



$in= "update transport set vehicleno='$vehicleno',width='$width',height='$height',loading_capacity='$loadingcapacity',contact_person='$name',phone='$phone' where ID='$id'";



$in1 = mysqli_query($conn,$in) or die(mysqli_error($conn));



if($in1)

{



 header("location:viewtransport.php?s=1");



}



}



else

{



 header("location:viewtransport.php?s=2");



}





}



else

{



$ex=mysqli_query($conn,"select * from transport where ID='".$id."'");

$ex1=mysqli_fetch_assoc($ex);



echo'<form id="course" action="viewtransport.php?id='.$id.'" method="post">



<input type="hidden" name="id" value="'.$id.'" />



<table width="70%" style="margin:auto; line-height:35px;">



<tr><td width="32%">Vehicle No. <span class="red"></span></td><td width="11"></td><td><input class="form-control" style="width:30ch; margin-bottom:10px;" type="text" name="vehicleno" id="required" title="*" value="'.$ex1['vehicleno'].'" autocomplete="off" /></td></tr>



<tr><td>Width </td><td></td><td><input class="form-control" style="width:30ch; margin-bottom:10px;" type="text" name="width" value="'.$ex1['width'].'" autocomplete="off" /></td></tr>



<tr><td>Height </td><td></td><td><input class="form-control" style="width:30ch; width-bottom:10px;" autocomplete="off" type="text" name="height" value="'.$ex1['height'].'" autocomplete="off" /></td></tr>



<tr><td>Loading Capacity </td><td></td><td><input class="form-control" style="width:30ch; margin-bottom:10px;" autocomplete="off" type="text" name="loadingcapacity" value="'.$ex1['loading_capacity'].'" autocomplete="off" /></td></tr>



<tr><td>Caontact Person </td><td></td><td><input class="form-control" style="width:30ch; margin-bottom:10px;" autocomplete="off" type="text" name="name" value="'.$ex1['contact_person'].'" autocomplete="off" /></td></tr>



<tr><td>Phone </td><td></td><td><input class="form-control" style="width:30ch; margin-bottom:10px;" autocomplete="off" type="text" name="phone" value="'.$ex1['phone'].'" autocomplete="off" /></td></tr>



<tr><td colspan="3" style="text-align:center; padding-top:7px;"><button type="submit" name="submit" class="btn btn btn-primary">Submit</button></td></tr>



</table>



</form>';



}



}



else

	{

		

	

		

		

	if (isset($_GET['s'])) 	

	{

	 $status=$_GET['s'];

		

		 if($status=='1')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values Edited Successfully.

				  </div>';				  

		 }

		 if($status=='7')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values Deleted Successfully.

				  </div>';				  

		 }

	}		





echo'<table style="width:99%; margin:11px auto 10px auto;">

                                        

                                        <tr><td style="width:20%;">

                                        <a href="transport.php"><button class="btn btn-minier btn-info">+ Add Transport</button></a>

                                        </td>

                                        

                                        <td style="width:50%;"></td>

                                        

                                        <td style="width:30%;">

                                        

                                        </td>

                                        

                                        </tr>

                                        

                                        </table>';



	echo"<table id='dynamic-table' class='table table-striped table-bordered table-hover'>



	<thead><th style='width:7%;'>S.No</th><th style='width:12%;'>Vehicle No.</th><th style='width:10%;'>Width</th>

	<th style='width:10%;'>Height</th><th style='width:10%;'>Loading Capacity</th><th style='width:13%;'>Contact Person</th>

	<th style='width:12%;'>Phone</th><th style='width:10%;'>Edit</th></thead>";



	$getsite3="select * from transport order by ID asc";

	$getsite4=mysqli_query($conn,$getsite3) or die("Could not get");

	$sno=0;

	while($getsite5=mysqli_fetch_assoc($getsite4))

	{

		$sno=$sno+1;

		

		echo"<tr><td>".$sno."</td><td>".$getsite5['vehicleno']."</td><td>".$getsite5['width']."</td>

		<td>".$getsite5['height']."</td><td>".$getsite5['loading_capacity']."</td><td>".$getsite5['contact_person']."</td>

		<td>".$getsite5['phone']."</td><td>

		

														<div class='hidden-sm hidden-xs btn-group'>";

																

															if($gtp1['type']!='staff')

															{

															echo"<a href='viewtransport.php?id=".$getsite5['ID']."' title='Edit'>

																<i class='ace-icon fa fa-pencil bigger-100 green'></i></a>";

															}

															

														 echo"</div>					  

		</td></tr>";



		}



		echo "</table>";



	}



?>



                                            

                                            							



										<!-- PAGE CONTENT ENDS -->

									</div><!-- /.col -->

								</div><!-- /.row -->

							</div><!-- /.page-content -->

						</div>

					</div><!-- /.main-content -->
					</div><!-- /.main-content -->
					</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

 

}



ob_flush();



?>