<?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();
if (@$_REQUEST['action'] == 'submit')
 {
	if($_REQUEST['txtComid1'] != "")
	{
 		$msg = $obj->insertActualCostSheetName();
	}
	else
	{
		$msg = $obj->completeVoyageEntry($_REQUEST['txtComid2']);
	}
	header('Location:./vessel_in_post_ops.php?msg=3');
 }
if (@$_REQUEST['action1'] == 'submit1')
{
	if (@$_REQUEST['txtuid'] == 1)
	{
		$msg = $obj->insertPerfAtSeaUploadDetails();
		header('Location:./vessel_in_post_ops.php?msg='.$msg);
	}
	else if (@$_REQUEST['txtuid'] == 2)
	{
		$msg = $obj->insertPerfAtPortUploadDetails();
		header('Location:./vessel_in_post_ops.php?msg='.$msg);
	}
}

if (isset($_REQUEST['selYear']) && $_REQUEST['selYear']!="")
{
	$selYear = $_REQUEST['selYear'];
	$_SESSION['selYear'] = $selYear;
}
else
{
	$selYear = $_SESSION['selYear'];
}

if (isset($_REQUEST['selBType']) && $_REQUEST['selBType']!="")
{
	$selBType = $_SESSION['selBType'] = $_REQUEST['selBType'];
}
else if(isset($_SESSION['selBType']))
{
	$selBType = $_SESSION['selBType'];
}
else
{
	unset($_SESSION['selBType']);
	$selBType = '';
}

if(isset($_POST['op']) && isset($_POST['id'])){


	$change_op_query=mysql_query("UPDATE freight_cost_estimate_compare SET OPERATOR='".$_POST['op']."'  WHERE  COMID = '".$_POST['id']."'");
	

	if($change_op_query){
		  echo true;
		  return;
	}

	echo false;
	return;

}




$pagename = basename($_SERVER['PHP_SELF']);

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];	
$rights = $obj->getUserRights($uid,$moduleid,5);
?>
<!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" />

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>



<!-- 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]-->
<style>
		.tablesorter th{
				position: -webkit-sticky;
				background-color: white !important;
				position: sticky;
				top: -10px;
				border-top: #ddd 1px solid !important;
				z-index: 999 !important;
			}
	</style>
</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(5); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-leaf"></i>&nbsp;Ops VC&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">Ops VC&nbsp;&nbsp;&nbsp;>&nbsp;&nbsp;&nbsp;Vessels in Post Ops VC</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<!--   content put here..................-->
				<?php if(isset($_REQUEST['msg'])){
						$msg = $_REQUEST['msg'];
						if($msg == 0){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> In Post Ops at a glance added/updated successfully.
				</div>
				<?php }?>
				<?php if($msg == 1){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-ban"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> In Post Ops at a glance sheet successfully create.
				</div>
				<?php }?>
                <?php if($msg == 4){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-ban"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> new sheet added successfully.
				</div>
				<?php }?>
				<?php if($msg == 2){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> Status changed successfully.
				</div>
				<?php }?>
				<?php if($msg == 3){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> Nomination sent to "History".
				</div>
				<?php }}?>
				<div class="box box-primary">
					<h3 style=" text-align:center;">In Post Ops at a glance - VC</h3>
				
					<form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>"/>
                            <div class="col-xs-6">
                            </div>
                            <div class="col-xs-3">
                                 <select name="selBType" id="selBType" class="form-control" onChange="getSubmit();">
                                 <option value="">---Select Business Type---</option>
								   <?php echo $obj->getBusinessTypeList1($selBType);?>
                                  </select>                  
							</div><!-- /.col -->
						    <div class="col-xs-3">
								  <select name="selYear" id="selYear" class="form-control" onChange="getSubmit();">
                                   <?php echo $obj->getYearList($selYear);?>
                                  </select>                      
							</div><!-- /.col -->
						<div style="height:10px;">
							<input type="hidden" name="txtComid2" id="txtComid2" value="zsd" />
							<input type="hidden" name="txtStatus" id="txtStatus" value="" />
							<input type="hidden" name="txtFileName" id="txtFileName" value="" />
							<input type="hidden" name="action" id="action" value="submit" />
						</div>
                
						<div class="box-body table-responsive" style="overflow-y:auto; max-height:390px;">
							<table class="table table-bordered tablesorter table-striped" id='in_ops_at_a_glance' style="border-collapse: separate;">
								<thead>
									<tr valign="top">
                                        <th align="left">FVF/ Voyage Docs</th>
										<th align="left">Nom ID / Voyage No.</th>
                                        <th align="left">Business Type</th>
										<th align="left">Material Name</th>
										<th align="left">Vessel</th>
										<th align="left">Charterer</th>
                                        <th align="left">CP Date</th>
                                        
                                        <!--<th align="left">Check List</th>-->
										<th align="left">Voyage Financials</th>
										<th align="left">FDA</th>
                                        <!--<th align="left">PDA Request</th>
										<th align="left">Appoint Agent</th>
										<th align="left">SOF</th>	-->
                                        <th align="left">Calculations</th>			
                                        <th align="left">Payment Grid</th>
                                        <?php if($rights == 1){ ?>
										<th align="center">Deactivate</th>
										<?php } ?>
										<th align="center">Operator</th>
										<th align="center">Last Updated By/Time</th>
										<th align="center">Chartering Team</th>
										<?php if($rights == 1){ ?>
										<th align="center">Complete</th>
										<?php } ?>
									</tr>
								</thead>
									<?php 
									if($selBType!='')
									{
									$sql = "select *,freight_cost_estimete_master.PERIODID as PERIODID, (select CONTACT_PERSON from login where login.LOGINID = freight_cost_estimate_compare.OPERATOR) as OPERATOR,freight_cost_estimate_compare.OPERATOR as toChangeOp from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.FCAID= freight_cost_estimate_compare.FCAID WHERE freight_cost_estimate_compare.MODULEID='".$_SESSION['moduleid']."' AND freight_cost_estimate_compare.MCOMPANYID='".$_SESSION['company']."' and freight_cost_estimate_compare.FINAL_ID!='' and freight_cost_estimete_master.FIXED=1 and freight_cost_estimate_compare.STATUS=2 and year(freight_cost_estimete_master.ADD_ON_DATE)='".$selYear."' and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' and COAAID is NULL order by date(freight_cost_estimete_master.FINAL_DATETIME) desc"; 
									
									

									$res = mysql_query($sql);
									$rec = mysql_num_rows($res);
									$i=1;
									$submit = 0;
								   if($rec == 0)
									{
										echo '<tbody>';
								
										echo '</tbody>';
									}else{
									?>
								<tbody>
								<?php while($rows = mysql_fetch_assoc($res)) 
								{ 
								
								$ESTIMATE_TYPE = $obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE");
								$materialid = $obj->getCompareEstimateData($rows['COMID'],"CARGO_ID");
								$fixture_date = $obj->getCompareEstimateData($rows['COMID'],"TRANS_DATE");
								if($fixture_date!="0000-00-00" && $fixture_date!=""){$fixture_date = date('d-m-Y',strtotime($fixture_date));}else{$fixture_date = "";}?>
								
								<tr style="font-size:11px;">
									<td>
                                        <a href="viewestimate.php?id=<?php echo $rows['FCAID'];?>&rttype=3" style="color:green;" title="Click me" >FVF</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="allPdf.php?id=77&fcaid=<?php echo $rows['FCAID'];?>" style="color:green;" title="Click me" ><span class="glyphicon glyphicon-download-alt"></span></a><br/><br/>
                                        <a href="documents.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:green;" title="Click me" >Docs</a>
                                    </td>
                                    <td>
										<?php echo $rows['MESSAGE'];?>/ <br>

										<?php echo $obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NO");?><br/><br/>
												<a style="color:blue;" href="voyage_report_vc.php?vesselimoid=<?php echo $rows['VESSEL_IMO_ID'];?>&comid=<?php echo $rows['COMID'];?>&page=2&type=VC" title="Voyage Departure Data" >Voyage&nbsp;Report</a>
                                    </td>
                                    <td>
                                        <?php echo $obj->getEstimateList($ESTIMATE_TYPE);?>
                                    </td>
                                    <td>
										<?php echo $obj->getCargoNameListForMultipleNamemultiple($materialid);?>
                                    </td>
                                    <td>
									
									<?php
													if ($rows['PERIODID']>0) {
															?>
																<span  style="color:red">
															<?php
													}
												?>
												<span  >
                                        <?php echo $obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"VESSEL_NAME");?>/<br/> <?php echo $obj->getCompareEstimateData($rows['COMID'],"VESSEL_TYPE");?>
										
										</span>
                                    </td>



									<td>
													<?php


$sql1 = "select QTY_TYPE_RADIO,(select NAME from vendor_master where vendor_master.CODE = freight_cost_estimete_master.FGFF_VENDORID) as FGFF_VENDORID,(select NAME from vendor_master where vendor_master.CODE = freight_cost_estimete_master.LUMP_VENDOR) as LUMP_VENDOR,FCAID from freight_cost_estimete_master where COMID='".$rows['COMID']."' and SHEET_NO is not null";

					
                                    $res1 = mysql_query($sql1);
									
						

									$rows1 = mysql_fetch_assoc($res1);


									$ven='';
												
									if($_SESSION['selBType']==2){

										if($rows1['QTY_TYPE_RADIO']==1){
											echo $rows1['LUMP_VENDOR'];
											
											// echo 'dpk';
											}else{

												$sql12 = "select * from freight_cost_estimete_slave12 where FCAID='" . $rows1['FCAID'] . "'";

										


																	$res12 = mysql_query($sql12);
																	$rec12 = mysql_num_rows($res12);

																	while ($rows12 = mysql_fetch_assoc($res12)) {
																		$ven .= $rows12['CUSTOMER'] . "&nbsp,&nbsp";

																	}

																	$ven=rtrim($ven," ,");
																	echo $ven;
											}
											



									}else{

										if($rows1['QTY_TYPE_RADIO']==1){

											echo $rows1['FGFF_VENDORID'];
										}else{
										
											$sql12 = "select (select NAME from vendor_master where vendor_master.CODE = freight_cost_estimete_slave7.QTY_VENDORID) as QTY_VENDORID from freight_cost_estimete_slave7 where FCAID='" . $rows1['FCAID'] . "'";
											//echo $sql12;
											$res12 = mysql_query($sql12);
											$rec12 = mysql_num_rows($res12);

											while ($rows2 = mysql_fetch_assoc($res12)) {

												$ven .= $rows2['QTY_VENDORID'] . "&nbsp,&nbsp";
											}	
											
											$ven=rtrim($ven," ,");
											echo $ven;
											
										}


									}

													
													
													
													?>
												</td>
									<td>
										<?php echo $fixture_date;?><br/><br/><?php echo $obj->getFreightFixtureBasedOnID($rows['FIXTURETYPEID']);?>
									</td>
                                   
									<!--<td>
										
                                        <?php if($rows['FIXTURETYPEID'] == 1){?>
                                            <a href="check_list_tci.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:red;" title="Click me" >Check List</a>	
                                        <?php }else{?>
                                            <a href="check_list.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:red;" title="Click me" >Check List</a>	
                                        <?php }?>
                                        <?php if($rows['FIXTURETYPEID'] == 2){?><br/><br/>
                                            
                                        <?php }?>
                                        
                                    </td>-->
                                    
									<td style="text-align:center;">
                                        
                                        <?php
                                            $sql1 = "select * from cost_sheet_name_master where COMID='".$rows['COMID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
                                            $latestsheet='';
                                            $res1 = mysql_query($sql1);
                                            $rec1 = mysql_num_rows($res1);

											$cost_sheet_id='';
                                            if($rec1 > 0)
                                            {
                                                while($rows1 = mysql_fetch_assoc($res1))
                                                {
												    $latestsheet = $rows1['COST_SHEETID'];
                                                    $href = "./cost_sheet_tci.php?comid=".$rows['COMID']."&cost_sheet_id=".$rows1['COST_SHEETID']."&page=2";
                                                        
                                                        echo "<a href='".$href."'>".str_replace(' ','&nbsp;',$rows1['SHEET_NAME'])."</a><br/>";
                                                        $curr_cst = $rows1['COST_SHEETID'];

														$cost_sheet_id.=$rows1['COST_SHEETID'];	
                                                   
                                                }
                                            }
											if($rights == 1){
											$fcaid = $obj->getLatestCostSheetID($rows['COMID']);	
											if($obj->getEstimateData($fcaid,"FINAL_STATUS")==1  && ($latestsheet=='' || $obj->getTCICostSheetRecDetails($rows['COMID'],$latestsheet)>0))
											{
											?>
												<br/><button class="btn btn-primary btn-flat" data-toggle="modal" data-target="#compose-modal1" type="button" title="Add New CS" onClick="openWin1(<?php echo $rows['COMID'];?>);">A</button>
											<?php }else{?>
											<br/><button class="btn btn-primary btn-flat" type="button" title="Add New CS" onClick="msg();">A</button>
											<?php }}?>	
                                           
                                    </td>
                                    <!--<td>
                                        <a href="agency_letter_generation.php?comid=<?php echo $rows['COMID'];?>&tab=0&page=2">Generate Agency Letter</a>
                                    </td>-->
                                    <td>
                                        <a href="nominate_agent.php?comid=<?php echo $rows['COMID'];?>&page=2">FDA</a>
                                    </td>			
                                    <!--<td>
                                        <a href="sof.php?comid=<?php echo $rows['COMID'];?>&page=2">SOF</a>		
                                    </td>-->
                                    <td>
                                        <?php if($obj->getFreightEstimationStatus($rows['COMID']) == 2 )
                                            {?>
                                        <a href="laytime_calculation.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:blue;" title="Click me" >Laytime</a><br/><br/>
                                        <?php }?>
										<a href="bunker_calculation.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:blue;" title="Click me" >Bunkers</a><br/><br/>
										<a href="soa_report.php?comid=<?php echo $rows['COMID'];?>&page=2" style="color:blue;" title="Click me" >SOA</a>
                                    </td>
			
									<td>

									
                                        <a href="payment_grid.php?voyage_no=<?=$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NO")?>&comid=<?php echo $rows['COMID'];?>&page=2" >View</a><br><br>
                                        <!--<a href="profit_head.php?comid=<?php echo $rows['COMID'];?>&page=2" >Headwise Detail</a>
                                        <br><br>-->
                                        <!--<a href="piclubdeclaration.php?comid=<?php echo $rows['COMID'];?>&page=2" >P & I Club Declaration</a>-->
                                        
                                    </td>
                                    
                                   
                                    <td style="text-align:center;">
									<?php if($rights == 1){ ?>

                                        <a href="#A" title="Deactivate entry" onClick="getValidate2(<?php echo $rows['COMID'];?>,<?php echo $i;?>);">
                                            <i class="fa fa-times" style="color:red;"></i>
                                        </a>
										<?php } ?>

									<?php if($_SESSION['COM_SH'] == 1){ ?>
									<button class="btn btn-primary btn-flat" data-toggle="modal" data-target="#compose-modal2" type="button" title="Compare Sheets" onClick="getCompareSheetData(<?php echo $rows['COMID'];?>);">Compare Sheets</button>
									<?php }?>
									
                                    </td>
                                    



                                    
									<?php if($_SESSION['iutype']=='mgmt_user'){?>
											
											
											<td align="center" valign="middle" class="input-text"><select name="selUser_<?php echo $i;?>" id="selUser_<?php echo $i;?>" class="form-control" onchange="changeOperator('<?=$rows['COMID']?>',this)"><?php echo $obj->getUserListForOp();?></select></td>
											<script> setTimeout(function () {$('#selUser_<?php echo $i?>').val('<?php echo $rows['toChangeOp'] ?>')  }, 100);</script>
										<?php } else{?>
											<td>
										   <?php 
											echo $rows['OPERATOR'];
											?>
										</td>

											<?php } ?>



									<?php
											$sql11 = "select L_UP_TIME,(select CONTACT_PERSON from login where login.LOGINID = freight_cost_estimete_master.L_UPDATED_BY) as LUPNAME from freight_cost_estimete_master where COMID='".$rows['COMID']."' and SHEET_NO is not null";

											$res11 = mysql_query($sql11);
											$rows11 = mysql_fetch_assoc($res11);

											// print_r($rows11);
											// echo $sql11;
											?>
											<td>
											   <?php 
												echo $rows11['LUPNAME'].'-'.$rows11['L_UP_TIME'];
												?>
                                            </td>





									<td>
									   <?php 

									//     $rows1['COST_SHEETID'];
									$s_id = $obj->getLatestCostSheetID($rows['COMID']);
									$obj->viewFreightCostEstimationTempleteRecordsNew($s_id);	 
									// $s_id = $obj->getTCICostSheetID($rows['COMID'],$cost_sheet_id);
									// 		$obj->viewFreightCostEstimationTempleteRecordsNew($s_id);		 


									echo $obj->getCountryName($obj->getFun261());

											// $pic_user_query=mysql_query("SELECT * FROM login WHERE STATUS=1 and USER_TYPE in ('internal_user','mgmt_user') and LOGINID=".$obj->getFun261()."");

											// echo mysql_fetch_assoc($pic_user_query)['CONTACT_PERSON'];

										?>
									</td>

									<?php if($rights == 1){ ?>
									<td>
										<button class="btn btn-primary btn-flat" id="inner-login-button"  type="button" title="Push to History" onClick="getValidate2(<?php echo $rows['COMID'];?>);"><b><span id="d27e53">History</span></b></button>
									</td>
                                    <?php } ?>
								</tr>
								<?php $i++;}}?>
                                <?php }?>
								</tbody>
							</table>
						</div>
					</form>
					<div class="modal fade" id="compose-modal1" tabindex="-1" role="dialog" aria-hidden="true">
						<div class="modal-dialog">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								</div>
								<div class="modal-body">
									<div class="box box-primary">
										<div class="box-body no-padding">
											<form name="frm2" id="frm2" method="post" enctype="multipart/form-data" action="<?php echo $pagename;?>">
												<div class="row invoice-info" style="padding:2%">
													<div class="col-sm-12 invoice-col">
														Please enter Voyage Financials Name and Submit
														<address>
															<input type="text" name="txtFile" id="txtFile" class="form-control" autocomplete="off" value="<?php echo $obj->getNomDetailsData($comid,"FREIGHT_RATE");?>" placeholder="Voyage Financials Name" />
															<input type="hidden" name="txtComid1" id="txtComid1" />
														</address>
													</div><!-- /.col -->
												</div>
												<div class="row invoice-info">
													<div class="col-sm-12 invoice-col" style="text-align:center;">
														 <button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate();">Submit</button>
														 <input type="hidden" name="action" id="action" value="submit" />
													</div><!-- /.col -->
												</div>
											</form>
										</div><!-- /.box-body -->
									</div>
								</div>
							</div><!-- /.modal-content -->
						</div><!-- /.modal-dialog -->
					</div>					
				</div>
				<!--   content ends here..................-->

				<div class="modal fade" id="compose-modal2" tabindex="-1" role="dialog" aria-hidden="true">
					<div class="modal-dialog" style="width:98%">
					    <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;Compare Sheets</h4>
                            </div>
                            <form name="frm2" id="frm2" enctype="multipart/form-data" action="<?php echo $pagename;?>"/>
                            <div class="modal-body" id="div_3" style="overflow:auto;">
                            </div>
                            
                            </form>
					    </div>
				    </div><!-- /.modal-dialog -->
				</div>		


                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<script src="../../js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="../../js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src='../../js/jquery.autosize.js'></script>
<script type="text/javascript">
$(document).ready(function(){ 
	$('.sidebar-toggle').trigger('click');
$("#in_ops_at_a_glance").dataTable({
	"iDisplayLength": 100, 
	bStateSave: true, 
	stateDuration: -1
    });


	var voyid = '<?= $_REQUEST['voy_no']?>';


	if(voyid!=''){

		$('.dataTables_filter').find('input').val(voyid).keyup();

	}


$(function() {
      $("[id^=alarm_]").tooltip();
});

//for uploading........
 $('#photoimg').live('change', function(){ 
 			$("#cpDiv_"+$("#txtVar").val()).append("<span id='labelDiv_"+$("#txtVar").val()+"_"+$("#txtID_"+$("#txtVar").val()).val()+"'>abc</span>");
			$("#labelDiv_"+$("#txtVar").val()+"_"+$("#txtID_"+$("#txtVar").val()).val()).html('<img src="../../images/loader.gif" alt="Uploading...." width="20" height="10"  />');
			$("#imageform").ajaxForm({
						target: '#labelDiv_'+$("#txtVar").val()+'_'+$("#txtID_"+$("#txtVar").val()).val()
			}).submit();
			var id = $("#txtID_"+$("#txtVar").val()).val();
			id = (id - 1) + 2;
			$("#txtID_"+$("#txtVar").val()).val(id);
			$.modal.close();
 			});
//....................
}); 
function getData()
{
	$("#in_ops_at_glance tbody").empty();
	$("#in_ops_at_glance tbody").html('<tr><td height="200" colspan="17" align="center" ><img src="../../images/loading.gif" /></td></tr>');
	$.post("options.php?id=43",{selVName:""+$("#selVName").val()+""}, function(html) {
	$("#in_ops_at_glance tbody").empty();
	$("#in_ops_at_glance tbody").append(html);
	});
}

function openWin1(comid)
{
	$('#basic-modal-content').modal();
	$("#txtComid1").val(comid);
	$("#simplemodal-container").css({"height":"150px"});
}

function getValidate()
{
	if($("#txtFile").val() != "")
	{
		return true;
	}
	else
	{
		jAlert('Please fill the file name', 'Alert');
		return false;
	}
}

function msg()
{
	jAlert('Please make sure the last cost sheet is Submit to Accounts', 'Alert');
}

function openWin2(var1,comid)
{
	$('#basic-modal-content1').modal();
	$("#txtVar").val(var1);
	$("#txtMappingid").val(comid);
	$("#simplemodal-container").css({"width":"300px","height":"50px"});
}	

function openWin(comid,vesselid,id)
{
	$('#basic-modal').modal();
	$("#txtMapid").val(comid);
	$("#txtVesselid").val(vesselid);
	$("#txtuid").val(id);
	$("#simplemodal-container").css({"width":"300px","height":"50px"});
}

function getValid()
{
	if($('#txtfile').val() == '')
	{
		jAlert('Please choose the file', 'Alert');
		return false;
	}
	else
	{
		var name = $('#txtfile').val();
		name = name.split('.');
		if(name[1] == 'txt')
		{
			return true;
		}
		else
		{
			jAlert('Please choose only .txt file', 'Alert');
			$('#txtfile').val('');
			return false;
		}
	}
}

function getPdfForSea(comid,vesselid)
{
	location.href='allPdf.php?id=12&comid='+comid+'&vesselid='+vesselid;
}

function getValidate2(var1)
{
	jConfirm('Are you sure to send this Nom ID to history ?', 'Confirmation', function(r) {
		if(r){ 
			$("#txtComid2").val(var1);
			document.frm1.submit();
		}
		else{return false;}
		});	
}

function getSubmit()
{ 
    $("#action").val("");
	document.frm1.submit();
}




function getCompareSheetData(comid)
{
	$("#div_3").empty();$("#txtCOMID").val('');
	$("#div_3").html('<div style="height:200px;text-align:center;"><img src="../../img/loading.gif" /></div>');
	$.post("options.php?id=131",{comid:""+comid+"",page:'2'}, function(html) {
		$("#div_3").empty();
		$("#div_3").html(html);
		$("#txtCOMID").val(comid);
		$(".autosize").autosize({append: "\n"});
		
		for(var i = 1;i<=$("#txtRowCount").val();i++)
		{
		    var amount = parseFloat($("#txtDifference_"+i).val());
			if(isNaN(amount)){amount = 0;}
		    if(amount < 0)
			{
			    $("#txtDifference_"+i).css("color","red" );
			}
			else
			{
			    $("#txtDifference_"+i).css("color","green" );
			}
		}
		
		for(var i = 1;i<=$("#txtIdentity8ID").val();i++)
		{
		    var amount = parseFloat($("#txtDifference_8_"+i).val());
			if(isNaN(amount)){amount = 0;}
		    if(amount < 0)
			{
			    $("#txtDifference_8_"+i).css("color","red" );
			}
			else
			{
			    $("#txtDifference_8_"+i).css("color","green" );
			}
		}
		
	});
}





function getjsPDF(){

var HTML_Width = $(".canvas_div_pdf").width();
var HTML_Height = $(".canvas_div_pdf").height();
var top_left_margin = 15;
var PDF_Width = HTML_Width+(top_left_margin*2);
var PDF_Height = (PDF_Width*1.5)+(top_left_margin*2);
var canvas_image_width = HTML_Width;
var canvas_image_height = HTML_Height;

var totalPDFPages = Math.ceil(HTML_Height/PDF_Height)-1;


html2canvas($(".canvas_div_pdf")[0],{allowTaint:true}).then(function(canvas) {
	canvas.getContext('2d');
	
	console.log(canvas.height+"  "+canvas.width);
	
	
	var imgData = canvas.toDataURL("image/jpeg", 1.0);
	var pdf = new jsPDF('p', 'pt',  [PDF_Width, PDF_Height]);
	pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin,canvas_image_width,canvas_image_height);
	
	
	for (var i = 1; i <= totalPDFPages; i++) { 
		pdf.addPage(PDF_Width, PDF_Height);
		pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
	}
	
	pdf.save("Compare-Sheet-Vc.pdf");
});
};


function changeOperator(table_id,clx){

	let op=$(clx).val()

	$.ajax({
		
			type: "POST",
			data: { id: table_id, op: op },
			dataType: "json",
			
			success: function (result) {
				// when call is sucessfull
				if(result){
					location.reload();
				}
				},
				error: function (err) {
				// check the err for error details
			
				}
		}); 

}










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