<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;

if(isset($_REQUEST['selBType']) && $_REQUEST['selBType']!="")
{
	$selBType = $_REQUEST['selBType'];
}
else if(isset($_SESSION['selBType']))
{
	$selBType = $_SESSION['selBType'];
}
else
{
	$selBType = '';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<link href="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
</head>
    <body class="skin-blue fixed">
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(161); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-folder"></i>&nbsp;Dashboard&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                         <li><a href="../"><i class="fa fa-home"></i> Home</a></li>
						 <li class="active">To - Do List</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<!--   content put here..................-->
				<div class="box box-primary">
				<h3 style=" text-align:center;">To - Do List</h3>
				<form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>"/>
					
					<div align="right">
						<!--<a href="#" title="Pdf" onClick="getPdf();"><button class="btn btn-default" style="margin-right: 5px;" type="button"><i class="fa fa-download"></i>Generate PDF</button></a>-->
					</div>
					
                    <div style="overflow:auto;">
                        <div class="box-body table-responsive" style="overflow:auto;">
                     		<table id="sf_list" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th align="left" valign="top" width="3%">#</th>
                                    <th align="left" valign="top" width="5%">Vessel</th>
									<th align="left" valign="top" width="5%">Voyage No</th>	
									<th align="left" valign="top" width="5%">Form Name</th>	
									<th align="left" valign="top" width="5%">Invoice/Advice No.</th>
									<th align="left" valign="top" width="5%">Type</th>
									<th align="left" valign="top" width="5%">Vendor Name</th>
                                    <th align="left" valign="top" width="6%">Status</th>
									<th align="left" valign="top" width="10%">Date</th>
									<th align="left" valign="top" width="10%">Documents</th>
                                    <th align="left" valign="top" width="5%">Edit Link</th>
                                </tr>
                                </thead>
                                <tbody id="tbody1">
							<?php $i=0;
								  $sel = "select * from alert_master where SHOW_STATUS=1 and SENDTO='".$_SESSION['uid']."' order by ADDONDATE DESC";

								  
								  $result = mysql_query($sel);
								  while($rows = mysql_fetch_assoc($result))
								  {$i++;
								      $voyagename = '';$voyageno = '';$status = '';$comid='';$vendorname = '';$invoiceno = '';$formname = '';
									  if($rows['IDENTIFY']=='FREIGHT INVOICE')
									  {
									      $sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, I_TYPE from freight_invoice_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $invoiceno  = $rows1['MESSAGE'];
										  $formname = $rows['I_TYPE'].' Freight Invoice';
										  $paytype = 'Receivable';
									  }
									  
									  if($rows['IDENTIFY']=='OTHER INVOICE')
									  {
									      $sql1 = "select COMID, INVOICEID, MESSAGE, VENDOR, STATUS, P_TYPE from other_invoice_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $invoiceno  = $rows1['MESSAGE'];
										  $formname = $rows['P_TYPE'];
										  $paytype = 'Receivable';
									  }
									  
									  if($rows['IDENTIFY']=='HIRE STATEMENT')
									  {
									      $sql1 = "select COMID, INVOICEID, INVOICE_NO, STATUS from invoice_hire_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $vendorname = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows1['COMID'],"DTCVENDORID"));
										  $invoiceno  = $rows1['INVOICE_NO'];
										  $formname = 'Hire Statement';
										  $paytype = 'Payable';
									  }
									  
									  if($rows['IDENTIFY']=='PAYMENT')
									  {
									      $sql1 = "select COMID, REQ_ID, PAYMENT_NO, VENDOR, STATUS, NAME from request_master where REQ_ID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $invoiceno  = $rows1['PAYMENT_NO'];
										  $formname = $rows1['NAME'];
										  $paytype = 'Payable';
									  }
									  
									  
									  if($rows['IDENTIFY']=='LAYTIME')
									  {
									      $sql1 = "select COMID, LAYTIME_ID, SUBMITID, PORT, PORTID, VENDOR from laytime_master where LAYTIME_ID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['SUBMITID'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $invoiceno  = $rows1['PORT'].' - '.$obj->getPortNameBasedOnID($rows1['PORTID']);
										  $formname = 'LAYTIME';
										  $paytype = 'Receivable';
									  }
									  
									  if($rows['IDENTIFY']=='FDA')
									  {
									      $sql1 = "select COMID, LP_COST_ID, SUBMITID, PORT, PORTID, RANDOMID from loadport_cost_master where LP_COST_ID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCompareEstimateData($rows1['COMID'],"VOYAGE_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['SUBMITID'];
										  $invoiceno  = $rows1['PORT'].' - '.$obj->getPortNameBasedOnID($rows1['PORTID']);
										  
										  $sqltc = "SELECT PORT_COSTLP_VENDOR, PORT_COSTDP_VENDOR, PORT_COSTTP_VENDOR from freight_cost_estimete_slave1 where FCAID='".$obj->getCompareEstimateData($rows1['COMID'],"FCAID")."' and RANDOMID='".$rows1['RANDOMID']."'";
										  $restc 	= mysql_query($sqltc);
										  $rectc 	= mysql_num_rows($restc);
										  $rowstc = mysql_fetch_assoc($restc);
										  if($rows1['PORT'] == 'LP')
										  {
										  	  $vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTLP_VENDOR']);
										  }
										  if($rows1['PORT'] == 'DP')
										  {
										  	  $vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTDP_VENDOR']);
										  }
										  if($rows1['PORT'] == 'TP')
										  {
										  	  $vendorname = $obj->getVendorListNewBasedOnID($rowstc['PORT_COSTTP_VENDOR']);
										  }
										  
										  $formname = 'FDA';
										  $paytype = 'Payable';
									  }
									  
									  
									  if($rows['IDENTIFY']=='HIRE INVOICE')
									  {
									      $sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE from invoice_tchire_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'],"TC_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $invoiceno  = $rows1['INVOICE_NO'];
										  
										  $sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getCharteringEstimateTCData($rows1['COMID'],"TCOUTID")."' and RANDOMID='".$rows1['RANDOMID']."'";
										  $restc 	= mysql_query($sqltc);
										  $rectc 	= mysql_num_rows($restc);
										  $rowstc = mysql_fetch_assoc($restc);
										  $vendorname = $obj->getVendorListNewBasedOnID($rowstc['TTL_REV_VENDOR']);
										  $formname = ucwords($rows['INVOICE_TYPE']).' TC Hire Invoice';
										  $paytype = 'Receivable';
									  }
									  
									  if($rows['IDENTIFY']=='TC HIRE STATEMENT')
									  {
									      $sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, INVOICE_TYPE from invoice_hiretc_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'],"TC_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $invoiceno  = $rows1['INVOICE_NO'];
										  
										  $sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getCharteringEstimateTCData($rows1['COMID'],"TCOUTID")."' and RANDOMID='".$rows1['RANDOMID']."'";
										  $restc 	= mysql_query($sqltc);
										  $rectc 	= mysql_num_rows($restc);
										  $rowstc = mysql_fetch_assoc($restc);
										  $vendorname = $obj->getVendorListNewBasedOnID($rowstc['TC_FINAL_HIERAGE_VENDOR']);
										  $formname =  $rows['INVOICE_TYPE'].' TC Hire Statement';
										  $paytype = 'Payable';
									  }
									  
									  if($rows['IDENTIFY']=='OTHER TC INVOICE')
									  {
									      $sql1 = "select COMID, INVOICEID, INVOICE_NO, RANDOMID, STATUS, VENDOR, SHORT_DESC from invoice_tcother_master where INVOICEID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'],"TC_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $invoiceno  = $rows1['INVOICE_NO'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $formname =  $rows['SHORT_DESC'];
										  $paytype = 'Receivable';
									  }
									  
									  if($rows['IDENTIFY']=='OTHER TC PAYMENT')
									  {
									      $sql1 = "select PAYMENTID, COMID, INVOICE_NO, RANDOMID, STATUS, VENDOR, SHORT_DESC from payment_tcother_master where PAYMENTID='".$rows['IDENTIFYID']."'";
										  $result1 = mysql_query($sql1) or die($sql1);
										  $rows1 = mysql_fetch_assoc($result1);
										  
										  $comid = $rows1['COMID'];
										  $voyageno = $obj->getCharteringEstimateTCData($rows1['COMID'],"TC_NO");
										  $voyagename = $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
										  $status = $rows1['STATUS'];
										  $invoiceno  = $rows1['INVOICE_NO'];
										  $vendorname = $obj->getVendorListNewBasedOnID($rows1['VENDOR']);
										  $formname =  "Other TC Payment";
										  $paytype = 'Payable';
									  }
									  
									  
								  ?>
									<tr>
									  <td><?=$i;?></td>
									  <td><?=$voyagename;?></td>
									  <td><?=$voyageno;?></td>
									  <td><?=$formname;?></td>
									  <td><?=$invoiceno;?></td>
									  <td><?=$paytype;?></td>
									  <td><?=$vendorname;?></td>
									  <td><strong>
								      <?php if($status==0){?>
									        <span class="label label-primary">Submit to Edit</span>
									  <?php }
									        else if($status==1){?>
									        <span class="label label-danger">Level 1 Approval Pending Since <?=$obj->getDaysDifference($rows['ADDONDATE'],date('Y-m-d',time()));?> Days</span>
									  <?php }
									        else if($status==2){?>
									        <span class="label label-warning">Sent for Review To Creator Since <?=$obj->getDaysDifference($rows1['ADDONDATE'],date('Y-m-d',time()));?> Days</span>
									  <?php } 
									        else if($status==3){?>
									        <span class="label label-danger">Level 2 Approval Pending Since <?=$obj->getDaysDifference($rows['ADDONDATE'],date('Y-m-d',time()));?> Days</span>
									  <?php }
									        else if($status==4){?>
									        <span class="label label-danger">Sent for Review To Approver 1 Since <?=$obj->getDaysDifference($rows1['ADDONDATE'],date('Y-m-d',time()));?> Days</span>
									  <?php }
									        else{?>
											<span class="label label-warning">Payment Received/Paid Pending Since <?=$obj->getDaysDifference($rows['ADDONDATE'],date('Y-m-d',time()));?> Days</span>
									  <?php }?>
									  </strong>
									  </td>
									  <td><?=date('d-m-Y',strtotime($rows['ADDONDATE']));?></td>
									  <td><a href="documents.php?comid=<?=$comid;?>&amp;page=1" style="color:green;" target="_blank" title="Click me">Docs</a></td>
									  <td>
									<?php if($rows['REDIRECTTO']!=''){?>
									  <a href="<?=$rows['REDIRECTTO'];?>&alertid=<?=$rows['ALERTID'];?>" target="_blank"><i class="fa fa-edit "></i> View</a>
									<?php }else{?>
									  <a href="payment_grid.php?comid=<?=$comid;?>&page=<?=$obj->getCompareTableData($comid, 'STATUS');?>&alertid=<?=$rows['ALERTID'];?>" target="_blank"><i class="fa fa-edit "></i> View</a>
									<?php }?>  
									  </td>
									</tr>
							<?php }?>
                                </tbody>
                            </table>
                        </div>
                    </div>
				</form>
				</div>
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<link href="../../css/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<script src='../../js/plugins/datatables/jquery.dataTables.min.js'></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	
	$("#sf_list").DataTable();
});


</script>
		
</body>
</html>