<?php
session_start();
if(!isset ($_SESSION['user_id'])){
	header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.php');
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	
	 <?php
  include 'title.php';
         ?>
	
	
	<link type = "image/png" rel="icon" href="images/kreen.png" />

    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
  <!-- jquery ui -->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<style>
  .error {
    color: #F00;
}  
</style>
	
	 <style>
        
        h1,h2,h3,h4,h5,h6{
            margin: 0;
            padding: 0;
        }
        p{
            margin: 0;
            padding: 0;
        }
        .container7{
            width: 100%;
            margin-right: auto;
            margin-left: auto;
			background-color: #F6F6F6;
        }
        .brand-section{
           background-color: #0d1033;
           padding: 10px 40px;
		   border: 1px solid gray;
        }
		.brand-section1{
           background-color: #F6F6F6;
           padding: 10px 40px;
		   font-size:7px;
		   border: 1px solid gray;
        }
        .logo{
            width: 50%;
        }
		.tbl{
		background-color: #F6F6F6;	
		}

        .row{
            display: flex;
            flex-wrap: wrap;
        }
        .col-6{
            width: 50%;
            flex: 0 0 auto;
			/*background-color: #F6F6F6;*/
        }
        .text-white{
            color: #fff;
			font-size:18px;
        }
		.text-black{
			font-size:20px;
        }
        .company-details{
            float: right;
            text-align: right;
        }
        .body-section{
            padding: 16px;
            border: 1px solid gray;
			background-color: #F6F6F6;
        }
        .heading{
            font-size: 15px;
            margin-bottom: 08px;
        }
        .sub-heading{
             color: #262626;
            margin-bottom: 05px;
			padding-left:6px;
			font-size:12px;
			text-align:justify;
        }
        table{
            background-color: #fff;
            width: 100%;
            border-collapse: collapse;
        }
        table thead tr{
            border: 1px solid #111;
            background-color: #f2f2f2;
        }
        table td {
            vertical-align: middle !important;
            text-align: center;
        }
        table th, table td {
            padding-top: 08px;
            padding-bottom: 08px;
        }
        .table-bordered{
            box-shadow: 0px 0px 5px 0.5px gray;
        }
        .table-bordered td, .table-bordered th {
            border: 1px solid #dee2e6;
        }
        .text-right{
            text-align: end;
        }
        .w-20{
            width: 20%;
        }
        .float-right{
            float: right;
        }
    </style>
	
	
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>
	
	
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
             <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>


           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="clientFiles.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$file_id = $_GET['i'];
				 $sql81 = "SELECT client_files.vessel_flight,client_files.sline,client_files.eta,client_files.consignee,client_files.destination,client_files.goods,client_files.file_no,clients.client_fname,clients.client_lname,entrypoint_type.name,entrypoint_name.ent_name,client_files.b_lNo,client_files.tra_RefNo,clients.client_email,clients.client_phone,clients.client_address,client_files.file_openDate,client_files.file_closeDate,client_files.fileStatus FROM clients,client_files,entrypoint_type,entrypoint_name WHERE client_files.file_id = {$file_id} and clients.client_id=client_files.client_id and entrypoint_type.entryId=client_files.entryId and entrypoint_name.entryName_id=client_files.entryName_id";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$fileNo = $data81['file_no'];
							$clientName = $data81['client_fname'].'&nbsp&nbsp'.$data81['client_lname'];
							$entrypoint_type = $data81['name'];
							$entrypoint_name = $data81['ent_name'];
							$B_LNO = $data81['b_lNo'];
							$Tra_RefNo = $data81['tra_RefNo'];
							$Consignee = $data81['consignee'];
							$Vesssel_Flight = $data81['vessel_flight'];
							$sline = $data81['sline'];
							$eta = $data81['eta'];
							$destination = $data81['destination'];
							$goods = $data81['goods'];
							$phoneNumber = $data81['client_phone'];
							$emailAddress = $data81['client_email'];
							$clientAddress = $data81['client_address'];
							$file_openDate = $data81['file_openDate'];
							$file_closeDate = $data81['file_closeDate'];
							$file_status =  $data81['fileStatus'];
				            }
							$fopenDate = date('d-m-Y', strtotime($file_openDate));
							$fcloseDate = date('d-m-Y', strtotime($file_closeDate));
							
							if(empty($file_closeDate)){
							$fileCloseDate == '';	
							}else{
							$fileCloseDate == $fcloseDate;	
							}
							
							
							
							if($file_status==0){
							$fstatus  = 'Pending File';
							}else{
							$fstatus  = 'Closed File';	
							}
							
				 $phone = substr($phoneNumber, 3);
	             $phone_number = '0'.$phone;
				?>
					
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
				  
				
				<div class="x_content" style="overflow: auto;">
				
				 <form class="form-horizontal" method="POST" id="id_frm" action="process_mail.php">
				 
				 <input type="hidden" name="file_id"  value="<?php echo $file_id; ?>" />
				 
				   <div class="container7">
        <div class="brand-section">
            <div class="row">
                <div class="col-6">
                    <h1 class="text-white">Kreen Logistics Co Ltd</h1>
                </div>
                <div class="col-6">
                    <div class="company-details">
                        <p class="text-white">+255764508508</p>
						<p class="text-white">info@kreenlogistics.co.tz</p>
                    </div>
                </div>
            </div>
        </div>
		
		<div class="brand-section1">
            <div class="row">
			<table border="0" class="tbl" style="width:100%">
			   <tr>
			   <td style="width:100%">
                <div class="col-12">
                    <h1 class="text-black"><center>CLIENT FILE</center></h1>
                </div>
				</td>
			   </tr>
			</table>	
				
				
            </div>
        </div>

        <div class="body-section">
            <div class="row">
			   <table border="0" class="tbl" style="width:100%">
			   <tr>
			   <td style="width:50%">
                <div class="col-6">
                    <p class="sub-heading"><b>B/L No:</b><?php print $B_LNO; ?></p>
                    <p class="sub-heading"><b>TRA Ref Number:</b> <?php print $Tra_RefNo; ?> </p>
                    <p class="sub-heading"><b>Client:</b> <?php print $clientName; ?> </p>
					<p class="sub-heading"><b>Goods:</b> <?php print $goods; ?> </p>
					<p class="sub-heading"><b>S.LINE:</b> <?php print $sline; ?> </p>
					<p class="sub-heading"><b>Destination:</b> <?php print $destination; ?> </p>
					<p class="sub-heading"><b>Entry Point:</b><b><?php print $entrypoint_type; ?></b>&nbsp&nbsp<b><?php print $entrypoint_name; ?></b></p>
					<p class="sub-heading"><b>Client Email Address:</b> <?php print $emailAddress; ?> </p>
					<p class="sub-heading"><b>Client Address:</b> <?php print $clientAddress; ?> </p>
					
                </div>
				</td>
				<td style="width:50%">
                <div class="col-6">
                    <p class="sub-heading"><b>File No:</b>  <?php print $fileNo; ?></p>
                    <p class="sub-heading"><b>File Status:</b>  <?php print $fstatus; ?> </p>
					<p class="sub-heading"><b>Consignee:</b>  <?php print $Consignee; ?> </p>
					<p class="sub-heading"><b>Vessel/Flight: </b> <?php print $Vesssel_Flight; ?> </p>
					<p class="sub-heading"><b>E.T.A: </b> <?php print $eta; ?>  </p>
					<p class="sub-heading"><b>Client PhoneNumber:</b> <?php print $phone_number; ?> </p>
					<p class="sub-heading"><b>File Open Date: </b> <?php print $fopenDate; ?>  </p>
					<p class="sub-heading"><b>File Close Date: </b> <?php print $fileCloseDate; ?>  </p>
					
                </div>
				</td>
				</tr>
				</table>
            </div>
        </div>

        <div class="body-section">
            <h3 class="heading">Expenses</h3>
            <br>
          
            <table class="table-bordered">
                <thead>
                    <tr>
					    <th><center>S/N</center></th>
                        <th><center>Standard Expenses</center></th>
                        <th class="w-15"><center>Amount</center></th>
                        <th class="w-15"><center>Paid By</center></th>
                        <th class="w-15"><center>Invoice No</center></th>
						<th class="w-15"><center>Debit Note</center></th>
                    </tr>
                </thead>
                <tbody>
				
				<?php
  $procRequestSql = "SELECT standard_expenses.name,client_fileexpenses.amount,client_fileexpenses.chargeable_to,client_fileexpenses.invoice,client_fileexpenses.debitNote FROM standard_expenses,client_fileexpenses WHERE standard_expenses.standardexp_id=client_fileexpenses.standardexp_id and client_fileexpenses.file_id = {$file_id}";
  $procRequestResult = $conn->query($procRequestSql);
                    $x = 1;
					$no = 1;
    while($procRequestData = $procRequestResult->fetch_array()){ 

    ?>
				
                    <tr>
					    <td><?php print $no;  ?></td>
                        <td><?php print $procRequestData['name'];  ?></td>
                        <td><?php print number_format($procRequestData['amount'],2);  ?></td>
                        <td><?php print $procRequestData['chargeable_to'];  ?></td>
                        <td><?php print $procRequestData['invoice'];  ?></td>
						<td><?php print $procRequestData['debitNote'];  ?></td>
                    </tr>
                    
					
				<?php
				$no++;
}
?>	
					
	
					
                </tbody>
            </table>


        </div>
		
		
		       <div class="body-section">
            <h3 class="heading">List Of Uploaded  Documents</h3>
            <br>
          
            <table class="table-bordered">
                <thead>
                    <tr>
					    <th><center>S/N</center></th>
                        <th><center>File Extension</center></th>
						<th class="w-50"><center>File</center></th>
                    </tr>
                </thead>
                <tbody>
				
				<?php
  $procRequestSql2 = "SELECT *  FROM client_docs where file_id={$file_id}";
  $procRequestResult2 = $conn->query($procRequestSql2);
                    $x2 = 1;
					$no2 = 1;
    while($procRequestData2 = $procRequestResult2->fetch_array()){ 
              $fileName = $procRequestData2['fileName'];
	$fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
	
	//if($fileExtension=='pdf' or $fileExtension=='doc' or $fileExtension=='docx' or $fileExtension=='xlsx' or $fileExtension=='txt' or $fileExtension=='csv'){
   $button = '<!-- Single button -->
	<div class="btn-group">
	    <a class="btn btn-primary" href="files/'.$fileName.'"  id="editOrderModalBtn"> <i class="glyphicon glyphicon-download"></i></a>
	</div>';
       //}
	   
	   //else{
	
     //$imageUrl = substr($procRequestData2['fileName'], 3);	
	 //$button = "<img class='img-round' src='".$imageUrl."' style='height:100px; width:100px;'  />";
		   
     //$button ='No File Uploaded';
       //}
    ?>
				
                    <tr>
					    <td><?php print $no2;  ?></td>
                        <td><?php print $fileExtension;  ?></td>
                        <td><?php print $button;  ?></td>
                    </tr>
                    
					
				<?php
				$no2++;
}
?>	
					
	
					
                </tbody>
            </table>


        </div>

        <div class="body-section">
            <p>&copy; Copyright <?php print date("Y");  ?> - Kreen Logistics. All rights reserved. 
            </p>
        </div>      
           </div> 
		   
		    </br></br>
			
			
			<div class="controls">
			  <div class="row">
			  
			  <div class="col-sm-12">
			  <div class="form-group">
                 <label for="form_name">Message: </label>
                 
			
			<textarea id="message" rows="10" cols="50" name="message" class="form-control" style="margin-left:0%;" autocomplete="off"> </textarea>
			<br/>
                         <label for="message" class="error" generated="true"></label>
			
                      
                </div>
			   </div>
			
				
			  </div>	  
              </div>
		   
		   
		   <div class="controls">
			  <div class="row">
			
			<div class="col-sm-12">
			  <div class="form-group submitButtonFooter">
			 
			  <button type="submit" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Send Email</button>
                    </div>
			  </div>
			  
			  </div>
                </div>

                 </form>            
					
				</div>  
               
				
				
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	<script>
//$(function(){



 $("#id_frm").validate({
        rules: {
			
			"message": {
                required: true
            }
            
        },
        messages: {
			
			"message": {
                required: "Please Compose Message."
            }
			
		
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });


</script>

   
	
    <!-- Must Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	<!-- file input -->
	<script src="assests/plugins/fileinput/js/plugins/canvas-to-blob.min.js'); ?>" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/sortable.min.js" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/purify.min.js" type="text/javascript"></script>
	<script src="assests/plugins/fileinput/js/fileinput.min.js"></script>	


	<!-- DataTables -->
	<script src="assests/plugins/datatables/jquery.dataTables.min.js"></script>

  </body>
</html>



<?php
}
?>