<?php
session_start();
require_once("../../includes/Numbertowordconversion.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
include_once("../../includes/fpdf.php");

@$i = $_REQUEST['id'];
$ret = "";
switch ($i)
{
  case 1:
        $ret = create_port_positions_pdf();
				break;
  case 2:
        $ret = create_generate_agency_letter_pdf();
				break;
  case 3:
        $ret = create_generate_agency_app_letter_pdf();
				break;
  case 4:
        $ret = cost_sheet_pdf();
				break;
  case 5:
        $ret = tc_trip_pdf();
				break;
  case 6:
        $ret = req_pdf();
				break;
  case 7:
        $ret = vendor_wise_payment_pdf();
				break;
  case 8:
        $ret = vendor_wise_request_pdf();
				break;
  case 9:
        $ret = daily_log_pdf();
				break;
  case 10:
        $ret = cargo_open_position_pdf();
				break;
  case 11:
        $ret = projected_cash_flow_pdf();
				break;
  case 12:
        $ret = bunker_voyage_pdf();
				break;
  case 13:
        $ret = cost_sheet_tmp_pdf();
				break;
  case 14:
        $ret = shipment_register_pdf();
				break;
  case 15:
        $ret = create_sof_pdf();
				break;
  case 16:
        $ret = create_laytime_pdf();
				break;
  case 17:
        $ret = create_pda_pdf();
				break;
  case 18:
        $ret = vessel_wise_payment_pdf();
				break;
	case 19:
        $ret = sensitivity_analysis_tci();
				break;
  case 20:
        $ret = sensitivity_analysis_vci();
				break;
  case 21:
        $ret = sensitivity_analysis_tci_tmp();
				break;
   case 22:
        $ret = cost_sheet_pdf_actual();
				break;
	case 23:
        $ret = baf_pdf();
				break;
	case 24:
        $ret = getCOAReportDataPdf();
				break;
	case 25:
        $ret = create_pre_arrival_pdf();
				break;
	case 26:
        $ret = checklistpdf();
				break;
	case 27:
        $ret = invoicepdf();
				break;
	case 28:
        $ret = TciChecklistpdf();
				break;
	 case 29:
        $ret = agent_list_pdf();
				break;
	 case 30:
        $ret = spot_fixture_pdf();
				break;
	case 31:
        $ret = demmurage_summary_pdf();
				break;
	case 32:
        $ret = owner_broker_fixture_pdf();
				break;
	case 33:
        $ret = pni_club_declaration_pdf();
				break;
	case 34:
        $ret = dead_freight_summery_pdf();
				break;
	case 35:
        $ret = profitability_pdf();
				break;
	case 36:
        $ret = aging_payable_pdf();
				break;
	case 37:
        $ret = aging_receivable_pdf();
				break;
	case 38:
        $ret = invoice_hire_pdf();
				break;
	case 39:
        $ret = voyage_financial_estimates_pdf();
				break;
	case 40:
        $ret = commercial_parameter_pdf();
				break;
	case 41:
        $ret = nomination_cost_sheet_pdf();
				break;
	case 42:
        $ret = inops_at_glance_insert_cost_sheet_pdf();
				break;
	case 43:
        $ret = inops_at_glance_update_cost_sheet_pdf();
				break;
	case 44:
        $ret = inops_at_glance_check_list_pdf();
				break;
	case 45:
        $ret = voyage_financial_pdf();
				break;
	case 46:
        $ret = hire_invoice_pdf();
				break;
	case 47:
        $ret = getProfitabilityHeadWiseReport();
				break;
	case 48:
        $ret = getPIClubDecelarationReport();
				break;
	case 49:
        $ret = getBunkeragencynominationReport();
				break;
	case 50:
        $ret = get_coa_pdf();
				break;
	case 51:
        $ret = getBunkeringAgentPDF();
				break;
	case 52:
        $ret = DumerageInvoicepdf();
				break;
    case 53:
        $ret = getDecisionChart();
				break;
	case 54:
        $ret = getDecisionChartList();
				break;
	case 55:
        $ret = getDailyPositionReport();
				break;
	case 56:
        $ret = getVesselComparePDF();
				break;
    case 57:
        $ret = getTCDecisionChart();
				break;
	case 58:
        $ret = getDecisionChartTCList();
				break;
	case 59:
        $ret = hire_tcinvoice_pdf();
				break;
    case 60:
        $ret = reqtc_pdf();
				break;
	case 61:
        $ret = inops_at_glance_check_listtc_pdf();
				break;
	case 62:
        $ret = port_performance_report();
				break;
	case 63:
        $ret = getBunkeringMasterPDF();
				break;
	case 64:
        $ret = getTankerQ88PDF();
				break;
	case 65:
        $ret = create_agency_nomination_letter_pdf();
				break;
	case 66:
        $ret = create_agency_letter_InOpsTC_pdf();
				break;
    case 67:
        $ret = create_tc_hire_invoice_pdf();
				break;
	case 68:
        $ret = create_tc_other_invoice_pdf();
				break;
	case 69:
        $ret = create_vendor_pdf();
				break;
	case 70:
        $ret = hire_invoice_pdfTC();
				break;
    case 71:
        $ret = getReletCompare();
				break;
				
	case 72:
        $ret = getCargoTonnageReport();
				break;
    case 73:
        $ret = getTC_BalticReport();
				break;
	case 74:
        $ret = invoiceReletpdf();
				break;
    case 75:
        $ret = OtherReletInvoicepdf();
				break;
	case 76:
        $ret = req_relet_pdf();
				break;
	case 77:
        $ret = create_VCFVF_pdf();
				break;
	case 78:
        $ret = getVesselOpenPosition_pdf();
				break;
	case 79:
        $ret = create_tc_other_Payment_pdf();
				break;
    case 80:
        $ret = create_FixtureNote_pdf();
				break;
	case 81:
        $ret = create_SOA_VO_REPORT_pdf();
				break;
	case 82:
        $ret = create_Bunker_Consumption_report_pdf();
				break;
	case 83:
        $ret = getGenericFinanceInvoicePDF();
				break;
	case 84:
        $ret = getTCProvisionalHireStatementPDF();
				break;
	default:
		    //$ret = funError();
				//echo $ret;
				break; 				
}


function getTCProvisionalHireStatementPDF()
{
	$obj = new data();
	$obj->funConnect();
	$randomid = $_REQUEST['randomid'];
	$comid = $_REQUEST['comid'];
$amttoword = new Numbertowordconversion();

$id = $obj->getLatestCostSheetIDTC($comid);
$obj->viewTCEstimationTempleteRecordsNew($id);

$sql = "SELECT * from invoice_hiretc_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$randomid."'";
$res 	= mysql_query($sql);
$rows 	= mysql_fetch_assoc($res);
$randomid = $rows['RANDOMID'];

$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."' and RANDOMID='".$randomid."'";
$restc 	= mysql_query($sqltc);
$rectc 	= mysql_num_rows($restc);
$rowstc = mysql_fetch_assoc($restc);

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];

$_SESSION['companyname']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
 
$_SESSION['invoice_date'] = date("d-m-Y",time());

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['companyaddress'].", ".$_SESSION['companycity']." ".$_SESSION['companycountry']." ".$_SESSION['companycode'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	$vendorid = $rowstc['TC_FINAL_HIERAGE_VENDOR'];
	$currency = 'USD';
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate VC Hire Statement Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate VC Hire Statement Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Statement No.","Provisional","Contract Ref. : ".$rowstc['TC_CP_NUMBER'] ,"CP Date ".date('d-m-Y',strtotime($rowstc['TC_CP_DATE']))));
	$invdate = date('d-m-Y',time());
	
	$pdf->Row(array("Statement Date",$invdate,"Vessel",$obj->getVesselIMOData($obj->getFun3(),"VESSEL_NAME")));
	
	$pdf->Row(array("Port/Region of Delivery",$rowstc['TC_PORT_DELIVERY'],"Port/Region of Re-Delivery",$rowstc['TC_PORT_REDELIVERY']));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Ship Owner:","Creating Company:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($vendorid)."\n".stripslashes($obj->getVendorDataBasedOnID($vendorid,'STREET_1')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
	
	$gety = $pdf->GetY();
	
	//$pdf->Ln(5);
//	
//    $pdf->SetFont('daxcondensedlight','',11);
//	$pdf->SetTextColor(0,0,0);
//	$arr1=array('L');
//	$arr2=array(190);
//	$pdf->SetAligns($arr1);
//	$pdf->SetWidths($arr2);
//	$pdf->Row1(array("Payment Terms:"));
//	$pdf->SetFont('daxcondensedlight','',10);
//	$pdf->Row1(array($rows['PAYMENT_TERMS']));
//	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$sql_2 = "select chartering_tc_estimate_slave2.RANDOMID, chartering_tc_estimate_slave2.TC_DELIVERY_DATE, chartering_tc_estimate_slave2.TC_REDELIVERY_DATE, chartering_tc_estimate_slave2.TC_RATE, chartering_tc_estimate_slave2.TD_DAYS, chartering_tc_estimate_slave2.HIERAGE, chartering_tc_estimate_slave2.BALLAST_BONUS, chartering_tc_estimate_slave2.GROSS_HIERAGE, chartering_tc_estimate_slave2.ADD_COMM, chartering_tc_estimate_slave2.ADD_COMM_AMT, chartering_tc_estimate_slave2.BROKERAGE_COMM, chartering_tc_estimate_slave2.BROKERAGE_COMM_AMT, chartering_tc_estimate_slave2.NET_HIERAGE, chartering_tc_estimate_slave2.CVE_MONTH, chartering_tc_estimate_slave2.CVE_AMOUNT from chartering_tc_estimate_slave2 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave2.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' ";	
	
	$result_2 = mysql_query($sql_2);$i = 0;
	$num_2 = mysql_num_rows($result_2);
	while($rows_2 = mysql_fetch_assoc($result_2))
	{$i++;
	    $uitiliseddays = 0;$fromdate = '';$todate = '';
		$sql_invslave1 = "select invoice_hiretc_slave3.HIRE_FROM, invoice_hiretc_slave3.HIRE_TO, invoice_hiretc_slave3.UTILISED_DAYS from invoice_hiretc_slave3 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave3.INVOICEID where invoice_hiretc_master.RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."' and invoice_hiretc_slave3.RANDOMID='".$rows_2['RANDOMID']."' and date(invoice_hiretc_slave3.HIRE_FROM)!='1970-01-01' and date(invoice_hiretc_slave3.HIRE_TO)!='1970-01-01'";
		//echo $sql_invslave1.'<br/>';
		$res_invslave1 = mysql_query($sql_invslave1);
		$num_invslave1 = mysql_num_rows($res_invslave1);
		$ik = 1;
		while($result_invslave1 = mysql_fetch_assoc($res_invslave1))
		{
		    $uitiliseddays = $uitiliseddays + $result_invslave1['UTILISED_DAYS'];
			if($ik == 1)
			{
				$fromdate = $result_invslave1['HIRE_FROM'];
			}
			if($ik == $num_invslave1)
			{
				$todate = $result_invslave1['HIRE_TO'];
			}
			$ik++;
		}
		if(date('d-m-Y',strtotime($fromdate))!='01-01-1970' && date('d-m-Y',strtotime($todate))!='01-01-1970')
		{
			$pdf->Ln(2);
			$hireamt = $uitiliseddays*$rows_2['TC_RATE'];
			$pdf->Row1(array("Period ".date('d-m-Y H:i',strtotime($fromdate))." - ".date('d-m-Y H:i',strtotime($todate)).", Total ".$uitiliseddays." Days",$hireamt));
			$pdf->Row1(array("Hire for ".$uitiliseddays." days at ".$currency." ".$rows_2['TC_RATE']." per day",""));
		}
	}
	
	
	$ballast_bonus = 0;$cve_amt = 0;$ifdeliverybunker=0;$ifredeliverybunker=0;$ifoffhire = 0;$offhirecveamt = 0;
	$sql_2 = "select chartering_tc_estimate_slave2.RANDOMID, chartering_tc_estimate_slave2.TC_DELIVERY_DATE, chartering_tc_estimate_slave2.TC_REDELIVERY_DATE, chartering_tc_estimate_slave2.TC_RATE, chartering_tc_estimate_slave2.TD_DAYS, chartering_tc_estimate_slave2.HIERAGE, chartering_tc_estimate_slave2.BALLAST_BONUS, chartering_tc_estimate_slave2.GROSS_HIERAGE, chartering_tc_estimate_slave2.ADD_COMM, chartering_tc_estimate_slave2.ADD_COMM_AMT, chartering_tc_estimate_slave2.BROKERAGE_COMM, chartering_tc_estimate_slave2.BROKERAGE_COMM_AMT, chartering_tc_estimate_slave2.NET_HIERAGE, chartering_tc_estimate_slave2.CVE_MONTH, chartering_tc_estimate_slave2.CVE_AMOUNT from chartering_tc_estimate_slave2 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave2.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' ";	
	
	$result_2 = mysql_query($sql_2);$i = 0;
	$num_2 = mysql_num_rows($result_2);
	while($rows_2 = mysql_fetch_assoc($result_2))
	{$i++;
	    $ifoffhireamt = 0;
		$sql_invslave1 = "select invoice_hiretc_slave3.UTILISED_DAYS, invoice_hiretc_slave3.HIRE_AMT, invoice_hiretc_slave3.ADD_COMM, invoice_hiretc_slave3.BROKERAGE_AMT, invoice_hiretc_slave3.CVE_AMT, invoice_hiretc_slave3.HIRE_FROM, invoice_hiretc_slave3.HIRE_TO, invoice_hiretc_slave3.CVE_AMT, invoice_hiretc_master.CHK_BALLAST_BONUS, invoice_hiretc_master.CHK_DELIVERY, invoice_hiretc_master.CHK_REDELIVERY, invoice_hiretc_master.CHK_OFFHIRE from invoice_hiretc_slave3 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave3.INVOICEID where invoice_hiretc_master.RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."' and invoice_hiretc_slave3.RANDOMID='".$rows_2['RANDOMID']."'";
		$res_invslave1 = mysql_query($sql_invslave1);
		while($result_invslave1 = mysql_fetch_assoc($res_invslave1))
		{
			if(date('d-m-Y',strtotime($result_invslave1['HIRE_FROM']))!='01-01-1970' && date('d-m-Y',strtotime($result_invslave1['HIRE_TO']))!='01-01-1970')
			{
				$pdf->Ln(2);
				
				if($result_invslave1['CVE_AMT']>0)
				{   $cve_amt = $cve_amt + $result_invslave1['CVE_AMT'];
				}
				
				if($result_invslave1['CHK_DELIVERY']==1)
				{
				    $ifdeliverybunker=1;
				}
				
				if($result_invslave1['CHK_OFFHIRE']==1)
				{
				    $ifoffhire=1;
				}
				
				if($result_invslave1['CHK_REDELIVERY']==1)
				{
				    $ifredeliverybunker=1;
				}
				
				if($result_invslave1['CHK_BALLAST_BONUS']==1)
				{   
				    $ballast_bonus = $ballast_bonus + $rows_2['BALLAST_BONUS'];
				}
			}
		}	
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	if($ballast_bonus>0)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Ballast Bonus",'(+) '.number_format($ballast_bonus,2,'.',',')));
	}
	
	$sql2 = "select invoice_hiretc_slave1.DESCRIPTION, invoice_hiretc_slave1.AMOUNT from invoice_hiretc_slave1 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave1.INVOICEID where invoice_hiretc_master.RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."' and IDENTIFY='ADD' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(+) '.number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($cve_amt>0)
	{
		$pdf->Row1(array("     CVE     ",'(+) '.number_format($cve_amt,2,'.',',')));
	}
	
	if($ifdeliverybunker==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Delivery Bunkers",""));
		
		$sqltc4 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_DATE, BUNKER_PRICE, BUNKER_AMT, IDENTIFY from chartering_tc_estimate_slave3 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave3.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave3.IDENTIFY='DEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['BUNKER_QTY'].'(MT)',number_format(($rowstc4['BUNKER_PRICE']),2,'.',','),'(+) '.number_format(($rowstc4['BUNKER_AMT']),2,'.',',')));
        }
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select invoice_hiretc_slave1.DESCRIPTION, invoice_hiretc_slave1.AMOUNT from invoice_hiretc_slave1 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave1.INVOICEID where invoice_hiretc_master.RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."' and IDENTIFY='SUB' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(-)'.$rows2['AMOUNT']));
	}
	
	$sqlcvecom1 = "select * from invoice_hiretc_master where RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."'";
    $rescvecom1 = mysql_query($sqlcvecom1);
	$numcvecom1 = mysql_num_rows($rescvecom1);
	
	$sqlcvecom = "select SUM(ADD_COMM_AMT) as ADD_COMM_AMT, SUM(BRO_COMM_AMT) as BRO_COMM_AMT, SUM(OFFHIRE_CVE_AMT) as OFFHIRE_CVE_AMT, SUM(FINAL_AMT) as FINAL_AMT, SUM(FINAL_AMT*EXCHANGE_RATE) as FINAL_AMT1, SUM(P_AMT) as P_AMT, SUM(P_AMT*EXCHANGE_RATE) as P_AMT1, SUM(EXCHANGE_RATE) as EXCHANGE_RATE from invoice_hiretc_master where RANDOMID='".$randomid."' and invoice_hiretc_master.COMID='".$comid."'";
    $rescvecom = mysql_query($sqlcvecom);
    $rowscvecom = mysql_fetch_assoc($rescvecom);
	
	if($rowscvecom['ADD_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     ADDRESS COMMISSION",'(-)'.$rowscvecom['ADD_COMM_AMT']));
	}
	
	if($rowscvecom['BRO_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     BROKERAGE COMMISSION",'(-)'.$rowscvecom['BRO_COMM_AMT']));
	}
	
	
	$sql_random = "SELECT invoice_hiretc_slave4.RANDOMID from invoice_hiretc_slave4 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave4.INVOICEID where invoice_hiretc_master.RANDOMID='".$rows['RANDOMID']."' and invoice_hiretc_master.COMID='".$comid."'";
	$res_random 	= mysql_query($sql_random) or die($sql_random);
	$rec_random 	= mysql_num_rows($res_random);
	
	$off =0;
	if($ifoffhire==1 && $rec_random>0)
	{
		$pdf->Ln(1);
		
		$pdf->Row1(array("   Off-hire",""));
		while($rec_random = mysql_fetch_assoc($res_random))
		{ $off++;
			$sqltc4 = "SELECT TC_SLAVE4ID, OFFHIRE_REASON, OFF_HIRE_FROM, OFF_HIRE_TO, OFF_HIRE_DAYS, OFF_HIRE_RATE, OF_HIRE_AMT, chartering_tc_estimate_slave4.RANDOMID from chartering_tc_estimate_slave4 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave4.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave4.RANDOMID='".$rec_random['RANDOMID']."'";
			$restc4 	= mysql_query($sqltc4);
			$rectc4 	= mysql_num_rows($restc4);
			while($rowstc4 = mysql_fetch_assoc($restc4))
			{
			    $pdf->SetTextColor(0,0,0);
				$arr1=array('L','R');
				$arr2=array(150,40);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("    ".$off.". ".$rowstc4['OFFHIRE_REASON']." (".$rowstc4['OFF_HIRE_DAYS']." Days)",'(-) '.number_format($rowstc4['OF_HIRE_AMT'],2,'.',',')));
				$sqltc5 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_PRICE, BUNKER_AMT, IS_OWNER_ACCOUNT from chartering_tc_estimate_slave5 where  TC_SLAVE4ID='".$rowstc4['TC_SLAVE4ID']."' and IS_OWNER_ACCOUNT=1";
				$restc5 	= mysql_query($sqltc5);
				$rectc5 	= mysql_num_rows($restc5);
				while($rowstc5 = mysql_fetch_assoc($restc5))
				{
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','R','R','R');
					$arr2=array(50,50,50,40);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc5['BUNKERID']),$rowstc5['BUNKER_QTY'].'(MT)',number_format(($rowstc5['BUNKER_PRICE']),2,'.',''),'(-) '.number_format(($rowstc5['BUNKER_AMT']),2,'.',',')));
				}
			}
		}
	}
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	if($ifoffhire==1 && $rowscvecom['OFFHIRE_CVE_AMT']>0)
	{
		$pdf->Row1(array("     CVE on Off-Hire ",'(-) '.$rowscvecom['OFFHIRE_CVE_AMT']));
	}
	
	
	if($ifdeliverybunker==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Re-Delivery Bunkers",""));
		
		$sqltc4 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_DATE, BUNKER_PRICE, BUNKER_AMT, IDENTIFY from chartering_tc_estimate_slave3 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave3.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave3.IDENTIFY='REDEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['BUNKER_QTY'].'(MT)',number_format(($rowstc4['BUNKER_PRICE']),2,'.',','),'(+) '.number_format(($rowstc4['BUNKER_AMT']),2,'.',',')));
        }
	}
	
	$pdf->Ln(2);
	$sqlprev = "SELECT * from invoice_hiretc_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and STATUS=1 and P_AMT>0";
	$resprev = mysql_query($sqlprev);
	$rec = mysql_num_rows($resprev);$m=0;
	while($rowsprev = mysql_fetch_assoc($resprev))
	{$m++;
	    $pdf->Ln(2);
		$pdf->SetFont('daxcondensedlight','',11);
		$pdf->SetTextColor(027,119,166);
		$arr1=array('L','R');
		$arr2=array(150,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
	    $pdf->Row1(array("     ".$m.'. '.$rowsprev['INVOICE_NO'],number_format($rowsprev['P_AMT'],2,'.','')));
	}
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Due to Owners ",($rowscvecom['FINAL_AMT']-$rowscvecom['P_AMT'])));
	if($rowscvecom['EXCHANGE_RATE']>$numcvecom1 || $rowscvecom['EXCHANGE_RATE']<$numcvecom1)
	{
		$pdf->Row(array("Due to Owners (".$rows['CURRENCY'].")",number_format(($rowscvecom['FINAL_AMT1'] - $rowscvecom['P_AMT1']),2,'.','')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	if($pdf->GetY() >205){$pdf->AddPage('P');$pdf->Ln(5);}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Due to Owners in Words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(($rowscvecom['FINAL_AMT']-$rowscvecom['P_AMT']),$currency))));
	if($rowscvecom['EXCHANGE_RATE']>$numcvecom1 || $rowscvecom['EXCHANGE_RATE']<$numcvecom1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format(($rowscvecom['FINAL_AMT1'] - $rowscvecom['P_AMT1']),2,'.',''),$rows['CURRENCY'])),""));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);
	
$filename = "Hire Provisional Statement.pdf";

$pdf->Output($filename,'D');
}


function getGenericFinanceInvoicePDF()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];
    $sql = "select * from generic_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);

    $currency       = 'USD';
	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddr']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddr'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	
	$sql = "select * from generic_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	if($rows['I_TYPE']=='Credit'){
		$invtitle = 'Credit Note';
		$inv_amt_title = 'to Credit';
	}else{
		$invtitle = 'Invoice';
		$inv_amt_title = 'Invoiced';
	}
	$pdf->SetTitle('Generate Generic Finance Invoice '.$invtitle.' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Freight '.$invtitle.' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." No.",$rows['INVOICE_NO'],"Invoice Type",$obj->getInvoiceTypeName1($rows['I_TYPE'])));
	$invdate = date('d-m-Y',strtotime($rows['INVOICE_DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	$duedate = date('d-m-Y',strtotime($rows['DUE_DATE'])); if($duedate=='01-01-1970'){$duedate = '';}
	$pdf->Row(array($invtitle." Date",$invdate,"Due Date",$duedate));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(48,142);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Contract Details",$rows['CONTRACT_DETAILS']));
	//$pdf->Row(array("Port of Loading",$lp_name,"Port of Discharging",$dp_name));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." To:",$invtitle." From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($rows['VENDOR'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'STREET_1')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'COUNTRY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY_POSTAL_CODE')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
		
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount (".$rows['EXCHANGE_CURRENCY'].")"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['AMOUNT_DESC'],$rows['AMOUNT']));

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from generic_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],$rows2['AMOUNT']));
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from generic_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],$rows2['AMOUNT']));
	}
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount ".$inv_amt_title,$rows['NET_PAYABLE']));
	
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	
	
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['NET_PAYABLE'],$rows['EXCHANGE_CURRENCY']))));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated ".strtolower($invtitle)." and no signatures are required",0,1,'L',0);
	
$filename = $invtitle." (".$rows['I_TYPE'].")".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}


function create_Bunker_Consumption_report_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date 	= date('Y-m-d',strtotime($_REQUEST['txtFrom_Date']));
	$txtTo_Date 	= date('Y-m-d',strtotime($_REQUEST['txtTo_Date']));
	$selBType       = $_REQUEST['selBType'];
	$selCOASpot     = $_REQUEST['selCOASpot'];
	$selVessel      = $_REQUEST['selVessel'];
	$currency       = 'USD';
   

    $_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,125,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			$this->Cell(0,4,"Tel: ".$_SESSION['phone']."  email: ".$_SESSION['email'],0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Bunker Consumption Report');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Bunker Consumption Report');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

    $pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',16);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('C');
	$arr2=array(270);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Bunker Consumption Report"));


	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(245, 242, 245);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L','L','L',"L",'L','L','L',"L","L");
	$arr2=array(12,19,23,23,19,48,48,42,42);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("S. No.","Nom ID","Voyage No.","Vessel Name","COA/Spot","Bunker Data(SOSP)","Bunker Data(SOSP)","Consumed(Charterer's)","Consumed(Owner's)"));
	
	if($selCOASpot == 2){$subquery = " and freight_cost_estimate_compare.COAAID is not NULL";}else{$subquery = " and freight_cost_estimate_compare.COAAID is NULL";}
	if($selVessel!= ''){$subquery1 = " and freight_cost_estimete_master.VESSEL_IMO_ID ='".$selVessel."'";}else{$subquery1 = " ";}
	
	$sql = "select freight_cost_estimate_compare.COMID, freight_cost_estimete_master.TRANS_DATE, freight_cost_estimate_compare.COAAID 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 in (1,2) AND freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$subquery." ".$subquery1." and date(freight_cost_estimete_master.TRANS_DATE) BETWEEN '".$txtFrom_Date."' and '".$txtTo_Date."' order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql) or die($sql);$j=0;
    while($rows = mysql_fetch_assoc($res))
	{
	    $fcaid = $obj->getLatestCostSheetID($rows['COMID']);
		$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
		$cpdate = strtotime($obj->getFun3());
		$coa_spot = '';
		if($obj->getFun175()!='')
		{   
			$coa_spot = 'COA'; 
		}
		else
		{
			$coa_spot = 'Spot'; 
		}
		
		$query11 = "select * from freight_cost_estimate_compare_slave where COMID='".$rows['COMID']."'";
		$res11  = mysql_query($query11);
		$num11 = mysql_num_rows($res11);
		if($num11 > 0)
		{$j++;
			$pdf->SetFillColor(250, 238, 217);
			$pdf->SetDrawColor(255, 255, 255);
			$arr1=array('L','L','L',"L",'L','L','L',"L","L");
	        $arr2=array(12,19,23,23,19,48,48,42,42);
			$pdf->SetFont('daxcondensedlight','',8);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			
			$sql2 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
				$result2 = mysql_query($sql2);$arr_ports = array();
				$num2 = mysql_num_rows($result2);$k = 0;
				while($rows2 = mysql_fetch_assoc($result2))
				{$k++;
					$arr_ports[] = array('portid'=>$rows2['FROM_PORT'],'randomid'=>$rows2['RANDOMID']);
					if($k == $num2)
					{
						$arr_ports[] = array('portid'=>$rows2['TO_PORT'],'randomid'=>$rows2['RANDOMID']);
					}
				}
			  
				$i = 0;$contentprev = $contentlast = '';
				foreach($arr_ports as $arr_ports1)
				{$i++;
				    if($i==1)
					{
						$query1 = "select * from freight_cost_estimate_compare_slave where PORTID='".$arr_ports1['portid']."' and RANDOMID='".$arr_ports1['randomid']."' and COMID='".$rows['COMID']."'";
						$res1  = mysql_query($query1);
						$row1 = mysql_fetch_assoc($res1);
						if(date('d-m-Y', strtotime($row1['ROB_DATE']))=='01-01-1970'){$rob_date = '';}else{$rob_date = date('d-m-Y H:i', strtotime($row1['ROB_DATE']));}
						$contentprev.= 'Date : '.$rob_date."\n";
						$contentprev.= 'Port : '.$obj->getPortNameBasedOnID($arr_ports1['portid'])."\n";
						
						$query2 = "select * from freight_cost_estimate_compare_slave5 where COMID='".$rows['COMID']."' and ROB_SOSP>0";
						$res2 = mysql_query($query2);
						while($row2 = mysql_fetch_assoc($res2))
						{
							$contentprev.= $obj->getBunkerGradeBasedOnID($row2['BUNKERID']).' - MT '.$row2['ROB_SOSP'].', '.$currency.' '.$row2['BUNKER_PRICE']."\n";
						}
					}
					
					if($i == count($arr_ports) && $i>1)
					{
						$query1 = "select * from freight_cost_estimate_compare_slave where PORTID='".$arr_ports1['portid']."' and RANDOMID='".$arr_ports1['randomid']."' and COMID='".$rows['COMID']."'";
						$res1  = mysql_query($query1);
						$row1 = mysql_fetch_assoc($res1);
						if(date('d-m-Y', strtotime($row1['ROB_DATE']))=='01-01-1970'){$rob_date = '';}else{$rob_date = date('d-m-Y H:i', strtotime($row1['ROB_DATE']));}
						$contentlast.= 'Date : '.$rob_date."\n";
						$contentlast.= 'Port : '.$obj->getPortNameBasedOnID($arr_ports1['portid'])."\n";
						
						$query2 = "select * from freight_cost_estimate_compare_slave2 where COMID='".$rows['COMID']."' and COM_SLAVEID='".$row1['COM_SLAVEID']."' and ROB_SOSP>0";
						$res2 = mysql_query($query2);
						while($row2 = mysql_fetch_assoc($res2))
						{
							$query3 = "select * from freight_cost_estimate_compare_slave3 where COMID='".$rows['COMID']."' and BUNKERID='".$row2['BUNKERID']."'";
							$res3 = mysql_query($query3);
							$row3 = mysql_fetch_assoc($res3);
							$contentlast.= $obj->getBunkerGradeBasedOnID($row2['BUNKERID']).' - MT '.$row2['ROB_SOSP'].', '.$currency.' '.$row3['SOSP_VALUE']."\n";
						}
					}
				}
				
				
				$content1 = '';
				$query4 = "select * from freight_cost_estimate_compare_slave4 where COMID='".$rows['COMID']."' and CONSUMEDON='CHARTERER'";
				$res4 = mysql_query($query4);
				$num4 = mysql_num_rows($res4);
				while($row4 = mysql_fetch_assoc($res4))
				{
					$content1.= $obj->getBunkerGradeBasedOnID($row4['BUNKERID']).' - MT '.$row4['QTY_USER'].', '.$currency.' '.$row4['USED_AMT']."\n";
				}
				
				$content2 = '';
				$query4 = "select * from freight_cost_estimate_compare_slave4 where COMID='".$rows['COMID']."' and CONSUMEDON='OWNER'";
				$res4 = mysql_query($query4);
				$num4 = mysql_num_rows($res4);
				while($row4 = mysql_fetch_assoc($res4))
				{
					$content2.= $obj->getBunkerGradeBasedOnID($row4['BUNKERID']).' - MT '.$row4['QTY_USER'].', '.$currency.' '.$row4['USED_AMT']."\n";
				}
		
			$pdf->Row2(array($j,$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getFun8(),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$coa_spot,$contentprev,$contentlast,$content1,$content2));
		}
		
	}
	 
	
	
	$filename = "Bunker Consumption Report ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');

}


function create_SOA_VO_REPORT_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$comid 							= $_REQUEST['comid'];
   

    $_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Consolidated Statement Of Accounts - VC/COA Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Consolidated Statement Of Accounts - VC/COA Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

    $pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',16);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('C');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Consolidated Statement Of Accounts - VC/COA"));

$quantity = $freight = 0; $freight_rate = array();$freight_level = '';
$cost_sheet_id = $obj->getLatestCostSheetID($comid);
$obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
if($obj->getFun175()!='')
{
	$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
	$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
	$rowscoa   = mysql_fetch_assoc($resultcoa);
	$charterer = $obj->getVendorListNewData($rowscoa['CHARTERER'],"NAME");
	$owner = $obj->getVendorListNewData($rowscoa['OWNER'],"NAME");
	$broker  = $obj->getVendorListNewData($rowscoa['BROKER'],"NAME");
	$cargoids = $rowscoa['CARGO'];
	$currency = $rowscoa['CURRENCY'];
	$fcaid = $obj->getLatestCostSheetID($comid);
	$sql12 = "select CARGO_MT, CARGO_CBM, RATE_USD_MT, AMOUNT_USD from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS in (1,2)";
	$res12 = mysql_query($sql12);
	while($row12 = mysql_fetch_assoc($res12))
	{
	    $freight_level = 'Freight Rate';
		$freight = $freight + $row12['AMOUNT_USD'];
		if($obj->getCompareEstimateData($comid,"ESTIMATE_TYPE")==1)
		{
			$quantity = $quantity + $row12['CARGO_CBM'];
			$freight_rate[] = $row12['RATE_USD_MT'];
		}
		else if($obj->getCompareEstimateData($comid,"ESTIMATE_TYPE")==2)
		{
			$quantity = $quantity + $row12['CARGO_CBM'];
			$freight_rate[] = $row12['RATE_USD_MT'];
		}
		else
		{
			$quantity = $quantity + $row12['CARGO_MT'];
			$freight_rate[] = $row12['RATE_USD_MT'];
		}
	}
}
else
{
	$arrvendor = array();
	$arrvendor[] = $obj->getVendorListNewData($obj->getCargoPlanningData($obj->getFun206(),"CHARTERER"),"NAME");
	$charterer = implode(',', $arrvendor);
	$owner = $obj->getVendorListNewData($obj->getCompareEstimateData($comid,"OWNER"),"NAME");
	$broker  = $obj->getVendorListNewData($obj->getCompareEstimateData($comid,"BROKER"),"NAME");
	$cargoids = $obj->getCompareEstimateData($comid,"CARGO_ID");
	$currency = $obj->getFun206();
	
	if($obj->getCompareEstimateData($comid,"ESTIMATE_TYPE")==1)
	{
		$quantity = $obj->getCompareEstimateData($comid,"GAS_QUANTITY");
		if($obj->getCompareEstimateData($comid,"GAS_MARKET")==1)
		{
		    $freight_level = 'Base Freight';
			$freight_rate[] = $obj->getCompareEstimateData($comid,"GAS_BASE_RATE");
		}
		else
		{
			$freight_level = 'Lump-sum  (USD)';
			$freight_rate[] = $obj->getCompareEstimateData($comid,"GAS_LUMSUM");
		}
		$freight = $obj->getFun172();
	}
	else if($obj->getCompareEstimateData($comid,"ESTIMATE_TYPE")==2)
	{
	    $quantity = $obj->getCompareEstimateData($comid,"TANK_QUANTITY");
	    if($obj->getFun228()==1)
        {
			if($obj->getCompareEstimateData($comid,"CHK_LUMPSUM") == 1)
			{
				
				$freight_level = 'Lump-sum  (USD)';
				$freight_rate[] = $obj->getCompareEstimateData($comid,"LUMPSUMAMT");
				$freight = $freight + $obj->getCompareEstimateData($comid,"LUMPSUMAMT");
			}
			else
			{
				$freight_level = 'WS';
				$sql12 = "select MIN_WS, OVE_WS, TOTAL_AMOUNT from freight_cost_estimete_slave12 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."'";
				$res12 = mysql_query($sql12);
				$row12 = mysql_fetch_assoc($res12);
				$freight_rate[]  = $row12['MIN_WS'];
				$freight = $freight + $row12['TOTAL_AMOUNT'];
			}
		}
		else
		{
			$freight_level = 'Freight';
			$sql12 = "select AMOUNT_USD, RATE_USD_MT, STATUS from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."'";
			$res12 = mysql_query($sql12);
			while($row12 = mysql_fetch_assoc($res12))
			{
			    if($row12['STATUS']==1 || $row12['STATUS']==2)
				{
					$freight_rate[]  = $row12['RATE_USD_MT'];
				}
				$freight = $freight + $row12['AMOUNT_USD'];
			}
		}
	}
	else
	{
	    $freight_level = 'Freight Rate';
		if($obj->getCompareEstimateData($comid,"QTY_TYPE_RADIO")== 1)
		{
			$quantity = $obj->getCompareEstimateData($comid,"QUANTITY");
			$freight_rate[]  = $obj->getFun47();
			$freight = $freight + $obj->getCompareEstimateData($comid,"TOTAL_PREIGHT_ADJ");
		}
		else
		{
			$sql12 = "select QUANTITY, AGREED_GROSS_FREIGHT, NET_FREIGHT, GROSS_FREIGHT from freight_cost_estimete_slave7 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."'";
			$res12 = mysql_query($sql12);
			while($row12 = mysql_fetch_assoc($res12))
			{
				$quantity = $quantity + $row12['QUANTITY'];
				$freight_rate[]  = number_format($row12['sum2'], 2, '.', '');
				$freight = $freight + $row12['GROSS_FREIGHT'];
			}
		}
	}
}



	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L',"L");
	$arr2=array(47,47,47,47);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Vessel","Nom ID","Voy No.","CP Date"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L','L','L',"L");
	$arr2=array(47,47,47,47);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$obj->getCompareTableData($comid,"MESSAGE"),$obj->getFun8(),date("d-m-Y",strtotime($obj->getFun3()))));
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',13);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("RECEIVABLES"));

	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L',"L",'L','L');
	$arr2=array(89,26,25,25,25);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("","Estimated (USD)","Invoiced (USD)","Received (USD)","Balance (USD)"));
	
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("FREIGHT"));
	
	
	$arr_sum1 = $arr_sum2 = $arr_sum3 = $arr_sum4 = array();
	$sum1 = $sum2 = $sum3 = 0;
	$sqlfreight = "select sum(NET_PAYABLE) as sum1, sum(ADDCOM_AMOUNT) as sum2, sum(P_AMT) as sum3 from freight_invoice_master where COMID='".$comid."' ";
	$resfreight = mysql_query($sqlfreight);$m = 0;
	while($rowfreight = mysql_fetch_assoc($resfreight))
	{
		$sum1 = $sum1 + $rowfreight['sum1'];
		$sum2 = $sum2 + $rowfreight['sum2'];
		$sum3 = $sum3 + $rowfreight['sum3'];
	}
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFillColor(245, 242, 245);
	$pdf->SetDrawColor(255, 255, 255);
	$arr1=array('L','R',"L",'R','R',"R",'R','R');
	$arr2=array(23,22,22,22,26,25,25,25);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(27,119,166);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Qty",$quantity,$freight_level,implode(',',$freight_rate),$freight,"","",""));
	$pdf->Row2(array("Add Comm.%",$obj->getFun74(),"","",$obj->getFun75(),$sum2,"",""));
	$pdf->Row2(array("","","","",number_format(($freight - $obj->getFun75()), 2, '.', ''),$sum1,$sum3,number_format(($sum1 - $sum3), 2, '.', '')));
	
	$arr_sum1[] = number_format(($freight - $obj->getFun75()), 2, '.', '');$arr_sum2[] = $sum1; $arr_sum3[] = $sum3;$arr_sum4[] = number_format(($sum1 - $sum3), 2, '.', '');
	
	
	$sql121    = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."' order by FCA_SLAVEID";
	$result    = mysql_query($sql121);
	$record    = mysql_num_rows($result);
	if($record > 0){
	while($rows11 = mysql_fetch_array($result))
	{
		if($rows11['IS_SHOW_DDCLP'] == NULL)
		{
			$sqlay = "select * from laytime_master where COMID='".$comid."' and PORT='LP' and PORTID='".$rows11['FROM_PORT']."' and RANDOMID='".$rows11['RANDOMID']."' and REVERSIBLE!=1";
			$reslay = mysql_query($sqlay);
			$reclay = mysql_num_rows($reslay);
			$rowslay = mysql_fetch_assoc($reslay);
			
			$sum1 = $sum2 = $sum3 = 0;
			$invtitle = "Demurrage/Dispatch Invoice for Load Port ".$obj->getPortNameBasedOnID($rows11['FROM_PORT']);
			$sqlfreight = "SELECT sum(NET_PAYABLE) as sum1, sum(P_AMT) as sum2  from other_invoice_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and VENDOR='".$rows11['DDCLP_VENDOR']."' and P_TYPE='".$invtitle."' and STATUS<2";
			$resfreight = mysql_query($sqlfreight);$m = 0;
			while($rowfreight = mysql_fetch_assoc($resfreight))
			{
				$sum2 = $sum2 + $rowfreight['sum2'];
				$sum1 = $sum1 + $rowfreight['sum1'];
			}
			
			$pdf->Ln(2);
			$gety = $pdf->GetY();
			$pdf->SetFont('daxcondensedlight','',12);
			$pdf->SetTextColor(27,119,166);
			$arr1=array('L');
			$arr2=array(190);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("DEMURRAGE - LOAD PORT ".strtoupper($obj->getPortNameBasedOnID($rows11['FROM_PORT']))));
			
			$arr1 = $arr2 = $arr3 = array();
			$pdf->SetFillColor(245, 242, 245);
			$pdf->SetDrawColor(255, 255, 255);
			$arr1=array('L','R',"L",'R','R',"R",'R','R');
			$arr2=array(23,22,22,22,26,25,25,25);
			$pdf->SetFont('daxcondensedlight','',11);
			$pdf->SetTextColor(27,119,166);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array("Time on demm",(($rowslay['TIME_TO_DEMURRAGE']>0)?$rowslay['TIME_TO_DEMURRAGE']:"-".$rowslay['TIME_TO_DESPATCH']),"Demm/Des Rate",(($rowslay['TIME_TO_DEMURRAGE']>0)?$rowslay['DEMURRAGE_RATE']:$rowslay['DESPATCH_RATE']),$rows11['DDCLP_REALCOST'],"","",""));
			$pdf->Row2(array("Add Comm.%",$rows11['DDCLP_COMM'],"","",number_format((($rows11['DDCLP_REALCOST'] * $rows11['DDCLP_COMM'])/100), 2, '.', ''),"","",""));
			$pdf->Row2(array("","","","",number_format($rows11['DDCLP_NETCOST'], 2, '.', ''),number_format($sum1, 2, '.', ''),number_format($sum2, 2, '.', ''),number_format(($sum1-$sum2), 2, '.', '')));
			$arr_sum1[] = number_format($rows11['DDCLP_NETCOST'], 2, '.', '');$arr_sum2[] = number_format($sum1, 2, '.', ''); $arr_sum3[] = number_format($sum2, 2, '.', '');$arr_sum4[] = number_format(($sum1-$sum2), 2, '.', '');
		}
		if($rows11['IS_SHOW_DDCDP']  == NULL)
		{
			$sqlay = "select * from laytime_master where COMID='".$comid."' and PORT='DP' and PORTID='".$rows11['TO_PORT']."' and RANDOMID='".$rows11['RANDOMID']."' and REVERSIBLE!=1";
			$reslay = mysql_query($sqlay);
			$reclay = mysql_num_rows($reslay);
			$rowslay = mysql_fetch_assoc($reslay);
			
			$sum1 = $sum2 = $sum3 = 0;
			$invtitle = "Demurrage/Dispatch Invoice for Discharge Port ".$obj->getPortNameBasedOnID($rows11['TO_PORT']);
			$sqlfreight = "SELECT sum(NET_PAYABLE) as sum1, sum(P_AMT) as sum2  from other_invoice_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and VENDOR='".$rows11['DDCDP_VENDOR']."' and P_TYPE='".$invtitle."' and STATUS<2";
			
			$resfreight = mysql_query($sqlfreight);$m = 0;
			while($rowfreight = mysql_fetch_assoc($resfreight))
			{
				$sum2 = $sum2 + $rowfreight['sum2'];
				$sum1 = $sum1 + $rowfreight['sum1'];
			}
			
			$pdf->Ln(2);
			$gety = $pdf->GetY();
			$pdf->SetFont('daxcondensedlight','',12);
			$pdf->SetTextColor(27,119,166);
			$arr1=array('L');
			$arr2=array(190);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("DEMURRAGE - DISCHARGE PORT ".strtoupper($obj->getPortNameBasedOnID($rows11['TO_PORT']))));
			
			$arr1 = $arr2 = $arr3 = array();
			$pdf->SetFillColor(245, 242, 245);
			$pdf->SetDrawColor(255, 255, 255);
			$arr1=array('L','R',"L",'R','R',"R",'R','R');
			$arr2=array(23,22,22,22,26,25,25,25);
			$pdf->SetFont('daxcondensedlight','',11);
			$pdf->SetTextColor(27,119,166);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array("Time on demm",(($rowslay['TIME_TO_DEMURRAGE']>0)?$rowslay['TIME_TO_DEMURRAGE']:"-".$rowslay['TIME_TO_DESPATCH']),"Demm/Des Rate",(($rowslay['TIME_TO_DEMURRAGE']>0)?$rowslay['DEMURRAGE_RATE']:$rowslay['DESPATCH_RATE']),$rows11['DDCDP_REALCOST'],"","",""));
			$pdf->Row2(array("Add Comm.%",$rows11['DDCDP_COMM'],"","",number_format((($rows11['DDCDP_REALCOST'] * $rows11['DDCDP_COMM'])/100), 2, '.', ''),"","",""));
			$pdf->Row2(array("","","","",number_format($rows11['DDCDP_NETCOST'], 2, '.', ''),number_format($sum1, 2, '.', ''),number_format($sum2, 2, '.', ''),number_format(($sum1-$sum2), 2, '.', '')));
			$arr_sum1[] = number_format($rows11['DDCDP_NETCOST'], 2, '.', '');$arr_sum2[] = number_format($sum1, 2, '.', ''); $arr_sum3[] = number_format($sum2, 2, '.', '');$arr_sum4[] = number_format(($sum1-$sum2), 2, '.', '');
	    }
	 }}
	 
	$pdf->Ln(2);
	$gety = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("OTHER INCOME"));
	
	
	$sum1 = $sum2 = $sum3 = 0;
	$query = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='OTHERINCOME' and RAW_AMOUNT>0";
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	if($qrec > 0)
	{
		while($qrows = mysql_fetch_assoc($qres))
		{
			$id = $comid.','.$obj->getFun1().','.$qrows['VENDORID'].','.$qrows['RAW_AMOUNT'].',Other Income';
			$invtitle = "Other Income Invoice for ".$qrows['IDENTY_ID'];
			if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '')
			{
				$arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				 $sql = "select sum(NET_PAYABLE) as sum1, sum(P_AMT) as sum2  from other_invoice_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and VENDOR='".$qrows['VENDORID']."' and P_TYPE='".$invtitle."' and STATUS<2";
				 $res 	= mysql_query($sql);
				 $rec 	= mysql_num_rows($res);
				 $rows = mysql_fetch_assoc($res);
				 $arr_sum1[] = number_format($qrows['RAW_AMOUNT'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '');
				
				$pdf->Row2(array($qrows['IDENTY_ID'],"","","",$qrows['RAW_AMOUNT'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
		    }
	 	 }
	 }
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R',"R",'R','R');
	$arr2=array(89,26,25,25,25);
	$pdf->SetFont('daxcondensedlight','',11);
	$arr3=array("Total",number_format(array_sum($arr_sum1), 2, '.', ''),number_format(array_sum($arr_sum2), 2, '.', ''),number_format(array_sum($arr_sum3), 2, '.', ''),number_format(array_sum($arr_sum4), 2, '.', ''));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',13);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("PAYABLES"));

	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R',"R",'R','R');
	$arr2=array(89,26,25,25,25);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("","Estimated (USD)","PO Made (USD)","Paid (USD)","Balance (USD)"));
	
	
	
	$arr_sum1 = $arr_sum2 = $arr_sum3 = $arr_sum4 = array();
	$sum1 = $sum2 = $sum3 = 0;
	$query = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	if($qrec > 0)
	{
	    $pdf->Ln(2);
		$gety = $pdf->GetY();
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('L');
		$arr2=array(190);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1(array("BUNKERS"));
		while($qrows = mysql_fetch_assoc($qres))
		{
			if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '')
			{
				$arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2  from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Bunkers Nett Supply' and NAME_ID='2' and GRADEID='".$qrows['BUNKERGRADEID']."' and VENDOR='".$qrows['VENDORID']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['COST'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '');
				
				$pdf->Row2(array("Grade",$obj->getBunkerGradeBasedOnID($qrows['BUNKERGRADEID']),"Qty(MT)",$qrows['QTY'],$qrows['COST'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
			
		    }
	    }
	}
	

	$sum1 = $sum2 = $sum3 = 0;
	$query = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	if($qrec > 0)
	{
	    $pdf->Ln(2);
		$gety = $pdf->GetY();
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('L');
		$arr2=array(190);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1(array("OPERATIONAL COST"));
		while($qrows = mysql_fetch_assoc($qres))
		{
			if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '')
			{
				$arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2  from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Operational Costs (Others)' and NAME_ID='3' and GRADEID='0' and VENDOR='".$qrows['VENDORID']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['BROKAGE_AMT'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '');
				$pdf->Row2(array("Brokerage Commission",$qrows['BROKAGE_AMT'],"","",$qrows['BROKAGE_AMT'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
			
		    }
	    }
	}
	
	$sum1 = $sum2 = $sum3 = 0;$i=0;
	$query = "select *, (select NAME from owner_related_cost_master where owner_related_cost_master.OWNER_RCOSTID=freight_cost_estimete_slave3.IDENTY_ID) as COSTNAME from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."'  and IDENTIFY='ORC'";
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	if($qrec > 0)
	{
		while($qrows = mysql_fetch_assoc($qres))
		{   
		    $i= $i +1;
			$id = '3'.','.'Operational Costs'.','.$i.','.$qrows['VENDORID'].','.$comid.','.$qrows['RAW_AMOUNT'];
			if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '')
			{
				$arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2 from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Operational Costs' and NAME_ID='3' and GRADEID='".$i."' and VENDOR='".$qrows['VENDORID']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['RAW_AMOUNT'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '');
				$pdf->Row2(array($qrows['COSTNAME'],$qrows['RAW_AMOUNT'],"","",$qrows['RAW_AMOUNT'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
			 }
	 	 }
	 }
	 
	 
	$sum1 = $sum2 = $sum3 = 0;
	$query = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."' order by FCA_SLAVEID";
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	if($qrec > 0)
	{   
	    $pdf->Ln(2);
		$gety = $pdf->GetY();
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('L');
		$arr2=array(190);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1(array("PORT COSTS"));
		
		while($qrows = mysql_fetch_assoc($qres))
		{
			
			if($qrows['LOAD_PORT_COST'] > 0)
			{
			
			    $arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2 from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Load Port Costs' and NAME_ID='5' and GRADEID='".$qrows['FROM_PORT']."' and VENDOR='".$qrows['PORT_COSTLP_VENDOR']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['LOAD_PORT_COST'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '');
				$pdf->Row2(array("LP - ".$obj->getPortNameBasedOnID($qrows['FROM_PORT']),$qrows['LOAD_PORT_COST'],"","",$qrows['LOAD_PORT_COST'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
			}
			if($qrows['DISC_PORT_COST'] > 0)
			{
			    $arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2  from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Discharge Port Costs' and NAME_ID='5' and GRADEID='".$qrows['TO_PORT']."' and VENDOR='".$qrows['PORT_COSTDP_VENDOR']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['DISC_PORT_COST'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum2'] - $rows['sum2']), 2, '.', '');
				$pdf->Row2(array("DP - ".$obj->getPortNameBasedOnID($qrows['TO_PORT']),$qrows['DISC_PORT_COST'],"","",$qrows['DISC_PORT_COST'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
			 }
			 if($qrows['TRANSIT_PORT_COST'] > 0)
			 {
			    $arr1 = $arr2 = $arr3 = array();
				$pdf->SetFillColor(245, 242, 245);
				$pdf->SetDrawColor(255, 255, 255);
				$arr1=array('L','R',"L",'R','R',"R",'R','R');
				$arr2=array(23,22,22,22,26,25,25,25);
				$pdf->SetFont('daxcondensedlight','',11);
				$pdf->SetTextColor(27,119,166);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				$sql = "select sum(REQ_TO_PAY) as sum1, sum(P_AMT) as sum2  from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and NAME='Transit Port Costs' and NAME_ID='5' and GRADEID='".$qrows['FROM_PORT']."' and VENDOR='".$qrows['PORT_COSTTP_VENDOR']."'";
				$res 	= mysql_query($sql);
				$rec 	= mysql_num_rows($res);
				$rows = mysql_fetch_assoc($res);
				$arr_sum1[] = number_format($qrows['TRANSIT_PORT_COST'], 2, '.', '');$arr_sum2[] = $rows['sum1']; $arr_sum3[] = $rows['sum2'];$arr_sum4[] = number_format(($rows['sum2'] - $rows['sum2']), 2, '.', '');
				$pdf->Row2(array("TP - ".$obj->getPortNameBasedOnID($qrows['FROM_PORT']),$qrows['TRANSIT_PORT_COST'],"","",$qrows['TRANSIT_PORT_COST'],$rows['sum1'],$rows['sum2'],number_format(($rows['sum1'] - $rows['sum2']), 2, '.', '')));
		   }
		}
	}
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("HIRE COSTS"));
	
	
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFillColor(245, 242, 245);
	$pdf->SetDrawColor(255, 255, 255);
	$arr1=array('L','R',"L",'R','R',"R",'R','R');
	$arr2=array(23,22,22,22,26,25,25,25);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(27,119,166);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Daily Hire",$obj->getFun91(),"Days",$obj->getFun62(),$obj->getFun132(),"","",""));
	$pdf->Row2(array("Add Comm.%",$obj->getFun129(),"","",$obj->getFun130(),"","",""));
	//$pdf->Row2(array("","","","",number_format($obj->getFun131(), 2, '.', ''),$sum1,$sum3,number_format(($sum1 - $sum3), 2, '.', '')));
	
	
	$sum1 = $sum2 = $sum3 = 0;
	$sqlfreight = "select FINAL_AMT, ADD_COMM_AMT, P_AMT, INVOICE_TYPE, INVOICE_NO from invoice_hire_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
	$resfreight = mysql_query($sqlfreight);$m = 0;
	while($rowfreight = mysql_fetch_assoc($resfreight))
	{$m++;
		$sum1 = $sum1 + $rowfreight['FINAL_AMT'];
		$sum2 = $sum2 + $rowfreight['P_AMT'];
		
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr1=array('L','R',"R",'R','R');
		$arr2=array(89,26,25,25,25);
		$pdf->SetFont('daxcondensedlight','',11);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2(array($m.".".$rowfreight['INVOICE_NO']." (".$rowfreight['INVOICE_TYPE'].")","",number_format($rowfreight['FINAL_AMT'], 2, '.', ''),number_format($rowfreight['P_AMT'], 2, '.', ''),number_format(($rowfreight['FINAL_AMT'] - $rowfreight['P_AMT']), 2, '.', '')));
   }
   
        $arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr1=array('R','R',"R",'R','R');
		$arr2=array(89,26,25,25,25);
		$pdf->SetFont('daxcondensedlight','',11);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2(array("Total",$obj->getFun236(),number_format($sum1, 2, '.', ''),number_format($sum2, 2, '.', ''),number_format(($sum1 - $sum2), 2, '.', '')));
		
	
	$arr_sum1[] = number_format(($obj->getFun236()), 2, '.', '');$arr_sum2[] = $sum1; $arr_sum3[] = $sum2;$arr_sum4[] = number_format(($sum1 - $sum2), 2, '.', '');
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R',"R",'R','R');
	$arr2=array(89,26,25,25,25);
	$pdf->SetFont('daxcondensedlight','',11);
	$arr3=array("Total",number_format(array_sum($arr_sum1), 2, '.', ''),number_format(array_sum($arr_sum2), 2, '.', ''),number_format(array_sum($arr_sum3), 2, '.', ''),number_format(array_sum($arr_sum4), 2, '.', ''));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$filename = "Consolidated Statement Of Accounts (".$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME")."_".$obj->getCompareTableData($comid,"MESSAGE").") ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');

}

function create_FixtureNote_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$tcoutid 							= $_REQUEST['tcoutid'];
    $obj->viewTCEstimationTempleteRecordsNew($tcoutid);
	$vlsImoId 	= $obj->getFun3();

    $_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate TC Fixture Note Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('TC Fixture Note Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

    $pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',15);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('C');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("TC Fixture Note"));
    

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L',"L",'L','L','L');
	$arr2=array(40,3,49,6,40,3,49);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Fixture Type",":","TC Out"," ","Vessel",":",$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME")));
	$pdf->Row1(array("Vessel Type",":",$obj->getFun4()," ","Flag",":",$obj->getFun5()));
	$pdf->Row1(array("Date",":",date("d-m-Y",strtotime($obj->getFun6()))," ","TC No.",":",$obj->getFun7()));


    $pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Charter Party"));

    $pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L',"L",'L','L','L');
	$arr2=array(40,3,49,6,40,3,49);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("CP Date",":",date("d-m-Y", strtotime($obj->getFun9())), " ","CP Type",":",$obj->getContractTypeMasterData($obj->getFun10(),"CONTRACT_TYPE")));
	$pdf->Row1(array("Charterers",":",$obj->getVendorListNewBasedOnID($obj->getFun11()), " ","Charterers' Operations",":",$obj->getVendorListNewBasedOnID($obj->getFun12())));
	$pdf->Row1(array("Law/Arbitration",":",$obj->getLawArbitrationNameBasedOnID($obj->getFun13()), " ","Charterers' Operations Details",":",$obj->getFun14()));
	
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L','L');
	$arr2=array(32,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("","Vessel Details : ".$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME")));
	
	$BUSINESSTYPEID = $obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID");
	
	
	$pdf->Ln(1);
	$arr1 = $arr2 = array();
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(50,5,70,33);
	$pdf->SetFillColor(245, 242, 245);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->SetX(42);$pdf->Row2(array("Build/Yard",":",$obj->getFun15()));
	$pdf->SetX(42);$pdf->Row2(array("Year Build",":",$obj->getFun16()));
	$pdf->SetX(42);$pdf->Row2(array("Flag",":",$obj->getFun17()));
	$pdf->SetX(42);$pdf->Row2(array("Port of Registry",":",$obj->getFun18()));
	$pdf->SetX(42);$pdf->Row2(array("IMO Number",":",$obj->getFun19()));
	$pdf->SetX(42);$pdf->Row2(array("Class/Class ID",":",$obj->getFun20()));
	
	if($obj->getFun21()=="" || $obj->getFun21()=="0000-00-00"  || $obj->getFun21()=="1970-01-01"){$txtLastSpSurvey = "";}else{$txtLastSpSurvey = date('d-m-Y',strtotime($obj->getFun21()));}
	
	$pdf->SetX(42);$pdf->Row2(array("Last Special Survey",":",$txtLastSpSurvey));
	
	if($obj->getFun22()=="" || $obj->getFun22()=="0000-00-00"  || $obj->getFun22()=="1970-01-01"){$txtLastDD = "";}else{$txtLastDD = date('d-m-Y',strtotime($obj->getFun22()));}
	
	$pdf->SetX(42);$pdf->Row2(array("Last DD",":",$txtLastDD));
	$pdf->SetX(42);$pdf->Row2(array("Owners’ P & I",":",$obj->getFun23()));
	$pdf->SetX(42);$pdf->Row2(array("Master’s Name",":",$obj->getFun24()));
	$pdf->SetX(42);$pdf->Row2(array("Call Sign",":",$obj->getFun25()));
	$pdf->SetX(42);$pdf->Row2(array("Inmarsat Tel",":",$obj->getFun26()));
	$pdf->SetX(42);$pdf->Row2(array("Inmarsat Email",":",$obj->getFun27()));
	$pdf->SetX(42);$pdf->Row2(array("LOA",":",$obj->getFun28()));
	$pdf->SetX(42);$pdf->Row2(array("Breadth",":",$obj->getFun29()));
	$pdf->SetX(42);$pdf->Row2(array("Summer DWT",":",$obj->getFun30()));
	$pdf->SetX(42);$pdf->Row2(array("Summer Draft",":",$obj->getFun31()));
	$pdf->SetX(42);$pdf->Row2(array("TPC",":",$obj->getFun32()));
	$pdf->SetX(42);$pdf->Row2(array("Gross Tonnage",":",$obj->getFun33()));
	$pdf->SetX(42);$pdf->Row2(array("Net Tonnage",":",$obj->getFun34()));
	
	if($BUSINESSTYPEID == 3)
	{
		$pdf->SetX(42);$pdf->Row2(array("Suez GRT",":",$obj->getFun35()));
		$pdf->SetX(42);$pdf->Row2(array("Suez NRT",":",$obj->getFun36()));
		$pdf->SetX(42);$pdf->Row2(array("Panama NRT",":",$obj->getFun37()));
		$pdf->SetX(42);$pdf->Row2(array("Grain Cap",":",$obj->getFun38()));
		$pdf->SetX(42);$pdf->Row2(array("Bale Cap",":",$obj->getFun39()));
		$pdf->SetX(42);$pdf->Row2(array("Cranes",":",$obj->getFun40()));
		$pdf->SetX(42);$pdf->Row2(array("Grabs",":",$obj->getFun41()));
	}
	if($BUSINESSTYPEID == 2)
	{
		$pdf->SetX(42);$pdf->Row2(array("Cargo Tank Capacity(CBM)",":",$obj->getFun111()));
		$pdf->SetX(42);$pdf->Row2(array("No. of Grades(Double V/V Seg)",":",$obj->getFun112()));
		$pdf->SetX(42);$pdf->Row2(array("Cargo Pump Capacity(CBM/Hr)",":",$obj->getFun113()));
		$pdf->SetX(42);$pdf->Row2(array("Total SBT Capacity(CBM)",":",$obj->getFun114()));
	}
	$pdf->SetX(42);$pdf->Row2(array("Keel to top of Mast",":",$obj->getFun42()));
	$pdf->SetX(42);$pdf->Row2(array("Waterline to Top of Mast full Ballast",":",$obj->getFun43()));
	
	
	$pdf->AddPage('P');
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L','L');
	$arr2=array(32,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("", "Charter Party Main Terms"));
	
	
	$pdf->Ln(1);
	$arr1 = $arr2 = array();
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(50,5,70,33);
    $pdf->SetFillColor(245, 242, 245);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->SetX(42);$pdf->Row2(array("Delivery Range / Port",":",$obj->getFun44()));
	$dfp = array( 1 => 'Trip TC', 2 => 'Period');
	$pdf->SetX(42);$pdf->Row2(array("Duration Fixed Period",":",$dfp[$obj->getFun45()]));
	if($obj->getFun45()==1)
	{
		$pdf->SetX(42);$pdf->Row2(array("Trip TC",":",$obj->getFun74()));
	}else{
		$pdf->SetX(42);$pdf->Row2(array("Period",":",$obj->getFun75()));
		$pdf->SetX(42);$pdf->Row2(array("No. Of Trips",":",$obj->getFun76()));
	}
	if($obj->getFun46()=="" || $obj->getFun46()=="0000-00-00 00:00:00"  || $obj->getFun46()=="1970-01-01 08:00:00"){$txtDeliveryDate = "";}else{$txtDeliveryDate = date('d-m-Y H:i',strtotime($obj->getFun46()));}
	$pdf->SetX(42);$pdf->Row2(array("Delivery Date/Time",":",$txtDeliveryDate));
	if($obj->getFun47()=="" || $obj->getFun47()=="0000-00-00 00:00:00"  || $obj->getFun47()=="1970-01-01 08:00:00"){$txtReDeliveryDate = "";}else{$txtReDeliveryDate = date('d-m-Y H:i',strtotime($obj->getFun47()));}
	$pdf->SetX(42);$pdf->Row2(array("Redelivery Date/Time",":",$txtReDeliveryDate));
	$pdf->SetX(42);$pdf->Row2(array("Duration Optional Period",":",$obj->getFun48()));
	$pdf->SetX(42);$pdf->Row2(array("Commencement Optional Period",":",$obj->getFun49()));
	if($obj->getFun50()=="" || $obj->getFun50()=="0000-00-00 00:00:00"  || $obj->getFun50()=="1970-01-01 08:00:00"){$txtLaycanFromDate = "";}else{$txtLaycanFromDate = date('d-m-Y H:i',strtotime($obj->getFun50()));}
	$pdf->SetX(42);$pdf->Row2(array("Laycan From",":",$txtLaycanFromDate));
	if($obj->getFun51()=="" || $obj->getFun51()=="0000-00-00 00:00:00"  || $obj->getFun51()=="1970-01-01 08:00:00"){$txtLaycanToDate = "";}else{$txtLaycanToDate = date('d-m-Y H:i',strtotime($obj->getFun51()));}
	$pdf->SetX(42);$pdf->Row2(array("Laycan To",":",$txtLaycanToDate));
	if($BUSINESSTYPEID == 3)
	{
		$pdf->SetX(42);$pdf->Row2(array("Laycan Narrowing",":",$obj->getFun52()));
	}
	$pdf->SetX(42);$pdf->Row2(array("Redelivery Range",":",$obj->getFun53()));
	$currency = array('EURO'=>'Euro (EUR)','USD'=>'United States Dollar (USD)');
	$pdf->SetX(42);$pdf->Row2(array("Hire PDPR Currency",":",$currency[$obj->getFun137()]));
	$pdf->SetX(42);$pdf->Row2(array("Exchange Rate To USD",":",$obj->getFun138()));
	$pdf->SetX(42);$pdf->Row2(array("Hire Fixed Period PDPR (".$currency[$obj->getFun137()].")",":",$obj->getFun54()));
	$pdf->SetX(42);$pdf->Row2(array("Hire Fixed Period PDPR (USD)",":",number_format(($obj->getFun54()*$obj->getFun138()),2,'.',',')));
	$pdf->SetX(42);$pdf->Row2(array("Hire Optional Period",":",$obj->getFun55()));
	$pdf->SetX(42);$pdf->Row2(array("Fuel Specs",":",$obj->getFun62()));
	$pdf->SetX(42);$pdf->Row2(array("CVE/Month(USD)",":",$obj->getFun63()));
	if($BUSINESSTYPEID == 3)
	{
		$pdf->SetX(42);$pdf->Row2(array("Supercargo and meals(USD)",":",$obj->getFun73()));
		$pdf->SetX(42);$pdf->Row2(array("Hold Cleaning Intermediate(USD)",":",$obj->getFun64()));
		$pdf->SetX(42);$pdf->Row2(array("ILOHC(USD)",":",$obj->getFun65()));
		$pdf->SetX(42);$pdf->Row2(array("ILOHC - Remarks from CP",":",$obj->getFun66()));
		$pdf->SetX(42);$pdf->Row2(array("Brokerage Comm. payable by",":",$obj->getFun15()));
		
	}
	$states = array( 'Charterer' =>'Charterer' , 'Operator' =>'Operator', 'N/A' =>'N/A');
	$pdf->SetX(42);$pdf->Row2(array("Delivery Range / Port",":",$states[$obj->getFun67()]));
	$pdf->SetX(42);$pdf->Row2(array("Add. Comm (%)",":",$obj->getFun68()));
	$pdf->SetX(42);$pdf->Row2(array("Broker’s Comm. (%)",":",$obj->getFun69()));
	$pdf->SetX(42);$pdf->Row2(array("Owner’s Banking Details",":",$obj->getBankingListNewBasedOnID($obj->getFun70())));
	$pdf->SetX(42);$pdf->Row2(array("Document created by",":",$obj->getFun71()));
	$pdf->SetX(42);$pdf->Row2(array("Additional Information",":",$obj->getFun72()));
	
	
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Bunker Details (Delivery)"));

    $pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L',"L",'L');
	$arr2=array(38,38,38,38,38);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Bunker Grade","Qty(MT)","Bunker Date","Price USD/MT)","Amount(USD)"));
	
	$sqltc = "select * from chartering_estimate_tc_slave4 where TCOUTID='".$obj->getFun1()."' and IDENTITY='DEL'";
	$restc 	= mysql_query($sqltc) or die($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$sum1 = 0;
	while($rowstc = mysql_fetch_assoc($restc))
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr2=array(38,38,38,38,38);
		$arr1=array('L','R','L',"R",'R');
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr3=array($obj->getBunkerGradeBasedOnID($rowstc['BUNKERID']),$rowstc['QTY'],date('d-m-Y',strtotime($rowstc['BUNKER_DATE'])),$rowstc['PRICE'],$rowstc['AMOUNT']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		$sum1 = $sum1 + $rowstc['AMOUNT'];
	}
	if($sum1>0)
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr2=array(152,38);
		$arr1=array('L','R');
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr3=array("Total",$sum1);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Bunker Details (Re-Delivery)"));

    $pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(250, 229, 190);
	$pdf->SetDrawColor(255, 255, 255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L',"L",'L');
	$arr2=array(38,38,38,38,38);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Bunker Grade","Qty(MT)","Bunker Date","Price USD/MT)","Amount(USD)"));
	
	$sqltc = "select * from chartering_estimate_tc_slave4 where TCOUTID='".$obj->getFun1()."' and IDENTITY='REDEL'";
	$restc 	= mysql_query($sqltc) or die($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$sum1 = 0;
	while($rowstc = mysql_fetch_assoc($restc))
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr2=array(38,38,38,38,38);
		$arr1=array('L','R','L',"R",'R');
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr3=array($obj->getBunkerGradeBasedOnID($rowstc['BUNKERID']),$rowstc['QTY'],date('d-m-Y',strtotime($rowstc['BUNKER_DATE'])),$rowstc['PRICE'],$rowstc['AMOUNT']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		$sum1 = $sum1 + $rowstc['AMOUNT'];
	}
	if($sum1 > 0)
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFillColor(245, 242, 245);
		$pdf->SetDrawColor(255, 255, 255);
		$arr2=array(152,38);
		$arr1=array('L','R');
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr3=array("Total",$sum1);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	
	$pdf->Ln(2);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(27,119,166);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Baltic Route Details"));

    $sqltc = "select CONCAT(CODE, ' - ' ,NAME) as BALTIC_ROUTE from baltic_master where BALTICID=".$obj->getFun140();
	$restc 	= mysql_query($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$rowstc = mysql_fetch_assoc($restc);

    $pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(27,40,27,40,27,40);
	$pdf->SetFillColor(255, 255, 255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	if(date('d-m-Y',strtotime($obj->getFun141()))!='01-01-1970'){$txtBalticDate = date('d-m-Y',strtotime($obj->getFun141()));}else{$txtBalticDate = '';}
	$pdf->Row2(array("Baltic Route : ",$rowstc['BALTIC_ROUTE'],"Baltic Route Date : ",$txtBalticDate,"Baltic Route Value : ",$obj->getFun142()));
	
	

$filename = "TC Fixture Note (".$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME").") ".date("d-m-Y",time()).".pdf";

$pdf->Output($filename,'D');

}

function create_tc_other_Payment_pdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$invoiceid                      = $_REQUEST['invoiceid'];
	$comid 							= $_REQUEST['comid'];
	$tcoutid = $obj->getLatestCostSheetIDTC($comid);
    $obj->viewTCEstimationTempleteRecordsNew($tcoutid);
	$sql = "SELECT * from payment_tcother_master where PAYMENTID='".$invoiceid."' and COMID='".$comid."'";
	$res 	= mysql_query($sql);
	$rec 	= mysql_num_rows($res);
	$rows 	= mysql_fetch_assoc($res);
	
	$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."' and RANDOMID='".$rows['RANDOMID']."'";
	$restc 	= mysql_query($sqltc) or die($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$rowstc = mysql_fetch_assoc($restc); 

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate TC Hire Payment Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate TC Hire Payment Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("PO No.",$rows['INVOICE_NO'],"Contract Ref.","CP Date ".date('d-m-Y',strtotime($obj->getFun9()))));
	$pdf->Row(array("PO Date",date('d-m-Y',strtotime($rows['INVOICE_DATE'])),"Incoming Invoice Date",date('d-m-Y',strtotime($rows['INCOM_INVOICE_DATE']))));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME"),"Payment Type","Other"));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Payment To:","Payment From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewData($rows['VENDOR'],"NAME")."\n".$obj->getVendorListNewData($rows['VENDOR'],"STREET_1")."\n".$obj->getVendorListNewData($rows['VENDOR'],"CITY").", ".$obj->getVendorListNewData($rows['VENDOR'],"COUNTRY")." ".$obj->getVendorListNewData($rows['VENDOR'],"CITY_POSTAL_CODE"),$_SESSION['companyname']."\n".$_SESSION['companyaddress']."\n".$_SESSION['companycity'].", ".$_SESSION['companycountry']." ".$_SESSION['companycode']));
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	
	$pdf->Ln(1);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(USD)"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['INV_IDENTITY'],number_format($rows['AMOUNT'],2,'.',',')));
	$pdf->Row1(array($rows['SHORT_DESC'],""));
	$pdf->Row1(array($rows['DESCRIPTION'],""));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from payment_tcother_slave1 where PAYMENTID='".$rows['PAYMENTID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from payment_tcother_slave1 where PAYMENTID='".$rows['PAYMENTID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount",number_format($rows['FINAL_AMOUNT'],2,'.',',')));
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['FINAL_AMOUNT'],'USD'))));
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);

$filename = $rows['INV_IDENTITY']." Payment TC (".$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME").") ".date("d-m-Y",time()).".pdf";
$pdf->Output($filename,'D');

}

function getVesselOpenPosition_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$selBType = $_REQUEST['selBType'];
    
$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Vessel Open Position Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Vessel Open Position Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

    $pdf->Ln(2);
	$pdf->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
	$pdf->SetFont('daxcondensedlight','',16);
	$pdf->SetTextColor(17,85,124);
	$pdf->Cell(0,4,"VESSEL OPEN POSITION REPORT",0,1,'C');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFillColor(250, 238, 217);
	$pdf->SetDrawColor(255, 255, 255);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(12,38,38,38,38,38,38,38);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("S.No.", "Vessel Name","Vessel Type","Last Business (Voyage/TC)","Last Dis Port/Port Open","Date Open","Last Cargo","Last Cargo Size(MT)"));
		
	$sql = "select VESSEL_IMO_ID, VESSEL_NAME, BUSINESSTYPEID, (select VesselType from vessel_type_master where vessel_type_master.VesselTypeId = vessel_imo_master.VESSEL_TYPE) as VESSEL_TYPE from vessel_imo_master where BUSINESSTYPEID='".$selBType."' and MCOMPANYID='".$_SESSION['company']."'";
	$i = 0;
	$result = mysql_query($sql) or die($sql);
	while($rows   = mysql_fetch_assoc($result))
	{
		$sql1 = "select COMID, FCAID, OPEN_CARGOID, (select TO_PORT from freight_cost_estimete_slave1 where freight_cost_estimete_slave1.FCAID=freight_cost_estimete_master.FCAID and DISC_PORT_QTY>0 order by FCA_SLAVEID DESC LIMIT 1) as LAST_DIS_PORT, (select RANDOMID from freight_cost_estimete_slave1 where freight_cost_estimete_slave1.FCAID=freight_cost_estimete_master.FCAID and DISC_PORT_QTY>0 order by FCA_SLAVEID DESC LIMIT 1) as LAST_RANDOMID, (select DISC_PORT_QTY from freight_cost_estimete_slave1 where freight_cost_estimete_slave1.FCAID=freight_cost_estimete_master.FCAID and DISC_PORT_QTY>0 order by FCA_SLAVEID DESC LIMIT 1) as LAST_DISC_PORT_QTY from freight_cost_estimete_master where VESSEL_IMO_ID='".$rows['VESSEL_IMO_ID']."' and MCOMPANYID='".$_SESSION['company']."' order by FCAID DESC";
		$result1 = mysql_query($sql1) or die($sql1);
		$num1 = mysql_num_rows($result1);
		$rows1 = mysql_fetch_assoc($result1);
		$checklistid      = $obj->getCheckListRecordsDataBasedOnComID($rows1['COMID'],"CHECKLIST_ID");
		$vesselsailed_VC1  = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"DP",$rows1['LAST_DIS_PORT'],$rows1['LAST_RANDOMID'],"VESSEL SAILED");
		$vesselsailed_VC1  = ($vesselsailed_VC1 == '')?$obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"DP",$rows1['LAST_DIS_PORT'],$rows1['LAST_RANDOMID'],"ETC/D"):$vesselsailed_VC1;
		$vesselsailed_VC  = date('d-m-Y',strtotime($vesselsailed_VC1));
		if($vesselsailed_VC == '01-01-1970'){$vesselsailed_VC = '';}else{$vesselsailed_VC  = date('d-m-Y',strtotime($vesselsailed_VC1));}
		
		$sql2 = "select COMID, TCOUTID, RE_DEL_RANGE, (select REDEL_DATE_EST from chartering_tc_estimate_slave1 where chartering_tc_estimate_slave1.TCOUTID=chartering_estimate_tc_master.TCOUTID order by TC_SLAVE1ID DESC LIMIT 1) as LAST_REDEL_DATE_EST, (select REDEL_DATE_EST from chartering_tc_estimate_slave1 where chartering_tc_estimate_slave1.TCOUTID=chartering_estimate_tc_master.TCOUTID order by TC_SLAVE1ID DESC LIMIT 1) as LAST_REDEL_DATE_EST1, (select RANDOMID from chartering_tc_estimate_slave1 where chartering_tc_estimate_slave1.TCOUTID=chartering_estimate_tc_master.TCOUTID order by TC_SLAVE1ID DESC LIMIT 1) as LAST_RANDOMID from chartering_estimate_tc_master where VESSEL_IMO_ID='".$rows['VESSEL_IMO_ID']."' and MCOMPANYID='".$_SESSION['company']."' order by TCOUTID DESC";
		
		$result2 = mysql_query($sql2) or die($sql2);
		$num2 = mysql_num_rows($result2);
		$rows2 = mysql_fetch_assoc($result2);
		$vesselsailed_TC1  = $rows2['LAST_REDEL_DATE_EST'];
		$vesselsailed_TC  = date('d-m-Y',strtotime($vesselsailed_TC1));
		if($vesselsailed_TC == '01-01-1970'){$vesselsailed_TC = '';}else{$vesselsailed_TC  = date('d-m-Y',strtotime($vesselsailed_TC1));}
		
		if($vesselsailed_VC !='' || $vesselsailed_TC !='')
		{   
			  
			$dischargeport = $cargo_name = $cargoqty = $bysseness = $opendate = '';
			if(($vesselsailed_TC !='' && $vesselsailed_VC !='' && strtotime($vesselsailed_TC) < strtotime($vesselsailed_VC)))
			{$dischargeport = $obj->getPortNameBasedOnID($rows1['LAST_DIS_PORT']);$cargo_name = $obj->getCargoNameListForMultipleNamemultiple($obj->getOpenCargoPositionData($rows1['OPEN_CARGOID'],'CARGO'));$cargoqty = $rows1['LAST_DISC_PORT_QTY']." MT";$bysseness = 'Voyage';$opendate = $vesselsailed_VC;}
			elseif($vesselsailed_TC =='' && $vesselsailed_VC !='')
			{$dischargeport = $obj->getPortNameBasedOnID($rows1['LAST_DIS_PORT']);$cargo_name = $obj->getCargoNameListForMultipleNamemultiple($obj->getOpenCargoPositionData($rows1['OPEN_CARGOID'],'CARGO'));$cargoqty = $rows1['LAST_DISC_PORT_QTY']." MT";$bysseness = 'Voyage';$opendate = $vesselsailed_VC;}
			elseif($vesselsailed_VC =='' && $vesselsailed_TC !='')
			{$dischargeport = '';$cargo_name = '';$cargoqty = '';$bysseness = 'TC';$dischargeport = $rows2['RE_DEL_RANGE'];$opendate = $vesselsailed_TC;}
			else{$dischargeport = '';$cargo_name = '';$cargoqty = '';$bysseness = 'TC';$dischargeport = $rows2['RE_DEL_RANGE'];$opendate = $vesselsailed_TC;}
			$i++;
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetFillColor(245, 242, 245);
			$pdf->SetDrawColor(255, 255, 255);
			$pdf->SetTextColor(27,119,166);
			
			$arr1=array('L','L','L','L','L','L','L','L');
			$arr2=array(12,38,38,38,38,38,38,38);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array($i, $rows['VESSEL_NAME'], $rows['VESSEL_TYPE'], $bysseness, $dischargeport, $opendate, $cargo_name,$cargoqty));
		}
	}
	
	
	
$filename = "Vessel Open Position Report ".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}

function create_VCFVF_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$fcaid = $_REQUEST['fcaid'];
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	
	class PDF extends FPDF
	{
		
		
	}
	
	$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	
	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('FVF Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('FVF Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

	$pdf->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
	$pdf->SetFont('daxcondensedlight','',16);
	$pdf->SetTextColor(17,85,124);
	$pdf->Cell(0,4,"VOYAGE FINANCIALS",0,1,'C');
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(290);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Fixture Type : VC Out        Vessel : ".$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME")."        Vessel Type : ".$obj->getFun6()."        CP Date : ".date('d-m-Y',strtotime($obj->getFun3()))."        Voy No. : ".$obj->getFun8()."        TC NO. : ".$obj->getFun229()."        Voy Fin Name : ".$obj->getFun9()));
	
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$pdf->SetFont('daxcondensedlight','',10);
	$laycanstartdate = date('d-m-Y',strtotime($obj->getCargoPlanningData($obj->getFun206(),'LAYCAN_SDATE')));
	if($laycanstartdate=='01-01-1970'){$laycanstartdate='';}
	$laycanenddate = date('d-m-Y',strtotime($obj->getCargoPlanningData($obj->getFun206(),'LAYCAN_EDATE')));
	if($laycanenddate=='01-01-1970'){$laycanenddate='';}
	if($obj->getFun155() ==1){$freighttype = 'Sigle';}else{$freighttype = 'Distributed';}
	$pdf->Cell(0,5,"Freight & Cargo Details",0,1,'L',1);
	if($obj->getFun158() ==1)
	{
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L');
		$arr2=array(50,100,45,45,45);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		if($obj->getFun159()==1){$freight_or_lumsum = "Base Freight (USD/MT) : ".$obj->getFun162();}else{$freight_or_lumsum = "Lumpsum (USD) : ".$obj->getFun164();}
		$pdf->Row1(array($freight_or_lumsum,"Cargo Name : ".$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),"Laycan Starts : ".$laycanstartdate,"Laycan Ends : ".$laycanenddate,"Cargo Qty(MT) : ".$obj->getFun163()));
	}
	if($obj->getFun158() ==2)
	{
		if($obj->getFun228() ==1)
		{
			if($obj->getFun171() ==1)
			{
				$pdf->SetFont('daxcondensedlight','',9);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L');
				$arr2=array(50,100,45,45,45);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				//echo $laycanstartdate;die;
				$pdf->Row(array("Lump-sum Amount (USD) : ".$obj->getFun172(), "Cargo Name : ".$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),"Laycan Starts : ".$laycanstartdate,"Laycan Ends : ".$laycanenddate,"Cargo Qty(MT) : ".$obj->getFun173()));
			}
			else
			{
				$pdf->SetFont('daxcondensedlight','',9);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L');
				$arr2=array(100,65,55);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("Cargo Name : ".$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),"Laycan Starts : ".$laycanstartdate,"Laycan Ends : ".$laycanenddate));
				
				$pdf->SetFont('daxcondensedlight','',10);
				$pdf->SetTextColor(17,85,124);
				$arr1=array('L','L','L','L');
				$arr2=array(100,100,39,38);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row(array("Freight Specs", "Customer","Amount(USD)","Quantity (MT)"));
				
				$sql1 = "select * from freight_cost_estimete_slave12 where FCAID='".$obj->getFun1()."'";
				$res1 = mysql_query($sql1);
				while($rows1 = mysql_fetch_assoc($res1))
				{
					$pdf->SetFont('daxcondensedlight','',9);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L');
					$arr2=array(100,100,39,38);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row(array($rows1['FREIGHT_SPECS'], $obj->getVendorListNewBasedOnID($rows1['CUSTOMER']), $rows1['TOTAL_AMOUNT'], $rows1['TOTAL_QTY']));
				}
			}
		}
		else
		{
			
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(17,85,124);
			$arr1=array('L','L','R','R','R','R','R');
			$arr2=array(60,50,33,33,33,33,33);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array("Shipper/Charterer", "Cargo","Cargo(CBM)","Cargo (MT)","Rate USD/MT","Amount(USD)","Demurrage(USD)"));
			
			$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS='1'";
			$res1 = mysql_query($sql1);
			$num1 = mysql_num_rows($res1);
			if($num1 > 0)
			{
				$pdf->SetFont('daxcondensedlight','',10);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L');
				$arr2=array(290);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("Main Cargo Details","",""));
				
				$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS='1'";
				$res1 = mysql_query($sql1);
				while($rows1 = mysql_fetch_assoc($res1))
				{
					$pdf->SetFont('daxcondensedlight','',9);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','R','R','R','R','R');
					$arr2=array(60,50,33,33,33,33,33);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row(array($obj->getVendorListNewBasedOnID($rows1['SHIPPER_CHARTER']),$obj->getMaterialCodeDesBasedOnId($rows1['CARGOID']), $rows1['CARGO_CBM'], $rows1['CARGO_MT'], $rows1['RATE_USD_MT'], $rows1['AMOUNT_USD'], $rows1['DEM_AMT']));
				}
			}
			
			$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS='2'";
			$res1 = mysql_query($sql1);
			$num1 = mysql_num_rows($res1);
			if($num1 > 0)
			{
				$pdf->Ln(1);
				$pdf->SetFont('daxcondensedlight','',10);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L');
				$arr2=array(100,65,55);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("Overage","",""));
				
				
				$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS='2'";
				$res1 = mysql_query($sql1);
				while($rows1 = mysql_fetch_assoc($res1))
				{
					$pdf->SetFont('daxcondensedlight','',9);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','R','R','R','R','R');
					$arr2=array(60,50,33,33,33,33,33);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row(array($obj->getVendorListNewBasedOnID($rows1['SHIPPER_CHARTER']),$obj->getMaterialCodeDesBasedOnId($rows1['CARGOID']), $rows1['CARGO_CBM'], $rows1['CARGO_MT'], $rows1['RATE_USD_MT'], $rows1['AMOUNT_USD'], $rows1['DEM_AMT']));
				}
			}
			
			$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS='3'";
			$res1 = mysql_query($sql1);
			$num1 = mysql_num_rows($res1);
			if($num1 > 0)
			{
				$pdf->Ln(1);
				$pdf->SetFont('daxcondensedlight','',10);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L');
				$arr2=array(100,65,55);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("Dead-freight","",""));
				
				while($rows1 = mysql_fetch_assoc($res1))
				{
					$pdf->SetFont('daxcondensedlight','',9);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','R','R','R','R','R');
					$arr2=array(60,50,33,33,33,33,33);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row(array($obj->getVendorListNewBasedOnID($rows1['SHIPPER_CHARTER']),$obj->getMaterialCodeDesBasedOnId($rows1['CARGOID']), $rows1['CARGO_CBM'], $rows1['CARGO_MT'], $rows1['RATE_USD_MT'], $rows1['AMOUNT_USD'], $rows1['DEM_AMT']));
				}
			}
		}
	}
	
	if($obj->getFun158() ==3)
	{
		if($obj->getFun155() ==1)
		{
			$pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L','L');
			$arr2=array(50,100,45,45,45);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$rdoMMarket= $obj->getFun45();
			if($rdoMMarket == 1){$freight_or_lumsum = "Gross Frt (USD/MT) : ".$obj->getFun47();}else{$freight_or_lumsum = "Lumpsum (USD) : ".$obj->getFun48();}
			$pdf->Row1(array($freight_or_lumsum,"Cargo Name : ".$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),"Laycan Starts : ".(($laycanstartdate!='01-01-1970')?$laycanstartdate:''),"Laycan Ends : ".(($laycanenddate!='01-01-1970')?$laycanenddate:''),"Cargo Qty(MT) : ".$obj->getFun50()));
			$pdf->Row1(array("Addnl. Cargo Frt(USD/MT) : ".$obj->getFun49(),"Addnl. Cargo Qty(MT) : ".$obj->getFun54(),"Total Frt(USD) : ".$obj->getFun69(),"",""));
		}
		else
		{
		    $pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(100,65,55);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Cargo Name : ".$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),"Laycan Starts : ".(($laycanstartdate!='01-01-1970')?$laycanstartdate:''),"Laycan Ends : ".(($laycanenddate!='01-01-1970')?$laycanenddate:'')));
			
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(17,85,124);
			$arr1=array('L','L','L','L','L','L','L','L','L','L');
			$arr2=array(50,40,20,25,30,22,22,21,22,25);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array("Customer","Agreed Gross Frt(Local Currency/MT)","Currency","Exchange Rate","Agreed Gross Frt (USD/MT)", "Quantity (MT)", "Gross Frt (USD)", "Brokerage(%)", "Net Brokerage", "Final Net Frt (USD)"));
			
			$sql1 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getFun1()."'";
			$res1 = mysql_query($sql1);
			while($rows1 = mysql_fetch_assoc($res1))
			{
			    $pdf->SetFont('daxcondensedlight','',9);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','R','L','R','R','R','R','R','R','R');
				$arr2=array(50,40,20,25,30,22,22,21,22,25);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row(array($obj->getVendorListNewBasedOnID($rows1['QTY_VENDORID']), number_format($rows1['AGREED_GROSS_FREIGHT_LOCAL'],2,'.',''), $rows1['CURRENCYID'], number_format($rows1['EXCHANGE_RATE'],3,'.',''), number_format($rows1['AGREED_GROSS_FREIGHT'],2,'.',''), number_format($rows1['QUANTITY'],2,'.',''), number_format($rows1['GROSS_FREIGHT'],2,'.',''), number_format($rows1['BROKERAGE'],2,'.',''), number_format($rows1['NET_BROKERAGE'],2,'.',''), number_format($rows1['NET_FREIGHT'],2,'.','')));
			}
		}
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Passage & Ports"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L','L','L','L','L','L','L');
	$arr2=array(39,39,25,25,25,25,24,24,24,25);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("From Port","To Port","Distance Type","Passage","Speed Type","Total Dist","Total Days", "SECA Dist", "SECA Days","Margin Dist. (%)"));
	
	$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    $pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','R','R','R','R','R');
	    $arr2=array(39,39,25,25,25,25,24,24,24,25);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row(array($obj->getPortNameBasedOnID($rows1['FROM_PORT']), $obj->getPortNameBasedOnID($rows1['TO_PORT']), $obj->getDistanceTypeBasedOnID_New($rows1['DIS_TYPE']), $obj->getPassageTypeNameBasedOnID($rows1['PASSAGE_TYPE']), $obj->getSelectSpeedNamebasedOnID($rows1['SPEED_TYPE']), $rows1['DISTANCE'], $rows1['TOTAL_VOYAGE_DAYS'], $rows1['SECA_DISTANCE'], $rows1['SECA_DAYS'], $rows1['MARGIN_DISTANCE']));
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Load Port(s)"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(67,35,35,35,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Port","Costs(USD)","Qty(MT)","Rate(MT/Day)","LP Terms","Work Days","Idle Days"));
	
	$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    $pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R','R','L','R','R');
	    $arr2=array(67,35,35,35,35,35,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
	
		$pdf->Row(array($obj->getPortNameBasedOnID($rows1['FROM_PORT']), number_format($rows1['LOAD_PORT_COST'],3,'.',''), number_format($rows1['LOAD_PORT_QTY'],3,'.',''), number_format($rows1['LOAD_PORT_RATE'],3,'.',''), $obj->getLPTermsNameBasedOnID($rows1['LOAD_PORT_TERMS']), number_format($rows1['LOAD_PORT_WORK_DAYS'],3,'.',''), number_format($rows1['LOAD_PORT_IDEAL_DAYS'],3,'.','')));
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Discharge Port(s)"));
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(67,35,35,35,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Port","Costs(USD)","Qty(MT)","Rate(MT/Day)","DP Terms","Work Days","Idle Days"));
	
	$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    $pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R','R','L','R','R');
	    $arr2=array(67,35,35,35,35,35,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array($obj->getPortNameBasedOnID($rows1['TO_PORT']), number_format($rows1['DISC_PORT_COST'],3,'.',''), number_format($rows1['DISC_PORT_QTY'],3,'.',''), number_format($rows1['DISC_PORT_RATE'],3,'.',''), $obj->getLPTermsNameBasedOnID($rows1['DISC_PORT_TERMS']), number_format($rows1['DISC_PORT_WORK_DAYS'],3,'.',''), number_format($rows1['DISC_PORT_IDEAL_DATE'],3,'.','')));
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Transit Port(s)"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','R','R');
	$arr2=array(60,45,45);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Port","Costs(USD)","Idle Days"));
	
	$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    $pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R');
	    $arr2=array(60,45,45);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array($obj->getPortNameBasedOnID($rows1['FROM_PORT']), number_format($rows1['TRANSIT_PORT_COST'],2,'.',''), number_format($rows1['TRANSIT_PORT_IDLE_DAYS'],2,'.','')));
	}
	
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Demurrage(USD)"));
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','R','R','R');
	$arr2=array(60,30,30,30);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Port","Est","Actual","Net"));
	
	$sql2 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res2 = mysql_query($sql2);
	while($rows2 = mysql_fetch_assoc($res2))
	{
	    $pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R','R');
		$arr2=array(60,30,30,30);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		if($rows2['IS_SHOW_DDCLP'] =='')
		{
			
			$pdf->Row(array("LP-".$obj->getPortNameBasedOnID($rows2['FROM_PORT']), number_format($rows2['DDCLP_ESTCOST'],2,'.',''), number_format($rows2['DDCLP_REALCOST'],2,'.',''), number_format($rows2['DDCLP_NETCOST'],2,'.','')));
		}
		if($rows2['IS_SHOW_DDCDP'] =='')
		{
			
			$pdf->Row(array("DP-".$obj->getPortNameBasedOnID($rows2['TO_PORT']), number_format($rows2['DDCDP_ESTCOST'],2,'.',''), number_format($rows2['DDCDP_REALCOST'],2,'.',''), number_format($rows2['DDCDP_NETCOST'],2,'.','')));
		}
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Total(s)"));
	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(80,80,80);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Laden Dist : ".number_format($obj->getFun55(),2,'.',''),"Ballast Dist : ".number_format($obj->getFun56(),2,'.',''),"Total Dist : ".number_format($obj->getFun63(),2,'.','')));
	$pdf->Row1(array("Laden Days : ".number_format($obj->getFun57(),2,'.',''),"Ballast Days : ".number_format($obj->getFun58(),2,'.',''),"Total Sea Days : ".number_format($obj->getFun59(),2,'.','')));
	$pdf->Row1(array("Port Idle Days : ".number_format($obj->getFun60(),2,'.',''),"Port Work Days : ".number_format($obj->getFun61(),2,'.',''),"Total Days : ".number_format($obj->getFun62(),2,'.','')));
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Bunkers Estimated"));

	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L');
	$arr2=array(50,40,40,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Bunker Grade","Qty(MT)","Price(USD)","Amt(USD)"));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("SECA"));
	
	$sql1 = "select * from freight_cost_estimete_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='SECA'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    if($rows1['EST_COST']>0)
		{
			$pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,40,40,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($obj->getBunkerGradeBasedOnID($rows1['BUNKERGRADEID']), number_format($rows1['EST_MT'],2,'.',''), number_format($rows1['EST_PRICE'],2,'.',''), number_format($rows1['EST_COST'],2,'.','')));
		}
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Non-SECA"));
	
	$sql1 = "select * from freight_cost_estimete_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='NON_SECA'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    if($rows1['EST_COST']>0)
		{
			$pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,40,40,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($obj->getBunkerGradeBasedOnID($rows1['BUNKERGRADEID']), number_format($rows1['EST_MT'],2,'.',''), number_format($rows1['EST_PRICE'],2,'.',''), number_format($rows1['EST_COST'],2,'.','')));
		}
	}
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Bunkers Consumed"));
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L');
	$arr2=array(50,40,40,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Bunker Grade","Qty(MT)","Price(USD)","Amt(USD)"));
	
	$sql1 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."' and IDENTIFY='CONSUMPTION'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    if($rows1['COST']>0)
		{
			
			$pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,40,40,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($obj->getBunkerGradeBasedOnID($rows1['BUNKERGRADEID']), number_format($rows1['QTY'],2,'.',''), number_format($rows1['PRICE'],2,'.',''), number_format($rows1['COST'],2,'.','')));
		}
	}
	
	
    $pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Bunkers Supplied"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(40,30,30,30,50,50);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Grade","Qty(MT)","Price(USD)","Amt(USD)", "Port", "Vendor"));
	
	$sql1 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."' and IDENTIFY='SUPPLY'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R','R','L','L');
		$arr2=array(40,30,30,30,50,50);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array($obj->getBunkerGradeBasedOnID($rows1['BUNKERGRADEID']), number_format($rows1['QTY'],2,'.',''), number_format($rows1['PRICE'],2,'.',''), number_format($rows1['COST'],2,'.',''),$obj->getPortNameBasedOnID($rows1['PORT']),$obj->getVendorListNewBasedOnID($rows1['VENDORID'])));
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Voyage Ops Cost(USD)"));
	

	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L','L');
	$arr2=array(60,45,45);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Cost Type","%/Rate","Cost(USD)"));
	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R','R');
	$arr2=array(60,45,45);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);

	$pdf->Row(array("Add. Comm.", number_format($obj->getFun74(),2,'.',''), number_format($obj->getFun75(),2,'.','')));
	$operationexpenses = 0;
	$i=1;
	$sql1 = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	  
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R');
		$arr2=array(60,45,45);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("Brokerage(".$i.")", number_format($rows1['BROKAGE_PERCENT'],2,'.',''), number_format($rows1['BROKAGE_AMT'],2,'.','')));
		$operationexpenses = $operationexpenses + $rows1['BROKAGE_AMT'];
		$i++;
	}
	
	$sql1 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='ORC' and RAW_AMOUNT>0";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R','R');
		$arr2=array(60,45,45);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array($obj->getOwnerRelatedCostNameBasedOnID($rows1['IDENTY_ID']), "", number_format($rows1['RAW_AMOUNT'],2,'.','')));
		$operationexpenses = $operationexpenses + $rows1['RAW_AMOUNT'];
	}
	
	$operationexpenses = $operationexpenses + $obj->getFun143();
	$pdf->Row(array("CVE", "", number_format($obj->getFun143(),2,'.','')));
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Other Income(USD)"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(17,85,124);
	$arr1=array('L','L');
	$arr2=array(60,30,30,30);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Income Type","Amt(USD)","Add Comm(%)","Nett Amt(USD)"));
	
	$sql1 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='OTHERINCOME' and RAW_AMOUNT>0";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
	    
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R');
		$arr2=array(60,30,30,30);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array($rows1['IDENTY_ID'], number_format($rows1['RAW_AMOUNT'],2,'.','')));
	}
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("TC In Hire (USD)"));
	
	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(60,28);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row(array("USD/Day", number_format($obj->getFun91(),2,'.','')));
	
	$pdf->Row(array("Hireage", number_format($obj->getFun132(),2,'.','')));
	
	$pdf->Row(array("Ballast Bonus", number_format($obj->getFun145(),2,'.','')));
	
	$pdf->Row(array("Add Comm(%)",number_format($obj->getFun129(),2,'.','')));
	
	$pdf->Row(array("Add Comm(USD)", number_format($obj->getFun130(),2,'.','')));
	
	$pdf->Row(array("Nett Hireage(USD)", number_format($obj->getFun131(),2,'.','')));
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(277);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Results(USD)"));
	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(60,28);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row(array("Nett Hireage(USD)", number_format($obj->getFun131(),2,'.','')));
	
	$pdf->Row(array("Port Exp.", number_format($obj->getFun153(),2,'.','')));
	
	$pdf->Row(array("Bunker Exp.", number_format($obj->getFun152(),2,'.','')));
	
	$pdf->Row(array("Ops Exp.", number_format($operationexpenses,2,'.','')));
	
	$pdf->Row(array("Gross Ops Exp.", number_format(($obj->getFun131() + $obj->getFun153() + $obj->getFun152() + $operationexpenses),2,'.','')));
	
	$pdf->Row(array("Gross Breakeven(USD)", number_format($obj->getFun226(),2,'.','')));
	
	$pdf->Row(array("Breakeven (USD/MT)", number_format($obj->getFun227(),2,'.','')));
	
	$pdf->Row(array("Revenue", number_format($obj->getFun86(),2,'.','')));
	
	$pdf->Row(array("Voy Earnings", number_format($obj->getFun89(),2,'.','')));
	
	$pdf->Row(array("VE + Dem", number_format($obj->getFun92(),2,'.','')));
	
	$pdf->Row(array("Gross Daily TCE", number_format($obj->getFun90(),2,'.','')));
	
	
	
	$filename = "VC FVF ".$obj->getFun8().".pdf";
	$pdf->Output($filename,'D');
}

function req_relet_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$comid = $_REQUEST['comid'];
	$req_id = $_REQUEST['req_id'];
	$fcaid = $obj->getLatestCostSheetIDRelet($comid);
$obj->viewCargoReletEstimationTempleteRecordsNew($fcaid);
	if($obj->getFun2()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun2()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
    //echo $_SESSION['email'] ;die;
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			$this->Cell(0,4,"Tel: ".$_SESSION['phone']."  email: ".$_SESSION['email'],0,1,'C');
			
		}
	}
	
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$sql = "select * from request_relet_master where REQ_ID='".$req_id."'";
$res = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{
$name = $rows['NAME'];
$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Account ".$name,0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(25,5,32,29,5,31,33,5,35);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Payment Type",":",$rows['ACCOUNT_TYPE'],"Payment No/Description",":",$rows['PAYMENT_NO'],"CP Date",":",date("d-M-Y",strtotime($rowscoa['COA_DATE']))));

$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($rows['DATE'])),"Fixture Ref.",":",$obj->getCompareReletTableData($comid,"CARGO_RELET_NO"),"Vessel",":",$obj->getVesselIMOData($obj->getCompareCargoReletData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")));


$pdf->Row1(array("Vendor",":",$obj->getVendorListNewBasedOnID($rows['VENDOR']),"Remarks",":",$rows['REMARKS']));

if(date("d-M-Y",strtotime($rows['INVOICE_DATE'])) == '01-Jan-1970'){$I_Date = '';}
else{$I_Date = date("d-M-Y",strtotime($rows['INVOICE_DATE']));}
$costtype = explode(" : ",$name);
$pdf->Row1(array("Cost Type Desc.",":",$name, "Vendor Invoice Amt.",":",$obj->getNumberFormat($rows['INVOICE_AMT']),"Invoice Date",":",$I_Date));

		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$name.": Details",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Total Payable",":",$obj->getNumberFormat($rows['TTL_OUTSTANDINGS'])));
		
		$sql6 = "select * from request_relet_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$rows['NAME']."' and VENDOR='".$rows['VENDOR']."'";
		$res6 = mysql_query($sql6);
		$i = 0;
		$cost = 0; $cost_deduction = 0;
		while($rows6 = mysql_fetch_assoc($res6))
		{
			$i = $i+1; $cost_deduction_1 = 0;
			$cost = $cost+$rows6['REQ_TO_PAY'];
			
			$sql7 = "select * from request_deduction_master where REQ_ID='".$rows6['REQ_ID']."'";
			$res7 = mysql_query($sql7);
			while($rows7 = mysql_fetch_assoc($res7)){$cost_deduction = $cost_deduction+$rows7['COST']; $cost_deduction_1 = $cost_deduction_1+$rows7['COST'];}
			
			if($rows6['REQ_ID'] == $req_id){break;}
			$pdf->Row1(array("Amount Paid ".$i,":",$obj->getNumberFormat($rows6['REQ_TO_PAY'])));
		}
		
		$cost = $ttl-$cost;
		
		$cost = $cost-$cost_deduction;
		
		$pdf->Row1(array("Balance Outstanding",":",$obj->getNumberFormat($cost)));
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Add",0,1,'L');
		
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_relet_master_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='ADD' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Less",0,1,'L');
		
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_relet_master_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='SUB' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Net Payable ",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['NET_AMT'])));
		
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Requested To Pay/Recover",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['REQ_TO_PAY'])));
		
		$pdf->Ln(5);
		$sql2 = "select * from request_relet_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$costtype[0]."' and NAME_ID='".$_REQUEST['name_id']."' and GRADEID='".$_REQUEST['grade']."' and VENDOR='".$_REQUEST['vendorid']."' and STATUS='1' and REQ_ID<'".$rows6['REQ_ID']."'";
		$res2 = mysql_query($sql2);
		$rec2 = mysql_num_rows($res2);
		if($rec2>0)
		{
			$pdf->SetFont('Arial','B',10);
		    $pdf->SetTextColor(27,119,166);
			$arr1=array('C','C','C','C','C','C');
			$arr2=array(20,30,40,40,30,30);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array("S.No.","Cost Type","Cost Desc.","Vendor","Payment No.","Requested To Pay"));
			$i = 0;
			while($rows2 = mysql_fetch_assoc($res2))
			{$i++;
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('C','L','L','L','L','R');
			    $arr2=array(20,30,40,40,30,30);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row(array($i,$costtype[0],$costtype[1],$obj->getVendorListNewBasedOnID($rows2['VENDOR']),$rows2['PAYMENT_NO'],$rows2['REQ_TO_PAY']));
			}
		}
}//echo 1;die;

$filename = "Payment request.pdf";

$pdf->Output($filename,'D');
}

function OtherReletInvoicepdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];
    $sql = "select * from other_relet_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	$fcaid = $obj->getLatestCostSheetIDRelet($rows['COMID']);
    $obj->viewCargoReletEstimationTempleteRecordsNew($fcaid);
	
	$sql1 = "select * from cargo_relet_estimate_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='IN'";
	$res1 = mysql_query($sql1);
	$lp_name = array(); 
	$dp_name = array();
	while($rows1 = mysql_fetch_assoc($res1))
	{   
		if($rows1['PORT_TYPE'] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
		else{$dp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
	}
	
	$lp_name  = implode(', ',$lp_name);
	$dp_name  = implode(', ',$dp_name);

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddress']      = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddress'],0,1,'C');	
		
	}
}	
	
	$fcaid = $obj->getLatestCostSheetIDRelet($rows['COMID']);
    $obj->viewCargoReletEstimationTempleteRecordsNew($fcaid);
	
	$sql1 = "select * from cargo_relet_estimate_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='IN'";
	$res1 = mysql_query($sql1);
	$lp_name = array(); 
	$dp_name = array();
	while($rows1 = mysql_fetch_assoc($res1))
	{   
		if($rows1['PORT_TYPE'] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
		else{$dp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
	}
	
	$lp_name  = implode(', ',$lp_name);
	$dp_name  = implode(', ',$dp_name);
	
	if($obj->getFun2()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun2()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Other Relet Invoice Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Other Relet Invoice Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Invoice No.",$rows['MESSAGE'],"Contract Ref.","CP Date ".date('d-m-Y',strtotime($rowscoa['COA_DATE']))));
	$invdate = date('d-m-Y',strtotime($rows['DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	$duedate = date('d-m-Y',strtotime($rows['DUE_DATE'])); if($duedate=='01-01-1970'){$duedate = '';}
	$pdf->Row(array("Invoice Date",$invdate,"Due Date",$duedate));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($obj->getCompareCargoReletData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),"",""));
	$pdf->Row(array("Port of Loading",$lp_name,"Port of Discharging",$dp_name));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Invoice To:","Invoice From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($rows['VENDOR'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'STREET_1')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
		
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['REMARKS'],number_format($rows['GROSS_AMT'],2,'.',',')));

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from other_relet_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from other_relet_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount Invoiced",number_format($rows['NET_PAYABLE'],2,'.',',')));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount Invoiced (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['NET_PAYABLE'],$currency))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);
	
$filename = "Invoice Of ".$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME")."(".$rows['I_TYPE'].")".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}


function invoiceReletpdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];
    $sql = "select * from freight_invoicerelet_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	
	$fcaid = $obj->getLatestCostSheetIDRelet($rows['COMID']);
	$obj->viewCargoReletEstimationTempleteRecordsNew($fcaid);
	$sql1 = "select * from cargo_relet_estimate_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='IN'";
	$res1 = mysql_query($sql1);
	$lp_name = array(); 
	$dp_name = array();
	while($rows1 = mysql_fetch_assoc($res1))
	{   
		if($rows1['PORT_TYPE'] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
		else{$dp_name[]= $obj->getPortNameBasedOnID($rows1['PORTID']);}
	}
	$lp_name  = implode(', ',$lp_name);
	$dp_name  = implode(', ',$dp_name);
	
	
	
	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddress']      = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddress'],0,1,'C');
		
		
	}
}	
	
	
	
	if($obj->getFun2()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun2()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Cargo Relet Hire Invoice Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Cargo Relet Hire Invoice Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Invoice No.",$rows['MESSAGE'],"Contract Ref.","CP Date ".date("d-m-Y",strtotime($rowscoa['COA_DATE']))));
	$invdate = date('d-m-Y',strtotime($rows['DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	$duedate = date('d-m-Y',strtotime($rows['DUE_DATE'])); if($duedate=='01-01-1970'){$duedate = '';}
	$pdf->Row(array("Invoice Date",$invdate,"Due Date",$duedate));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($obj->getCompareCargoReletData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),"",""));
	$pdf->Row(array("Port of Loading",$lp_name,"Port of Discharging",$dp_name));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Invoice To:","Invoice From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($rows['VENDOR'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'STREET_1')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
		
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['REMARKS'],number_format($rows['NET_AMOUNT'],2,'.',',')));

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from freight_invoicerelet_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['CHK_BUNK_SUR']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Bunker Surcharge","(+) ".number_format($obj->getFun34(),2,'.',',')));
	}
	
	if($rows['CHK_DEM']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Demurrage","(+) ".number_format($obj->getFun35(),2,'.',',')));
	}
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from freight_invoicerelet_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['BROKERAGE'] > 0)
	{
		$pdf->Row1(array("     Brokerage(".$rows['BROKERAGE_PERCENT']."%)","(-) ".number_format($rows['BROKERAGE'],2,'.',',')));
	}
	
	if($rows['ADDCOM_AMOUNT'] > 0)
	{
		$pdf->Row1(array("     Less Addcom(".$rows['ADDCOM']."%)","(-) ".number_format($rows['ADDCOM_AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount Invoiced",number_format($rows['NET_PAYABLE'],2,'.',',')));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount Invoiced (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['NET_PAYABLE'],$currency))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);
	
$filename = "Invoice Of ".$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME")."(".$rows['I_TYPE'].")".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}



function getTC_BalticReport()
{
	$obj = new data();
	$obj->funConnect();
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
    //echo $_SESSION['email'] ;die;
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,125,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Vessel/TC Perf against Baltic Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Vessel/TC Perf against Baltic Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,5,"Vessel/TC Performance against Baltic",0,1,'C');
	$pdf->Ln(3);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(255,255,255); 
	$arr1=array('L','L','L','L','L','L','L','L','L','L','R','L','L','R','R','R');
	$arr2=array(8,16,16,16,21,21,22,22,20,17,17,17,16,16,16,16);
	$arr3=array("Sr. No.","TC No.","CP Date","Vessel","Charterer","Owner","Del Date","Re-Del Date","Del Port","Re-Del Port","Daily Hire(USD)","Baltic Route","Baltic Route Date","Baltic Route Value(USD)","TCE Diff","TCE Diff(%)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql = "select chartering_estimate_tc_master.TC_NO, chartering_estimate_tc_master.CP_DATE1, chartering_estimate_tc_master.VESSEL_IMO_ID, SEL_CHARTERER, OWNERS_PI, DEL_DATE, RE_DEL_DATE, DEL_RANGE_PORT, RE_DEL_RANGE, HIRE_FIX_PER, EXCHANGE_RATE, BALTIC_ROUTE, (select CONCAT(CODE, ' - ' ,NAME) from baltic_master where baltic_master.BALTICID=chartering_estimate_tc_master.BALTIC_ROUTE) as BALTIC_ROUTENAME, BALTIC_DATE, BALTIC_RATE from chartering_estimate_tc_compare inner join chartering_estimate_tc_master on chartering_estimate_tc_master.TCOUTID= chartering_estimate_tc_compare.TCOUTID WHERE chartering_estimate_tc_compare.MODULEID='".$_SESSION['moduleid']."' AND chartering_estimate_tc_compare.MCOMPANYID='".$_SESSION['company']."' and chartering_estimate_tc_compare.FINAL_ID!='' and chartering_estimate_tc_master.FIXED=1 and chartering_estimate_tc_compare.STATUS in (1,2,3)";
	$res = mysql_query($sql) or die($sql);
	$i = 1;
	while($rows = mysql_fetch_assoc($res))
	{
		$pdf->SetFillColor(255,255,255);
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','R','L','L','R','R','R');
	    $arr2=array(8,16,16,16,21,21,22,22,20,17,17,17,16,16,16,16);
		
		if(date('d-m-Y',strtotime($rows['BALTIC_DATE']))!='01-01-1970'){$txtBalticDate = date('d-m-Y',strtotime($rows['BALTIC_DATE']));}else{$txtBalticDate = '';}
		$diff = number_format(($rows['BALTIC_RATE'] - ($rows['HIRE_FIX_PER']*$rows['EXCHANGE_RATE'])),2,'.','');
		$diffper = number_format((($diff/$rows['BALTIC_RATE'])*100),2,'.','');
		
		$arr3=array($i, $rows['TC_NO'], date('d-m-Y',strtotime($rows['CP_DATE1'])), $obj->getVesselIMOData($rows['VESSEL_IMO_ID'], 'VESSEL_NAME'), $obj->getVendorListNewData($rows['SEL_CHARTERER'],"NAME"), $obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"), date('d-m-Y H:i',strtotime($rows['DEL_DATE'])), date('d-m-Y H:i',strtotime($rows['RE_DEL_DATE'])), $rows['DEL_RANGE_PORT'], $rows['RE_DEL_RANGE'], number_format($rows['HIRE_FIX_PER']*$rows['EXCHANGE_RATE'],2,'.',''), $rows['BALTIC_ROUTENAME'], $txtBalticDate, $rows['BALTIC_RATE'], $diff, $diffper);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		$i++;			  
	}

	$filename = "Vessel_TC Performance against Baltic ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}



function getCargoTonnageReport()
{
	$obj = new data();
	$obj->funConnect();
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Cargo Tonnage Book Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Cargo Tonnage Book Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,5,"Cargo Tonnage Book Report",0,1,'C');
	$pdf->Ln(3);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(255,255,255); 
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(8,23,22,15,15,18,18,15,15,15,15,15,15,15,15,24,15);
	$arr3=array("Sr. No.","Charterer","Owner","Basin","COA/ Spot","Laycan From","Laycan To","LP","DP","Cargo Name","Stem Size(MT)","Tolerance /Terms","B Hedge","Biz Type","Vessel Type","Comments", "Status");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$txtFrom_Date = $_REQUEST['txtFrom_Date'];
	$txtTo_Date   = $_REQUEST['txtTo_Date'];
	$selMonth     = $_REQUEST['selMonth'];
	$selYear      = $_REQUEST['selYear'];
	$selQtr       = $_REQUEST['selQtr'];
	$selStatus    = $_REQUEST['selStatus'];
	$selBType     = $_REQUEST['selBType'];
	$fromdate = $todate = '';
	if($selQtr==1 && $selYear!=''){$fromdate = $selYear.'-01-01';$todate = $selYear.'-03-31';}
	if($selQtr==2 && $selYear!=''){$fromdate = $selYear.'-04-01';$todate = $selYear.'-06-30';}
	if($selQtr==3 && $selYear!=''){$fromdate = $selYear.'-07-01';$todate = $selYear.'-09-30';}
	if($selQtr==4 && $selYear!=''){$fromdate = $selYear.'-10-01';$todate = $selYear.'-12-31';}
	
	$sQuery = "SELECT OPEN_CARGOID, CPID, MODULEID, MCOMPANYID, COA_DATE, (select count(DISTINCT(freight_cost_estimete_master.COMID)) from freight_cost_estimete_master where freight_cost_estimete_master.OPEN_CARGOID=open_cargo_master.OPEN_CARGOID and SHEET_NO and COAID is NULL) as VOYAGEBOOk, (select count(DISTINCT(freight_cost_estimete_master.COMID)) from freight_cost_estimete_master where freight_cost_estimete_master.OPEN_CARGOID=open_cargo_master.OPEN_CARGOID and SHEET_NO is not NULL and COAID is not NULL) as COABOOk, (select count(DISTINCT(cargo_relet_estimate_masster.COMID)) from cargo_relet_estimate_masster where cargo_relet_estimate_masster.OPEN_CARGOID=open_cargo_master.OPEN_CARGOID and SHEET_NO is not NULL and COAID is NOT NULL) as COARELETBOOk, (select MATERIAL_TYPE from cargo_master where cargo_master.MATERIALID = open_cargo_master.CARGO) as CARGONAME, (select NAME from basein_master where basein_master.BASEINID = open_cargo_master.BASINID) as BASINAME, LOAD_PORT, DISCHARGE_PORT, (select NAME from vendor_master where vendor_master.CODE = open_cargo_master.CHARTERER and vendor_master.MCOMPANYID='".$_SESSION['company']."') as CHARTERERNAME, (select NAME from vendor_master where vendor_master.CODE = open_cargo_master.OWNER and vendor_master.MCOMPANYID='".$_SESSION['company']."') as OWNERNAME, COA_SPOT, (case when (COA_SPOT = 1) THEN 'SPOT' ELSE 'COA' END) as COASPOT, CARGOSTEAMSIZE, LAYCAN_SDATE, LAYCAN_EDATE, BASE_FREIGHT, BUNKER_HEDGE, CARGO_RELET, TOLERANCE, (case when (CARGO_RELET = 1) THEN 'Cargo Relet' ELSE 'Voyage' END) as CARGORELET, (case when (BUNKER_HEDGE = 1) THEN 'Yes' ELSE 'No' END) as BUNKER_HEDGE1, UPDATE_STATUS, VESSEL_TYPE, (select VesselType from vessel_type_master where vessel_type_master.VesselTypeId = open_cargo_master.VESSEL_TYPE) as VESSEL_TYPE1, REMARKS FROM open_cargo_master where UPDATE_STATUS =2 and MCOMPANYID='".$_SESSION['company']."' and BUSINESSTYPEID='".$selBType."'";
	
	if($txtFrom_Date!='' && $txtTo_Date!='')
	{
		$sQuery.= " and LAYCAN_SDATE >='".date('Y-m-d',strtotime($txtFrom_Date))."' and LAYCAN_SDATE <='".date('Y-m-d',strtotime($txtTo_Date))."'";
	}
	if($selMonth)
	{
		$sQuery.= " and month(LAYCAN_SDATE) ='".$selMonth."'";
	}
	if($selYear && $fromdate=='' && $todate=='')
	{
		$sQuery.= " and year(LAYCAN_SDATE) ='".$selYear."'";
	}
	if($selYear!='' && $fromdate!='' && $todate!='')
	{
		$sQuery.= " and LAYCAN_SDATE >='".$fromdate."' and LAYCAN_SDATE <='".$todate."'";
	}
	
	$i = 1;
	$rResult = mysql_query($sQuery) or die($sQuery);
	while($rows = mysql_fetch_array($rResult))
	{
	    if($rows['VOYAGEBOOk']>0 || $rows['COABOOk']>0 || $rows['COARELETBOOk']>0){$status = 'Booked';}else{$status = 'Open';}
		
		$sqlload = "select GROUP_CONCAT(PortName) as PORTNAME from port_master where PortId in (".$rows['LOAD_PORT'].")";
	    $resultload = mysql_query($sqlload) or die($sqlload);
	    $rowsload   = mysql_fetch_assoc($resultload);
		
		$sqldis = "select GROUP_CONCAT(PortName) as PORTNAME from port_master where PortId in (".$rows['DISCHARGE_PORT'].")";
		$resultdis = mysql_query($sqldis) or die($sqldis);
	    $rowsdis   = mysql_fetch_assoc($resultdis);
		
		if($selStatus == 2 && $status == 'Booked')
		{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetFont('daxcondensedlight','',8);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			$arr2=array(8,23,22,15,15,18,18,15,15,15,15,15,15,15,15,24,15);
			if($rows['COASPOT']=='SPOT')
			{
				$sql4 = "select DISTINCT(COMID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =1;
				$shipment2 =$rows4['LEGS'];
			}
			else
			{
				$coaids = array();
				$sql2 = "select DISTINCT(COAID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul2 = mysql_query($sql2) or die($sql2);
				while($rows2 = mysql_fetch_assoc($resul2))
				{
					$coaids[] = $rows2['COAID'];
				}
				
				$sql3 = "select DISTINCT(COAID) from cargo_relet_estimate_compare inner join cargo_relet_estimate_masster on cargo_relet_estimate_masster.COMID = cargo_relet_estimate_compare.COMID where cargo_relet_estimate_masster.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul3 = mysql_query($sql3) or die($sql3);
				while($rows3 = mysql_fetch_assoc($resul3))
				{
					$coaids[] = $rows3['COAID'];
				}
				
				$sql4 = "select TOTAL_SHIPMENTS, (select COUNT(*) as LEGS from freight_cost_estimate_compare where freight_cost_estimate_compare.COAAID=coa_master.COAID) as LEGS from coa_master where COAID in (".implode(',',$coaids).")";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =$rows4['TOTAL_SHIPMENTS'];
				$shipment2 =$rows4['LEGS'];
			}
			
			$arr3=array($i,$rows['CHARTERERNAME'],$rows['OWNERNAME'],$rows['BASINAME'],$rows['COASPOT'],date('d-m-Y',strtotime($rows['LAYCAN_SDATE'])),date('d-m-Y',strtotime($rows['LAYCAN_EDATE'])),$rowsload['PORTNAME'],$rowsdis['PORTNAME'],$rows['CARGONAME'],$rows['CARGOSTEAMSIZE'],$rows['TOLERANCE'],$rows['BUNKER_HEDGE1'],$rows['CARGORELET'],$rows['VESSEL_TYPE1'],$rows['REMARKS'],$status);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
			$i++;
		}
		if($selStatus == 1 && $status == 'Open')
		{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetFont('daxcondensedlight','',8);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			$arr2=array(8,23,22,15,15,18,18,15,15,15,15,15,15,15,15,24,15);
			
			if($rows['COASPOT']=='SPOT')
			{
				$sql4 = "select DISTINCT(COMID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =1;
				$shipment2 =$rows4['LEGS'];
			}
			else
			{
				$coaids = array();
				$sql2 = "select DISTINCT(COAID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul2 = mysql_query($sql2) or die($sql2);
				while($rows2 = mysql_fetch_assoc($resul2))
				{
					$coaids[] = $rows2['COAID'];
				}
				
				$sql3 = "select DISTINCT(COAID) from cargo_relet_estimate_compare inner join cargo_relet_estimate_masster on cargo_relet_estimate_masster.COMID = cargo_relet_estimate_compare.COMID where cargo_relet_estimate_masster.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul3 = mysql_query($sql3) or die($sql3);
				while($rows3 = mysql_fetch_assoc($resul3))
				{
					$coaids[] = $rows3['COAID'];
				}
				
				$sql4 = "select TOTAL_SHIPMENTS, (select COUNT(*) as LEGS from freight_cost_estimate_compare where freight_cost_estimate_compare.COAAID=coa_master.COAID) as LEGS from coa_master where COAID in (".implode(',',$coaids).")";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =$rows4['TOTAL_SHIPMENTS'];
				$shipment2 =$rows4['LEGS'];
			}
			
			$arr3=array($i,$rows['CHARTERERNAME'],$rows['OWNERNAME'],$rows['BASINAME'],$rows['COASPOT'],date('d-m-Y',strtotime($rows['LAYCAN_SDATE'])),date('d-m-Y',strtotime($rows['LAYCAN_EDATE'])),$rowsload['PORTNAME'],$rowsdis['PORTNAME'],$rows['CARGONAME'],$rows['CARGOSTEAMSIZE'],$rows['TOLERANCE'],$rows['BUNKER_HEDGE1'],$rows['CARGORELET'],$rows['VESSEL_TYPE1'],$rows['REMARKS'],$status);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
			$i++;
		}
		if($selStatus == 0)
		{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetFont('daxcondensedlight','',8);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			$arr2=array(8,23,22,15,15,18,18,15,15,15,15,15,15,15,15,24,15);
			
			if($rows['COASPOT']=='SPOT')
			{
				$sql4 = "select DISTINCT(COMID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =1;
				$shipment2 =$rows4['LEGS'];
			}
			else
			{
				$coaids = array();
				$sql2 = "select DISTINCT(COAID) from freight_cost_estimate_compare inner join freight_cost_estimete_master on freight_cost_estimete_master.COMID = freight_cost_estimate_compare.COMID where freight_cost_estimete_master.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul2 = mysql_query($sql2) or die($sql2);
				while($rows2 = mysql_fetch_assoc($resul2))
				{
					$coaids[] = $rows2['COAID'];
				}
				
				$sql3 = "select DISTINCT(COAID) from cargo_relet_estimate_compare inner join cargo_relet_estimate_masster on cargo_relet_estimate_masster.COMID = cargo_relet_estimate_compare.COMID where cargo_relet_estimate_masster.OPEN_CARGOID='".$rows['OPEN_CARGOID']."'";
				$resul3 = mysql_query($sql3) or die($sql3);
				while($rows3 = mysql_fetch_assoc($resul3))
				{
					$coaids[] = $rows3['COAID'];
				}
				
				$sql4 = "select TOTAL_SHIPMENTS, (select COUNT(*) as LEGS from freight_cost_estimate_compare where freight_cost_estimate_compare.COAAID=coa_master.COAID) as LEGS from coa_master where COAID in (".implode(',',$coaids).")";
				$resul4 = mysql_query($sql4);
				$rows4 = mysql_fetch_assoc($resul4);
				$shipment1 =$rows4['TOTAL_SHIPMENTS'];
				$shipment2 =$rows4['LEGS'];
			}
			
			$arr3=array($i,$rows['CHARTERERNAME'],$rows['OWNERNAME'],$rows['BASINAME'],$rows['COASPOT'],date('d-m-Y',strtotime($rows['LAYCAN_SDATE'])),date('d-m-Y',strtotime($rows['LAYCAN_EDATE'])),$rowsload['PORTNAME'],$rowsdis['PORTNAME'],$rows['CARGONAME'],$rows['CARGOSTEAMSIZE'],$rows['TOLERANCE'],$rows['BUNKER_HEDGE1'],$rows['CARGORELET'],$rows['VESSEL_TYPE1'],$rows['REMARKS'],$status);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
			$i++;
		}	  
	}

	$filename = "Cargo Tonnage Book Report ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}

function getReletCompare()
{	
	$obj 			= new data();
    $comid   =  $_REQUEST['comid'];
	$fcaid = $obj->getLatestCostSheetIDRelet($comid);
    $obj->viewCargoReletEstimationTempleteRecordsNew($fcaid);
	
	$coaid  = $obj->getFun2();
	$resultcoa = mysql_query("select * from coa_master where COAID='".$coaid."'") or die;
	$rowscoa   = mysql_fetch_assoc($resultcoa);
	$currencttoshow = $rowscoa['CURRENCY'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
			$this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
				$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
				$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
				
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Compare Sheets Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Compare Sheets Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	$pdf->Ln(6);
	$pdf->SetFont('daxcondensedlight','',14);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,5,"Fixture Type : Cargo Relet",0,1,'L');
	
	$getY = $pdf->GetY();
	$pdf->Ln(10);
	
	$sqlin = "select CHARTERER, (select NAME from vendor_master where vendor_master.CODE=cargo_relet_estimate_slave1.CHARTERER) as CHARTERERNAME, OWNER, (select NAME from vendor_master where vendor_master.CODE=cargo_relet_estimate_slave1.OWNER) as OWNERNAME from cargo_relet_estimate_slave1 where FCAID='".$obj->getFun1()."' and IDENTIFY='IN'";
	
	$resin = mysql_query($sqlin);
	$arr_charterer = array();$arr_owner = array();
	while($rowsin = mysql_fetch_assoc($resin))
	{
		$arr_charterer[] = $rowsin['CHARTERERNAME'];
		$arr_owner[] = $rowsin['OWNERNAME'];
	}
	$sqlout = "select OWNER, (select NAME from vendor_master where vendor_master.CODE=cargo_relet_estimate_slave1.OWNER) as OWNERNAME from cargo_relet_estimate_slave1 where FCAID='".$obj->getFun1()."' and IDENTIFY='OUT'";
	$resout = mysql_query($sqlout);
	
	while($rowsout = mysql_fetch_assoc($resout))
	{
		//$arr_owner[] = $rowsout['OWNERNAME'];
	}
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(23,3,70);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Owner", ":", implode(', ',$arr_owner));
	$pdf->Row1($arr3);
	$arr3=array("Charterer", ":", implode(', ',$arr_charterer));
	$pdf->Row1($arr3);
	
	$arr3=array("Cargo", ":", number_format($obj->getFun10(),2,'.','')." MT");
	$pdf->Row1($arr3);
	
	$getY1 = $pdf->GetY();
	$pdf->Ln($getY - $getY1);
	$pdf->Ln(5);
	$pdf->SetX(110);
	$arr1=array('L','L','L');
	$arr2=array(24,3,57);
	$arr3=array("Start Date", ":", date("d-m-Y",strtotime($obj->getFun7())));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetX(110);
	if(date("d-m-Y",strtotime($obj->getFun104()))!='01-01-1970'){$enddate = date("d-m-Y",strtotime($obj->getFun104()));}else{$enddate = '';}
	$arr3=array("End Date", ":", $enddate);
	$pdf->Row1($arr3);
	
	$pdf->SetX(110);
	$arr3=array("Vessel", ":", $obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"));
	$pdf->Row1($arr3);
	
	$sql2 = "select * from cargo_relet_estimate_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='IN'";
	$result2 = mysql_query($sql2);
	$arr_loadport = $arr_disport = array();
	while($rows2 = mysql_fetch_assoc($result2))
	{
		if($rows2['PORT_TYPE'] == 'LP')
		{
			$arr_loadport[] = $obj->getPortName($rows2['PORTID']);
		}
		else
		{
			$arr_disport[] = $obj->getPortName($rows2['PORTID']);
		}
	}
	
	$pdf->SetX(110);
	$arr3=array("Loading Port(s)", ":", implode(', ',$arr_loadport));
	$pdf->Row1($arr3);
	
	$pdf->SetX(110);
	$arr3=array("Discharge Port(s)", ":", implode(', ',$arr_disport));
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(20,119,166);
	$pdf->SetX(110);
	$arr3=array("Total Profit", ":", number_format($obj->getFun40(),2,'.','')." ".$currencttoshow);
	$pdf->Row1($arr3);
	
	$arr1=array('L','L','L');
	$arr2=array(23,3,75);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Created By", ":", $obj->getUserDetailBaseOnId($_SESSION['uid'],'CONTACT_PERSON'));
	$pdf->Row1($arr3);
	$arr3=array("Last Modified By", ":", $obj->getUserDetailBaseOnId($_SESSION['uid'],'CONTACT_PERSON'));
	$pdf->Row1($arr3);
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',14);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"General",0,1,'L');
	
	$pdf->Ln(-2);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(190,1,"______________________________________________________________________________________",0,1,'C','0');
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Income",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','R','R');
	$arr2=array(30,90,35,35);
	$arr3=array("", "Comment", "Value", "Total");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$sum1 = 0;
	$arr3=array("Freight", number_format($obj->getFun10(),2,'.','')." MT * ".number_format($obj->getFun11(),2,'.','')." ".$currencttoshow, number_format($obj->getFun33(),2,'.',''), number_format($obj->getFun33(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun33(),2,'.','');
	
	$arr3=array("Bunker Surcharge", number_format($obj->getFun10(),2,'.','')." MT * (".number_format($obj->getFun20(),2,'.','')." - ".number_format($obj->getFun19(),2,'.','').") * ".number_format($obj->getFun12(),4,'.',''), number_format($obj->getFun34(),2,'.',''), number_format($obj->getFun34(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun34(),2,'.','');
	
	$arr3=array("Demurrage", "Demurrage, if any", number_format($obj->getFun35(),2,'.',''), number_format($obj->getFun35(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + $obj->getFun35();
	
	$arr3=array("Despatch","Despatch, if any", number_format($obj->getFun36(),2,'.',''), number_format($obj->getFun36(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun36(),2,'.','');
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(155,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("         Total", number_format($sum1,2,'.',''));
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Costs",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','R','R');
	$arr2=array(30,90,35,35);
	$arr3=array("", "Comment", "Value", "Total");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$sum1 = 0;
	$arr3=array("Freight", number_format($obj->getFun10(),2,'.','')." MT * ".number_format($obj->getFun21(),2,'.','')." ".$currencttoshow, number_format($obj->getFun41(),2,'.',''), number_format($obj->getFun41(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun41(),2,'.','');
	
	$arr3=array("Demurrage", "Demurrage, if any", number_format($obj->getFun43(),2,'.',''), number_format($obj->getFun43(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun43(),2,'.','');
	
	$arr3=array("Despatch","Despatch, if any", number_format($obj->getFun44(),2,'.',''), number_format($obj->getFun44(),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($obj->getFun44(),2,'.','');
	
	$arr3=array("Commission","-(".number_format($obj->getFun10(),2,'.','')." MT * ".number_format($obj->getFun21(),2,'.','')." ".$currencttoshow." * ".number_format($obj->getFun25(),2,'.','')."% addcomm + ".number_format($obj->getFun10(),2,'.','')." MT * ".number_format($obj->getFun21(),2,'.','')." ".$currencttoshow." * ".number_format($obj->getFun26(),2,'.','')."% Brokerage)", -(number_format($obj->getFun45(),2,'.','') + number_format($obj->getFun46(),2,'.','')), -(number_format($obj->getFun45(),2,'.','') + number_format($obj->getFun46(),2,'.','')));
	$pdf->Row2($arr3);
	$sum1 = $sum1 - number_format($obj->getFun45(),2,'.','') - number_format($obj->getFun46(),2,'.','');
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(155,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("         Total", number_format($sum1,2,'.',''));
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(8);
	$pdf->SetFont('daxcondensedlight','',14);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Intake",0,1,'L');
	
	$pdf->Ln(-2);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(190,1,"______________________________________________________________________________________",0,1,'C','0');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','R','R','L','L','L','R','R');
	$arr2=array(20,5,30,30,20,20,5,30,30);
	$arr3=array("Draft Type", ":", "SUMMER", "", "", "", "", "", "");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("DWT", ":", $obj->getFun74()." MT", $obj->getFun75()." LT", "", "DRAFT", ":", $obj->getFun76()." M", $obj->getFun77()." FT");
	$pdf->Row1($arr3);
	
	$arr3=array("Full Draft TPI", ":", $obj->getFun78()." MT/Inch", $obj->getFun79()." LT/Inch", "", "Full Draft TPC", ":", $obj->getFun80()." MT/Cm", $obj->getFun81()." LT/Cm");
	$pdf->Row1($arr3);
	
	$arr3=array("Grain Capacity", ":", $obj->getFun84()." CBM", $obj->getFun85()." CFT", "", "Constants", ":", $obj->getFun82()." MT", $obj->getFun83()." LT");
	$pdf->Row1($arr3);
	
	
	$pdf->Ln(3);
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L');
	$arr2=array(30,30,30);
	$arr3=array("Allowed Draft", "Bunker ROB", "Intake");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('R','R','R');
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr3=array($obj->getFun86()." M", $obj->getFun87()." MT", $obj->getFun88()." MT");
	$pdf->SetAligns($arr1);
	$pdf->Row2($arr3);
	
	
	
	
	
    $pdf->AddPage('P');	
	$pdf->Ln(6);
	$pdf->SetFont('daxcondensedlight','',14);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,5,"Comment",0,1,'L');
	$pdf->Ln(-2);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(190,1,"______________________________________________________________________________________",0,1,'C','0');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$arr3=array($obj->getFun72());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',14);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Comparison",0,1,'L');
	$pdf->Ln(-2);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(190,1,"______________________________________________________________________________________",0,1,'C','0');
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Income",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(85,35,35,35);
	$arr3=array("", "E1", "E2", "E2 - E1");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from cargo_relet_estimate_masster where COMID='".$comid."' order by FCAID ASC";
	$result1 = mysql_query($sql1);
	$rows1 = mysql_fetch_assoc($result1);
	
	$sql2 = "select * from cargo_relet_estimate_masster where COMID='".$comid."' and SHEET_NO is not NULL order by FCAID DESC";
	$result2 = mysql_query($sql2);
	$num2 = mysql_num_rows($result2);
	$rows2 = mysql_fetch_assoc($result2);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R','R','R');
	$arr2=array(85,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$sum1 = $sum2 = 0;
	$arr3=array("Freight",number_format($rows1['FREIGHT_AMT'],2,'.',''),number_format($rows2['FREIGHT_AMT'],2,'.',''),number_format(($rows2['FREIGHT_AMT']-$rows1['FREIGHT_AMT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($rows1['FREIGHT_AMT'],2,'.','');
	$sum2 = $sum2 + number_format($rows2['FREIGHT_AMT'],2,'.','');
	
	$arr3=array("Bunker Surcharge",number_format($rows1['BUNKER_SURCHARGE_AMT'],2,'.',''),number_format($rows2['BUNKER_SURCHARGE_AMT'],2,'.',''),number_format(($rows2['BUNKER_SURCHARGE_AMT']-$rows1['BUNKER_SURCHARGE_AMT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($rows1['BUNKER_SURCHARGE_AMT'],2,'.','');
	$sum2 = $sum2 + number_format($rows2['BUNKER_SURCHARGE_AMT'],2,'.','');
	
	$arr3=array("Demurrage",number_format($rows1['DEMMURAGE_AMT'],2,'.',''),number_format($rows2['DEMMURAGE_AMT'],2,'.',''),number_format(($rows2['DEMMURAGE_AMT']-$rows1['DEMMURAGE_AMT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($rows1['DEMMURAGE_AMT'],2,'.','');
	$sum2 = $sum2 + number_format($rows2['DEMMURAGE_AMT'],2,'.','');
	
	$arr3=array("Despatch",number_format($rows1['DESPATCH_AMT'],2,'.',''),number_format($rows2['DESPATCH_AMT'],2,'.',''),number_format(($rows2['DESPATCH_AMT']-$rows1['DESPATCH_AMT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum1 = $sum1 + number_format($rows1['DESPATCH_AMT'],2,'.','');
	$sum2 = $sum2 + number_format($rows2['DESPATCH_AMT'],2,'.','');
	
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetFont('daxcondensedlight','',11);
	$arr1=array('C','R','R','R');
	$arr2=array(85,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Income:",number_format($sum1,2,'.',''),number_format($sum2,2,'.',''),number_format(($sum2-$sum1),2,'.',''));
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(20,119,166);
	$pdf->Cell(0,6,"Costs",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(85,35,35,35);
	$arr3=array("", "E1", "E2", "E2 - E1");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from cargo_relet_estimate_masster where COMID='".$comid."' order by FCAID ASC";
	$result1 = mysql_query($sql1);
	$rows1 = mysql_fetch_assoc($result1);
	
	$sql2 = "select * from cargo_relet_estimate_masster where COMID='".$comid."' and SHEET_NO is not NULL order by FCAID DESC";
	$result2 = mysql_query($sql2);
	$num2 = mysql_num_rows($result2);
	$rows2 = mysql_fetch_assoc($result2);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R','R','R');
	$arr2=array(85,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$sum3 = $sum4 = 0;
	$arr3=array("Freight",number_format($rows1['FREIGHT_AMT_OUT'],2,'.',''),number_format($rows2['FREIGHT_AMT_OUT'],2,'.',''),number_format(($rows2['FREIGHT_AMT_OUT']-$rows1['FREIGHT_AMT_OUT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum3 = $sum3 + number_format($rows1['FREIGHT_AMT_OUT'],2,'.','');
	$sum4 = $sum4 + number_format($rows2['FREIGHT_AMT_OUT'],2,'.','');
	
	$arr3=array("Demurrage",number_format($rows1['DEMMURAGE_AMT_OUT'],2,'.',''),number_format($rows2['DEMMURAGE_AMT_OUT'],2,'.',''),number_format(($rows2['DEMMURAGE_AMT_OUT']-$rows1['DEMMURAGE_AMT_OUT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum3 = $sum3 + number_format($rows1['DEMMURAGE_AMT_OUT'],2,'.','');
	$sum4 = $sum4 + number_format($rows2['DEMMURAGE_AMT_OUT'],2,'.','');
	
	$arr3=array("Despatch",number_format($rows1['DESPATCH_AMT_OUT'],2,'.',''),number_format($rows2['DESPATCH_AMT_OUT'],2,'.',''),number_format(($rows2['DESPATCH_AMT_OUT']-$rows1['DESPATCH_AMT_OUT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum3 = $sum3 + number_format($rows1['DESPATCH_AMT_OUT'],2,'.','');
	$sum4 = $sum4 + number_format($rows2['DESPATCH_AMT_OUT'],2,'.','');
	
	$arr3=array("Commission",'-'.(number_format($rows1['ADD_COMM_AMT_OUT'] + $rows1['BROKERAGE_AMT_OUT'],2,'.','')),'-'.(number_format($rows2['ADD_COMM_AMT_OUT'] + $rows2['BROKERAGE_AMT_OUT'],2,'.','')),number_format(($rows2['ADD_COMM_AMT_OUT'] + $rows2['BROKERAGE_AMT_OUT'] - $rows1['ADD_COMM_AMT_OUT'] - $rows1['BROKERAGE_AMT_OUT']),2,'.',''));
	$pdf->Row2($arr3);
	$sum3 = $sum3 - number_format($rows1['ADD_COMM_AMT_OUT'] + $rows1['BROKERAGE_AMT_OUT'],2,'.','');
	$sum4 = $sum4 - number_format($rows2['ADD_COMM_AMT_OUT'] + $rows2['BROKERAGE_AMT_OUT'],2,'.','');
	
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetFont('daxcondensedlight','',11);
	$arr1=array('C','R','R','R');
	$arr2=array(85,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Costs:",number_format($sum3,2,'.',''),number_format($sum4,2,'.',''),number_format(($sum4-$sum3),2,'.',''));
	$pdf->Row2($arr3);
	$pdf->Ln(3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetFont('daxcondensedlight','',11);
	$arr1=array('C','R','R','R');
	$arr2=array(85,35,35,35);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Grand Total:",number_format($sum1 - $sum3,2,'.',''),number_format($sum2 - $sum4,2,'.',''),number_format((($sum2 - $sum1) - ($sum4 - $sum3)),2,'.',''),'','','','');
	$pdf->Row2($arr3);
	
	$filename = "Compare Sheets.pdf";

	$pdf->Output($filename,'D');
}


function hire_invoice_pdfTC()
{
	$obj = new data();
	$obj->funConnect();
	
	$invoiceid = $_REQUEST['invoiceid'];
	$comid = $_REQUEST['comid'];
	$_SESSION['invoiceid'] = $invoiceid;
$amttoword = new Numbertowordconversion();

$id = $obj->getLatestCostSheetIDTC($comid);
$obj->viewTCEstimationTempleteRecordsNew($id);

$sql = "SELECT * from invoice_hiretc_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and INVOICEID='".$invoiceid."'";
$res 	= mysql_query($sql);
$rows 	= mysql_fetch_assoc($res);
$randomid = $rows['RANDOMID'];

$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."' and RANDOMID='".$randomid."'";
$restc 	= mysql_query($sqltc);
$rectc 	= mysql_num_rows($restc);
$rowstc = mysql_fetch_assoc($restc);

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];

$_SESSION['companyname']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
 
$_SESSION['invoice_date'] = date("d-m-Y",strtotime($rows['INVOICE_DATE']));

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['companyaddress'].", ".$_SESSION['companycity']." ".$_SESSION['companycountry']." ".$_SESSION['companycode'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	$vendorid = $rowstc['TC_FINAL_HIERAGE_VENDOR'];
	$currency = 'USD';
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate VC Hire Statement Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate VC Hire Statement Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Statement No.",$rows['INVOICE_NO'],"Contract Ref. : ".$rowstc['TC_CP_NUMBER'] ,"CP Date ".date('d-m-Y',strtotime($rowstc['TC_CP_DATE']))));
	$invdate = date('d-m-Y',strtotime($rows['INVOICE_DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	
	$pdf->Row(array("Statement Date",$invdate,"Vessel",$obj->getVesselIMOData($obj->getFun3(),"VESSEL_NAME")));
	//$pdf->Row(array("Vessel",$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),"",""));
	$pdf->Row(array("Port/Region of Delivery",$rowstc['TC_PORT_DELIVERY'],"Port/Region of Re-Delivery",$rowstc['TC_PORT_REDELIVERY']));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Ship Owner:","Creating Company:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($vendorid)."\n".stripslashes($obj->getVendorDataBasedOnID($vendorid,'STREET_1')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
	
	
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$ballast_bonus = 0;
	$sql_2 = "select chartering_tc_estimate_slave2.RANDOMID, chartering_tc_estimate_slave2.TC_DELIVERY_DATE, chartering_tc_estimate_slave2.TC_REDELIVERY_DATE, chartering_tc_estimate_slave2.TC_RATE, chartering_tc_estimate_slave2.TD_DAYS, chartering_tc_estimate_slave2.HIERAGE, chartering_tc_estimate_slave2.BALLAST_BONUS, chartering_tc_estimate_slave2.GROSS_HIERAGE, chartering_tc_estimate_slave2.ADD_COMM, chartering_tc_estimate_slave2.ADD_COMM_AMT, chartering_tc_estimate_slave2.BROKERAGE_COMM, chartering_tc_estimate_slave2.BROKERAGE_COMM_AMT, chartering_tc_estimate_slave2.NET_HIERAGE, chartering_tc_estimate_slave2.CVE_MONTH, chartering_tc_estimate_slave2.CVE_AMOUNT from chartering_tc_estimate_slave2 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave2.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' ";	
	//echo $sql_2;
	$result_2 = mysql_query($sql_2);$i = 0;
	$num_2 = mysql_num_rows($result_2);
	while($rows_2 = mysql_fetch_assoc($result_2))
	{$i++;
	$ballast_bonus = $ballast_bonus + $rows_2['BALLAST_BONUS'];
	$sql_invslave1 = "select invoice_hiretc_slave3.UTILISED_DAYS, invoice_hiretc_slave3.HIRE_AMT, invoice_hiretc_slave3.ADD_COMM, invoice_hiretc_slave3.BROKERAGE_AMT, invoice_hiretc_slave3.CVE_AMT, invoice_hiretc_slave3.HIRE_FROM, invoice_hiretc_slave3.HIRE_TO from invoice_hiretc_slave3 inner join invoice_hiretc_master on invoice_hiretc_master.INVOICEID=invoice_hiretc_slave3.INVOICEID where invoice_hiretc_master.INVOICEID='".$rows['INVOICEID']."' and invoice_hiretc_slave3.RANDOMID='".$rows_2['RANDOMID']."'";
	$res_invslave1 = mysql_query($sql_invslave1);
	$result_invslave1 = mysql_fetch_assoc($res_invslave1);
		if(date('d-m-Y',strtotime($result_invslave1['HIRE_FROM']))!='01-01-1970' && date('d-m-Y',strtotime($result_invslave1['HIRE_TO']))!='01-01-1970')
		{
			$pdf->Ln(2);
			if($rows['CHK_BALLAST_BONUS']==1)
			{
				$hireamt = $result_invslave1['HIRE_AMT'] - $rows_2['BALLAST_BONUS'];
			}else{$hireamt = $result_invslave1['HIRE_AMT'];}
			$pdf->Row1(array("Period ".date('d-m-Y H:i',strtotime($result_invslave1['HIRE_FROM']))." - ".date('d-m-Y H:i',strtotime($result_invslave1['HIRE_TO'])).", Total ".$result_invslave1['UTILISED_DAYS']." Days",$hireamt));
			$pdf->Row1(array("Hire for ".$result_invslave1['UTILISED_DAYS']." days at ".$currency." ".$rows_2['TC_RATE']." per day",""));
		}
	
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	if($rows['CHK_BALLAST_BONUS']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Ballast Bonus",'(+) '.number_format($ballast_bonus,2,'.',',')));
	}
	
	$sql2 = "select * from invoice_hiretc_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(+) '.number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['CVE_AMT']>0)
	{
		$pdf->Row1(array("     CVE     ",'(+) '.number_format($rows['CVE_AMT'],2,'.',',')));
	}
	
	if($rows['CHK_DELIVERY']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Delivery Bunkers",""));
		
		$sqltc4 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_DATE, BUNKER_PRICE, BUNKER_AMT, IDENTIFY from chartering_tc_estimate_slave3 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave3.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave3.IDENTIFY='DEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['BUNKER_QTY'].'(MT)',number_format(($rowstc4['BUNKER_PRICE']),2,'.',','),'(+) '.number_format(($rowstc4['BUNKER_AMT']),2,'.',',')));
        }
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from invoice_hiretc_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(-)'.$rows2['AMOUNT']));
	}
	
	
	if($rows['ADD_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     ADDRESS COMMISSION",'(-)'.$rows['ADD_COMM_AMT']));
	}
	
	if($rows['BRO_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     BROKERAGE COMMISSION",'(-)'.$rows['BRO_COMM_AMT']));
	}
	
	
	$sql_random = "SELECT RANDOMID from invoice_hiretc_slave4 where INVOICEID='".$rows['INVOICEID']."'";
	$res_random 	= mysql_query($sql_random) or die($sql_random);
	$rec_random 	= mysql_num_rows($res_random);
	
	$off =0;
	if($rows['CHK_OFFHIRE']==1 && $rec_random>0)
	{
		$pdf->Ln(1);
		
		$pdf->Row1(array("   Off-hire",""));
		while($rec_random = mysql_fetch_assoc($res_random))
		{ $off++;
			$sqltc4 = "SELECT TC_SLAVE4ID, OFFHIRE_REASON, OFF_HIRE_FROM, OFF_HIRE_TO, OFF_HIRE_DAYS, OFF_HIRE_RATE, OF_HIRE_AMT, chartering_tc_estimate_slave4.RANDOMID from chartering_tc_estimate_slave4 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave4.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave4.RANDOMID='".$rec_random['RANDOMID']."'";
			$restc4 	= mysql_query($sqltc4);
			$rectc4 	= mysql_num_rows($restc4);
			while($rowstc4 = mysql_fetch_assoc($restc4))
			{
			    $pdf->SetTextColor(0,0,0);
				$arr1=array('L','R');
				$arr2=array(150,40);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array("    ".$off.". ".$rowstc4['OFFHIRE_REASON']." (".$rowstc4['OFF_HIRE_DAYS']." Days)",'(-) '.number_format($rowstc4['OF_HIRE_AMT'],2,'.',',')));
				$sqltc5 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_PRICE, BUNKER_AMT, IS_OWNER_ACCOUNT from chartering_tc_estimate_slave5 where  TC_SLAVE4ID='".$rowstc4['TC_SLAVE4ID']."' and IS_OWNER_ACCOUNT=1";
				$restc5 	= mysql_query($sqltc5);
				$rectc5 	= mysql_num_rows($restc5);
				while($rowstc5 = mysql_fetch_assoc($restc5))
				{
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','R','R','R');
					$arr2=array(50,50,50,40);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc5['BUNKERID']),$rowstc5['BUNKER_QTY'].'(MT)',number_format(($rowstc5['BUNKER_PRICE']),2,'.',''),'(-) '.number_format(($rowstc5['BUNKER_AMT']),2,'.',',')));
				}
			}
		}
	}
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	if($rows['CHK_OFFHIRE']==1 && $rows['OFFHIRE_CVE_AMT']>0)
	{
		$pdf->Row1(array("     CVE on Off-Hire ",'(-) '.$rows['OFFHIRE_CVE_AMT']));
	}
	
	
	if($rows['CHK_REDELIVERY']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Re-Delivery Bunkers",""));
		
		$sqltc4 = "SELECT BUNKERID, BUNKER_QTY, BUNKER_DATE, BUNKER_PRICE, BUNKER_AMT, IDENTIFY from chartering_tc_estimate_slave3 inner join chartering_tc_estimate_slave1 on chartering_tc_estimate_slave1.TC_SLAVE1ID=chartering_tc_estimate_slave3.TC_SLAVE1ID where chartering_tc_estimate_slave1.TCOUTID='".$obj->getFun1()."' and chartering_tc_estimate_slave1.RANDOMID='".$randomid."' and chartering_tc_estimate_slave3.IDENTIFY='REDEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['BUNKER_QTY'].'(MT)',number_format(($rowstc4['BUNKER_PRICE']),2,'.',','),'(+) '.number_format(($rowstc4['BUNKER_AMT']),2,'.',',')));
        }
	}
	
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Due to Owners ",$rows['FINAL_AMT']));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Due to Owners (".$rows['CURRENCY'].")",number_format(($rows['FINAL_AMT']*$rows['EXCHANGE_RATE']),2,'.','')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	if($pdf->GetY() >205){$pdf->AddPage('P');$pdf->Ln(5);}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Due to Owners in Words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['FINAL_AMT'],$currency))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['FINAL_AMT']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['CURRENCY'])),""));
	}
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);
	
$filename = "Hire Statement ".$rows['INVOICE_NO'].".pdf";

$pdf->Output($filename,'D');
}




function create_vendor_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$vendorid                       = $_REQUEST['vendorid'];
	$sql 							= "select * from vendor_master where VENDORID='".$vendorid."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate '.$rows['NAME'].' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate '.$rows['NAME'].' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(60,130);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Vendor Type :", $obj->getVendorTypeNameBasedOnID($rows['VENDOR_TYPEID'])));
	$pdf->Ln(2);
	$pdf->Row1(array("Vendor Name :", $rows['NAME']));
	$pdf->Ln(2);
	$pdf->Row1(array("Vendor Code :", $rows['CODE']));
	$pdf->Ln(2);
	$pdf->Row1(array("Vendor Short Name :", $rows['SHORT_NAME']));
	$pdf->Ln(2);
	$pdf->Row1(array("Address 1 :", $rows['STREET_1']));
	$pdf->Ln(2);
	$pdf->Row1(array("VAT/Tax Number :", $rows['VAT_NUMBER']));
	$pdf->Ln(2);
	$pdf->Row1(array("Person Incharge :", $rows['STREET_2']));
	$pdf->Ln(2);
	$pdf->Row1(array("City :", $rows['CITY']));
	$pdf->Ln(2);
	$pdf->Row1(array("Country :", $rows['COUNTRY']));
	$pdf->Ln(2);
	$pdf->Row1(array("Pin Code :", $rows['CITY_POSTAL_CODE']));
	$pdf->Ln(2);
	$pdf->Row1(array("Phone No. :", $rows['PHONE']));
	$pdf->Ln(2);
	$pdf->Row1(array("Fax No. :", $rows['FAX']));
	$pdf->Ln(2);
	$pdf->Row1(array("Email Address :", $rows['EMAILID']));
	
	
	

$filename = $rows['NAME']." ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}

function create_tc_other_invoice_pdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$invoiceid                      = $_REQUEST['invoiceid'];
	$comid 							= $_REQUEST['comid'];
	$tcoutid = $obj->getLatestCostSheetIDTC($comid);
    $obj->viewTCEstimationTempleteRecordsNew($tcoutid);
	$sql = "SELECT * from invoice_tcother_master where INVOICEID='".$invoiceid."' and COMID='".$comid."'";
	$res 	= mysql_query($sql);
	$rec 	= mysql_num_rows($res);
	$rows 	= mysql_fetch_assoc($res);
	
	$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."' and RANDOMID='".$rows['RANDOMID']."'";
	$restc 	= mysql_query($sqltc) or die($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$rowstc = mysql_fetch_assoc($restc); 

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(4);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,9,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(2);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['companyaddress'].", ".$_SESSION['companycity']." ".$_SESSION['companycountry']." ".$_SESSION['companycode'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	
	if($rows['INVOICE_TYPE']=='Credit'){
		$invtitle = 'Credit Note';
		$inv_amt_title = 'to Credit';
	}else{
		$invtitle = 'Invoice';
		$inv_amt_title = 'Invoiced';
	}
	
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate TC Hire '.$invtitle.' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate TC Hire '.$invtitle.' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." No.",$rows['INVOICE_NO'],"Contract Ref.","CP Date ".date('d-m-Y',strtotime($obj->getFun9()))));
	$pdf->Row(array($invtitle." Date",date('d-m-Y',strtotime($rows['INVOICE_DATE'])),"Due Date",date('d-m-Y',strtotime($rows['DUE_DATE']))));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME"),$invtitle." Type","Other"));
	$pdf->Row(array("Place",$_SESSION['companycity'],"",""));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." To:",$invtitle." From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewData($rows['VENDOR'],"NAME")."\n".$obj->getVendorListNewData($rows['VENDOR'],"STREET_1")."\n".$obj->getVendorListNewData($rows['VENDOR'],"CITY").", ".$obj->getVendorListNewData($rows['VENDOR'],"COUNTRY")." ".$obj->getVendorListNewData($rows['VENDOR'],"CITY_POSTAL_CODE"),$_SESSION['companyname']."\n".$_SESSION['companyaddress']."\n".$_SESSION['companycity'].", ".$_SESSION['companycountry']." ".$_SESSION['companycode']));
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	
	$pdf->Ln(1);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(USD)"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['INV_IDENTITY'],number_format($rows['AMOUNT'],2,'.',',')));
	$pdf->Row1(array($rows['SHORT_DESC'],""));
	$pdf->Row1(array($rows['DESCRIPTION'],""));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from invoice_tcother_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from invoice_tcother_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount ".$inv_amt_title,number_format($rows['FINAL_AMOUNT'],2,'.',',')));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount ".$inv_amt_title." (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['FINAL_AMOUNT']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['FINAL_AMOUNT'],'USD'))));
	//,"In exoneration of VAT according to Art 43 $1 i) LTVA and Art 15.4.15.5 and 15.8 Directive 77/388/CEE"
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['FINAL_AMOUNT']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['BANKINGID']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nCORRESPONDENT BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['B_ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated ".strtolower($invtitle)." and no signatures are required",0,1,'L',0);

$filename = $rows['INV_IDENTITY']." ".$invtitle." TC (".$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME").") ".date("d-m-Y",time()).".pdf";
$pdf->Output($filename,'D');

}

function create_tc_hire_invoice_pdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$invoiceid                      = $_REQUEST['invoiceid'];
	$comid 							= $_REQUEST['comid'];
	$tcoutid = $obj->getLatestCostSheetIDTC($comid);
    $obj->viewTCEstimationTempleteRecordsNew($tcoutid);
	$sql = "SELECT * from invoice_tchire_master where INVOICEID='".$invoiceid."' and COMID='".$comid."'";
	$res 	= mysql_query($sql);
	$rec 	= mysql_num_rows($res);
	$rows 	= mysql_fetch_assoc($res);
	
	$sqlprev = "SELECT SUM(CVE_AMOUNT) as CVE_TOTAL, SUM(CVE_OFFHIRE_AMOUNT) as CVE_OFFHIRE_TOTAL, SUM(FINAL_AMOUNT) as INVOICE_AMT_TOTAL, SUM(ADDRESS_COMMISSION_AMOUNT) as ADDRESS_COMM_TOTAL, SUM(BROKER_COMMISSION_AMOUNT) as BROKER_COMM_TOTAL from invoice_tchire_master where RANDOMID='".$rows['RANDOMID']."' and COMID='".$comid."'";
	$resprev 	= mysql_query($sqlprev);
	$recprev 	= mysql_num_rows($resprev);
	$rowsprev 	= mysql_fetch_assoc($resprev);
	
	$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."' and RANDOMID='".$rows['RANDOMID']."'";
	$restc 	= mysql_query($sqltc) or die($sqltc);
	$rectc 	= mysql_num_rows($restc);
	$rowstc = mysql_fetch_assoc($restc); 
	if($rows['OLD_EXCHANGE_CURRENCY']!=''){$printcurrency = $rows['OLD_EXCHANGE_CURRENCY'];}else{$printcurrency = $rowstc['EXCHANGE_CURRENCY'];}
	if($printcurrency==''){$printcurrency = 'USD';}
	if($rows['OLD_DAILY_HIRE_RATE']!=''){$dailyhirey = $rows['OLD_DAILY_HIRE_RATE'];}else{$dailyhirey = $rowstc['DAILY_GROSS_HIRE_EST'];}

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddress']      = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddress'],0,1,'C');
		
		
	}
}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	
	if($rows['INVOICE_TYPE']=='Credit'){
		$invtitle = 'Credit Note';
		$inv_amt_title = 'to Credit';
	}else{
		$invtitle = 'Invoice';
		$inv_amt_title = 'Invoiced';
	}
	
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate TC Hire '.$invtitle.' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate TC Hire '.$invtitle.' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." No.",$rows['INVOICE_NO'],"Contract Ref.","CP Date ".date('d-m-Y',strtotime($obj->getFun9()))));
	$pdf->Row(array($invtitle." Date",date('d-m-Y',strtotime($rows['INVOICE_DATE'])),"Due Date",date('d-m-Y',strtotime($rows['DUE_DATE']))));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME"),$invtitle." Type","Hire"));
	$pdf->Row(array("Place",$_SESSION['companycity'],"",""));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." To:",$invtitle." From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewData($rowstc['TTL_REV_VENDOR'],"NAME")."\n".$obj->getVendorListNewData($rowstc['TTL_REV_VENDOR'],"STREET_1")."\n".$obj->getVendorListNewData($rowstc['TTL_REV_VENDOR'],"CITY").", ".$obj->getVendorListNewData($rowstc['TTL_REV_VENDOR'],"COUNTRY")." ".$obj->getVendorListNewData($rowstc['TTL_REV_VENDOR'],"CITY_POSTAL_CODE"),$_SESSION['companyname']."\n".$_SESSION['companyaddress']."\n".$_SESSION['companycity'].", ".$_SESSION['companycountry']." ".$_SESSION['companycode']));
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$printcurrency.")"));
	
	$pdf->Ln(2);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Period ".date('d-m-Y H:i',strtotime($rows['HIRE_FROM_DATE']))." - ".date('d-m-Y H:i',strtotime($rows['HIRE_TO_DATE'])).", Total ".$rows['HIRE_DAYS']." Days",number_format($rows['HIRE_INV_AMT'],2,'.',',')));
	$pdf->Row1(array("TC Hire for ".$rows['HIRE_DAYS']." days at ".$printcurrency." ".$dailyhirey." per day",""));
	$pdf->Row1(array($rows['DESCRIPTION'],""));
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	if($rows['CVE_AMOUNT']>0)
	{
		$pdf->Row1(array("     CVE","(+) ".number_format($rows['CVE_AMOUNT'],2,'.',',')));
	}
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from invoice_tchire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['IS_DELIVERYBUNKERS']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Delivery Bunkers",""));
		$sqltc4 = "SELECT BUNKERID, AMOUNT, QTY, PRICE, IDENTITY from chartering_estimate_tc_slave5 where TC_SLAVE1ID='".$rowstc['TC_SLAVE1ID']."'and IDENTITY='DEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['QTY'].'(MT)',number_format(($rowstc4['PRICE']/$rowstc['EXCHANGE_RATE']),2,'.',','),"(+) ".number_format(($rowstc4['AMOUNT']/$rowstc['EXCHANGE_RATE']),2,'.',',')));
        }
	}
    
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	
	if($rows['ADDRESS_COMMISSION_AMOUNT']>0)
	{
		$pdf->Row1(array("     Address Commission","(-) ".number_format($rows['ADDRESS_COMMISSION_AMOUNT'],2,'.',',')));
	}
	
	if($rows['BROKER_COMMISSION_AMOUNT']>0)
	{
		$pdf->Row1(array("     Broker Commission","(-) ".number_format($rows['BROKER_COMMISSION_AMOUNT'],2,'.',',')));
	}
	
	$sql2 = "select * from invoice_tchire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	$sqltc3 = "SELECT SUM(OFF_HIRE) as SUM, SUM(OFF_DAYS) as SUM1 from chartering_estimate_tc_slave3 where TC_SLAVE1ID='".$rowstc['TC_SLAVE1ID']."'";
	$restc3 	= mysql_query($sqltc3);
	$rectc3 	= mysql_num_rows($restc3);
	$rowstc3 = mysql_fetch_assoc($restc3);
	
	if($rows['IS_OFFHIRE']==1 && $rowstc3['SUM']>0)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Off-hire","(-) ".number_format($rowstc3['SUM'],2,'.',',')));
	}
	
	
	if($rows['CVE_OFFHIRE_AMOUNT']>0)
	{
		$pdf->Row1(array("     CVE on Off-Hire","(-) ".number_format($rows['CVE_OFFHIRE_AMOUNT'],2,'.',',')));
	}
	
	if($rows['IS_REDELIVERYBUNKERS']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Re-Delivery Bunkers",""));
		$sqltc4 = "SELECT BUNKERID, AMOUNT, QTY, PRICE, IDENTITY from chartering_estimate_tc_slave5 where TC_SLAVE1ID='".$rowstc['TC_SLAVE1ID']."'and IDENTITY='REDEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['QTY'].'(MT)',number_format(($rowstc4['PRICE']/$rowstc['EXCHANGE_RATE']),2,'.',','),"(-) ".number_format(($rowstc4['AMOUNT']/$rowstc['EXCHANGE_RATE']),2,'.',',')));
        }
	}
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount ".$inv_amt_title,number_format($rows['FINAL_AMOUNT'],2,'.',',')));
	
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount ".$inv_amt_title." (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['FINAL_AMOUNT']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	if($pdf->GetY() >230){$pdf->AddPage('P');$pdf->Ln(5);}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['FINAL_AMOUNT'],$printcurrency))));
	
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['FINAL_AMOUNT']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['BANKINGID']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['B_ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated ".strtolower($invtitle)." and no signatures are required",0,1,'L',0);

$filename = "Hire ".$invtitle." TC (".$obj->getVesselIMOData($vlsImoId,"VESSEL_NAME").") ".date("d-m-Y",time()).".pdf";
$pdf->Output($filename,'D');

}




function create_agency_letter_InOpsTC_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$comid 							= $_REQUEST['comid'];
	$tc_no 							= $_REQUEST['tc_no'];
	
	$sql 							= "select * from generate_agency_letter_tc where GEN_AGENCY_TC_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	$id 							= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");
	$vslName			 			= $obj->getVesselIMOData($obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
	$portname			 			= $obj->getPortName($rows['PORT_OF_CALL']);
	$agentname				      	= $obj->getVendorListNewData($rows['VENDORID'],"NAME");
	$shipOwner						= $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$shipOwnerAdd					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$shipOwnerAdd2					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_2");
	$shipOwnerPhone					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$shipOwnerFax					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"FAX");
	$shipOwnerEmailid				= $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$shipOwnerVAT					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	
	$agentPersnInc					= $obj->getVendorListNewData($rows['VENDORID'],"STREET_2");
	$agentPersnIncEmailid			= $obj->getVendorListNewData($rows['VENDORID'],"EMAILID");
		
	if($rows['TERMO_OF_TOLERANCE']!="")
	{
	  $_SESSION['termOfTolerance'] =" ".$rows['TERMO_OF_TOLERANCE'];
	}
	else
	{
	  $_SESSION['termOfTolerance'] ="";
	}

	$cost_sheet_id 					= $obj->getLatestCostSheetIDTC($rows['COMID']);
  									  $obj->viewTCEstimationTempleteRecordsNew($cost_sheet_id);
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$obj = new data();
		$obj->funConnect();
		$this->SetFillColor(255,255,255);
		$image_path1 = '../../img/slogo.jpg';
		$this->Image($image_path1,83,5,40,18);
		$this->SetTextColor(27,119,166);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(20);
		$this->SetY(7);
		$this->SetX(21);
		
		$this->Ln(1);
		$this->SetFont('Arial','',10);
		$this->SetX(20);
		$this->Cell(170,6,"",0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(12);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
	}
}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate PDA Request Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate PDA Request Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(5);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetFillColor(0,0,0);
	//$pdf->Cell(190,6,"Please copy : opex@socatra.com",0,1,'L',0);
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetFillColor(0,0,0);
	
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("To :".$agentname." (".$portname.") /att. ".$agentPersnInc." (".$agentPersnIncEmailid.")"));
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(0,0,0);

	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Cc: Master mt :".$vslName." /att. Capt. ".$rows['TERMO_OF_TOLERANCE']));
	$pdf->Row1(array("Cc: ".$shipOwner.", ".$shipOwnerAdd));
	
	
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$find[] = 'â€œ'; 
	$find[] = 'â€'; 
	$find[] = 'â€˜'; 
	$find[] = 'â€™'; 
	$find[] = 'â€¦'; 
	$find[] = 'â€”'; 
	$find[] = 'â€“'; 
	
	$replace[] = "'";
	$replace[] = '"';
	$replace[] = "'";
	$replace[] = "'";
	$replace[] = "...";
	$replace[] = "-";
	$replace[] = "-";
	
	
	$pdf->Ln(3);
	$pdf->Row1(array(str_replace($find, $replace, $rows['MAIN_DESCRIPTION'])));

$filename = "PDA Request Letter(".$vslName."-".$obj->getVendorListNewBasedOnID($rows['VENDORID']).") ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}

function RemoveBS($Str) {  
  $StrArr = str_split($Str); $NewStr = '';
  foreach ($StrArr as $Char) {    
    $CharNo = ord($Char);
    if ($CharNo == 163) { $NewStr .= $Char; continue; } // keep £ 
    if ($CharNo > 31 && $CharNo < 127) {
      $NewStr .= $Char;    
    }
  }  
  return $NewStr;
}

function create_agency_nomination_letter_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$randomno                   = $_REQUEST['randomno'];
	$comid 						= $_REQUEST['comid'];
	$port_type 					= $_REQUEST['port_type'];
	
	$sql 							= "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	$id 							= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$_SESSION['vslName'] 			= $obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
	$_SESSION['portname'] 			= $obj->getPortName($rows['PORTID']);
	$_SESSION['kind_attan_to']		= $rows['KIND_ATTN_TO'];
	$_SESSION['nomid']              = $obj->getCompareTableData($rows['COMID'],'MESSAGE');
	$agent_code						= $_REQUEST['agent_code'];
	$_SESSION['agent_name']      	= $obj->getVendorListNewData($agent_code,"NAME");
	
	$_SESSION['pda_ini_pay_per'] 	= $rows['PAD_INI_PAY_PERSENT'];
	$_SESSION['pda_fin_pay_per'] 	= $rows['PAD_FIN_PAY_PERSENT'];
	
	$_SESSION['vslconInfo'] 		= $rows['VSL_CONTACT_DETAILS'];
	$_SESSION['vslinfo'] 			= $rows['VSL_DETAILS'];
	$_SESSION['about'] 				= $rows['VSL_ABOUT'];
	$ship_owner						= $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$ship_owner_add					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$ship_owner_ph					= $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$ship_owner_email				= $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$ship_owner_personInc			= $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_2");
	
	if($rows['TERMO_OF_TOLERANCE']!="")
	{
	  $_SESSION['termOfTolerance'] =" ".$rows['TERMO_OF_TOLERANCE'];
	}
	else
	{
	  $_SESSION['termOfTolerance'] ="";
	}
	if($rows['CARGO_PACKING_DESC']!="")
	{
	  $_SESSION['cargoPackDesc'] =" ".$rows['CARGO_PACKING_DESC'];
	}
	else
	{
	  $_SESSION['cargoPackDesc'] ="";
	}
	$_SESSION['tolerancesub'] 	    = $rows['TOLERANCE_SUB'];
	$_SESSION['tolerancePerSub'] 	= $rows['TOLERANCE_PERCENT_SUB'];
	$_SESSION['toleranceAdd'] 	    = $rows['TOLERANCE_ADD'];
	$_SESSION['tolerancePerAdd'] 	= $rows['TOLERANCE_PERCENT_ADD'];
	
	
	number_format(($rows['AGREED_GROSS_FREIGHT_LOCAL']),2,'.','');
	if($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']>0)
	{$_SESSION['tolerancePerSub']= " -".number_format($rows['TOLERANCE_PERCENT_SUB'],1,'.','')."%/";}
	else if(($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']==0) || ($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']==""))
	{$_SESSION['tolerancePerSub']= " -".number_format($rows['TOLERANCE_PERCENT_SUB'],1,'.','')."% ";}
	else
	{$_SESSION['tolerancePerSub']= "";}
	if($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']>0)
	{$_SESSION['tolerancePerAdd']= "+".number_format($rows['TOLERANCE_PERCENT_ADD'],1,'.','')."% ";}
	else if(($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']==0) || ($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']==""))
	{$_SESSION['tolerancePerAdd']= " +".number_format($rows['TOLERANCE_PERCENT_ADD'],1,'.','')."% ";}
	else
	{$_SESSION['tolerancePerAdd']= "";}
	
	$cost_sheet_id 					= $obj->getLatestCostSheetID($rows['COMID']);
	
									  $obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	$_SESSION['quantity'] 			= $rows['QTY'];
	$_SESSION['cargo_name']			= $obj->getCargoNameListForMultipleNamemultiple($obj->getCompareEstimateData($rows['COMID'],"CARGO_ID"));
	if(date('d-m-Y',strtotime($rows['ETA_DATE1']))!='01-01-1970')
	{
	    $_SESSION['ETADATE']	        = date('d-m-Y H:i',strtotime($rows['ETA_DATE1']));
	}else{
		$_SESSION['ETADATE']            = '_____________';
	}
	$vlsImoId 						= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$charterer_name 				= "";
	

if($obj->getFun155()==1)
{
	$charterer_name = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"QTY_VENDORID"));
}
else
{
	$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
	$res12 = mysql_query($sql12);
	$rec12 = mysql_num_rows($res12);
	while($rows2 = mysql_fetch_assoc($res12))
	{
		$charterer_name = $charterer_name.", ".$obj->getVendorListNewBasedOnID($rows2['VENDORID']);
	}
}


$sql1 = "select * from generate_agency_letter_slave1 where GEN_AGENCY_ID=".$g_agency_id." order by SLAVEID asc";

$result1 = mysql_query($sql1);
$rows1 = mysql_fetch_assoc($result1);
$op_emailds = $rows1['EMAILID'];

/********************FOR LOAD PORT***************************/

if($port_type == "LP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(4);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(0,0,0);
	$pdf->Cell(190,6,"To :".$_SESSION['agent_name']." (".$_SESSION['portname'].") / att. ".$rows1['ENTITY_NAME']." (".$rows1['EMAILID'].")",0,1,'L',0);
	
	
	$pdf->Ln(3);
	$pdf->Cell(25,10,"Good day,",0,1,'L');
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(2);
	$pdf->Row1(array("We are glad to appoint you as our agents for handling cargo operations for subject vessel, which shows ETA on/around ".$_SESSION['ETADATE']." IAGW."));
	$pdf->Ln(2);
	$pdf->Row1(array("Vessel expected to load about ".$_SESSION['quantity']." MTS (subject to master's stow plan) of ".$_SESSION['cargo_name']." in Bulk at the port of ".$_SESSION['portname']));
	//
	$pdf->Ln(3);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->Cell(190,4,"VESSEL NAME : ".strtoupper($_SESSION['vslName']),0,1,'L');
	$pdf->Cell(190,4,"FLAG : ".strtoupper($obj->getCountryNameOnId($obj->getVesselIMOData($vlsImoId,"FLAG"))),0,1,'L');
	$pdf->Cell(190,4,"CLASS : ".strtoupper($obj->getClaSocNameOnId($obj->getVesselIMOData($vlsImoId,"CLA_SOC_ID"))),0,1,'L');
	$pdf->Cell(190,4,"BUILT (WHEN/WHERE) : ".$obj->getVesselIMOData($vlsImoId,"YEARBUILT")."/".strtoupper($obj->getCountryNameOnId($obj->getVesselParticularData('COUNTRY_ID','vessel_master_1',$vlsImoId)))."/".strtoupper($obj->getVesselParticularData('YARD_NAME','vessel_master_1',$vlsImoId)),0,1,'L');
	$pdf->Cell(190,4,"IMO NUMBER : ". $obj->getVesselIMOData($vlsImoId,"IMO_NO")."",0,1,'L');
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('REGISTRY_PORT','vessel_master_tankers',$vlsImoId))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vlsImoId,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vlsImoId)." MT / ".$obj->getVesselIMOData($vlsImoId,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vlsImoId)." MT",0,1,'L');
	}else{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('PORT_ID','vessel_master_1',$vlsImoId))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vlsImoId,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vlsImoId)." MT / ".$obj->getVesselIMOData($vlsImoId,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vlsImoId)." MT",0,1,'L');
	}
	
	$tonnage = $obj->getVesselIMOData($vlsImoId,"GRT_NRT");
	$tonnage1 = $obj->getVesselIMOData($vlsImoId,"NRT");
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==3)
	{
		$pdf->Cell(190,4,"CARGO HOLD CAPACITY (GRAINS) : ".$obj->getVesselIMOData($vlsImoId,"GRAIN")." MT",0,1,'L'); 
		$pdf->Cell(190,4,"NO.OF HOLDS / NO. OF HATCHES : ". $obj->getVesselIMOData($vlsImoId,"NOH")."/".$obj->getVesselIMOData($vlsImoId,"NOHA"),0,1,'L');
	}
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (98PCT) : ".$obj->getVesselIMOData($vlsImoId,"GAS_TANK_CAPACITY")." CBM",0,1,'L'); 
	}
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (TANKER) : ".$obj->getVesselIMOData($vlsImoId,"TANKER_CAPACITY")." CBM",0,1,'L');
		$pdf->Cell(190,4,"NO. OF CARGO PUMPS / NO. OF GRADES(DOUBLE V/V SEG) : ".$obj->getVesselIMOData($vlsImoId,"TANKER_CARGO_PUMP")."/".$obj->getVesselIMOData($vlsImoId,"NO_OF_GRADE"),0,1,'L');
	}
	$pdf->Ln(1);
	$pdf->Cell(190,4,"GROSS TONNAGE : ".$tonnage."",0,1,'L');
	$pdf->Cell(190,4,"NET TONNAGE : ".$tonnage1."",0,1,'L');
	$pdf->Cell(190,4,"PANAMA TONNAGE : ".$obj->getVesselParticularData('GT_PANAMA','vessel_master_1',$vlsImoId)."",0,1,'L');
	$pdf->Cell(190,4,"SUEZ CANAL TONNAGE : ".$obj->getVesselParticularData('GT_SUEZ','vessel_master_1',$vlsImoId)."",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (O.A.) : ".$obj->getVesselIMOData($vlsImoId,"LOA")." M",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (P.P) : ".$obj->getVesselParticularData('LBW','vessel_master_1',$vlsImoId)." M",0,1,'L');
	$pdf->Cell(190,4,"BREADTH(MLD.) : ".$obj->getVesselIMOData($vlsImoId,"EXT_BREADTH")." M",0,1,'L');
	$pdf->Cell(190,4,"DEPTH (MLD.) : ".$obj->getVesselParticularData('DEPTH_MODULE','vessel_master_1',$vlsImoId)." M",0,1,'L');
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Cell(190,4,"Vsl communication details: ",0,1,'L');
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_tankers',$vlsImoId)."",0,1,'L');
		//$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_tankers',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_tankers',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('PHONE_NO','vessel_master_tankers',$vlsImoId)."/".$obj->getVesselParticularData('TELEX_NO','vessel_master_tankers',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAXNO','vessel_master_tankers',$vlsImoId),0,1,'L');
		//$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_tankers',$vlsImoId),0,1,'L');
	}else{
	    $pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_6',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_6',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('TELEX_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAX_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
	}
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("FOR WHICH PLEASE ADVICE ON THE FOLLOWING :"));
	$pdf->Row1(array("- LOA/BEAM/DRAFT RESTRICTION, IF ANY"));
	if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
	{
		$pdf->Row1(array("- METHOD OF LOADING"));
	}else
	{
		$pdf->Row1(array("- METHOD OF LOADING (USING VSLS GEARS, GRABS/ SHORE EQPMENTS- SPECIFY)"));
	}
	$pdf->Row1(array("- AVERAGE LOAD RATE BEING ACHIEVED PER DAY"));
	$pdf->Row1(array("- ESTIMATED PORT DISBURSEMENT WITH PORT TARIFF BREAK-UP UP OF CHARGES + AGENCY FEE WITHOUT STEVEDORING CHARGES."));
	$pdf->Row1(array("- PORT CONGESTION  / BERTHING DELAY OR ANCHORAGE DELAY OR WAITING TIME IF ANY"));
	$pdf->Row1(array("- BUNKER AND FRESH WATER AVAILABILITY ?"));
	$pdf->Row1(array("- OTHER RELEVANT INFORMATION IF ANY SUCH TAX/OR LEVY ETC"));
	if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
	{
		$pdf->Row1(array("- WEATHER CONDITIONS"));
	}else
	{
		$pdf->Row1(array("- WEATHER CONDITIONS I.E PERIOD OF MONSOON , TROPICAL SHOWERS AND ANY OTHER WEATHER FACTORS THAT WOULD AFFECT THE LOADING ROUND THE YEAR."));
	}
	$pdf->Row1(array("- ANY OTHER REQUIRED INFORMATION, IF ANY"));
	
	$pdf->Ln(2);
	$pdf->Row1(array("We request you to kindly ensure UTMOST DISPATCH of the ship and keep us and Master of the vessel updated daily on the port conditions, line ups, loading/discharging status, etc. following shipping practice and should guide us / master on any documentation to be done with port well in advance."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Master has the right to mention his remark on daily working / stevedore report which is to form part of SOF. Also, if any note of protest is raised by master same should also be part of SOF. And SOF should explicitly mention that stevedores / daily working report / note or letter of protest etc is part of SOF."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Kindly make sure bills of lading (in case of load port ) to be ready prior sailing of vessel to obtain master signature, if same not ready master will authorize you to sign on his behalf"));
	
	$pdf->Ln(2);
	$pdf->Row1(array("- The draft B/L & draft SOF also to be forwarded to us for confirmation."));
	$pdf->Row1(array("- Daily loading/discharging and stevedore report to be sent"));
	$pdf->Row1(array("- Prior completion of the loading proper port clearance should be obtained."));
	$pdf->Row1(array("- Pls ask Master to tender to regular eta notices to all parties concerned."));
	
	$pdf->Ln(4);
	$pdf->Row1(array("Best regards,"));
	$pdf->Ln(2);
	//$pdf->Row1(array('Operations'));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'CONTACT_PERSON')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'PHONE_NO')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'ADDRESS')));
	$pdf->Row1(array("AS AGENT FOR AND BEHALF OF CHARTERERS / OPERATORS."));
	//$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'EMAILID')));
	//$pdf->Row1(array($obj->getCompanyNameBasedOnID($obj->getUserDetailBaseOnId($rows['LOGINID'],'MCOMPANYID'),'COMPANY_NAME')));
	
}

/********************FOR DISCHARGE PORT**********************/

else if($port_type == "DP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	
	
	$pdf->Ln(4);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(0,0,0);
	$pdf->Cell(190,6,"To :".$_SESSION['agent_name']." (".$_SESSION['portname'].") / att. ".$rows1['ENTITY_NAME']." (".$rows1['EMAILID'].")",0,1,'L',0);
	
	
	$pdf->Ln(3);
	$pdf->Cell(25,10,"Good day,",0,1,'L');
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(2);
	$pdf->Row1(array("We are glad to appoint you as our agents for handling cargo operations for subject vessel, which shows ETA on/around ".$_SESSION['ETADATE']." IAGW."));
	$pdf->Ln(2);
	$pdf->Row1(array("Vessel expected to discharge about ".$_SESSION['quantity']." MTS of ".$_SESSION['cargo_name']." in Bulk at the port of ".$_SESSION['portname']));
	//
	$pdf->Ln(3);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->Cell(190,4,"VESSEL NAME : ".strtoupper($_SESSION['vslName']),0,1,'L');
	$pdf->Cell(190,4,"FLAG : ".strtoupper($obj->getCountryNameOnId($obj->getVesselIMOData($vlsImoId,"FLAG"))),0,1,'L');
	$pdf->Cell(190,4,"CLASS : ".strtoupper($obj->getClaSocNameOnId($obj->getVesselIMOData($vlsImoId,"CLA_SOC_ID"))),0,1,'L');
	$pdf->Cell(190,4,"BUILT (WHEN/WHERE) : ".$obj->getVesselIMOData($vlsImoId,"YEARBUILT")."/".strtoupper($obj->getCountryNameOnId($obj->getVesselParticularData('COUNTRY_ID','vessel_master_1',$vlsImoId)))."/".strtoupper($obj->getVesselParticularData('YARD_NAME','vessel_master_1',$vlsImoId)),0,1,'L');
	$pdf->Cell(190,4,"IMO NUMBER : ". $obj->getVesselIMOData($vlsImoId,"IMO_NO")."",0,1,'L');
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('REGISTRY_PORT','vessel_master_tankers',$vlsImoId))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vlsImoId,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vlsImoId)." MT / ".$obj->getVesselIMOData($vlsImoId,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vlsImoId)." MT",0,1,'L');
	}else{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('PORT_ID','vessel_master_1',$vlsImoId))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vlsImoId,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vlsImoId)." MT / ".$obj->getVesselIMOData($vlsImoId,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vlsImoId)." MT",0,1,'L');
	}
	
	$tonnage = $obj->getVesselIMOData($vlsImoId,"GRT_NRT");
	$tonnage1 = $obj->getVesselIMOData($vlsImoId,"NRT");
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==3)
	{
		$pdf->Cell(190,4,"CARGO HOLD CAPACITY (GRAINS) : ".$obj->getVesselIMOData($vlsImoId,"GRAIN")." MT",0,1,'L'); 
		$pdf->Cell(190,4,"NO.OF HOLDS / NO. OF HATCHES : ". $obj->getVesselIMOData($vlsImoId,"NOH")."/".$obj->getVesselIMOData($vlsImoId,"NOHA"),0,1,'L');
	}
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (98PCT) : ".$obj->getVesselIMOData($vlsImoId,"GAS_TANK_CAPACITY")." CBM",0,1,'L'); 
	}
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (TANKER) : ".$obj->getVesselIMOData($vlsImoId,"TANKER_CAPACITY")." CBM",0,1,'L');
		$pdf->Cell(190,4,"NO. OF CARGO PUMPS / NO. OF GRADES(DOUBLE V/V SEG) : ".$obj->getVesselIMOData($vlsImoId,"TANKER_CARGO_PUMP")."/".$obj->getVesselIMOData($vlsImoId,"NO_OF_GRADE"),0,1,'L');
	}
	$pdf->Ln(1);
	$pdf->Cell(190,4,"GROSS TONNAGE : ".$tonnage."",0,1,'L');
	$pdf->Cell(190,4,"NET TONNAGE : ".$tonnage1."",0,1,'L');
	$pdf->Cell(190,4,"PANAMA TONNAGE : ".$obj->getVesselParticularData('GT_PANAMA','vessel_master_1',$vlsImoId)."",0,1,'L');
	$pdf->Cell(190,4,"SUEZ CANAL TONNAGE : ".$obj->getVesselParticularData('GT_SUEZ','vessel_master_1',$vlsImoId)."",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (O.A.) : ".$obj->getVesselIMOData($vlsImoId,"LOA")." M",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (P.P) : ".$obj->getVesselParticularData('LBW','vessel_master_1',$vlsImoId)." M",0,1,'L');
	$pdf->Cell(190,4,"BREADTH(MLD.) : ".$obj->getVesselIMOData($vlsImoId,"EXT_BREADTH")." M",0,1,'L');
	$pdf->Cell(190,4,"DEPTH (MLD.) : ".$obj->getVesselParticularData('DEPTH_MODULE','vessel_master_1',$vlsImoId)." M",0,1,'L');
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Cell(190,4,"Vsl communication details: ",0,1,'L');
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	if($obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vlsImoId,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_tankers',$vlsImoId)."",0,1,'L');
		//$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_tankers',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_tankers',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('PHONE_NO','vessel_master_tankers',$vlsImoId)."/".$obj->getVesselParticularData('TELEX_NO','vessel_master_tankers',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAXNO','vessel_master_tankers',$vlsImoId),0,1,'L');
		//$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_tankers',$vlsImoId),0,1,'L');
	}else{
	    $pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_6',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_6',$vlsImoId)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('TELEX_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAX_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
		$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_6',$vlsImoId),0,1,'L');
	}
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("FOR WHICH PLEASE ADVICE ON THE FOLLOWING :"));
	$pdf->Row1(array("- LOA/BEAM/DRAFT RESTRICTION, IF ANY"));
	if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
	{
		$pdf->Row1(array("- METHOD OF DISCHARGING"));
	}else
	{
		$pdf->Row1(array("- METHOD OF DISCHARGING (USING VSLS GEARS, GRABS/ SHORE EQPMENTS- SPECIFY)"));
	}
	$pdf->Row1(array("- METHOD OF DISCHARGING (USING VSLS GEARS, GRABS/ SHORE EQPMENTS- SPECIFY)"));
	$pdf->Row1(array("- AVERAGE DISCHARGE RATE BEING ACHIEVED PER DAY"));
	$pdf->Row1(array("- ESTIMATED PORT DISBURSEMENT WITH PORT TARIFF BREAK-UP UP OF CHARGES + AGENCY FEE WITHOUT STEVEDORING CHARGES."));
	$pdf->Row1(array("- PORT CONGESTION  / BERTHING DELAY OR ANCHORAGE DELAY OR WAITING TIME IF ANY"));
	$pdf->Row1(array("- BUNKER AND FRESH WATER AVAILABILITY ?"));
	$pdf->Row1(array("- OTHER RELEVANT INFORMATION IF ANY SUCH TAX/OR LEVY ETC"));
	if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
	{
		$pdf->Row1(array("- WEATHER CONDITIONS"));
	}else
	{
		$pdf->Row1(array("- WEATHER CONDITIONS I.E PERIOD OF MONSOON , TROPICAL SHOWERS AND ANY OTHER WEATHER FACTORS THAT WOULD AFFECT THE DISCHARGING ROUND THE YEAR."));
	}
	
	$pdf->Row1(array("- ANY OTHER REQUIRED INFORMATION, IF ANY"));
	
	$pdf->Ln(2);
	$pdf->Row1(array("We request you to kindly ensure UTMOST DISPATCH of the ship and keep us and Master of the vessel updated daily on the port conditions, line ups, loading/discharging status, etc. following shipping practice and should guide us / master on any documentation to be done with port well in advance."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Master has the right to mention his remark on daily working / stevedore report which is to form part of SOF. Also, if any note of protest is raised by master same should also be part of SOF. And SOF should explicitly mention that stevedores / daily working report / note or letter of protest etc is part of SOF."));
	
	
	
	$pdf->Ln(2);
	$pdf->Row1(array("- The draft B/L & draft SOF also to be forwarded to us for confirmation."));
	$pdf->Row1(array("- Daily loading/discharging and stevedore report to be sent"));
	$pdf->Row1(array("- Prior completion of the discharging proper port clearance should be obtained."));
	$pdf->Row1(array("- Pls ask Master to tender to regular eta notices to all parties concerned."));
	
	$pdf->Ln(4);
	$pdf->Row1(array("Best regards,"));
	$pdf->Ln(2);
	//$pdf->Row1(array('Operations'));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'CONTACT_PERSON')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'PHONE_NO')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'ADDRESS')));
	$pdf->Row1(array("AS AGENT FOR AND BEHALF OF CHARTERERS / OPERATORS."));
}

else if($port_type == "TP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Agency Nomination Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
}

	$pdf->Ln(6);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(50,50,90);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Username: ".$rows['USERNAME'],"Password: ".$rows['PASSWORD'],""));
	$pdf->Ln(2);
	$pdf->SetTextColor(027,119,166);
	$link='https://progress.sevenoceansgenesis.com/agentlogin.html';
	$pdf->SetLink($link);
	$pdf->Write(4,'Click here to login',$link);

$filename = "Agency Nomination Letter(".$_SESSION['vslName']."-".$obj->getVendorListNewBasedOnID($rows['VENDORID']).") ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}




function getTankerQ88PDF(){
	
	$obj 			= new data();
	$obj->funConnect();
	$vesselid 		= $_REQUEST['vesselid'];
	
	$sql = "select * from vessel_master_tankers where VESSEL_IMO_ID='".$vesselid."'";
	$res = mysql_query($sql) or die($sql);
	$rows = mysql_fetch_assoc($res);
	$yesnoarray = array(''=>'','1'=>'Yes','2'=>'No');
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('TANKER CHARTERING QUESTIONNAIRE 88 (Q88)');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('TANKER CHARTERING QUESTIONNAIRE 88 (Q88)');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/*********************************FIXTURE DETAILS*****************************************/
	
	$pdf->SetFont('Arial','B',11);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"INTERTANKO'S STANDARD TANKER CHARTERING QUESTIONNAIRE 88 (Q88)",0,1,'C');
					
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"1. VESSEL DESCRIPTION",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L');
	$arr2=array(100,90);
	$pdf->Ln(1);
	$arr3=array("1.1 Date updated ",date('d-m-Y',strtotime($rows['UPDATEONDATE'])));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.2 Vessel's name ",$obj->getVesselIMOData($_REQUEST['vesselid'],"VESSEL_NAME"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.3 IMO number ",$obj->getVesselIMOData($_REQUEST['vesselid'],"IMO_NO"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	if($rows['DATEOFCHANGE'] == "0000-00-00" || $rows['DATEOFCHANGE'] == ""){ $dateofchange = ""; }else{ $dateofchange = date('d-m-Y',strtotime($rows['DATEOFCHANGE'])); }
	$arr3=array("1.4 Vessel's previous name(s) and date(s) of change",$rows['PREVIOUS_NAME'],$dateofchange);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	if($rows['DATEOFDELIVERY'] == "0000-00-00" || $rows['DATEOFDELIVERY'] == ""){ $dateofdelivery = ""; }else{ $dateofdelivery = date('d-m-Y',strtotime($rows['DATEOFDELIVERY'])); }
	$arr3=array("1.5 Date delivered",$dateofdelivery,'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.6 Builder (where built)",$rows['BUILDER'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.7 Flag",$obj->getPortNameBasedOnID($obj->getVesselParticularData('FLAG','vessel_imo_master',$_REQUEST['vesselid'])),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.8 Port of Registry",$obj->getPortNameBasedOnID($rows['REGISTRY_PORT']),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.9 Call sign",$rows['CALL_SIGN'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.10 Vessel's satcom phone number",$rows['PHONE_NO'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	$arr3=array("        Vessel's fax number",$rows['FAXNO'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	$arr3=array("        Vessel's telex number",$rows['TELEX_NO'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	$arr3=array("        Vessel's email address",$rows['EMAIL_ADDRESS'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.11 Type of vessel",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($_REQUEST['vesselid'],"VESSEL_TYPE")),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.12 Type of hull",$rows['HULL_TYPE'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Classification",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr3=array("1.13 Classification society",$obj->getClaSocNameOnId($obj->getVesselIMOData($_REQUEST['vesselid'],"CLA_SOC_ID")),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.14 Class notation",$rows['CLASS_NOTATION'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.15 If Classification society changed, name of previous society",$obj->getClaSocNameOnId($rows['PREV_CLA_SOC_ID']),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	if($rows['DATEOFCLASSCHANGE'] == "0000-00-00" || $rows['DATEOFCLASSCHANGE'] == ""){ $DATEOFCLASSCHANGE = ""; }else{ $DATEOFCLASSCHANGE = date('d-m-Y',strtotime($rows['DATEOFCLASSCHANGE'])); }
	$arr3=array("1.16 If Classification society changed, date of change",$DATEOFCLASSCHANGE ,'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.17 IMO type, if applicable",$rows['IMO_TYPE'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.18 Does the vessel have ice class? If yes, state what level",$yesnoarray[$rows['RDO_ICE_CLASS']] ,$rows['ICE_CLASS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	if($rows['DRY_DOCK_DATE'] == "0000-00-00" || $rows['DRY_DOCK_DATE'] == ""){ $DRY_DOCK_DATE = ""; }else{ $DRY_DOCK_DATE = date('d-m-Y',strtotime($rows['DRY_DOCK_DATE'])); }
	$arr3=array("1.19 Date / place of last dry-dock",$DRY_DOCK_DATE ,$obj->getPortNameBasedOnID($rows['DRY_DOCK_PORT']));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	if($rows['NEXT_DRY_DOCK_DATE'] == "0000-00-00" || $rows['NEXT_DRY_DOCK_DATE'] == ""){ $NEXT_DRY_DOCK_DATE = ""; }else{ $NEXT_DRY_DOCK_DATE = date('d-m-Y',strtotime($rows['NEXT_DRY_DOCK_DATE'])); }
	$arr3=array("1.20 Date next dry dock due",$NEXT_DRY_DOCK_DATE,'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	if($rows['SURVEY_DATE'] == "0000-00-00" || $rows['SURVEY_DATE'] == ""){ $SURVEY_DATE = ""; }else{ $SURVEY_DATE = date('d-m-Y',strtotime($rows['SURVEY_DATE'])); }
	if($rows['DUE_SURVEY_DATE'] == "0000-00-00" || $rows['DUE_SURVEY_DATE'] == ""){ $DUE_SURVEY_DATE = ""; }else{ $DUE_SURVEY_DATE = date('d-m-Y',strtotime($rows['DUE_SURVEY_DATE'])); }
	$arr3=array("1.21 Date of last special survey / next survey due",$SURVEY_DATE,$DUE_SURVEY_DATE);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	if($rows['ANNUAL_SURVEY_DATE'] == "0000-00-00" || $rows['ANNUAL_SURVEY_DATE'] == ""){ $ANNUAL_SURVEY_DATE = ""; }else{ $ANNUAL_SURVEY_DATE = date('d-m-Y',strtotime($rows['ANNUAL_SURVEY_DATE'])); }
	$arr3=array("1.22 Date of last annual survey",$ANNUAL_SURVEY_DATE ,'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.23 If ship has Condition Assessment Program (CAP), what is the latest overall rating",$rows['OVERALL_RATING'],'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	if($rows['EXPIRY_STAT_DATE'] == "0000-00-00" || $rows['EXPIRY_STAT_DATE'] == ""){ $EXPIRY_STAT_DATE = ""; }else{ $EXPIRY_STAT_DATE = date('d-m-Y',strtotime($rows['EXPIRY_STAT_DATE'])); }
	$arr3=array("1.24 Does the vessel have a statement of compliance issued under the provisions of the Condition Assessment Scheme (CAS): If yes, what is the expiry date?",$yesnoarray[$rows['RDOIS_STATEMENT']] ,$EXPIRY_STAT_DATE);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Dimensions",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Ln(1);
	$arr3=array("1.25 Length Over All (LOA)",$obj->getVesselIMOData($_REQUEST['vesselid'],"LOA")." M",'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.26 Length Between Perpendiculars (LBP)",$rows['LBP_LENGTH']." M",'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.27 Extreme breadth (Beam)",$rows['BEAM']." M",'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.28 Moulded depth",$rows['MODULER_DEPTH']." M" ,'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.29 Keel to Masthead (KTM) / KTM in collapsed condition (if applicable)",$rows['KEEL_KTM']." M" ,$rows['KTM_COLLAPSED']." M");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$arr3=array("1.30 Bow to Center Manifold (BCM) / Stern to Center Manifold (SCM):",$rows['BCENTER_MANIFOLD']." M" ,$rows['SCENTER_MANIFOLD']." M");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.31 Distance bridge front to center of manifold",$rows['FCENTER_MANIFOLD']." M",'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(55,47,47,47);
	$arr3=array("1.32 Parallel body distances",'Lightship(M)','Normal Ballast(M)','Summer Dwt(M)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forward to mid-point manifold:",$rows['LIGHTSHIP_1'],$rows['BALLAST_1'],$rows['SDRAFT_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Aft to mid-point manifold",$rows['LIGHTSHIP_2'],$rows['BALLAST_2'],$rows['SDRAFT_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Parallel body length",$rows['LIGHTSHIP_3'],$rows['BALLAST_3'],$rows['SDRAFT_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("1.33 FWA at summer draft/ TPC immersion at summer draft",$rows['FWA_SUMMER']." MM",$rows['TPC_SUMMER']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L');
	$arr2=array(102,47,47);
	$arr3=array("1.34 What is the max height of mast above waterline (air draft)",'Full Mast(M)','Collapsed Mast(M)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Lightship",$rows['FULL_MAST_1'],$rows['COLLAPSED_MAST_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Normal ballast",$rows['FULL_MAST_2'],$rows['COLLAPSED_MAST_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        At loaded summer deadweight",$rows['FULL_MAST_3'],$rows['COLLAPSED_MAST_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Tonnages",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Ln(1);
	$arr3=array("1.35 Net Tonnage",'',$rows['NET_TONNAGE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("1.36 Gross Tonnage / Reduced Gross Tonnage (if applicable)" ,'',$rows['LBP_LENGTH']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.37 Suez Canal Tonnage - Gross (SCGT) / Net (SCNT)",$rows['CANAL_TONNAGE'] ,$rows['NET_SCNT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("1.38 Panama Canal Net Tonnage (PCNT)" ,'',$rows['PCN_TONNAGE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Loadline Information",0,1,'L');
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L','L');
	$arr2=array(55,35,35,35,36);
	$arr3=array("1.39 Loadline",'Freeboard(M)','Draft(M)','Deadweight(MT)','Displacement(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Summer",$rows['FREEBOARD_1'],$rows['DRAFT_1'],$rows['DEADWEIGHT_1'],$rows['DISPLACEMENT_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Winter",$rows['FREEBOARD_2'],$rows['DRAFT_2'],$rows['DEADWEIGHT_2'],$rows['DISPLACEMENT_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Tropical",$rows['FREEBOARD_3'],$rows['DRAFT_3'],$rows['DEADWEIGHT_3'],$rows['DISPLACEMENT_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Lightship",$rows['FREEBOARD_4'],$rows['DRAFT_4'],$rows['DEADWEIGHT_4'],$rows['DISPLACEMENT_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Normal Ballast Condition",$rows['FREEBOARD_5'],$rows['DRAFT_5'],$rows['DEADWEIGHT_5'],$rows['DISPLACEMENT_5']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);

	
	$pdf->Ln(1);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("1.40 Does vessel have multiple SDWT?" ,'',$yesnoarray[$rows['RDODEADWEIGHT']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.41 If yes, what is the maximum assigned deadweight?",'',$rows['ASSDEADWEIGHT']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Ownership and Operation",0,1,'L');
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L');
	$arr2=array(100,90);
	$arr3=array("1.42 Registered owner - Full style",$rows['REGISTEREDOWNER']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.43 Technical operator - Full style",$rows['TECHNICALOPERATOR']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.44 Commercial operator - Full style",$rows['COMMERCIALOPERATOR']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("1.45 Disponent owner - Full style",$rows['DISPONENTOWNER']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"2. CERTIFICATION",0,1,'L');
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','B',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(90,35,35,35);
	$arr3=array("Certificate Name",'Date Of Issue','Date Of Last Annual Endorsement','Date Of Expiry');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(90,35,35,35);
	
	
	$sql1 = "select * from vessel_master_tankers_slave where VESSEL_IMO_ID=".$_REQUEST['vesselid'];
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		if($rows1['DATE_ISSUE'] == "0000-00-00" || $rows1['DATE_ISSUE'] == ""){ $DATE_ISSUE = ""; }else{ $DATE_ISSUE = date('d-m-Y',strtotime($rows1['DATE_ISSUE'])); }
		if($rows1['DATE_LAST'] == "0000-00-00" || $rows1['DATE_LAST'] == ""){ $DATE_LAST = ""; }else{ $DATE_LAST = date('d-m-Y',strtotime($rows1['DATE_LAST'])); }
		if($rows1['DATE_EXPIRY'] == "0000-00-00" || $rows1['DATE_EXPIRY'] == ""){ $DATE_EXPIRY = ""; }else{ $DATE_EXPIRY = date('d-m-Y',strtotime($rows1['DATE_EXPIRY'])); }
		$arr3=array($obj->getCertificateNameOnId($rows1['CERTIFICATE_ID']),$DATE_ISSUE,$DATE_LAST,$DATE_EXPIRY);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Documentation",0,1,'L');
	
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("2.18 Does vessel have all updated publications as listed in the Vessel Inspection Questionnaire, Chapter 2- Question 2.24, as applicable" ,'',$yesnoarray[$rows['RDOPUBLICATIONS']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("2.19 Owner warrant that vessel is member of ITOPF and will remain so for the entire duration of this voyage/contract",'',$yesnoarray[$rows['RDOOWNERWARRANT']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"3. CREW MANAGEMENT",0,1,'L');
	
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("3.1 Nationality of Master" ,'',$rows['MASTER_NATIONALITY']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("3.2 Nationality of Officers",'',$rows['OFFICER_NATIONALITY']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("3.3 Nationality of Crew",'',$rows['CREW_NATIONALITY']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("3.4 If Officers/Crew employed by a Manning Agency - Full style",'',$rows['MANNING_AGENCY']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("3.5 What is the common working language onboard",'',$rows['WORKING_LANGUAGE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("3.6 Do officers speak and understand English",'',$yesnoarray[$rows['RDOUNDERSTAND_ENGLISH']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("3.7 In case of Flag Of Convenience, is the ITF Special Agreement on board",'',$rows['ITF_SPECIAL_AGREEMENT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"4. HELICOPTERS",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("4.1 Can the ship comply with the ICS Helicopter Guidelines" ,'',$yesnoarray[$rows['RDOICSHELICOPTER']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("4.2 If Yes, state whether winching or landing area provided",'',$rows['ICSHELICOPTER_AREA']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"5. FOR USA CALLS",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("5.1 Has the vessel Operator submitted a Vessel Spill Response Plan to the US Coast Guard which has been approved by
official USCG letter" ,'',$yesnoarray[$rows['RDOSPILLRESPONSE']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("5.2 Qualified individual (QI) - Full style",'',$rows['QUALIFIED_INDIVIDUAL']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("5.3 Oil Spill Response Organization (OSRO) -Full style",'',$rows['SPILL_RESPONSE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr3=array("5.4 Has technical operator signed the SCIA / C-TPAT agreement with US customs concerning drug smuggling" ,'',$yesnoarray[$rows['RDOAGREEMENTUS']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"6. CARGO AND BALLAST HANDLING",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Double Hull Vessels",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.1 Is vessel fitted with centerline bulkhead in all cargo tanks" ,'',$yesnoarray[$rows['RDOBULKHEAD']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.2 If Yes, is bulkhead solid or perforated",'',$rows['BULKHEAD']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Cargo Tank Capacities",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.3 Capacity (98%) of each natural segregation with double valve (specify tanks)",'',$rows['CAPACITY_98']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.4 Total cubic capacity (98%, excluding slop tanks)(M3)" ,'',$rows['CUBIC_CAPACITY']." M3");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.5 Slop tank(s) capacity (98%)(M3)" ,'',$rows['SLOP_CAPACITY98']." M3");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.6 Residual/Retention oil tank(s) capacity (98%), if applicable(M3)" ,'',$rows['OIL_TANKCAPACITY98']." M3");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.7 Does vessel have Segregated Ballast Tanks (SBT) or Clean Ballast Tanks (CBT)(M3)" ,'',$rows['SEGREGATED_BALLAST']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"SBT Vessels",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.8 What is total capacity of SBT?(M3)",'',$rows['SBT_CAPACITY']." M3");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.9 What percentage of SDWT can vessel maintain with SBT only(%)" ,'',$rows['SDWT_PERCENT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.10 Does vessel meet the requirements of MARPOL Annex I Reg 18.2: (previously Reg 13.2)" ,'',$yesnoarray[$rows['RDOMARPOLANNEX']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Cargo Handling",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.11 How many grades/products can vessel load/discharge with double valve segregation",'',$rows['NO_OF_CRUDE_PRODUCT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.12 Maximum loading rate for homogenous cargo per manifold connection(M3/HR)" ,'',$rows['CARGORATE_PERMANIFOLD']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.13 Maximum loading rate for homogenous cargo loaded simultaneously through all manifolds(M3/HR)" ,'',$rows['CARGORATE_ALLMANIFOLD']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.14 Are there any cargo tank filling restrictions." ,'',$yesnoarray[$rows['RDOCARGOTANKRESTRICTIONS']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        If yes, please specify" ,'',$rows['CARGOTANKRESTRICTIONS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Pumping Systems",0,1,'L');
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(55,45,45,45);
	$arr3=array("6.15 Pumps",'No.','Type','Capacity(M3/HR)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Cargo",$rows['PUMPSNO_1'],$rows['PUMPSTYPE_1'],$rows['PUMPSCAPACITY_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Stripping",$rows['PUMPSNO_2'],$rows['PUMPSTYPE_2'],$rows['PUMPSCAPACITY_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Eductors",$rows['PUMPSNO_3'],$rows['PUMPSTYPE_3'],$rows['PUMPSCAPACITY_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Ballast",$rows['PUMPSNO_4'],$rows['PUMPSTYPE_4'],$rows['PUMPSCAPACITY_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.16 How many cargo pumps can be run simultaneously at full capacity" ,'',$rows['NO_OF_CARGO_PUMPS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Cargo Control Room",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.17 Is ship fitted with a Cargo Control Room (CCR)",'',$yesnoarray[$rows['RDOCARGOCONTROLROOM']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.18 Can tank innage / ullage be read from the CCR" ,'',$yesnoarray[$rows['RDOTANKINNAGECCR']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Gauging and Sampling",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.19 Can ship operate under closed conditions in accordance with ISGOTT" ,'',$yesnoarray[$rows['RDOSHIPOPERATEUNDERCLOSED']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.20 What type of fixed closed tank gauging system is fitted" ,'',$rows['TYPE_OF_GAUGING_SYSTEM']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.21 Are overfill (high-high) alarms fitted?" ,'',$yesnoarray[$rows['RDOOVERFILLALARM']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("         If Yes, indicate whether to all tanks or partial" ,'',$rows['OVERFILLALARM']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Vapor Emission Control",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.22 Is a vapor return system (VRS) fitted" ,'',$yesnoarray[$rows['RDOVAPORRETURNSYSTEM']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.23 Number/size of VRS manifolds (per side)",$rows['NO_OF_VRS'],$rows['SIZE_OF_VRS']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Venting",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.24 State what type of venting system is fitted" ,'',$rows['TYPE_OF_VENTING_SYSTEM']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Cargo Manifolds",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.25 Does vessel comply with the latest edition of the OCIMF 'Recommendations for Oil Tanker Manifolds and Associated Equipment" ,'',$yesnoarray[$rows['RDOOCIMFEDITION']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.26 What is the number of cargo connections per side" ,'',$rows['CARGO_CONNECTION_PER_SIDE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.27 What is the size of cargo connections" ,'',$rows['SIZE_OF_CARGO_CONNECTION']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.28 What is the material of the manifold" ,'',$rows['MATERIAL_OF_MANIFOLDS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Manifold Arrangement",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.29 Distance between cargo manifold centers" ,'',$rows['MANIFOLDS_DISTANCE']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.30 Distance ships rail to manifold" ,'',$rows['SHIPS_RAIL_MANIFOLD']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.31 Distance manifold to ships side" ,'',$rows['MANIFOLD_SHIPSIDE_DISTANCE']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.32 Top of rail to center of manifold" ,'',$rows['TOPRAIL_CENTER_MANIFOLD']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.33 Distance main deck to center of manifold" ,'',$rows['DISTANCE_MAIN_DECK']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.34 Manifold height above the waterline in normal ballast / at SDWT condition" ,$rows['HEIGHT_AT_BALLAST']." M",$rows['HEIGHT_AT_SDWT']." M");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.35 Number / size reducers" ,'',$rows['NUM_SIZE_REDUCERS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Stern Manifold",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.36 Is vessel fitted with a stern manifold" ,'',$yesnoarray[$rows['RDOFITTEDSTERMMANIFOLD']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("6.37 If stern manifold fitted, state size" ,'',$rows['FITTEDSTERMMANIFOLD']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Cargo Heating",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.38 Type of cargo heating system?" ,'',$rows['TYPEODCARGOHEATING']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("6.39 If fitted, are all tanks coiled?" ,'',$yesnoarray[$rows['RDOTANKCOILED']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);

    $arr3=array("6.40 If fitted, what is the material of the heating coils" ,'',$rows['TANKCOILED']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("6.41 Maximum temperature cargo can be loaded/maintained" ,'',$rows['MAXIMUMTEMPRATURE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Tank Coating",0,1,'L');
	
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(55,45,45,45);
	$arr3=array("6.42 Are cargo, ballast and slop tanks coated?",'Coated','Type','To What Extent');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Cargo tanks",$yesnoarray[$rows['RDOTANKCOATING1']],$rows['COATINGTYPE_1'],$rows['COATINGEXTENT_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Ballast tanks",$yesnoarray[$rows['RDOTANKCOATING2']],$rows['COATINGTYPE_2'],$rows['COATINGEXTENT_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Slop tanks",$yesnoarray[$rows['RDOTANKCOATING3']],$rows['COATINGTYPE_3'],$rows['COATINGEXTENT_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.43 If fitted, what type of anodes are used" ,'',$rows['COATINGTYPEUSED']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"7. INERT GAS AND CRUDE OIL WASHING",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("7.1 Is an Inert Gas System (IGS) fitted" ,'',$yesnoarray[$rows['RDOGASSYSTEM']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("7.2 Is IGS supplied by flue gas, inert gas (IG) generator and/or nitrogen",'',$rows['IGS_SUPPLIED']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("7.3 Is a Crude Oil Washing (COW) installation fitted",'',$rows['CRUDEOILWASHING']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"8. MOORING",0,1,'L');
	
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(40,30,30,30,30,30);
	$arr3=array("8.1 Mooring wires (on drums)",'No','Diameter(MM)','Material','Length(M)','Breaking Strength(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORNO_1'],$rows['MOORDIAMETER_1'],$rows['MOORMATERIAL_1'],$rows['MOORLENGTH_1'],$rows['MOORBREAKSTREANGTH_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORNO_2'],$rows['MOORDIAMETER_2'],$rows['MOORMATERIAL_2'],$rows['MOORLENGTH_2'],$rows['MOORBREAKSTREANGTH_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORNO_3'],$rows['MOORDIAMETER_3'],$rows['MOORMATERIAL_3'],$rows['MOORLENGTH_3'],$rows['MOORBREAKSTREANGTH_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORNO_4'],$rows['MOORDIAMETER_4'],$rows['MOORMATERIAL_4'],$rows['MOORLENGTH_4'],$rows['MOORBREAKSTREANGTH_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(3);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(40,30,30,30,30,30);
	$arr3=array("8.2 Wire tails",'No','Diameter(MM)','Material','Length(M)','Breaking Strength(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORNO1_1'],$rows['MOORDIAMETER1_1'],$rows['MOORMATERIAL1_1'],$rows['MOORLENGTH1_1'],$rows['MOORBREAKSTREANGTH1_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORNO1_2'],$rows['MOORDIAMETER1_2'],$rows['MOORMATERIAL1_2'],$rows['MOORLENGTH1_2'],$rows['MOORBREAKSTREANGTH1_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORNO1_3'],$rows['MOORDIAMETER1_3'],$rows['MOORMATERIAL1_3'],$rows['MOORLENGTH1_3'],$rows['MOORBREAKSTREANGTH1_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORNO1_4'],$rows['MOORDIAMETER1_4'],$rows['MOORMATERIAL1_4'],$rows['MOORLENGTH1_4'],$rows['MOORBREAKSTREANGTH1_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(3);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(40,30,30,30,30,30);
	$arr3=array("8.3 Mooring ropes (on drums)",'No','Diameter(MM)','Material','Length(M)','Breaking Strength(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORNO2_1'],$rows['MOORDIAMETER2_1'],$rows['MOORMATERIAL2_1'],$rows['MOORLENGTH2_1'],$rows['MOORBREAKSTREANGTH2_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORNO2_2'],$rows['MOORDIAMETER2_2'],$rows['MOORMATERIAL2_2'],$rows['MOORLENGTH2_2'],$rows['MOORBREAKSTREANGTH2_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORNO2_3'],$rows['MOORDIAMETER2_3'],$rows['MOORMATERIAL2_3'],$rows['MOORLENGTH2_3'],$rows['MOORBREAKSTREANGTH2_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORNO2_4'],$rows['MOORDIAMETER2_4'],$rows['MOORMATERIAL2_4'],$rows['MOORLENGTH2_4'],$rows['MOORBREAKSTREANGTH2_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(3);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(40,30,30,30,30,30);
	$arr3=array("8.4 Other mooring lines",'No','Diameter(MM)','Material','Length(M)','Breaking Strength(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORNO3_1'],$rows['MOORDIAMETER3_1'],$rows['MOORMATERIAL3_1'],$rows['MOORLENGTH3_1'],$rows['MOORBREAKSTREANGTH3_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORNO3_2'],$rows['MOORDIAMETER3_2'],$rows['MOORMATERIAL3_2'],$rows['MOORLENGTH3_2'],$rows['MOORBREAKSTREANGTH3_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORNO3_3'],$rows['MOORDIAMETER3_3'],$rows['MOORMATERIAL3_3'],$rows['MOORLENGTH3_3'],$rows['MOORBREAKSTREANGTH3_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORNO3_4'],$rows['MOORDIAMETER3_4'],$rows['MOORMATERIAL3_4'],$rows['MOORLENGTH3_4'],$rows['MOORBREAKSTREANGTH3_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L','L');
	$arr2=array(55,45,45,45);
	$arr3=array("8.5 Mooring winches ",'No','# Drums','Brake Capacity(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORWINNO_1'],$rows['MOORDRUMS_1'],$rows['MOORBRAKECAP_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORWINNO_2'],$rows['MOORDRUMS_2'],$rows['MOORBRAKECAP_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORWINNO_3'],$rows['MOORDRUMS_3'],$rows['MOORBRAKECAP_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORWINNO_4'],$rows['MOORDRUMS_4'],$rows['MOORBRAKECAP_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L');
	$arr2=array(70,60,60);
	$arr3=array("8.6 Mooring bitts",'No','SWL(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORBITTNO_1'],$rows['MOORSWL_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORBITTNO_2'],$rows['MOORSWL_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORBITTNO_3'],$rows['MOORSWL_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORBITTNO_4'],$rows['MOORSWL_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',9);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(141,147,151);
	$arr1=array('L','L','L');
	$arr2=array(70,60,60);
	$arr3=array("8.7 Closed chocks and/or fairleads of enclosed type",'No','SWL(MT)');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Forecastle",$rows['MOORFAIRNO_1'],$rows['MOORFAIRSWL_1']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck fwd",$rows['MOORFAIRNO_2'],$rows['MOORFAIRSWL_2']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Main deck aft",$rows['MOORFAIRNO_3'],$rows['MOORFAIRSWL_3']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("        Poop deck",$rows['MOORFAIRNO_4'],$rows['MOORFAIRSWL_4']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Emergency Towing System",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("6.38 Type of cargo heating system?" ,'',$rows['TYPEODCARGOHEATING']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("8.8 Type / SWL of Emergency Towing system forward" ,$rows['ETSF_TYPE'],$rows['ETSF_SWL']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);

    $arr3=array("8.9 Type / SWL of Emergency Towing system aft" ,$rows['ETSA_TYPE_AFT'],$rows['ETSA_SWL_AFT']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Anchors",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.10 Number of shackles on port cable" ,'',$rows['SHACKLESCABLENO']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.11 Number of shackles on starboard cable" ,'',$rows['SHACKLESSCABLENO']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Escort Tug",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.12 What is SWL and size of closed chock and/or fairleads of enclosed type on stern" ,$rows['CLOSED_CHOCK_SWL']." MT",$rows['CLOSED_CHOCK_SIZE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.13 What is SWL of bollard on poopdeck suitable for escort tug" ,'',$rows['BOLLARDSWL']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Bow/Stern Thruster",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.14 What is brake horse power of bow thruster (if fitted)" ,$rows['CLOSED_CHOCK_SWL']." BHP",$rows['CLOSED_CHOCK_SIZE']." KW");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.15 What is brake horse power of stern thruster (if fitted)" ,$rows['HPSTERNTHRUSTER']." BHP",$rows['KWSTERNTHRUSTER']." KW");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Single Point Mooring (SPM) Equipment",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.16 Does vessel comply with the latest edition of OCIMF 'Recommendations for Equipment Employed in the Mooring of Vessels at Single Point Moorings (SPM)",'' ,$yesnoarray[$rows['RDOOCIMF']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.17 Is vessel fitted with chain stopper(s)" ,'',$yesnoarray[$rows['RDOCHAINSTOPPER']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("8.18 How many chain stopper(s) are fitted",'' ,$rows['CHAINSTOPPER']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.19 State type of chain stopper(s) fitted" ,'',$rows['CHAINSTOPPERTYPE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("8.20 Safe Working Load (SWL) of chain stopper(s)",'' ,$rows['LOADCHAINSTOPPER']." MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.21 What is the maximum size chain diameter the bow stopper(s) can handle" ,'',$rows['SIZECHAINSTOPPER']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("8.22 Distance between the bow fairlead and chain stopper/bracket",'' ,$rows['DISTANCECHAINSTOPPER']." MM");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.23 Is bow chock and/or fairlead of enclosed type of OCIMF recommended size (600mm x 450mm)? If not, give details of size" ,$yesnoarray[$rows['RDOOCIMFSIZE']],$rows['OCIMF_SIZE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Lifting Equipment",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.24 Derrick / Crane description (Number, SWL and location)",$rows['CCRANE_NUMBER'] ,$rows['CCRANE_SWL']." ".$rows['CCRANE_LOCATION']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("8.25 What is maximum outreach of cranes / derricks outboard of the ship's side" ,'',$rows['CCRANE_OUTREACH']." M");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Ship To Ship Transfer (STS)",0,1,'L');
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("8.26 Does vessel comply with recommendations contained in OCIMF/ICS Ship To Ship Transfer Guide (Petroleum or Liquified Gas, as applicable)",'' ,$yesnoarray[$rows['RDOOCIMFICS']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"9. MISCELLANEOUS",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Engine Room",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("9.1 What type of fuel is used for main propulsion?" ,'',$rows['PROPULTION_FUEL']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("9.2 What type of fuel is used in the generating plant?",'',$rows['PLANT_FUEL']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("9.3 Capacity of bunker tanks - IFO and MDO/MGO",$rows['IFO_CAPACITY']." M3",$rows['DO_CAPACITY']." M3");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("9.4 Is vessel fitted with fixed or controllable pitch propeller(s)?",'',($rows['PITCHTYPE']==1)?'Fixed Pitch':'Controllable Pitch');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Insurance",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("9.5 P & I Club - Full Style" ,'',$rows['P_I_CLUB']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("9.6 P & I Club coverage - pollution liability coverage(USD)",'',$rows['P_I_COVERAGE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Port State Control",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	if($rows['LAST_PORT_STATE_DATE'] == "0000-00-00" || $rows['LAST_PORT_STATE_DATE'] == ""){ $LAST_PORT_STATE_DATE = ""; }else{ $LAST_PORT_STATE_DATE = date('d-m-Y',strtotime($rows['LAST_PORT_STATE_DATE'])); }
	$arr3=array("9.7 Date and place of last Port State Control inspection" ,$LAST_PORT_STATE_DATE,$rows['LAST_PORT_STATE_PLACE']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("9.8 Any outstanding deficiencies as reported by any Port State Control",'',$yesnoarray[$rows['ISREPORTED']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("9.9 If yes, provide details",'',$rows['REPORTED_DETAILS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Recent Operational History",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	$arr3=array("9.10 Has vessel been involved in a pollution incident during the past 12 months? If yes, full description" ,'',$yesnoarray[$rows['RDOPOLUTION']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("     If yes, full description",'',$rows['POLUTION_DETAILS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("9.10 Has vessel been involved in a grounding incident during the past 12 months? If yes, full description" ,'',$yesnoarray[$rows['RDOGROUNDING']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("     If yes, full description",'',$rows['GROUNDING_DETAILS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("9.10 Has vessel been involved in a serious casualty incident during the past 12 months? If yes, full description" ,'',$yesnoarray[$rows['RDOCASUALTY']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("     If yes, full description",'',$rows['CASUALTY_DETAILS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Ln(1);
	$arr3=array("9.10 Has vessel been involved in a collision incident during the past 12 months? If yes, full description" ,'',$yesnoarray[$rows['RDOACCIDENT']]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr3=array("     If yes, full description",'',$rows['ACCIDENT_DETAILS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("9.11 Last three cargoes / charterers / voyages (Last / 2nd Last / 3rd Last)",'','Contact owner for details');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Vetting",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L');
	$arr2=array(100,45,45);
	if($rows['LAST_SIRE_DATE'] == "0000-00-00" || $rows['LAST_SIRE_DATE'] == ""){ $LAST_SIRE_DATE = ""; }else{ $LAST_SIRE_DATE = date('d-m-Y',strtotime($rows['LAST_SIRE_DATE'])); }
	$arr3=array("9.12 Date/Place of last SIRE Inspection" ,$LAST_SIRE_DATE,$obj->getPortNameBasedOnID($rows['SIRE_PORT']));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	if($rows['LAST_CDI_DATE'] == "0000-00-00" || $rows['LAST_CDI_DATE'] == ""){ $LAST_CDI_DATE = ""; }else{ $LAST_CDI_DATE = date('d-m-Y',strtotime($rows['LAST_CDI_DATE'])); }
	$arr3=array("9.13 Date/Place of last CDI Inspection" ,$LAST_CDI_DATE,$obj->getPortNameBasedOnID($rows['CDI_PORT']));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(1);
	$arr3=array("Recent Oil company inspections/screenings (To the best of owners knowledge and without guarantee of acceptance for future business)*",'','Contact owner for details');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$filename = strtoupper($obj->getVesselIMOData($_REQUEST['vesselid'],"VESSEL_NAME"))." TANKER CHARTERING QUESTIONNAIRE 88 (Q88) ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
	
}

function getBunkeringMasterPDF()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$port_type 						= $_REQUEST['port_type'];
	$randomno                       = $_REQUEST['randomno'];
	$sql 							= "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	
	$sql2 							= "select * from generate_agency_letter_slave2 where GEN_AGENCY_ID='".$g_agency_id."'";
	$res2 							= mysql_query($sql2);
	$rows2 							= mysql_fetch_assoc($res2);
	
	$vslid 							= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$_SESSION['vslName'] 			= $obj->getVesselIMOData($vslid,"VESSEL_NAME");
	$_SESSION['portname'] 			= $obj->getPortName($rows['PORTID']);
	$_SESSION['email'] 				= $rows['EMAIL_ADDRESS'];
	$_SESSION['vslconInfo'] 		= $rows['VSL_CONTACT_DETAILS'];
	$_SESSION['vslinfo'] 			= $rows['VSL_DETAILS'];
	$_SESSION['about'] 				= $rows['VSL_ABOUT'];
	$_SESSION['hsfoQty'] 			= $rows['BA_HSFO_QTY'];
	$_SESSION['supplier'] 			= $rows['BA_SUPPLIER_T_B_AD'];
	$_SESSION['necessary'] 			= $rows['BA_NECESSARY_GUID'];
	
	$_SESSION['bunkeringport'] 		= $obj->getPortNameBasedOnCode($rows2['BUNKERPORT']);
	
	
	$cost_sheet_id 					= $obj->getLatestCostSheetID($rows['COMID']);
							  		  $obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	$_SESSION['quantity'] 			= $rows['QTY'];
	$_SESSION['cargo_name']         = $obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($rows['COMID'],"MATERIALID")));
	$agent_code						= $_REQUEST['agent_code'];
	$_SESSION['agent_name']      	= $obj->getVendorListNewData($agent_code,"NAME");
	
	if(@$_REQUEST['port_type'] =="TP"){
		$qtyCargo					= "...........";
	}else{
		$qtyCargo 					= $_SESSION['quantity']." MT (".$_SESSION['cargo_name'].").WP WOG UCAE.";
	}
	
	$charterer_name 		= "";
	
	if($obj->getFun31()==1)
	{
		$charterer_name = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"QTY_VENDORID"));
	}
	else
	{
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$charterer_name = $charterer_name.", ".$obj->getVendorListNewBasedOnID($rows2['VENDORID']);
		}
	}

    $eta_fixture   = date('d-m-Y',strtotime($rows['ETA_DATE']));
	if($eta_fixture=="01-01-1970")
	{
		$eta_fixture="00:00";
	}
	else
	{
		$eta_fixture=date('d-m-Y H:i',strtotime($rows['ETA_DATE']));
	}

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Agency Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Agency Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(0,0,0);
	$pdf->Ln(2);
	$pdf->Cell(190,6,"Letter to Master ".$_SESSION['vslName']." for bunkering at ".$_SESSION['bunkeringport'].". Vessel ETA around ".$eta_fixture." LT",0,1,'C');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Ln(2);
	$pdf->Cell(190,5,"To : ",0,1,'L');
	
	$pdf->Cell(190,5,"".$_SESSION['vslName'],0,1,'L');
	
	$pdf->Ln(3);
	$pdf->Cell(190,5,"From : ",0,1,'L');
	$pdf->Cell(190,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,1,'L');
	$pdf->Ln(2);
	$pdf->Cell(190,5,"Agents : ".$_SESSION['agent_name'],0,1,'L');
	$pdf->Ln(2);
	$pdf->Cell(25,6,"Good day Sir,",0,1,'L');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("1)We have arranged bunkers to be delivered as follows:"));
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$arr1=array('L','L','L','L');
	$arr2=array(50,50,50,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array('FUEL GRADE/SPEC','SUPPLIER','PHYSICAL','QUANTITY(MT)'));
	
	$sql2 	= "select * from generate_agency_letter_slave2 where GEN_AGENCY_ID='".$g_agency_id."'";
	$res2 	= mysql_query($sql2);
	while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->Row(array($rows2['GRADE'],$rows2['SUPPLIER'],$rows2['PHYSICAL'],$rows2['QUANTITY']));
	}
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(2);
	$pdf->Row1(array("2)Agents will co-ordinate closely with you and the suppliers, in order to expedite final quantities and activity report with timings."));
	$pdf->Ln(2);
	$pdf->Row1(array("3) When bunkers are delivered from the barge, please ensure that Chief Engineer witnesses barge figures and barge samples. Soundings must be taken before and after the supply."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("4) Please ensure that a sample, in addition to that for Marpol, is drawn for vessel's use and is kept for further use if needed."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("5)Please note that in order to have the evidence to claim potential short supply from suppliers/bunker barge following measuring procedures must be followed:"));
	
	$pdf->Ln(1);
	$pdf->Row1(array("  a)The procedures are based on the supplier's terms and conditions and according to those terms bunker quantity shall be determined at supplier's option from the gauge or meter of shore or bunker barge tanks."));
	$pdf->Ln(1);
	$pdf->Row1(array("  b)The supplier's determination of quantity shall be final and conclusive, but the receiver shall have the right to attend the measure at shore or barge tanks."));
	$pdf->Ln(1);
	$pdf->Row1(array("  c)Any challenge by the receiver of the said measurement shall be admissible only if made to the supplier's representative and noted in the delivery receipt at the time of delivery."));
	$pdf->Ln(1);
	$pdf->Row1(array("  d)Basis above clauses it is beyond any doubt and common practice that the vessel in order to be able to challenge supplier's figures and put a notice on delivery receipt, should have exercised her right to witness the barge figures prior and after bunkering replenishment apart from usual checking of vessel's tanks. "));
	$pdf->Ln(1);
	$pdf->Row1(array("  e)Bunker supplier's back to back terms & conditions to apply."));
	
	
	
	$pdf->Ln(2);
	$pdf->Row1(array("Please confirm safe receipt of our message by return email."));
	
	
	$pdf->Ln(2);
	$pdf->Row1(array("Kind regards,"));
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME")));
	

$filename = "Letter to Master - Bunker Stemmed ( ".$_SESSION['vslName']." - ".$obj->getVendorListNewBasedOnID($rows['VENDORID'])." ) ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}




function port_performance_report()
{
	$obj = new data();
	$obj->funConnect();
	$selPort          	= $_REQUEST['selPort'];
	$selBType           = $_REQUEST['selBType'];
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Port Performance Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Port Performance Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(255,255,255); 
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(10,34,33,33,33,33,33,33,33);
	$arr3=array("Sr. No.","Port","Vessel Name","Nom Id","Quantity","Pre Berthing Delays (DAYS)","Cargo Working Time (DAYS)","Actual Load / Disg Rate (MT/DAYS)","Demmurage / Despatch Amt (USD)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$sql = "select * 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 in (1,2) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$j =1;
	if($rec == 0)
	{
		
	}
	else
	{	
		while($rows = mysql_fetch_assoc($res))
		{
			$quantity = 0;
			if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
			}
			else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
			}
			else
			{
				if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
				{
					$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
				}
				else
				{
					$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					$quantity = $row12['sum'];
				}
			}
			$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
            $obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			$arr       = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);
			for($i=0;$i<count($arr);$i++)
			{
				$arr_portval = explode('@@',$arr[$i]);
				if($selPort== $arr_portval[1])
				{
					$sql1 = "select * from sof_master where COMID='".$rows['COMID']."' and LOGIN='INTERNAL_USER' and MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."' and PORT='".$arr_portval[0]."' and PORTID='".$selPort."' and RANDOMID='".$arr_portval[2]."'";
					$res1 = mysql_query($sql1);
					$rec1 = mysql_num_rows($res1);
					if($rec1 > 0)
					{
						$rows1 = mysql_fetch_assoc($res1);
						
						if($rows1['NT_1'] != '' && $rows1['PBFB_1'] != '')
						{ 
							$start = strtotime($rows1['NT_1']); 
							$end   = strtotime($rows1['PBFB_1']);
							$days_pre_berthing = ($end - $start) / 86400;
						}
						else if($rows1['NT_1'] != '' && $rows1['LC'] != '')
						{ 
							$start = strtotime($rows1['NT_1']); 
							$end   = strtotime($rows1['LC']);
							$days_pre_berthing = ($end - $start) / 86400;
						}
						else
						{ 
							$start = 0; $end = 0;
							$days_pre_berthing = 0;
						} 
						
						
						$start = strtotime($rows1['LC']); 
						$end   = strtotime($rows1['LC1']);
						
						$days_cargo_wrk = ($end - $start) / 86400;
						
						$actual_rate = $quantity/$days_cargo_wrk;
						
						if($arr_portval[0] == "LP")
						{
							$sql1  = "select * from laytime_master where COMID='".$rows['COMID']."' and LOGIN='INTERNAL_USER' and PORT='LP' and PORTID='".$selPort."' and RANDOMID='".$arr_portval[2]."'";
							$res1  = mysql_query($sql1) or die($sql1);
							$rows1 = mysql_fetch_assoc($res1);
							
							if($rows1['TTL_DEMURRAGE'] == 0 && $rows1['TTL_DESPATCH'] == 0){$value = 0;}
							if($rows1['TTL_DEMURRAGE'] == 0){$value = "-".$rows1['TTL_DESPATCH'];}
							if($rows1['TTL_DESPATCH'] == 0){$value = $rows1['TTL_DEMURRAGE'];}
						}
						else
						{
							$sql1  = "select * from laytime_master where COMID='".$rows['COMID']."' and LOGIN='INTERNAL_USER' and PORT='DP' and PORTID='".$selPort."' and RANDOMID='".$arr_portval[2]."'";
							$res1  = mysql_query($sql1) or die($sql1);
							$rec1  = mysql_num_rows($res1);
							$rows1 = mysql_fetch_assoc($res1);
							
							if($rows1['TTL_DEMURRAGE'] == 0 && $rows1['TTL_DESPATCH'] == 0){$value = 0;}
							if($rows1['TTL_DEMURRAGE'] == 0){$value = "-".$rows1['TTL_DESPATCH'];}
							if($rows1['TTL_DESPATCH'] == 0){$value = $rows1['TTL_DEMURRAGE'];}
						}
						$pdf->SetFillColor(255,255,255);
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
		                $arr2=array(10,34,33,33,33,33,33,33,33);
						$net_effect = $totals/$obj->getFun50();
						$arr3=array($j,$obj->getPortNameBasedOnID($selPort),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getNumberFormat($quantity),$obj->getNumberFormat($days_pre_berthing),$obj->getNumberFormat($days_cargo_wrk),$obj->getNumberFormat($actual_rate),$obj->getNumberFormat($value));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						$j++;
				   }
				}
			}
		}
	}

	$filename = "Port Performance Report ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}


function inops_at_glance_check_listtc_pdf()
{
	$obj 		= new data();
	$comid 		= $_REQUEST['comid'];
	$id 		= $obj->getLatestCostSheetIDTC($comid);
    $obj->viewTCEstimationTempleteRecordsNew($id);
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('In Ops TC Checklist Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('In Ops TC Checklist Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/*********************************FIXTURE DETAILS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"FIXTURE DETAILS",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$sql1 = "select DEL_DATE_EST, DEL_HFO_MT_EST, DEL_MGO_MT_EST from chartering_tc_estimate_slave1 where TCOUTID=".$obj->getFun1()." order by TC_SLAVE1ID ASC";
	$result1 = mysql_query($sql1);
	$rowsdel = mysql_fetch_assoc($result1);
	$sql2 = "select REDEL_DATE_EST, REDEL_HFO_MT_EST, REDEL_MGO_MT_EST from chartering_tc_estimate_slave1 where TCOUTID=".$obj->getFun1()." order by TC_SLAVE1ID DESC";
	$result2 = mysql_query($sql2);
	$rowsredel = mysql_fetch_assoc($result2);
	
	$sql  		= "select * from check_list_tc where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
	$res  		= mysql_query($sql);
	$rows 		= mysql_fetch_assoc($res);
	$chartPni 	= $rows['CHARTERER_PNI'];
	
	$arr3=array("TC No.",":",$obj->getFun7(),"Vessel Name",":",$obj->getVesselIMOData($obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"CP DATE",":",date("d-M-Y",strtotime($obj->getFun9())));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);

	$arr3=array("CHARTERER",":",$obj->getVendorListNewBasedOnID($obj->getFun11(),"NAME"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	/*********************************VSL DETAILS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"VSL DETAILS",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$arr3=array("BUILT",":",$obj->getFun16(),"DEADWEIGHT",":",$obj->getFun30(),"DRAFT",":",$obj->getFun31());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($obj->getVesselIMOData($obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"),"BUSINESSTYPEID")==3){$tpc = $obj->getVesselParticularData('SUMMER_3','vessel_master_1',$obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"));}else{$tpc = $obj->getVesselParticularData('TPC_SUMMER','vessel_master_tankers',$obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"));}
	
	$arr3=array("GRT/NRT",":",$obj->getVesselParticularData('GRT_NRT','vessel_imo_master',$obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"))."/".$obj->getVesselParticularData('NRT','vessel_imo_master',$obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID")),"TPC",":",$tpc,"VESSEL PNI",":",$obj->getVendorOnlyNameBasedOnID($obj->getVesselIMOData($obj->getCharteringEstimateTCData($comid,"VESSEL_IMO_ID"),'P_I')));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/*********************************VESSEL CHECKS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"VESSEL CHECKS",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	if($rows['REG']=="1"){$style_1 = 'Yes';}else {$style_1 = 'No';}
	if($rows['CLASS']=="1"){$style_2 = 'Yes';} else {$style_2 = 'No';}
	if($rows['PNI']=="1"){$style_3 = 'Yes';} else {$style_3 = 'No';}
	
	$arr3=array("REG",":",$style_1,"CLASS",":",$style_2,"PNI",":",$style_3);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['ISM']=="1"){$style_4 = 'Yes';} else {$style_4 = 'No';}
	if($rows['DOC']=="1"){$style_5 = 'Yes';} else {$style_5 = 'No';}
	if($rows['ITC']=="1"){$style_6 = 'Yes';} else {$style_6 = 'No';}
	
	$arr3=array("ISM",":",$style_4,"DOC",":",$style_5,"ITC",":",$style_6);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['ISPS']=="1"){$style_7 = 'Yes';} else {$style_7 = 'No';}
	if($rows['LL']=="1"){$style_8 = 'Yes';} else {$style_8 = 'No';}
	if($rows['BQ']=="1"){$style_9 = 'Yes';} else {$style_9 = 'No';}
	
	$arr3=array("ISPS",":",$style_7,"LL",":",$style_8,"BQ",":",$style_9);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['H_M']=="1"){$style_10 = 'Yes';} else {$style_10 = 'No';}
	if($rows['SEA_WEB']=="1"){$style_11 = 'Yes';} else {$style_11 = 'No';}
	if($rows['CARGODECL_MASTER']=="1"){$style_12 = 'Yes';} else {$style_12 = 'No';}
	
	$arr3=array("H&M",":",$style_10,"SEA-WEB",":",$style_11,"CARGO DECL. SIGN MASTER",":",$style_12);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['REQDOCSSENTTOINS']=="1"){$style_13 = 'Yes';} else {$style_13 = 'No';}

	$arr3=array("REQUIRED DOCS SENT TO INSURANCE DESK",":",$style_13,"CHARTERERS PNI",":",$obj->updatecheckListChartererPniByVendorListNewForCOATe($chartPni),"LAST PORT AGENT",":",$rows['LASTPORTAGENT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/*********************************DELIVERY DATA*****************************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"DELIVERY",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$arr3=array("LAYCAN FROM",":",date("d-m-Y", strtotime($rows['LAYCAN_FROM'])),"LAYCAN TO",":",date("d-m-Y", strtotime($rows['LAYCAN_TO'])),"DRAFT RESTRICTIONS AS PER CP",":",$rows['DRFTRESASPERCP']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("LOAD RATE - CP",":",$rows['LOAD_RATE_CP'],"DISCHARGE RATE - CP",":",$rows['DIS_RATE_CP']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"ETA NOTICES",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$sql1  = mysql_query("select * from check_list_tc_s1 where CHKLISTTC_ID='".$rows['CHKLISTTC_ID']."' and STATUS=1 ");
	while($rows1 = mysql_fetch_assoc($sql1))
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','L','L','L','L');
		$arr2=array(50,50,42,40,45);
						
		$arr3=array("",$rows1['ETA_NOTICES_TEXT'],":",$rows1['ETA_NOTICES_DATA']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}

	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"ARRIVAL",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L','L','L');
	$arr2=array(50,50,42,40,45);
	
	$arr3=array("",$rows['DEL_ARRI_TEXT'],":",date("d-m-Y H:i", strtotime($rows['DEL_ARRI_DATA'])));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['DEL_NORTEN_TEXT'],":",date("d-m-Y H:i", strtotime($rows['DEL_NORTEN_DATA'])));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['DEL_PORT_TEXT'],":",$rows['DEL_PORT_DATA']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['DEL_FO_DO_TEXT'],":",$rowsdel['DEL_HFO_MT_EST'].'/'.$rowsdel['DEL_MGO_MT_EST']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rowsdel['DEL_DATE_EST']=="" || $rowsdel['DEL_DATE_EST']=="0000-00-00 00:00:00"  || $rowsdel['DEL_DATE_EST']=="1970-01-01 08:00:00"){$txtDeliveryDate = "";}else{$txtDeliveryDate = date('d-m-Y H:i',strtotime($rowsdel['DEL_DATE_EST']));}
	
	$arr3=array("",$rows['DEL_DATETIM_TXT'],":",$txtDeliveryDate);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/*********************************RE-DELIVERY DATA*****************************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"RE-DELIVERY",0,1,'L');
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"ETA NOTICES",0,1,'L');
	
	$sql2  = mysql_query("select * from check_list_tc_s1 where CHKLISTTC_ID='".$rows['CHKLISTTC_ID']."' and STATUS=2 ");
	while($rows2 = mysql_fetch_assoc($sql2))
	{
		$arr1 = $arr2 = $arr3 = array();
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','L','L','L','L');
		$arr2=array(50,50,42,40,45);
						
		$arr3=array("",$rows2['ETA_NOTICES_TEXT'],":",$rows2['ETA_NOTICES_DATA']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"ARRIVAL",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L','L','L');
	$arr2=array(50,50,42,40,45);
	
	$arr3=array("",$rows['RDEL_ARRI_TEXT'],":",date("d-m-Y H:i", strtotime($rows['RDEL_ARRI_DATA'])));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['RDEL_NORTEN_TEXT'],":",date("d-m-Y H:i", strtotime($rows['RDEL_NORTEN_DATE'])));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['RDEL_PORT_TEXT'],":",$rows['RDEL_PORT_DATA']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("",$rows['RDEL_FO_DO_TEXT'],":",$rowsredel['REDEL_HFO_MT_EST'].'/'.$rowsredel['REDEL_MGO_MT_EST']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rowsredel['REDEL_DATE_EST']=="" || $rowsredel['REDEL_DATE_EST']=="0000-00-00 00:00:00"  || $rowsredel['REDEL_DATE_EST']=="1970-01-01 08:00:00"){$txtReDeliveryDate = "";}else{$txtReDeliveryDate = date('d-m-Y H:i',strtotime($rowsredel['REDEL_DATE_EST']));}
	
	$arr3=array("",$rows['RDEL_DATETIM_TXT'],":",$txtReDeliveryDate);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"REMARKS",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L','L','L');
	$arr2=array(50,50,42,50,15);
	
	$arr3=array("","REMARKS",":",$rows['REMARKS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
		
	$filename = "Check List Report TC ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}





function reqtc_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$comid = $_REQUEST['comid'];
	$req_id = $_REQUEST['req_id'];
	$name = $_REQUEST['name'];
	$vendorid = $_REQUEST['vendorid'];
	$randomid = $_REQUEST['randomid'];
	$ttl = $_REQUEST['ttl_outs'];
    $id = $obj->getLatestCostSheetIDTC($comid);
    $obj->viewTCEstimationTempleteRecordsNew($id);
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$sql = "select * from request_mastertc where REQ_ID='".$req_id."'";
$res = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{
	if($rows['NAME_ID'] == 1)
	{
		$costtype = 'Brokerage Commission';
	}
	else if($rows['NAME_ID'] == 1)
	{
		$costtype = $obj->getOwnerRelatedCostNameBasedOnID($rows['GRADEID']);
	}
	else if($rows['NAME_ID'] == 3)
	{
		$costtype = "Port Costs (".$obj->getPortNameBasedOnID($rows['GRADEID']).")";
	}

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Account ".$name,0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(25,5,32,29,5,31,33,5,35);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Payment Type",":",$rows['ACCOUNT_TYPE'],"Payment No/Description",":",$rows['PAYMENT_NO'],"CP Date",":",date("d-M-Y",strtotime($rows['CP_DATE']))));

$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($rows['DATE'])),"Nom ID",":",$obj->getCompareTableData($comid,"MESSAGE"),"Vessel",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")));


$pdf->Row1(array("Vendor",":",$obj->getVendorListNewBasedOnID($vendorid),"Remarks",":",$rows['REMARKS']));

if(date("d-M-Y",strtotime($rows['INVOICE_DATE'])) == '01-Jan-1970'){$I_Date = '';}
else{$I_Date = date("d-M-Y",strtotime($rows['INVOICE_DATE']));}
$costtype = explode(" : ",$name);
$pdf->Row1(array("Cost Type Desc.",":",$costtype[1], "Vendor Invoice Amt.",":",$obj->getNumberFormat($rows['INVOICE_AMT']),"Invoice Date",":",$I_Date));

		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$name.": Details",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Total Payable",":",$obj->getNumberFormat($ttl)));
		
		$sql6 = "select * from request_mastertc where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$rows['NAME']."' and NAME_ID='".$rows['NAME_ID']."' and GRADEID='".$rows['GRADEID']."' and VENDOR='".$vendorid."' and RANDOMID='".$randomid."'";
		$res6 = mysql_query($sql6);
		$i = 0;
		$cost = 0; $cost_deduction = 0;
		while($rows6 = mysql_fetch_assoc($res6))
		{
			$i = $i+1; $cost_deduction_1 = 0;
			$cost = $cost+$rows6['REQ_TO_PAY'];
			
			$sql7 = "select * from request_deductiontc_master where REQ_ID='".$rows6['REQ_ID']."'";
			$res7 = mysql_query($sql7);
			while($rows7 = mysql_fetch_assoc($res7)){$cost_deduction = $cost_deduction+$rows7['COST']; $cost_deduction_1 = $cost_deduction_1+$rows7['COST'];}
			
			if($rows6['REQ_ID'] == $req_id){break;}
			$pdf->Row1(array("Amount Paid ".$i,":",$obj->getNumberFormat($rows6['REQ_TO_PAY'])));
		}
		
		$cost = $ttl-$cost;
		
		$cost = $cost-$cost_deduction;
		
		$pdf->Row1(array("Balance Outstanding",":",$obj->getNumberFormat($cost)));
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Add",0,1,'L');
		
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_mastertc_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='ADD' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Less",0,1,'L');
		
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_mastertc_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='SUB' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Net Payable ",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['NET_AMT'])));
		
		
		
		$pdf->Ln(5);
		$pdf->SetFont('Arial','B',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Requested To Pay/Recover",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['REQ_TO_PAY'])));
		
		$pdf->Ln(5);
		$sql2 = "select * from request_mastertc where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$costtype[0]."' and NAME_ID='".$_REQUEST['name_id']."' and GRADEID='".$_REQUEST['grade']."' and VENDOR='".$_REQUEST['vendorid']."' and RANDOMID='".$randomid."' and STATUS='1' and REQ_ID<'".$rows6['REQ_ID']."'";
		$res2 = mysql_query($sql2);
		$rec2 = mysql_num_rows($res2);
		if($rec2>0)
		{
			$pdf->SetFont('Arial','B',10);
		    $pdf->SetTextColor(27,119,166);
			$arr1=array('C','C','C','C','C','C');
			$arr2=array(20,51,51,51,51,51);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array("S.No.","Cost Type","Cost Desc.","Vendor","Payment No.","Requested To Pay"));
			$i = 0;
			while($rows2 = mysql_fetch_assoc($res2))
			{$i++;
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('C','L','L','L','L','R');
			$arr2=array(20,51,51,51,51,51);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row(array($i,$costtype[0],$costtype[1],$obj->getVendorListNewBasedOnID($rows2['VENDOR']),$rows2['PAYMENT_NO'],$rows2['REQ_TO_PAY']));
			}
		}
}

$filename = "Payment ".$paymentno.".pdf";

$pdf->Output($filename,'D');
}


function hire_tcinvoice_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$invoiceid = $_REQUEST['invoiceid'];
	$comid = $_REQUEST['comid'];
	$_SESSION['invoiceid'] = $invoiceid;


$sheetid = $obj->getLatestCostSheetIDTC($comid);
$obj->viewTCEstimationTempleteRecordsNew($sheetid);
$arr  = $obj->getTCLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($sheetid);
$vendorid = $obj->getFun103();
$lp_name = array(); 
$dp_name = array();
for($j=0;$j<count($arr);$j++)
{   
    $arr_explode = explode('-',$arr[$j]);
	if($arr_explode[0] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
	elseif($arr_explode[0] == "DP"){$dp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
}
$lp_name  = implode(', ',$lp_name);
$dp_name  = implode(', ',$dp_name);

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];


$sql = "SELECT * from invoice_tchire_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and INVOICEID='".$invoiceid."'";
$res 	= mysql_query($sql);
$rows 	= mysql_fetch_assoc($res); 
$_SESSION['invoice_date'] = date("d-m-Y",strtotime($rows['INVOICE_DATE']));
class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
if($obj->getFun69()=='0000-00-00 00:00:00' || $obj->getFun69()==''){$deldate = '';}else{$deldate = date('d-m-Y H:i',strtotime($obj->getFun69()));}
if($obj->getFun71()=='0000-00-00 00:00:00' || $obj->getFun71()==''){$redeldate = '';}else{$redeldate = date('d-m-Y H:i',strtotime($obj->getFun71()));}
$arr3=array("DLY","FROM",$deldate,$redeldate);

$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Hire Invoice Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Hire Invoice Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetTextColor(27,119,166);
$pdf->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
$pdf->SetFont('daxcondensedlight','',10);
$pdf->Cell(140,5,"OWNER: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,0,'L','0');
$pdf->Cell(50,5,"DATE: ".date('d-m-Y',strtotime($rows['INVOICE_DATE'])),0,1,'R','0');
$pdf->Ln(4);
$pdf->SetTextColor(27,119,166);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->Cell(192,5,$rows['INVOICE_NO'],1,1,'C','0');
$pdf->Ln(0);


$pdf->SetY(50);

$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L');
$arr2=array(100,90);
$arr3=array("VESSEL:  ".$obj->getVesselIMOData($obj->getFun2(),"VESSEL_NAME")." (IMO No. ".$obj->getVesselIMOData($obj->getFun2(),"IMO_NO").")","CP Date:   ".date("d-m-Y",strtotime($obj->getFun16())));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L');
$arr2=array(100,90);
$arr3=array("Charterers: ".$obj->getVendorListNewBasedOnID($vendorid),'DEL AT: '.$obj->getPortNameBasedOnID($obj->getFun70())."   REDEL AT: ".$obj->getPortNameBasedOnID($obj->getFun71()));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);


$sql4 = "select * from invoice_tchire_slave3 where INVOICEID='".$rows['INVOICEID']."' ";
$result4= mysql_query($sql4);
$num41 = mysql_num_rows($result4);


$pdf->Ln(0);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->Cell(192,25 + $num41*5,"",1,1,'C','0');
$pdf->SetY(60);

$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L','R','R');
$arr2=array(60,12,26,37,57);
if($obj->getFun69()=='0000-00-00 00:00:00' || $obj->getFun69()==''){$deldate = '';}else{$deldate = date('d-m-Y H:i',strtotime($obj->getFun69()));}
if($obj->getFun71()=='0000-00-00 00:00:00' || $obj->getFun71()==''){$redeldate = '';}else{$redeldate = date('d-m-Y H:i',strtotime($obj->getFun71()));}
$arr3=array("DEL","",$deldate,'REDEL',$redeldate);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$j = 0;
$sum = 0;
while($row4 = mysql_fetch_assoc($result4))
{$j = $j + 1;
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','L','L','L','R');
	$arr2=array(60,12,30,8,40,42);
	$arr3=array("OFF HIRE","FROM",date('d-m-Y H:i',strtotime($row4['FROM_OFF_DATE'])),"TO",date('d-m-Y H:i',strtotime($row4['TO_OFF_DATE'])),number_format($row4['OFFHIRE_DAYS'],5,'.',''));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$sum = $sum + number_format($row4['OFFHIRE_DAYS'],5,'.','');
}
if($sum >0)
{	  
	$j = $j + 1;
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','L','L','L','R');
	$arr2=array(60,12,30,24,24,42);
	$arr3=array("LESS OFF HIRE PERIOD","","","","DAYS", number_format($sum,5,'.',''));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
}

$j = $j + 1;
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','C');
$arr1=array('L','L','L','L','L','R');
$arr2=array(60,12,30,24,24,42);
$arr3=array("TOTAL TRIP DURATION","","","","DAYS", number_format($obj->getFun100(),5,'.',''));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$j = $j + 1;
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','C');
$arr1=array('L','L','L','L','L','R');
$arr2=array(60,12,30,24,24,42);
$arr3=array("NET RELEASE HIRE DAYS","","","","DAYS", number_format($rows['RELEASE_HIRE_DAYS'],5,'.',''));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$pdf->SetY(65);
for($i = 1;$i<=$j;$i++)
{
	$pdf->SetX(146);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Cell(56,5,'',1,1,'R','0');
}

$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','C');
$arr2=array(60,60,20);
$arr3=array("DAILY HIRE RATE","$ ".number_format($rows['TC_COST'],2,'.',''),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);



$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L');
$arr2=array(136,56);
$arr3=array("AMOUNT DUE TO OWNERS:  ","AMOUNT IN USD");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row($arr3);

$getYheight = $pdf->GetY();
$val  = 0;
$sql_inv2 = "select * from invoice_tchire_slave2 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='DEL' and BUNKER_QTY>0"; 
$res_inv2 = mysql_query($sql_inv2) or die($sql_inv2);
$num_inv2 = mysql_num_rows($res_inv2);	 	

$sql44 = "select * from invoice_tchire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD' ";
$res44 = mysql_query($sql44);
$num44 = mysql_num_rows($res44);

$pdf->Ln(0);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);

$sum1 = 0;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','C','L','L','R','L','L','R',"L");
$arr2=array(40,44,21,4,15,12,4,21,29);
$arr3=array("1. NET HIRE",number_format($rows['RELEASE_HIRE_DAYS'],5,'.','')."  DAYS","*", "$",number_format($rows['TC_COST'],2,'.',','),"","$",number_format($rows['NETT_HIRE'],2,'.',','),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);
$sum1 = $sum1 + $rows['NETT_HIRE'];
$ro = 0;
if($rows['IS_BALLASTBONUS']==1)
{
	$ro++;
	$pdf->Ln(1);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','L','L','L','R','L');
	$arr2=array(50,30,25,31,4,21,29);
	$arr3=array($ro.". BALLAST BONUS","","","","$",number_format($rows['BALLASTBONUSAMT'],2,'.',','),"");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$pdf->Ln(1);
	$sum1 = $sum1 + $rows['BALLAST_BONUS'];
}

if($rows['IS_ILOHC']==1)
{
	$ro++;
	$pdf->Ln(1);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','L','L','L','R','L');
	$arr2=array(50,30,25,31,4,21,29);
	$arr3=array($ro.". ILOHC","","","","$",number_format($rows['ILOHCAMT'],2,'.',','),"");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$pdf->Ln(1);
	$sum1 = $sum1 + $rows['ILOHCAMT'];
}
if($rows['IS_CVE']==1)
{
	$ro++;
	$pdf->Ln(1);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','L','L','L','R','L');
	$arr2=array(50,30,25,31,4,21,29);
	$arr3=array($ro.". CVE","","","","$",number_format($rows['CVEAMT'],2,'.',','),"");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$pdf->Ln(1);
	$sum1 = $sum1 + $rows['CVEAMT'];
}

$sql_inv2 = "select * from invoice_tchire_slave2 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='DEL'"; 
$res_inv2 = mysql_query($sql_inv2);
$num_res2 = mysql_num_rows($res_inv2);
if($num_res2>0)
{
	$ro++;
	$pdf->Cell(278,5,$ro.". COST OF BUNKER ON DELIVERY",0,1,'L','0');
	while($rows_inv2 = mysql_fetch_assoc($res_inv2))
	{ 	
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(0,0,0);
		$arr1 = $arr2 = $arr3 = array();	
		$arr1=array('C','L','R','C','L','R','L','L','R','L');
		$arr2=array(25,20,20,40,4,15,12,4,21,29);
		$arr3=array($obj->getBunkerGradeBasedOnID($rows_inv2['BUNKERID']),"MT",number_format($rows_inv2['BUNKER_QTY'],3,'.',','),"*","$",number_format($rows_inv2['BUNKER_PRICE'],2,'.',',')," PMT","$",number_format($rows_inv2['BUNKER_AMT'],2,'.',','),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
		$sum1 = $sum1 + $rows_inv2['BUNKER_PER_AMT'];
	}
}


$sql44 = "select * from invoice_tchire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD' ";
$res44 = mysql_query($sql44);
$num44 = mysql_num_rows($res44);
while($rows44 = mysql_fetch_assoc($res44))
{
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','R','L');
	$arr2=array(136,4,21,29);
	$arr3=array($rows44['DESCRIPTION'],"$",number_format($rows44['AMOUNT'],2,'.',','),"");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$sum1 = $sum1 + $rows44['AMOUNT'];
}

$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L','L','L','R','L');
$arr2=array(50,30,25,31,4,21,29);
$arr3=array("","","  ","TOTAL","$",number_format($sum1,2,'.',','),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$getYheight1 = $pdf->GetY();
$pdf->SetY($getYheight);
$pdf->Cell(192,($getYheight1-$getYheight),"",1,1,'C','0');

$pdf->SetY($getYheight);
$pdf->SetX(146);
$pdf->Cell(56,($getYheight1-$getYheight),"",1,1,'C','0');




//$pdf->SetY($height);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L');
$arr2=array(136,56);
$arr3=array("LESS","");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row($arr3);

$getYheight = $pdf->GetY() ;
$val  = 0;

$pdf->Ln(0);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);


$sum2 = 0;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L','L','L','R','L');
$arr2=array(50,30,25,31,4,21,29);
$arr3=array("1. COMISSIONS","",$rows['COMISSION_PER']." PCT", "","$",number_format($rows['COMISSION_PER_AMT'],2,'.',','),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);
$sum2 = $sum2 + $rows['COMISSION_PER_AMT'];
$pdf->Ln(2);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L','L','L','R','L');
$arr2=array(50,30,25,31,4,21,29);
$arr3=array("2. BROKERAGE","","","","$",number_format($rows['BROKERAGE_PER_AMT'],2,'.',','),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);
$sum2 = $sum2 + $rows['BROKERAGE_PER_AMT'];

$sql_inv2 = "select * from invoice_tchire_slave2 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='REDEL'"; 
$res_inv2 = mysql_query($sql_inv2);
$num_res2 = mysql_num_rows($res_inv2);
if($num_res2>0)
{
	$ro++;
	$pdf->Cell(278,5,$ro.". COST OF BUNKER ON DELIVERY",0,1,'L','0');
	while($rows_inv2 = mysql_fetch_assoc($res_inv2))
	{ 	
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(0,0,0);
		$arr1 = $arr2 = $arr3 = array();	
		$arr1=array('C','L','R','C','L','R','L','L','R','L');
		$arr2=array(25,20,20,40,4,15,12,4,21,29);
		$arr3=array($obj->getBunkerGradeBasedOnID($rows_inv2['BUNKERID']),"MT",number_format($rows_inv2['BUNKER_QTY'],3,'.',','),"*","$",number_format($rows_inv2['BUNKER_PRICE'],2,'.',',')," PMT","$",number_format($rows_inv2['BUNKER_AMT'],2,'.',','),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
		$sum2 = $sum2 + $rows_inv2['BUNKER_PER_AMT'];
	}
}

$pdf->Ln(2);
$sql44 = "select * from invoice_tchire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB' ";
$res44 = mysql_query($sql44);
$num44 = mysql_num_rows($res44);
while($rows44 = mysql_fetch_assoc($res44))
{
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L','L','R','L');
	$arr2=array(136,4,21,29);
	$arr3=array($rows44['DESCRIPTION'],"$",number_format($rows44['AMOUNT'],2,'.',','),"");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$sum2 = $sum2 + $rows44['AMOUNT'];
}

$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','L','L','L','R','L');
$arr2=array(50,30,25,31,4,21,29);
$arr3=array("","","  ","TOTAL","$",number_format($sum2,2,'.',','),"");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);


$getYheight1 = $pdf->GetY();
$pdf->SetY($getYheight);
$pdf->Cell(192,($getYheight1-$getYheight),"",1,1,'C','0');

$pdf->SetY($getYheight);
$pdf->SetX(146);
$pdf->Cell(56,($getYheight1-$getYheight),"",1,1,'C','0');



$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L','R','L');
$arr2=array(136,4,21,29);
$arr3=array("BALANCE DUE TO OWNER", "$",number_format(($sum1 - $sum2),2,'.',',')."");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);

$height = $pdf->getY();
$pdf->SetY($height-5);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L');
$arr2=array(136,56);
$arr3=array("","");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row($arr3);

$pdf->SetTextColor(0,0,0);
$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L','L');
$arr2=array(56,136);
$arr3=array("BANKING DETAILS",$rows['BANKINGDATAILS']);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row($arr3);

$filename = "Hire Invoice ".$rows['INVOICE_NO'].".pdf";

$pdf->Output($filename,'D');
}








function getDecisionChartTCList()
{	
	$obj 			= new data();
    $val   =  $_REQUEST['val'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Decision Chart List Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Decision Chart List Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Decision Chart List",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(7,20,20,20,20,20,30,20,20,20,20,20,20,20,10);
	$arr3=array("S.No.","Vessel Name","Vessel Type","TC No.","CP Date","DWT","Del Port","Re Del Port","TC Days","Daily Gross Hire(USD)" ,"Total Rev(USD)", "Status","Remarks","Select");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	$val   =  $_REQUEST['val'];
	$val2   =  $_REQUEST['val2'];
	if(strlen($val2) ==1){$val2 = "00".$val2;}
	if(strlen($val2) ==2){$val2 = "0".$val2;}
	if(strlen($val2) >2){$val2 = $val2;}
	$sql1 = "select * from chartering_estimate_tc_compare WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and MESSAGE ='".$val."-".$val2."' ";
	$res1 = mysql_query($sql1) or die();
	$arr = array();
	while($row1 = mysql_fetch_assoc($res1))
	{
		$arr[] = $row1['TCOUTID'];
	}
	$arr1 = implode(',',$arr);
	
	
	$sql = "SELECT TCOUTID, chartering_estimate_tc_master.VESSEL_TYPE, chartering_estimate_tc_master.FIXED, vessel_imo_master.VESSEL_NAME, (select SUM(TC_DAYS_EST) as SUM from chartering_tc_estimate_slave1 where chartering_tc_estimate_slave1.TCOUTID= chartering_estimate_tc_master.TCOUTID) as TC_DAYS_EST, (select SUM(TOTAL_REV_EST) as SUM from chartering_tc_estimate_slave1 where chartering_tc_estimate_slave1.TCOUTID= chartering_estimate_tc_master.TCOUTID) as TOTAL_REV_EST, vessel_imo_master.VESSEL_IMO_ID, TC_NO, SEL_CP_TYPE, CP_DATE1, FUEL_SPECS, MASTERS_NAME, DWT_SUMMER_CP, DEL_RANGE_PORT, RE_DEL_RANGE, HIRE_FIX_PER FROM chartering_estimate_tc_master inner JOIN vessel_imo_master ON vessel_imo_master.VESSEL_IMO_ID=chartering_estimate_tc_master.VESSEL_IMO_ID WHERE MODULEID='".$_SESSION['moduleid']."' AND vessel_imo_master.MCOMPANYID='".$_SESSION['company']."' and TCOUTID in (".$arr1.") order by TCOUTID desc";
	$res = mysql_query($sql) or die($sql);
	$rec = mysql_num_rows($res);
	$i = 1;
	while($rows = mysql_fetch_assoc($res))
	{
		$sql2 = "select * from chartering_estimate_tc_compare WHERE MESSAGE ='".$val."-".$val2."' and TCOUTID='".$rows['TCOUTID']."' ";
		$res2 = mysql_query($sql2);
		$row2 = mysql_fetch_assoc($res2);
		if($rows['FIXED']==1){$fixed = "Finalised";}else{$fixed = "Not Fixed";}
		if($row2['TCOUTID']==$row2['FINAL_ID']){$checked = "Yes";}else{$checked = "";}
		
		if($rows['CP_DATE1']=="" || $rows['CP_DATE1']=="1970-01-01"){$CP_DATE1 = "";}else{$CP_DATE1 = date('d-m-Y',strtotime($rows['CP_DATE1']));}
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	    $arr2=array(7,20,20,20,20,20,30,20,20,20,20,20,20,20,10);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($i,$rows['VESSEL_NAME'],$rows['VESSEL_TYPE'],$rows['TC_NO'],$CP_DATE1,$rows['DWT_SUMMER_CP'],$rows['DEL_RANGE_PORT'],$rows['RE_DEL_RANGE'],$rows['TC_DAYS_EST'],$rows['HIRE_FIX_PER'],$rows['TOTAL_REV_EST'],$fixed,$row2['REMARKS'],$checked);
		
		$pdf->Row2($arr3);
		$i++;
	}	
	
	
	$filename = "Decision_Chart.pdf";

	$pdf->Output($filename,'D');
}



function getTCDecisionChart()
{	
	$obj 			= new data();
    class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Decision Chart List Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Decision Chart List Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Decision Chart List",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(25,35,35,30,35,45,35,35);
	$arr3=array("S.No.","Decision Chart","Chart No.","TC No.","Vessel","Del Port/Redel Port","Add On Date","Added By");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql = "select * from chartering_estimate_tc_compare WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and FINAL_ID!=''";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	
	$j =0;
	while($rows = mysql_fetch_assoc($res))
	{$j =$j +1;
		
		$sql1 = "SELECT TCOUTID, (select VESSEL_NAME from vessel_imo_master where vessel_imo_master.VESSEL_IMO_ID=chartering_estimate_tc_master.VESSEL_IMO_ID) as VESSEL_NAME, TC_NO, DEL_RANGE_PORT, RE_DEL_RANGE FROM chartering_estimate_tc_master WHERE TCOUTID= ".$rows['FINAL_ID'];
		$res1 = mysql_query($sql1) or die($sql1);
		$rows1 = mysql_fetch_assoc($res1);
		
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L');
	    $arr2=array(25,35,35,30,35,45,35,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($j,$rows['MESSAGE'],$rows['MESSAGE_NO'],$rows1['TC_NO'],$rows1['VESSEL_NAME'],$rows1['DEL_RANGE_PORT'].'/'.$rows1['RE_DEL_RANGE'],date('d-m-Y',strtotime($rows['ADD_ON_DATE'])),$obj->getUserDetailBaseOnId($rows['USERID'],'CONTACT_PERSON'));
		
		$pdf->Row2($arr3);
	}
	
	$filename = "Decision_Chart.pdf";

	$pdf->Output($filename,'D');
}

function getVesselComparePDF()
{	
	$obj 			= new data();
    $chkArr1   =  explode(',',$_REQUEST['chkValue']);
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Vessel Comparison Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Vessel Comparison Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(275,6,"Vessel Comparison",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	
	$width = 240/count($chkArr1);
	
	//echo $width;die;
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',8);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Vessel Name/Commercial Parameters";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselIMOData($chkArr1[$i],"VESSEL_NAME");
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Vessel Type";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselTypeBasedOnID($obj->getVesselIMOData($chkArr1[$i],"VESSEL_TYPE"));
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="DWT (Summer)";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselIMOData($chkArr1[$i],"DWT");
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Draft (Summer)";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselIMOData($chkArr1[$i],"DRAFTM");
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="TPC";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselParticularData('SUMMER_3','vessel_master_1',$chkArr1[$i]);
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetFont('Arial','',7);
	$pdf->Cell(275,6,"SPEED DATA",1,1,'C');
	
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Ballast Speed - Full Speed (Knots)";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselParameterData($chkArr1[$i],"B_FULL_SPEED",$user);
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Ballast Speed - Service Speed (Knots)";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselParameterData($chkArr1[$i],"B_ECO_SPEED1",$user);
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] ="Ballast Speed - Most Eco Speed (Knots)";
	for($i=0;$i<count($chkArr1);$i++)
	{
		$arr1[$i+1] = 'C';
		$arr2[$i+1] = $width;
		$arr3[$i+1] = $obj->getVesselParameterData($chkArr1[$i],"B_ECO_SPEED2",$user);
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',8);
	$pdf->Cell(275,6,"FO Consp/day(MT) - At Sea",1,1,'C');
	
	$arr_level = array('SECA (Ballast) - Full Speed', 'SECA (Laden) - Full Speed', 'NON-SECA (Ballast) - Full Speed', 'NON-SECA (Laden) - Full Speed', 'SECA (Ballast) - Service Speed', 'SECA (Laden) - Service Speed', 'NON-SECA (Ballast) - Service Speed', 'NON-SECA (Laden) - Service Speed', 'SECA (Ballast) - Most Eco Speed', 'SECA (Laden) - Most Eco Speed', 'NON-SECA (Ballast) - Most Eco Speed', 'NON-SECA (Laden) - Most Eco Speed');
	$arr_fields = array('FO_BALAST_ATSEA_SECA_CONSP_FS', 'FO_LADEN_ATSEA_SECA_CONSP_FS', 'FO_BALAST_ATSEA_NONSECA_CONSP_FS', 'FO_LADEN_ATSEA_NONSECA_CONSP_FS', 'FO_BALAST_ATSEA_SECA_CONSP_SS', 'FO_LADEN_ATSEA_SECA_CONSP_SS', 'FO_BALAST_ATSEA_NONSECA_CONSP_SS', 'FO_LADEN_ATSEA_NONSECA_CONSP_SS', 'FO_BALAST_ATSEA_SECA_CONSP_MES', 'FO_LADEN_ATSEA_SECA_CONSP_MES', 'FO_BALAST_ATSEA_NONSECA_CONSP_MES', 'FO_LADEN_ATSEA_NONSECA_CONSP_MES');
	
	for($j=0;$j<count($arr_level);$j++)
	{
	    $pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] =$arr_level[$j];
		
		for($i=0;$i<count($chkArr1);$i++)
		{
		    $sql = "select ".$arr_fields[$j].", BUNKERID from vessel_commercial_parameters_slave1 where IDENTIFY='FO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($chkArr1[$i],"COMMERCIAL_PARAMETERID");
		    $result = mysql_query($sql);
		    $bunker_consp = array();
			while($rows = mysql_fetch_assoc($result))
			{
			    $bunker_consp[] = $obj->getBunkerGradeBasedOnID($rows['BUNKERID']).' - '.$rows[$arr_fields[$j]];
			}
			
			$arr1[$i+1] = 'C';
			$arr2[$i+1] = $width;
			$arr3[$i+1] = implode(', ',$bunker_consp);
		}
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	$pdf->SetFont('Arial','',8);
	$pdf->Cell(275,6,"DO Consp/day(MT) - At Sea",1,1,'C');
	
	$arr_level = array('SECA (Ballast) - Full Speed', 'SECA (Laden) - Full Speed', 'NON-SECA (Ballast) - Full Speed', 'NON-SECA (Laden) - Full Speed', 'SECA (Ballast) - Service Speed', 'SECA (Laden) - Service Speed', 'NON-SECA (Ballast) - Service Speed', 'NON-SECA (Laden) - Service Speed', 'SECA (Ballast) - Most Eco Speed', 'SECA (Laden) - Most Eco Speed', 'NON-SECA (Ballast) - Most Eco Speed', 'NON-SECA (Laden) - Most Eco Speed');
	$arr_fields = array('FO_BALAST_ATSEA_SECA_CONSP_FS', 'FO_LADEN_ATSEA_SECA_CONSP_FS', 'FO_BALAST_ATSEA_NONSECA_CONSP_FS', 'FO_LADEN_ATSEA_NONSECA_CONSP_FS', 'FO_BALAST_ATSEA_SECA_CONSP_SS', 'FO_LADEN_ATSEA_SECA_CONSP_SS', 'FO_BALAST_ATSEA_NONSECA_CONSP_SS', 'FO_LADEN_ATSEA_NONSECA_CONSP_SS', 'FO_BALAST_ATSEA_SECA_CONSP_MES', 'FO_LADEN_ATSEA_SECA_CONSP_MES', 'FO_BALAST_ATSEA_NONSECA_CONSP_MES', 'FO_LADEN_ATSEA_NONSECA_CONSP_MES');
	
	for($j=0;$j<count($arr_level);$j++)
	{
	    $pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] =$arr_level[$j];
		
		for($i=0;$i<count($chkArr1);$i++)
		{
		    $sql = "select ".$arr_fields[$j].", BUNKERID from vessel_commercial_parameters_slave1 where IDENTIFY='DO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($chkArr1[$i],"COMMERCIAL_PARAMETERID");
		    $result = mysql_query($sql);
		    $bunker_consp = array();
			while($rows = mysql_fetch_assoc($result))
			{
			    $bunker_consp[] = $obj->getBunkerGradeBasedOnID($rows['BUNKERID']).' - '.$rows[$arr_fields[$j]];
			}
			
			$arr1[$i+1] = 'C';
			$arr2[$i+1] = $width;
			$arr3[$i+1] = implode(', ',$bunker_consp);
		}
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	$pdf->SetFont('Arial','',8);
	$pdf->Cell(275,6,"FO Consp/day(MT)- In Port",1,1,'C');
	
	$arr_level = array('SECA - Working', 'NON-SECA - Working', 'SECA - Idle', 'NON-SECA - Idle', 'SECA - Others', 'NON-SECA - Others');
	$arr_fields = array('FO_INPORT_SECA_CONSP_WORKING', 'FO_INPORT_NONSECA_CONSP_WORKING', 'FO_INPORT_SECA_CONSP_IDLE', 'FO_INPORT_NONSECA_CONSP_IDLE', 'FO_INPORT_SECA_CONSP_OTHER', 'FO_INPORT_NONSECA_CONSP_OTHER');
	
	for($j=0;$j<count($arr_level);$j++)
	{
	    $pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] =$arr_level[$j];
		
		for($i=0;$i<count($chkArr1);$i++)
		{
		    $sql = "select ".$arr_fields[$j].", BUNKERID from vessel_commercial_parameters_slave1 where IDENTIFY='FO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($chkArr1[$i],"COMMERCIAL_PARAMETERID");
		    $result = mysql_query($sql);
		    $bunker_consp = array();
			while($rows = mysql_fetch_assoc($result))
			{
			    $bunker_consp[] = $obj->getBunkerGradeBasedOnID($rows['BUNKERID']).' - '.$rows[$arr_fields[$j]];
			}
			
			$arr1[$i+1] = 'C';
			$arr2[$i+1] = $width;
			$arr3[$i+1] = implode(', ',$bunker_consp);
		}
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	
	$pdf->SetFont('Arial','',8);
	$pdf->Cell(275,6,"DO Consp/day(MT)- In Port",1,1,'C');
	
	$arr_level = array('SECA - Working', 'NON-SECA - Working', 'SECA - Idle', 'NON-SECA - Idle', 'SECA - Others', 'NON-SECA - Others');
	$arr_fields = array('FO_INPORT_SECA_CONSP_WORKING', 'FO_INPORT_NONSECA_CONSP_WORKING', 'FO_INPORT_SECA_CONSP_IDLE', 'FO_INPORT_NONSECA_CONSP_IDLE', 'FO_INPORT_SECA_CONSP_OTHER', 'FO_INPORT_NONSECA_CONSP_OTHER');
	
	for($j=0;$j<count($arr_level);$j++)
	{
	    $pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1[0] = 'L';$arr2[0] = 35;$arr3[0] =$arr_level[$j];
		
		for($i=0;$i<count($chkArr1);$i++)
		{
		    $sql = "select ".$arr_fields[$j].", BUNKERID from vessel_commercial_parameters_slave1 where IDENTIFY='DO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($chkArr1[$i],"COMMERCIAL_PARAMETERID");
		    $result = mysql_query($sql);
		    $bunker_consp = array();
			while($rows = mysql_fetch_assoc($result))
			{
			    $bunker_consp[] = $obj->getBunkerGradeBasedOnID($rows['BUNKERID']).' - '.$rows[$arr_fields[$j]];
			}
			
			$arr1[$i+1] = 'C';
			$arr2[$i+1] = $width;
			$arr3[$i+1] = implode(', ',$bunker_consp);
		}
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	
	
	
	
	
	$filename = "Vessel Comparison.pdf";

	$pdf->Output($filename,'D');

}


function create_sof_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$comid = $_REQUEST['comid'];
	$port = $_REQUEST['port'];
	$portid = $_REQUEST['portid'];
    $randomid   = $_REQUEST['randomid'];
	
	
	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Sof Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Sof Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(30,5,60,30,5,60);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("PORT",":",$port." - ".$obj->getPortNameBasedOnID($portid)));

if($port == 'LP')
{$name = 'SHIPPER';}else{$name = 'RECEIVER';}

$pdf->Ln(5);
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(244,244,244);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);   
$arr1=array('L','L','L');
$arr2=array(10,85,97);
$arr3[0]=array("1.","NAME OF VESSEL",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"));
$arr3[1]=array("2.","BUILT",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"YEARBUILT"));
$arr3[2]=array("3.","GRT/NRT",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRT_NRT").'/'.$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"NRT"));
$arr3[3]=array("4.","FLAG",$obj->getCountryNameBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"FLAG")));
$arr3[4]=array("5.","DWT(s)",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DWT"));
$arr3[5]=array("6.","LOA/BEAM",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"LOA"));

if($obj->getCompareEstimateData($comid,"ESTIMATE_TYPE")!=2){
	$arr3[6]=array("7.","GEAR/GRABS",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"CARGO_GEAR"));
	$arr3[7]=array("8.","HATCH/HOLD",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"HATCH_SIZE"));
}else{
	$arr3[6]=array("7.","NO. OF CARGO PUMP(Main)",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TANKER_CARGO_PUMP"));
	$arr3[7]=array("8.","CARGO PUMP MAIN CAP(CBM/Hr)",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TANKER_PUMP_MAINCAP"));
}

$arr3[8]=array("9.","PORT/TERMINAL/BERTH/ANCHORAGE",$obj->getSOFdata($comid,$port,$portid,$randomid,"TERMINAL"));
$arr3[9]=array("10.","STOWAGE PLAN QUANTITY (MT)",$obj->getSOFdata($comid,$port,$portid,$randomid,"VA_1"));
$arr3[10]=array("11.","VESSEL ARRIVED",$obj->getSOFdata($comid,$port,$portid,$randomid,"VAPS_1"));
$arr3[11]=array("12.","NOR TENDERED",$obj->getSOFdata($comid,$port,$portid,$randomid,"NT_1"));
$arr3[12]=array("13.","PILOT ON BOARD",$obj->getSOFdata($comid,$port,$portid,$randomid,"PBFB_1"));
$arr3[13]=array("14.","LOAD/DISCH COMMENCED",$obj->getSOFdata($comid,$port,$portid,$randomid,"LC"));
$arr3[14]=array("15.","LOAD/DISCH COMPLETED",$obj->getSOFdata($comid,$port,$portid,$randomid,"LC1"));
$arr3[15]=array("16.","VESSEL SAILED",$obj->getSOFdata($comid,$port,$portid,$randomid,"VS"));


$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
for($i=0;$i<43;$i++)
{$pdf->Row2($arr3[$i]);}

$k = 16;
$sql = "select * from sof_master where COMID='".$comid."' and LOGIN='INTERNAL_USER' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='".$port."' and PORTID='".$portid."' and RANDOMID='".$randomid."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$sql = "select * from sof_master where MAPPINGID='".$mappingid."' and LOGIN='AGENT' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='".$port."' and PORTID='".$portid."' and RANDOMID='".$randomid."' and SUBMITID='2'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
}
else
{
	$rows = mysql_fetch_assoc($res);
}

$sql1 = "select * from sof_slave_3 where SOFID='".$rows['SOFID']."'";
$res1 = mysql_query($sql1);
$rec1 = mysql_num_rows($res1);
if($rec1 > 0)
{ 
	while($rows1 = mysql_fetch_assoc($res1))
	{ 
		$k = $k+1;
		$arr3=array($k.'.',$rows1['ENTITY_NAME'],$rows1['ENTITY_VALUE']);
		$pdf->Row2($arr3);
	}
}

$pdf->Ln(5);
$k = $k+1;
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$arr3=array($k.".");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('C','C','C');
$arr2=array(65,65,62);
$arr3=array("BL Date","Cargo","BL Qty(MT)");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql2 = "select * from sof_slave_1 where SOFID='".$rows['SOFID']."'";
$res2 = mysql_query($sql2);
$rec2 = mysql_num_rows($res2);
$i = 0;
if($rec2 == 0)
{
	$arr1 = $arr2 = $arr3 = array();	
	$i=$i+1;
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',8);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C');
	$arr2=array(192);
	$arr3=array("currently there are Zero(0) Records");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}
else
{
	while($rows2 = mysql_fetch_assoc($res2))
	{
		$arr1 = $arr2 = $arr3 = array();	
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(244,244,244);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','C','C');
		$arr2=array(65,65,62);
		$arr3=array(date("d-M-Y",strtotime($rows2['BL_DATE'])),$rows2['CARGO'],$rows2['BL_QTY']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
}

$pdf->Ln(5);
$k = $k+1;
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$arr3=array($k.". ALL ACTIVITIES IN PORT TO BE MENTIONED IN BELOW SECTION START FROM VESSEL ARRIVAL, WORKING, STOPPAGES TILL VESSEL SAILING AND CLEARING PORT");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L','L','L','L');
$arr2=array(80,30,30,20,32);
$arr3=array("ACTIVITY IN PORT","FROM","TO","DURATION","REMARKS");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql13 = "select * from sof_slave where SOFID='".$rows['SOFID']."' and GROUP_NAME='1'";
$res13 = mysql_query($sql13);
$rec13 = mysql_num_rows($res13);
$i = 0;
if($rec13 == 0)
{
	$arr1 = $arr2 = $arr3 = array();	
	$i=$i+1;
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',8);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C');
	$arr2=array(192);
	$arr3=array("currently there are Zero(0) Records");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}
else
{
	while($rows13 = mysql_fetch_assoc($res13))
	{
		$arr1 = $arr2 = $arr3 = array();	
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(244,244,244);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		
		if(date("d-M-Y",strtotime($rows13['START_DATETIME'])) == '01-Jan-1970') {$s_date = "";} else {$s_date = date("d-M-Y H:i",strtotime($rows13['START_DATETIME']));}
		if(date("d-M-Y",strtotime($rows13['FINISH_DATETIME'])) == '01-Jan-1970') {$f_date = "";} else {$f_date = date("d-M-Y H:i",strtotime($rows13['FINISH_DATETIME']));}
		
		if(date("d-M-Y",strtotime($rows13['START_DATETIME'])) == '01-Jan-1970' || date("d-M-Y",strtotime($rows13['FINISH_DATETIME'])) == '01-Jan-1970')
		{$duration = '';}else{$duration = $rows13['DURATION'];}
		
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L');
		$arr2=array(80,30,30,20,32);
		$arr3=array($rows13['ACTIVITYID'],$s_date,$f_date,$duration,$rows13['NOTES']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
}

$pdf->Ln(5);
$k = $k+1;
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$arr3=array($k.". AGENT'S REMARKS (If Any)");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(255,255,255);
$arr1=array('L');
$arr2=array(192);
$arr3=array($obj->getSOFdata($comid,$port,$portid,$randomid,"SHIPPER_REMARKS"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);



$pdf->Ln(5);
$k = $k+1;
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$arr3=array($k.". PRE ARRIVAL & OTHER");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(255,255,255);
$arr2=array(95,97);
$arr3=array("VESSEL NAME",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("NOMINATION ID",$obj->getCompareTableData($comid,"MESSAGE"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

if($port == 'LP')
{
	$name = 'CARGO DECL.SIGN MASTER';
	$name_1 = 'STOW PLAN QTY';
	$name_2 = 'SP DEP DRAFT';
	$name_3 = 'SP ARR DRAFT';
	$name_4 = 'ENGAGEMENT';
	$name_5 = 'LOADED';
}
else
{
	$name = 'BL MANIFEST';
	$name_1 = 'BL QUANTITY';
	$name_2 = 'ARR DRAFT';
	$name_3 = 'DEP DRAFT';
	$name_4 = 'BL';
	$name_5 = 'DISCHARGE';
}

$sql15 = "select * from sof_slave_4 where COMID='".$comid."' and LOGIN='AGENT' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='".$port."' and PORTID='".$portid."'";
$res15 = mysql_query($sql15);
$rows15 = mysql_fetch_assoc($res15);


if($rows15['CARGO_DECL'] == 1){$style = 'Yes';}else{$style = '';}
if(date("d-M-Y",strtotime($rows15['ETA_30_DAYS'])) == '01-Jan-1970') {$eta_1 = "";} else {$eta_1 = date("d-M-Y H:i",strtotime($rows15['ETA_30_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_25_DAYS'])) == '01-Jan-1970') {$eta_2 = "";} else {$eta_2 = date("d-M-Y H:i",strtotime($rows15['ETA_25_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_20_DAYS'])) == '01-Jan-1970') {$eta_3 = "";} else {$eta_3 = date("d-M-Y H:i",strtotime($rows15['ETA_20_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_25_DAYS'])) == '01-Jan-1970') {$eta_4 = "";} else {$eta_4 = date("d-M-Y H:i",strtotime($rows15['ETA_20_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_10_DAYS'])) == '01-Jan-1970') {$eta_5 = "";} else {$eta_5 = date("d-M-Y H:i",strtotime($rows15['ETA_10_DAYS']));}

if(date("d-M-Y",strtotime($rows15['ETA_7_DAYS'])) == '01-Jan-1970') {$eta_6 = "";} else {$eta_6 = date("d-M-Y H:i",strtotime($rows15['ETA_7_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_5_DAYS'])) == '01-Jan-1970') {$eta_7 = "";} else {$eta_7 = date("d-M-Y H:i",strtotime($rows15['ETA_5_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_3_DAYS'])) == '01-Jan-1970') {$eta_8 = "";} else {$eta_8 = date("d-M-Y H:i",strtotime($rows15['ETA_3_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_2_DAYS'])) == '01-Jan-1970') {$eta_9 = "";} else {$eta_9 = date("d-M-Y H:i",strtotime($rows15['ETA_2_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ETA_1_DAYS'])) == '01-Jan-1970') {$eta_10 = "";} else {$eta_10 = date("d-M-Y H:i",strtotime($rows15['ETA_1_DAYS']));}
if(date("d-M-Y",strtotime($rows15['ACTUAL_ARRIVAL'])) == '01-Jan-1970') {$eta_11 = "";} else {$eta_11 = date("d-M-Y H:i",strtotime($rows15['ACTUAL_ARRIVAL']));}
if(date("d-M-Y",strtotime($rows15['NOR_TENDERED'])) == '01-Jan-1970') {$eta_12 = "";} else {$eta_12 = date("d-M-Y H:i",strtotime($rows15['NOR_TENDERED']));}

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array($name,$style);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array($name_1,$rows15['STOW_PLAN_QTY']);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array($name_2,$rows15['SP_DEPT_DRAFT']);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array($name_3,$rows15['SP_ARR_DRAFT']);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 30 DAYS",$eta_1);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 25 DAYS",$eta_2);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 20 DAYS",$eta_3);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 15 DAYS",$eta_4);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 10 DAYS",$eta_5);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 7 DAYS",$eta_6);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 5 DAYS",$eta_7);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 3 DAYS",$eta_8);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 2 DAYS",$eta_9);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ETA 1 DAYS",$eta_10);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("ACTUAL ARRIVAL",$eta_11);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L');
$arr2=array(95,97);
$arr3=array("NOR TENDERED",$eta_12);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);



$pdf->Ln(5);
$k = $k+1;
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$arr3=array($k.". DAILY QTY");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('L','L','L','L','L','L');
$arr2=array(32,32,32,32,32,32);
$arr3=array("DATE (EVERY N/N OR ON COMPLETION)","TOTAL AGREED QTY (MT)","LOADED LAST 24 HRS (MT)","TOTAL LOADED THIS FAR (MT)","BALANCE (MT)","ETC CARGO/CARGO COMPLETED");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);




$sql16 = "select * from sof_slave_5 where COMID='".$comid."' and LOGIN='AGENT' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='".$port."' and PORTID='".$portid."'"; 
$res16 = mysql_query($sql16) or die($sql16);
$rec16 = mysql_num_rows($res16);
$i = 0;
if($rec16 == 0)
{ 
	$arr1=array('C');
	$arr2=array(192);
	$pdf->SetTextColor(0,0,0);
    $pdf->SetFillColor(255,255,255);
	$arr3=array("currently there are Zero(0) Records");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}
else
{
	while($rows16 = mysql_fetch_assoc($res16))
	{
		$arr1 = $arr2 = $arr3 = array();	
		
		if(date("d-M-Y H:i",strtotime($rows16['PRE_DATE'])) == '01-Jan-1970') {$pre_date = "";} else {$pre_date = date("d-M-Y",strtotime($rows16['PRE_DATE']));}
		if(date("d-M-Y H:i",strtotime($rows16['ETCD'])) == '01-Jan-1970') {$etcd = "";} else {$etcd = date("d-M-Y H:i",strtotime($rows16['ETCD']));}
		
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
        $pdf->SetFillColor(255,255,255);
		$arr1=array('L','L','L','L','L','L');
        $arr2=array(32,32,32,32,32,32);
		$arr3=array($pre_date,$rows16['ENGAGEMENT_QTY'],$rows16['LOAD_LAST'],$rows16['TTL_LOAD'],$rows16['BALANCE'],$etcd);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
}



$filename = 'Sof Report ('.$port.' - '.$obj->getPortNameBasedOnID($portid).')_'.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}







function inops_at_glance_check_list_pdf(){
	
	$obj 			= new data();
	$comid 		= $_REQUEST['comid'];
	
	$cost_sheet_id 	= $obj->getLatestCostSheetID($comid);
	$obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$charterer = $obj->getVendorListNewData($rowscoa['CHARTERER'],"NAME");
		$broker  = $obj->getVendorListNewData($rowscoa['BROKER'],"NAME");
	}
	else
	{
		$arrvendor = array();
		if($obj->getFun158()==2)
		{
		    if($obj->getFun228()==1)
			{
				$res11 = mysql_query("select * from freight_cost_estimete_slave12 where FCAID='".$obj->getFun1()."' and CUSTOMER!='' ");
				$num11 = mysql_num_rows($res11);
				while($rows11 = mysql_fetch_assoc($res11))
				{
				   $arrvendor[] = $obj->getVendorListNewData($rows11['CUSTOMER'],"NAME");
				}
			}
			else
			{
				$sql12 = "select SHIPPER_CHARTER, STATUS from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."' group by SHIPPER_CHARTER";
				$res12 = mysql_query($sql12);
				while($row12 = mysql_fetch_assoc($res12))
				{
					if($row12['STATUS']==1 || $row12['STATUS']==2)
					{
						$arrvendor[]  = $obj->getVendorListNewBasedOnID($row12['SHIPPER_CHARTER']);
					}
				}
			}
		}
		else
		{
			$arrvendor = $obj->getVendorListNewData($obj->getCompareEstimateData($comid,"FGFF_VENDORID"),"NAME");
		}
		$charterer = implode(',', $arrvendor);
		
		$broker  = $obj->getVendorListNewData($obj->getCompareEstimateData($comid,"BROKER"),"NAME");
	}
	$owner = $obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME");
	
    $arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$cost_sheet_id);
	$vendosrs = array();
	$sql11 = "select * from freight_cost_estimete_slave4 where FCAID='".$cost_sheet_id."'";
	$res11 = mysql_query($sql11) or die($sql11);
	while($rows11 = mysql_fetch_assoc($res11))
	{
		$vendosrs[] = $obj->getVendorListNewData($rows11['VENDORID'],'NAME');
	}
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Charter Out Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Charter Out Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/*********************************FIXTURE DETAILS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"FIXTURE DETAILS",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$sql  		= "select * from check_list where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
	$res  		= mysql_query($sql);
	$rows 		= mysql_fetch_assoc($res);
	$chartPni 	= $rows['CHARTERER_PNI'];
	
	$arr3=array("REF ID",":",$obj->getCompareEstimateData($comid,"VOYAGE_NO"),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"CP DATE",":",date('d-m-Y',strtotime($obj->getFun3())));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);

	$arr3=array("CHARTERER",":",$charterer,"OWNER",":",$owner,"BROKER",":",$broker);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	/*********************************VSL DETAILS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"VSL DETAILS",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	$arr3=array("BUILT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"YEARBUILT"),"DEADWEIGHT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DWT"),"DRAFT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DRAFTM"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	 if($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BUSINESSTYPEID")==3){$tpc = $obj->getVesselParticularData('SUMMER_3','vessel_master_1',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"));}else{$tpc = $obj->getVesselParticularData('TPC_SUMMER','vessel_master_tankers',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"));}
	
	$arr3=array("GRT",":",$obj->getVesselParticularData('GRT_NRT','vessel_imo_master',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID")).'/'.$obj->getVesselParticularData('NRT','vessel_imo_master',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID")),"TPC",":",$tpc,"VESSEL PNI",":",$obj->getVendorOnlyNameBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),'P_I')));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/*********************************VESSEL CHECKS*****************************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"VESSEL CHECKS",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	if($rows['REG']=="1"){$style_1 = 'Yes';}else {$style_1 = 'No';}
	if($rows['CLASS']=="1"){$style_2 = 'Yes';} else {$style_2 = 'No';}
	if($rows['PNI']=="1"){$style_3 = 'Yes';} else {$style_3 = 'No';}
	$arr3=array("REG",":",$style_1,"CLASS",":",$style_2,"PNI",":",$style_3);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	if($rows['ISM']=="1"){$style_4 = 'Yes';} else {$style_4 = 'No';}
	if($rows['DOC']=="1"){$style_5 = 'Yes';} else {$style_5 = 'No';}
	if($rows['ITC']=="1"){$style_6 = 'Yes';} else {$style_6 = 'No';}
	
	$arr3=array("ISM",":",$style_4,"DOC",":",$style_5,"ITC",":",$style_6);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['ISPS']=="1"){$style_7 = 'Yes';} else {$style_7 = 'No';}
	if($rows['LL']=="1"){$style_8 = 'Yes';} else {$style_8 = 'No';}
	if($rows['BQ']=="1"){$style_9 = 'Yes';} else {$style_9 = 'No';}
	
	$arr3=array("ISPS",":",$style_7,"LL",":",$style_8,"BQ",":",$style_9);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['H_M']=="1"){$style_10 = 'Yes';} else {$style_10 = 'No';}
	if($rows['SEA_WEB']=="1"){$style_11 = 'Yes';} else {$style_11 = 'No';}
	if($rows['CARGODECL_MASTER']=="1"){$style_12 = 'Yes';} else {$style_12 = 'No';}
	
	$arr3=array("H&M",":",$style_10,"SEA-WEB",":",$style_11,"CARGO DECL. SIGN MASTER",":",$style_12);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	if($rows['CERTBQ_DESK']=="1"){$style_13 = 'Yes';} else {$style_13 = 'No';}
	$arr3=array("CERTIS AND BQ SENT TO INSU. DESK",":",$style_13,"CHARTERERS PNI",":",$obj->updatecheckListChartererPniByVendorListNewForCOATe($chartPni),"LAST PORT AGENT",":",$rows['LPA_DETAIL']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$arr3=array("WORKING CP",":",$rows['WORKING_CP'],"",":","","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/*********************************LOADPORT*****************************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"LOADPORT",0,1,'L');
	
	$pdf->Ln(1);
	
	for($j=0;$j<count($arr);$j++)
	{
		$arr_explode = explode('@@',$arr[$j]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
		if($arr_explode[0] == "LP"){			
			$pdf->SetFont('Arial','B',10);
			$pdf->SetFillColor(27,119,166);
			$pdf->SetTextColor(255,255,255);
			$pdf->SetDrawColor(27,119,166);
			$arr1=array('L','C','L');
			$arr2=array(90,90,96,);
			$arr3=array("",$port_name,"");
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
	}
	
	$arr1 = $arr2 = $arr3 = array();
	
	
	$arr_1 = array("DEMURRAGE RATE(USD/DAY)","LAYCAN (OWNER)","LAYCAN (SHIPPER)","SHIPPER","DRAFT RESTRICTION","PARCEL SIZE","LOAD RATE","AGENT","REMARKS 1","","STOW PLAN QTY","SP ARR DRAFT (M)","SP DEP DRAFT (M)","","ETA 30 DAYS","ETA 25 DAYS","ETA 20 DAYS","ETA 15 DAYS","ETA 10 DAYS","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","ACTUAL ARRIVAL","NOR TENDERED","","COMMENCED","ETC/D","COMPLETED","VESSEL SAILED","DOCUMENT(S)","REMARKS 2");
	
	for($i=0;$i<count($arr_1);$i++)
	{
		if($i==9){
			
			$pdf->SetFont('Arial','B',8);
			$pdf->SetFillColor(27,119,166);
			$pdf->SetTextColor(255,255,255);
			$pdf->SetDrawColor(195,207,207);
			$arr1=array('L','C','L');
			$arr2=array(90,90,96,);
			$arr3=array("","STOWAGE PLAN","");
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}elseif($i==13){
			$pdf->SetFont('Arial','B',8);
			$pdf->SetFillColor(27,119,166);
			$pdf->SetTextColor(255,255,255);
			$pdf->SetDrawColor(195,207,207);
			$arr1=array('L','C','L');
			$arr2=array(90,90,96,);
			$arr3=array("","ETA NOTICES","");
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}elseif($i==26){
			$pdf->SetFont('Arial','B',8);
			$pdf->SetFillColor(27,119,166);
			$pdf->SetTextColor(255,255,255);
			$pdf->SetDrawColor(195,207,207);
			$arr1=array('L','C','L');
			$arr2=array(90,90,96,);
			$arr3=array("","LOAD PORT VESSEL OPERATIONS","");
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
		
		for($j=0;$j<count($arr);$j++){
			$arr_explode = explode('@@',$arr[$j]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
			if($arr_explode[0] == "LP"){
					$sql_query = "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."'";
					$result = mysql_query($sql_query);
					$testres = mysql_fetch_assoc($result);
					
					$lpvessaloper = "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
					$result1 = mysql_query($lpvessaloper);
					$testrec = mysql_fetch_assoc($result1);	
					$etc_date = date("d-M-Y",strtotime($testrec['ETCD']));
					$completed_date = date("d-M-Y",strtotime($testrec['PRE_DATE']));
					
					$comp_sql = "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."'";
					$rock_rs = mysql_query($comp_sql);
					$min_val = mysql_fetch_assoc($rock_rs);
					
					$comp_sql1 = "select * from sof_slave_5 where SOFSLAVEID='".$min_val['min']."'"; 
					$rock_rs1 = mysql_query($comp_sql1);
					$min_val = mysql_fetch_assoc($rock_rs1);	
					$commenced = date("d-M-Y",strtotime($min_val['PRE_DATE']));
					
					$sqlVss = "select * from sof_master where LOGIN='AGENT' and PORT='LP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."' ";
					$resVss = mysql_query($sqlVss);
					$sofVesselsailesLP = mysql_fetch_assoc($resVss);
					
					$pre_sql = "select * from sof_slave_4 where LOGIN='AGENT' and PORT='LP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."'";
					$pre_res = mysql_query($pre_sql);
					$preArivalLp = mysql_fetch_assoc($pre_res);
						
					$sql1 = mysql_query("select * from checklist_loadport where PORT='LP' and PORTID='".$arr_explode[1]."' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and ENTITY_NAME='".$arr_1[$i]."' and RANDOMID='".$arr_explode[2]."'");
					$rows1 = mysql_fetch_assoc($sql1);
					
					$arr1 = $arr2 = $arr3 = array();
					$pdf->SetFont('Arial','',7);
					$pdf->SetFillColor(255,255,255);
					$pdf->SetTextColor(000,000,000);
					$pdf->SetDrawColor(255,255,255);
					$arr1=array('L','L','L','L','L');
					$arr2=array(80,50,52,50,45);
					
					if($i==8){		
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==10 ){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==11){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==12){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);					
					}elseif($i==14){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==15){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==17){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==18){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==19){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==20){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==21){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==22){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==23){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==24){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}elseif($i==25){
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					} else{
						$arr3=array("",$arr_1[$i],":",$rows1['ENTITY_VALUE'],"");
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}		
			}
	}
	
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','C','C');
	$arr2=array(92,92,92);
	$arr3=array("BL DATE","CARGO","BL QTY");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$j = 0;
						
	$sql2 = "select * from sof_slave_1 inner join sof_master on sof_master.SOFID = sof_slave_1.SOFID where sof_master.PORT='LP' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER'";
	$res2 = mysql_query($sql2) or die($sql2);
	$rec2 = mysql_num_rows($res2);
	while($rows2 = mysql_fetch_assoc($res2))
	{ 
	    $arr1 = $arr2 = $arr3 = array();
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C');
	    $arr2=array(92,92,92);
		$arr3=array(date("d-M-Y",strtotime($rows2['BL_DATE'])),$rows2['CARGO'],$rows2['BL_QTY']);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	
	}
	$j=0;
	$k=0;
	$sql_fty = "select * from checklist_finalqty where CHECKLIST_ID='".$rows['CHECKLIST_ID']."'";
	$fty_res = mysql_query($sql_fty);
	$fty_rec = mysql_num_rows($fty_res);
	
	while($fty_rows = mysql_fetch_assoc($fty_res))
	{
		$barr[$k] = $fty_rows['QTY_ID'];
		$name_arr[$k] = $fty_rows['ENTITY_NAME'];
		$k++;
	}
	
	$unique_arr = array_values(array_unique($name_arr));
	$count 		= sizeof($unique_arr);
	
	if($fty_rec > 0)
	{
		for($i=0;$i<$count;$i++)
		{ 
			$j = $j+1;
			
			unset($barr_1);
			$sql_fty_1 = "select * from checklist_finalqty where CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and ENTITY_NAME='".$unique_arr[$i]."'";
			$fty_res_1 = mysql_query($sql_fty_1);
			$k=0;
			while($fty_rows_1 = mysql_fetch_assoc($fty_res_1))
			{
				$barr_1[$k] = $fty_rows_1['ENTITY_VALUE'];
				$k++;
			}
					
			for($x=0;$x<count($arr);$x++)
			{
				$arr_explode = explode('@@',$arr[$x]);
				if($arr_explode[0] == "LP")
				{
					$arr3=array("",$unique_arr[$i],":",$barr_1[$x],"");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
		}
	}
	
	/**********************************LOAD PORT DAILY QTY****************************************/
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"LOAD PORT DAILY QTY",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(50,40,50,55,42,40);
	$arr3=array("DATE","ENGAGEMENT QTY","LOAD LAST 24 HRS","TOTAL LOADED","BALANCE","ETCD");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$k=0;
	for($i=0;$i<count($arr);$i++){ 
	$arr_explode = explode('@@',$arr[$i]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
	   if($arr_explode[0] == "LP"){
		 $sql16 = "select * from sof_slave_5 where COMID='".$comid."' and LOGIN='AGENT' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$arr_explode[1]."' and RANDOMID='".$arr_explode[2]."'"; 
		$lpdailyqty = mysql_query($sql16);
		}
	}
	$rec16 = mysql_num_rows($lpdailyqty);
	if($rec16 == 0)
	{ 
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','L','L','L','L');
		$arr2=array(50,70,150,30,20);
		$arr3=array("","","sorry currently there are zero(0) record","","",);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
	}else{
		 for($i=0;$i<count($arr);$i++){ 
		 $arr_explode = explode('@@',$arr[$i]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
			if($arr_explode[0] == "LP"){
				while($rows16 = mysql_fetch_assoc($lpdailyqty)){ 
					if(date("d-M-Y",strtotime($rows16['PRE_DATE'])) == '01-Jan-1970') {
						$pre_date = "";
					} else {
						$pre_date = date("d-M-Y",strtotime($rows16['PRE_DATE']));
					}
					if(date("d-M-Y",strtotime($rows16['ETCD'])) == '01-Jan-1970') {
						$etcd = "";
					} else {
						$etcd = date("d-M-Y H:i",strtotime($rows16['ETCD']));
					}
					
					if($k % 2 == 0)
					{
						$pdf->SetFillColor(255,255,255);
					}
					else
					{
						$pdf->SetFillColor(244,244,244);
					}
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(241,241,241);
					$arr1=array('L','L','L','L','L','L','L','L');
					$arr2=array(50,40,50,55,42,40);
					$arr3=array($pre_date,$rows16['ENGAGEMENT_QTY'],$rows16['LOAD_LAST'],$rows16['TTL_LOAD'],$rows16['BALANCE'],$etcd);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
					
					$k++;
				}
			}
	 	}
	}
	
	
	/**********************************PAYMENTS****************************************/
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"PAYMENTS",0,1,'L');
	
	$pdf->Ln(1);
	$arr1 = $arr2 = $arr3 = array();
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	
	if($rows['FREIGHT_PAYMENT']=="1"){$style_105 = 'Yes';} else {$style_105 = 'No';}
	if($rows['FREIGHT_PAYMENT']=="2"){$style_106 = 'Yes';} else {$style_106 = 'No';}
	if($rows['DAADV_AGENT']=="1"){$style_16 = 'Yes';} else {$style_16 = 'No';}
	
	$arr3=array("95% FREIGHT PAYMENT",":",$style_105,"90% FREIGHT PAYMENT",":",$style_106,"DA ADVANCE  AGENT",":",$style_16);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	if($rows['FREIGHT_PAYMENT']=="1"){$style_107 = 'Yes';} else {$style_107 = 'No';}
	if($rows['FREIGHT_PAYMENT']=="2"){$style_108 = 'Yes';} else {$style_108 = 'No';}
	
	$arr3=array("5% FREIGHT PAYMENT",":",$style_107,"10% FREIGHT PAYMENT",":",$style_108,"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	if($rows['FREIGHT_PAYMENT']=="1"){$style_110 = 'Yes';} else {$style_110 = 'No';}
	if($rows['FREIGHT_PAYMENT']=="2"){$style_111 = 'Yes';} else {$style_111 = 'No';}
	
	$arr3=array("DA final",":",$style_110,"Hire",":",$style_111,"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
		
		
		
		if(count($arr)!=0)
		{
			$pdf->SetFont('Arial','B',10);
			$pdf->SetTextColor(27,119,166);
			$pdf->Cell(190,6,"DISCHARGE PORT",0,1,'L');
			$pdf->Ln(1);
			for($j=0;$j<count($arr);$j++)
			{
				$arr_explode = explode('@@',$arr[$j]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
				if($arr_explode[0] == "DP")
				{
					$pdf->SetFont('Arial','B',10);
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(27,119,166);
					$arr1=array('L','C','L');
					$arr2=array(90,90,96,);
					$arr3=array("",$port_name,"");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);	
				}
			} 
			
			$arr_2 = array("DEMURRAGE RATE(USD/DAY)","PORT (S)","AGENT","DISCHARGE RATE","RECEIVER","REMARKS 3","","LOI FROM RECIVER","LOI TO OWNER","BL MANIFEST","DISCHARGE INSTRUCTIONS","REMARKS","","ETA 30 DAYS","ETA 25 DAYS","ETA 20 DAYS","ETA 15 DAYS","ETA 10 DAYS","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","NOR TENDERED","","COMMENCED","ETC/D","BALANCE","TOTAL","24HRS","COMPLETED","VESSEL SAILED","DOCUMENT(S)","REMARKS 4");
				
			for($i=0;$i<count($arr_2);$i++)
			{
				if($i==6)
				{
					$pdf->SetFont('Arial','B',8);
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(195,207,207);
					$arr1=array('L','C','L');
					$arr2=array(90,90,96,);
					$arr3=array("","LOI","");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				} 
				elseif($i==12)
				{
					$pdf->SetFont('Arial','B',8);
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(195,207,207);
					$arr1=array('L','C','L');
					$arr2=array(90,90,96,);
					$arr3=array("","DISCHARGE PORT ETA NOTICES","");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				} 
				elseif($i==24)
				{
					$pdf->SetFont('Arial','B',8);
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(195,207,207);
					$arr1=array('L','C','L');
					$arr2=array(90,90,96,);
					$arr3=array("","DISCHARGE PORT VESSEL OPERATIONS","");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				} 
				else
				{
					$pdf->SetFont('Arial','B',8);
					$pdf->SetFillColor(27,119,166);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(195,207,207);
					$arr1=array('L','C','L');
					$arr2=array(90,90,96,);
					$arr3=array("",$arr_2[$i],"");
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
				for($j=0;$j<count($arr);$j++)
				{
					$arr_explode = explode('@@',$arr[$j]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
					if($arr_explode[0] == "DP")
					{
					
						$sql_query 			= "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."' ";
						
						$result 			= mysql_query($sql_query) or die($sql_query);
						$testres 			= mysql_fetch_assoc($result);
						
						$lpvessaloper 		= "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
						$result1 			= mysql_query($lpvessaloper);
						$testrec 			= mysql_fetch_assoc($result1);	
						if($testrec['ETCD']!="")
						{$etc_date 			= date("d-M-Y",strtotime($testrec['ETCD']));}
						else{$etc_date 		= "01-Jan-1970";}
						if($testrec['PRE_DATE']!="")
						{$completed_date 			= date("d-M-Y",strtotime($testrec['PRE_DATE']));}
						else{$completed_date 		= "";}
						
						$comp_sql 			= "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."' ";
						$rock_rs 			= mysql_query($comp_sql);
						$min_val 			= mysql_fetch_assoc($rock_rs);
						
						$comp_sql1 			= "select * from sof_slave_5 where SOFSLAVEID='".$min_val['min']."'"; 
						$rock_rs1 			= mysql_query($comp_sql1);
						$min_val 			= mysql_fetch_assoc($rock_rs1);	
						$commenced 			= date("d-M-Y",strtotime($min_val['PRE_DATE']));
						
						$sqlDp 				= "select * from sof_master where LOGIN='AGENT' and PORT='DP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."' ";
						$resultDp 			= mysql_query($sqlDp);
						$sofVesselsailesDp 	= mysql_fetch_assoc($resultDp);
						
						$pre_sqlDP 			= "select * from sof_slave_4 where LOGIN='AGENT' and PORT='DP' and PORTID='".$arr_explode[1]."' and COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and RANDOMID='".$arr_explode[2]."' ";
						$pre_resDP 			= mysql_query($pre_sqlDP);
						$preArivalDp 		= mysql_fetch_assoc($pre_resDP);
						
						$sql2 				= "select * from checklist_loadport where PORT='DP' and PORTID='".$arr_explode[1]."' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and ENTITY_NAME='".$arr_2[$i]."' and RANDOMID='".$arr_explode[2]."' ";
						$res2 				= mysql_query($sql2);
						$rows2 				= mysql_fetch_assoc($res2);
				
						if($i==6)
						{
						} 
						elseif($i==12)
						{
						} 
						elseif($i==24)
						{
						} 
						elseif($i==5 || $i==11 || $i==33)
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==10)
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i>6 && $i<12)
						{ 
							if($rows2['ENTITY_VALUE']=="1"){$style_17 = 'Yes';} else {$style_17 = 'No';}
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$style_17,"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						
						} 
						elseif($i==24)
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
							
						} 
						
						elseif($i==25)
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==26)
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						
						elseif($i==27 && $testrec['BALANCE']=="0" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==27 && $testrec['BALANCE']!="0" && $rows2['ENTITY_VALUE']=="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['TTL_LOAD'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==27 && $testrec['BALANCE']=="" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==27 && $testrec['BALANCE']!="0" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['BALANCE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==28 && $testrec['TTL_LOAD']=="0" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==28 && $testrec['TTL_LOAD']!="0" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['TTL_LOAD'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==28 && $testrec['TTL_LOAD']=="" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==28 && $testrec['TTL_LOAD']!="0" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['TTL_LOAD'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==29 && $testrec['LOAD_LAST']=="0" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==29 && $testrec['LOAD_LAST']!="0" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['LOAD_LAST'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==29 && $testrec['LOAD_LAST']=="" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==29 && $testrec['LOAD_LAST']!="0" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$testrec['LOAD_LAST'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
						elseif($i==30 && $sofVesselsailesDp['LC1'] == "" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==30 && $sofVesselsailesDp['LC1']!="" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$sofVesselsailesDp['LC1'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==30 && $sofVesselsailesDp['LC1']=="" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==30 && $sofVesselsailesDp['LC1']!="" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$sofVesselsailesDp['LC1'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==31 && $sofVesselsailesDp['VS'] == "" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==31 && $sofVesselsailesDp['VS']!="" && $rows2['ENTITY_VALUE']=="")
						{   
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$sofVesselsailesDp['VS'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==31 && $sofVesselsailesDp['VS']=="" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==31 && $sofVesselsailesDp['VS']!="" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$sofVesselsailesDp['VS'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==13 && date("d-M-Y",strtotime($preArivalDp['ETA_30_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==13 && date("d-M-Y",strtotime($preArivalDp['ETA_30_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{  
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_30_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==13 && date("d-M-Y",strtotime($preArivalDp['ETA_30_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==13 && date("d-M-Y",strtotime($preArivalDp['ETA_30_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_30_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==14 && date("d-M-Y",strtotime($preArivalDp['ETA_25_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==14 && date("d-M-Y",strtotime($preArivalDp['ETA_25_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_25_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==14 && date("d-M-Y",strtotime($preArivalDp['ETA_25_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==14 && date("d-M-Y",strtotime($preArivalDp['ETA_25_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_25_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==15 && date("d-M-Y",strtotime($preArivalDp['ETA_20_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==15 && date("d-M-Y",strtotime($preArivalDp['ETA_20_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_20_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==15 && date("d-M-Y",strtotime($preArivalDp['ETA_20_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==15 && date("d-M-Y",strtotime($preArivalDp['ETA_20_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_20_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==16 && date("d-M-Y",strtotime($preArivalDp['ETA_15_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==16 && date("d-M-Y",strtotime($preArivalDp['ETA_15_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_15_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==16 && date("d-M-Y",strtotime($preArivalDp['ETA_15_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==16 && date("d-M-Y",strtotime($preArivalDp['ETA_15_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_15_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==17 && date("d-M-Y",strtotime($preArivalDp['ETA_10_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==17 && date("d-M-Y",strtotime($preArivalDp['ETA_10_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_10_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==17 && date("d-M-Y",strtotime($preArivalDp['ETA_10_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==17 && date("d-M-Y",strtotime($preArivalDp['ETA_10_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_10_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==18 && date("d-M-Y",strtotime($preArivalDp['ETA_7_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==18 && date("d-M-Y",strtotime($preArivalDp['ETA_7_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_7_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==18 && date("d-M-Y",strtotime($preArivalDp['ETA_7_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==18 && date("d-M-Y",strtotime($preArivalDp['ETA_7_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_7_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
						elseif($i==19 && date("d-M-Y",strtotime($preArivalDp['ETA_5_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==19 && date("d-M-Y",strtotime($preArivalDp['ETA_5_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_5_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==19 && date("d-M-Y",strtotime($preArivalDp['ETA_5_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==19 && date("d-M-Y",strtotime($preArivalDp['ETA_5_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_5_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==20 && date("d-M-Y",strtotime($preArivalDp['ETA_3_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==20 && date("d-M-Y",strtotime($preArivalDp['ETA_3_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_3_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==20 && date("d-M-Y",strtotime($preArivalDp['ETA_3_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==20 && date("d-M-Y",strtotime($preArivalDp['ETA_3_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_3_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==21 && date("d-M-Y",strtotime($preArivalDp['ETA_2_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==21 && date("d-M-Y",strtotime($preArivalDp['ETA_2_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_2_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==21 && date("d-M-Y",strtotime($preArivalDp['ETA_2_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==21 && date("d-M-Y",strtotime($preArivalDp['ETA_2_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_2_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==22 && date("d-M-Y",strtotime($preArivalDp['ETA_1_DAYS'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==22 && date("d-M-Y",strtotime($preArivalDp['ETA_1_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_1_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==22 && date("d-M-Y",strtotime($preArivalDp['ETA_1_DAYS']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==22 && date("d-M-Y",strtotime($preArivalDp['ETA_1_DAYS']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['ETA_1_DAYS'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						
						elseif($i==23 && date("d-M-Y",strtotime($preArivalDp['NOR_TENDERED'])) == "01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":","","");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==23 && date("d-M-Y",strtotime($preArivalDp['NOR_TENDERED']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']=="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['NOR_TENDERED'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==23 && date("d-M-Y",strtotime($preArivalDp['NOR_TENDERED']))=="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i==23 && date("d-M-Y",strtotime($preArivalDp['NOR_TENDERED']))!="01-Jan-1970" && $rows2['ENTITY_VALUE']!="")
						{
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",date("d-M-Y H:i",strtotime($preArivalDp['NOR_TENDERED'])),"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						} 
						elseif($i>11 && $i<23) 
						{ 
							$pdf->SetFont('Arial','',7);
							$pdf->SetFillColor(255,255,255);
							$pdf->SetTextColor(000,000,000);
							$pdf->SetDrawColor(255,255,255);
							$arr1=array('L','L','L','L','L');
							$arr2=array(80,50,52,50,45);
							$arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
					   } 
					   else 
					   {
						   $pdf->SetFont('Arial','',7);
						   $pdf->SetFillColor(255,255,255);
						   $pdf->SetTextColor(000,000,000);
						   $pdf->SetDrawColor(255,255,255);
						   $arr1=array('L','L','L','L','L');
						   $arr2=array(80,50,52,50,45);
						   $arr3=array("",$arr_2[$i],":",$rows2['ENTITY_VALUE'],"");
						   $pdf->SetAligns($arr1);
						   $pdf->SetWidths($arr2);
						   $pdf->Row2($arr3);
					   }
					}
                }
             } 
         }
		
		
		
			
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"DISCHARGE PORT DAILY QTY",0,1,'L');
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(50,40,50,55,42,40);
	$arr3=array("DATE","ENGAGEMENT QTY","LOAD LAST 24 HRS","TOTAL LOADED","BALANCE","ETCD");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$k=0;
	for($i=0;$i<count($arr);$i++){ 
	   $arr_explode = explode('-',$arr[$i]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
	   if($arr_explode[0] == "DP"){
		 	$sql16 = "select * from sof_slave_5 where COMID='".$comid."' and LOGIN='AGENT' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$arr_explode[1]."' and RANDOMID='".$arr_explode[2]."'"; 
		$lpdailyqty = mysql_query($sql16);
		}
	}
		$rec16 = mysql_num_rows($lpdailyqty);
		if($rec16 == 0)
		{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetDrawColor(255,255,255);
			$pdf->SetTextColor(230, 0, 0);
			$arr1=array('L','L','L','L','L');
			$arr2=array(50,70,150,30,20);
			$arr3=array("","","sorry currently there are zero(0) record","","",);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}else{
			for($i=0;$i<count($arr);$i++){ 
			$arr_explode = explode('-',$arr[$i]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
				if($arr_explode[0] == "LP"){
					while($rows16 = mysql_fetch_assoc($lpdailyqty)){ 
						if(date("d-M-Y",strtotime($rows16['PRE_DATE'])) == '01-Jan-1970') {$pre_date = "";} else {$pre_date = date("d-M-Y",strtotime($rows16['PRE_DATE']));}
						if(date("d-M-Y",strtotime($rows16['ETCD'])) == '01-Jan-1970') {$etcd = "";} else {$etcd = date("d-M-Y H:i",strtotime($rows16['ETCD']));}
						
						if($k % 2 == 0)
						{
							$pdf->SetFillColor(255,255,255);
						}
						else
						{
							$pdf->SetFillColor(244,244,244);
						}
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(241,241,241);
						$arr1=array('L','L','L','L','L','L','L','L');
						$arr2=array(50,40,50,55,42,40);
						$arr3=array($pre_date,$rows16['ENGAGEMENT_QTY'],$rows16['LOAD_LAST'],$rows16['TTL_LOAD'],$rows16['BALANCE'],$etcd);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						$k++;
					}
				}
			}
		}	
	
	    if($rows['REDEL_DATE']=="1970-01-01" || $rows['REDEL_DATE']=="")
		{$redel_date="";}
		else
		{$redel_date = date('d-m-Y',strtotime($rows['REDEL_DATE']));}
		$pdf->SetFont('Arial','B',8);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Voyage Completion Date : ".$redel_date,0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"",0,1,'L');
		$pdf->Ln(1);
		if($rows['LP_FTF']=="1"){$style_18 = 'Yes';} else {$style_18 = 'No';}
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','C','L','L','C','L','L','C','L');
		$arr2=array(50,5,50,40,5,50,40,5,40);
		$arr3=array("FILED TO FOLDER",":",$style_18,"REMARKS",":",$rows['REMARKS'],"","","");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
	
	$filename = "Check List Report ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
	
}


function create_laytime_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$comid = $_REQUEST['comid'];
	$cost_sheet_id = $obj->getLatestCostSheetID($comid);
	$obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$charterer = $obj->getVendorListNewData($rowscoa['CHARTERER'],"NAME");
		$cargo = $obj->getCargoNameListForMultipleName($rowscoa['CARGO']);
	}
	else
	{
	    if($obj->getFun228()==1)
        {
		    if($obj->getCompareEstimateData($comid,"CHK_LUMPSUM") == 1)
			{
				$charterer = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($comid,"LUMP_VENDOR"));
			}
			else
			{
				$arr_ven = array();
				$sqlslav = "select * from freight_cost_estimete_slave12 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."'";
				$res1slav = mysql_query($sqlslav);
				while($rowsslav = mysql_fetch_assoc($res1slav))
				{
					$arr_ven[] = $obj->getVendorListNewBasedOnID($rowsslav['CUSTOMER']);
				}
				$charterer = implode(', ',$arr_ven);
			}
		}
		else
		{
		    $arr_ven = array();
			$sql12 = "select SHIPPER_CHARTER, STATUS from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."' group by SHIPPER_CHARTER";
			$res12 = mysql_query($sql12);
			while($row12 = mysql_fetch_assoc($res12))
			{
				if($row12['STATUS']==1 || $row12['STATUS']==2)
				{
					$arr_ven[]  = $obj->getVendorListNewBasedOnID($row12['SHIPPER_CHARTER']);
				}
			}
			$charterer = implode(', ',$arr_ven);
		}
		
		$cargo = $obj->getCargoNameListForMultipleNamemultiple($obj->getCompareEstimateData($comid,"CARGO_ID"));
	}
	$arr_port  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$cost_sheet_id);
	$laytimeid = $_REQUEST['laytimeid'];

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(190,1,"______________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
			
		}
	}
	
	$obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	$pdf = new PDF();
	for($k=0;$k<count($arr_port);$k++)
	{
		$arr_explode = explode('@@',$arr_port[$k]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
	    $sql = "select * from laytime_master where COMID='".$comid."' and LOGIN='INTERNAL_USER' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='".$arr_explode[0]."' and PORTID='".$arr_explode[1]."' and RANDOMID='".$arr_explode[2]."'";
		$result = mysql_query($sql);
		$num1 = mysql_num_rows($result);
		if($num1 > 0)
		{
			$rows = mysql_fetch_assoc($result);
			
			$pdf->AddPage('P');
			$pdf->SetDisplayMode('real','single');
			$pdf->SetDisplayMode('real','single');
			$pdf->SetTitle('Laytime Report Pdf');
			$pdf->SetAuthor('Seven Oceans Holdings');
			$pdf->SetSubject('Laytime Report Pdf');
			$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',10);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('C');
			$arr2=array(195);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($arr_explode[0].'-'.$port_name));
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		
			$pdf->Row1(array("Laytime Applicable","Reversible","COA/CP Date"));
			
			$charterer = '';
			$cpdate = date("d-m-Y",strtotime($obj->getFun3()));
			if($obj->getFun175()!='')
			{
				$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
				$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
				$rowscoa   = mysql_fetch_assoc($resultcoa);
				$charterer = $obj->getVendorListNewData($rowscoa['CHARTERER'],"NAME");
				$cargo = $obj->getCargoNameListForMultipleNamemultiple($rowscoa['CARGO']);
				$currency = $rowscoa['CURRENCY'];
			}
			else
			{$arrvendor = array();
				if($obj->getFun158()==2)
				{
					if($obj->getFun228()==1)
					{
						if($obj->getCompareEstimateData($comid,"CHK_LUMPSUM") == 1)
						{
							$arrvendor[] = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($comid,"LUMP_VENDOR"));
						}
						else
						{
							$arr_ven = array();
							$sqlslav = "select * from freight_cost_estimete_slave12 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."'";
							$res1slav = mysql_query($sqlslav);
							while($rowsslav = mysql_fetch_assoc($res1slav))
							{
								$arrvendor[] = $obj->getVendorListNewBasedOnID($rowsslav['CUSTOMER']);
							}
						}
					}
					else
					{
						$sql12 = "select SHIPPER_CHARTER, STATUS from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($comid,"FCAID")."' group by SHIPPER_CHARTER";
						$res12 = mysql_query($sql12);
						while($row12 = mysql_fetch_assoc($res12))
						{
							if($row12['STATUS']==1 || $row12['STATUS']==2)
							{
								$arrvendor[]  = $obj->getVendorListNewBasedOnID($row12['SHIPPER_CHARTER']);
							}
						}
					}
				}
				else
				{
					$arrvendor[] = $obj->getVendorListNewData($obj->getCompareEstimateData($comid,"FGFF_VENDORID"),"NAME");
				}
				$charterer = implode(',', $arrvendor);
				$currency = 'USD';
			}
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array(($rows['APPLICABLE_STATUS']==1)?'Yes':'No',($rows['REVERSIBLE']==1)?'Yes':'',$cpdate));
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Entity","Charterer","Cargo"));
			
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array('Ship Owner',$charterer,$cargo));
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Nomination ID","Vessel",""));
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($obj->getCompareTableData($comid,"MESSAGE"),$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),''));
			
			if($obj->getFun158()==3){
				$pdf->Ln(2);
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(30,133,190);
				$arr1=array('L','L','L');
				$arr2=array(65,65,65);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				if($arr_explode[0] == "LP")
				{
					$pdf->Row1(array("Terminal/Berth","Load Qty (MT)","Load Rate (MT/Day)",""));
				}else{
					$pdf->Row1(array("Terminal/Berth","Discharge Qty (MT)","Discharge Rate (MT/Day)",""));
				}
				
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L');
				$arr2=array(65,65,65);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array($obj->getSOFdata($comid,$rows['PORT'],$rows['PORTID'],$rows['RANDOMID'],"TERMINAL"),$rows['LOADED_QTY'],$rows['LOADED_RATE'],''));
            }	
			else{
			    $pdf->Ln(2);
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(30,133,190);
				$arr1=array('L','L','L');
				$arr2=array(65,65,65);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				if($arr_explode[0] == "LP")
				{
					$pdf->Row1(array("Terminal/Berth","","",""));
				}else{
					$pdf->Row1(array("Terminal/Berth","","",""));
				}
				
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L');
				$arr2=array(65,65,65);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array($obj->getSOFdata($comid,$rows['PORT'],$rows['PORTID'],$rows['RANDOMID'],"TERMINAL"),"","",''));
			
			}		
			if($obj->getFun158()==1 || $obj->getFun158()==2){$title1 = "Hrs";	}else{$title1 = "Days";	}
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Laytime Allowed(".$title1.")","Actual Laytime As Per Below Entry(".$title1.")",""));
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($rows['LAYTIME_ALLOWED'],$rows['ACTUAL_LAYTIME'],""));
			
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Time to demurrage(".$title1.")","Demurrage Rate (".$currency."/Day)","Demurrage(".$currency.")"));
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($rows['TIME_TO_DEMURRAGE'],$rows['DEMURRAGE_RATE'],$rows['TTL_DEMURRAGE']));
			
			
			$pdf->Ln(2);
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array("Time to despatch(".$title1.")","Despatch Rate (".$currency."/Day)","Despatch(".$currency.")"));
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L');
			$arr2=array(65,65,65);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($rows['TIME_TO_DESPATCH'],$rows['DESPATCH_RATE'],$rows['TTL_DESPATCH']));
			
			
			$total_time_used = 0; $j = 0; unset($laytime_allowed); unset($time_to_demm); unset($demm_rate); unset($demm);
			if(trim($rows['ACTUAL_LAYTIME']) != '')
			{ 
				$total_time_used = $total_time_used+$rows['ACTUAL_LAYTIME'];
				$laytime_allowed[$j] = $rows['LAYTIME_ALLOWED'];
				$time_to_demm[$j] = $rows['TIME_TO_DEMURRAGE'];
				$demm_rate[$j] = $rows['DEMURRAGE_RATE'];
				$demm[$j] = $rows['TTL_DEMURRAGE'];
				$j++;
				
				$pdf->Ln(5);
				$pdf->SetFont('Arial','',8);
				$pdf->SetTextColor(30,133,190);
				$arr1=array('L');
				$arr2=array(80);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array($rows['PORT'].' - '.$obj->getPortNameBasedOnID($rows['PORTID'])));
				
				$arr1 = $arr2 = $arr3 = array();	
				$pdf->SetFont('Arial','B',7);
				$pdf->SetFillColor(128,128,128);
				$pdf->SetTextColor(255,255,255);
				$pdf->SetDrawColor(238,238,238);
				$arr1=array('L','C','C','C','C','C');
				$arr2=array(50,25,25,15,15,25,26);
				$arr3=array("Activity in Port","Date / Time - Start","Date / Time - Finish","Duration(Hrs)","LT(Partial %)","Cummulative Time","Notes");
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
				
				$query = "select * from laytime_slave where LAYTIME_ID='".$rows['LAYTIME_ID']."'";
				$qres = mysql_query($query);
				$i = 0;
				while($qrows = mysql_fetch_assoc($qres))
				{
					if(date("d-M-Y",strtotime($qrows['START_DATETIME'])) == '01-Jan-1970'){$start_date = '';}else{$start_date = date("d-M-Y H:i",strtotime($qrows['START_DATETIME']));}
					if(date("d-M-Y",strtotime($qrows['FINISH_DATETIME'])) == '01-Jan-1970'){$finish_date = '';}else{$finish_date = date("d-M-Y H:i",strtotime($qrows['FINISH_DATETIME']));}
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','C','C','C','C','C');
					$arr2=array(50,25,25,15,15,25,26);
					$arr3=array($qrows['ACTIVITYID'],$start_date,$finish_date,$qrows['DURATION'],$qrows['LT_PARTIAL'],$qrows['CUMMULATIVE_TIME'],$qrows['NOTES']);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
		}
	}
	$filename = 'Laytime Report '.date("d-m-Y",time()).'.pdf';
	$pdf->Output($filename,'D');
}


function getDailyPositionReport()
{	
	$obj 			= new data();
    $val            =  $_REQUEST['val'];
	$selBType       =  $_REQUEST['selBType'];
	$selVoyageType  =  $_REQUEST['selVoyageType'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Daily Position Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Daily Position Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	$pdf->SetFont('daxcondensedlight','',15);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(275,6,date("d M Y",time())." DAILY POSITION REPORT VC & COA",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	$pdf->Ln(1);
	
	if($selVoyageType=='VC'){
	 	$sql1 =" and COAAID is NULL"; 
	 }
	 if($selVoyageType=='COA'){
	 	$sql1 =" and COAAID is not NULL";
	 }
	 
	 $operator_arr = array();
	 $sql = "select *, (select CONTACT_PERSON from login where login.LOGINID=freight_cost_estimate_compare.OPERATOR) as OPERATOR1, (select LAYCAN_SDATE from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as LAYCAN_SDATE, (select LAYCAN_EDATE from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as LAYCAN_EDATE, (select CARGO from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as CARGOIDS, (select CHARTERER from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as CHARTERER1, (select OWNER from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as OWNER1, (select SHIPPER from open_cargo_master where open_cargo_master.OPEN_CARGOID = freight_cost_estimete_master.OPEN_CARGOID) as SHIPPER1 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 in (1,2) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$sql1." group by freight_cost_estimete_master.FCAID order by freight_cost_estimate_compare.COMID desc ";
	 
	$res  = mysql_query($sql);
	$res1 = mysql_query($sql);
	$res2 = mysql_query($sql);
	$res3 = mysql_query($sql);
	$rec  = mysql_num_rows($res);
	
	if($rec > 0)
	{
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',12);
	    $pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L');
		$arr2=array(288);
		$arr3=array("TOWARDS LOAD PORT - AT SEA");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
		$arr3=array("S. No.","Vessel","Nom ID/Voyage ID","Operator Name","Charterer", "Shipper","Owner","Port","ETA","Cargo","Qty(MT)" ,"Laycan", "Agent","Broker","Dem. Rate(USD/Day)","Dis Port(s)","Remarks");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$j=1;
		while($rows = mysql_fetch_assoc($res))
		{
			$port_arr_lp  = $obj->getLoadPortArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID']);
			for($i=0;$i<count($port_arr_lp);$i++)
			{
				
				if($obj->getCheckListRecordsRecBasedOnComID($rows['COMID']) > 0)
				{
					
					$arr_loadport  = explode('###',$port_arr_lp[$i]);
					$checklistid   = $obj->getCheckListRecordsDataBasedOnComID($rows['COMID'],"CHECKLIST_ID");
					$eta30days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 30 DAYS");
					$eta25days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 25 DAYS");
					$eta20days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 20 DAYS");
					$eta15days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 15 DAYS");
					$eta10days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 10 DAYS");
					$eta7days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 7 DAYS");
					$eta5days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 5 DAYS");
					$eta3days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 3 DAYS");
					$eta2days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 2 DAYS");
					$eta1days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETA 1 DAY");
					$actualarrival = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ACTUAL ARRIVAL");
					
					if(($eta30days!='' && $actualarrival=="") || ($eta25days!='' && $actualarrival=="") || ($eta20days!='' && $actualarrival=="") || ($eta15days!='' && $actualarrival=="") || ($eta10days!='' && $actualarrival=="") || ($eta7days!='' && $actualarrival=="") || ($eta5days!='' && $actualarrival=="") || ($eta3days!='' && $actualarrival=="") || ($eta2days!='' && $actualarrival=="") || ($eta1days!='' && $actualarrival==""))
					{
						$count_arr_lp1[] = $j;
						
						$operator_arr[$rows['OPERATOR']][] = 1;
						$cargos = $obj->getCargoNameListForMultipleNamemultiple($rows['CARGOIDS']);
						$broker_arr = array();
						$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
						$sql_brok = "select VENDORID from freight_cost_estimete_slave4 where FCAID='".$fcaid."'";
						$res_brok = mysql_query($sql_brok);
						while($rows_brok = mysql_fetch_assoc($res_brok))
						{
							$broker_arr[] = $obj->getVendorListNewBasedOnID($rows_brok['VENDORID']);
						}
						
						$sql_qty = "select LOAD_PORT_QTY from freight_cost_estimete_slave1 where FROM_PORT='".$arr_loadport[0]."' and RANDOMID='".$arr_loadport[1]."' and FCAID='".$fcaid."'";
						$res_qty = mysql_query($sql_qty) or die($sql_qty);
						$rows_qty = mysql_fetch_assoc($res_qty);
						$quantity = $rows_qty['LOAD_PORT_QTY'];
						
						$pdf->SetX(5);
						$pdf->SetFont('daxcondensedlight','',8);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
						$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
						$arr3=array($j,$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$obj->getCompareTableData($rows['COMID'],"MESSAGE").'/'.$rows['VOYAGE_NO'],$rows['OPERATOR1'],$obj->getVendorListNewBasedOnID($rows['CHARTERER1']), $obj->getVendorListNewBasedOnID($rows['SHIPPER1']),$obj->getVendorListNewBasedOnID($rows['OWNER1']), $obj->getPortNameBasedOnID($arr_loadport[0]),$obj->getMaxETADate($rows['COMID'],"LP",$arr_loadport[0],$arr_loadport[1]), $cargos, $quantity,date('d-m-Y',strtotime($rows['LAYCAN_EDATE'])).'/'.date('d-m-Y',strtotime($rows['LAYCAN_EDATE'])), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"AGENT"), implode(', ',$broker_arr), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"DEMURRAGE RATE(USD/DAY)"), implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID'])),$obj->getCheckListPortDataRecordsRecBasedOnComID($rows['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"REMARKS TOWARDS LOAD PORT"));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						 $j++;
					}
			    }
		    }
		}
		if(!is_array($count_arr_lp1))
		{
			$pdf->SetX(5);
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFillColor(255,255,255);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		    $arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
			$arr3=array('-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-');
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
		
		$count_arr_lp2  = array();
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L');
		$arr2=array(288);
		$arr3=array("AT LOAD PORT");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
		$arr3=array("S. No.","Vessel","Nom ID/Voyage ID","Operator Name","Charterer", "Shipper","Owner","Port","ARRVD/ETC","Cargo","Qty(MT)" ,"Laycan", "Agent","Broker","Dem. Rate(USD/Day)","Dis Port(s)","Remarks");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$j=1;
		while($rows1 = mysql_fetch_assoc($res1))
		{
			$port_arr_lp       = $obj->getLoadPortArrBasedOnIDComidAndProcessWithoutTBN($rows1['COMID']);
			for($i=0;$i<count($port_arr_lp);$i++)
			{
				if($obj->getCheckListRecordsRecBasedOnComID($rows1['COMID']) > 0)
				{
					$arr_loadport      = explode('###',$port_arr_lp[$i]);
					$checklistid       = $obj->getCheckListRecordsDataBasedOnComID($rows1['COMID'],"CHECKLIST_ID");
					$actualarrival     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ACTUAL ARRIVAL");
					$vesselsailed      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"VESSEL SAILED");
					if($actualarrival!='' && $vesselsailed=="")
					{
						$count_arr_lp2[] = $j;
						$operator_arr[$rows1['OPERATOR']][] = 1;
						$cargos = $obj->getCargoNameListForMultipleNamemultiple($rows1['CARGOIDS']);
						$broker_arr = array();
						$fcaid = $obj->getLatestCostSheetID($rows1['COMID']);
						$sql_brok = "select VENDORID from freight_cost_estimete_slave4 where FCAID='".$fcaid."'";
						$res_brok = mysql_query($sql_brok);
						while($rows_brok = mysql_fetch_assoc($res_brok))
						{
							$broker_arr[] = $obj->getVendorListNewBasedOnID($rows_brok['VENDORID']);
						}
						
						$sql_qty = "select LOAD_PORT_QTY from freight_cost_estimete_slave1 where FROM_PORT='".$arr_loadport[0]."' and RANDOMID='".$arr_loadport[1]."' and FCAID='".$fcaid."'";
						$res_qty = mysql_query($sql_qty) or die($sql_qty);
						$rows_qty = mysql_fetch_assoc($res_qty);
						$quantity = $rows_qty['LOAD_PORT_QTY'];
						
						$arrival_date = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ACTUAL ARRIVAL");
						$etcd_date = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"ETC/D");
						if(date("d-m-Y",strtotime($arrival_date))!='01-01-1970'){$arrival_date =date("d-M-Y H:i",strtotime($arrival_date)); }
						if(date("d-m-Y",strtotime($etcd_date))!='01-01-1970'){$etcd_date = $arrival_date.'/'.date("d-M-Y H:i",strtotime($etcd_date)); }else{$etcd_date = $arrival_date;}
						$pdf->SetX(5);
						$pdf->SetFont('daxcondensedlight','',8);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetFillColor(255,255,255);
						$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
						$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
						$arr3=array($j,$obj->getVesselIMOData($obj->getCompareEstimateData($rows1['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$obj->getCompareTableData($rows1['COMID'],"MESSAGE").'/'.$rows1['VOYAGE_NO'],$rows1['OPERATOR1'],$obj->getVendorListNewBasedOnID($rows1['CHARTERER1']), $obj->getVendorListNewBasedOnID($rows1['SHIPPER1']),$obj->getVendorListNewBasedOnID($rows1['OWNER1']), $obj->getPortNameBasedOnID($arr_loadport[0]),$etcd_date, $cargos, $quantity,date('d-m-Y',strtotime($rows1['LAYCAN_EDATE'])).'/'.date('d-m-Y',strtotime($rows1['LAYCAN_EDATE'])), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"AGENT"), implode(', ',$broker_arr), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"DEMURRAGE RATE(USD/DAY)"), implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows1['COMID'])),$obj->getCheckListPortDataRecordsRecBasedOnComID($rows1['COMID'],$checklistid,"LP",$arr_loadport[0],$arr_loadport[1],"REMARKS TOWARDS LOAD PORT"));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						 $j++;
					}
			    }
		    }
		}
		if(!is_array($count_arr_lp2))
		{
			$pdf->SetX(5);
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFillColor(255,255,255);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		    $arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
			$arr3=array('-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-');
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
		
		
		
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',12);
	    $pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L');
		$arr2=array(288);
		$arr3=array("TOWARDS DISCHARGE PORT - AT SEA");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
		$arr3=array("S. No.","Vessel","Nom ID/Voyage ID","Operator Name","Charterer", "Shipper","Owner","Port","ETA","Cargo","Qty(MT)" ,"Laycan", "Agent","Broker","Dem. Rate(USD/Day)","Dis Port(s)","Remarks");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$j=1;
		while($rows2 = mysql_fetch_assoc($res2))
		{
			$port_arr_dp       = $obj->getDisPortArrBasedOnIDComidAndProcessWithoutTBN($rows2['COMID']);
			for($i=0;$i<count($port_arr_dp);$i++)
			{
				if($obj->getCheckListRecordsRecBasedOnComID($rows2['COMID']) > 0)
				{
					$arr_dischargeport = explode('###',$port_arr_dp[$i]);
					$checklistid   = $obj->getCheckListRecordsDataBasedOnComID($rows2['COMID'],"CHECKLIST_ID");
					$eta30days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 30 DAYS");
					$eta25days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 25 DAYS");
					$eta20days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 20 DAYS");
					$eta15days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 15 DAYS");
					$eta10days     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 10 DAYS");
					$eta7days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 7 DAYS");
					$eta5days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 5 DAYS");
					$eta3days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 3 DAYS");
					$eta2days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 2 DAYS");
					$eta1days      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETA 1 DAY");
					$actualarrival   = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ACTUAL ARRIVAL");
					if(($eta30days!='' && $actualarrival=="") || ($eta25days!='' && $actualarrival=="") || ($eta20days!='' && $actualarrival=="") || ($eta15days!='' && $actualarrival=="") || ($eta10days!='' && $actualarrival=="") || ($eta7days!='' && $actualarrival=="") || ($eta5days!='' && $actualarrival=="") || ($eta3days!='' && $actualarrival=="") || ($eta2days!='' && $actualarrival=="") || ($eta1days!='' && $actualarrival==""))
					{
						$count_arr_dp1[] = $j;
						
						$operator_arr[$rows2['OPERATOR']][] = 1;
						$cargos = $obj->getCargoNameListForMultipleNamemultiple($rows2['CARGOIDS']);
						
						$broker_arr = array();
						$fcaid = $obj->getLatestCostSheetID($rows2['COMID']);
						$sql_brok = "select VENDORID from freight_cost_estimete_slave4 where FCAID='".$fcaid."'";
						$res_brok = mysql_query($sql_brok);
						while($rows_brok = mysql_fetch_assoc($res_brok))
						{
							$broker_arr[] = $obj->getVendorListNewBasedOnID($rows_brok['VENDORID']);
						}
						$sql_qty = "select LOAD_PORT_QTY from freight_cost_estimete_slave1 where TO_PORT='".$arr_dischargeport[0]."' and RANDOMID='".$arr_dischargeport[1]."' and FCAID='".$fcaid."'";
						$res_qty = mysql_query($sql_qty) or die($sql_qty);
						$rows_qty = mysql_fetch_assoc($res_qty);
						$quantity = $rows_qty['LOAD_PORT_QTY'];
						
						$pdf->SetX(5);
						$pdf->SetFont('daxcondensedlight','',8);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		                $arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
						
						$arr3=array($j,$obj->getVesselIMOData($obj->getCompareEstimateData($rows2['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$obj->getCompareTableData($rows2['COMID'],"MESSAGE").'/'.$rows2['VOYAGE_NO'],$rows2['OPERATOR1'],$obj->getVendorListNewBasedOnID($rows2['CHARTERER1']), $obj->getVendorListNewBasedOnID($rows2['SHIPPER1']),$obj->getVendorListNewBasedOnID($rows2['OWNER1']), $obj->getPortNameBasedOnID($arr_dischargeport[0]),$obj->getMaxETADate($rows2['COMID'],"DP",$arr_dischargeport[0],$arr_dischargeport[1]), $cargos, $quantity,date('d-m-Y',strtotime($rows2['LAYCAN_EDATE'])).'/'.date('d-m-Y',strtotime($rows2['LAYCAN_EDATE'])), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"AGENT"), implode(', ',$broker_arr), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"DEMURRAGE RATE(USD/DAY)"), implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows2['COMID'])),$obj->getCheckListPortDataRecordsRecBasedOnComID($rows2['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"REMARKS TOWARDS DISCHARGE PORT"));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						 $j++;
					}
			    }
		    }
		}
		if(!is_array($count_arr_lp1))
		{
			$pdf->SetX(5);
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFillColor(255,255,255);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		    $arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
			$arr3=array('-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-');
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
		
		$count_arr_lp2  = array();
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L');
		$arr2=array(288);
		$arr3=array("AT DISCHARGE PORT");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetX(5);
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
		$arr3=array("S. No.","Vessel","Nom ID/Voyage ID","Operator Name","Charterer", "Shipper","Owner","Port","ARRVD/ETC","Cargo","Qty(MT)" ,"Laycan", "Agent","Broker","Dem. Rate(USD/Day)","Dis Port(s)","Remarks");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$j=1;
		while($rows3 = mysql_fetch_assoc($res3))
		{
			$port_arr_dp   = $obj->getDisPortArrBasedOnIDComidAndProcessWithoutTBN($rows3['COMID']);
			for($i=0;$i<count($port_arr_dp);$i++)
			{
				if($obj->getCheckListRecordsRecBasedOnComID($rows3['COMID']) > 0)
				{
					$arr_dischargeport = explode('###',$port_arr_dp[$i]);
					$checklistid       = $obj->getCheckListRecordsDataBasedOnComID($rows3['COMID'],"CHECKLIST_ID");
					$actualarrival     = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ACTUAL ARRIVAL");
					$vesselsailed      = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"VESSEL SAILED");
					if($actualarrival!= "" && $vesselsailed=="")
					{
						$count_arr_dp2[] = $j;
						
						$operator_arr[$rows3['OPERATOR']][] = 1;
						$cargos = $obj->getCargoNameListForMultipleNamemultiple($rows3['CARGOIDS']);
						
						$broker_arr = array();
						$fcaid = $obj->getLatestCostSheetID($rows3['COMID']);
						$sql_brok = "select VENDORID from freight_cost_estimete_slave4 where FCAID='".$fcaid."'";
						$res_brok = mysql_query($sql_brok);
						while($rows_brok = mysql_fetch_assoc($res_brok))
						{
							$broker_arr[] = $obj->getVendorListNewBasedOnID($rows_brok['VENDORID']);
						}
						$sql_qty = "select LOAD_PORT_QTY from freight_cost_estimete_slave1 where TO_PORT='".$arr_dischargeport[0]."' and RANDOMID='".$arr_dischargeport[1]."' and FCAID='".$fcaid."'";
						$res_qty = mysql_query($sql_qty) or die($sql_qty);
						$rows_qty = mysql_fetch_assoc($res_qty);
						$quantity = $rows_qty['LOAD_PORT_QTY'];
						
						$arrival_date = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ACTUAL ARRIVAL");
						$etcd_date = $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"ETC/D");
						if(date("d-m-Y",strtotime($arrival_date))!='01-01-1970'){$arrival_date =date("d-M-Y H:i",strtotime($arrival_date)); }
						if(date("d-m-Y",strtotime($etcd_date))!='01-01-1970'){$etcd_date = $arrival_date.'/'.date("d-M-Y H:i",strtotime($etcd_date)); }else{$etcd_date = $arrival_date;}
						
						$pdf->SetX(5);
						$pdf->SetFont('daxcondensedlight','',8);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
						$arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
						
						$arr3=array($j,$obj->getVesselIMOData($obj->getCompareEstimateData($rows3['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$obj->getCompareTableData($rows3['COMID'],"MESSAGE").'/'.$rows3['VOYAGE_NO'],$rows3['OPERATOR1'],$obj->getVendorListNewBasedOnID($rows3['CHARTERER1']), $obj->getVendorListNewBasedOnID($rows3['SHIPPER1']),$obj->getVendorListNewBasedOnID($rows3['OWNER1']), $obj->getPortNameBasedOnID($arr_dischargeport[0]), $etcd_date, $cargos, $quantity, date('d-m-Y',strtotime($rows3['LAYCAN_EDATE'])).'/'.date('d-m-Y',strtotime($rows3['LAYCAN_EDATE'])), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"AGENT"), implode(', ',$broker_arr), $obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"DEMURRAGE RATE(USD/DAY)"), implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows3['COMID'])),$obj->getCheckListPortDataRecordsRecBasedOnComID($rows3['COMID'],$checklistid,"DP",$arr_dischargeport[0],$arr_dischargeport[1],"REMARKS AT DISCHARGE PORT"));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
						 $j++;
					}
			    }
		    }
		}
		if(!is_array($count_arr_lp2))
		{
			$pdf->SetX(5);
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFillColor(255,255,255);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
		    $arr2=array(16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17);
			$arr3=array('-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-');
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
		}
		
		
		
	}
	
	
	
	$pdf->AddPage('L');
	$pdf->Ln(10);
	$pdf->SetFont('daxcondensedlight','',12);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L');
	$arr2=array(100);
	$arr3=array("NO. OF VESSELS PER OPERATOR");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->SetFillColor(255,255,255);
	$arr1=array('L','L');
	$arr2=array(50,50);
	$arr3=array("Operator","No. Of Vessels");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql4 = "select LOGINID, CONTACT_PERSON from login where STATUS=1 and USER_TYPE='internal_user'";
	$res4 = mysql_query($sql4);$sum = 0;
	while($rows4 = mysql_fetch_assoc($res4))
	{
		$pdf->SetFont('daxcondensedlight','',9);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R');
		$arr2=array(50,50);
		
		$arr3=array($rows4['CONTACT_PERSON'],count($operator_arr[$rows4['LOGINID']]));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		$sum = $sum + count($operator_arr[$rows4['LOGINID']]);
	}
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','R');
	$arr2=array(50,50);
	
	$arr3=array("Total",$sum);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
    $filename = "Daily Position Report.pdf";
	$pdf->Output($filename,'D');
}


function getDecisionChartList()
{	
	$obj 			= new data();
    $val   =  $_REQUEST['val'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Decision Chart List Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Decision Chart List Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Decision Chart List",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(5,20,20,20,20,20,20,20,20,20,20,20,20,20,10);
	if($_SESSION['selBType']==1)
	{
		$freighttext = 'Base Freight (USD/MT)/ Lumpsum (USD)';
	}
	if($_SESSION['selBType']==3)
	{
		$freighttext = 'Freight (USD/MT)';
	}
	if($_SESSION['selBType']==2)
	{
		$freighttext = 'WS/Lumpsum (USD/MT)';
	}
	$arr3=array("S.No.","Vessel Name","Sheet Name","DWT",$freighttext, "Delivery Port","LP/DP","Duration","Cargo Quantity","TCE","Daily Time Charter (USD/Day)" ,"P/L", "Status","Remarks","Select");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	$val   =  $_REQUEST['val'];
	$val2   =  $_REQUEST['val2'];
	if(strlen($val2) ==1){$val2 = "00".$val2;}
	if(strlen($val2) ==2){$val2 = "0".$val2;}
	if(strlen($val2) >2){$val2 = $val2;}
	$sql1 = "select * from freight_cost_estimate_compare WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and MESSAGE ='".$val."-".$val2."' ";
	$res1 = mysql_query($sql1) or die();
	$arr = array();
	while($row1 = mysql_fetch_assoc($res1))
	{
		$arr[] = $row1['FCAID'];
	}
	$arr1 = implode(',',$arr);
	
	
	$sql = "select * from freight_cost_estimete_master WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and FCAID in (".$arr1.") order by FCAID desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$i = 1;
	while($rows = mysql_fetch_assoc($res))
	{
		$arr_ballast = $arr_load = $arr_discharge = array();
		$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$rows['FCAID']."'";
		$res1 = mysql_query($sql1);
		while($rows1 = mysql_fetch_assoc($res1))
		{
			if($rows1['LOAD_PORT_QTY']>0)
			{
			  $arr_load[] = $obj->getPortNameBasedOnID($rows1['FROM_PORT']);
			}
			if($rows1['DISC_PORT_QTY']>0)
			{
			  $arr_discharge[] = $obj->getPortNameBasedOnID($rows1['TO_PORT']);
			}
			if($rows1['PASSAGE_TYPE'] == 1)
			{
				$arr_ballast[] = $obj->getPortNameBasedOnID($rows1['FROM_PORT']);
			}
		}
		
		$sql2 = "select * from freight_cost_estimate_compare WHERE MESSAGE ='".$val."-".$val2."' and FCAID='".$rows['FCAID']."' ";
		$res2 = mysql_query($sql2);
		$row2 = mysql_fetch_assoc($res2);
		if($rows['FIXED']==1){$fixed = "Finalised";}else{$fixed = "Not Fixed";}
		if($row2['FCAID']==$row2['FINAL_ID']){$checked = "Yes";}else{$checked = "";}
		
		
		$quantity = 0;$freight = 0;
		if($rows['ESTIMATE_TYPE']==1)
		{
			$quantity = $rows['GAS_QUANTITY'];
			if($rows['GAS_MARKET']==1){$freight = 'Base Freight '.$rows['GAS_BASE_RATE'];}else{$freight = 'Lumpsum '.$rows['GAS_LUMSUM'];}
		}
		else if($rows['ESTIMATE_TYPE']==2)
		{
			$quantity = $rows['TANK_QUANTITY'];
			if($rows['TANKER_RADIO_SINGLE_DIS']==1)
			{
				$sql21 = "select MIN_WS from freight_cost_estimete_slave12 where FCAID='".$rows['FCAID']."' ";
				$res21 = mysql_query($sql21);
				$row21 = mysql_fetch_assoc($res21);
				if($rows['CHK_LUMPSUM']==1){$freight = 'Lumpsum '.$rows['LUMPSUMAMT'];}else{$freight = 'WS '.$row21['MIN_WS'];}
			}
			else
			{
				$sql12 = "select sum(AMOUNT_USD) as sum1 from freight_cost_estimete_slave10 where FCAID='".$rows['FCAID']."'";
				$res12 = mysql_query($sql12);
				$row12 = mysql_fetch_assoc($res12);
				$freight = 'Lumpsum '.$row12['sum1'];
			}
		}
		else
		{
			if($rows['QTY_TYPE_RADIO'] == 1)
			{
				$quantity = $rows['QUANTITY'];
				$freight = $rows['FREIGHT_GROSS'];
			}
			else
			{
				$sql12 = "select sum(QUANTITY) as sum, sum(GROSS_FREIGHT) as sum1 from freight_cost_estimete_slave7 where FCAID='".$rows['FCAID']."'";
				$res12 = mysql_query($sql12);
				$row12 = mysql_fetch_assoc($res12);
				$quantity = $row12['sum'];
				$freight = $row12['sum1'];
			}
		}
		
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	    $arr2=array(5,20,20,20,20,20,20,20,20,20,20,20,20,20,10);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($i,$obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"VESSEL_NAME"),$rows['VOYAGE_NAME'],$obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"DWT"),$freight,implode(', ',$arr_ballast),implode(', ',$arr_load).'/ '.implode(', ',$arr_discharge),$rows['TOTAL_DAYS'],$quantity,$rows['DAILY_EARNING'],$rows['DAILY_VESSEL_OPERATION_EXP'],$rows['PROFIT_LOSS'],$fixed,$row2['REMARKS'],$checked);
		
		$pdf->Row2($arr3);
		$i++;
	}	
	
	
	$filename = "Decision_Chart.pdf";

	$pdf->Output($filename,'D');
}


function getDecisionChart()
{	
	$obj 			= new data();

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Decision Chart List Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Decision Chart List Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(0,6,"Decision Chart List",0,1,'C');
					
	$arr1 = $arr2 = $arr3 = array();
	
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(25,35,35,30,35,45,35,35);
	$arr3=array("S.No.","Decision Chart","Chart No.","Voyage No.","Vessel","LP/DP","Add On Date","Added By");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql = "select MESSAGE, MESSAGE_NO, freight_cost_estimate_compare.ADD_ON_DATE, USERID, freight_cost_estimate_compare.COMID, freight_cost_estimate_compare.FINAL_ID 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 FINAL_ID !='' and freight_cost_estimete_master.ESTIMATE_TYPE='".$_SESSION['selBType']."' order by freight_cost_estimate_compare.ADD_ON_DATE desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	
	$j =0;
	while($rows = mysql_fetch_assoc($res))
	{$j =$j +1;
		$sql1 = "SELECT FCAID, (select VESSEL_NAME from vessel_imo_master where vessel_imo_master.VESSEL_IMO_ID=freight_cost_estimete_master.VESSEL_IMO_ID) as VESSEL_NAME, VOYAGE_NO FROM freight_cost_estimete_master WHERE FCAID= ".$rows['FINAL_ID'];
		$res1 = mysql_query($sql1) or die($sql1);
		$rows1 = mysql_fetch_assoc($res1);
		$loadports = $obj->getLoadPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID']);
		$disports = $obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID']);
		
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L');
	    $arr2=array(25,35,35,30,35,45,35,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($j,$rows['MESSAGE'],$rows['MESSAGE_NO'],$rows1['VOYAGE_NO'],$rows1['VESSEL_NAME'],implode(',',$loadports).' / '.implode(',',$disports),date('d-m-Y',strtotime($rows['ADD_ON_DATE'])),$obj->getUserDetailBaseOnId($rows['USERID'],'CONTACT_PERSON'));
		
		$pdf->Row2($arr3);
	}
	
	$filename = "Decision_Chart.pdf";

	$pdf->Output($filename,'D');

}



function DumerageInvoicepdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];
    $sql = "select * from other_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
	$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddr']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddr'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	
	$sql = "select * from other_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
	$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);

	$lp_name = array(); 
	$dp_name = array();
	
	if($rows['I_TYPE']=='Credit'){
		$invtitle = 'Credit Note';
		$inv_amt_title = 'to Credit';
	}else{
		$invtitle = 'Invoice';
		$inv_amt_title = 'Invoiced';
	}
	
	$discharge_port = "";
	
	for($j=0;$j<count($arr);$j++)
	{   
		$arr_explode = explode('@@',$arr[$j]);
		if($arr_explode[0] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
		if($arr_explode[0] == "DP"){$dp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
	}
	
	$lp_name  = implode(', ',$lp_name);
	$dp_name  = implode(', ',$dp_name);
	
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Other '.$invtitle.' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Other '.$invtitle.' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." No.",$rows['MESSAGE'],"Contract Ref.","CP Date ".date("d-m-Y",strtotime($obj->getFun3()))));
	$invdate = date('d-m-Y',strtotime($rows['DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	$duedate = date('d-m-Y',strtotime($rows['DUE_DATE'])); if($duedate=='01-01-1970'){$duedate = '';}
	$pdf->Row(array($invtitle." Date",$invdate,"Due Date",$duedate));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$invtitle." Type","Other"));
	$pdf->Row(array("Port of Loading",$lp_name,"Port of Discharging",$dp_name));
	$pdf->Row(array("Voyage Number ",$obj->getFun8(),"",""));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." To:",$invtitle." From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($rows['VENDOR'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'STREET_1')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'COUNTRY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY_POSTAL_CODE')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
		
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['REMARKS'],$rows['GROSS_AMT']));

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from other_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
	    $pdf->SetTextColor(0,0,0);
		$arr1=array('L','R');
		$arr2=array(150,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],$rows2['AMOUNT']));
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from other_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
	    $pdf->SetTextColor(0,0,0);
		$arr1=array('L','R');
		$arr2=array(150,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],$rows2['AMOUNT']));
	}
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount ".$inv_amt_title,$rows['NET_PAYABLE']));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount ".$inv_amt_title." (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE']),2,'.','')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['NET_PAYABLE'],$currency))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated ".strtolower($invtitle)." and no signatures are required",0,1,'L',0);
	
$filename = $invtitle." Of ".$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME")."(".$rows['I_TYPE'].") ".$obj->getFun8()." ".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}





function getBunkeringAgentPDF()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$port_type 						= $_REQUEST['port_type'];
	$randomno                       = $_REQUEST['randomno'];
	$sql 							= "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	
	$sql2 							= "select * from generate_agency_letter_slave2 where GEN_AGENCY_ID='".$g_agency_id."'";
	$res2 							= mysql_query($sql2);
	$rows2 							= mysql_fetch_assoc($res2);
	
	$vslid 							= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$_SESSION['vslName'] 			= $obj->getVesselIMOData($vslid,"VESSEL_NAME");
	$_SESSION['portname'] 			= $obj->getPortName($rows['PORTID']);
	$_SESSION['email'] 				= $rows['EMAIL_ADDRESS'];
	$_SESSION['vslconInfo'] 		= $rows['VSL_CONTACT_DETAILS'];
	$_SESSION['vslinfo'] 			= $rows['VSL_DETAILS'];
	$_SESSION['about'] 				= $rows['VSL_ABOUT'];
	$_SESSION['hsfoQty'] 			= $rows['BA_HSFO_QTY'];
	$_SESSION['supplier'] 			= $rows['BA_SUPPLIER_T_B_AD'];
	$_SESSION['necessary'] 			= $rows['BA_NECESSARY_GUID'];
	
	$_SESSION['bunkeringport'] 		= $obj->getPortNameBasedOnCode($rows2['BUNKERPORT']);
	
	
	$cost_sheet_id 					= $obj->getLatestCostSheetID($rows['COMID']);
							  		  $obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	$_SESSION['quantity'] 			= $rows['QTY'];
	$_SESSION['cargo_name']         = $obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($rows['COMID'],"MATERIALID")));
	$agent_code						= $_REQUEST['agent_code'];
	$_SESSION['agent_name']      	= $obj->getVendorListNewData($agent_code,"NAME");
	
	if(@$_REQUEST['port_type'] =="TP"){
		$qtyCargo					= "...........";
	}else{
		$qtyCargo 					= $_SESSION['quantity']." MT (".$_SESSION['cargo_name'].").WP WOG UCAE.";
	}
	
	$charterer_name 		= "";
	
	if($obj->getFun31()==1)
	{
		$charterer_name = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"QTY_VENDORID"));
	}
	else
	{
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$charterer_name = $charterer_name.", ".$obj->getVendorListNewBasedOnID($rows2['VENDORID']);
		}
	}

    $eta_fixture   = date('d-m-Y',strtotime($rows['ETA_DATE']));
	if($eta_fixture=="01-01-1970")
	{
		$eta_fixture="00:00";
	}
	else
	{
		$eta_fixture=date('d-m-Y H:i',strtotime($rows['ETA_DATE']));
	}

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			//$this->Cell(170,6,"SOCATRA ",0,1,'C',0);
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Agency Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Agency Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetFillColor(0,0,0);
	$pdf->Ln(2);
	$pdf->Cell(190,6,"Letter to Agents for ".$_SESSION['vslName']." at ".$_SESSION['bunkeringport']." for bunkering ",0,1,'C');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Ln(2);
	$pdf->Cell(190,5,"To : ",0,1,'L');
	
	$pdf->Cell(190,5,"".$_SESSION['agent_name'],0,1,'L');
	$arr1 = $arr2 = $arr3 = array();	
	$addr_arr = explode(",",$obj->getVendorListNewData($rows['VENDORID'],"STREET_1")); 
	
	for($i=0; $i<=count($addr_arr); $i++){
		$addr = trim($addr_arr[$i]);	
		$pdf->Row1(array("".$addr));
	}
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->Ln(-6);
	$pdf->Cell(190,6,"".$obj->getVendorListNewData($rows['VENDORID'],"STREET_2"),0,1,'L');
	
	$pdf->Ln(-1);
	$pdf->Cell(190,5,"From : ",0,1,'L');
	$pdf->Cell(190,5,"PROGRESS SHIPPING",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->Cell(25,6,"Good day,",0,1,'L');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("As owners/disponent owners of the captioned vessel, we are pleased to consign the vessel to your agency during her bunker supply at ".$_SESSION['bunkeringport'].". Vessel ETA at ".$_SESSION['bunkeringport']." around ".$eta_fixture." LT."));
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(2);
	$pdf->Row1(array("1)Please declare the vessel to port and contact master for pre-arrival formalities without delay."));
	$pdf->Ln(2);
	$pdf->Row1(array("2) Vessel particulars are stated below:"));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->Cell(190,4,"VESSEL NAME : ".strtoupper($_SESSION['vslName']),0,1,'L');
	$pdf->Cell(190,4,"FLAG : ".strtoupper($obj->getCountryNameOnId($obj->getVesselIMOData($vslid,"FLAG"))),0,1,'L');
	$pdf->Cell(190,4,"CLASS : ".strtoupper($obj->getClaSocNameOnId($obj->getVesselIMOData($vslid,"CLA_SOC_ID"))),0,1,'L');
	$pdf->Cell(190,4,"BUILT (WHEN/WHERE) : ".$obj->getVesselIMOData($vslid,"YEARBUILT")."/".strtoupper($obj->getCountryNameOnId($obj->getVesselParticularData('COUNTRY_ID','vessel_master_1',$vslid)))."/".strtoupper($obj->getVesselParticularData('YARD_NAME','vessel_master_1',$vslid)),0,1,'L');
	$pdf->Cell(190,4,"IMO NUMBER : ". $obj->getVesselIMOData($vslid,"IMO_NO")."",0,1,'L');
	if($obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('REGISTRY_PORT','vessel_master_tankers',$vslid))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vslid,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vslid)." MT / ".$obj->getVesselIMOData($vslid,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vslid)." MT",0,1,'L');
	}else{
		$pdf->Cell(190,4,"PORT OF REGISTRY : ".strtoupper($obj->getPortName($obj->getVesselParticularData('PORT_ID','vessel_master_1',$vslid))),0,1,'L');
		$pdf->Cell(190,4,"SUMMER: DEADWEIGHT / DISPLACEMENT / DRAFT / TPC : ".strtoupper($obj->getVesselIMOData($vslid,"DWT"))." MT / ".$obj->getVesselParticularData('DISPLACEMENT','vessel_master_1',$vslid)." MT / ".$obj->getVesselIMOData($vslid,"DRAFTM")." M / ".$obj->getVesselParticularData('SUMMER_3','vessel_master_1',$vslid)." MT",0,1,'L');
	}
	
	$tonnage = $obj->getVesselIMOData($vslid,"GRT_NRT");
	$tonnage1 = $obj->getVesselIMOData($vslid,"NRT");
	if($obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==3)
	{
		$pdf->Cell(190,4,"CARGO HOLD CAPACITY (GRAINS) : ".$obj->getVesselIMOData($vslid,"GRAIN")." MT",0,1,'L'); 
		$pdf->Cell(190,4,"NO.OF HOLDS / NO. OF HATCHES : ". $obj->getVesselIMOData($vslid,"NOH")."/".$obj->getVesselIMOData($vslid,"NOHA"),0,1,'L');
	}
	if($obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==1)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (98PCT) : ".$obj->getVesselIMOData($vslid,"GAS_TANK_CAPACITY")." CBM",0,1,'L'); 
	}
	if($obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CARGO TANK CAPACITY (TANKER) : ".$obj->getVesselIMOData($vslid,"TANKER_CAPACITY")." CBM",0,1,'L');
		$pdf->Cell(190,4,"NO. OF CARGO PUMPS / NO. OF GRADES(DOUBLE V/V SEG) : ".$obj->getVesselIMOData($vslid,"TANKER_CARGO_PUMP")."/".$obj->getVesselIMOData($vslid,"NO_OF_GRADE"),0,1,'L');
	}
	$pdf->Ln(1);
	$pdf->Cell(190,4,"GROSS TONNAGE : ".$tonnage."",0,1,'L');
	$pdf->Cell(190,4,"NET TONNAGE : ".$tonnage1."",0,1,'L');
	$pdf->Cell(190,4,"PANAMA TONNAGE : ".$obj->getVesselParticularData('GT_PANAMA','vessel_master_1',$vslid)."",0,1,'L');
	$pdf->Cell(190,4,"SUEZ CANAL TONNAGE : ".$obj->getVesselParticularData('GT_SUEZ','vessel_master_1',$vslid)."",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (O.A.) : ".$obj->getVesselIMOData($vslid,"LOA")." M",0,1,'L');
	$pdf->Cell(190,4,"LENGTH (P.P) : ".$obj->getVesselParticularData('LBW','vessel_master_1',$vslid)." M",0,1,'L');
	$pdf->Cell(190,4,"BREADTH(MLD.) : ".$obj->getVesselIMOData($vslid,"EXT_BREADTH")." M",0,1,'L');
	$pdf->Cell(190,4,"DEPTH (MLD.) : ".$obj->getVesselParticularData('DEPTH_MODULE','vessel_master_1',$vslid)." M",0,1,'L');
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Cell(190,4,"Vsl communication details: ",0,1,'L');
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	if($obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==1 || $obj->getVesselIMOData($vslid,"BUSINESSTYPEID")==2)
	{
		$pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_tankers',$vslid)."",0,1,'L');
		//$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_tankers',$vslid)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_tankers',$vslid),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('PHONE_NO','vessel_master_tankers',$vslid)."/".$obj->getVesselParticularData('TELEX_NO','vessel_master_tankers',$vslid),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAXNO','vessel_master_tankers',$vslid),0,1,'L');
		//$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_tankers',$vslid),0,1,'L');
	}else{
	    $pdf->Cell(190,4,"CALL SIGN :	".$obj->getVesselParticularData('CALL_SIGN','vessel_master_6',$vslid)."",0,1,'L');
		$pdf->Cell(190,4,"MMSI NO : ".$obj->getVesselParticularData('MMSI_NUMBER','vessel_master_6',$vslid)."",0,1,'L');
		$pdf->Cell(190,4,"E-MAIL : ".$obj->getVesselParticularData('EMAIL_ADDRESS','vessel_master_6',$vslid),0,1,'L');
		$pdf->Cell(190,4,"INM-F TEL : ".$obj->getVesselParticularData('TELEX_NUMBER','vessel_master_6',$vslid),0,1,'L');
		$pdf->Cell(190,4,"INM-F FAX : ".$obj->getVesselParticularData('FAX_NUMBER','vessel_master_6',$vslid),0,1,'L');
		$pdf->Cell(190,4,"INM-C : ".$obj->getVesselParticularData('INMARSAT_NUMBER','vessel_master_6',$vslid),0,1,'L');
	}
	
	$pdf->Ln(2);
	$pdf->Row1(array("3) Please contact vessel master directly for regular updates on ETA. Keep us in copy."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Bunker supply details –"));
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$arr1=array('L','L','L','L');
	$arr2=array(50,50,50,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array('FUEL GRADE/SPEC','SUPPLIER','PHYSICAL','QUANTITY(MT)'));
	
	$sql2 	= "select * from generate_agency_letter_slave2 where GEN_AGENCY_ID='".$g_agency_id."'";
	$res2 	= mysql_query($sql2);
	while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->Row(array($rows2['GRADE'],$rows2['SUPPLIER'],$rows2['PHYSICAL'],$rows2['QUANTITY']));
	}
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(2);
	$pdf->Row1(array("4) Notices: Once bunker supplier details are received, please send relevant notices to bunker suppliers with copy to us. The barge schedule and activity should also be shared with us regularly."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("5)Please appoint bunker surveyor stated below at ".$_SESSION['bunkeringport']." Our operations department will contact the surveyor for necessary guidelines."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("  Bunker Surveyor (Name) :".$rows['BUNKER_SURVEYOR']));
	$pdf->Row1(array("  Bunker Surveyor (Company and Contact) :".$rows['BUNKER_SURVEYORCOM']));
	
	
	$pdf->Ln(2);
	$pdf->Row1(array("6) Please advise bunker survey fees in the PDA/FDA submission."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("7) Please send all bunker related vouchers, receipts and survey report to our operations department, within 30 days. Meanwhile, PDFs of these to be sent to us via email, upon completion."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("8) Details of boarding officer, if any, to be shared with us."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Please confirm safe receipt of our message by return email."));
	$pdf->Row1(array("Many thanks and we look forward to a speedy and cost-effective turnaround of the vessel under your agency."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Kind regards,"));
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME")));
	
	
	$pdf->Ln(6);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(50,50,90);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Username: ".$rows['USERNAME'],"Password: ".$rows['PASSWORD'],""));
	$pdf->Ln(2);
	$pdf->SetTextColor(027,119,166);
	$link='https://progress.sevenoceansgenesis.com/agentlogin.html';
	$pdf->SetLink($link);
	$pdf->Write(4,'Click here to login',$link);
	

$filename = "Letter to Agents - Bunker Stemmed ( ".$_SESSION['vslName']." - ".$obj->getVendorListNewBasedOnID($rows['VENDORID'])." ) ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}


function get_coa_pdf(){
	$obj = new data();
	$obj->funConnect();
	$coaid = @$_REQUEST['coaid'];
	$obj->viewCOARecords($coaid);
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();
	$pdf->AddPage('P');
	
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Charter Out Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Charter Out Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************COA*************************/
	$pdf->Ln(2);
	$arr1 = $arr2 = $arr3 = array();
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(25,6,30,25,6,30,25,6,30);
	$arr3=array("Cargo/Material Type",":",$obj->getCargoTypeNameBasedOnID($obj->getFun25()),"Vessel Category",":",$obj->getVesselCategoryTypeBasedOnId($obj->getFun26()));	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);

	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(25,6,30,25,6,30,25,6,30);
	$arr3=array("COA Number",":",$obj->getFun1(),"COA CP Date",":",date("d-m-Y",strtotime($obj->getFun2())),"Cargo Qty(MT)",":",$obj->getFun3());	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr3=array("Owner",":",$obj->getVendorListNewData($obj->getFun4(),"name"),"Broker",":",$obj->getVendorListNewData($obj->getFun5(),"name"),"Charterer",":",$obj->getVendorListNewData($obj->getFun6(),"name"));	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr3=array("No. of Shipments",":",$obj->getFun7(),"Shipment Qty(MT)",":",$obj->getFun8(),"Tolerance(%)",":",$obj->getFun9());	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr3=array("Shipment (s)",":",$obj->getFun10(),"Per/Month",":",$obj->getFun11(),"Starting Date",":",date("d-m-Y",strtotime($obj->getFun12())));	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr3=array("Notice(Days)",":",$obj->getFun13(),"Freight Rate(USD/MT)",":",$obj->getFun14(),"","","");	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr3=array("Demurrage Rate",":",$obj->getFun16(),"Dispatch Rate",":",$obj->getFun17(),"Add Comm(%)",":",$obj->getFun18());	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	if(($obj->getFun20() != '') || ($obj->getFun21() != '') || ($obj->getFun22() != '')){
		
		$arr3=array("Bunker Price IFO(USD/MT)",":",$obj->getFun20(),"BAF Terms(Days)",":",$obj->getFun21(),"BAF(USD/MT)",":",$obj->getFun22());	
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(2);
	
	$arr1=array('L','C','L');
	$arr2=array(25,6,80);
	$arr3=array("Remarks",":",$obj->getFun23());	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$filename = 'COA '.date("d-m-Y").'.pdf';
	$pdf->Output($filename,'D');
	
	
}



function getBunkeragencynominationReport()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$port_type 						= $_REQUEST['port_type'];
	$port_name 						= explode("-",$_REQUEST['port_name']);
	$sql 							= "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	$id 							= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$_SESSION['vslName'] 			= $obj->getVesselIMOData($id,"VESSEL_NAME");
	$_SESSION['portname'] 			= $obj->getPortName($rows['PORTID']);
	
	$cost_sheet_id 					= $obj->getLatestCostSheetID($rows['COMID']);
							  		  $obj->viewFreightEstimationRecords($rows['COMID'],$cost_sheet_id);
	$_SESSION['quantity'] 			= $obj->getFun15();
	$_SESSION['cargo_name'] 		= $obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($rows['COMID'],"MATERIALID")));
	
	$_SESSION['Supplier_Physical'] 	= $rows['BS_SUPPLIER']."/".$rows['BS_PHYSICAL'];
	$_SESSION['Fuel_GRADE_SPEC'] 	= $rows['BS_FUEL_GR_SP'];
	$_SESSION['Quantity'] 			= $rows['BS_QUANTITY'];
	$_SESSION['Dolor_Applicable'] 	= $rows['BS_DOLOR_APP'];
	$_SESSION['Port_Name'] 			= $port_name[1];
	
	$agent_code						= $_REQUEST['agent_code'];
	$_SESSION['agent_name']      	= $obj->getVendorListNewData($agent_code,"NAME")." (".$agent_code.")";
	
	$charterer_name = "";
	
if($obj->getFun31()==1)
{
	$charterer_name = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"QTY_VENDORID"));
}
else
{
	$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
	$res12 = mysql_query($sql12);
	$rec12 = mysql_num_rows($res12);
	
	while($rows2 = mysql_fetch_assoc($res12))
	{
		$charterer_name = $charterer_name.", ".$obj->getVendorListNewBasedOnID($rows2['VENDORID']);
	}
}

$eta_fixture = $obj->getCompareEstimateData($rows['COMID'],"ETA_DATE");
if($eta_fixture=="")
{
	$eta_fixture="";
}
else
{
	$eta_fixture=date('d-m-Y',strtotime($eta_fixture));
}

class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Bunker agency nomination Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Bunker agency nomination Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Ln(2);
	$pdf->Cell(190,5,"To :",0,1,'L');

	$pdf->Cell(190,5,"".$_SESSION['vslName'],0,1,'L');
	
		
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$pdf->Ln(1);
	$pdf->Cell(190,5,"From :",0,1,'L');
	$pdf->Cell(190,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,1,'L');
	
	$pdf->Ln(1);
	$pdf->Cell(25,5,"Good day Capt.,",0,1,'L');
	
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("We have stemmed bunkers to be delivered at ".$_SESSION['Port_Name']." as follows in order to make BOD=BOR: "));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(000,000,000);
	$arr1=array('C','C','C','C');
	$arr2=array(63,63,62);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("FUEL GRADE/SPEC","SUPPLIER/PHYSICAL","QUANTITY (MTONS)"));	
	$arr1=array('C','C','C','C');
	$arr2=array(63,63,62);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($_SESSION['Fuel_GRADE_SPEC'],$_SESSION['Supplier_Physical'],$_SESSION['Quantity']));
	
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('daxcondensedlight','',9);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(194);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Ln(1);
	$pdf->Cell(190,6,"Agents: ",0,1,'L');
	$pdf->Row1(array("".$obj->getVendorListNewBasedOnID($rows['VENDORID'])));
	if($obj->getVendorListNewData($rows['VENDORID'],"STREET_1")!="")
	$addr_arr = explode(",",$obj->getVendorListNewData($rows['VENDORID'],"STREET_1")); 
	
	for($i=0; $i<=count($addr_arr); $i++){
		$addr = trim($addr_arr[$i]);	
		$pdf->Row1(array("".$addr));
	}
	
	$pdf->Ln(-6);
	
	if($obj->getVendorListNewData($rows['VENDORID'],"PHONE")!="")
	$pdf->Row1(array("Phone : ".$obj->getVendorListNewData($rows['VENDORID'],"PHONE")));
	if($obj->getVendorListNewData($rows['VENDORID'],"FAX")!="")
	$pdf->Row1(array("Fax : ".$obj->getVendorListNewData($rows['VENDORID'],"FAX")));
	if($obj->getVendorListNewData($rows['VENDORID'],"EMAILID")!="")
	$pdf->Row1(array("Email : ".$obj->getVendorListNewData($rows['VENDORID'],"EMAILID")));
	if($obj->getVendorListNewData($rows['VENDORID'],"STREET_2")!="")
	$pdf->Row1(array("PIC : ".$obj->getVendorListNewData($rows['VENDORID'],"STREET_2")));
	$pdf->Ln(2);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	
	$pdf->Row1(array("Please coordinate with the agents for prompt delivery avoiding any delays and keep them regularly posted with your eta."));
	
	$pdf->Row1(array("On completion of bunkering provide us with associated delivery receipts and bunkering message as per charterers' standing instructions."));
	
	
	$pdf->Row1(array("For the agents:"));
	
	
	$pdf->Row1(array("Please coordinate with the suppliers and the master and do your utmost the bunkers to be delivered without delays."));
	

	$pdf->Row1(array("Important"));
	
	$pdf->Row1(array("  - Please ensure that you liaise closely with suppliers to arrange final quantities and timings for an expeditious supply. "));
	
	
	$pdf->Row1(array("  - In the event of delivery by barge, barge figures and barge crew drawn samples which are duly witnessed by vessel's chief engineer or his representative"));
	
	
	$pdf->Row1(array("  - Please ensure crew/vessel's representative witnesses on the supplier's delivery equipment:"));
	
	
	$pdf->Row1(array("a) The drawing by the supplier of the representative samples of each of the fuels to be supplied and receives and retains a sealed and signed container of each of those samples and"));
	
	
	
	$pdf->Row1(array("b) The soundings and measurements of quantities before and after delivery."));
	
	$pdf->Row1(array("Samples"));
	
	$pdf->Row1(array("Pls ensure that:"));
	
	$pdf->Row1(array("A sample, in addition to that for Marpol, is drawn for ship's use and kept in vessel's inventory for further reference"));
	
	$pdf->Row1(array("Quantity determination procedures:"));
	
	$pdf->Row1(array("Please note that in order to have the evidence to claim potential short supply from suppliers/bunker barge following measuring procedures must be followed:"));
	
	$pdf->Row1(array("The procedures are based on the supplier's terms and conditions and according to those terms bunker quantity shall be determined at suppliers option from the gauge or meter of shore or bunker barge tanks."));
	
	$pdf->Row1(array("The supplier's determination of quantity shall be final and conclusive, but the receiver shall have the right to attend the measuring at shore or barge tanks."));

	$pdf->Row1(array("Any challenge by the receiver of the said measurement shall be admissible only if made to the supplier's representative and noted in the delivery receipt at the time of delivery."));
	
	
	$pdf->Row1(array("Basis the above clause it is beyond any doubt and common practice that the vessel in order to be able to challenge suppliers figures and put a notice on delivery receipt, should have exercised her right to witness the barge figures prior and after bunkering replenishment apart from usual vessel's tanks checking. Bunker suppliers back to back terms & conditions to apply."));
	
	$pdf->Ln(2);
	$pdf->Row1(array("Pls acknowledge receipt of the mail."));
	$pdf->Row1(array("Best regards"));
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS")));
		
$filename = "Letter to Master - Bunker Stemmed(".$_SESSION['vslName']."-".$obj->getVendorListNewBasedOnID($rows['VENDORID']).") ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}



function create_generate_agency_letter_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
	$randomno                   = $_REQUEST['randomno'];
	$comid 						= $_REQUEST['comid'];
	$port_type 					= $_REQUEST['port_type'];
	
	$sql 							= "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
	$res 							= mysql_query($sql);
	$rows 							= mysql_fetch_assoc($res);
	$id 							= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$_SESSION['vslName'] 			= $obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME");
	$_SESSION['portname'] 			= $obj->getPortName($rows['PORTID']);
	$_SESSION['kind_attan_to']		= $rows['KIND_ATTN_TO'];
	$agent_code						= $_REQUEST['agent_code'];
	$_SESSION['agent_name']      	= $obj->getVendorListNewData($agent_code,"NAME");
	
	$_SESSION['pda_ini_pay_per'] 	= $rows['PAD_INI_PAY_PERSENT'];
	$_SESSION['pda_fin_pay_per'] 	= $rows['PAD_FIN_PAY_PERSENT'];
	
	$_SESSION['vslconInfo'] 		= $rows['VSL_CONTACT_DETAILS'];
	$_SESSION['vslinfo'] 			= $rows['VSL_DETAILS'];
	$_SESSION['about'] 				= $rows['VSL_ABOUT'];
	
	if($rows['TERMO_OF_TOLERANCE']!="")
	{
	  $_SESSION['termOfTolerance'] =" ".$rows['TERMO_OF_TOLERANCE'];
	}
	else
	{
	  $_SESSION['termOfTolerance'] ="";
	}
	if($rows['CARGO_PACKING_DESC']!="")
	{
	  $_SESSION['cargoPackDesc'] =" ".$rows['CARGO_PACKING_DESC'];
	}
	else
	{
	  $_SESSION['cargoPackDesc'] ="";
	}
	$_SESSION['tolerancesub'] 	    = $rows['TOLERANCE_SUB'];
	$_SESSION['tolerancePerSub'] 	= $rows['TOLERANCE_PERCENT_SUB'];
	$_SESSION['toleranceAdd'] 	    = $rows['TOLERANCE_ADD'];
	$_SESSION['tolerancePerAdd'] 	= $rows['TOLERANCE_PERCENT_ADD'];
	
	
	number_format(($rows['AGREED_GROSS_FREIGHT_LOCAL']),2,'.','');
	if($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']>0)
	{$_SESSION['tolerancePerSub']= " -".number_format($rows['TOLERANCE_PERCENT_SUB'],1,'.','')."%/";}
	else if(($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']==0) || ($rows['TOLERANCE_PERCENT_SUB']>0 && $rows['TOLERANCE_PERCENT_ADD']==""))
	{$_SESSION['tolerancePerSub']= " -".number_format($rows['TOLERANCE_PERCENT_SUB'],1,'.','')."% ";}
	else
	{$_SESSION['tolerancePerSub']= "";}
	if($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']>0)
	{$_SESSION['tolerancePerAdd']= "+".number_format($rows['TOLERANCE_PERCENT_ADD'],1,'.','')."% ";}
	else if(($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']==0) || ($rows['TOLERANCE_PERCENT_ADD']>0 && $rows['TOLERANCE_PERCENT_SUB']==""))
	{$_SESSION['tolerancePerAdd']= " +".number_format($rows['TOLERANCE_PERCENT_ADD'],1,'.','')."% ";}
	else
	{$_SESSION['tolerancePerAdd']= "";}
	
	$cost_sheet_id 					= $obj->getLatestCostSheetID($rows['COMID']);
	
									  $obj->viewFreightCostEstimationTempleteRecordsNew($cost_sheet_id);
	$_SESSION['quantity'] 			= $rows['QTY'];
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
	    $_SESSION['cargo_name']			= $obj->getCargoNameListForMultipleName($rowscoa['CARGO']);
	}
	else
	{
		$_SESSION['cargo_name']			= $obj->getCargoNameListForMultipleNamemultiple($obj->getCompareEstimateData($rows['COMID'],"CARGO_ID"));
	}
	
	$vlsImoId 						= $obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID");
	$charterer_name 				= "";
	

if($obj->getFun155()==1)
{
	$charterer_name = $obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"QTY_VENDORID"));
}
else
{
	$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
	$res12 = mysql_query($sql12);
	$rec12 = mysql_num_rows($res12);
	while($rows2 = mysql_fetch_assoc($res12))
	{
		$charterer_name = $charterer_name.", ".$obj->getVendorListNewBasedOnID($rows2['VENDORID']);
	}
}

$eta_fixture   = $obj->getCheckListLoadPortRecordsDataBasedOnMappingIDEntryName($rows['COMID'],"ACTUAL ARRIVAL","ENTITY_VALUE",$port_type,$rows['PORTID'],$randomno);
if($eta_fixture=="")
{
	$eta_fixture="";
}
else
{
	$eta_fixture=date('d-m-Y H:i',strtotime($eta_fixture));
}

$sql1 = "select * from generate_agency_letter_slave1 where GEN_AGENCY_ID=".$g_agency_id." order by SLAVEID asc";

$result1 = mysql_query($sql1);
$rows1 = mysql_fetch_assoc($result1);
$op_emailds = $rows1['EMAILID'];

/********************FOR LOAD PORT***************************/

if($port_type == "LP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate PDA Request Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate PDA Request Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	//$pdf->Cell(190,6,"Please copy : opex@socatra.com",0,1,'L',0);
	
	//$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Cell(190,6,"To :".$_SESSION['agent_name']." (".$_SESSION['portname'].") /att. ".$rows1['ENTITY_NAME']." (".$rows1['EMAILID'].")",0,1,'L',0);
	
	$pdf->Ln(2);
	$pdf->Cell(190,5,"From : ".$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->Cell(25,5,"Good day,",0,1,'L');
	$pdf->Cell(25,5,"Dear Sirs,",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Ln(1);
	$pdf->Cell(190,4,"Re. ".strtoupper($_SESSION['vslName']),0,1,'L',1);
	
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(1);
	$pdf->Row1(array("We are working on a possible loading at your facility for (".$_SESSION['cargo_name'].") ".$_SESSION['quantity']." MT."));
	$pdf->Ln(5);
	$pdf->Row1(array("Please revert with your best Performa DA on basis following vessel’s particulars:"));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Cell(190,4,"LOA(M) : ".$obj->getVesselIMOData($vlsImoId,"LOA"),0,1,'L',1);
	$pdf->Cell(190,4,"BOA(M) : ".$obj->getVesselParticularData('BEAM','vessel_master_tankers',$vlsImoId),0,1,'L',1);
	$pdf->Cell(190,4,"MAX S.DRAFT(M) : ".$obj->getVesselIMOData($vlsImoId,"DRAFTM"),0,1,'L',1);

	$pdf->Cell(190,4,"DWT(MT) : ".$obj->getVesselIMOData($vlsImoId,"DWT"),0,1,'L',1);
	$pdf->Cell(190,4,"GRT : ".$obj->getVesselIMOData($vlsImoId,"GRT_NRT"),0,1,'L',1);
	$pdf->Cell(190,4,"NRT : ".$obj->getVesselIMOData($vlsImoId,"NRT"),0,1,'L',1);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1 = $arr2 = $arr3 = $arr4 = $arr5 = $arr6 = $arr7 = $arr8 = $arr9 = $arr10 = array();
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Please quote ALL IN agency fee."));
	$pdf->Ln(5);
	$pdf->Row1(array("In addition, please advise the usual port restrictions for this vessel type."));
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row1(array("Best regards,"));
	$pdf->Ln(6);
	$pdf->Row1(array('Operations'));
	
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($obj->getUserDetailBaseOnId($rows['LOGINID'],'MCOMPANYID'),'COMPANY_NAME')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'CONTACT_PERSON')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'ADDRESS')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'PHONE_NO')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'EMAILID')));
	
}

/********************FOR DISCHARGE PORT**********************/

else if($port_type == "DP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate PDA Request Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate PDA Request Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	//$pdf->Cell(190,6,"Please copy : opex@socatra.com",0,1,'L',0);
	
	//$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Cell(190,6,"To :".$_SESSION['agent_name']." (".$_SESSION['portname'].") /att. ".$rows1['ENTITY_NAME']." (".$rows1['EMAILID'].")",0,1,'L',0);
	
	$pdf->Ln(2);
	$pdf->Cell(190,5,"From : ".$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->Cell(25,5,"Good day,",0,1,'L');
	$pdf->Cell(25,5,"Dear Sirs,",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Ln(1);
	$pdf->Cell(190,4,"Re. ".strtoupper($_SESSION['vslName']),0,1,'L',1);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(1);
	$pdf->Row1(array("We are working on a possible discharging at your facility for (".$_SESSION['cargo_name'].") ".$_SESSION['quantity']." MT."));
	$pdf->Ln(5);
	$pdf->Row1(array("Please revert with your best Performa DA on basis following vessel’s particulars:"));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Cell(190,4,"LOA(M) : ".$obj->getVesselIMOData($vlsImoId,"LOA"),0,1,'L',1);
	$pdf->Cell(190,4,"BOA(M) : ".$obj->getVesselParticularData('BEAM','vessel_master_tankers',$vlsImoId),0,1,'L',1);
	$pdf->Cell(190,4,"MAX S.DRAFT(M) : ".$obj->getVesselIMOData($vlsImoId,"DRAFTM"),0,1,'L',1);
	$pdf->Cell(190,4,"DWT(MT) : ".$obj->getVesselIMOData($vlsImoId,"DWT"),0,1,'L',1);
	$pdf->Cell(190,4,"GRT : ".$obj->getVesselIMOData($vlsImoId,"GRT_NRT"),0,1,'L',1);
	$pdf->Cell(190,4,"NRT : ".$obj->getVesselIMOData($vlsImoId,"NRT"),0,1,'L',1);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1 = $arr2 = $arr3 = $arr4 = $arr5 = $arr6 = $arr7 = $arr8 = $arr9 = $arr10 = array();
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Please quote ALL IN agency fee."));
	$pdf->Ln(5);
	$pdf->Row1(array("In addition, please advise the usual port restrictions for this vessel type."));
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row1(array("Best regards,"));
	$pdf->Ln(6);
	$pdf->Row1(array('Operations'));
	
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($obj->getUserDetailBaseOnId($rows['LOGINID'],'MCOMPANYID'),'COMPANY_NAME')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'CONTACT_PERSON')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'ADDRESS')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'PHONE_NO')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'EMAILID')));
}

else if($port_type == "TP")
{
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}	
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate PDA Request Letter Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate PDA Request Letter Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	//$pdf->Cell(190,6,"Please copy : opex@socatra.com",0,1,'L',0);
	
	//$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(0,0,0);
	$pdf->Cell(190,6,"To :".$_SESSION['agent_name']." (".$_SESSION['portname'].") /att. ".$rows1['ENTITY_NAME']." (".$rows1['EMAILID'].")",0,1,'L',0);
	
	$pdf->Ln(2);
	$pdf->Cell(190,5,"From : ".$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->Cell(25,5,"Good day,",0,1,'L');
	$pdf->Cell(25,5,"Dear Sirs,",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Ln(1);
	$pdf->Cell(190,4,"Re. ".strtoupper($_SESSION['vslName']),0,1,'L',1);
	
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Ln(1);
	$pdf->Row1(array("We are working on a possible transit at your facility for (".$_SESSION['cargo_name'].") ".$_SESSION['quantity']." MT."));
	$pdf->Ln(5);
	$pdf->Row1(array("Please revert with your best Performa DA on basis following vessel’s particulars:"));
	
	$pdf->Ln(1);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->Cell(190,4,"LOA(M) : ".$obj->getVesselIMOData($vlsImoId,"LOA"),0,1,'L',1);
	$pdf->Cell(190,4,"BOA(M) : ".$obj->getVesselParticularData('BEAM','vessel_master_tankers',$vlsImoId),0,1,'L',1);
	$pdf->Cell(190,4,"MAX S.DRAFT(M) : ".$obj->getVesselIMOData($vlsImoId,"DRAFTM"),0,1,'L',1);
	$pdf->Cell(190,4,"DWT(MT) : ".$obj->getVesselIMOData($vlsImoId,"DWT"),0,1,'L',1);
	$pdf->Cell(190,4,"GRT : ".$obj->getVesselIMOData($vlsImoId,"GRT_NRT"),0,1,'L',1);
	$pdf->Cell(190,4,"NRT : ".$obj->getVesselIMOData($vlsImoId,"NRT"),0,1,'L',1);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1 = $arr2 = $arr3 = $arr4 = $arr5 = $arr6 = $arr7 = $arr8 = $arr9 = $arr10 = array();
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Please quote ALL IN agency fee."));
	$pdf->Ln(5);
	$pdf->Row1(array("In addition, please advise the usual port restrictions for this vessel type."));
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row1(array("Best regards,"));
	$pdf->Ln(6);
	$pdf->Row1(array('Operations'));
	
	$pdf->Row1(array($obj->getCompanyNameBasedOnID($obj->getUserDetailBaseOnId($rows['LOGINID'],'MCOMPANYID'),'COMPANY_NAME')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'CONTACT_PERSON')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'ADDRESS')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'PHONE_NO')));
	$pdf->Row1(array($obj->getUserDetailBaseOnId($rows['LOGINID'],'EMAILID')));
	
}

	$pdf->Ln(6);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L');
	$arr2=array(50,50,90);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Username: ".$rows['USERNAME'],"Password: ".$rows['PASSWORD'],""));
	$pdf->Ln(2);
	$pdf->SetTextColor(027,119,166);
	$link='http://progress.sevenoceansgenesis.com/agentlogin.html';
	$pdf->SetLink($link);
	$pdf->Write(4,'Click here to login',$link);

$filename = "PDA Request Letter(".$_SESSION['vslName']."-".$obj->getVendorListNewBasedOnID($rows['VENDORID']).") ".date("d-m-Y").".pdf";
$pdf->Output($filename,'D');

}



function invoicepdf()
{
	$obj = new data();
	$amttoword = new Numbertowordconversion();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];
    $sql = "select * from freight_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
	$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);

	$_SESSION['companyname']        =  $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
	$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
	$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
	$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
	$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
	$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
	$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
	$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
	$_SESSION['footeraddr']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"FOOTER_DETAILS");
	
	$vlsImoId 						= $obj->getCharteringEstimateTCData($rows['COMID'],"VESSEL_IMO_ID");

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['footeraddr'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	
	$sql = "select * from freight_invoice_master where INVOICEID='".$im_id."'";
	$res = mysql_query($sql);
	$rows = mysql_fetch_assoc($res);
	$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
	$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);

	$lp_name = array(); 
	$dp_name = array();
	$discharge_port = "";
	
	for($j=0;$j<count($arr);$j++)
	{   
		$arr_explode = explode('@@',$arr[$j]);
		if($arr_explode[0] == "LP"){$lp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
		if($arr_explode[0] == "DP"){$dp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
	}
	
	$lp_name  = implode(', ',$lp_name);
	$dp_name  = implode(', ',$dp_name);
	
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	
	if($rows['I_TYPE']=='Credit'){
		$invtitle = 'Credit Note';
		$inv_amt_title = 'to Credit';
	}else{
		$invtitle = 'Invoice';
		$inv_amt_title = 'Invoiced';
	}
	
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate Freight '.$invtitle.' Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate Freight '.$invtitle.' Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(48,47,48,47);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." No.",$rows['MESSAGE'],"Contract Ref.","CP Date ".date("d-m-Y",strtotime($obj->getFun3()))));
	$invdate = date('d-m-Y',strtotime($rows['DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	$duedate = date('d-m-Y',strtotime($rows['DUE_DATE'])); if($duedate=='01-01-1970'){$duedate = '';}
	$pdf->Row(array($invtitle." Date",$invdate,"Due Date",$duedate));
	$pdf->Row(array("Vessel",$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$invtitle." Type","Freight"));
	$pdf->Row(array("Port of Loading",$lp_name,"Port of Discharging",$dp_name));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($invtitle." To:",$invtitle." From:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($rows['VENDOR'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'STREET_1')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'COUNTRY')).", ".stripslashes($obj->getVendorDataBasedOnID($rows['VENDOR'],'CITY_POSTAL_CODE')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
		
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($rows['REMARKS'],number_format($rows['NET_AMOUNT'],2,'.',',')));

	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from freight_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(+) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from freight_invoice_slave where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB'";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],"(-) ".number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['BROKERAGE'] > 0)
	{
		$pdf->Row1(array("     Brokerage(".$rows['BROKERAGE_PERCENT']."%)","(-) ".number_format($rows['BROKERAGE'],2,'.',',')));
	}
	
	if($rows['ADDCOM_AMOUNT'] > 0)
	{
		$pdf->Row1(array("     Less Addcom(".$rows['ADDCOM']."%)","(-) ".number_format($rows['ADDCOM_AMOUNT'],2,'.',',')));
	}
	
	$pdf->Ln(3);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total Amount ".$inv_amt_title,number_format($rows['NET_PAYABLE'],2,'.',',')));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Total Amount ".$inv_amt_title." (".$rows['EXCHANGE_CURRENCY'].")",number_format(($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Total amount in words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(strtoupper($amttoword->convert_number_to_words($rows['NET_PAYABLE'],$currency))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(strtoupper($amttoword->convert_number_to_words(number_format($rows['NET_PAYABLE']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['EXCHANGE_CURRENCY'])),""));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(30,160);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Remit To:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
	$res2 = mysql_query($sql2);
	$rows2 = mysql_fetch_assoc($res2);
	$pdf->Row(array("Beneficiary",$_SESSION['companyname']."\nBENEFICIARY NAME: ".$rows2['NAME']."\nBENEFICIARY BANK: ".$rows2['BANK']."\nADDRESS: ".$rows2['ADDRESS']."\nACCOUNT NUMBER: ".$rows2['AC_NO']."\nSWIFT CODE: ".$rows2['BANK_SWIFT_CODE']."\nIBAN No.: ".$rows2['IBAN_NO']));
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated ".strtolower($invtitle)." and no signatures are required",0,1,'L',0);
	
$filename = $invtitle." Of ".$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME")."(".$rows['I_TYPE'].")".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');
}



function getPIClubDecelarationReport()
{
	$obj = new data();
	$obj->funConnect();
	
	$comid = $_REQUEST['comid'];
	$declid    = $_REQUEST['declid'];
	//$sheetid   = $_REQUEST['sheetid'];
$cost_sheet_id = $obj->getLatestCostSheetID($comid);
$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$cost_sheet_id);
$sheetid = $obj->getCompareEstimateData($comid,"SHEET_NO");


$lp_name = ''; 
$dp_name = '';

for($j=0;$j<count($arr);$j++)
{$arr_explode = explode('-',$arr[$j]);$port_name = $obj->getPortNameBasedOnID($arr_explode[1]);
	if($arr_explode[0] == "LP"){
		$lp_name .= $port_name.",";
	}
	elseif($arr_explode[0] == "DP"){
		$dp_name .= $port_name.",";
	}
	elseif($arr_explode[0] == "TP"){
		//$tp_name .= $port_name.",";
	}
}

$lp_name  = substr($lp_name,0,-1);
$dp_name  = substr($dp_name,0,-1);
//$tp_name  = substr($tp_name,0,-1);

class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Charterers Club Vessel Declaration Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Charterers Club Vessel Declaration Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


$pdf->SetFont('Arial','B',14);
$pdf->SetFillColor(27,119,166);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(241,241,241);
$arr1 = $arr2 = $arr3 = array();
$pdf->setX(0);
$arr2=array(210);		
$arr1=array('C');
$arr3=array("The Charterers Club Vessel Declaration Form Cover : ".$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);
    $sql = "select * from piclub_declaration where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and COMID='".$comid."' and DECELARATIONID='".$declid."' and SHEET_NO='".$sheetid."' ";
	$res = mysql_query($sql) or die($sql);
    $rows = mysql_fetch_assoc($res);
	$pdf->Ln(7);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Vessel"," : ",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Year built	"," : ",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"YEARBUILT"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Flag  "," : ",$obj->getCountryData($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"FLAG"),"COUNTRY_NAME"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("GT/NT"," : ",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRT_NRT"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("DWT"," : ",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DWT"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Classification"," : ",$obj->getClaSocNameOnId($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"CLA_SOC_ID")));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Owners P&I Cover"," : ",$obj->getVendorOnlyNameBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"P_I"))."");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Charter party"," : ",$rows['CHARTERER_PARTY']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Date of Delivery"," : ",$rows['DATE_FROM']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Estimated Duration"," : ",$rows['DAYS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	$i++;
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Voyage"," : ","Load Port: ".$lp_name.", Discharge Port: ".$dp_name);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Cargo "," : ",$obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($comid,"MATERIALID"))));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	$pdf->Ln(6);
	$pdf->SetFont('Arial','',10);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1 = $arr2 = $arr3 = array();
	$arr2=array(50,20,150);		
	$arr1=array('L','L','L');
	$arr3=array("Remarks "," : ",$rows['REMARKS']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);

$filename = "Charterers Club Vessel Declaration Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}
function getProfitabilityHeadWiseReport()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date = $_REQUEST['txtFrom_Date'];
	$txtTo_Date = $_REQUEST['txtTo_Date'];

class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
			
		}
	}
	
$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Profitability Head Wise Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Profitability Head Wise Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(27,119,166);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(241,241,241);
$arr1 = $arr2 = $arr3 = array();
$arr2=array(15,34,35,31,30,40,31,31,31);		
$arr1=array('C','C','C','C','C','C','C','C','C');
$arr3=array("Sr. No.","Nom Id","Vessel","CP Date","Total Qty. (MT)","Vendor","Cost In (Revenue)","Cost Out (Expense)","Difference");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql = "select * from freight_cost_analysis_master inner join mapping_master on mapping_master.MAPPINGID = freight_cost_analysis_master.MAPPINGID where TRANS_DATE >='".date('Y-m-d',strtotime($_REQUEST['txtFrom_Date']))."' and TRANS_DATE <='".date('Y-m-d',strtotime($_REQUEST['txtTo_Date']))."' and freight_cost_analysis_master.MODULEID='".$_SESSION['moduleid']."' AND freight_cost_analysis_master.MCOMPANYID='".$_SESSION['company']."' group by freight_cost_analysis_master.MAPPINGID ";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	if($rec == 0)
	{
		//$worksheet->formatmergeCellsMultiple($k,0,$k,8,"SORRY CURRENTLY THERE ARE ZERO(0) RECORDS FOUND",$body_text_center);
		
	}
	else
	{   
		$i = 1;
	    $arr_sumin = $arr_sumout = array();
		while($rows = mysql_fetch_assoc($res))
		{
		    $sheetNo = $obj->getLatestCostSheetID($rows['MAPPINGID']);
			$cpdate = date('Y-m-d',strtotime($rows['TRANS_DATE']));
			$sel2 = "select sum(COSTIN) as sum1, sum(COSTOUT) as sum2 from profit_head_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and MAPPINGID='".$rows['MAPPINGID']."' and SHEET_NO='".$sheetNo."' and (COSTIN >0 or COSTOUT>0) and VENDORID!=''";
			$result2 = mysql_query($sel2) or die($sel2);
			$rows2  = mysql_fetch_assoc($result2);
			
			$sel = "select * from profit_head_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and MAPPINGID='".$rows['MAPPINGID']."' and SHEET_NO='".$sheetNo."' and (COSTIN >0 or COSTOUT>0) and VENDORID!=''";
			$result = mysql_query($sel) or die($sel);
			$num1   = mysql_num_rows($result);
			if($num1>0){$colspan = $num1+ 2;}else{$colspan = 1;}
			
			if($num1>0)
			{
			    $arr_sumin1 = $arr_sumout1 = array();
				
				$pdf->SetFont('Arial','B',9);
				$pdf->SetFillColor(255,255,255);
				$pdf->SetTextColor(0,0,0);
				$arr1 = $arr2 = $arr3 = array();
				$arr2=array(15,34,35,31,30,40,31,31,31);		
				$arr1=array('C','C','C','C','C','R','R','R','R');
				$arr3=array($i,$obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($rows['OPEN_VESSEL_ID'],'VESSEL_IMO_ID'),"VESSEL_NAME"),date('d-m-Y',strtotime($cpdate)),$rows['CARGO_QTY'],"",$rows2['sum1'],$rows2['sum2'],$rows2['sum1'] - $rows2['sum2']);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
				while($rows1  = mysql_fetch_assoc($result))
				{
				    $text = "";
					$arr_sumin1[] = $rows1['COSTIN']; $arr_sumout1[]=$rows1['COSTOUT'];
				    if($rows1['IDENTIFY']=="FREIGHT")
					{$text = "Final Nett Freight";}
					else if($rows1['IDENTIFY']=="BROKERAGE")
					{$text = "Total Brokerage Commission (%)";}
					else if($rows1['IDENTIFY']=="BROKERAGE")
					{$text = "Total Brokerage Commission (%)";}
					else if($rows1['IDENTIFY']=="BUNKERNETT")
					{$text = "Total Brokerage Commission (%)";}
					else if($rows1['IDENTIFY']=="OWNERRELATED")
					{$text = "Owner Related Costs (".$obj->getOwnerRelatedCostNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="CHARTERER")
					{$text = "Charterers' Costs (".$obj->getChartererCostNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="LPCOST")
					{$text = "Port Cost (Load Port  ".$obj->getPortNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					
					else if($rows1['IDENTIFY']=="DPCOST")
					{$text = "Port Cost (Discharge Port ".$obj->getPortNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="TPCOST")
					{$text = "Port Cost (Transit Port ".$obj->getPortNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="DLPCOST")
					{$text = "Demurrage (Load Port  ".$obj->getPortNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="DDPCOST")
					{$text = "Demurrage (Discharge Port  ".$obj->getPortNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					else if($rows1['IDENTIFY']=="OTHERMISC")
					{$text = "Other Misc. Income (".$obj->getOtherMiscCostNameBasedOnID($rows1['IDENTIFY_ID']).")";}
					
					$pdf->SetFont('Arial','',8);
					$pdf->SetFillColor(255,255,255);
					$pdf->SetTextColor(0,0,0);
					$arr1 = $arr2 = $arr3 = array();
					$arr2=array(15,34,35,31,30,40,31,31,31);		
					$arr1=array('L','L','L','L','L','L','R','R','R');
					$arr3=array("","","","",$text,$obj->getVendorListNewBasedOnID($rows1['VENDORID']),$rows1['COSTIN'],$rows1['COSTOUT'],$rows1['COSTIN'] - $rows1['COSTOUT']);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
					$i++;
				}
				$pdf->SetFont('Arial','B',9);
				$pdf->SetFillColor(255,255,255);
				$pdf->SetTextColor(0,0,0);
				$arr1 = $arr2 = $arr3 = array();
				$arr2=array(15,34,35,31,70,31,31,31);		
				$arr1=array('L','L','L','L','C','R','R','R');
				$arr3=array("","","","","Total",array_sum($arr_sumin1),array_sum($arr_sumout1),array_sum($arr_sumin1) - array_sum($arr_sumout1));
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
				$k++;
			}
		}
	}
$filename = "Profitability Head Wise Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function hire_invoice_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$invoiceid = $_REQUEST['invoiceid'];
	$comid = $_REQUEST['comid'];
	$_SESSION['invoiceid'] = $invoiceid;
$amttoword = new Numbertowordconversion();

$fcaid = $obj->getLatestCostSheetID($comid);
$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);
$vendorid = $obj->getFun140();
$lp_name = array(); 
$dp_name = array();

for($j=0;$j<count($arr);$j++)
{   $arr_explode = explode('@@',$arr[$j]);
    
    if($arr_explode[0] == "LP" && $arr_explode[8]==''){$lp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
	if($arr_explode[0] == "DP" && $arr_explode[8]==''){$dp_name[]= $obj->getPortNameBasedOnID($arr_explode[1]);}
}

$lp_name  = implode(', ',$lp_name);
$dp_name  = implode(', ',$dp_name);

$uid	  = $_SESSION['uid'];
$moduleid = $_SESSION['moduleid'];
$sql = "SELECT * from invoice_hire_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and INVOICEID='".$invoiceid."'";
$res 	= mysql_query($sql);
$rows 	= mysql_fetch_assoc($res);

$_SESSION['companyname']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"NAME");
$_SESSION['companyaddress']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"STREET_1");
$_SESSION['companycity']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY");
$_SESSION['companycountry']     = $obj->getVendorListNewData($rows['SHIP_OWNER'],"COUNTRY");
$_SESSION['companycode']        = $obj->getVendorListNewData($rows['SHIP_OWNER'],"CITY_POSTAL_CODE");
$_SESSION['companyemail']       = $obj->getVendorListNewData($rows['SHIP_OWNER'],"EMAILID");
$_SESSION['companytel']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"PHONE");
$_SESSION['companyvat']         = $obj->getVendorListNewData($rows['SHIP_OWNER'],"VAT_NUMBER");
 
$_SESSION['invoice_date'] = date("d-m-Y",strtotime($rows['INVOICE_DATE']));

class PDF extends FPDF
{
	function Header()
	{
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(027,119,166);
		$this->Ln(3);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',25);
		$this->SetX(10);
		$this->Cell(0,8,$_SESSION['companyname'],0,1,'C',0);
		$this->SetTextColor(177,175,175);
		$this->Ln(1);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(2);
	}
		
	function Footer()
	{
		$this->SetY(-20);
		$this->SetFillColor(255,255,255);
		$this->SetTextColor(177,175,175);
		$this->SetFont('Arial','',10);
		$this->SetX(0);
		$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
		$this->Ln(1);
		$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
		$this->SetFont('daxcondensedlight','',8);
		$this->SetTextColor(027,119,166);
		$this->Ln(1);
		$this->Cell(0,4,$_SESSION['companyaddress'].", ".$_SESSION['companycity']." ".$_SESSION['companycountry']." ".$_SESSION['companycode'],0,1,'C');
		$this->Cell(0,4,"Tel: ".$_SESSION['companytel']."  email: ".$_SESSION['companyemail'],0,1,'C');
		//$this->Cell(0,4,"VAT ID: ".$_SESSION['companyvat'],0,1,'C');
		
		
	}
}	
	
	if($obj->getFun175()!='')
	{
		$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
		$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
		$rowscoa   = mysql_fetch_assoc($resultcoa);
		$currency = $rowscoa['CURRENCY'];
	}else
	{
		$currency = 'USD';
	}
	
	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Generate VC Hire Statement Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Generate VC Hire Statement Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->Ln(7);
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L');
	$arr2=array(35,60,35,60);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Statement No.",$rows['INVOICE_NO'],"Contract Ref.","CP Date/TC No. ".date("d-m-Y",strtotime($obj->getFun3())).'/'.$obj->getFun229()));
	$invdate = date('d-m-Y',strtotime($rows['INVOICE_DATE'])); if($invdate=='01-01-1970'){$invdate = '';}
	
	$pdf->Row(array("Statement Date",$invdate,"Vessel",$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME")));
	
	$pdf->Row(array("Load Port ",$lp_name,"Discharge Port ",$dp_name));
	$pdf->Row(array("Voyage Number ",$obj->getFun8(),"",""));
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Owners:","Charterers:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(95,95);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array($obj->getVendorListNewBasedOnID($vendorid)."\n".stripslashes($obj->getVendorDataBasedOnID($vendorid,'STREET_1')),$obj->getVendorListNewBasedOnID($rows['SHIP_OWNER'])."\n".stripslashes($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'STREET_1'))));
	
	
	
	$pdf->Ln(5);
	$gety = $pdf->GetY();
    $pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Payment Terms:"));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row1(array($rows['PAYMENT_TERMS']));
	
	$pdf->Ln(2);
	$gety2 = $pdf->GetY();
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Description","Amount(".$currency.")"));
	
	$pdf->Ln(2);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Period ".date('d-m-Y H:i',strtotime($rows['HIRE_FROM']))." - ".date('d-m-Y H:i',strtotime($rows['HIRE_TO'])).", Total ".$rows['HIRE_DAYS']." Days",number_format($rows['HIRE_AMT'],2,'.',',')));
	$pdf->Row1(array("Hire for ".$rows['HIRE_DAYS']." days at ".$currency." ".$obj->getFun91()." per day",""));
	$pdf->Row1(array($rows['DESCRIPTION'],""));
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Additional:",""));
	
	$pdf->SetFont('daxcondensedlight','',10); 
	
	if($rows['CHK_BALLAST_BONUS']==1 && $obj->getFun145()>0)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("     Ballast Bonus",'(+) '.number_format($obj->getFun145(),2,'.',',')));
	}
	
	$sql2 = "select * from invoice_hire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='ADD' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(+) '.number_format($rows2['AMOUNT'],2,'.',',')));
	}
	
	if($rows['CVE_AMT']>0)
	{
		$pdf->Row1(array("     CVE     -   ".$currency.' '.$rows['CVE'],'(+) '.number_format($rows['CVE_AMT'],2,'.',',')));
	}
	
	if($rows['CHK_DELIVERY']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Delivery Bunkers",""));
		
		$sqltc4 = "SELECT BUNKERID, AMOUNT, QTY, PRICE, IDENTITY from freight_cost_estimete_slave13 where FCAID='".$fcaid."' and IDENTITY='DEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['QTY'].'(MT)',number_format(($rowstc4['PRICE']),2,'.',','),'(+) '.number_format(($rowstc4['AMOUNT']),2,'.',',')));
        }
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Less:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$sql2 = "select * from invoice_hire_slave1 where INVOICEID='".$rows['INVOICEID']."' and IDENTIFY='SUB' and AMOUNT>0";
    $res2 = mysql_query($sql2);
    while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->Row1(array("     ".$rows2['DESCRIPTION'],'(-) '.number_format($rows2['AMOUNT'],2,'.',',')));
	}

	
	if($rows['ADD_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     ADDRESS COMMISSION(".$rows['ADD_COMM_PER']."%)",'(-) '.number_format($rows['ADD_COMM_AMT'],2,'.',',')));
	}
	
	if($rows['BRO_COMM_AMT'] > 0)
	{
		$pdf->Row1(array("     BROKERAGE COMMISSION(".$rows['BRO_COMM_PER']."%)",'(-) '.number_format($rows['BRO_COMM_AMT'],2,'.',',')));
	}
	
	$sql_random = "SELECT RANDOMID from invoice_hire_slave4 where COMID='".$rows['COMID']."' and INVOICEID='".$rows['INVOICEID']."'";
	$res_random 	= mysql_query($sql_random) or die($sql_random);
	$rec_random 	= mysql_num_rows($res_random);
	
	$off =0;
	if($rows['CHK_OFFHIRE']==1 && $rec_random>0)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Off-hire",""));
		while($rec_random = mysql_fetch_assoc($res_random))
		{ $off++;
			$sqltc4 = "SELECT * from freight_cost_estimete_slave14 where FCAID='".$fcaid."' and RANDOMID='".$rec_random['RANDOMID']."'";
			$restc4 	= mysql_query($sqltc4);
			$rectc4 	= mysql_num_rows($restc4);
			while($rowstc4 = mysql_fetch_assoc($restc4))
			{
				$pdf->Row1(array("    ".$off.". ".$rowstc4['OFF_REASON']." (".$rowstc4['OFF_DAYS']." Days)",'(-) '.number_format($rowstc4['OFF_HIRE'],2,'.',',')));
				$sqltc5 = "SELECT * from freight_cost_estimete_slave15 where FCAID='".$fcaid."' and FCA_SLAVE14ID='".$rowstc4['FCA_SLAVE14ID']."' and CHECK_BUNKER_CAL=1 ";
				$restc5 	= mysql_query($sqltc5);
				$rectc5 	= mysql_num_rows($restc5);
				while($rowstc5 = mysql_fetch_assoc($restc5))
				{
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','R','R','R');
					$arr2=array(50,50,50,40);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc5['BUNKERID']),$rowstc5['BUNKERQTY'].'(MT)',number_format(($rowstc5['BUNKERPRICE']),2,'.',''),'(-) '.number_format(($rowstc5['BUNKERAMT']),2,'.',',')));
				}
			}
		}
	}
	
	$pdf->Ln(1);
	if($rows['CHK_OFFHIRE']==1 && $rec_random>0)
	{
		$pdf->Row1(array("     CVE on Off-Hire ",'(-) '.number_format($rows['OFFHIRE_CVE_AMT'],2,'.',',')));
	}
	
	
	if($rows['CHK_REDELIVERY']==1)
	{
		$pdf->Ln(1);
		$pdf->Row1(array("   Re-Delivery Bunkers",""));
		$sqltc4 = "SELECT BUNKERID, AMOUNT, QTY, PRICE, IDENTITY from freight_cost_estimete_slave13 where FCAID='".$fcaid."' and IDENTITY='REDEL'";
		$restc4 	= mysql_query($sqltc4);
		$rectc4 	= mysql_num_rows($restc4);
		while($rowstc4 = mysql_fetch_assoc($restc4))
		{
		    $pdf->SetTextColor(0,0,0);
			$arr1=array('L','R','R','R');
			$arr2=array(50,50,50,40);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
		    $pdf->Row1(array("     ".$obj->getBunkerGradeBasedOnID($rowstc4['BUNKERID']),$rowstc4['QTY'].'(MT)',number_format(($rowstc4['PRICE']),2,'.',''),'(-) '.number_format(($rowstc4['AMOUNT']),2,'.',',')));
        }
	}
	
	$sqlprev = "SELECT * from invoice_hire_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and STATUS=1 and INVOICEID<'".$rows['INVOICEID']."' and P_AMT>0";
	$resprev = mysql_query($sqlprev);
	$rec = mysql_num_rows($resprev);$m=0;
	while($rowsprev = mysql_fetch_assoc($resprev))
	{$m++;
	    $pdf->Ln(3);
		$pdf->SetFont('daxcondensedlight','',11);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','R');
		$arr2=array(150,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
	    $pdf->Row1(array("     ".$m.'. Remittance ('.$rowsprev['INVOICE_NO'].')',number_format($rowsprev['P_AMT'],2,'.',',')));
	}
	$pdf->Ln(2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','R');
	$arr2=array(150,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Balance ",number_format($rows['FINAL_AMT'],2,'.',',')));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array("Balance (".$rows['CURRENCY'].")",number_format(($rows['FINAL_AMT']*$rows['EXCHANGE_RATE']),2,'.',',')));
	}
	
	$gety1 = $pdf->GetY();
	$pdf->Ln(-($gety1 - $gety));
    $pdf->Cell(0,($gety1 - $gety),"",1,1,'L',0);
	
	$pdf->Ln(-($gety1 - $gety2));
	$pdf->SetX(160);
    $pdf->Cell(40,($gety1 - $gety2),"",1,1,'L',0);
	
	if($pdf->GetY() >205){$pdf->AddPage('P');$pdf->Ln(5);}
	
	$pdf->Ln(5);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row(array("Amount in Words:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	$pdf->Row(array(str_replace("NEGATIVE ","",strtoupper($amttoword->convert_number_to_words($rows['FINAL_AMT'],$currency)))));
	if($rows['EXCHANGE_RATE']!=1)
	{
		$pdf->Row(array(str_replace("NEGATIVE ","",strtoupper($amttoword->convert_number_to_words(number_format($rows['FINAL_AMT']*$rows['EXCHANGE_RATE'],2,'.',''),$rows['CURRENCY']))),""));
	}
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L');
	$arr2=array(190);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->SetFont('daxcondensedlight','',11);
	$pdf->Row(array("Banking Details:",""));
	$pdf->SetFont('daxcondensedlight','',10);
	if($rows['FINAL_AMT']>0)
	{
		$pdf->Row(array($obj->getVendorDataBasedOnID($vendorid,'BANKING_DETAILS')));
	}
	else
	{
		$pdf->Row(array($obj->getVendorDataBasedOnID($rows['SHIP_OWNER'],'BANKING_DETAILS')));
	}
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','I',9);
	$pdf->SetTextColor(10,10,10);
	$pdf->Cell(0,6,"* This is a system generated invoice and no signatures are required",0,1,'L',0);
	
$filename = "Hire Invoice ".$obj->getFun8()." ".$rows['INVOICE_NO'].".pdf";

$pdf->Output($filename,'D');
}


function voyage_financial_pdf()
{	
	$obj 						= new data();
	$connect					= $obj->funConnect();
	$selVFEstimate 				= $_REQUEST['selVFEstimate'];
	$mappingid 					= $_REQUEST['mappingid'];
	$_SESSION['selVFEstimate'] 	= $selVFEstimate;
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',9);
			$this->SetFillColor(0,0,0);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(255,255,255);
			
			$arr = explode(",",$_SESSION['selVFEstimate']);
			$arr1=array('L');
			$arr2=array(50);
			$arr3=array("VOYAGE ESTIMATES");
			if(count($arr) > 4){$max = 4;$len = 228/4;}else{$max = count($arr);$len = 228/count($arr);}
			for($i=0;$i<$max;$i++)
			{
				$arr1[]='C';
				$arr2[]=$len;
				$arr3[]=$obj->getFreightCostEstimationData($arr[$i],"ESTIMATION_NO");
			}
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Financials Comparison Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Financials Comparison Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFont('Arial','',8);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(128,128,128);
						
	$arr1 = $arr2 = $arr3 = array();	
	$arr = explode(",",$_REQUEST['selVFEstimate']);
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Fixture Type");
	if(count($arr) > 4){$max = 4;$len = 228/4;}else{$max = count($arr);$len = 228/count($arr);}
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightFixtureBasedOnID($obj->getFreightCostEstimationData($arr[$i],"FIXTURETYPEID"));
	}

	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);


	/*$arr1 = $arr2 = $arr3 = array();
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Vessel Type");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"VESSEL_TYPE"));
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);*/


	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Vessel Name");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Date");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = date("d M Y",strtotime($obj->getFreightCostEstimationData($arr[$i],"TRANS_DATE")));
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Voy No.");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightCostEstimationData($arr[$i],"VOYAGE_NO");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	/*
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("DWT (Summer)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getVesselMaster1Data($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"SUMMER_1");
	}
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	*/
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Cargo Type / Cargo Name");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION"));
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Cargo Qty (MT)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightCostEstimationData($arr[$i],"CARGO_QTY");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Load Port");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortNameBasedOnID($arr[$i],"fca_tci_load_port","LOADPORTID");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Load Rate (MT/Day)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortDataBasedOnID($arr[$i],"fca_tci_load_port","RATE");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Load Port Cost");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortDataBasedOnID($arr[$i],"fca_tci_load_port","PORT_COST");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Discharge Port");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortNameBasedOnID($arr[$i],"fca_tci_disch_port","DIS_PORT_ID");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Discharge Rate (MT/Day)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortDataBasedOnID($arr[$i],"fca_tci_disch_port","RATE");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Discharge Port Cost");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortDataBasedOnID($arr[$i],"fca_tci_disch_port","PORT_COST");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Transit Port");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortNameBasedOnID($arr[$i],"fca_tci_transit_port","LOAD_PORTID");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Transit Port Cost");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFCECostSheetPortDataBasedOnID($arr[$i],"fca_tci_transit_port","PORT_COST");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("TOTAL DAYS");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_DAYS");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Sea Days");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_SEA_DAYS");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Port Idle");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_PORT_IDLE_DAYS");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Port Working");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_PORT_WORK_DAYS");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("FUEL DETAILS");
	$pdf->SetFont('Arial','B',9);
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = "";
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("FO Consp (MT)");
	$pdf->SetFont('Arial','',8);
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_FO_CONSP_MT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("DO Consp (MT)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_DO_CONSP_MT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("FO Price (USD/MT)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFoConspCostSheetDataBasedOnID($arr[$i],"EST_PRICE");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("DO Price (USD/MT)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getDoConspCostSheetDataBasedOnID($arr[$i],"EST_PRICE");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Fuel Cost (USD)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$ttl_fuel_cost = ($obj->getFoConspCostSheetDataBasedOnID($arr[$i],"EST_MT") * $obj->getFoConspCostSheetDataBasedOnID($arr[$i],"EST_PRICE")) + ($obj->getDoConspCostSheetDataBasedOnID($arr[$i],"EST_MT") * $obj->getDoConspCostSheetDataBasedOnID($arr[$i],"EST_PRICE"));
		$arr3[] = $ttl_fuel_cost;
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Related Cost (USD)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_SHIPOWNER_EXP");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	/*$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Other Shipping Cost (USD)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getOSCSumTMP($arr[$i]);
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);*/
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Other Miscellaneous Cost (USD)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getOMCSumCostSheet($arr[$i]);
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->Cell(278,5,"",1,1,'C');
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("RESULTS");
	$pdf->SetFont('Arial','B',9);
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = "";
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Revenue (Final Nett Freight)");
	$pdf->SetFont('Arial','',8);
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"REVENUE");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Owners Expenses");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_OWNER_EXP");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Total Charterers &rsquo; Expenses");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_CHARTERER_EXP");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Voyage Earnings");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"VOYAGE_EARNING");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Daily Earnings / TCE");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"DAILY_EARNING");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Daily Time Charter (USD/Day)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"DAILY_VO_EXP");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Hireage");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"HIREAGE_AMT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Add Comm (%)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"HIREAGE_PERCENT").' - '.$obj->getFreightEstimationTotalRecords($arr[$i],"HIREAGE_PER_AMT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);	
	
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("G Total Voyage Earnings (Voyage Earnings + Demurrage)");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"GRAND_TTL_VOYAGE_EARNING");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Nett Hireage");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"HIREAGE_NETT_AMT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Nett Daily Earnings");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"NETT_DAILY_EARNING");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("Nett Daily Profit");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = $obj->getFreightEstimationTotalRecords($arr[$i],"NETT_DAILY_PROFIT");
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = array();	
	$arr1=array('L');
	$arr2=array(50);
	$arr3=array("P / L");
	for($i=0;$i<$max;$i++)
	{
		$arr1[] = 'C';
		$arr2[] = $len;
		$arr3[] = round($obj->getFreightEstimationTotalRecords($arr[$i],"NETT_DAILY_PROFIT") * $obj->getFreightEstimationTotalRecords($arr[$i],"TTL_DAYS"),2);
	}
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);

	$filename = "Voyage Financials Comparison Report ".date("d-M-Y",time()).".pdf";
	$pdf->Output($filename,'D');

}

/***********************************************************/


/************************Update Inops Cost Sheet PDF ***************************/

function inops_at_glance_update_cost_sheet_pdf()
{	
	$obj 			= new data();
	$sheetid     	= @$_REQUEST['sheetid'];
	$comid     		= @$_REQUEST['comid'];
	$page 		   	= @$_REQUEST['page'];
	$obj->viewFreightCostEstimationTempleteRecordsNew($sheetid);

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Charter Out Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Charter Out Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Main Particulars",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE")),"","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Date",":",date("d-m-Y",strtotime($obj->getFun3())),"Voyage No.",":",$obj->getFun8(),"Voyage Financials Name",":",$obj->getFun9());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("DWT(Summer)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1"),"DWT(Tropical)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1"),"Grain Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Bale Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE"),"SF (CBM/MT)",":",$obj->getFun30(),"Loadable (MT)",":",$obj->getFun16());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/**********************Market***************************/
	
	$rdoQtyType = $obj->getFun155();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType ==1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','C','L','L','C','L','L','C','L');
		$arr2=array(50,5,50,40,5,50,40,5,40);
		
		$arr3=array("Agreed Gross Freight (Local Currency/MT)",":",$obj->getFun133(),"Currency",":",$obj->getCountryData($obj->getFun134(),'CURRENCY_NAME'),"Exchange Rate",":",$obj->getFun135());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
		
		$arr3=array("Agreed Gross Freight (USD/MT)",":",$obj->getFun47(),"Lumpsum (USD)",":",$obj->getFun48(),"Addnl Cargo Rate (USD/MT)",":",$obj->getFun49());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
	}
	
	else if($rdoQtyType ==2){
		
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L','L','L','L');
		$arr2=array(62,65,70,80);
		$arr3=array("Customer","Agreed Gross Freight (USD/MT)","Quantity (MT)","Gross Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		$i = 0;
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			//$i = $i + 1;
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			$pdf->SetFillColor(255,255,255);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L');
			$arr2=array(62,65,70,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['AGREED_GROSS_FREIGHT'],$rows2['QUANTITY'],$rows2['GROSS_FREIGHT']);
			$pdf->Row2($arr3);
			$totalQuantity += $rows2['QUANTITY'];
			$totalGrassFreight += $rows2['GROSS_FREIGHT'];
			$i++;
		}
		$pdf->SetFillColor(255,255,255);
		$arr3=array("","",number_format($totalQuantity, 2, '.', ''),number_format($totalGrassFreight, 2, '.', ''));
		$pdf->Row2($arr3);
	}
	
	/**********************Cargo*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Cargo",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Quantity (MT)",":",$obj->getFun50(),"Cargo Type",":",$obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($comid,"MATERIALID"))));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
 	//******************Passage Locations*********************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Passage Locations",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(62,65,70,80);
	$arr3=array("Location From","Location To","Passage Type","Distance");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from freight_cost_estimete_slave6 where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	
	while($rows = mysql_fetch_assoc($res))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L');
		$arr2=array(62,65,70,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($rows['LOCATION_FROM'],$rows['LOCATION_TO'],$obj->getPassageTypeNameBasedOnID($rows['PASSAGE_TYPE'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEED_TYPE'])." )",$rows['DISTANCE'],$actual_sp[$j]['ACTUAL_DAYS']);
		
		$pdf->Row2($arr3);
	}
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Off Hire",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(62,65,70,80);
	$arr3=array("Off Hire Reason","Off Hire From","Off Hire To","Off Hire Days");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	
	while($rows = mysql_fetch_assoc($res))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L');
		$arr2=array(62,65,70,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($rows['OFFHIRE_REASON'],date('d-m-Y H:i',strtotime($rows['FROM_OFF_DATE'])),date('d-m-Y H:i',strtotime($rows['TO_OFF_DATE'])),$rows['OFF_HIRE_DAYS']);
		
		$pdf->Row2($arr3);
	}
	
	//*********************See Passage**************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Sea Passage",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(45,45,45,52,45,45);
	$arr3=array("From Port","To Port","Passage Type","Distance","Speed Adj.","Margin distance(%)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L');
		$arr2=array(45,45,45,52,45,45);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['FROM_PORT']),$obj->getPortNameBasedOnID($rows1['TO_PORT']),$obj->getPassageTypeNameBasedOnID($rows1['PASSAGE_TYPE'])." (".$obj->getPassageSpeedBasedOnID($rows1['SPEED_TYPE'])." )",$rows1['DISTANCE']." (".$obj->getDistanceTypeBasedOnID_New($rows1['DIS_TYPE'])." )",$rows1['SPEED_ADJ'],$rows1['MARGIN_DISTANCE']);
		
		$pdf->Row2($arr3);
	}
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Load Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(35,35,35,34,34,34,34,35);
	$arr3=array("Load Port","Qty MT","Rate(MT/Day)","LP/Terms","Port Costs(USD)","Work Days","Idle Days","Port Cost Vendor");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L');
		$arr2=array(35,35,35,34,34,34,34,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['FROM_PORT']),$rows1['LOAD_PORT_QTY'],$rows1['LOAD_PORT_RATE'],$obj->getPaymentTermName($rows1['LOAD_PORT_TERMS']),$rows1['LOAD_PORT_COST'],$rows1['LOAD_PORT_WORK_DAYS'],$rows1['LOAD_PORT_IDEAL_DAYS'],$obj->getVendorListNewBasedOnID($rows1['PORT_COSTLP_VENDOR']));
		
		$pdf->Row2($arr3);
	}
	
	//*********************Load Port(s)**************************
	
	
	///********************Discharge Port**************************
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
    $arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(35,35,35,34,34,34,34,35);
	$arr3=array("Discharge Port","Qty MT","Rate(MT/Day)","DP/Terms","Port Costs(USD)","Work Days","Idle Days","Port Cost Vendor");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L');
		$arr2=array(35,35,35,34,34,34,34,35);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getPortNameBasedOnID($rows1['TO_PORT']),$rows1['DISC_PORT_QTY'],$rows1['DISC_PORT_RATE'],$obj->getPaymentTermName($rows1['LOAD_PORT_TERMS']),$rows1['DISC_PORT_COST'],$rows1['DISC_PORT_WORK_DAYS'],$rows1['DISC_PORT_IDEAL_DATE'],$obj->getVendorListNewBasedOnID($rows1['PORT_COSTDP_VENDOR']));
		$pdf->Row2($arr3);
	}
	
	//*********************Transit Port(s)***************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(70,70,70,70);
	$arr3=array("Transit Port","Port Costs(USD)","Idle Days","Port Cost Vendor");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql3 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$res3 = mysql_query($sql3);
	$rec3 = mysql_num_rows($res3);
	$i = 0;
	$j = 1;
	
	while($rows3 = mysql_fetch_assoc($res3))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L');
	    $arr2=array(70,70,70,70);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($obj->getPortNameBasedOnID($rows3['FROM_PORT']),$rows3['TRANSIT_PORT_COST'],$rows3['TRANSIT_PORT_IDLE_DAYS'],$obj->getVendorListNewBasedOnID($rows3['PORT_COSTTP_VENDOR']));
		
		$pdf->Row2($arr3);	
		$i++;
		$j++;
	}
	
	//*********************Totals*****************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Totals",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Dist",":",$obj->getFun55(),"Ballast Dist",":",$obj->getFun56(),"Total Dist",":",$obj->getFun63());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Days",":",$obj->getFun57(),"Ballast Days",":",$obj->getFun58(),"Total Sea Days",":",$obj->getFun59());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl Port Idle Days",":",$obj->getFun60(),"Ttl Port Work Days",":",$obj->getFun61(),"Total Days",":", $obj->getFun62());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT",":",$obj->getFun64(),"Ttl DO Consp MT",":",$obj->getFun65(),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT (Manual)",":",$obj->getFun136(),"Ttl DO Consp MT (Manual",":",$obj->getFun137(),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp Off Hire",":",$obj->getFun138(),"Ttl DO Consp Off Hire",":",$obj->getFun139(),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	///*************************Freight Adjustment******************************
	
	$rdoQtyType = $obj->getFun155();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","Percent","USD","Per MT");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Gross Freight","",$obj->getFun66(),$obj->getFun70());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Dead Freight","",$obj->getFun67(),$obj->getFun71());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Addnl Freight","",$obj->getFun68(),$obj->getFun72());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Total Freight","",$obj->getFun69(),$obj->getFun73());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Brokerage",$obj->getFun77(),$obj->getFun78(),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Net Freight","",$obj->getFun80(),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,70,60,60,37);
		$arr3=array("Customer","Gross Freight (USD)","Brokerage(%)","Net Brokerage","Net Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,70,60,60,37);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['GROSS_FREIGHT'],$rows2['BROKERAGE'],$rows2['NET_BROKERAGE'],$rows2['NET_FREIGHT']);
			
			$netBrokerage += $rows2['NET_BROKERAGE'];
			$netFreight   += $rows2['NET_FREIGHT'];
			
			$pdf->Row2($arr3);	
			$i++;
		}	
		
		$arr3=array("","","",$netBrokerage,$netFreight);	
		$pdf->Row2($arr3);
	}
	
	//*************************Freight Details*******************************
	
	$rdoQtyType = $obj->getFun155();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($obj->getFun141()),$obj->getFun80(),$obj->getFun81());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}	
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","","","");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['NET_FREIGHT'],$rows2['NET_FREIGHT_PERMT']);
			$pdf->Row2($arr3);	
			$i++;
		}
	
	}
	
	//*************************Bunker Adjustment*******************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');
	
	$pdf->Ln(1);
													
	$sql = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and STATUS=1";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	
	$ttl_bg = array("Select Bunker grade",);
	while($rows = mysql_fetch_assoc($res)){
		$ttl_bg[]  = $rows['NAME'];
		$ttl_bg1[] = $rows['BUNKERGRADEID'];
	}
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','C','C');
	$arr2=array(92,92,93);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array($ttl_bg[0],$ttl_bg[1],$ttl_bg[2]));

	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("","MT","Price","Cost","MT","Price","Cost");
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Estimated",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"EST_PRICE")));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("On Delivery",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"DEL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"DEL_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Supply",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"SUPPLY_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"SUPPLY_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Off Hire",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"LESS_OH_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"LESS_OH_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"LESS_OH_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"LESS_OH_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"LESS_OH_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"LESS_OH_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("On Re-Delivery",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"RE_DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"RE_DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"RE_DEL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"RE_DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"RE_DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"RE_DEL_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Actual Consumption",$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[0],"ACTUAL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[1],"ACTUAL_COST"));
	$pdf->Row2($arr3);
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','C','C');
	$arr2=array(92,92,93);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array($ttl_bg[3],$ttl_bg[4],$ttl_bg[5]));
	
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("MT","Price","Cost","MT","Price","Cost","MT","Price","Cost");
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"EST_PRICE")));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"DEL_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"DEL_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"DEL_PRICE")),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"DEL_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"DEL_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"DEL_PRICE")),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"DEL_PRICE"),($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"DEL_MT"))*($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"DEL_PRICE")));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"SUPPLY_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"SUPPLY_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"SUPPLY_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"LESS_OH_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"LESS_OH_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"LESS_OH_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"LESS_OH_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"LESS_OH_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"LESS_OH_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"LESS_OH_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"LESS_OH_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"LESS_OH_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"RE_DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"RE_DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"RE_DEL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"RE_DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"RE_DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"RE_DEL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"RE_DEL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"RE_DEL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"RE_DEL_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C','C','C');
	$arr2=array(30,30,31,30,31,32,30,30,31);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array($obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[2],"ACTUAL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[3],"ACTUAL_COST"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$ttl_bg1[4],"ACTUAL_COST"));
	$pdf->Row2($arr3);
	
	
	
	//****************************Bunkers Nett Supply*******************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Bunkers Nett Supply",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Value/MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$ttl_bg = $ttl_bg1 = array();
	$sql = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and STATUS=1";
	$res = mysql_query($sql);
	while($rows = mysql_fetch_assoc($res))
	{
		$ttl_bg[]  = $rows['NAME'];
		$ttl_bg1[] = $rows['BUNKERGRADEID'];
	}
	
	for($i=0;$i<count($ttl_bg);$i++)
	{
		$query = "select * from freight_cost_estimete_slave8 where COST>0 and BUNKERGRADEID='".$ttl_bg1[$i]."' and FCAID='".$obj->getFun1()."'";
		$qres = mysql_query($query) or die($query);
		while($qrows = mysql_fetch_assoc($qres))
		{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($ttl_bg[$i]."Nett",$qrows['COST'],$obj->getVendorListNewBasedOnID($qrows['VENDORID']),$qrows['COST_MT']);
			$pdf->Row2($arr3);	
		}
	}
	
	//***********************Owner Related Costs (Others)*************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Operational Costs (Others)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Address Commission",$obj->getFun74(),$obj->getFun75(),$obj->getVendorListNewBasedOnID($obj->getFun76()));
	$pdf->Row2($arr3);
	
	$sql_brok = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";										
	$res_brok = mysql_query($sql_brok);
	$num_brok = mysql_num_rows($res_brok);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	
	if($num_brok==0){
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("Brokerage Commission (%)","","","");
		$pdf->Row2($arr3);
		
	}else{
		$i=0;
		while($rows_brok = mysql_fetch_assoc($res_brok))
		{
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$i = $i + 1;
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Brokerage Commission (%)",$rows_brok['BROKAGE_PERCENT'],$rows_brok['BROKAGE_AMT'],$obj->getVendorListNewBasedOnID($rows_brok['VENDORID']));
			$pdf->Row2($arr3);
			  
		}
		
	}
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Brokerage Commission (%)",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PERCENT"),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM"),"");
	$pdf->Row2($arr3);
	
	$sql4 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='ORC'";
	$res4 = mysql_query($sql4);
	$rec4 = mysql_num_rows($res4);
	$i=0;
	while($rows4 = mysql_fetch_assoc($res4))
	{
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getOwnerRelatedCostNameBasedOnID($rows4['IDENTY_ID']),$rows4['COST'],$obj->getVendorListNewBasedOnID($rows4['VENDORID']));
		$pdf->Row2($arr3);
	}
	
	
	
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Hire",0,1,'L');
	
	$pdf->Ln(1);	
	
	$pdf->SetFont('Arial','',7);
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Time Charter (USD/Day)","",$obj->getFun91(),$obj->getVendorListNewBasedOnID($obj->getFun140()));
	$pdf->Row2($arr3);
	
	$sqlinvoice = "select INVOICE_TYPE, INVOICE_NO, BALANCE_TO_OWNER from invoice_hire_master WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and COMID='".$comid."' and STATUS=2 order by INVOICEID";
	$resinvoice = mysql_query($sqlinvoice);
	$numinvoice = mysql_num_rows($resinvoice);
	$hirage = $obj->getFun154();
	while($rowsinvoice = mysql_fetch_assoc($resinvoice))
	{
	    $i = $i + 1;
		$hirage = $hirage - $rowsinvoice['BALANCE_TO_OWNER'];
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($rowsinvoice['INVOICE_NO']. "(".$rowsinvoice['INVOICE_TYPE'].")", "",$rowsinvoice['BALANCE_TO_OWNER'], "");
		$pdf->Row2($arr3);
		if($rowsinvoice['INVOICE_TYPE']=="Interim"){}else{$hirage = 0;}
	}
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Hireage", "",$obj->getFun132(), "");
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Ballast Bonus", "",$obj->getFun145(), "");
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Add Comm (%)", $obj->getFun129(),$obj->getFun130(), "");
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Hireage", "",$obj->getFun131(), "");
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Brokerage (%)", $obj->getFun146(),$obj->getFun147(), "");
	$pdf->Row2($arr3);
	
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("ILOHC", "",$obj->getFun148(), $obj->getVendorListNewBasedOnID($obj->getFun151()));
	$pdf->Row2($arr3);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("CVE",$obj->getFun142(), $obj->getFun143(), $obj->getVendorListNewBasedOnID($obj->getFun144()));
	$pdf->Row2($arr3);
	
	//************************Charterers' Costs***************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Charterers' Costs",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql5 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='CC'";
	$res5 = mysql_query($sql5);
	$rec5 = mysql_num_rows($res5);
	$i=0;
	while($rows5 = mysql_fetch_assoc($res5))
	{
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L','L');
		$arr2=array(50,47,60,60,60);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($rows5['IDENTY_ID'],$rows5['ADDCOMM'],$rows5['COST'],$obj->getVendorListNewBasedOnID($rows5['VENDORID']),$rows5['NET_AMOUNT']);
		$pdf->Row2($arr3);
	
		$i++;
	}
	
	
	
	//**********************Demurrage Dispatch Ship Owner*******************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Ship Owner",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);

	$mysql2 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
	$myres2 = mysql_query($mysql2);
	$myrec2 = mysql_num_rows($myres2);
	$i=0;
	while($myrows2 = mysql_fetch_assoc($myres2))
	{
		$pdf->SetFillColor(255,255,255);
		if($myrows2['IS_SHOW_DDCLP']!=1)
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L','L');
			$arr2=array(50,47,60,60,60);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Load Port ".$obj->getPortNameBasedOnID($myrows2['FROM_PORT']),$myrows2['DDCLP_COMM'],$myrows2['DDCLP_ESTCOST'],$obj->getVendorListNewBasedOnID($myrows2['DDCLP_VENDOR']),$myrows2['DDCLP_REALCOST']);
			$pdf->Row2($arr3);
		}
		if($myrows2['IS_SHOW_DDCDP']!=1)
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L','L');
			$arr2=array(50,47,60,60,60);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Discharge Port ".$obj->getPortNameBasedOnID($myrows2['TO_PORT']),$myrows2['DDCDP_COMM'],$myrows2['DDCDP_ESTCOST'],$obj->getVendorListNewBasedOnID($myrows2['DDCDP_VENDOR']),$myrows2['DDCDP_REALCOST']);
			$pdf->Row2($arr3);
		}
		$i++;
	}
	
	//*************************Other Misc. Income************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Other Misc. Income",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql6 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."' and IDENTIFY='OMI'";
	$res6 = mysql_query($sql6);
	$rec6 = mysql_num_rows($res6);
	$i=0;
	while($rows6 = mysql_fetch_assoc($res6))
	{
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L','L');
		$arr2=array(50,47,60,60,60);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($rows6['IDENTY_ID'],$rows6['ADDCOMM'],$rows6['COST'],$obj->getVendorListNewBasedOnID($rows6['VENDORID']),$rows6['NET_AMOUNT']);
		$pdf->Row2($arr3);
		$i++;
	}
	
	//****************************Results*******************************
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Results",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Revenue (Final Nett Freight)","",$obj->getFun86(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Operational Expenses","",$obj->getFun84(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Port Expenses","",$obj->getFun153(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Bunker Expenses","",$obj->getFun152(),"");
	$pdf->Row2($arr3);
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Charterers' Expenses","",$obj->getFun88(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Voyage Earnings","",$obj->getFun89(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Earnings / TCE","",$obj->getFun90(),"");
	$pdf->Row2($arr3);
	
	
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("G Total Voyage Earnings (Voyage Earnings + Demurrage)","",$obj->getFun92(),"");
	$pdf->Row2($arr3);
	
	
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Daily Profit","",$obj->getFun93(),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("P/L","",$obj->getFun95(),"");
	$pdf->Row2($arr3);
	
	$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")." ".date('d-m-Y').".pdf";

	$pdf->Output($filename,'D');
	//header('Location:./cost_sheet_tci.php?mappingid='.$mappingid.'&cost_sheet_id='.$cost_sheet_id.'&page='.$page);

}


/*********************Update Inops Cost Sheet PDF Close***********************/

function inops_at_glance_insert_cost_sheet_pdf()
{
	
	$mappingid     		= @$_REQUEST['mappingid'];
	$cost_sheet_id 		= @$_REQUEST['cost_sheet_id'];
	$page 		   		= @$_REQUEST['page'];
	
	$obj 				= new data();
	$l_cost_sheet_id 	= $obj->getLatestCostSheetID($mappingid);
						  $obj->viewFreightEstimationRecords($mappingid,$l_cost_sheet_id);
	$actual_sp  		= $obj->getActualSeaPassageData($obj->getFun1());
	$actual_lp  		= $obj->getActualLoadPortData($obj->getFun1());
	$actual_dp  		= $obj->getActualDeschargePortData($obj->getFun1());
	$actual_tp  		= $obj->getActualTransitPortData($obj->getFun1());

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Charter Out Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Charter Out Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Main Particulars",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Nom ID",":",$obj->getMappingData($mappingid,"NOMINATION_ID"),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE")));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Date",":",date("d-m-Y",strtotime($obj->getFun3())),"Voyage No.",":",$obj->getFun6(),"Voyage Financials Name",":",$obj->getCostSheetNameBasedOnID($cost_sheet_id));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("DWT(Summer)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1"),"DWT(Tropical)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1"),"Grain Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Bale Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE"),"SF (CBM/MT)",":",$obj->getFun15(),"Loadable (MT)",":",$obj->getFun16());
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/**********************Market***************************/
	
	$rdoQtyType = $obj->getFun155();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType ==1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','C','L','L','C','L','L','C','L');
		$arr2=array(50,5,50,40,5,50,40,5,40);
		
		$arr3=array("Agreed Gross Freight (Local Currency/MT)",":",$obj->getFun133(),"Currency",":",$obj->getCountryData($obj->getFun134(),'CURRENCY_NAME'),"Exchange Rate",":",$obj->getFun135());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
		
		$arr3=array("Agreed Gross Freight (USD/MT)",":",$obj->getFun47(),"Lumpsum (USD)",":",$obj->getFun48(),"Addnl Cargo Rate (USD/MT)",":",$obj->getFun49());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
	}
	
	else if($rdoQtyType ==2){
		
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L','L','L','L');
		$arr2=array(62,65,70,80);
		$arr3=array("Customer","Agreed Gross Freight (USD/MT)","Quantity (MT)","Gross Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		$i = 0;
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			//$i = $i + 1;
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L');
			$arr2=array(62,65,70,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['AGREED_GROSS_FREIGHT'],$rows2['QUANTITY'],$rows2['GROSS_FREIGHT']);
			$pdf->Row2($arr3);
			$totalQuantity += $rows2['QUANTITY'];
			$totalGrassFreight += $rows2['GROSS_FREIGHT'];
			$i++;
		}
		$pdf->SetFillColor(255,255,255);
		$arr3=array("","",number_format($totalQuantity, 2, '.', ''),number_format($totalGrassFreight, 2, '.', ''));
		$pdf->Row2($arr3);
	}
	
	/**********************Cargo*************************/
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Cargo",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Quantity (MT)",":",$obj->getFun15(),"Cargo Type",":",$obj->getMaterialDescBasedOnMaterialCode($obj->getCargoIDBasedOnMaterialCode($obj->getCompareEstimateData($comid,"MATERIALID"))));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	
	 /**********************Passage Locations***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Passage Locations",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(62,65,70,80);
	$arr3=array("Location From","Location To","Passage Type","Distance");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from fca_tci_sea_passage_location where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	$i = 0;
	$j = 1;
	
	while($rows = mysql_fetch_assoc($res))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L');
	    $arr2=array(62,65,70,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($rows['LOCATION_FROM'],$rows['LOCATION_TO'],$obj->getPassageTypeNameBasedOnID($rows['PASSAGE_TYPE'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEED_TYPE'])." )",$rows['DISTANCE']);
		
		$pdf->Row2($arr3);
		$i++;
		$j++;
	}
	/**********************See Passage***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Sea Passage",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(39,35,35,45,40,30,26,26);
	$arr3=array("From Port","To Port","Passage Type","Distance","Speed Adj.","Margin distance(%)","Estimated (days)","Actual (days)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from fca_tci_sea_passage where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	$i = 0;
	$j = 1;
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L');
		$arr2=array(39,35,35,45,40,30,26,26);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['FROM_PORTID']),$obj->getPortNameBasedOnID($rows1['TO_PORTID']),$obj->getPassageTypeNameBasedOnID($rows1['PASSAGETYPEID'])." (".$obj->getPassageSpeedBasedOnID($rows1['SPEEDID'])." )",$rows1['DISTANCE']." (".$obj->getDistanceTypeBasedOnID_New($rows1['DISTANCE_TYPEID'])." )",$rows1['WEATHER'],$rows1['MARGIN'],$obj->getEstimatedDays($mappingid,$rows1['MARGIN'],$rows1['DISTANCE'],$rows1['SPEEDID'],$rows1['PASSAGETYPEID'],$rows1['WEATHER']),$actual_sp[$j]['ACTUAL_DAYS']);
		
		$pdf->Row2($arr3);
		$i++;
		$j++;
	}
	
	/**********************Load Port(s)***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Load Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);

	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(30,40,30,30,30,30,30,30,26);
	$arr3=array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days","Estimated (days)","Actual (days)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from fca_tci_load_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	$i = 0;
	$j = 1;
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L','L');
		$arr2=array(30,40,30,30,30,30,30,30,26);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['LOADPORTID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION"),$obj->getMappingData($mappingid,"SHIPPING_STAGE")),$rows1['QTY_MT'],$rows1['RATE'],$rows1['PORT_COST'],$rows1['IDLE_DAYS'],$rows1['WORK_DAYS'],$rows1['IDLE_DAYS'] + $rows1['WORK_DAYS'],$actual_lp[$rows1['LOADPORTID']][$j]['ACTUAL_DAYS']);
		
		$pdf->Row2($arr3);	
		$i++;
	}
	
	/**********************Discharge Port***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(30,40,30,30,30,30,30,30,26);
	$arr3=array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days","Estimated (days)","Actual (days)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from fca_tci_disch_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	$i = 0;
	$j = 1;
	
	while($rows2 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L','L','L','L');
		$arr2=array(30,40,30,30,30,30,30,30,26);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows2['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION"),$obj->getMappingData($mappingid,"SHIPPING_STAGE")),$rows2['QTY_MT'],$rows2['RATE'],$rows2['PORT_COST'],$rows2['IDLE_DAYS'],$rows2['WORK_DAYS'],$rows2['IDLE_DAYS'] + $rows2['WORK_DAYS'],$actual_dp[$rows2['DIS_PORT_ID']][$j]['ACTUAL_DAYS']);
		
		$pdf->Row2($arr3);
		$i++;
		$j++;
	}
	
	/**********************Transit Port(s)***************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L');
	$arr2=array(56,55,55,56,54);
	$arr3=array("Transit Port","Port Costs(USD)","Idle Days","Estimated (days)","Actual (days)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql3 = "select * from fca_tci_transit_port where FCAID='".$obj->getFun1()."'";
	$res3 = mysql_query($sql3);
	$rec3 = mysql_num_rows($res3);
	$i = 0;
	$j = 1;
	
	while($rows3 = mysql_fetch_assoc($res3))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L');
		$arr2=array(56,55,55,56,54);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($obj->getPortNameBasedOnID($rows3['LOAD_PORTID']),$rows3['PORT_COST'],$rows3['IDLE_DAYS'],$rows3['IDLE_DAYS'],$actual_tp[$rows3['LOAD_PORTID']][$j]['ACTUAL_DAYS']);
		
		$pdf->Row2($arr3);	
		$i++;
		$j++;
	}
	
	/**********************Totals*****************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Totals",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DIST"),"Ballast Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DIST"),"Total Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TOTAL_DIST"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DAYS"),"Ballast Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DAYS"),"Total Sea Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SEA_DAYS"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl Port Idle Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_IDLE_DAYS"),"Ttl Port Work Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_WORK_DAYS"),"Total Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT"),"Ttl DO Consp MT",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT (Manual)",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL"),"Ttl DO Consp MT (Manual",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT_MANUAL"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp Off Hire",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_OFFHIRE"),"Ttl DO Consp Off Hire",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_OFFHIRE"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	/**************************Freight Adjustment*******************************/

	
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","Percent","USD","Per MT");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Gross Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"GROSS_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"GROSS_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Dead Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"DEAD_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"DEAD_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Addnl Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"ADDNL_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"ADDNL_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Total Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"TTL_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"TTL_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Brokerage",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AGC_PERCENT"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AGC_USD"),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Net Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"NETT_FRT_PAYABLE"),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,70,60,60,37);
		$arr3=array("Customer","Gross Freight (USD)","Brokerage(%)","Net Brokerage","Net Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,70,60,60,37);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['GROSS_FREIGHT'],$rows2['BROKERAGE'],$rows2['NET_BROKERAGE'],$rows2['NET_FREIGHT']);
			
			$netBrokerage += $rows2['NET_BROKERAGE'];
			$netFreight   += $rows2['NET_FREIGHT'];
			
			$pdf->Row2($arr3);	
			$i++;
		}	
		
		$arr3=array("","","",$netBrokerage,$netFreight);	
		$pdf->Row2($arr3);
	}
	
	/**************************Freight Details*******************************/
	
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"FGF_VENDORID")),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"FINAL_NETT_FREIGHT_USD"),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"FNF_MT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}	
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","","","");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['NET_FREIGHT'],$rows2['NET_FREIGHT_PERMT']);
			$pdf->Row2($arr3);	
			$i++;
		}
	
	}
	
	/**************************Bunker Adjustment*******************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');
	
	$pdf->Ln(1);
													
	$sql = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and STATUS=1";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	
	$ttl_bg = array("Select Bunker grade",);
	while($rows = mysql_fetch_assoc($res)){
		$ttl_bg[]  = $rows['NAME'];
		$ttl_bg1[] = $rows['BUNKERGRADEID'];
	} 
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','C','C');
	$arr2=array(92,92,93);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($ttl_bg);

	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("","MT","Price","Cost","MT","Price","Cost");
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Estimated",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_PRICE")));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Supply",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPPLY_COST"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPPLY_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPPLY_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPPLY_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Supplier Adjustment",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPP_ADJ_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPP_ADJ_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"SUPP_ADJ_COST"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPP_ADJ_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPP_ADJ_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"SUPP_ADJ_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(244,244,244);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Supply",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"NETT_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"NETT_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"NETT_COST"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"NETT_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"NETT_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"NETT_COST"));
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('C','C','C','C','C','C','C');
	$arr2=array(92,30,30,32,30,31,32);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Actual Consumption",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"ACTUAL_COST"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"ACTUAL_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"ACTUAL_PRICE"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"ACTUAL_COST"));
	$pdf->Row2($arr3);
	
	/*****************************Bunkers Nett Supply*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Bunkers Nett Supply",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Value/MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$query = "select * from fca_tci_bunker_nett where FCAID='".$obj->getFun1()."'";											
	$qres = mysql_query($query);
	$qrec = mysql_num_rows($qres);
	
	while($qrows = mysql_fetch_assoc($qres))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getBunkerGradeBasedOnID($qrows['BUNKERGRADEID'])."Nett",$qrows['COST'],$obj->getVendorListNewBasedOnID($qrows['VENDORID']),$qrows['COST_MT']);
		$pdf->Row2($arr3);	
		$i++;
	}
	
	/*****************************Owner Related Costs (Others)*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	//$pdf->Cell(190,6,"Owner Related Costs (Others)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql_brok = "select * from fca_tci_brokage_commission where FCAID='".$obj->getFun1()."'";										
	$res_brok = mysql_query($sql_brok);
	$num_brok = mysql_num_rows($res_brok);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	
	if($num_brok==0){
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("Brokerage Commission (%)","","","");
		$pdf->Row2($arr3);
		
	}else{
		$i=0;
		while($rows_brok = mysql_fetch_assoc($res_brok))
		{
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$i = $i + 1;
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Brokerage Commission (%)",$rows_brok['BROKAGE_PERCENT'],$rows_brok['BROKAGE_AMT'],$obj->getVendorListNewBasedOnID($rows_brok['VENDORID']));
			$pdf->Row2($arr3);
			  
		}
		
	}
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Brokerage Commission (%)",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PERCENT"),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM"),"");
	$pdf->Row2($arr3);
	
	$sql4 = "select * from fca_tci_owner_related_cost where FCAID='".$obj->getFun1()."'";
	$res4 = mysql_query($sql4);
	$rec4 = mysql_num_rows($res4);
	$i=0;
	while($rows4 = mysql_fetch_assoc($res4))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$amount = "";
		if($rows4['AMOUNT'] > 0){
			$amount = abs($rows4['AMOUNT']);		
		}else if($rows4['AMOUNT'] < 0){
			$amount = abs($rows4['AMOUNT']);
		}else if($rows4['AMOUNT'] == 0){
			if($obj->getOwnerRelatedCostData($rows4['OWNER_RCOSTID'],"RDO_STATUS") == 1){
				$amount = abs($rows4['AMOUNT']);
			}else if($obj->getOwnerRelatedCostData($rows4['OWNER_RCOSTID'],"RDO_STATUS") == 2){
				$amount = abs($rows4['AMOUNT']);
			}
		}
			
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getOwnerRelatedCostNameBasedOnID($rows4['OWNER_RCOSTID']),"",$amount,$obj->getVendorListNewBasedOnID($rows4['VENDORID']));
		$pdf->Row2($arr3);
		$i = $i + 1;
	}
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Shipowner Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("","","Value/MT",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXP_MT"));
	$pdf->Row2($arr3);
	
	
	/*****************************Charterers' Costs*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Charterers' Costs",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql5 = "select * from fca_tci_charterer_cost where FCAID='".$obj->getFun1()."'";
	$res5 = mysql_query($sql5);
	$rec5 = mysql_num_rows($res5);
	$i=0;
	while($rows5 = mysql_fetch_assoc($res5))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L','L');
		$arr2=array(50,47,60,60,60);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getChartererCostNameBasedOnID($rows5['CHARTERER_COSTID']),$rows5['ADDCOMM'],$rows5['ABSOLUTE'],$obj->getVendorListNewBasedOnID($rows5['VENDORID']),$rows5['COST_MT']);
		$pdf->Row2($arr3);
	
		$i++;
	}
	
	/*****************************Port Costs*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Port Costs",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Value/MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$mysql = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID ASC";
	$myres = mysql_query($mysql);
	$myrec = mysql_num_rows($myres);
	$i=0;
	while($myrows = mysql_fetch_assoc($myres))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows['PORT'] == "Load"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Load Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}
		if($myrows['PORT'] == "Discharge"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Discharge Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}
		
		if($myrows['PORT'] == "Transit"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Transit Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}		
		$i++;
	}
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('Arial','B',7);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Port Costs",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS"),"",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"));
	$pdf->Row2($arr3);
	
	
	/*****************************Demurrage Dispatch Ship Owner*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Ship Owner",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$mysql2 = "select * from fca_tci_dd_shipowner where FCAID='".$obj->getFun1()."'";
	$myres2 = mysql_query($mysql2);
	$myrec2 = mysql_num_rows($myres2);
	
	$i=0;
	while($myrows2 = mysql_fetch_assoc($myres2)){
		$omcvalue = $myrows2['COST'] - (($myrows2['COST'] * $myrows2['ADDCOMM'])/100);
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows2['PORT_TYPE']== "Load")
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L','L');
			$arr2=array(50,47,60,60,60);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Load Port ".$obj->getPortNameBasedOnID($myrows2['LOADPORTID']),$myrows2['ADDCOMM'],$myrows2['COST'],$obj->getVendorListNewBasedOnID($myrows2['VENDORID']),$omcvalue);
			$pdf->Row2($arr3);
		}
		$i++;
	}
	
	$mysql2 = "select * from fca_tci_dd_shipowner where FCAID='".$obj->getFun1()."'";
	$myres2 = mysql_query($mysql2);
	$myrec2 = mysql_num_rows($myres2);
	$i=0;
	while($myrows2 = mysql_fetch_assoc($myres2))
	{
		$omcvalue = $myrows2['COST'] - (($myrows2['COST'] * $myrows2['ADDCOMM'])/100);
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows2['PORT_TYPE']== "Discharge")
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L','L');
			$arr2=array(50,47,60,60,60);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Discharge Port ".$obj->getPortNameBasedOnID($myrows2['LOADPORTID']),$myrows2['ADDCOMM'],$myrows2['COST'],$obj->getVendorListNewBasedOnID($myrows2['VENDORID']),$omcvalue);
			$pdf->Row2($arr3);
		}
		$i++;
	}
	
	/*****************************Other Misc. Income*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Other Misc. Income",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L','L');
	$arr2=array(50,47,60,60,60);
	$arr3=array("","Add Comm(%)","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql6 = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
	$res6 = mysql_query($sql6);
	$rec6 = mysql_num_rows($res6);
	$i=0;
	while($rows6 = mysql_fetch_assoc($res6))
	{
		$omcvalue = $rows6['AMOUNT'] - (($rows6['AMOUNT'] * $rows6['ADDCOMM'])/100);
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L','L');
		$arr2=array(50,47,60,60,60);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getOtherMiscCostNameBasedOnID($rows6['OTHER_MCOSTID']),$rows6['ADDCOMM'],$rows6['AMOUNT'],$obj->getVendorListNewBasedOnID($rows6['VENDORID']),number_format($omcvalue,2,'.',''));
		$pdf->Row2($arr3);
		$i++;
	}
	
	/*****************************Results*******************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Results",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Revenue (Final Nett Freight)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"REVENUE"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Owners Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_OWNER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Charterers' Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_CHARTERER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Voyage Earnings","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"VOYAGE_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Earnings / TCE","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"DAILY_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Time Charter (USD/Day)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"DAILY_VO_EXP"),$obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"VESSEL_OPR_VENDORID")));
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("G Total Voyage Earnings (Voyage Earnings + Demurrage)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"GRAND_TTL_VOYAGE_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Daily Earnings","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Daily Profit","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_PROFIT"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("P/L","",number_format($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_PROFIT")*$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"),2,'.',''),"");
	$pdf->Row2($arr3);
	
	$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")." ".date('d-m-Y').".pdf";

	$pdf->Output($filename,'D');
	header('Location : ./cost_sheet_tci.php?mappingid='.$mappingid.'&cost_sheet_id='.$cost_sheet_id.'&page='.$page);
}

/**********************************************************/
/**********************************************************/
/**********************************************************/
/**********************************************************/

function nomination_cost_sheet_pdf(){
	
	$mappingid     = @$_REQUEST['mappingid'];
	$cost_sheet_id = @$_REQUEST['cost_sheet_id'];
		
	$obj = new data();
	$obj->viewFreightEstimationRecords($mappingid,$cost_sheet_id);
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
					
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	$pdf = new PDF();	
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Voyage Charter Out Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Voyage Charter Out Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	/**********************Main Particulars*************************/
	$pdf->Ln(1);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Main Particulars",0,1,'L');
					
	$arr1 = $arr2 = $arr3 = array();
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Nom ID",":",$obj->getMappingData($mappingid,"NOMINATION_ID"),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE")));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Date",":",date("d-m-Y",strtotime($obj->getFun3())),"Voyage No.",":",$obj->getFun6(),"Voyage Financials Name",":",$obj->getCostSheetNameBasedOnID($cost_sheet_id));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("DWT(Summer)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1"),"DWT(Tropical)",":",$obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1"),"Grain Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$dwtSummer = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1");
	if($dwtSummer != ''){$LoadableMT = $dwtSummer;}else{$LoadableMT = $obj->getFun31();}
	$arr3=array("Bale Cap.(CBM)",":",$obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE"),"SF (CBM/MT)",":",$obj->getFun30(),"Loadable (MT)",":",$LoadableMT);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1($arr3);
	
	/**********************Market***************************/
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType ==1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','C','L','L','C','L','L','C','L');
		$arr2=array(50,5,50,40,5,50,40,5,40);
		
		$arr3=array("Agreed Gross Freight (Local Currency/MT)",":",$obj->getFun33(),"Currency",":",$obj->getCountryData($obj->getFun34(),'CURRENCY_NAME'),"Exchange Rate",":",$obj->getFun35());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
		
		$arr3=array("Agreed Gross Freight (USD/MT)",":",$obj->getFun9(),"Lumpsum (USD)",":",$obj->getFun10(),"Addnl Cargo Rate (USD/MT)",":",$obj->getFun26());
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
	}
	
	elseif($rdoQtyType ==2){
		
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Market",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('L','L','L','L');
		$arr2=array(62,65,70,80);
		$arr3=array("Customer","Agreed Gross Freight (USD/MT)","Quantity (MT)","Gross Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		$i = 0;
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			//$i = $i + 1;
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L');
			$arr2=array(62,65,70,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['AGREED_GROSS_FREIGHT'],$rows2['QUANTITY'],$rows2['GROSS_FREIGHT']);
			$pdf->Row2($arr3);
			$totalQuantity += $rows2['QUANTITY'];
			$totalGrassFreight += $rows2['GROSS_FREIGHT'];
			$i++;
		}
		$pdf->SetFillColor(255,255,255);
		$arr3=array("","",number_format($totalQuantity, 2, '.', ''),number_format($totalGrassFreight, 2, '.', ''));
		$pdf->Row2($arr3);
	}
	
	/**********************Cargo*************************/
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType ==1){
		
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Cargo",0,1,'L');
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(000,000,000);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('L','C','L','L','C','L','L','C','L');
		$arr2=array(50,5,50,40,5,50,40,5,40);
		$arr3=array("Quantity (MT)",":",$obj->getFun15(),"Cargo Type",":",$obj->getCargoNameBasedOnId($obj->getFun16()),"Cargo Name",":",$obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION")));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row1($arr3);
	}
	
	 /**********************Passage Locations***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Passage Locations",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L');
	$arr2=array(62,65,70,80);
	$arr3=array("Location From","Location To","Passage Type","Distance");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql  = "select * from fca_tci_sea_passage_location where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec  = mysql_num_rows($res1);
	$i = 0;
	
	
	while($rows = mysql_fetch_assoc($res))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L');
	    $arr2=array(62,65,70,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($rows['LOCATION_FROM'],$rows['LOCATION_TO'],$obj->getPassageTypeNameBasedOnID($rows['PASSAGE_TYPE'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEED_TYPE'])." )",$rows['DISTANCE']);
		
		$pdf->Row2($arr3);
		$i++;
		
	}
	
	/**********************See Passage***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Sea Passage",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L');
	$arr2=array(39,45,50,45,50,48);
	$arr3=array("From Port","To Port","Passage Type","Distance","Speed Adj.","Margin distance(%)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql = "select * from fca_tci_sea_passage where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql);
	$rec = mysql_num_rows($res1);
	$i = 0;
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L');
		$arr2=array(39,45,50,45,50,48);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['FROM_PORTID']),$obj->getPortNameBasedOnID($rows1['TO_PORTID']),$obj->getPassageTypeNameBasedOnID($rows1['PASSAGETYPEID'])." (".$obj->getPassageSpeedBasedOnID($rows1['SPEEDID'])." )",$rows1['DISTANCE']." (".$obj->getDistanceTypeBasedOnID_New($rows1['DISTANCE_TYPEID'])." )",$rows1['WEATHER'],$rows1['MARGIN']);
		
		$pdf->Row2($arr3);	
		$i++;
	}
	
	/**********************Load Port(s)***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Load Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(30,40,40,40,47,40,40);
	$arr3=array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from fca_tci_load_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	$i = 0;
	
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L');
		$arr2=array(30,40,40,40,47,40,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows1['LOADPORTID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION"),$obj->getMappingData($mappingid,"SHIPPING_STAGE")),$rows1['QTY_MT'],$rows1['RATE'],$rows1['PORT_COST'],$rows1['IDLE_DAYS'],$rows1['WORK_DAYS']);
		
		$pdf->Row2($arr3);	
		$i++;
	}
	
	/**********************Discharge Port***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(30,40,40,40,47,40,40);
	$arr3=array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select * from fca_tci_disch_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	$i = 0;
	
	while($rows2 = mysql_fetch_assoc($res1))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L','L','L','L');
		$arr2=array(30,40,40,40,47,40,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		
		$arr3=array($obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows2['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION"),$obj->getMappingData($mappingid,"SHIPPING_STAGE")),$rows2['QTY_MT'],$rows2['RATE'],$rows2['PORT_COST'],$rows2['IDLE_DAYS'],$rows2['WORK_DAYS']);
		
		$pdf->Row2($arr3);
		$i++;
	}
	
	/**********************Transit Port(s)***************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L');
	$arr2=array(92,92,93);
	$arr3=array("Transit Port","Port Costs(USD)","Idle Days");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql3 = "select * from fca_tci_transit_port where FCAID='".$obj->getFun1()."'";
	$res3 = mysql_query($sql3);
	$rec3 = mysql_num_rows($res3);
	$i = 0;
	
	while($rows3 = mysql_fetch_assoc($res3))
	{
		$arr1 = $arr2 = $arr3 = $arr5 = array();
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','L','L');
		$arr2=array(92,92,93);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$arr3=array($obj->getPortNameBasedOnID($rows3['LOAD_PORTID']),$rows3['PORT_COST'],$rows3['IDLE_DAYS']);
		
		$pdf->Row2($arr3);	
		$i++;
	}
	
	/**********************Totals*****************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Totals",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DIST"),"Ballast Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DIST"),"Total Dist",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TOTAL_DIST"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Laden Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DAYS"),"Ballast Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DAYS"),"Total Sea Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SEA_DAYS"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl Port Idle Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_IDLE_DAYS"),"Ttl Port Work Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_WORK_DAYS"),"Total Days",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT"),"Ttl DO Consp MT",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp MT (Manual)",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL"),"Ttl DO Consp MT (Manual",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT_MANUAL"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
		
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(000,000,000);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(50,5,50,40,5,50,40,5,40);
	$arr3=array("Ttl FO Consp Off Hire",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_OFFHIRE"),"Ttl DO Consp Off Hire",":",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_OFFHIRE"),"","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	/**************************Freight Adjustment*******************************/
	
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","Percent","USD","Per MT");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Gross Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"GROSS_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"GROSS_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Dead Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"DEAD_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"DEAD_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Addnl Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"ADDNL_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"ADDNL_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Total Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"TTL_FREIGHT_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"TTL_FREIGHT_PERMT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(244,244,244);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Brokerage",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AGC_PERCENT"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AGC_USD"),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Net Freight","",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"NETT_FRT_PAYABLE"),"");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,70,60,60,37);
		$arr3=array("Customer","Gross Freight (USD)","Brokerage(%)","Net Brokerage","Net Freight (USD)");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,70,60,60,37);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array($obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['GROSS_FREIGHT'],$rows2['BROKERAGE'],$rows2['NET_BROKERAGE'],$rows2['NET_FREIGHT']);
			
			$netBrokerage += $rows2['NET_BROKERAGE'];
			$netFreight   += $rows2['NET_FREIGHT'];
			
			$pdf->Row2($arr3);	
			$i++;
		}	
		
		$arr3=array("","","",$netBrokerage,$netFreight);	
		$pdf->Row2($arr3);
	}
	
	/**************************Freight Details*******************************/
	
	$rdoQtyType = $obj->getFun31();
	if($rdoQtyType ==""){$rdoQtyType = 1;}
	if($rdoQtyType == 1){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFillColor(255,255,255);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"FGF_VENDORID")),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"FINAL_NETT_FREIGHT_USD"),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"FNF_MT"));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}	
	elseif($rdoQtyType == 2){
		$pdf->Ln(2);
		$pdf->SetFont('Arial','B',10);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Freight Details",0,1,'L');
		
		$pdf->Ln(1);
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$arr3=array("","","","");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
		
		$sql12 = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."'";
		$res12 = mysql_query($sql12);
		$rec12 = mysql_num_rows($res12);
		
		while($rows2 = mysql_fetch_assoc($res12))
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Final Nett Freight",$obj->getVendorListNewBasedOnID($rows2['QTY_VENDORID']),$rows2['NET_FREIGHT'],$rows2['NET_FREIGHT_PERMT']);
			$pdf->Row2($arr3);	
			$i++;
		}
	
	}
	/**************************Bunker Adjustment*******************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');
	
	$pdf->Ln(1);
													
	$sql = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and STATUS=1";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	
	$ttl_bg = array("Select Bunker grade",);
	while($rows = mysql_fetch_assoc($res)){
		$ttl_bg[]  = $rows['NAME'];
		$ttl_bg1[] = $rows['BUNKERGRADEID'];
	}
	
	$arr3 = array($ttl_bg[0],$ttl_bg[1],$ttl_bg[2]);
	
	if(($ttl_bg[1] != '') || ($ttl_bg[2] != '') ){
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','C','C');
		$arr2=array(92,92,93);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	
		$pdf->SetFillColor(244,244,244);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C','C');
		$arr2=array(92,30,30,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("","MT","Price","Cost","MT","Price","Cost");
		$pdf->Row2($arr3);
		
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C','C');
		$arr2=array(92,30,30,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("Estimated",$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[0],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[1],"EST_PRICE")));
		$pdf->Row2($arr3);
		
		$pdf->Ln(1);
	}
	
	$arr3 = array($ttl_bg[3],$ttl_bg[4],$ttl_bg[5]);
	if(($ttl_bg[3] != '') || ($ttl_bg[4] != '') || ($ttl_bg[5] != '') ){
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','C','C');
		$arr2=array(92,92,93);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	
		$pdf->SetFillColor(244,244,244);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C','C','C','C');
		$arr2=array(30,30,32,30,31,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("MT","Price","Cost","MT","Price","Cost","MT","Price","Cost");
		$pdf->Row2($arr3);
		
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C','C','C','C');
		$arr2=array(30,30,32,30,31,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);	
		$arr3=array($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[2],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[2],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[2],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[2],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[3],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[3],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[3],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[3],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[4],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[4],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[4],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[4],"EST_PRICE")));
		
		$pdf->Row2($arr3);
	}
	
	
	$arr3 = array($ttl_bg[6],$ttl_bg[7]);
	if(($ttl_bg[6] != '') || ($ttl_bg[7] != '') ){
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(27,119,166);
		$pdf->SetTextColor(255,255,255);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C','C','C');
		$arr2=array(92,92,93);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	
		$pdf->SetFillColor(244,244,244);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C');
		$arr2=array(30,30,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("MT","Price","Cost","MT","Price","Cost");
		$pdf->Row2($arr3);
		
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(255,255,255);
		$arr1=array('C','C','C','C','C','C');
		$arr2=array(30,30,32,30,31,32);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);	
		$arr3=array($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[5],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[5],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[5],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[5],"EST_PRICE")),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[6],"EST_MT"),$obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[6],"EST_PRICE"),($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[6],"EST_MT"))*($obj->getBunkerValues($obj->getFun1(),$mappingid,$ttl_bg1[6])));
		
		$pdf->Row2($arr3);
	}
	
	/*****************************Owner Related Costs (Others)*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Owner Related Costs (Others)",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);

	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql_brok = "select * from fca_tci_brokage_commission where FCAID='".$obj->getFun1()."'";										
	$res_brok = mysql_query($sql_brok);
	$num_brok = mysql_num_rows($res_brok);
	
	$arr1 = $arr2 = $arr3 = $arr5 = array();
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFillColor(255,255,255);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("Address Commission",$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AC_PERCENT"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AC_USD"),$obj->getFreightEstimationTotalTCIRecords($obj->getFun1(),"AC_PERMT"));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
 
 	if($num_brok==0){
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array("Brokerage Commission (%)","","","");
		$pdf->Row2($arr3);
		
	}else{
		$i=0;
		while($rows_brok = mysql_fetch_assoc($res_brok))
		{
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$i = $i + 1;
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Brokerage Commission (%)",$rows_brok['BROKAGE_PERCENT'],$rows_brok['BROKAGE_AMT'],$obj->getVendorListNewBasedOnID($rows_brok['VENDORID']));
			$pdf->Row2($arr3);
			  
		}
		
	}
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Brokerage Commission (%)",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PERCENT"),$obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM"),"");
	$pdf->Row2($arr3);
	
	$sql4 = "select * from fca_tci_owner_related_cost where FCAID='".$obj->getFun1()."'";
	$res4 = mysql_query($sql4);
	$rec4 = mysql_num_rows($res4);
	$i=0;
	while($rows4 = mysql_fetch_assoc($res4))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$amount = "";
		if($rows4['AMOUNT'] > 0){
			$amount = abs($rows4['AMOUNT']);		
		}else if($rows4['AMOUNT'] < 0){
			$amount = abs($rows4['AMOUNT']);
		}else if($rows4['AMOUNT'] == 0){
			if($obj->getOwnerRelatedCostData($rows4['OWNER_RCOSTID'],"RDO_STATUS") == 1){
				$amount = abs($rows4['AMOUNT']);
			}else if($obj->getOwnerRelatedCostData($rows4['OWNER_RCOSTID'],"RDO_STATUS") == 2){
				$amount = abs($rows4['AMOUNT']);
			}
		}
			
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getOwnerRelatedCostNameBasedOnID($rows4['OWNER_RCOSTID']),"",$amount,$obj->getVendorListNewBasedOnID($rows4['VENDORID']));
		$pdf->Row2($arr3);
		$i = $i + 1;
	}
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Shipowner Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("","","Value/MT",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXP_MT"));
	$pdf->Row2($arr3);
	
	
	/*****************************Charterers' Costs*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Charterers' Costs",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql5 = "select * from fca_tci_charterer_cost where FCAID='".$obj->getFun1()."'";
	$res5 = mysql_query($sql5);
	$rec5 = mysql_num_rows($res5);
	$i=0;
	while($rows5 = mysql_fetch_assoc($res5))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getChartererCostNameBasedOnID($rows5['CHARTERER_COSTID']),$rows5['ABSOLUTE'],$obj->getVendorListNewBasedOnID($rows5['VENDORID']),$rows5['COST_MT']);
		$pdf->Row2($arr3);
	
		$i++;
	}
	
	/*****************************Port Costs*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Port Costs",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Value/MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$mysql = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID ASC";
	$myres = mysql_query($mysql);
	$myrec = mysql_num_rows($myres);
	$i=0;
	while($myrows = mysql_fetch_assoc($myres))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows['PORT'] == "Load"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Load Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}
		if($myrows['PORT'] == "Discharge"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Discharge Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}
		
		if($myrows['PORT'] == "Transit"){
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Transit Port".$obj->getPortNameBasedOnID($myrows['LOADPORTID'])."",$myrows['COST'],$obj->getVendorListNewBasedOnID($myrows['VENDORID']),$myrows['COST_MT']);
			$pdf->Row2($arr3);
		}		
		$i++;
	}
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('Arial','B',7);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Port Costs",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS"),"",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"));
	$pdf->Row2($arr3);
	
	
	/*****************************Demurrage Dispatch Ship Owner*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Ship Owner",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Value/MT");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$mysql2 = "select * from fca_tci_dd_shipowner where FCAID='".$obj->getFun1()."'";
	$myres2 = mysql_query($mysql2);
	$myrec2 = mysql_num_rows($myres2);
	
	$i=0;
	while($myrows2 = mysql_fetch_assoc($myres2)){
	
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows2['PORT_TYPE']== "Load")
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Load Port ".$obj->getPortNameBasedOnID($myrows2['LOADPORTID']),$myrows2['COST'],$obj->getVendorListNewBasedOnID($myrows2['VENDORID']),($myrows2['COST'] / $obj->getFun15()));
			$pdf->Row2($arr3);
		}
		$i++;
	}
	
	$mysql2 = "select * from fca_tci_dd_shipowner where FCAID='".$obj->getFun1()."'";
	$myres2 = mysql_query($mysql2);
	$myrec2 = mysql_num_rows($myres2);
	$i=0;
	while($myrows2 = mysql_fetch_assoc($myres2))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		if($myrows2['PORT_TYPE']== "Discharge")
		{
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','L','L');
			$arr2=array(50,75,76,76);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Discharge Port ".$obj->getPortNameBasedOnID($myrows2['LOADPORTID']),$myrows2['COST'],$obj->getVendorListNewBasedOnID($myrows2['VENDORID']),($myrows2['COST'] / $obj->getFun15()));
			$pdf->Row2($arr3);
		}
		$i++;
	}
	
	/*****************************Other Misc. Income*******************************/
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Other Misc. Income",0,1,'L');
	
	$pdf->Ln(1);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","Cost","Vendor","Nett Value");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql6 = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
	$res6 = mysql_query($sql6);
	$rec6 = mysql_num_rows($res6);
	$i=0;
	while($rows6 = mysql_fetch_assoc($res6))
	{
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C','L','L','L');
		$arr2=array(50,75,76,76);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$arr3=array($obj->getOtherMiscCostNameBasedOnID($rows6['OTHER_MCOSTID']),$rows6['AMOUNT'],$obj->getVendorListNewBasedOnID($rows6['VENDORID']),$rows6['COST_MT']);
		$pdf->Row2($arr3);
		$i++;
	}
	
	/*****************************Results*******************************/
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Results",0,1,'L');
	
	$pdf->Ln(1);
	$pdf->SetFont('Arial','',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$arr3=array("","","","");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Revenue (Final Nett Freight)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"REVENUE"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Owners Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_OWNER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Total Charterers' Expenses","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_CHARTERER_EXP"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Voyage Earnings","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"VOYAGE_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Earnings / TCE","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"DAILY_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Daily Time Charter (USD/Day)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"DAILY_VO_EXP"),$obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"VESSEL_OPR_VENDORID")));
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("G Total Voyage Earnings   (Voyage Earnings + Demurrage)","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"GRAND_TTL_VOYAGE_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Daily Earnings","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_EARNING"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(244,244,244);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Nett Daily Profit","",$obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_PROFIT"),"");
	$pdf->Row2($arr3);
	
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C','L','L','L');
	$arr2=array(50,75,76,76);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("P/L","",number_format($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_DAILY_PROFIT")*$obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"),2,'.',''),"");
	$pdf->Row2($arr3);
	
	$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")." ".date('d-m-Y').".pdf";

	$pdf->Output($filename,'D');
	header('Location : ./update_voyage_charterer.php?mappingid='.$mappingid.'&cost_sheet_id='.$cost_sheet_id);
}

function commercial_parameter_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$id = $_REQUEST['imoid'];
	$user = $_REQUEST['user'];
	
class PDF extends FPDF
{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,160,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(290,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			//$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF('L','mm','Legal');
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Commercial Parameter Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Commercial Parameter Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

if($user == 'EXTERNAL_USER')
{
	$name = $obj->getExternalVesselData($id,"VESSEL_NAME"); 
	$type = $obj->getVesselTypeBasedOnID($obj->getExternalVesselData($id,"VESSEL_TYPE"));
}else{
	$name = $obj->getVesselIMOData($id,"VESSEL_NAME"); 
	$type = $obj->getVesselTypeBasedOnID($obj->getVesselIMOData($id,"VESSEL_TYPE"));
}

if($obj->getVesselParameterData($id,"MAIN_DATA_DATE",$user) != "")
{
	$date = date("d-m-Y",strtotime($obj->getVesselParameterData($id,"MAIN_DATA_DATE",$user)));
}
else
{
	$date = date("d-m-Y",time());
}

if($obj->getVesselIMOData($id,"BUSINESSTYPEID")==3)
{
	$tpc = $obj->getVesselParticularData('SUMMER_3','vessel_master_1',$id);
}
else
{
	$tpc = $obj->getVesselParticularData('TPC_SUMMER','vessel_master_tankers',$id);
}

$pdf->Ln(2);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Main Data",0,1,'L');
$pdf->Ln(3);

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,45,35,5,45,35,5,45);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Vessel Name",":",$name,"Vessel Type",":",$type,"Date",":",$date));
$pdf->Ln(4);

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,45,35,5,45,35,5,45);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("DWT (Summer)",":",$obj->getVesselIMOData($id,"DWT"),"Draft (Summer)",":",$obj->getVesselIMOData($id,"DRAFTM"),"TPC",":",$tpc));
$pdf->Ln(5);

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Speed Data",0,1,'L');

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L','L');
$arr9=array(90,62,62,62);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Full Speed","Service Speed","Most Eco Speed"));

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Ballast Speed (Knots)",$obj->getVesselParameterData($id,"B_FULL_SPEED",$user),$obj->getVesselParameterData($id,"B_ECO_SPEED1",$user),$obj->getVesselParameterData($id,"B_ECO_SPEED2",$user)));
$pdf->Row2(array("Laden Speed (Knots)",$obj->getVesselParameterData($id,"L_FULL_SPEED",$user),$obj->getVesselParameterData($id,"L_ECO_SPEED1",$user),$obj->getVesselParameterData($id,"L_ECO_SPEED2",$user)));
$pdf->Ln(6);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"FO Consp/day(MT) - At Sea",0,1,'L');

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','C','C','C');
$arr9=array(35,100,100,100);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Full Speed","Service Speed","Most Eco Speed"));

$arr8=array('L','C','C','C','C','C','C','C','C','C','C','C','C');
$arr9=array(35,25,25,25,25,25,25,25,25,25,25,25,25);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Bunker","SECA (Ballast)","SECA (Laden)","NON-SECA (Ballast)", "NON-SECA (Laden)", "SECA (Ballast)", "SECA (Laden)", "NON-SECA (Ballast)", "NON-SECA (Laden)", "SECA (Ballast)", "SECA (Laden)", "NON-SECA (Ballast)", "NON-SECA (Laden)"));

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$arr8=array('L','R','R','R','R','R','R','R','R','R','R','R','R');
$arr9=array(35,25,25,25,25,25,25,25,25,25,25,25,25);
$sql = "select * from vessel_commercial_parameters_slave1 where IDENTIFY='FO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($id,"COMMERCIAL_PARAMETERID");
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
{
	$pdf->SetAligns($arr8);
	$pdf->SetWidths($arr9);
	$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows['BUNKERID']), $rows['FO_BALAST_ATSEA_SECA_CONSP_FS'], $rows['FO_LADEN_ATSEA_SECA_CONSP_FS'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_FS'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_FS'], $rows['FO_BALAST_ATSEA_SECA_CONSP_SS'], $rows['FO_LADEN_ATSEA_SECA_CONSP_SS'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_SS'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_SS'], $rows['FO_BALAST_ATSEA_SECA_CONSP_MES'], $rows['FO_LADEN_ATSEA_SECA_CONSP_MES'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_MES'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_MES']));
}

$pdf->Ln(3);
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"DO Consp/day(MT) - At Sea",0,1,'L');

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','C','C','C');
$arr9=array(35,100,100,100);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Full Speed","Service Speed","Most Eco Speed"));

$arr8=array('L','C','C','C','C','C','C','C','C','C','C','C','C');
$arr9=array(35,25,25,25,25,25,25,25,25,25,25,25,25);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Bunker","SECA (Ballast)","SECA (Laden)","NON-SECA (Ballast)", "NON-SECA (Laden)", "SECA (Ballast)", "SECA (Laden)", "NON-SECA (Ballast)", "NON-SECA (Laden)", "SECA (Ballast)", "SECA (Laden)", "NON-SECA (Ballast)", "NON-SECA (Laden)"));

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$arr8=array('L','R','R','R','R','R','R','R','R','R','R','R','R');
$arr9=array(35,25,25,25,25,25,25,25,25,25,25,25,25);
$sql = "select * from vessel_commercial_parameters_slave1 where IDENTIFY='DO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($id,"COMMERCIAL_PARAMETERID");
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
{
	$pdf->SetAligns($arr8);
	$pdf->SetWidths($arr9);
	$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows['BUNKERID']), $rows['FO_BALAST_ATSEA_SECA_CONSP_FS'], $rows['FO_LADEN_ATSEA_SECA_CONSP_FS'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_FS'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_FS'], $rows['FO_BALAST_ATSEA_SECA_CONSP_SS'], $rows['FO_LADEN_ATSEA_SECA_CONSP_SS'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_SS'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_SS'], $rows['FO_BALAST_ATSEA_SECA_CONSP_MES'], $rows['FO_LADEN_ATSEA_SECA_CONSP_MES'], $rows['FO_BALAST_ATSEA_NONSECA_CONSP_MES'], $rows['FO_LADEN_ATSEA_NONSECA_CONSP_MES']));
}




$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"FO Consp/day(MT)- In Port",0,1,'L');

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','C','C','C');
$arr9=array(35,100,100,100);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Working","Idle","Others"));

$arr8=array('L','C','C','C','C','C','C');
$arr9=array(35,50,50,50,50,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Bunker","SECA","NON-SECA","SECA","NON-SECA","SECA","NON-SECA"));

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$arr8=array('L','R','R','R','R','R','R');
$arr9=array(35,50,50,50,50,50,50);
$sql = "select * from vessel_commercial_parameters_slave1 where IDENTIFY='FO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($id,"COMMERCIAL_PARAMETERID");
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
{
	$pdf->SetAligns($arr8);
	$pdf->SetWidths($arr9);
	$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows['BUNKERID']), $rows['FO_INPORT_SECA_CONSP_WORKING'], $rows['FO_INPORT_NONSECA_CONSP_WORKING'], $rows['FO_INPORT_SECA_CONSP_IDLE'], $rows['FO_INPORT_NONSECA_CONSP_IDLE'], $rows['FO_INPORT_SECA_CONSP_OTHER'], $rows['FO_INPORT_NONSECA_CONSP_OTHER']));
}

$pdf->Ln(3);
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"DO Consp/day(MT)- In Port",0,1,'L');

$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','C','C','C');
$arr9=array(35,100,100,100);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Working","Idle","Others"));

$arr8=array('L','C','C','C','C','C','C');
$arr9=array(35,50,50,50,50,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Bunker","SECA","NON-SECA","SECA","NON-SECA","SECA","NON-SECA"));

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$arr8=array('L','R','R','R','R','R','R');
$arr9=array(35,50,50,50,50,50,50);
$sql = "select * from vessel_commercial_parameters_slave1 where IDENTIFY='DO' and COMMERCIAL_PARAMETERID=".$obj->getVesselParameterData($id,"COMMERCIAL_PARAMETERID");
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
{
	$pdf->SetAligns($arr8);
	$pdf->SetWidths($arr9);
	$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows['BUNKERID']), $rows['FO_INPORT_SECA_CONSP_WORKING'], $rows['FO_INPORT_NONSECA_CONSP_WORKING'], $rows['FO_INPORT_SECA_CONSP_IDLE'], $rows['FO_INPORT_NONSECA_CONSP_IDLE'], $rows['FO_INPORT_SECA_CONSP_OTHER'], $rows['FO_INPORT_NONSECA_CONSP_OTHER']));
}


$filename = "Commercial Parameters".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function voyage_financial_estimates_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$selVFEstimate = $_REQUEST['selVFEstimate'];
	$_SESSION['selVFEstimate'] = $selVFEstimate;
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(12);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',9);
			$this->SetFillColor(0,0,0);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(255,255,255);
			
			$arr = explode(",",$_SESSION['selVFEstimate']);
			$arr1=array('L');
			$arr2=array(50);
			$arr3=array("VOYAGE ESTIMATES");
			if(count($arr) > 4){$max = 4;$len = 228/4;}else{$max = count($arr);$len = 228/count($arr);}
			for($i=0;$i<$max;$i++)
			{
				$arr1[]='C';
				$arr2[]=$len;
				$arr3[]=$obj->getFreightCostEstimationTempleteData($arr[$i],"ESTIMATION_NO")."\n(".$obj->getVesselIMOData($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"VESSEL_NAME").' )';
			}
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Voyage Financials Estimates Comparison Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Voyage Financials Estimates Comparison Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFont('Arial','',8);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(128,128,128);
					
$arr1 = $arr2 = $arr3 = array();	
$arr = explode(",",$_REQUEST['selVFEstimate']);
$arr1=array('L');
$arr2=array(50);
$arr3=array("Fixture Type");
if(count($arr) > 4){$max = 4;$len = 228/4;}else{$max = count($arr);$len = 228/count($arr);}
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightFixtureBasedOnID($obj->getFreightCostEstimationTempleteData($arr[$i],"FIXTURETYPEID"));
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();
$arr1=array('L');
$arr2=array(50);
$arr3=array("Vessel Type");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"VESSEL_TYPE"));
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Vessel Name");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getVesselIMOData($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"VESSEL_NAME");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Date");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = date("d M Y",strtotime($obj->getFreightCostEstimationTempleteData($arr[$i],"TRANS_DATE")));
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Voy No.");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteData($arr[$i],"VOYAGE_NO");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("DWT (Summer)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getVesselMaster1Data($obj->getFreightCostEstimationTempleteData($arr[$i],"VESSEL_IMO_ID"),"SUMMER_1");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Cargo Type / Cargo Name");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getCargoTypeNameBasedOnID($obj->getFreightCostEstimationTempleteData($arr[$i],"CARGO_TYPEID")).' / '.$obj->getMaterialCodeDesBasedOnId($obj->getFreightCostEstimationTempleteData($arr[$i],"MATERIALID"));
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Cargo Qty (MT)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteData($arr[$i],"CARGO_QTY");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Load Port");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortNameBasedOnID($arr[$i],"fca_tci_tmp_load_port","LOADPORTID");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Load Rate (MT/Day)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortDataBasedOnID($arr[$i],"fca_tci_tmp_load_port","RATE");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Load Port Cost");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortDataBasedOnID($arr[$i],"fca_tci_tmp_load_port","PORT_COST");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Discharge Port");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortNameBasedOnID($arr[$i],"fca_tci_tmp_disch_port","DIS_PORT_ID");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Discharge Rate (MT/Day)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortDataBasedOnID($arr[$i],"fca_tci_tmp_disch_port","RATE");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Discharge Port Cost");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortDataBasedOnID($arr[$i],"fca_tci_tmp_disch_port","PORT_COST");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Transit Port");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortNameBasedOnID($arr[$i],"fca_tci_tmp_transit_port","LOAD_PORTID");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Transit Port Cost");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFCEPortDataBasedOnID($arr[$i],"fca_tci_tmp_transit_port","PORT_COST");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("TOTAL DAYS");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_DAYS");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Sea Days");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_SEA_DAYS");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Port Idle");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_PORT_IDLE_DAYS");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Port Working");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_PORT_WORK_DAYS");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("FUEL DETAILS");
$pdf->SetFont('Arial','B',9);
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = "";
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("FO Consp (MT)");
$pdf->SetFont('Arial','',8);
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_FO_CONSP_MT");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);


$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("DO Consp (MT)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_DO_CONSP_MT");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("FO Price (USD/MT)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFoConspDataBasedOnID($arr[$i],"EST_PRICE");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("DO Price (USD/MT)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getDoConspDataBasedOnID($arr[$i],"EST_PRICE");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Fuel Cost (USD)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$ttl_fuel_cost = ($obj->getFoConspDataBasedOnID($arr[$i],"EST_MT") * $obj->getFoConspDataBasedOnID($arr[$i],"EST_PRICE")) + ($obj->getDoConspDataBasedOnID($arr[$i],"EST_MT") * $obj->getDoConspDataBasedOnID($arr[$i],"EST_PRICE"));
	$arr3[] = $ttl_fuel_cost;
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Owner Related Cost (USD)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_SHIPOWNER_EXP");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Other Shipping Cost (USD)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getOSCSumTMP($arr[$i]);
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Other Miscellaneous Cost (USD)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getOMCSumTMP($arr[$i]);
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Cell(278,5,"",1,1,'C');

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("RESULTS");
$pdf->SetFont('Arial','B',9);
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = "";
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Revenue (Final Nett Freight)");
$pdf->SetFont('Arial','',8);
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"REVENUE");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Owners Expenses");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_OWNER_EXP");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Total Charterers &rsquo; Expenses");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"TTL_CHARTERER_EXP");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Voyage Earnings");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"VOYAGE_EARNING");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Daily Earnings / TCE");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"DAILY_EARNING");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Daily Time Charter (USD/Day)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"DAILY_VO_EXP");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("G Total Voyage Earnings (Voyage Earnings + Demurrage)");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"GRAND_TTL_VOYAGE_EARNING");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Nett Daily Earnings");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"NETT_DAILY_EARNING");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Nett Daily Earnings");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"NETT_DAILY_EARNING");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("Nett Daily Profit");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"NETT_DAILY_PROFIT");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1 = $arr2 = $arr3 = array();	
$arr1=array('L');
$arr2=array(50);
$arr3=array("P / L");
for($i=0;$i<$max;$i++)
{
	$arr1[] = 'C';
	$arr2[] = $len;
	$arr3[] = $obj->getFreightCostEstimationTempleteTotalRecords($arr[$i],"PL");
}

$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);



$filename = "Voyage Financials Estimates Comparison Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}

function invoice_hire_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$im_id = $_REQUEST['im_id'];

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Laytime Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Laytime Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$sql = "select * from invoice_hire_master where INVOICEID='".$im_id."'";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(30,5,30,30,5,30,30,5,25);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Account Type",":",$rows['ACC_TYPE'],"Hire No.",":",$rows['PAYMENT_NO'],"CP Date",":",date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE")))));

$pdf->Ln(2);
$pdf->Row1(array("Charterer",":",$obj->getVendorListNewBasedOnID($rows['CHARTERER']),"Invoice Date",":",date("d-M-Y",strtotime($rows['INVOICEDATE'])),"Vessel",":",$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME")));

$pdf->Ln(2);
$arr1=array('L','C','L','L','C');
$arr2=array(30,5,30,30,5,90);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Fixture Ref.",":",$obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),"Remarks",":",$rows['REMARKS']));

$pdf->Ln(10);
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('C','C','C','C');
$arr2=array(95,30,30,36);
$arr3=array("Details","USD/Day","Days","Amt");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql1 = "select * from invoice_hire_master_1 where INVOICEID='".$rows['INVOICEID']."'";
$res1 = mysql_query($sql1);
$i = 0;
while($rows1 = mysql_fetch_assoc($res1))
{
	$arr1 = $arr2 = $arr3 = array();	
	$i=$i+1;
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','C','C','C');
	$arr2=array(95,30,30,36);
	$arr3=array($rows1['DETAILS'],$rows1['USD'],$rows1['DAYS'],$rows1['AMT']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}

$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','C');
$arr2=array(155,36);
$arr3=array("Totals",$rows['TTT_AMT']);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Ln(10);
$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L');
$arr2=array(50,5,120);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Name Of Beneficiary",":",$obj->getBankingListNewBasedOnID($rows['NOB'])));

$sql2 = "select * from banking_details where BD_ID='".$rows['NOB']."'";
$res2 = mysql_query($sql2);
$rows2 = mysql_fetch_assoc($res2);

$pdf->Ln(2);
$pdf->Row1(array("Address",":",$rows2['ADDRESS']));

$pdf->Ln(2);
$pdf->Row1(array("Beneficiary A/C No",":",$rows2['AC_NO']));

$pdf->Ln(2);
$pdf->Row1(array("Beneficiary Bank",":",$rows2['BANK']));

$pdf->Ln(2);
$pdf->Row1(array("Beneficiary Bank Address",":",$rows2['B_ADDRESS']));

$pdf->Ln(2);
$pdf->Row1(array("Beneficiary Bank Swift Code",":",$rows2['BANK_SWIFT_CODE']));

$pdf->Ln(2);
$pdf->Row1(array("IBAN No.",":",$rows2['IBAN_NO']));

$pdf->Ln(2);
$pdf->Row1(array("FED ABA",":",$rows2['FED_ABA']));

$sql3 = "select * from banking_details_slave where BD_ID='".$rows['NOB']."' and STATUS=1";
$res3 = mysql_query($sql3);
while($rows3 = mysql_fetch_assoc($res3))
{
	$pdf->Ln(2);
	$pdf->Row1(array($rows3['NAME'],":",$rows3['VALUE']));
}

$pdf->SetFont('Arial','B',8);
$pdf->Ln(2);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L');
$arr2=array(192);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2(array("CORRESPONDENT DETAILS"));

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L');
$arr2=array(50,5,120);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Correspondent Bank Name",":",$rows2['C_BANK_NAME']));

$pdf->Ln(2);
$pdf->Row1(array("Swift Code",":",$rows2['C_SWIFT_CODE']));

$pdf->Ln(2);
$pdf->Row1(array("Reference",":",$rows2['REFERENCE']));

$sql3 = "select * from banking_details_slave where BD_ID='".$rows['NOB']."' and STATUS=2";
$res3 = mysql_query($sql3);
while($rows3 = mysql_fetch_assoc($res3))
{
	$pdf->Ln(2);
	$pdf->Row1(array($rows3['NAME'],":",$rows3['VALUE']));
}


$filename = 'Invoice Hire Report '.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function aging_receivable_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
	
			//$this->SetTextColor(0,0,0);
			//$this->SetFont('Arial','B',10);
			//$this->Cell(278,5,"",0,1,'C');
			$this->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',7);
			$this->SetFillColor(27,119,166);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(241,241,241);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L');
			$arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
			$arr3=array("S.No.","Client","Spot/COA/TC","Nom Id/Voyage No.","Vessel","CP Date","Invoice Type","Invoice No.","Invoice Date","Amount Invoiced","Amount Received","Difference","Delay (Days)");
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
				
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Aging Report (Receivables) Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Aging Report (Receivables) Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

	$selVendor      = $_REQUEST['selVendor'];
	$selBType    	= $_REQUEST['selBType'];
	$selDate_Type 	= $_REQUEST['selDate_Type'];
	$selSpotCOA     = $_REQUEST['selSpotCOA'];
	
	$var = '';
	if($selDate_Type == 1)
	{
	    $var = 1;
	}
	else if($selDate_Type == 2)
	{
	    $from_date = date('Y-m-d',strtotime('-30 days'));
	    $to_date = date('Y-m-d',time());
		$var = 2;
	}
	else if($selDate_Type == 3)
	{
        $from_date = date('Y-m-d',strtotime('-60 days'));
	    $to_date = date('Y-m-d',strtotime('-30 days'));	
		$var = 2;
	}
	else if($selDate_Type == 4)
	{
	    $from_date = date('Y-m-d',strtotime('-90 days'));
	    $to_date = date('Y-m-d',strtotime('-60 days'));	
		$var = 2;
	}
	else if($selDate_Type == 5)
	{
	    $from_date = date('Y-m-d',strtotime('-90 days'));
		$var = 3;
	}

	$pdf->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
	$pdf->SetFont('daxcondensedlight','',8);

	if($selSpotCOA == 3)
	{
	    $selCOASpot1 = 'TC';
		$sql = "select * from chartering_estimate_tc_compare inner join chartering_estimate_tc_master on chartering_estimate_tc_master.TCOUTID= chartering_estimate_tc_compare.TCOUTID WHERE chartering_estimate_tc_compare.MODULEID='".$_SESSION['moduleid']."' AND chartering_estimate_tc_compare.MCOMPANYID='".$_SESSION['company']."' and chartering_estimate_tc_compare.FINAL_ID!='' and chartering_estimate_tc_master.FIXED=1 and chartering_estimate_tc_compare.STATUS in (1,2) and chartering_estimate_tc_master.ESTIMATE_TYPE='".$selBType."' order by chartering_estimate_tc_compare.COMID desc";
	}
	else
	{
		if($selSpotCOA == 2){$subquery = " and freight_cost_estimete_master.COAID is not NULL";$selCOASpot1='COA';}else{$subquery = " and freight_cost_estimete_master.COAID is NULL";$selCOASpot1='Spot';}
		$sql = "select * 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 in (1,2) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$subquery." order by freight_cost_estimate_compare.COMID desc";
	}
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$i = 1;
	if($rec == 0)
	{
		
	}
	else
	{	
	
	    while($rows = mysql_fetch_assoc($res))
		{		
		    if($selSpotCOA == 3)
        	{
				$tcoutid = $obj->getLatestCostSheetIDTC($rows['COMID']);
				$obj->viewTCEstimationTempleteRecordsNew($tcoutid);
				$sqltc = "SELECT * from chartering_tc_estimate_slave1 where TCOUTID='".$obj->getFun1()."'";
				$restc 	= mysql_query($sqltc);
				$rectc 	= mysql_num_rows($restc);
				while($rowstc = mysql_fetch_assoc($restc))
				{
					$currency = $rowstc['EXCHANGE_CURRENCY'];
					if(($_REQUEST['selVendor']!='' && $_REQUEST['selVendor']==$rowstc['TTL_REV_VENDOR']) || $_REQUEST['selVendor'] =='')
					{
						if($var == 1)
						{
							$sql1 = "select * from invoice_tchire_master where COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
						}
						else if($var == 2)
						{
							$sql1 = "select * from invoice_tchire_master where (INVOICE_DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
						}
						else if($var == 3)
						{
							$sql1 = "select * from invoice_tchire_master where INVOICE_DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
						}
						$res1 = mysql_query($sql1) or die($sql1);
						while ($rows1 = mysql_fetch_assoc($res1))
						{
						    $cost_type = 'Hire Invoice';
							$invoice_amt= $rows1['FINAL_AMOUNT'];
							$amt_paid = $rows1['P_AMT'];
							$diff = $invoice_amt - $amt_paid;
							$start = strtotime($rows1['INVOICE_DATE']);
							if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '')
							{
								$end = strtotime(date('Y-m-d',time()));
							}
							else
							{
								$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
							}
							$delay_days = ceil(abs($end - $start) / 86400);
							if($rowstc['TTL_REV_VENDOR']!="")
							{
								$arr1 = $arr2 = $arr3 = array();	
								$pdf->SetFont('daxcondensedlight','',9);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L','R','R','R','R');
			                    $arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
								$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rowstc['TTL_REV_VENDOR']),$selCOASpot1,$obj->getCompareTableDataTC($rows['COMID'],"MESSAGE")."/\n".$obj->getFun7(),$obj->getVesselIMOData($obj->getFun3(),"VESSEL_NAME"),(($obj->getFun9()=='' || $obj->getFun9()=='0000-00-00' || $obj->getFun9()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun9()))),$cost_type,$rows1['INVOICE_NO'],date("d-m-Y",strtotime($rows1['INVOICE_DATE'])),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row($arr3);
								$i++;
							}
						}
					}
					
					if($var == 1)
					{
						$sql1 = "select * from invoice_tcother_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
					}
					else if($var == 2)
					{
						$sql1 = "select * from invoice_tcother_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." (INVOICE_DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
					}
					else if($var == 3)
					{
						$sql1 = "select * from invoice_tcother_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." INVOICE_DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' and RANDOMID='".$rowstc['RANDOMID']."'";
					}
					$res1 = mysql_query($sql1) or die($sql1);
					while($rows1 = mysql_fetch_assoc($res1))
					{
						if($rows1['VENDOR']!="")
						{
							$cost_type = $rows1['INV_IDENTITY'].' '.$rows1['SHORT_DESC'];
							$invoice_amt= $rows1['FINAL_AMOUNT'];
							$amt_paid = $rows1['P_AMT'];
							$diff = $invoice_amt - $amt_paid;
							$start = strtotime($rows1['INVOICE_DATE']);
							if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '')
							{
								$end = strtotime(date('Y-m-d',time()));
							}
							else
							{
								$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
							}
							$delay_days = ceil(abs($end - $start) / 86400);
							
							$arr1 = $arr2 = $arr3 = array();	
							$pdf->SetFont('daxcondensedlight','',9);
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','L','L','L','L','L','L','R','R','R','R');
							$arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
							$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows1['VENDOR']),$selCOASpot1,$obj->getCompareTableDataTC($rows['COMID'],"MESSAGE")."/\n".$obj->getFun7(),$obj->getVesselIMOData($obj->getFun3(),"VESSEL_NAME"),(($obj->getFun9()=='' || $obj->getFun9()=='0000-00-00' || $obj->getFun9()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun9()))),$cost_type,$rows1['INVOICE_NO'],date("d-m-Y",strtotime($rows1['INVOICE_DATE'])),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row($arr3);
							
						    $i++;
						}
					}
				}
			}
			else
			{
				$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
				$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
				if($obj->getFun175()!='')
				{
					$sqlcoa = "select * from coa_master where COAID='".$obj->getFun175()."'";
					$resultcoa = mysql_query($sqlcoa) or die($sqlcoa);
					$rowscoa   = mysql_fetch_assoc($resultcoa);
					$charterer = $obj->getVendorListNewData($rowscoa['CHARTERER'],"NAME");
					$currency = $rowscoa['CURRENCY'];
				}
				else
				{
					$currency = $obj->getFun206();
					
				}
				if($var == 1)
				{
					$sql1 = "select * from other_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." COMID='".$rows['COMID']."'";
				}
				else if($var == 2)
				{
					$sql1 = "select * from other_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." (DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."' ";
				}
				else if($var == 3)
				{
					$sql1 = "select * from other_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' ";
				}
				$res1 = mysql_query($sql1) or die($sql1);
				while ($rows1 = mysql_fetch_assoc($res1))
				{
					$invoice_amt= $rows1['NET_PAYABLE'];
					$amt_paid = $rows1['P_AMT'];
					$diff = $invoice_amt - $amt_paid;
					$cost_type = $rows1['P_TYPE'];
					$start = strtotime($rows1['DATE']);
					if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '')
					{
						$end = strtotime(date('Y-m-d',time()));
					}
					else
					{
						$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
					}
					$delay_days = ceil(abs($end - $start) / 86400);
					if($rows1['VENDOR']!="")
					{
						$arr1 = $arr2 = $arr3 = array();	
						$pdf->SetFont('daxcondensedlight','',9);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L','R','R','R','R');
						$arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
						$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows1['VENDOR']),$selCOASpot1,$obj->getCompareTableData($rows['COMID'],"MESSAGE")."/\n".$obj->getFun8(),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$cost_type,$rows1['MESSAGE'],date("d-m-Y",strtotime($rows1['DATE'])),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row($arr3);
						$i++;
					}
					
					
				}
				if($var == 1)
				{
					$sql1 = "select * from freight_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." COMID='".$rows['COMID']."' ";
				}
				else if($var == 2)
				{
					$sql1 = "select * from freight_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." (DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."'";
				}
				else if($var == 3)
				{
					$sql1 = "select * from freight_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' ";
				}
				$res1 = mysql_query($sql1) or die($sql1);
				while($rows1 = mysql_fetch_assoc($res1))
				{
					if($rows1['VENDOR']!="")
					{
						$cost_type = 'Final Nett Freight';
						$invoice_amt= $rows1['NET_PAYABLE'];
						$amt_paid = $rows1['P_AMT'];
						$diff = $invoice_amt - $amt_paid;
						$start = strtotime($rows1['DATE']);
						if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '0000-00-00' || $rows1['P_DATE'] == '')
						{
							$end = strtotime(date('Y-m-d',time()));
						}
						else
						{
							$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
						}
						$delay_days = ceil(abs($end - $start) / 86400);
						
						$arr1 = $arr2 = $arr3 = array();	
						$pdf->SetFont('daxcondensedlight','',9);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L','R','R','R','R');
						$arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
						$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows1['VENDOR']),$selCOASpot1,$obj->getCompareTableData($rows['COMID'],"MESSAGE")."/\n".$obj->getFun8(),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$cost_type,$rows1['MESSAGE'],date("d-m-Y",strtotime($rows1['DATE'])),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row($arr3);
					$i++;
					}
				}
			}
		}
		
	}
	
	$currency = 'USD';
	if($var == 1)
	{
		$sql1 = "select * from generic_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." CONTRACT_TYPE='".$selSpotCOA."' and BUSINESSTYPEID='".$selBType."' ";
	}
	else if($var == 2)
	{
		$sql1 = "select * from generic_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." (DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."') and CONTRACT_TYPE='".$selSpotCOA."' and BUSINESSTYPEID='".$selBType."'";
	}
	else if($var == 3)
	{
		$sql1 = "select * from generic_invoice_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." DATE<'".date("Y-m-d",strtotime($from_date))."' and CONTRACT_TYPE='".$selSpotCOA."' and BUSINESSTYPEID='".$selBType."'";
	}
	$res1 = mysql_query($sql1) or die($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		if($rows1['VENDOR']!="")
		{
			$cost_type = $rows1['AMOUNT_DESC'];
			$invoice_amt= $rows1['NET_PAYABLE'];
			$amt_paid = $rows1['P_AMT'];
			$diff = $invoice_amt - $amt_paid;
			$start = strtotime($rows1['INVOICE_DATE']);
			if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '0000-00-00' || $rows1['P_DATE'] == '')
			{
				$end = strtotime(date('Y-m-d',time()));
			}
			else
			{
				$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
			}
			$delay_days = ceil(abs($end - $start) / 86400);
			
			$arr1 = $arr2 = $arr3 = array();	
			$pdf->SetFont('daxcondensedlight','',9);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('L','L','L','L','L','L','L','L','L','R','R','R','R');
			$arr2=array(10,30,18,23,21,21,30,21,21,21,21,21,21);
			$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows1['VENDOR']),$obj->getCOA_SPOTBasedOnID($selSpotCOA),'Generic Finances','','',$cost_type,$rows1['INVOICE_NO'],date("d-m-Y",strtotime($rows1['INVOICE_DATE'])),$obj->getNumberFormat($invoice_amt).' '.$currency,$obj->getNumberFormat($amt_paid).' '.$currency,$obj->getNumberFormat($diff).' '.$currency,$delay_days);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row($arr3);
		$i++;
		}
	}

	$filename = "Aging Report (Receivables) ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}

function aging_payable_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$selBType       = $_REQUEST['selBType'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);

			$this->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',7);
			$this->SetFillColor(27,119,166);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(241,241,241);
			$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			$arr2=array(10,30,16,30,25,20,20,25,20,20,20,15,15,15);
			$arr3=array("S.No.","Vendor","COA/Spot","Nom Id/Voyage No.","Vessel","CP Date","Cost Type","Payment No.","Invoice Date","Payment Date","Amount Invoiced","Amount Paid","Difference","Delay (Days)");
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
				
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Aging Report (Payable) Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Aging Report (Payable) Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$selVendor      = $_REQUEST['selVendor'];
	$selDate_Type 	= $_REQUEST['selDate_Type'];
	$selBType       = $_REQUEST['selBType'];
	$selCOASpot     = $_REQUEST['selCOASpot'];
	if($selDate_Type == 1)
	{
	    $var = 1;
	}
	else if($selDate_Type == 2)
	{
	    $from_date = date('Y-m-d',strtotime('-30 days'));
	    $to_date = date('Y-m-d',time());
		$var = 2;
	}
	else if($selDate_Type == 3)
	{
        $from_date = date('Y-m-d',strtotime('-60 days'));
	    $to_date = date('Y-m-d',strtotime('-30 days'));	
		$var = 2;
	}
	else if($selDate_Type == 4)
	{
	    $from_date = date('Y-m-d',strtotime('-90 days'));
	    $to_date = date('Y-m-d',strtotime('-60 days'));	
		$var = 2;
	}
	else if($selDate_Type == 5)
	{
	    $from_date = date('Y-m-d',strtotime('-90 days'));
		$var = 3;
	}
	
	$pdf->SetFont('Arial','',7);

	
	if($selCOASpot == 2){$subquery = " and freight_cost_estimete_master.COAID is not NULL";$selCOASpot1='COA';}else{$subquery = " and freight_cost_estimete_master.COAID is NULL";$selCOASpot1='Spot';}
	$sql = "select * 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 in (1,2) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$subquery." group by freight_cost_estimate_compare.COMID";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$i = 1;
	if($rec == 0)
	{
		$pdf->SetFillColor(255,255,255);
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetDrawColor(241,241,241);
		$arr1=array('C');
		$arr2=array(278);
		$arr3=array("sorry currently there are zero(0) records");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	else
	{	
		while($rows = mysql_fetch_assoc($res))
		{		
		    $fcaid = $obj->getLatestCostSheetID($rows['COMID']);
			$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			if($var == 1)
			{
				$sql1 = "select * from request_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")." COMID='".$rows['COMID']."'";
			}
			else if($var == 2)
			{
				$sql1 = "select * from request_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")."  (INVOICE_DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."' ";
			}
			else if($var == 3)
			{
				$sql1 = "select * from request_master where ".(($_REQUEST['selVendor']!='')?"VENDOR='".$selVendor."' and ":"")."  INVOICE_DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' ";
			}
			$res1 = mysql_query($sql1);
			while ($rows1 = mysql_fetch_assoc($res1))
			{
				if($rows1['NAME_ID'] == 2)
				{
					$cost_type = $rows1['NAME'].' - '.$obj->getBunkerGradeBasedOnID($rows1['GRADEID']);
				}
				else if($rows1['NAME_ID'] == 3)
				{
					if($rows1['GRADEID']==0)
					{
						$cost_type = $rows1['NAME'].' - Brokerage Commission (%)';
					}
					else
					{
					    $sql4 = "select * from freight_cost_estimete_slave3 where FCAID='".$obj->getFun1()."'  and IDENTIFY='ORC' ";
						$res4 = mysql_query($sql4);
						$rec4 = mysql_num_rows($res4);$j=0;
						while($rows4 = mysql_fetch_assoc($res4))
						{$j++;
							if($j==$rows1['GRADEID'])
							{
								$cost_type = $rows1['NAME'].' - '.$obj->getOwnerRelatedCostNameBasedOnID($rows4['IDENTY_ID']);
							}
						}
					}
				}
				
				else if($rows1['NAME_ID'] == 5)
				{
					$cost_type = $rows1['NAME'].' - '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
				}
				
				
				$invoice_amt= $rows1['NET_AMT'];
				$amt_paid = $rows1['P_AMT'];
				$diff = $invoice_amt - $amt_paid;
				
				$start = strtotime($rows1['INVOICE_DATE']);
				if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '')
				{
					$end = strtotime(date('Y-m-d',time()));
				}
				else
				{
				    $end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
				}
				$delay_days = ceil(abs($end - $start) / 86400);
					
				if($rows1['VENDOR']!="")
				{
					$pdf->SetTextColor(0,0,0);
					$pdf->SetFont('Arial','',7);
					$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			        $arr2=array(10,30,16,30,25,20,20,25,20,20,20,15,15,15);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows1['VENDOR']),$selCOASpot1,$obj->getCompareTableData($rows['COMID'],"MESSAGE").'/'.$obj->getFun8(),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$cost_type,$rows1['PAYMENT_NO'],date("d-m-Y",strtotime($rows1['INVOICE_DATE'])),(($rows1['P_DATE']=='' || $rows1['P_DATE']=='0000-00-00' || $rows1['P_DATE']=='1970-01-01')?'':date("d-m-Y",strtotime($rows1['P_DATE']))),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row($arr3);
					$i++;
				}
			}
			if($var == 1)
			{
				$sql1 = "select * from invoice_hire_master where COMID='".$rows['COMID']."' ";
			}
			else if($var == 2)
			{
				$sql1 = "select * from invoice_hire_master where (INVOICE_DATE BETWEEN '".date("Y-m-d",strtotime($from_date))."' and '".date("Y-m-d",strtotime($to_date))."')  and COMID='".$rows['COMID']."'";
			}
			else if($var == 3)
			{
				$sql1 = "select * from invoice_hire_master where INVOICE_DATE<'".date("Y-m-d",strtotime($from_date))."'  and COMID='".$rows['COMID']."' ";
			}
			//echo $sql1;
			$res1 = mysql_query($sql1);
			while($rows1 = mysql_fetch_assoc($res1))
			{
				if(($obj->getCompareEstimateData($rows['COMID'],"DTCVENDORID")!="") || ($selVendor!='' && $selVendor == $obj->getCompareEstimateData($rows['COMID'],"DTCVENDORID")))
				{
					$cost_type = 'Daily Time Charter';
					$invoice_amt= $rows1['FINAL_AMT'];
					$amt_paid = $rows1['P_AMT'];
					$diff = $invoice_amt - $amt_paid;
					
					$start = strtotime($rows1['INVOICE_DATE']);
					if($rows1['P_DATE'] == NULL || date('d-m-Y',strtotime($rows1['P_DATE'])) == '01-01-1970' || $rows1['P_DATE'] == '')
					{
						$end = strtotime(date('Y-m-d',time()));
					}
					else
					{
						$end = strtotime(date('Y-m-d',strtotime($rows1['P_DATE'])));
					}
					$delay_days = ceil(abs($end - $start) / 86400);
					
					$pdf->SetTextColor(0,0,0);
					$pdf->SetFont('Arial','',7);
					$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
			        $arr2=array(10,30,16,30,25,20,20,25,20,20,20,15,15,15);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$arr3=array($i.".",$obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"DTCVENDORID")),$selCOASpot1,$obj->getCompareTableData($rows['COMID'],"MESSAGE").'/'.$obj->getFun8(),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$cost_type,$rows1['INVOICE_NO'],date("d-m-Y",strtotime($rows1['INVOICE_DATE'])),(($rows1['P_DATE']=='' || $rows1['P_DATE']=='0000-00-00' || $rows1['P_DATE']=='1970-01-01')?'':date("d-m-Y",strtotime($rows1['P_DATE']))),$obj->getNumberFormat($invoice_amt),$obj->getNumberFormat($amt_paid),$obj->getNumberFormat($diff),$delay_days);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row($arr3);
					$i++;
				}
			}
		}
	}
	
	
	
	$filename = "Aging Report (Payable) ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}


function dead_freight_summery_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date 		= strtotime($_REQUEST['txtFrom_Date']); 
	$_SESSION['F_DATE'] = date("d-m-Y",strtotime($_REQUEST['txtFrom_Date']));
	$txtTo_Date   		= strtotime($_REQUEST['txtTo_Date']); 
	$_SESSION['T_DATE'] = date("d-m-Y",strtotime($_REQUEST['txtTo_Date']));
	$chk          		= $_REQUEST['chk'];
	$selBType       = $_REQUEST['selBType'];
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
	
	

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Dead Freight Summary Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Dead Freight Summary Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


    $pdf->Ln(2);
	$pdf->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
	$pdf->SetFont('daxcondensedlight','',16);
	$pdf->SetTextColor(17,85,124);
	$pdf->Cell(0,4,"DEAD FREIGHT SUMMARY REPORT",0,1,'C');
	
	
	$pdf->Ln(3);
			
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(7,20,20,20,20,20,33,33,21,21,20,20,20);
	$arr3=array("Sr. No.","Nom Id","Voyage No.","Vessel Name","COA/Spot","CP Date","Shipper","Charterer","Load Port","Discharge Port","Contract Qty (MT)","Dead freight Qty (MT)","Dead freight Amount (USD)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);

	$chk = $_REQUEST['chk'];
	
	$sql = "select * 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 in (1,2) AND freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql) or die($sql);
	$rec = mysql_num_rows($res);
	$i=1; $k=0;
	$cost_sheet_id = "";
	$arr = array();

	if($rec == 0)
	{	
		$pdf->SetFillColor(255,255,255);
		$pdf->SetFont('Arial','',7);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('C');
		$arr2=array(279);
		$arr3=array("sorry currently there are zero(0) records");
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
	else
	{
		while($rows = mysql_fetch_assoc($res))
		{
			$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
            $obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			
			$cpdate = strtotime($obj->getFun112());
			
			if($txtFrom_Date <= $cpdate && $cpdate <= $txtTo_Date)
			{
				if($obj->getFun2() == 2)
				{
					if($chk == 1)
					{
						if($obj->getFun67()!= 0)
						{
							$pdf->SetTextColor(0,0,0);
							$pdf->SetFont('Arial','',7);
							$arr1=array('L','R','R','C','L','L','L','L','L','L','R','R','R');
			                $arr2=array(7,20,20,20,20,20,33,33,21,21,20,20,20);
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							
							$quantity = $dfqty = $dfamt = 0;$coa_spot = '';
							if($obj->getFun175()!='')
							{
								$coa_spot = 'COA'; 
								$sql12 = "select sum(CARGO_MT) as sum1, sum(CARGO_CBM) as sum2 from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS=1";
								$res12 = mysql_query($sql12);
								$row12 = mysql_fetch_assoc($res12);
								if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
								{
									$quantity = $row12['sum2'];
								}
								else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
								{
									$quantity = $row12['sum2'];
								}
								else
								{
								   $quantity = $row12['sum1'];
								}
								$sql12 = "select sum(CARGO_MT) as sum1, sum(CARGO_CBM) as sum2, sum(AMOUNT_USD) as sum3 from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS=3";
								$res12 = mysql_query($sql12);
								$row12 = mysql_fetch_assoc($res12);
								if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
								{
									$dfqty = $row12['sum2'];
								}
								else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
								{
									$dfqty = $row12['sum2'];
								}
								else
								{
								   $dfqty = $row12['sum1'];
								}
								
								$dfamt = $row12['sum3'];
							}
							else
							{
								$coa_spot = 'SPOT';
								if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
								{
									$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
								}
								else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
								{
									$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
								}
								else
								{
									if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
									{
										$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
									}
									else
									{
										$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
										$res12 = mysql_query($sql12);
										$row12 = mysql_fetch_assoc($res12);
										$quantity = $row12['sum'];
									}
									$dfqty = $obj->getFun53();
									$dfamt = $obj->getFun67();
								}
								
							}
							
							if(date("d-M-Y",strtotime($obj->getFun3())) == "01-Jan-1970")
							{
								$cp_date = '';
							}
							else
							{
								$cp_date = date("d-m-Y",strtotime($obj->getFun3()));
							}
							
								
							$arr3=array($i.".",$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getFun8(),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$coa_spot,$cp_date,$obj->getVendorListNewBasedOnID($obj->getOpenCargoPositionData($obj->getFun206(),'SHIPPER')),$obj->getVendorListNewBasedOnID($obj->getOpenCargoPositionData($obj->getFun206(),'CHARTERER')),implode(" , ",$obj->getLoadPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID'])),implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID'])),$quantity,$dfqty,$dfamt);
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row($arr3);	
							$i++;
						}
					}
					else
					{
						$pdf->SetTextColor(0,0,0);
						$pdf->SetFont('Arial','',7);
						$arr1=array('L','R','R','C','L','L','L','L','L','L','R','R','R');
			            $arr2=array(7,20,20,20,20,20,33,33,21,21,20,20,20);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						
						$quantity = $dfqty = $dfamt = 0;$coa_spot = '';
						if($obj->getFun175()!='')
						{
							$coa_spot = 'COA'; 
							$sql12 = "select sum(CARGO_MT) as sum1, sum(CARGO_CBM) as sum2 from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS=1";
							$res12 = mysql_query($sql12);
							$row12 = mysql_fetch_assoc($res12);
							if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
							{
								$quantity = $row12['sum2'];
							}
							else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
							{
								$quantity = $row12['sum2'];
							}
							else
							{
							   $quantity = $row12['sum1'];
							}
							$sql12 = "select sum(CARGO_MT) as sum1, sum(CARGO_CBM) as sum2, sum(AMOUNT_USD) as sum3 from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS=3";
							$res12 = mysql_query($sql12);
							$row12 = mysql_fetch_assoc($res12);
							if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
							{
								$dfqty = $row12['sum2'];
							}
							else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
							{
								$dfqty = $row12['sum2'];
							}
							else
							{
							   $dfqty = $row12['sum1'];
							}
							
							$dfamt = $row12['sum3'];
						}
						else
						{
							$coa_spot = 'SPOT';
							if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
							{
								$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
							}
							else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
							{
								$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
							}
							else
							{
								if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
								{
									$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
								}
								else
								{
									$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
									$res12 = mysql_query($sql12);
									$row12 = mysql_fetch_assoc($res12);
									$quantity = $row12['sum'];
								}
								$dfqty = $obj->getFun53();
								$dfamt = $obj->getFun67();
							}
							
						}
						
						if(date("d-M-Y",strtotime($obj->getFun3())) == "01-Jan-1970")
						{
							$cp_date = '';
						}
						else
						{
							$cp_date = date("d-m-Y",strtotime($obj->getFun3()));
						}
						
							
						$arr3=array($i.".",$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getFun8(),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$coa_spot,$cp_date,$obj->getVendorListNewBasedOnID($obj->getOpenCargoPositionData($obj->getFun206(),'SHIPPER')),$obj->getVendorListNewBasedOnID($obj->getOpenCargoPositionData($obj->getFun206(),'CHARTERER')),implode(" , ",$obj->getLoadPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID'])),implode(" , ",$obj->getDisPortNameArrBasedOnIDComidAndProcessWithoutTBN($rows['COMID'])),$quantity,$dfqty,$dfamt);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row($arr3);	
						$i++;
					}
				}
			}
		}
   }

$filename = "Dead Freight Summary Report ".date("d-m-Y",time()).".pdf";

$pdf->Output($filename,'D');
}



function profitability_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date = strtotime($_REQUEST['txtFrom_Date']); 
	$_SESSION['F_DATE'] = date("d-M-Y",strtotime($_REQUEST['txtFrom_Date']));
	
	$txtTo_Date = strtotime($_REQUEST['txtTo_Date']); 
	$_SESSION['T_DATE'] = date("d-M-Y",strtotime($_REQUEST['txtTo_Date']));
	
	$selBType 	    = $_REQUEST['selBType'];
	$selCOASpot	    = $_REQUEST['selCOASpot'];
	
	$selAmt_Type = $_REQUEST['selAmt_Type']; 
	$_SESSION['TYPE'] = $selAmt_Type;
	
	if($selAmt_Type == 1){$_SESSION['AMT_NAME'] = "Amount Based";}else{$_SESSION['AMT_NAME'] = "Freight Based";}
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
			
			$this->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',7);
			$this->SetFillColor(128,128,128);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(238,238,238);
			$arr1=array('C','L','C','C','C','C','C','C','C','C');
			$arr2=array(10,20,35,38,25,25,31,31,31,31);
			
			$arr3=array("Sr. No.","Nom Id","Vessel","(COA/Spot)/Voyage No.","CP Date","Status","Total Qty. (MT)","Earnings (Including Demurrage)","Expense","Net Earnings");
			
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Profitability Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Profitability Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);

$selBType 	    = $_REQUEST['selBType'];
if($selCOASpot == 2){$subquery = " and freight_cost_estimete_master.COAID is not NULL";}else{$subquery = " and freight_cost_estimete_master.COAID is NULL";}
$sql = "select * 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 in (1,2) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$subquery." order by freight_cost_estimate_compare.COMID desc";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
$j = 1; $k = 0;
if($rec == 0)
{	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C');
	$arr2=array(279);
	$arr3=array("sorry currently there are zero(0) records");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}
else
{
	while($rows = mysql_fetch_assoc($res))
	{
		$var  = 0; 
		$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
		$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
		
		$quantity = 0;
		if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
		{
			$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
		}
		else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
		{
			$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
		}
		else
		{
			if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
			}
			else
			{
				$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
				$res12 = mysql_query($sql12);
				$row12 = mysql_fetch_assoc($res12);
				$quantity = $row12['sum'];
			}
		}
		
		$cpdate = strtotime($obj->getFun112());
		
		if($rows['STATUS'] == '1'){$status = 'In Ops';}else{$status = 'Post Ops';}
		
		$mysql2 = "select sum(DDCDP_NETCOST) as sum2, sum(DDCLP_NETCOST) as sum3 from freight_cost_estimete_slave1 where FCAID='".$fcaid."'";
		$myres2 = mysql_query($mysql2) or die($mysql2);
		$myrows2 = mysql_fetch_assoc($myres2);
		
		$profit = $obj->getFun86() + $myrows2['sum2'] + $myrows2['sum3'];
		
		$expense = $obj->getFun84() + $obj->getFun153() + $obj->getFun152() + $obj->getFun131();
		
		$diff = $profit - $expense;
		
		if($txtFrom_Date <= $cpdate && $cpdate <= $txtTo_Date)
		{
			$arr1 = $arr2 = $arr3 = array();	
			$k=$k+1;
			if($k % 2 == 0)
			{
				$pdf->SetFillColor(244,244,244);
			}
			else
			{
				$pdf->SetFillColor(255,255,255);
			}
			
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','C','C','C','C','R','R','R','R');
			$arr2=array(10,20,35,38,25,25,31,31,31,31);
			if($selCOASpot == 2){
			$coaspotvoyage = 'COA/'.$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NO");
			}else{
			$coaspotvoyage = 'Spot/'.$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NO");
			}	
			$arr3=array($j.".",$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$coaspotvoyage,(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$status,$obj->getNumberFormat($quantity),$obj->getNumberFormat($profit),$expense,$diff);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
			
			$j++;
		}
	}
}

$filename = "Profitability Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}

function pni_club_declaration_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date = strtotime($_REQUEST['txtFrom_Date']); $_SESSION['F_DATE'] = date("d-M-Y",strtotime($_REQUEST['txtFrom_Date']));
	$txtTo_Date = strtotime($_REQUEST['txtTo_Date']); $_SESSION['T_DATE'] = date("d-M-Y",strtotime($_REQUEST['txtTo_Date']));
	$chk = $_REQUEST['chk'];
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);

			//$this->SetTextColor(0,0,0);
			//$this->SetFont('Arial','B',10);
			//$this->Cell(278,5,"",0,1,'C');
			$this->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',7);
			$this->SetFillColor(128,128,128);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(238,238,238);
			$arr1=array('L','L','L','C','C','C','L','L','L');
			$arr2=array(10,34,34,34,34,34,33,33,33);
			$arr3=array("Sr. No.","Nom Id","Vessel Name","CP Date","Material Code","PNI Club Vendor","Amount","Paid","Balance");
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('PNI Club Declaration Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('PNI Club Declaration Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);

$sql = "select * from mapping_master where MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."' and STATUS in (2,5) order by MAPPINGID";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
$i=1; $k=0;
$cost_sheet_id = "";
$arr = array();

if($rec == 0)
{	
	$pdf->SetFillColor(255,255,255);
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('C');
	$arr2=array(279);
	$arr3=array("sorry currently there are zero(0) records");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}
else
{
	
	while($rows = mysql_fetch_assoc($res))
	{
		$l_cost_sheet_id = $obj->getLatestCostSheetID($rows['MAPPINGID']);
		$obj->viewFreightEstimationRecords($rows['MAPPINGID'],$l_cost_sheet_id);
		//$cpdate = strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"));
		$cpdate = strtotime($obj->getFun3());
		
		if($txtFrom_Date <= $cpdate && $cpdate <= $txtTo_Date)
		{
				if($chk == 1)
				{
					if($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"AMOUNT") != 0)
					{
							$arr1 = $arr2 = $arr3 = $arr5 = array();
							$k=$k+1;
							if($k % 2 == 0)
							{
								$pdf->SetFillColor(255,255,255);
							}
							else
							{
								$pdf->SetFillColor(244,244,244);
							}
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','C','C','C','L','L','L');
							$arr2=array(10,34,34,34,34,34,33,33,33);
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							
							if(date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))) == "01-Jan-1970")
							{
								$cp_date == "";
							}
							else
							{
								$cp_date = date("d M Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE")));
							}
							
							if($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"VENDORID") != "")
							{
								$paid = $obj->getPaidRequestAmount($rows['MAPPINGID'],'6','3');
								$final_paid = number_format($paid,2,'.',',');
							}
							else
							{
								$paid = 0.00;
								$final_paid = $paid;
							}
							
							$arr3=array($i.".",$obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($rows['OPEN_VESSEL_ID'],'VESSEL_IMO_ID'),"VESSEL_NAME"),$cp_date,$obj->getCargoContarctForMapping($obj->getMappingData($rows['MAPPINGID'],"CARGO_IDS"),$obj->getMappingData($rows['MAPPINGID'],"CARGO_POSITION")),$obj->getVendorListNewBasedOnID($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"VENDORID")),number_format($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"AMOUNT"),2,'.',','),$final_paid,number_format(($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"AMOUNT") - $paid),2,'.',','));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
							
						$i++;
					}
				}
				else
				{
						$arr1 = $arr2 = $arr3 = $arr5 = array();
						$k=$k+1;
						if($k % 2 == 0)
						{
							$pdf->SetFillColor(255,255,255);
						}
						else
						{
							$pdf->SetFillColor(244,244,244);
						}
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','C','C','C','L','L','L');
						$arr2=array(10,34,34,34,34,34,33,33,33);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						
						if(date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))) == "01-Jan-1970")
						{
							$cp_date == "";
						}
						else
						{
							$cp_date = date("d M Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE")));
						}
						
						if($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"VENDORID") != "")
						{
							$paid = $obj->getPaidRequestAmount($rows['MAPPINGID'],'6','3');
							$final_paid = number_format($paid,2,'.',',');
						}
						else
						{
							$paid = 0.00;
							$final_paid = $paid;
						}
					
					$arr3=array($i.".",$obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($rows['OPEN_VESSEL_ID'],'VESSEL_IMO_ID'),"VESSEL_NAME"),$cp_date,$obj->getCargoContarctForMapping($obj->getMappingData($rows['MAPPINGID'],"CARGO_IDS"),$obj->getMappingData($rows['MAPPINGID'],"CARGO_POSITION")),$obj->getVendorListNewBasedOnID($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"VENDORID")),number_format($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"AMOUNT"),2,'.',','),$final_paid,number_format(($obj->getOtherMiscDetailsBasedOnMappingid($rows['MAPPINGID'],$obj->getFun1(),'3',"AMOUNT") - $paid),2,'.',','));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);		
							
					$i++;
				}
		}
	}
}

$filename = "PNI Club Declaration Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}

function owner_broker_fixture_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$selVendor = $_REQUEST['selVendor'];
	$selBOwner = $_REQUEST['selBOwner'];
	$selBType = $_REQUEST['selBType'];
	if($selBOwner == 11){$label = "Owner";$label1 = "Broker";}else if($selBOwner == 12){$label = "Broker";$label1 = "Owner";}
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

    $pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Owner/Broker Wise Fixture Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Owner/Broker Wise Fixture Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	
	if($selBOwner == 11){$label = "Owner";$label1 = "Broker";}else if($selBOwner == 12){$label = "Broker";$label1 = "Owner";}
	
	$pdf->Ln(4);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(10,30,20,20,20,20,20,20,30);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Sr. No",$label,"Vessel Type","Voyage Financials Name","Vessel Name","CP Date","Contract Qty","Fixture Type",$label1);
	$pdf->Row2($arr3);	

	$sql1 = "select * from vessel_type_master where STATUS=1 and BusinessType='".$selBType."' order by VesselType";
	$res1 = mysql_query($sql1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$sql = "select freight_cost_estimate_compare.COMID, freight_cost_estimete_master.FCAID 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=1 and freight_cost_estimete_master.VESSEL_TYPE='".$rows1['VesselType']."' and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."'  order by freight_cost_estimete_master.FCAID desc";
		$res = mysql_query($sql);
		$rec = mysql_num_rows($res);
		$i=1;
		$cost_sheet_id = "";
		$arr = array();
		while($rows = mysql_fetch_assoc($res))
		{ 
		    $quantity = 0;
			if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
			}
			else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
			}
			else
			{
				if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
				{
					$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
				}
				else
				{
					$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					$quantity = $row12['sum'];
				}
			}
			
			$fcaid = $obj->getCompareEstimateData($rows['COMID'],"FCAID");
			$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			if($selBOwner == 11)
			{  
				if($selVendor == $obj->getFun140())
				{
					$arr1 = $arr2 = $arr3 = $arr5 = array();
					$pdf->SetFillColor(255,255,255);
					$pdf->SetFont('Arial','',6);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
	                $arr2=array(10,30,20,20,20,20,20,20,30);
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					
					$cpdate = $obj->getCompareEstimateData($rows['COMID'],"CP_DATE");
					if(date("d-M-Y",strtotime($cpdate)) == "01-Jan-1970")
					{
						$cpdate = '';
					}
					else
					{
						$cpdate = date("d-m-Y",strtotime($cpdate));
					}
					$sql2 = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";
					$res2 = mysql_query($sql2);
					$rec2 = mysql_num_rows($res2);
					$vendorid = array();
					while($rows2 = mysql_fetch_assoc($res2))
					{
						$vendorid[] = $obj->getVendorListNewBasedOnID($rows2['VENDORID']);
					}
					$arr3=array($i.".",$obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"DTCVENDORID")),$obj->getCompareEstimateData($rows['COMID'],"VESSEL_TYPE"),$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NAME"),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$cp_date,$quantity,$obj->getFreightFixtureBasedOnID($obj->getCompareEstimateData($rows['COMID'],"FIXTURETYPEID")),implode(', ',$vendorid));
					$pdf->Row2($arr3);
					$i++;
				}
			}
			else if($selBOwner == 12)
			{  
				$sql2 = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";
				$res2 = mysql_query($sql2);
				$rec2 = mysql_num_rows($res2);
				$vendorid = array();
				while($rows2 = mysql_fetch_assoc($res2))
				{
					if($selVendor == $rows2['VENDORID'])
					{
						$arr1 = $arr2 = $arr3 = $arr5 = array();
						$pdf->SetFillColor(255,255,255);
						$pdf->SetFont('Arial','',6);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(10,30,20,20,20,20,20,20,30);
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$cpdate = $obj->getCompareEstimateData($rows['COMID'],"CP_DATE");
						if(date("d-M-Y",strtotime($cpdate)) == "01-Jan-1970")
						{
							$cp_date == "";
						}
						else
						{
							$cp_date = date("d-M-Y",strtotime($cpdate));
						}
						$arr3=array($i.".",$obj->getVendorListNewBasedOnID($rows2['VENDORID']),$obj->getCompareEstimateData($rows['COMID'],"VESSEL_TYPE"),$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NAME"),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$cp_date,$quantity,$obj->getFreightFixtureBasedOnID($obj->getCompareEstimateData($rows['COMID'],"FIXTURETYPEID")),$obj->getVendorListNewBasedOnID($obj->getFun140()));
						$pdf->Row2($arr3);
						$i++;
					}
				}
			}	
		}
		if($i > 1)
		{
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			$pdf->SetFillColor(255,255,255);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','C','C');
			$arr2=array(40,30,120);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			
			$arr3=array("Total ".$rows1['VesselType'],($i-1),"");
			$pdf->Row2($arr3);
		}	
	}

$filename = "Owner/Broker Wise Fixture Report ".date("d-m-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function demmurage_summary_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date 		= strtotime($_REQUEST['txtFrom_Date']); 
	$_SESSION['F_DATE'] = date("d-m-Y",strtotime($_REQUEST['txtFrom_Date']));
	$txtTo_Date   		= strtotime($_REQUEST['txtTo_Date']); 
	$_SESSION['T_DATE'] = date("d-m-Y",strtotime($_REQUEST['txtTo_Date']));
	$chk          		= $_REQUEST['chk'];
	$selBType           = $_REQUEST['selBType'];
	if($selBType == 3){$hrdays = 'Days';}else{$hrdays = 'Hrs';}
	$selCOASpot         = $_REQUEST['selCOASpot'];
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}	

	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Demmurage Summary Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Demmurage Summary Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->SetX(3);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(241,241,241);
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(255,255,255); 
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(5,10,10,15,10,15,11,17,16,20,30,22,22,22,22,22,22);
	$arr3=array("Sr. No.","Nom Id","Voyage No.","Vessel Name","COA/ Spot","CP Date","Total Qty.(MT)","Port","Turn Time (Hrs)","TT terms","Load/Dis Port Rate (MT/Day)","Laytime Allowed(".$hrdays.")","Actual Laytime(".$hrdays.")","Time to demurrage/despatch(".$hrdays.")","Demurrage / Dispatch (USD)","Total Demurrage /Dispatch (USD)","Net Freight Effect (USD/MT)");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	if($selCOASpot == 2){$subquery = " and freight_cost_estimate_compare.COAAID is not NULL";}else{$subquery = " and freight_cost_estimate_compare.COAAID is NULL";}

	$sql = "select * 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 in (1,2) AND freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' ".$subquery." order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$j =1;
	if($rec == 0)
	{
		
	}
	else
	{	
		while($rows = mysql_fetch_assoc($res))
		{
			$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
            $obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			$cpdate = strtotime($obj->getFun112());
			if($txtFrom_Date <= $cpdate && $cpdate <= $txtTo_Date)
			{
				$arr       = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);
				$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($comid,$fcaid);
				
				$lp_name = array(); $dp_name =array(); $lp_name_1 = array(); $dp_name_1 = array(); $totals = 0;
				$lp_turnTime = array();$dp_turnTime = array();$lp_ttterms = array();$dp_ttterms = array();$lp_loadRate = array();$dp_loadRate = array();
				$lp_laytime = array();$dp_laytime = array();$lp_Alaytime = array();$dp_Alaytime = array();$lp_timetodum = array();$dp_timetodum = array();
				for($i=0;$i<count($arr);$i++)
				{
					$arr_portval = explode('@@',$arr[$i]);
					if($arr_portval[0] == "LP" && $arr_explode[8]=='')
					{
						$sql1 = "select * from laytime_master where COMID='".$rows['COMID']."' and LOGIN='INTERNAL_USER' and PORT='LP' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."'";
						$res1 = mysql_query($sql1);
						$rec1 = mysql_num_rows($res1);
						$rows1 = mysql_fetch_assoc($res1);
						
						if($rows1['TTL_DEMURRAGE'] == 0 && $rows1['TTL_DESPATCH'] == 0){$value = 0;}
						if($rows1['TTL_DEMURRAGE'] == 0){$value = "-".$rows1['TTL_DESPATCH'];}
						if($rows1['TTL_DESPATCH'] == 0){$value = $rows1['TTL_DEMURRAGE'];}
						
						if($rec1 > 0){$lp_name_1[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$obj->getNumberFormat($value); $totals = $totals+$value;}
						$lp_name[]= 'LP-'.$obj->getPortNameBasedOnID($arr_portval[1]);
						$lp_turnTime[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$obj->getNumberFormat($rows1['TURN_TIME']);
						$lp_ttterms[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['TT_TERMS'];
						$lp_loadRate[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['LOADED_RATE'];
						$lp_laytime[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['LAYTIME_ALLOWED'];
						$lp_Alaytime[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['ACTUAL_LAYTIME'];
						if($rows1['TIME_TO_DEMURRAGE'] >0)
						{$lp_timetodum[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- DEM- '.$rows1['TIME_TO_DEMURRAGE'];}
						else
						{$lp_timetodum[]= 'LP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- DES- '.$rows1['TIME_TO_DESPATCH'];}
					}
					if($arr_portval[0] == "DP" && $arr_explode[8]=='')
					{
						$sql1 = "select * from laytime_master where COMID='".$rows['COMID']."' and LOGIN='INTERNAL_USER' and PORT='DP' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."'";
						$res1 = mysql_query($sql1);
						$rec1 = mysql_num_rows($res1);
						$rows1 = mysql_fetch_assoc($res1);
						
						if($rows1['TTL_DEMURRAGE'] == 0 && $rows1['TTL_DESPATCH'] == 0){$value = 0;}
						if($rows1['TTL_DEMURRAGE'] == 0){$value = "-".$rows1['TTL_DESPATCH'];}
						if($rows1['TTL_DESPATCH'] == 0){$value = $rows1['TTL_DEMURRAGE'];}
						
						if($rec1 > 0){$dp_name_1[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'-'.$obj->getNumberFormat($value); $totals = $totals+$value;}
						$dp_name[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]);
						$dp_turnTime[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'-'.$obj->getNumberFormat($rows1['TURN_TIME']);
						$dp_ttterms[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['TT_TERMS'];
						$dp_loadRate[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['LOADED_RATE'];
						$dp_laytime[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['LAYTIME_ALLOWED'];
						$dp_Alaytime[]= 'DP-'.$obj->getPortNameBasedOnID($arr_portval[1]).'- '.$rows1['ACTUAL_LAYTIME'];
						if($rows1['TIME_TO_DEMURRAGE'] >0)
						{$dp_timetodum[]= 'DP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- DEM- '.$rows1['TIME_TO_DEMURRAGE'];}
						else
						{$dp_timetodum[]= 'DP- '.$obj->getPortNameBasedOnID($arr_portval[1]).'- DES- '.$rows1['TIME_TO_DESPATCH'];}
					}
				}
				
				if(count($lp_name) >0 && count($dp_name) >0)
				{$portsdata = implode(', ',$lp_name).'  '.implode(', ',$dp_name);}
				if(count($lp_name)==0)
				{$portsdata = implode(', ',$dp_name);}
				if(count($dp_name)==0)
				{$portsdata = implode(', ',$lp_name);}
				
				if(count($lp_name_1) >0 && count($dp_name_1) >0)
				{$portsdata_1 = implode(', ',$lp_name_1).'  '.implode(', ',$dp_name_1);}
				if(count($lp_name_1)==0)
				{$portsdata_1 = implode(', ',$dp_name_1);}
				if(count($dp_name_1)==0)
				{$portsdata_1 = implode(', ',$lp_name_1);}
				
				if(count($lp_turnTime) >0 && count($dp_turnTime) >0)
				{$portsdata_2 = implode(', ',$lp_turnTime).'  '.implode(', ',$dp_turnTime);}
				if(count($lp_turnTime)==0)
				{$portsdata_2 = implode(', >',$dp_turnTime);}
				if(count($dp_turnTime)==0)
				{$portsdata_2 = implode(', ',$lp_turnTime);}
				
				if(count($lp_ttterms) >0 && count($dp_ttterms) >0)
				{$portsdata_3 = implode(', ',$lp_ttterms).'  '.implode(', ',$dp_ttterms);}
				if(count($lp_ttterms)==0)
				{$portsdata_3 = implode(', ',$dp_ttterms);}
				if(count($dp_ttterms)==0)
				{$portsdata_3 = implode(', ',$lp_ttterms);}
				
				if(count($lp_loadRate) >0 && count($dp_loadRate) >0)
				{$portsdata_4 = implode(', ',$lp_loadRate).'  '.implode(',  ',$dp_loadRate);}
				if(count($lp_loadRate)==0)
				{$portsdata_4 = implode(', ',$dp_loadRate);}
				if(count($dp_loadRate)==0)
				{$portsdata_4 = implode(', ',$lp_loadRate);}
				
				if(count($lp_laytime) >0 && count($dp_laytime) >0)
				{$portsdata_5 = implode(', ',$lp_laytime).'  '.implode(', ',$dp_laytime);}
				if(count($lp_laytime)==0)
				{$portsdata_5 = implode(', ',$dp_laytime);}
				if(count($dp_laytime)==0)
				{$portsdata_5 = implode(', ',$lp_laytime);}
				
				if(count($lp_Alaytime) >0 && count($dp_Alaytime) >0)
				{$portsdata_6 = implode(', ',$lp_Alaytime).'  '.implode(', ',$dp_Alaytime);}
				if(count($lp_Alaytime)==0)
				{$portsdata_6 = implode(', ',$dp_Alaytime);}
				if(count($dp_Alaytime)==0)
				{$portsdata_6 = implode(', ',$lp_Alaytime);}
				
				if(count($lp_timetodum) >0 && count($dp_timetodum) >0)
				{$portsdata_7 = implode(', ',$lp_timetodum).'  '.implode(', ',$dp_timetodum);}
				if(count($lp_timetodum)==0)
				{$portsdata_7 = implode(', ',$dp_timetodum);}
				if(count($dp_timetodum)==0)
				{$portsdata_7 = implode(', ',$lp_timetodum);}
				
				
				if($chk == 1){if($totals == 0){$var = 0;}else{$var = 1;}}
				else{$var = 1;}
				$quantity = 0;$coa_spot = '';
				if($obj->getFun175()!='')
				{   
				    $coa_spot = 'COA'; 
					$sql12 = "select sum(CARGO_MT) as sum1, sum(CARGO_CBM) as sum2 from freight_cost_estimete_slave10 where FCAID='".$fcaid."' and STATUS=1";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
					{
						$quantity = $row12['sum2'];
					}
					else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
					{
						$quantity = $row12['sum2'];
					}
					else
					{
					   $quantity = $row12['sum1'];
					}
					
				}
				else
				{
					$coa_spot = 'SPOT';
					if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
					{
						$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
					}
					else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
					{
						$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
					}
					else
					{
						if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
						{
							$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
						}
						else
						{
							$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$fcaid."'";
							$res12 = mysql_query($sql12);
							$row12 = mysql_fetch_assoc($res12);
							$quantity = $row12['sum'];
						}
					}
					
				}
				if($var == 1)
				{
				    $pdf->SetX(3);
					$pdf->SetFillColor(255,255,255);
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	                $arr2=array(5,10,10,15,10,15,11,17,16,20,30,22,22,22,22,22,22);
					$net_effect = $totals/$obj->getFun50();
					$arr3=array($j,$obj->getCompareTableData($rows['COMID'],"MESSAGE"), $obj->getFun8(),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$coa_spot,date("d-m-Y",strtotime($obj->getFun3())),$quantity ,$portsdata,$portsdata_2,$portsdata_3,$portsdata_4,$portsdata_5,$portsdata_6,$portsdata_7,$portsdata_1,$obj->getNumberFormat($totals),$obj->getNumberFormat($net_effect));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
					$j++;
				}
			}
		}
	}
	
	

	$filename = "Demmurage Summary Report ".date("d-m-Y",time()).".pdf";
	$pdf->Output($filename,'D');
}

function spot_fixture_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$_SESSION['address'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS");
	$_SESSION['phone'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO");
	$_SESSION['email'] = $obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID");
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetTextColor(17,85,124);
			$this->Cell(0,5,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),0,1,'C');
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->SetTextColor(177,175,175);
		    $this->Ln(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$this->Cell(0,4,$_SESSION['address'],0,1,'C');
			
		}
	}
    
	$pdf = new PDF();
	$pdf->AddPage('L');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Spot Fixtures Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Spot Fixtures Report Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	
	
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	
	$txtFrom_Date = strtotime($_REQUEST['txtFrom_Date']);
	$txtTo_Date   = strtotime($_REQUEST['txtTo_Date']);
	$selBType     = $_REQUEST['selBType'];
	
	$pdf->Ln(4);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(10,27,27,27,27,27,27,27,27,27,27);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Sr. No","Voyage Financials Name","Vessel Name","CP Date","Owner","Broker","Vessel Type","Contract Qty (MT)","Load Port","Discharge Port","Freight (USD)");
	$pdf->Row2($arr3);	
	
	$sql = "select freight_cost_estimate_compare.COMID as COMID, freight_cost_estimete_master.VESSEL_IMO_ID as VESSEL_IMO_ID, freight_cost_estimate_compare.MESSAGE as MESSAGE, freight_cost_estimete_master.COA_SPOT as COA_SPOT, freight_cost_estimete_master.FIXTURETYPEID as FIXTURETYPEID 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=1 and (freight_cost_estimete_master.TRANS_DATE!='0000-00-00' or freight_cost_estimete_master.TRANS_DATE is not NULL) and freight_cost_estimete_master.ESTIMATE_TYPE='".$selBType."' order by freight_cost_estimete_master.FCAID desc"; 
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$i=1;
	$cost_sheet_id = "";
	$arr = array();
	while($rows = mysql_fetch_assoc($res))
	{
		$cp_date = $obj->getCompareEstimateData($rows['COMID'],"TRANS_DATE");
		$cpdate = strtotime($cp_date);
		if($txtFrom_Date <= $cpdate && $cpdate <= $txtTo_Date)
		{
			if($rows['COA_SPOT'] == 1)
			{
				$arr_load = $arr_discharge = array();
				$sql1 = "select FROM_PORT, TO_PORT, LOAD_PORT_COST, LOAD_PORT_QTY, DISC_PORT_COST, DISC_PORT_QTY from freight_cost_estimete_slave1 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
				$res1 = mysql_query($sql1);
				while($row1 = mysql_fetch_assoc($res1))
				{
					if($row1['LOAD_PORT_QTY']>0)
					{
						$arr_load[] = $obj->getPortNameBasedOnID($row1['FROM_PORT']);
					}
					if($row1['DISC_PORT_QTY']>0)
					{
						$arr_discharge[] = $obj->getPortNameBasedOnID($row1['TO_PORT']);
					}
				}
				
				if(date("d-M-Y",strtotime($cp_date)) == "01-Jan-1970")
				{
					$cp_date == "";
				}
				else
				{
					$cp_date = date("d-M-Y",strtotime($cp_date));
				}
				$arr1 = $arr2 = $arr3 = $arr5 = array();
				$pdf->SetFillColor(255,255,255);
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L','L','L','L','L','L','L');
	            $arr2=array(10,27,27,27,27,27,27,27,27,27,27);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				
				$sql2 = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
				$res2 = mysql_query($sql2);
				$rec2 = mysql_num_rows($res2);
				$vendorid = array();
				while($rows2 = mysql_fetch_assoc($res2))
				{
					$vendorid[] = $obj->getVendorListNewBasedOnID($rows2['VENDORID']);
				}
				
				$sql12 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
				$res12 = mysql_query($sql12);
				$rec12 = mysql_num_rows($res12);
				$arr2 = array();
				while($rows2 = mysql_fetch_assoc($res12))
				{
					$arr2[] = $rows2['GROSS_FREIGHT'];
				}
				
				$quantity = $freight = 0;
					if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
					{
						$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
						if($obj->getCompareEstimateData($rows['COMID'],"GAS_MARKET"))
						{
							$freight = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
						}
						else
						{
							$freight = number_format(($obj->getCompareEstimateData($rows['COMID'],"GAS_BALTIC") + $obj->getCompareEstimateData($rows['COMID'],"ADDNL_PRENIUM"))*$obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY"), 2, '.', '');
						}
					}
					else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
					{
						$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
					    if($obj->getCompareEstimateData($rows['COMID'],"TANKER_RADIO_SINGLE_DIS")==1)
						{
						    if($obj->getCompareEstimateData($rows['COMID'],"CHK_LUMPSUM") == 1)
							{

								$freight = $obj->getCompareEstimateData($rows['COMID'],"LUMPSUMAMT");
							}
							else
							{
								$sql12 = "select sum(TOTAL_AMOUNT) as sum1 from freight_cost_estimete_slave12 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
								$res12 = mysql_query($sql12);
								$row12 = mysql_fetch_assoc($res12);
								$freight  = $row12['sum1'];
							}
						}
						else
						{
							$sql12 = "select sum(AMOUNT_USD) as sum1 from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
							$res12 = mysql_query($sql12);
							$row12 = mysql_fetch_assoc($res12);
							$freight  = $row12['sum1'];
						}
					}
					else
					{
						if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
						{
							$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
							$freight  = $obj->getCompareEstimateData($rows['COMID'],"NET_PAYABLE");
						}
						else
						{
							$sql12 = "select sum(QUANTITY) as sum, sum(NET_FREIGHT) as sum2 from freight_cost_estimete_slave7 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
							$res12 = mysql_query($sql12);
							$row12 = mysql_fetch_assoc($res12);
							$quantity = $row12['sum'];
							$freight  = number_format($row12['sum2'], 2, '.', '');
						}
					}
				
				$arr3=array($i.".",$obj->getCompareEstimateData($rows['COMID'],"VOYAGE_NAME"),$obj->getVesselIMOData($obj->getCompareEstimateData($rows['COMID'],"VESSEL_IMO_ID"),"VESSEL_NAME"),$cp_date,$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),implode(', ',$vendorid),$obj->getCompareEstimateData($rows['COMID'],"VESSEL_TYPE"),$quantity,implode(', ',$arr_load),implode(', ',$arr_discharge),$freight);
				$pdf->Row2($arr3);
				$i++;
			}
		}
	}	

$filename = "Spot Fixtures Report ".date("d-m-Y",time()).".pdf";

$pdf->Output($filename,'D');
}

function agent_list_pdf()
{
	$obj = new data();
	$obj->funConnect();
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Agent List Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Agent List Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	$pdf->Ln(4);
	
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('L','L','L','L','L','L','L','L');
	$arr2=array(17,30,20,25,20,25,25,25);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Sr. No","Voyage Financials Name","CP Date","Vessel Name","Port", "Material Code","Agent","Shipper");
	$pdf->Row2($arr3);	
    $selPort = $_REQUEST['selPort'];
	
	$sql = "select * 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 in (1,2) order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$i=1;
	$cost_sheet_id = "";
	$arr = array();
	while($rows = mysql_fetch_assoc($res))
	{
		$l_cost_sheet_id = $obj->getLatestCostSheetID($rows['COMID']);
		$arr = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($rows['COMID'],$l_cost_sheet_id);
		$port_arr = $obj->getPortNameBasedOnID($rows['LPID']);
		for($j=0;$j<count($arr);$j++)
		{
			$arr_portval = explode('@@',$arr[$j]);
			if($selPort == $arr_portval[1])
			{
				$arr1 = $arr2 = $arr3 = $arr5 = array();
				$pdf->SetFillColor(255,255,255);
				$pdf->SetFont('Arial','',6);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L','L','L','L');
				$arr2=array(17,30,20,25,20,25,27,27);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				if(date("d-M-Y",strtotime($rows['TRANS_DATE'])) == "01-Jan-1970")
				{
					$cp_date = '';
				}
				else
				{
					$cp_date = date("d-m-Y",strtotime($rows['TRANS_DATE']));
				}
				
				$mysql = "select * from generate_agency_letter where COMID='".$rows['COMID']."' and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and PORT='".$arr_portval[0]."' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."' and STATUS=2";
				$myres = mysql_query($mysql);
				$myrec = mysql_num_rows($myres);
				if($myrec == 1)
				{
					$myrows  = mysql_fetch_assoc($myres);
					$agent = $obj->getVendorListNewBasedOnID($myrows['VENDORID']);
				}
				else
				{
					$agent = '';
				}
				
				$arr3=array($i.".",$rows['VOYAGE_NAME'],$cp_date,$obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"VESSEL_NAME"),$obj->getPortName($arr_portval[1]),$obj->getMaterialCodeDesBasedOnId($obj->getCompareEstimateData($rows['COMID'],"CARGO_ID")),$agent,$obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"SHIPPER")));
				$pdf->Row2($arr3);
				$i++;
			}
			else if($selPort == "")
			{
				$arr1 = $arr2 = $arr3 = $arr5 = array();
				$pdf->SetFillColor(255,255,255);
				$pdf->SetFont('Arial','',6);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L','L','L','L');
				$arr2=array(17,30,20,25,20,25,27,27);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				
				if(date("d-M-Y",strtotime($rows['TRANS_DATE'])) == "01-Jan-1970")
				{
					$cp_date = '';
				}
				else
				{
					$cp_date = date("d-m-Y",strtotime($rows['TRANS_DATE']));
				}
				$mysql = "select * from generate_agency_letter where COMID='".$rows['COMID']."' and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and PORT='".$arr_portval[0]."' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."' and STATUS=2";
				$myres = mysql_query($mysql);
				$myrec = mysql_num_rows($myres);
				if($myrec == 1)
				{
					$myrows  = mysql_fetch_assoc($myres);
					$agent = $obj->getVendorListNewBasedOnID($myrows['VENDORID']);
				}
				else
				{
					$agent = '';
				}
				
				
				$arr3=array($i.".",$rows['VOYAGE_NAME'],$cp_date,$obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"VESSEL_NAME"),$obj->getPortName($arr_portval[1]),$obj->getMaterialCodeDesBasedOnId($obj->getCompareEstimateData($rows['COMID'],"CARGO_ID")),$agent,$obj->getVendorListNewBasedOnID($obj->getCompareEstimateData($rows['COMID'],"SHIPPER")));
				$pdf->Row2($arr3);
				$i++;
			}
		}
	}

$filename = "Agent List ".date("d-m-Y",time()).".pdf";
$pdf->Output($filename,'D');

}


function TciChecklistpdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['mappingid'])){$mappingid = $_REQUEST['mappingid']; }
	
	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Checklist Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Checklist Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

/************************ For FIXTURE DETAILS *************************/

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"FIXTURE DETAILS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);


$cost_sheet_id = $obj->getLatestCostSheetID($mappingid);
$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);

$sql = "select * from tci_checklist where MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);
$chartPni = $rows['CHARTERER_PNI'];

$pdf->Row1(array("REF ID ",":",$obj->getMappingData($mappingid,"NOM_NAME"),"","","","","",""));

 if(date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE"))) == "01-Jan-1970")
	{
		$cpdate = "";
	}
	else
	{
		$cpdate = date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE")));
	}

$pdf->Row1(array("VESSEL NAME",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"CP DATE",":",$cpdate,"","",""));

$pdf->Row1(array("CHARTERER",":",$obj->getNomDetailsData($mappingid,"CHARTERER"),"OWNER",":",$obj->getCompareEstimateData($comid,"OWNER"),"BROKER",":",$obj->getCompareEstimateData($comid,"BROKER")));

$pdf->Row1(array("DAILY HIRE",":",$rows['DAILY_HIRE'],"OPERATOR",":",$rows['OPERATOR'],"AS",":",$rows['FIXTURE_AS']));

/************************ For VSL DETAILS *************************/

$pdf->Ln(3);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"VSL DETAILS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("BUILT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"YEARBUILT"),"DEADWEIGHT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DWT"),"DRAFT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DRAFTM")));

$pdf->Row1(array("GRT",":",$obj->getVesselParticularData('GT_INATERNATIONAL','vessel_master_1',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID")),"TPC",":",$rows['TPC'],"VESSEL PNI",":",$rows['PL_CLUB']));

if($rows['DG_LICENSE']=="1"){$style_1 = 'checked';} else {$style_1 = 'unchecked';}
if($rows['BUNKER_DECL']=="1"){$style_2 = 'checked';} else {$style_2 = 'unchecked';}
if($rows['CONVERSION_CERT']=="1"){$style_3 = 'checked';} else {$style_3 = 'unchecked';}
if($rows['FIXTURE_NOTE']=="1"){$style_4 = 'checked';} else {$style_4 = 'unchecked';}

$pdf->Row1(array("BALAST SPEED/CONSUMPTION",":",$rows['BALAST_SPEED'],"DG LICENSE",":",$style_1,"BUNKER DECLARATION",":",$style_2));

$pdf->Row1(array("CONVERSION CERTIFICATE",":",$style_3,"FIXTURE NOTE",":",$style_4,"LOADED SPEED/CONSUMPTION",":",$rows['LOADED_SPEED']));

/************************ For VESSEL CHECKS *************************/

//dropdown value print code start
	$query = mysql_query("select * from vendor_master where CODE='$chartPni'");
	$sql_rows = mysql_fetch_assoc($query);
	$value= $sql_rows['NAME']." ( ".$sql_rows['CODE']." )";
//dropdown value print code End

$pdf->Ln(4);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"VESSEL CHECKS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

//$pdf->Image('../../images/icon_delete.gif');

if($rows['REG']=="1"){$style_5 = 'checked';} else {$style_5 = 'unchecked';}
if($rows['CLASS']=="1"){$style_6 = 'checked';} else {$style_6 = 'unchecked';}
if($rows['PNI']=="1"){$style_7 = 'checked';} else {$style_7 = 'unchecked';}
if($rows['ISM']=="1"){$style_8 = 'checked';} else {$style_8 = 'unchecked';}
if($rows['DOC']=="1"){$style_9 = 'checked';} else {$style_9 = 'unchecked';}
if($rows['ITC']=="1"){$style_10 = 'checked';} else {$style_10 = 'unchecked';}
if($rows['ISPS']=="1"){$style_11 = 'checked';} else {$style_11 = 'unchecked';}
if($rows['LL']=="1"){$style_12 = 'checked';} else {$style_12 = 'unchecked';}
if($rows['BQ']=="1"){$style_13 = 'checked';} else {$style_13 = 'unchecked';}
if($rows['H_M']=="1"){$style_14 = 'checked';} else {$style_14 = 'unchecked';}
if($rows['SEA_WEB']=="1"){$style_15 = 'checked';} else {$style_15 = 'unchecked';}
if($rows['CARGODECL_MASTER']=="1"){$style_16 = 'checked';} else {$style_16 = 'unchecked';}
if($rows['CERTBQ_DESK']=="1"){$style_17 = 'checked';} else {$style_17 = 'unchecked';}

$pdf->Row1(array("REG",":",$style_5,"CLASS",":",$style_6,"PNI",":",$style_7));

$pdf->Row1(array("ISM",":",$style_8,"DOC",":",$style_9,"ITC",":",$style_10));

$pdf->Row1(array("ISPS",":",$style_11,"LL",":",$style_12,"BQ",":",$style_13));

$pdf->Row1(array("H&M",":",$style_14,"SEA-WEB",":",$style_15,"CARGO DECL. SIGN MASTER",":",$style_16));

$pdf->Row1(array("CERTIS AND BQ SENT TO INSU. DESK",":",$style_17,"CHARTERERS PNI",":",$value,"LOAD PORT AGENT",":",$rows['LP_AGENT']));

$pdf->Row1(array("WORKING CP",":",$rows['WORKING_CP'],"STRIKE CLUB",":",$rows['STRIKE_CLUB'],"LAST PORT AGENT DETAILS",":",$rows['LP_AGENT_DETAIL']));

$pdf->Row1(array("APPOINT WX ROUTING",":",$rows['APPOINT_ROUTING'],"VOYAGE INSTRUCTIONS SEND TO MASTER",":",$rows['VOLT_INS_MASTER'],"","",""));


/************************ For DELIVERY NOTICES *************************/

$pdf->Ln(5);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"DELIVERY NOTICES",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

if(date("d-M-Y H:i",strtotime($rows['DEL_TENDAYS'])) == '01-Jan-1970 00:00') {$delten_date = "";} else {$delten_date = date("d-M-Y H:i",strtotime($rows['DEL_TENDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['DEL_SEVENDAYS'])) == '01-Jan-1970 00:00') {$delseven_date = "";} else {$delseven_date = date("d-M-Y H:i",strtotime($rows['DEL_SEVENDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['DEL_FIVEDAYS'])) == '01-Jan-1970 00:00') {$delfive_date = "";} else {$delfive_date = date("d-M-Y H:i",strtotime($rows['DEL_FIVEDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['DEL_THREEDAYS'])) == '01-Jan-1970 00:00') {$delthree_date = "";} else {$delthree_date = date("d-M-Y H:i",strtotime($rows['DEL_THREEDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['DEL_TWODAYS'])) == '01-Jan-1970 00:00') {$deltwo_date = "";} else {$deltwo_date = date("d-M-Y H:i",strtotime($rows['DEL_TWODAYS']));}

if(date("d-M-Y H:i",strtotime($rows['DEL_ONEDAY'])) == '01-Jan-1970 00:00') {$delone_date = "";} else {$delone_date = date("d-M-Y H:i",strtotime($rows['DEL_ONEDAY']));}

if(date("d-M-Y H:i",strtotime($rows['DELIVERY_TIME'])) == '01-Jan-1970 00:00') {$del_date_time = "";} else {$del_date_time = date("d-M-Y H:i",strtotime($rows['DELIVERY_TIME']));}

$pdf->Row1(array("10 DAYS",":",$delten_date,"","","","","",""));
$pdf->Row1(array("7 DAYS",":",$delseven_date,"","","","","",""));
$pdf->Row1(array("5 DAYS",":",$delfive_date,"","","","","",""));
$pdf->Row1(array("3 DAYS",":",$delthree_date,"","","","","",""));
$pdf->Row1(array("2 DAYS",":",$deltwo_date,"","","","","",""));
$pdf->Row1(array("1 DAYS",":",$delone_date,"","","","","",""));
$pdf->Row1(array("DELIVERY PLACE",":",$rows['DELIVERY_PLACE'],"DELIVERY DATE/TIME",":",$del_date_time,"IFO",":",$rows['DELIVERY_IFO']));
$pdf->Row1(array("MDO",":",$rows['DELIVERY_MDO'],"","","","","",""));

/************************ For ETA NOTICE *************************/

$pdf->Ln(6);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"ETA NOTICE",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("ON HIRE (CONDITION + BUNKER) SURVERY",":",$rows['ETA_HIRE_SURVERY'],"APPOINT",":",$rows['ETA_APPOINT'],"REPORT",":",$rows['ETA_REPORT']));
$pdf->Row1(array("ILH PURCHASE",":",$rows['ETA_ILH_PURCHASE'],"BUNKER DUTY INVOICE",":",$rows['ETA_BUNKER_INVOICE'],"FREIGHT TAX INVOICE",":",$rows['ETA_FREIGHT_INVOICE']));
$pdf->Row1(array("HIRE",":",$rows['ETA_HIRE'],"","","","","",""));
/****** For HIER ******/

$j=0;
$sql_hier = "select * from tci_checklist_hier where TCI_CHECKLISTID='".$rows['TCI_CHECKLISTID']."'";
$hier_res = mysql_query($sql_hier);
$hier_rec = mysql_num_rows($hier_res);
if($hier_rec > 0)
{ 
	while($hier_rows = mysql_fetch_assoc($hier_res))
	{ 
	$j = $j+1;
	$pdf->Row1(array($hier_rows['HIRE_NAME'],":",$hier_rows['HIRE_VALUE'],"","","","","",""));
	}
}

/************************ For LOADPORT *************************/

$pdf->Ln(7);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"LOADPORT",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

if(count($arr)!=0){
$myarr = array("");
for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "LP")
	{	
		$myarr[] = $arr[$j];
	}
}
$count=count($myarr);
$columns=190/$count;

for($i=0;$i<count($myarr);$i++)
{ $alignment[]='L'; $width_array[]= $columns; }

$arr4=$alignment;
$arr5=$width_array;
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2($myarr);

$arr_1 = array("LAYCAN (OWNER)","LAYCAN (SHIPPER)","SHIPPER","DRAFT RESTRICTION","PARCEL SIZE","LOAD RATE","AGENT","REMARKS 1","","STOW PLAN QTY","SP DEP DRAFT","SP ARR DRAFT","","ETA 10 DAYS","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","ACTUAL ARRIVAL","NOR TENDERED","","COMMENCED","ETC/D","BALANCE","TOTAL","24HRS","COMPLETED","DOCUMENT(S)","REMARKS 2","","DRAFT BL","FINAL B/L QTY1");

for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "LP")
	{
		$sql_query = "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' ";
		$result = mysql_query($sql_query);
		$testres = mysql_fetch_assoc($result);
					
		$lpvessaloper = "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
		$result1 = mysql_query($lpvessaloper);
		$testrec = mysql_fetch_assoc($result1);	
		$balance[] = $testrec['BALANCE'];
		$total[] = $testrec['TTL_LOAD'];
		$loadlast[] = $testrec['LOAD_LAST'];
		$etc_date[] = date("d-M-Y",strtotime($testrec['ETCD']));
		$completed_date[] = date("d-M-Y",strtotime($testrec['PRE_DATE']));
		
		$sof_query = "select * from sof_slave_5";
		$sof_res = mysql_query($sof_query);
		$maxnumrows = mysql_num_rows($sof_res);
		
		$comp_sql = "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
		$rock_rs = mysql_query($comp_sql);
		$min_val = mysql_fetch_assoc($rock_rs);
	
		$comp_sql1 = "select * from sof_slave_5 where SOFSLAVEID='".$min_val['min']."'"; 
		$rock_rs1 = mysql_query($comp_sql1);
		$min_val = mysql_fetch_assoc($rock_rs1);	
		$commenced[] = date("d-M-Y",strtotime($min_val['PRE_DATE']));
		//echo'<pre>';print_r($commenced);
	}
}//die();
				

$j=0;
for($i=0;$i<count($arr_1);$i++)
{   
		unset($myarr1);
		$j=$j+1;
		if($j % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetDrawColor(238,238,238);
			$pdf->SetAligns($arr4);
			$pdf->SetWidths($arr5);
			//$pdf->Row2(array($arr_1[$i]));
			$myarr1[] = $arr_1[$i];
		
			//$myarr1 = array("");
			for($j=0;$j<count($arr);$j++)
			{
				if(substr($arr[$j],0,2) == "LP")
				{	
					$sql1 = mysql_query("select * from tci_checklist_port where PORT='LP' and PORTID='".$port_arr[$j]."' and TCI_CHECKLISTID='".$rows['TCI_CHECKLISTID']."' and ENTITY_NAME='".$arr_1[$i]."'");
					$rows1 = mysql_fetch_assoc($sql1);
					$myarr1[] = $rows1['ENTITY_VALUE'];
				}
			}
			if($i==8)
				{
					$stowagearray=array("STOWAGE PLAN");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==12)
				{
					$stowagearray=array("ETA NOTICES");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==21)
				{
					$stowagearray=array("LOAD PORT VESSEL OPERATIONS");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==30)
				{
					$stowagearray=array("BILL OF LADING");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==31)
				{
					$style_14=array("DRAFT BL");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$style_14[] = 'checked';} else {$style_14[] = 'unchecked';}
					}
					$pdf->Row2($style_14);
				}
				
		/***************** For COMMENCED ****************/
				
				elseif($i==22)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMMENCED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$commenced);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
			/***************** For ETC/D ****************/
				
				elseif($i==23)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("ETC/D");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$etc_date);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
		
	/***************** For BALANCE ****************/
	
				elseif($i==24)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("BALANCE");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$balance);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
					
		/***************** For TOTAL ****************/
		
			elseif($i==25)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("TOTAL");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$total);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
		/***************** For 24HRS ****************/
		
				elseif($i==26)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("24HRS");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$loadlast);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
		/***************** For COMPLETED ****************/
		
				elseif($i==27)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMPLETED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$completed_date);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}			
		/***************** END ****************/
		
				else
				{
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					//echo'<pre>';print_r($myarr1);
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($myarr1);
				}
	
}

		$v = 0;
		$sql_fty = "select * from tci_checklist_finalqty where TCI_CHECKLISTID='".$rows['TCI_CHECKLISTID']."'";
		$fty_res = mysql_query($sql_fty);
		$fty_rec = mysql_num_rows($fty_res);
		
		while($fty_rows = mysql_fetch_assoc($fty_res))
		{	
			$barr[$v] = $fty_rows['FINALQTY_ID'];
			$name_arr[$v] = $fty_rows['ENTITY_NAME'];
			$v++;
		}
		
		$unique_arr = array_values(array_unique($name_arr));
		$count = sizeof($unique_arr);
	
		if($fty_rec>0)
		{
			$kkk=0; 
			for($i=0;$i<$count;$i++)
			{
				$k=0;
				$sql_fty_1 = "select * from tci_checklist_finalqty where TCI_CHECKLISTID='".$rows['TCI_CHECKLISTID']."' and ENTITY_NAME='".$unique_arr[$i]."'";
				
				$fty_res_1 = mysql_query($sql_fty_1);
				$kt=0;
				while($fty_rows_1 = mysql_fetch_assoc($fty_res_1))
				{
					$barr_1[$kt] = $fty_rows_1['ENTITY_VALUE'];
					$kt++;
				}
				
				$fty_name[] = $unique_arr[$i];
				$test = array_slice($fty_name,$i);
				$mergarr = array_merge($test,$barr_1);
				//echo'<pre>';print_r($mergarr);
				
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$pdf->SetDrawColor(238,238,238);
				
				$count1=count($myarr1);
				$columns1=190/$count1;
				
				$arr4=$alignment;
				$arr5=$width_array;
				$pdf->SetAligns($arr4);
				$pdf->SetWidths($arr5);
				$pdf->Row2($mergarr);
		
				
			}
		}
}

/************************ For AFTER LOADPORT *************************/

$pdf->Ln(8);

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("BUNKER PORT",":",$rows['BUNKER_PORT'],"SUPPLIER",":",$rows['SUPPLIER'],"REQUESTED",":",$rows['REQUESTED']));
$pdf->Row1(array("ARRANGED",":",$rows['ARRANGED'],"SUPPLIED",":",$rows['SUPPLIED'],"","",""));

/************************ For DISCHARGE PORT *************************/

if(count($arr)!=0){
$pdf->Ln(9);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"DISCHARGE PORT",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$myarray = array("");
for($l=0;$l<count($arr);$l++)
{
	if(substr($arr[$l],0,2) == "DP")
	{	
		$myarray[] = $arr[$l];
	}
}
$count=count($myarray);
$columns=190/$count;

for($m=0;$m<count($myarray);$m++)
{ $alignment[]='L'; $width_array[]= $columns; }

$arr4=$alignment;
$arr5=$width_array;
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2($myarray);

$disarr = array("PORT (S)","AGENT","DISCHARGE RATE","RECEIVER","REMARKS 3","","LOI FROM RECIVER","LOI TO OWNER","BL MANIFEST","DISCHARGE INSTRUCTION","REMARKS","","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","NOR TENDERED","","COMMENCED","ETC/D","BALANCE","TOTAL","24HRS ","COMPLETED","DOCUMENT(S)","REMARKS 4");

for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "DP")
	{
		$sql_query = "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' ";
		$result = mysql_query($sql_query);
		$testres = mysql_fetch_assoc($result);
					
		$lpvessaloper1 = "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
		$result11 = mysql_query($lpvessaloper1);
		$testrec1 = mysql_fetch_assoc($result11);	
		$balance1[] = $testrec1['BALANCE'];
		$total1[] = $testrec1['TTL_LOAD'];
		$loadlast1[] = $testrec1['LOAD_LAST'];
		$etc_date1[] = date("d-M-Y",strtotime($testrec1['ETCD']));
		$completed_date1[] = date("d-M-Y",strtotime($testrec1['PRE_DATE']));
		//echo'<pre>';print_r($balance);
		
		$sof_query1 = "select * from sof_slave_5";
		$sof_res1 = mysql_query($sof_query1);
		$maxnumrows1 = mysql_num_rows($sof_res1);
		
		$comp_sql1 = "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
		$rock_rs1 = mysql_query($comp_sql1);
		$min_val1 = mysql_fetch_assoc($rock_rs1);
	
		$comp_sql11 = "select * from sof_slave_5 where SOFSLAVEID='".$min_val1['min']."'"; 
		$rock_rs11 = mysql_query($comp_sql11);
		$min_val12 = mysql_fetch_assoc($rock_rs11);	
		$commenced1[] = date("d-M-Y",strtotime($min_val12['PRE_DATE']));
	}
}

$j=0;
for($i=0;$i<count($disarr);$i++)
{   
unset($myarr1);
		$j=$j+1;
		if($j % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetDrawColor(238,238,238);
			$pdf->SetAligns($arr4);
			$pdf->SetWidths($arr5);
			$myarr1[] = $disarr[$i];
		
		for($j=0;$j<count($arr);$j++)
			{
				if(substr($arr[$j],0,2) == "DP")
				{				
					$sql2 = "select * from tci_checklist_port where PORT='DP' and PORTID='".$port_arr[$j]."' and TCI_CHECKLISTID='".$rows['TCI_CHECKLISTID']."' and ENTITY_NAME='".$disarr[$i]."'";
					$res2 = mysql_query($sql2);
					$rows2 = mysql_fetch_assoc($res2);
					$myarr1[] = $rows2['ENTITY_VALUE'];	
				}
			}
			if($i==5)
				{
					$stowagearray=array("LOI");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==6)
				{
					$loifrmrec=array("LOI FROM RECIVER");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==7)
				{
					$loifrmrec=array("LOI TO OWNER");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==8)
				{
					$loifrmrec=array("BL MANIFEST");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==9)
				{
					$loifrmrec=array("DISCHARGE INSTRUCTION");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==11)
				{
					$stowagearray=array("DISCHARGE PORT ETA NOTICES");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==18)
				{
					$stowagearray=array("DISCHARGE PORT VESSEL OPERATIONS");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
/************************* For COMMENCED *****************************/	
			
				elseif($i==19)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMMENCED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$commenced1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For ETC/D *****************************/

				elseif($i==20)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("ETC/D");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$etc_date1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For BALANCE *****************************/

				elseif($i==21)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("BALANCE");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$balance1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For TOTAL *****************************/

				elseif($i==22)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("TOTAL");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$total1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For 24HRS *****************************/		
				
				elseif($i==23)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("24HRS");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$loadlast1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For COMPLETED *****************************/	

				elseif($i==24)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMPLETED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$completed_date1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For END *****************************/	
				else
				{
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($myarr1);
				}
}}

/************************ For RE DELIVERY NOTICES *************************/

$pdf->Ln(10);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"RE DELIVERY NOTICE",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

if(date("d-M-Y H:i",strtotime($rows['REDEL_TENDAYS'])) == '01-Jan-1970 00:00') {$redelten_date = "";} else {$redelten_date = date("d-M-Y H:i",strtotime($rows['REDEL_TENDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_SEVENDAYS'])) == '01-Jan-1970 00:00') {$redelseven_date = "";} else {$redelseven_date = date("d-M-Y H:i",strtotime($rows['REDEL_SEVENDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_FIVEDAYS'])) == '01-Jan-1970 00:00') {$redelfive_date = "";} else {$redelfive_date = date("d-M-Y H:i",strtotime($rows['REDEL_FIVEDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_THREEDAYS'])) == '01-Jan-1970 00:00') {$redelthree_date = "";} else {$redelthree_date = date("d-M-Y H:i",strtotime($rows['REDEL_THREEDAYS']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_TWODAYS'])) == '01-Jan-1970 00:00') {$redeltwo_date = "";} else {$redeltwo_date = date("d-M-Y H:i",strtotime($rows['REDEL_TWODAYS']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_ONEDAY'])) == '01-Jan-1970 00:00') {$redelone_date = "";} else {$redelone_date = date("d-M-Y H:i",strtotime($rows['REDEL_ONEDAY']));}

if(date("d-M-Y H:i",strtotime($rows['REDEL_TIME'])) == '01-Jan-1970 00:00') {$redel_date_time = "";} else {$redel_date_time = date("d-M-Y H:i",strtotime($rows['REDEL_TIME']));}

$pdf->Row1(array("10 DAYS",":",$redelten_date,"","","","","",""));
$pdf->Row1(array("7 DAYS",":",$redelseven_date,"","","","","",""));
$pdf->Row1(array("5 DAYS",":",$redelfive_date,"","","","","",""));
$pdf->Row1(array("3 DAYS",":",$redelthree_date,"","","","","",""));
$pdf->Row1(array("2 DAYS",":",$redeltwo_date,"","","","","",""));
$pdf->Row1(array("1 DAYS",":",$redelone_date,"","","","","",""));
$pdf->Row1(array("DELIVERY PLACE",":",$rows['REDEL_PLACE'],"DELIVERY DATE/TIME",":",$redel_date_time,"FINAL HIRE",":",$rows['REDEL_FINALHIRE']));
$pdf->Row1(array("MDO",":",$rows['REDEL_MDO'],"IFO",":",$rows['REDEL_IFO'],"","",""));

/************************ For LAST PART *************************/

$pdf->Ln(12);
if($rows['LP_FTF']=="1"){$style_18 = 'checked';} else {$style_18 = 'unchecked';}

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("FILED TO FOLDER",":",$style_18,"","","","","",""));
$pdf->Row1(array("REMARKS",":",$rows['REMARKS'],"","","","SIGNATURE","",""));


$filename = "Checklist ".date("d-M-Y",time()).".pdf";
$pdf->Output($filename,'D');

}



function checklistpdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['mappingid'])){$mappingid = $_REQUEST['mappingid']; }
	
	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
		
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Checklist Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Checklist Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

/************************ For FIXTURE DETAILS *************************/

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"FIXTURE DETAILS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);


$cost_sheet_id = $obj->getLatestCostSheetID($mappingid);
$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);

$sql = "select * from check_list where MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);
$chartPni = $rows['CHARTERER_PNI'];

$pdf->Row1(array("REF ID ",":",$obj->getMappingData($mappingid,"NOM_NAME"),"","","","","",""));

 if(date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE"))) == "01-Jan-1970")
	{
		$cpdate = "";
	}
	else
	{
		$cpdate = date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE")));
	}

$pdf->Row1(array("VESSEL NAME",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"CP DATE",":",$cpdate,"","",""));

$pdf->Row1(array("CHARTERER",":",$obj->getNomDetailsData($mappingid,"CHARTERER"),"OWNER",":",$obj->getCompareEstimateData($comid,"OWNER"),"BROKER",":",$obj->getCompareEstimateData($comid,"BROKER")));

$pdf->Row1(array("DEMURRAGE RATE(USD/DAY)",":",$rows['DEMM_RATE'],"OPERATOR",":",$rows['OPERATOR'],"","",""));

/************************ For VSL DETAILS *************************/

$pdf->Ln(3);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"VSL DETAILS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("BUILT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"YEARBUILT"),"DEADWEIGHT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DWT"),"DRAFT",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"DRAFTM")));

$pdf->Row1(array("GRT",":",$obj->getVesselParticularData('GT_INATERNATIONAL','vessel_master_1',$obj->getCompareEstimateData($comid,"VESSEL_IMO_ID")),"TPC",":",$rows['TPC'],"VESSEL P & I",":",$rows['PL_CLUB']));

/************************ For VESSEL CHECKS *************************/

//dropdown value print code start
	$query = mysql_query("select * from vendor_master where CODE='$chartPni'");
	$sql_rows = mysql_fetch_assoc($query);
	$value= $sql_rows['NAME']." ( ".$sql_rows['CODE']." )";
//dropdown value print code End

$pdf->Ln(4);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"VESSEL CHECKS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

if($rows['REG']=="1"){$style_1 = 'checked';} else {$style_1 = 'unchecked';}
if($rows['CLASS']=="1"){$style_2 = 'checked';} else {$style_2 = 'unchecked';}
if($rows['PNI']=="1"){$style_3 = 'checked';} else {$style_3 = 'unchecked';}
if($rows['ISM']=="1"){$style_4 = 'checked';} else {$style_4 = 'unchecked';}
if($rows['DOC']=="1"){$style_5 = 'checked';} else {$style_5 = 'unchecked';}
if($rows['ITC']=="1"){$style_6 = 'checked';} else {$style_6 = 'unchecked';}
if($rows['ISPS']=="1"){$style_7 = 'checked';} else {$style_7 = 'unchecked';}
if($rows['LL']=="1"){$style_8 = 'checked';} else {$style_8 = 'unchecked';}
if($rows['BQ']=="1"){$style_9 = 'checked';} else {$style_9 = 'unchecked';}
if($rows['H_M']=="1"){$style_10 = 'checked';} else {$style_10 = 'unchecked';}
if($rows['SEA_WEB']=="1"){$style_11 = 'checked';} else {$style_11 = 'unchecked';}
if($rows['CARGODECL_MASTER']=="1"){$style_12 = 'checked';} else {$style_12 = 'unchecked';}
if($rows['CERTBQ_DESK']=="1"){$style_13 = 'checked';} else {$style_13 = 'unchecked';}

$pdf->Row1(array("REG",":",$style_1,"CLASS",":",$style_2,"P & I",":",$style_3));

$pdf->Row1(array("ISM",":",$style_4,"DOC",":",$style_5,"ITC",":",$style_6));

$pdf->Row1(array("ISPS",":",$style_7,"LL",":",$style_8,"BQ",":",$style_9));

$pdf->Row1(array("H&M",":",$style_10,"SEA-WEB",":",$style_11,"CARGO DECL. SIGN MASTER",":",$style_12));

$pdf->Row1(array("CERTS AND IOC WRAP SENT TO INSURENCE DESK",":",$style_13,"CHARTERERS P & I",":",$value,"LOAD PORT AGENT",":",$rows['LPA_DETAIL']));

$pdf->Row1(array("WORKING CP",":",$rows['WORKING_CP'],"","","","","",""));

/************************ For LOADPORT *************************/
if(count($arr)!=0){

$pdf->Ln(5);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"LOADPORT",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$myarr = array("");
for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "LP")
	{	
		$myarr[] = $arr[$j];
	}
}
$count=count($myarr);
$columns=190/$count;

for($i=0;$i<count($myarr);$i++)
{ $alignment[]='L'; $width_array[]= $columns; }

$arr4=$alignment;
$arr5=$width_array;
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2($myarr);

$arr_1 = array("LAYCAN (OWNER)","LAYCAN (SHIPPER)","SHIPPER","DRAFT RESTRICTION","PARCEL SIZE","LOAD RATE","AGENT","REMARKS 1","","STOW PLAN QTY","SP DEP DRAFT","SP ARR DRAFT","","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","ACTUAL ARRIVAL","NOR TENDERED","","COMMENCED","ETC/D","BALANCE","TOTAL","24HRS","COMPLETED","DOCUMENT(S)","REMARKS 2","","DRAFT BL","FINAL B/L QTY1","FINAL B/L QTY2","FINAL B/L QTY3","FINAL B/L QTY4");

for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "LP")
	{
		$sql_query = "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' ";
		$result = mysql_query($sql_query);
		$testres = mysql_fetch_assoc($result);
					
		$lpvessaloper = "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
		$result1 = mysql_query($lpvessaloper);
		$testrec = mysql_fetch_assoc($result1);	
		$balance[] = $testrec['BALANCE'];
		$total[] = $testrec['TTL_LOAD'];
		$loadlast[] = $testrec['LOAD_LAST'];
		$etc_date[] = date("d-M-Y",strtotime($testrec['ETCD']));
		$completed_date[] = date("d-M-Y",strtotime($testrec['PRE_DATE']));
		
		$sof_query = "select * from sof_slave_5";
		$sof_res = mysql_query($sof_query);
		$maxnumrows = mysql_num_rows($sof_res);
		
		$comp_sql = "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='LP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
		$rock_rs = mysql_query($comp_sql);
		$min_val = mysql_fetch_assoc($rock_rs);
	
		$comp_sql1 = "select * from sof_slave_5 where SOFSLAVEID='".$min_val['min']."'"; 
		$rock_rs1 = mysql_query($comp_sql1);
		$min_val = mysql_fetch_assoc($rock_rs1);	
		$commenced[] = date("d-M-Y",strtotime($min_val['PRE_DATE']));
	}
}

$j=0;
for($i=0;$i<count($arr_1);$i++)
{   
unset($myarr1);
		$j=$j+1;
		if($j % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetDrawColor(238,238,238);
			$pdf->SetAligns($arr4);
			$pdf->SetWidths($arr5);
			$myarr1[] = $arr_1[$i];
		
		for($j=0;$j<count($arr);$j++)
			{
				if(substr($arr[$j],0,2) == "LP")
				{	
					$sql1 = mysql_query("select * from checklist_loadport where PORT='LP' and PORTID='".$port_arr[$j]."' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and ENTITY_NAME='".$arr_1[$i]."'");
					$rows1 = mysql_fetch_assoc($sql1);
					$myarr1[] = $rows1['ENTITY_VALUE'];	
				}
			}
			//echo"<pre>";print_r($myarr1);
			
				if($i==8)
				{
					$stowagearray=array("STOWAGE PLAN");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==12)
				{
					$stowagearray=array("ETA NOTICES");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==20)
				{
					$stowagearray=array("LOAD PORT VESSEL OPERATIONS");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==29)
				{
					$stowagearray=array("BILL OF LADING");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==30)
				{
					$style_14=array("DRAFT BL");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$style_14[] = 'checked';} else {$style_14[] = 'unchecked';}
					}
					$pdf->Row2($style_14);
				}
				
		/***************** For COMMENCED ****************/
				
				elseif($i==21)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMMENCED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$commenced);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
		/***************** For ETC/D ****************/
				
				elseif($i==22)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("ETC/D");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$etc_date);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
		
	/***************** For BALANCE ****************/
	
				elseif($i==23)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("BALANCE");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$balance);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
					
		/***************** For TOTAL ****************/
		
			elseif($i==24)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("TOTAL");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$total);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')


							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
		/***************** For 24HRS ****************/
		
				elseif($i==25)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("24HRS");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$loadlast);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
		/***************** For COMPLETED ****************/
		
				elseif($i==26)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMPLETED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$completed_date);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}			
		/***************** END ****************/
				
				else
				{
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($myarr1);
				}
			} 
		}


/************************ For PAYMENTS *************************/

$pdf->Ln(6);
if($rows['FREIGHT_PAYMENT']=="1"){$style_15 = 'checked';} else {$style_15 = 'unchecked';}
if($rows['DAADV_AGENT']=="1"){$style_16 = 'checked';} else {$style_16 = 'unchecked';}
	
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"PAYMENTS",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("95% FREIGHT PAYMENT",":",$style_15,"DA ADVANCE  AGENT",":",$style_16,"","",""));

/************************ For DISCHARGE PORT *************************/

if(count($arr)!=0){
$pdf->Ln(7);

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"DISCHARGE PORT",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$myarray = array("");
for($l=0;$l<count($arr);$l++)
{
	if(substr($arr[$l],0,2) == "DP")
	{	
		$myarray[] = $arr[$l];
	}
}
$count=count($myarray);
$columns=190/$count;

for($m=0;$m<count($myarray);$m++)
{ $alignment[]='L'; $width_array[]= $columns; }

$arr4=$alignment;
$arr5=$width_array;
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2($myarray);

$disarr = array("PORT (S)","AGENT","DISCHARGE RATE","RECEIVER","REMARKS 3","","LOI FROM RECIVER","LOI TO OWNER","BL MANIFEST","DISCHARGE INSTRUCTION","REMARKS","","ETA 7 DAYS","ETA 5 DAYS","ETA 3 DAYS","ETA 2 DAYS","ETA 1 DAY","NOR TENDERED","","COMMENCED","ETC/D","BALANCE","TOTAL","24HRS ","COMPLETED","DOCUMENT(S)","REMARKS 4");

for($j=0;$j<count($arr);$j++)
{
	if(substr($arr[$j],0,2) == "DP")
	{
		$sql_query = "select max(SOFSLAVEID) as max from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' ";
		$result = mysql_query($sql_query);
		$testres = mysql_fetch_assoc($result);
					
		$lpvessaloper1 = "select * from sof_slave_5 where SOFSLAVEID='".$testres['max']."'"; 
		$result11 = mysql_query($lpvessaloper1);
		$testrec1 = mysql_fetch_assoc($result11);	
		$balance1[] = $testrec1['BALANCE'];
		$total1[] = $testrec1['TTL_LOAD'];
		$loadlast1[] = $testrec1['LOAD_LAST'];
		$etc_date1[] = date("d-M-Y",strtotime($testrec1['ETCD']));
		$completed_date1[] = date("d-M-Y",strtotime($testrec1['PRE_DATE']));
		//echo'<pre>';print_r($balance);
		
		$sof_query1 = "select * from sof_slave_5";
		$sof_res1 = mysql_query($sof_query1);
		$maxnumrows1 = mysql_num_rows($sof_res1);
		
		$comp_sql1 = "select MIN(SOFSLAVEID) as min from sof_slave_5 where LOGIN='AGENT' and PORT='DP' and PORTID='".$port_arr[$j]."' and MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."'";
		$rock_rs1 = mysql_query($comp_sql1);
		$min_val1 = mysql_fetch_assoc($rock_rs1);
	
		$comp_sql11 = "select * from sof_slave_5 where SOFSLAVEID='".$min_val1['min']."'"; 
		$rock_rs11 = mysql_query($comp_sql11);
		$min_val12 = mysql_fetch_assoc($rock_rs11);	
		$commenced1[] = date("d-M-Y",strtotime($min_val12['PRE_DATE']));
	}
}

$j=0;
for($i=0;$i<count($disarr);$i++)
{   
unset($myarr1);
		$j=$j+1;
		if($j % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetDrawColor(238,238,238);
			$pdf->SetAligns($arr4);
			$pdf->SetWidths($arr5);
			$myarr1[] = $disarr[$i];
		
			for($j=0;$j<count($arr);$j++)
			{
				if(substr($arr[$j],0,2) == "DP")
				{	
					$sql2 = "select * from checklist_loadport where PORT='DP' and PORTID='".$port_arr[$j]."' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and ENTITY_NAME='".$disarr[$i]."'";
					$res2 = mysql_query($sql2);
					$rows2 = mysql_fetch_assoc($res2);
					$myarr1[] = $rows2['ENTITY_VALUE'];	
				}
			}
			if($i==5)
				{
					$stowagearray=array("LOI");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==6)
				{
					$loifrmrec=array("LOI FROM RECIVER");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==7)
				{
					$loifrmrec=array("LOI TO OWNER");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==8)
				{
					$loifrmrec=array("BL MANIFEST");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==9)
				{
					$loifrmrec=array("DISCHARGE INSTRUCTION");
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					
					for($p=0;$p<count($myarr1)-1;$p++){	
					if($myarr1[$p+1]=="1"){$loifrmrec[] = 'checked';} else {$loifrmrec[] = 'unchecked';}
					}
					$pdf->Row2($loifrmrec);
				}
				elseif($i==11)
				{
					$stowagearray=array("DISCHARGE PORT ETA NOTICES");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				elseif($i==18)
				{
					$stowagearray=array("DISCHARGE PORT VESSEL OPERATIONS");
					$pdf->SetFont('Arial','B',7);
					$pdf->SetFillColor(128,128,128);
					$pdf->SetTextColor(255,255,255);
					$pdf->SetDrawColor(255,255,255);
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1;}
					
					for($stp=0;$stp<count($myarr1)-1;$stp++) { $stowagearray[]=""; }
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($stowagearray);
				}
				
/************************* For COMMENCED *****************************/	
			
				elseif($i==19)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMMENCED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$commenced1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For ETC/D *****************************/

				elseif($i==20)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("ETC/D");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$etc_date1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For BALANCE *****************************/

				elseif($i==21)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("BALANCE");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$balance1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For TOTAL *****************************/

				elseif($i==22)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("TOTAL");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$total1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}

/************************* For 24HRS *****************************/		
				
				elseif($i==23)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("24HRS");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$loadlast1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For COMPLETED *****************************/	

				elseif($i==24)
				{	
					if($maxnumrows > 0)
					{
						$new_array=array();
						$style_14=array("COMPLETED");
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
				
						$mergarray = array_merge($style_14,$completed_date1);
						//echo'<pre>';print_r($mergarray);
						$nub=count($mergarray);
						for($b=0;$b<$nub;$b++)
						{
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]!='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]=$mergarray[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]!='')
							{
								$new_array[]=$myarr1[$b];
							}
							if($mergarray[$b]=='01-Jan-1970' && $myarr1[$b]=='')
							{
								$new_array[]='';
							}
						}
						$pdf->Row2($new_array);				
					}
					else
					{
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$pdf->SetDrawColor(238,238,238);
						
						$count1=count($myarr1);
						$columns1=190/$count1;
						
						for($k=0;$k<count($myarr1);$k++)
						{ $alignment[]='L'; $width_array[]= $columns1; }
						
						$arr4=$alignment;
						$arr5=$width_array;
						$pdf->SetAligns($arr4);
						$pdf->SetWidths($arr5);
						
						$pdf->Row2($myarr1);
					}
				}
				
/************************* For END *****************************/	
				
				else
				{
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$pdf->SetDrawColor(238,238,238);
					
					$count1=count($myarr1);
					$columns1=190/$count1;
					
					for($k=0;$k<count($myarr1);$k++)
					{ $alignment[]='L'; $width_array[]= $columns1; }
					
					$arr4=$alignment;
					$arr5=$width_array;
					$pdf->SetAligns($arr4);
					$pdf->SetWidths($arr5);
					$pdf->Row2($myarr1);
				}
			}
		}


/************************ For DISCHARGE PORT BELOW *************************/

$pdf->Ln(8);
if($rows['LP_FTF']=="1"){$style_18 = 'checked';} else {$style_18 = 'unchecked';}

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("FILED TO FOLDER",":",$style_18,"","","","","",""));

$pdf->Row1(array("REMARKS",":",$rows['REMARKS'],"","","","SIGNATURE","",""));


$filename = "Checklist ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
	
}

function getCOAReportDataPdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['selFYear'])){$curr_fyear = $_REQUEST['selFYear']; }
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
				
	}
$pdf = new PDF('L','mm','Legal');
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('COA Status Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('COA Status Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


$pdf->SetFont('Arial','B',12);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(27,119,166);

$pdf->Cell(338,8,$curr_fyear."    COA STATUS SHEET",0,1,'C','1');
$curr_fyear_arr = explode("-",$curr_fyear);
//$pdf->Ln(2);

$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(27,119,166);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(128,128,128);

$arr1=array('C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
$arr2=array(18,20,30,30,30,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row2(array('Owner','COA CP Date','Total','Performed / Nominated','Balance','Apr-'.$curr_fyear_arr[0],'May-'.$curr_fyear_arr[0],'Jun-'.$curr_fyear_arr[0],'July-'.$curr_fyear_arr[0],'Aug-'.$curr_fyear_arr[0],'Sep-'.$curr_fyear_arr[0],'Oct-'.$curr_fyear_arr[0],'Nov-'.$curr_fyear_arr[0],'Dec-'.$curr_fyear_arr[0],'Jan-'.($curr_fyear_arr[0]+1),'Feb-'.($curr_fyear_arr[0]+1),'Mar-'.($curr_fyear_arr[0]+1),'Notice(d)','Dem'));


$pdf->SetFont('Arial','',7);
$pdf->SetFillColor(238,232,232);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(128,128,128);

$arr1=array('C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
$arr2=array(18,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row2(array('','','Vol. MT','Shpmt No','Vol. MT','Shpmt No','Vol. MT','Shpmt No','','','','','','','','','','','','','',''));

$ttl_vol_mt = $ttl_shpmt = $ttl_perf = $ttl_perf_shpmt = $blnce_vol_mt = $blnce_shpmt = 0;

$sql = "select * from vessel_category_master where STATUS=1 order by NAME";
$res  = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{
	$arr1=array('C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
	$arr2=array(18,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);

	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(338,5,strtoupper($rows['NAME']),1,1,'L','1');
	
	$sql1 = "select * from coa_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and VESSEL_CATEGORY_ID='".$rows['VESSEL_CATEGORY_ID']."' and START_DATE between '".$curr_fyear_arr[0]."-04-01' and '".$curr_fyear_arr[1]."-03-31'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	if($rec1 == 0)
	{
		$pdf->Cell(338,5,"",1,1,'L','1');
	}
	else
	{
		$ttl_vol_mt_l = $ttl_shpmt_l = $ttl_perf_l = $ttl_perf_shpmt_l = $blnce_vol_mt_l = $blnce_shpmt_l = 0;
		while($rows1 = mysql_fetch_assoc($res1))
		{
			$pdf->SetFont('Arial','',6);
			$pdf->SetFillColor(255,255,255);
			$pdf->SetTextColor(0,0,0);
			if($obj->getPerformedVesselRec($rows1['COAID']) == 0){$perf_qty = "0.00";}else{$perf_qty = ($obj->getPerformedVesselRec($rows1['COAID']) * $rows['SIZE']) / 1000000;}
			
			if($rows1['STATUS'] == 2)
			{
				$arr3=array('L','C','C','C','C','C','C','C','L','C','C');
				$arr4=array(18,20,15,15,15,15,15,15,180,15,15);
				$pdf->SetAligns($arr3);
				$pdf->SetWidths($arr4);
				
				$pdf->Row2(array($obj->getVendorListNewBasedOnID($rows1['OWNER']),date("d M Y",strtotime($rows1['COA_DATE'])),$obj->getNumberFormat(($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000),$rows1['NO_OF_SHIPMENT'],$obj->getNumberFormat($perf_qty),$obj->getPerformedVesselRec($rows1['COAID']),$obj->getNumberFormat((($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000) - $perf_qty),($rows1['NO_OF_SHIPMENT'] - $obj->getPerformedVesselRec($rows1['COAID'])),$rows1['CANCEL_REMARKS'],$rows1['NOTICE_DAYS'].' (d)',$obj->getNumberFormat($rows1['DEMURRAGE_RATE'])));
			}
			else
			{
				$arr3=array('L','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
				$arr4=array(18,20,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
				$pdf->SetAligns($arr3);
				$pdf->SetWidths($arr4);
				
				$pdf->Row2(array($obj->getVendorListNewBasedOnID($rows1['OWNER']),date("d M Y",strtotime($rows1['COA_DATE'])),$obj->getNumberFormat(($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000),$rows1['NO_OF_SHIPMENT'],$obj->getNumberFormat($perf_qty),$obj->getPerformedVesselRec($rows1['COAID']),$obj->getNumberFormat((($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000) - $perf_qty),($rows1['NO_OF_SHIPMENT'] - $obj->getPerformedVesselRec($rows1['COAID'])),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"04"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"05"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"06"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"07"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"08"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"09"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"10"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"11"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"12"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"01"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"02"),$obj->getAttachedVesselWithCOABasedOnFinancialYearForPDF($rows1['COAID'],$curr_fyear_arr[0],"03"),$rows1['NOTICE_DAYS'].' (d)',$obj->getNumberFormat($rows1['DEMURRAGE_RATE'])));
			}
			$ttl_vol_mt += $obj->getNumberFormat(($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000);
			$ttl_shpmt += $rows1['NO_OF_SHIPMENT'];
			$ttl_perf += $perf_qty;
			$ttl_perf_shpmt += $obj->getPerformedVesselRec($rows1['COAID']);
			$blnce_vol_mt += $obj->getNumberFormat((($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000) - $perf_qty);
			$blnce_shpmt += ($rows1['NO_OF_SHIPMENT'] - $obj->getPerformedVesselRec($rows1['COAID']));
			
			$ttl_vol_mt_l += $obj->getNumberFormat(($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000);
			$ttl_shpmt_l += $rows1['NO_OF_SHIPMENT'];
			$ttl_perf_l += $perf_qty;
			$ttl_perf_shpmt_l += $obj->getPerformedVesselRec($rows1['COAID']);
			$blnce_vol_mt_l += $obj->getNumberFormat((($rows1['NO_OF_SHIPMENT'] * $rows['SIZE']) / 1000000) - $perf_qty);
			$blnce_shpmt_l += ($rows1['NO_OF_SHIPMENT'] - $obj->getPerformedVesselRec($rows1['COAID']));
		}
				$pdf->SetFont('Arial','B',8);
				$pdf->SetFillColor(255,255,255);
				$pdf->SetTextColor(220,99,30);
				$arr3=array('L','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
				$arr4=array(38,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
				$pdf->SetAligns($arr3);
				$pdf->SetWidths($arr4);	
				
				$pdf->Row2(array("Totals ".strtoupper($rows['NAME']),$ttl_vol_mt_l,$ttl_shpmt_l,$obj->getNumberFormat($ttl_perf_l),$ttl_perf_shpmt_l,$blnce_vol_mt_l,$blnce_shpmt_l,"","","","","","","","","","","","","",""));	
	}
}

$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(220,99,30);
$arr3=array('L','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C');
$arr4=array(38,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15);
$pdf->SetAligns($arr3);
$pdf->SetWidths($arr4);	
				
$pdf->Row2(array("GRAND TOTALS",$ttl_vol_mt,$ttl_shpmt,$obj->getNumberFormat($ttl_perf),$ttl_perf_shpmt,$blnce_vol_mt,$blnce_shpmt,"","","","","","","","","","","","","",""));	

$filename = $curr_fyear." COA Status Sheet - ".date("d M Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function projected_cash_flow_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$selDate_Type 	= $_REQUEST['selDate_Type'];
	$txtFrom_Date 	= $_REQUEST['txtFrom_Date'];
	$txtTo_Date 	= $_REQUEST['txtTo_Date'];
	$txtDays 		= $_REQUEST['txtDays'];
	$selBType 		= $_REQUEST['selBType'];
	$arr_eta 		= array("ETA 1 DAY","ETA 2 DAYS","ETA 3 DAYS","ETA 5 DAYS","ETA 7 DAYS");
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Integration Log Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Integration Log Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(30,5,40,30,5,40,35);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Actual ETA From",":",date("d-M-Y",strtotime($txtFrom_Date)),"Actual ETA To",":",date("d-M-Y",strtotime($txtTo_Date))));

$pdf->Ln(2);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L','L','L');
$arr2=array(8,24,24,23,30,24,30,30,30);
$arr3=array("S.No.", "Nom ID","Material Name","Vessel","Total Outstanding (USD)","Payments (USD)","Balance Outstanding (USD)","Due Date");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);



$sql = "select * from check_list where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
$k = 1;
if($rec == 0)
{
}
else
{
	while($rows = mysql_fetch_assoc($res))
	{
		$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
		$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
		if($obj->getFun158() == $selBType)
		{
			$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($rows['COMID'],$fcaid);
			
			$rec1 = 0;
			
			for($i=0;$i<count($arr);$i++)
			{
				$arr_portval = explode('@@',$arr[$i]);
				if($arr_portval[0] == 'LP')
				{
					if($selDate_Type == 1)
					{
						for($j=0;$j<sizeof($arr_eta);$j++)
						{
							$sql1 = "select * from checklist_loadport where PORT='LP' and PORTID='".$arr_portval[1]."' and ENTITY_NAME ='".$arr_eta[$j]."' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and RANDOMID='".$arr_portval[2]."' and ENTITY_VALUE!=''";
							
							$res1 = mysql_query($sql1);
							$res11 = mysql_query($sql1);
							$rec1 = mysql_num_rows($res1);
							$rows1 = mysql_fetch_assoc($res1);
							$date2 = $rows1['ENTITY_VALUE'];
							$vall = 0;
							if($date2!="")
							{
								$date3 = strtotime($date2);
								if(strtotime($date2)>=strtotime($txtFrom_Date) && strtotime($date2)<=strtotime($txtTo_Date))
								{
								   $vall = 1;
								}
								else{$vall = 0;}
								
							}else{$vall = 0;}
							if($vall > 0){break;}
						}
					}
					else
					{
						$sql1 = "select * from checklist_loadport where PORT='LP' and PORTID='".$arr_portval[1]."' and ENTITY_NAME ='ETC/D' and CHECKLIST_ID='".$rows['CHECKLIST_ID']."' and RANDOMID='".$arr_portval[2]."'";
						$res1 = mysql_query($sql1);
						$res11 = mysql_query($sql1);
						$rec1 = mysql_num_rows($res1);
						$rows1 = mysql_fetch_assoc($res1);
						$date2 = $rows1['ENTITY_VALUE'];
						$vall = 0;
						if($date2!="")
						{
							$date3 = strtotime($date2);
							if(strtotime($date2)>=strtotime($txtFrom_Date) && strtotime($date2)<=strtotime($txtTo_Date))
							{
							   $vall = 1;
							}
							else{$vall = 0;}
							
						}else{$vall = 0;}
						if($vall > 0){break;}
					}
				}
				
				if($vall > 0){break;}
			}
			
			if($vall > 0)
			{
				$rows1 = mysql_fetch_assoc($res11);
				$cost = 0; $bal_cost = 0;
				
				$sql3 = "select * from request_master where COMID='".$rows['COMID']."' and MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."'";
				$res3 = mysql_query($sql3);
				while($rows3 = mysql_fetch_assoc($res3))
				{
					$cost = $cost + $rows3['REQ_TO_PAY'];
				}
				$arr1 = $arr2 = $arr3 = array();	
				$i=$i+1;
				if($i % 2 == 0)
				{
					$pdf->SetFillColor(244,244,244);
				}
				else
				{
					$pdf->SetFillColor(255,255,255);
				}
				
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L','L','L','L','L');
				$arr2=array(8,24,24,23,30,24,30,30,30);
				$bal_cost = $obj->getFun84() + $obj->getFun153() + $obj->getFun152() + $obj->getFun131() - $cost;
				$ttl_cost = $ttl_cost + $obj->getFun84() + $obj->getFun153() + $obj->getFun152() + $obj->getFun131();
				$ttl_bal_cost = $ttl_bal_cost + $bal_cost;
				$arr3=array($k,$obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),$obj->getNumberFormat(($obj->getFun84() + $obj->getFun153() + $obj->getFun152() + $obj->getFun131())),$obj->getNumberFormat($cost),$obj->getNumberFormat($bal_cost),date("d-M-Y , D",strtotime($rows1['ENTITY_VALUE']. ' + '.$txtDays.' days')));
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
				$k++;
			}
		}	
	}
}

if($k > 1)
{
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('R','L','L','L','L');
	$arr2=array(80,30,24,30,30);
	$arr3=array("Totals",$obj->getNumberFormat($ttl_cost),"",$obj->getNumberFormat($ttl_bal_cost),'');
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}

$filename = "Projected Cash Flow ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');

}

function baf_pdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['mappingid'])){$mappingid = $_REQUEST['mappingid']; }
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}		
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cost Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cost Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
$obj->viewBAFCalculationRecords($mappingid);

$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(27,119,166);
$pdf->SetTextColor(255,255,255);
$pdf->Cell(192,6,strtoupper($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"))." / ".(int)$obj->getCompareEstimateData($comid,"NO_OF_LIFT")." LIFT / ".date("d M Y",strtotime($obj->getCOANumberDataBasedOnID($obj->getCompareEstimateData($comid,'COA_NO'),'COA_DATE')))." / ".$obj->getCOANumberBasedOnID($obj->getCompareEstimateData($comid,"COA_NO"))." :: BAF CALCULATION",0,1,'C',1);

if($obj->getCOANumberDataBasedOnID($obj->getCompareEstimateData($comid,'COA_NO'),'BAF') == 0)
{
	$pdf->SetFont('Arial','',8);
	$pdf->SetTextColor(0,0,0);
	$pdf->Cell(192,6,strtoupper("Please fulfill BAF details in COA."),0,1,'C');
}
else
{
	$pdf->Ln(2);
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(35,5,30,35,3,20,40,3,20);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	
	$pdf->Row1(array("Bunker Price IFO (USD/MT)",":",$obj->getFun2(),"BAF Terms (Days)",":",$obj->getFun3(),"BAF (USD/MT)",":",$obj->getFun4()));
		
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',8);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$arr3=array('L','L','L','L');
	$arr4=array(52,40,40,60);
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("Port","BL Quantity (MT)","BL Date","Remarks"));	
	
	$sql = "select * from baf_slave1 where BAFID = ".$obj->getFun1();
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	while($rows = mysql_fetch_assoc($res))
	{
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetDrawColor(128,128,128);
		$pdf->SetTextColor(0,0,0);
		$pdf->Row2(array($obj->getPortNameBasedOnCode($rows['PORT_CODE']),$obj->getNumberFormat($rows['BL_QTY']),date("d-M-Y",strtotime($rows['BL_DATE'])),$rows['REMARKS']));	
	}
	$pdf->SetFont('Arial','B',8);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->Row2(array("",$obj->getFun5(),"",""));
	
	$pdf->Ln(2);
	$pdf->SetFont('Arial','B',8);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("Date","Day","Rate IFO (USD/MT)","Remarks"));	
	
	$sql1 = "select * from baf_slave2 where BAFID = ".$obj->getFun1();
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$pdf->SetFont('Arial','',7);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetDrawColor(128,128,128);
		$pdf->SetTextColor(0,0,0);
		$pdf->Row2(array(date("d-M-Y",strtotime($rows1['DATE'])),$rows1['DAY'],$obj->getNumberFormat4Decimal($rows1['RATE_IFO']),$rows1['REMARKS']));	
	}
	
	$pdf->Ln(2);
	$sql2 = "select * from baf_slave1 where BAFID = ".$obj->getFun1();
	$res2 = mysql_query($sql2);
	$rec2 = mysql_num_rows($res2);
	$i=1;
	while($rows2 = mysql_fetch_assoc($res2))
	{
		$pdf->SetFont('Arial','B',8);
		$pdf->SetFillColor(255,255,255);
		$pdf->SetTextColor(220,99,30);
		$pdf->Cell(192,6,$obj->getPortNameBasedOnCode($rows2['PORT_CODE'])." / ".date("d-M-Y",strtotime($rows2['BL_DATE']))." / ".$obj->getNumberFormat($rows2['BL_QTY']),1,1,'L',1);
		
		$sql3 = "select * from baf_slave2 where BAFID = ".$obj->getFun1();
		$res3 = mysql_query($sql3);
		$rec3 = mysql_num_rows($res3);
		$j=1;
		$sum = $count = 0;
		$arr5=array('L','L');
		$arr6=array(32,160);
		$pdf->SetAligns($arr5);
		$pdf->SetWidths($arr6);
		while($rows3 = mysql_fetch_assoc($res3))
		{
			if($obj->getBAF_slave3Data($obj->getFun1(),$rows2['BAF_SLAVE1_ID'],$rows3['BAF_SLAVE2_ID'],"CHECK_STATUS") == 1)
			{
				$count++;
				$sum += $obj->getBAF_slave3Data($obj->getFun1(),$rows2['BAF_SLAVE1_ID'],$rows3['BAF_SLAVE2_ID'],"AMOUNT");
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$pdf->Row2(array(date("d-M-Y",strtotime($rows3['DATE'])),$obj->getNumberFormat4Decimal($obj->getBAF_slave3Data($obj->getFun1(),$rows2['BAF_SLAVE1_ID'],$rows3['BAF_SLAVE2_ID'],"AMOUNT"))));
			}
		}
		
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		//$pdf->Row2(array("Sum",$obj->getNumberFormat4Decimal($sum)));
		$pdf->Row2(array("Average",$obj->getNumberFormat4Decimal($sum/$count)));
		
		if($count == 0)
		{
			$pdf->Row2(array("","0.0000"));
			$pdf->Row2(array("BAF","0.0000"));
		}
		else
		{
			$pdf->Row2(array("",$obj->getNumberFormat4Decimal(($sum/$count) - $obj->getFun2())));
			$pdf->Row2(array("BAF",$obj->getNumberFormat4Decimal((($sum/$count) - $obj->getFun2()) * $obj->getFun4())));
		}
		
		$pdf->Ln(5);
	}

	$pdf->SetFont('Arial','B',9);
	$pdf->SetFillColor(255,255,255);
	$pdf->SetTextColor(220,99,30);
	$pdf->SetDrawColor(255,255,255);
	$pdf->Row(array("APPLICABLE BAF"," :   ".$obj->getNumberFormat4Decimal($obj->getFun7())));
}


$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")." / ".date("d M Y",strtotime($obj->getCOANumberDataBasedOnID($obj->getCompareEstimateData($comid,'COA_NO'),'COA_DATE')))." BAF CALCULATION.pdf";

$pdf->Output($filename,'D');
}

function cargo_open_position_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$selBType = $_REQUEST['selBType'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

	$pdf = new PDF();
	$pdf->AddPage('P');
	$pdf->SetDisplayMode('real','single');
	$pdf->SetTitle('Cargo Open Position Report Pdf');
	$pdf->SetAuthor('Seven Oceans Holdings');
	$pdf->SetSubject('Cargo Open Position Pdf');
	$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
	$pdf->Ln(4);
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(17,20,25,25,25,25,25,25);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$arr3=array("Cargo ID","Shipper","Material Desc","Material Qty","Load Port","Discharge Port", "Date Range","Open Vessel");
	$pdf->Row2($arr3);	
	if($selBType!='')
	{
		$sql = "select * from freight_cost_estimete_master where SHEET_NO is NULL and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and CARGOID!='' and ESTIMATE_TYPE='".$selBType."'";
		$res = mysql_query($sql);
	
		$i = 0;	
		while($rows = mysql_fetch_assoc($res))
		{
			$quantity = 0;
			if($rows['ESTIMATE_TYPE']==1)
			{
				$quantity = $rows['GAS_QUANTITY'];
			}
			else if($rows['ESTIMATE_TYPE']==2)
			{
				$quantity = $rows['TANK_QUANTITY'];
			}
			else
			{
				if($rows['QTY_TYPE_RADIO'] == 1)
				{
					$quantity = $rows['QUANTITY'];
				}
				else
				{
					$sql12 = "select sum(QUANTITY) as sum from freight_cost_estimete_slave7 where FCAID='".$rows['FCAID']."'";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					$quantity = $row12['sum'];
				}
			}
			$arr1 = $arr2 = $arr3 = $arr5 = array();
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(255,255,255);
			}
			else
			{
				$pdf->SetFillColor(244,244,244);
			}
			$pdf->SetFont('Arial','',7);
			$pdf->SetTextColor(0,0,0);
			$pdf->SetDrawColor(241,241,241);
			$arr1=array('L','L','L','L','L','L','L');
			$arr2=array(17,20,25,25,25,25,25,25);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$arr3=array("Cargo ID","Shipper","Material Desc","Material Qty","Load Port","Discharge Port", "Date Range","Open Vessel");
			
			if($rows['LAYCAN_START_DATE']=="" || $rows['LAYCAN_START_DATE']=="0000-00-00"){$txtFDate = "";}else{$txtFDate = date('d-m-Y',strtotime($rows['LAYCAN_START_DATE']));}
			if($rows['LAYCAN_FINISH_DATE']=="" || $rows['LAYCAN_FINISH_DATE']=="0000-00-00"){$txtTDate = "";}else{$txtTDate = date('d-m-Y',strtotime($rows['LAYCAN_FINISH_DATE']));}
			$arr_load = $arr_discharge = array();
			$sql1 = "select FROM_PORT, TO_PORT, LOAD_PORT_COST, LOAD_PORT_QTY, DISC_PORT_COST, DISC_PORT_QTY from freight_cost_estimete_slave1 where FCAID='".$rows['FCAID']."'";
			$res1 = mysql_query($sql1);
			while($row1 = mysql_fetch_assoc($res1))
			{
				if($row1['LOAD_PORT_QTY']>0)
				{
					$arr_load[] = $obj->getPortNameBasedOnID($row1['FROM_PORT']);
				}
				if($row1['DISC_PORT_QTY']>0)
				{
					$arr_discharge[] = $obj->getPortNameBasedOnID($row1['TO_PORT']);
				}
			}
			
			$arr3=array($rows['CARGOID'],$obj->getVendorListNewBasedOnID($rows['SHIPPER']),$obj->getCargoNameListForMultipleNamemultiple($rows['CARGO_ID']),$quantity,implode(', ',$arr_load),implode(', ',$arr_discharge), $txtFDate.' To '.$txtTDate,$obj->getVesselIMOData($rows['VESSEL_IMO_ID'],"VESSEL_NAME"));
			
			$pdf->Row2($arr3);	
			$i++;
		}
	}
	$filename = "Cargo Open Position Report ".date("d-M-Y",time()).".pdf";

	$pdf->Output($filename,'D');
}


function sensitivity_analysis_tci_tmp()
{
	$obj = new data();
	$obj->funConnect();
	
	$i_width 		= $_REQUEST['i_width'];
	$i_point 		= $_REQUEST['i_point'];
	$amount 		= $_REQUEST['amount'];
	$process 		= $_REQUEST['process'];
	$fca_tmpid 		= $_REQUEST['fca_tmpid'];
	

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$obj->viewFreightCostEstimationTempleteRecords($fca_tmpid);

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,30,35,3,20,40,3,20);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Vessel Name",":",$obj->getVesselIMOData($obj->getFun4(),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getFun4(),"VESSEL_TYPE")),"Sheet Name",":",$obj->getFun5()));

if($process == 1){$string = 'TC Cost Per Day (USD) ';}
if($process == 2){$string = 'Price IFO';}
if($process == 3){$string = 'Cargo Qty (MT)';}
if($process == 4){$string = 'Freight (USD/MT)';}

$pdf->Row1(array($string,":",number_format($amount,2,'.',','),"Interval Width",":",$i_width,"Interval Basis Points",":",$i_point));

$pdf->Ln(3);
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('C','C','C');
$arr2=array(64,63,63);
$arr3=array($string,"Resultant Cost / MT - USD","TCE");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$last_val_min = $amount;
for($i=0;$i<$i_point;$i++)
{
	$minus_arr[$i] = ($last_val_min - $i_width);
	$last_val_min = ($last_val_min - $i_width);
}
sort($minus_arr);
$curr_arr = array($amount);

$last_val_min1 = $amount;
for($i=0;$i<$i_point;$i++)
{
	$plus_arr[$i] = ($last_val_min1 + $i_width);
	$last_val_min1 = ($last_val_min1 + $i_width);
}

$final_arr = array_merge($minus_arr,$curr_arr,$plus_arr);
//echo "<pre>";print_r($final_arr);
for($i=0;$i<count($final_arr);$i++)
	{
		$arr1 = $arr2 = $arr3 = array();	
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		
		if($final_arr[$i] == $amount)
		{
			$pdf->SetFillColor(241,149,96);
			$pdf->SetTextColor(255,255,255);
		}
		
		if(number_format($final_arr[$i],2,'.',',') < 0)
		{
			$cost = '( '.number_format(abs($final_arr[$i]),2,'.',',').' )';
		}
		else
		{
			$cost = number_format($final_arr[$i],2,'.',',');
		}
		
		if($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"COST_MT") < 0)
		{
			$costMT = '( '.number_format(abs($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"COST_MT")),2,'.',',').' )';
		}
		else
		{
			$costMT = number_format($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"COST_MT"),2,'.',',');
		}
		
		if($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"TCE") < 0)
		{
			$tce = '( '.number_format(abs($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"TCE")),2,'.',',').' )';
		}
		else
		{
			$tce = number_format($obj->getFinalCostSheetMT_TMP($final_arr[$i],$process,$fca_tmpid,"TCE"),2,'.',',');
		}
		$arr3=array($cost,$costMT,$tce);
		$pdf->Row2($arr3);
	}
$filename = 'Sensitivity Analysis Report ('.$obj->getVesselIMOData($obj->getFun4(),"VESSEL_NAME").')_'.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}


function sensitivity_analysis_vci()
{
	$obj = new data();
	$obj->funConnect();
	
	$i_width 		= $_REQUEST['i_width'];
	$i_point 		= $_REQUEST['i_point'];
	$amount 		= $_REQUEST['amount'];
	$process 		= $_REQUEST['process'];
	$mappingid 		= $_REQUEST['mappingid'];
	$cost_sheet_id  = $_REQUEST['cost_sheet_id'];

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,30,35,3,20,40,3,20);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE")),"","",""));

if($process == 1){$string = 'Agreed Gross Freight (USD/MT) ';}
if($process == 2){$string = 'Total Cargo Qty (MT)';}
$pdf->Row1(array($string,":",number_format($amount,2,'.',','),"Interval Width",":",$i_width,"Interval Basis Points",":",$i_point));

$pdf->Ln(3);
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('C','C');
$arr2=array(95,95);
$arr3=array($string,"Resultant Cost / MT - USD");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$last_val_min = $amount;
for($i=0;$i<$i_point;$i++)
{
	$minus_arr[$i] = ($last_val_min - $i_width);
	$last_val_min = ($last_val_min - $i_width);
}
sort($minus_arr);
$curr_arr = array($amount);

$last_val_min1 = $amount;
for($i=0;$i<$i_point;$i++)
{
	$plus_arr[$i] = ($last_val_min1 + $i_width);
	$last_val_min1 = ($last_val_min1 + $i_width);
}

$final_arr = array_merge($minus_arr,$curr_arr,$plus_arr);
//echo "<pre>";print_r($final_arr);
for($i=0;$i<count($final_arr);$i++)
	{
		$arr1 = $arr2 = $arr3 = array();	
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		
		if($final_arr[$i] == $amount)
		{
			$pdf->SetFillColor(241,149,96);
			$pdf->SetTextColor(255,255,255);
		}
		
				if(number_format($final_arr[$i],2,'.',',') < 0)
		{
			$cost = '( '.number_format(abs($final_arr[$i]),2,'.',',').' )';
		}
		else
		{
			$cost = number_format($final_arr[$i],2,'.',',');
		}
		
		if($obj->getFinalCostSheetMT_VCI($final_arr[$i],$process,$mappingid,$cost_sheet_id) < 0)
		{
			$costMT = '( '.number_format(abs($obj->getFinalCostSheetMT_VCI($final_arr[$i],$process,$mappingid,$cost_sheet_id)),2,'.',',').' )';
		}
		else
		{
			$costMT = number_format($obj->getFinalCostSheetMT_VCI($final_arr[$i],$process,$mappingid,$cost_sheet_id),2,'.',',');
		}
		$arr3=array($cost,$costMT);
		$pdf->Row2($arr3);
	}
$filename = 'Sensitivity Analysis Report ('.$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME").')_'.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function sensitivity_analysis_tci()
{
	$obj = new data();
	$obj->funConnect();
	
	$i_width 		= $_REQUEST['i_width'];
	$i_point 		= $_REQUEST['i_point'];
	$amount 		= $_REQUEST['amount'];
	$process 		= $_REQUEST['process'];
	$mappingid 		= $_REQUEST['mappingid'];
	$cost_sheet_id  = $_REQUEST['cost_sheet_id'];

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('SENSITIVITY ANALYSIS Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,30,35,3,20,40,3,20);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE")),"","",""));

if($process == 1){$string = 'TC Cost Per Day (USD) ';}
if($process == 2){$string = 'Price IFO';}
if($process == 3){$string = 'Cargo Qty (MT)';}
$pdf->Row1(array($string,":",number_format($amount,2,'.',','),"Interval Width",":",$i_width,"Interval Basis Points",":",$i_point));

$pdf->Ln(3);
$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('C','C');
$arr2=array(95,95);
$arr3=array($string,"Resultant Cost / MT - USD");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$last_val_min = $amount;
for($i=0;$i<$i_point;$i++)
{
	$minus_arr[$i] = ($last_val_min - $i_width);
	$last_val_min = ($last_val_min - $i_width);
}
sort($minus_arr);
$curr_arr = array($amount);

$last_val_min1 = $amount;
for($i=0;$i<$i_point;$i++)
{
	$plus_arr[$i] = ($last_val_min1 + $i_width);
	$last_val_min1 = ($last_val_min1 + $i_width);
}

$final_arr = array_merge($minus_arr,$curr_arr,$plus_arr);
//echo "<pre>";print_r($final_arr);
for($i=0;$i<count($final_arr);$i++)
	{
		$arr1 = $arr2 = $arr3 = array();	
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(255,255,255);
		}
		else
		{
			$pdf->SetFillColor(244,244,244);
		}
		$pdf->SetFont('Arial','',8);
		$pdf->SetTextColor(0,0,0);
		
		if($final_arr[$i] == $amount)
		{
			$pdf->SetFillColor(241,149,96);
			$pdf->SetTextColor(255,255,255);
		}
		
				if(number_format($final_arr[$i],2,'.',',') < 0)
		{
			$cost = '( '.number_format(abs($final_arr[$i]),2,'.',',').' )';
		}
		else
		{
			$cost = number_format($final_arr[$i],2,'.',',');
		}
		
		if($obj->getFinalCostSheetMT($final_arr[$i],$process,$mappingid,$cost_sheet_id) < 0)
		{
			$costMT = '( '.number_format(abs($obj->getFinalCostSheetMT($final_arr[$i],$process,$mappingid,$cost_sheet_id)),2,'.',',').' )';
		}
		else
		{
			$costMT = number_format($obj->getFinalCostSheetMT($final_arr[$i],$process,$mappingid,$cost_sheet_id),2,'.',',');
		}
		$arr3=array($cost,$costMT);
		$pdf->Row2($arr3);
	}
$filename = 'Sensitivity Analysis Report ('.$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME").')_'.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function vessel_wise_payment_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$Date_From = $_REQUEST['txtFrom_Date'];
	$Date_To = $_REQUEST['txtTo_Date'];
	$selVessel = $_REQUEST['selVessel'];
	//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(30,5,65,30,5,65);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Date From (financial year)",":",$Date_From,"Date To (financial year)",":",$Date_To));

$pdf->Ln(5);

if($selVessel == '')
{
	$sql = "select * from mapping_master where MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."' and STATUS in (2,5) order by MAPPINGID"; 
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	$j = 0;
	while($rows = mysql_fetch_assoc($res))
	{
		$j++;
		
		$l_cost_sheet_id = $obj->getLatestCostSheetID($rows['MAPPINGID']);
		$obj->viewFreightEstimationRecords($rows['MAPPINGID'],$l_cost_sheet_id);
		$open_vessel_id = $obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID");
		//$sql1 = "select * from open_vessel_entry_master where (CP_DATE BETWEEN '".date("Y-m-d",strtotime($Date_From))."' and '".date("Y-m-d",strtotime($Date_To))."') and OPENVESSEL_ID='".$open_vessel_id."'";
		$sql1 = "select * from freight_cost_analysis_master where (TRANS_DATE BETWEEN '".date("Y-m-d",strtotime($Date_From))."' and '".date("Y-m-d",strtotime($Date_To))."') and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and MAPPINGID='".$rows['MAPPINGID']."' and SHEET_NO='".$l_cost_sheet_id."'";
		
		$res1 = mysql_query($sql1);
		$rec1 = mysql_num_rows($res1);
		if($rec1 > 0)
		{
			$pdf->SetFont('Arial','',8);
			$pdf->SetTextColor(30,133,190);
			$arr1=array('L');
			$arr2=array(80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row1(array($obj->getVesselIMOData($obj->getVesselOpenEntryDeta($rows['OPEN_VESSEL_ID'],"VESSEL_IMO_ID"),"VESSEL_NAME")));
			
			$pdf->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$pdf->SetFont('Arial','B',7);
			$pdf->SetFillColor(128,128,128);
			$pdf->SetTextColor(255,255,255);
			$pdf->SetDrawColor(238,238,238);
			$arr1=array('L','L','L','L','L','L','L','L','L');
			$arr2=array(20,20,20,20,20,25,20,25,20);
			$arr3=array("Nom ID","Cost Type","Cost Desc.","Vendor","CP Date","Port","TTL Outstanding","Payment","Balance Outstanding");
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2($arr3);
			
			$i = 0;
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_bunker_nett where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$cost_1 = 0; $vendor = ''; $pay_name = '';
						
						if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
						{
							$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
						
							$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='1' and GRADEID='".$qrows['BUNKERGRADEID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
							$res2 = mysql_query($sql2);
							$deduction = 0;
							while($rows2 = mysql_fetch_assoc($res2))
							{ 
								$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
								$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
								
								$qsql = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
								$qres = mysql_query($qsql);
								$deduction_1 = 0;
								while($qrows = mysql_fetch_assoc($qres))
								{ $deduction = $deduction+$qrows['COST']; $deduction_1 = $deduction_1+$qrows['COST'];}
								
								$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
							}
							
							$cost_1 = $qrows['COST']-$cost_1-$deduction;
							
							$arr1 = $arr2 = $arr3 = array();	
							$i=$i+1;
							if($i % 2 == 0)
							{
								$pdf->SetFillColor(244,244,244);
							}
							else
							{
								$pdf->SetFillColor(255,255,255);
							}
							
							$pdf->SetFont('Arial','',7);
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','L','L','L','L','L','L');
							$arr2=array(20,20,20,20,20,25,20,25,20);
							$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Bunkers Nett Supply',$obj->getBunkerGradeBasedOnID($qrows['BUNKERGRADEID']).' Nett',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
						
					}
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$cost_1 = 0; $vendor = ''; $pay_name = '';
						
				if($obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID")) != '') 
				{
					$vendor .= $obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID")).'('.$obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID").')';
				
				
					$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='7' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
					$res2 = mysql_query($sql2);
					while($rows2 = mysql_fetch_assoc($res2))
					{ 
						$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
						$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
					}
					
					$cost_1 = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost_1;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),$pay_name,$obj->getNumberFormat($cost_1));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
			else
			{
				$cost_1 = 0; $vendor = ''; $pay_name = '';
						
				if($obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR")) != '') 
				{
					$vendor .= $obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR")).'('.$obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR").')';
				
				
					$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='9' and GRADEID='0' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
					$res2 = mysql_query($sql2);
					$deduction = 0;
					while($rows2 = mysql_fetch_assoc($res2))
					{ 
						$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
						$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
						
						$qsql = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
						$qres = mysql_query($qsql);
						$deduction_1 = 0;
						while($qrows = mysql_fetch_assoc($qres))
						{ $deduction = $deduction+$qrows['COST']; $deduction_1 = $deduction_1+$qrows['COST'];}
						
						$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
					}
					
					$cost_1 = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")-$cost_1-$deduction;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")),$pay_name,$obj->getNumberFormat($cost_1));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
			}
			else
			{
				$query = "select * from fca_vci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
			}
			$qres = mysql_query($query);
			$qrec = mysql_num_rows($qres);
			while($qrows = mysql_fetch_assoc($qres))
			{
				$cost_1 = 0; $vendor = ''; $pay_name = '';
						
				if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
				{
					$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
				
				
					$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='2' and GRADEID='".$qrows['OTHER_SCOSTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
					$res2 = mysql_query($sql2);
					$deduction = 0;
					while($rows2 = mysql_fetch_assoc($res2))
					{ 
						$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
						$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
						
						$qsql = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
						$qres = mysql_query($qsql);
						$deduction_1 = 0;
						while($qrows = mysql_fetch_assoc($qres))
						{ $deduction = $deduction+$qrows['COST']; $deduction_1 = $deduction_1+$qrows['COST'];}
						
						$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
					}
					
					$cost_1 = $qrows['ABSOLUTE']-$cost_1-$deduction;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'All Other Shipping Costs',$obj->getOtherShippingCostNameBasedOnID($qrows['OTHER_SCOSTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['ABSOLUTE']),$pay_name,$obj->getNumberFormat($cost_1));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
			}
			else
			{
				$query = "select * from fca_vci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
			}
			$qres = mysql_query($query);
			$qrec = mysql_num_rows($qres);
			while($qrows = mysql_fetch_assoc($qres))
			{
				$cost_1 = 0; $vendor = ''; $pay_name = ''; $port_name = '';
				
				if($qrows['PORT'] == "Load"){$port_name = 'Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
				else if($qrows['PORT'] == "Discharge"){$port_name = 'Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
				else if($qrows['PORT'] == "Transit"){$port_name = 'Transit Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
						
				if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
				{
					$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
				
				
					$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='3' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
					$res2 = mysql_query($sql2);
					$deduction = 0;
					while($rows2 = mysql_fetch_assoc($res2))
					{ 
						$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
						$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
						
						$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
						$qres1 = mysql_query($qsql1);
						$deduction_1 = 0;
						while($qrows1 = mysql_fetch_assoc($qres1))
						{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
						
						$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
					}
					
					$cost_1 = $qrows['COST']-$cost_1-$deduction;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Port Costs',$port_name,$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
			
			if($obj->getFun2() == 2)
			{
				$query = "select * from fca_vci_totals where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$cost_1 = 0; $vendor = ''; $pay_name = '';
						if($obj->getVendorListNewBasedOnID($qrows['DDB_VENDOR']) != '')
						{
							$vendor .= $obj->getVendorListNewBasedOnID($qrows['DDB_VENDOR']).'('.$qrows['DDB_VENDOR'].')';
							
							$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='8' and GRADEID='0' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
							$res2 = mysql_query($sql2);
							$deduction = 0;
							while($rows2 = mysql_fetch_assoc($res2))
							{ 
								$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
								$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
								
								$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
								$qres1 = mysql_query($qsql1);
								$deduction_1 = 0;
								while($qrows1 = mysql_fetch_assoc($qres1))
								{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
								
								$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
							}
							
							$cost_1 = $qrows['DD_BROKERAGE_COST']-$cost_1-$deduction;
							
							$arr1 = $arr2 = $arr3 = array();	
							$i=$i+1;
							if($i % 2 == 0)
							{
								$pdf->SetFillColor(244,244,244);
							}
							else
							{
								$pdf->SetFillColor(255,255,255);
							}
							
							$pdf->SetFont('Arial','',7);
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','L','L','L','L','L','L');
							$arr2=array(20,20,20,20,20,25,20,25,20);
							$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Ship Owner','Brokerage',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['DD_BROKERAGE_COST']),$pay_name,$obj->getNumberFormat($cost_1));
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
						
						$cost_1 = 0; $vendor = ''; $pay_name = '';
						if($obj->getVendorListNewBasedOnID($qrows['DDN_VENDOR']) != '')
						{
							$vendor .= $obj->getVendorListNewBasedOnID($qrows['DDN_VENDOR']).'('.$qrows['DDN_VENDOR'].')';
							
							$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='8' and GRADEID='1' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
							$res2 = mysql_query($sql2);
							$deduction = 0;
							while($rows2 = mysql_fetch_assoc($res2))
							{ 
								$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
								$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
								
								$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
								$qres1 = mysql_query($qsql1);
								$deduction_1 = 0;
								while($qrows1 = mysql_fetch_assoc($qres1))
								{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
								
								$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
							}
							
							$cost_1 = $qrows['DD_NETT']-$cost_1-$deduction;
							
							$arr1 = $arr2 = $arr3 = array();	
							$i=$i+1;
							if($i % 2 == 0)
							{
								$pdf->SetFillColor(244,244,244);
							}
							else
							{
								$pdf->SetFillColor(255,255,255);
							}
							
							$pdf->SetFont('Arial','',7);
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','L','L','L','L','L','L');
							$arr2=array(20,20,20,20,20,25,20,25,20);
							$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Ship Owner','Nett',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['DD_NETT']),$pay_name,$obj->getNumberFormat($cost_1));
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
						
					}
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_dd_shipper where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
						$qqres = mysql_query($qqsql);
						$qqrec = mysql_num_rows($qqres);
						if($qqrec == 0)
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
										
							if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
							
							
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='4' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else

								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
						}
						else
						{
							while($qqrows = mysql_fetch_assoc($qqres))
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
									
								if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
								if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
								if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
									
								if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%S_4_%' and GRADEID='".$qqrows2['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $value-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
						}
					}
				}
			}
			else
			{
				$query = "select * from fca_vci_dd_shipper where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
						$qqres = mysql_query($qqsql);
						$qqrec = mysql_num_rows($qqres);
						if($qqrec == 0)
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
										
							if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
							
							
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='S_4_' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
						}
						else
						{
							while($qqrows = mysql_fetch_assoc($qqres))
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
									
								if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
								if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
								if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
									
								if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%S_4_%' and GRADEID='".$qqrows2['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $value-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
						}
					}
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_dd_receiver where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
						$qqres = mysql_query($qqsql);
						$qqrec = mysql_num_rows($qqres);
						if($qqrec == 0)
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
										
							if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
							
								
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='5' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
						}
						else
						{
							while($qqrows = mysql_fetch_assoc($qqres))
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
									
								if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value1 = 0;}
								if($qqrows['TTL_DEMURRAGE'] == 0){$value1 = $qqrows['TTL_DESPATCH'];}
								if($qqrows['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows['TTL_DEMURRAGE'];}  
									
								if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%R_5_%' and GRADEID='".$qqrows['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $value-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
						}
					}
				}
			}
			else
			{
				$query = "select * from fca_vci_dd_receiver where FCAID='".$obj->getFun1()."'";
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				if($qrec > 0)
				{
					while($qrows = mysql_fetch_assoc($qres))
					{
						$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
						$qqres = mysql_query($qqsql);
						$qqrec = mysql_num_rows($qqres);
						if($qqrec == 0)
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
										
							if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
							
								
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='R_5_' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
						}
						else
						{
							while($qqrows = mysql_fetch_assoc($qqres))
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
									
								if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value1 = 0;}
								if($qqrows['TTL_DEMURRAGE'] == 0){$value1 = $qqrows['TTL_DESPATCH'];}
								if($qqrows['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows['TTL_DEMURRAGE'];}  
									
								if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%R_5_%' and GRADEID='".$qqrows['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $value-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
						}
					}
				}
			}
			
			if($obj->getFun2() == 1)
			{
				$query = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
			}
			else
			{
				$query = "select * from fca_vci_other_misc_cost where FCAID='".$obj->getFun1()."'";
			}
			$qres = mysql_query($query);
			$qrec = mysql_num_rows($qres);
			while($qrows = mysql_fetch_assoc($qres))
			{
				$cost_1 = 0; $vendor = ''; $pay_name = '';
					
				if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
				{
					$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
				
				
					$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='6' and GRADEID='".$qrows['OTHER_MCOSTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
					$res2 = mysql_query($sql2);
					$deduction = 0;
					while($rows2 = mysql_fetch_assoc($res2))
					{ 
						$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
						$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
						
						$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
						$qres1 = mysql_query($qsql1);
						$deduction_1 = 0;
						while($qrows1 = mysql_fetch_assoc($qres1))
						{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
						
						$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
					}
					
					$cost_1 = $qrows['AMOUNT']-$cost_1-$deduction;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'All Other Miscellaneous Costs',$obj->getOtherMiscCostNameBasedOnID($qrows['OTHER_MCOSTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['AMOUNT']),$pay_name,$obj->getNumberFormat($cost_1));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
			}
			
			if($j < $rec)
			{
				$pdf->AddPage('P');
			}
			$pdf->Ln(5);
		}
		
	}
	
}
else
{
	$msql = "select * from open_vessel_entry_master where VESSEL_IMO_ID='".$selVessel."'";
	$mres = mysql_query($msql);
	$mrec = mysql_num_rows($mres);
	while($mrows = mysql_fetch_assoc($mres))
	{
		$sql = "select * from mapping_master where MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."' and OPEN_VESSEL_ID='".$mrows['OPENVESSEL_ID']."' and STATUS in (2,5) order by MAPPINGID"; 
		$res = mysql_query($sql);
		while($rows = mysql_fetch_assoc($res))
		{
			$open_vessel_id = $obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID");
			$sql1 = "select * from open_vessel_entry_master where (CP_DATE BETWEEN '".date("Y-m-d",strtotime($Date_From))."' and '".date("Y-m-d",strtotime($Date_To))."') and OPENVESSEL_ID='".$open_vessel_id."'";
			$res1 = mysql_query($sql1);
			$rec1 = mysql_num_rows($res1);
			if($rec1 > 0)
			{
				$pdf->SetFont('Arial','',8);
				$pdf->SetTextColor(30,133,190);
				$arr1=array('L');
				$arr2=array(80);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row1(array($obj->getVesselIMOData($obj->getVesselOpenEntryDeta($rows['OPEN_VESSEL_ID'],"VESSEL_IMO_ID"),"VESSEL_NAME")));
				
				$pdf->Ln(1);
				
				$arr1 = $arr2 = $arr3 = array();	
				$pdf->SetFont('Arial','B',7);
				$pdf->SetFillColor(128,128,128);
				$pdf->SetTextColor(255,255,255);
				$pdf->SetDrawColor(238,238,238);
				$arr1=array('L','L','L','L','L','L','L','L','L');
				$arr2=array(20,20,20,20,20,25,20,25,20);
				$arr3=array("Nom ID","Cost Type","Cost Desc.","Vendor","CP Date","Port","TTL Outstanding","Payment","Balance Outstanding");
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
				
				$l_cost_sheet_id = $obj->getLatestCostSheetID($rows['MAPPINGID']);
				$obj->viewFreightEstimationRecords($rows['MAPPINGID'],$l_cost_sheet_id);
				
				$i = 0;
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_bunker_nett where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
							
							if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
							
							
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='1' and GRADEID='".$qrows['BUNKERGRADEID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Bunkers Nett Supply',$obj->getBunkerGradeBasedOnID($qrows['BUNKERGRADEID']).' Nett',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
							
						}
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$cost_1 = 0; $vendor = ''; $pay_name = '';
							
					if($obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID")) != '') 
					{
						$vendor .= $obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID")).'('.$obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID").')';
					
					
						$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='7' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
						$res2 = mysql_query($sql2);
						while($rows2 = mysql_fetch_assoc($res2))
						{ 
							$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
							$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
						}
						
						$cost_1 = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost_1;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
				else
				{
					$cost_1 = 0; $vendor = ''; $pay_name = '';
							
					if($obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR")) != '') 
					{
						$vendor .= $obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR")).'('.$obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_VENDOR").')';
					
					
						$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='9' and GRADEID='0' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
						$res2 = mysql_query($sql2);
						$deduction = 0;
						while($rows2 = mysql_fetch_assoc($res2))
						{ 
							$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
							$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
							
							$qsql = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
							$qres = mysql_query($qsql);
							$deduction_1 = 0;
							while($qrows = mysql_fetch_assoc($qres))
							{ $deduction = $deduction+$qrows['COST']; $deduction_1 = $deduction_1+$qrows['COST'];}
							
							$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
						}
						
						$cost_1 = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")-$cost_1-$deduction;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")),$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
				}
				else
				{
					$query = "select * from fca_vci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
				}
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				while($qrows = mysql_fetch_assoc($qres))
				{
					$cost_1 = 0; $vendor = ''; $pay_name = '';
							
					if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
					{
						$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
					
					
						$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='2' and GRADEID='".$qrows['OTHER_SCOSTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
						$res2 = mysql_query($sql2);
						$deduction = 0;
						while($rows2 = mysql_fetch_assoc($res2))
						{ 
							$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
							$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
							
							$qsql = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
							$qres = mysql_query($qsql);
							$deduction_1 = 0;
							while($qrows = mysql_fetch_assoc($qres))
							{ $deduction = $deduction+$qrows['COST']; $deduction_1 = $deduction_1+$qrows['COST'];}
							
							$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
						}
						
						$cost_1 = $qrows['ABSOLUTE']-$cost_1-$deduction;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'All Other Shipping Costs',$obj->getOtherShippingCostNameBasedOnID($qrows['OTHER_SCOSTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['ABSOLUTE']),$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
				}
				else
				{
					$query = "select * from fca_vci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
				}
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				while($qrows = mysql_fetch_assoc($qres))
				{
					$cost_1 = 0; $vendor = ''; $pay_name = ''; $port_name = '';
					
					if($qrows['PORT'] == "Load"){$port_name = 'Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
					else if($qrows['PORT'] == "Discharge"){$port_name = 'Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
					else if($qrows['PORT'] == "Transit"){$port_name = 'Transit Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']);}
							
					if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
					{
						$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
					
					
						$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='3' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
						$res2 = mysql_query($sql2);
						$deduction = 0;
						while($rows2 = mysql_fetch_assoc($res2))
						{ 
							$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
							$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
							
							$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
							$qres1 = mysql_query($qsql1);
							$deduction_1 = 0;
							while($qrows1 = mysql_fetch_assoc($qres1))
							{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
							
							$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
						}
						
						$cost_1 = $qrows['COST']-$cost_1-$deduction;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Port Costs',$port_name,$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
				
				if($obj->getFun2() == 2)
				{
					$query = "select * from fca_vci_totals where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$cost_1 = 0; $vendor = ''; $pay_name = '';
							if($obj->getVendorListNewBasedOnID($qrows['DDB_VENDOR']) != '')
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['DDB_VENDOR']).'('.$qrows['DDB_VENDOR'].')';
								
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='8' and GRADEID='0' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['DD_BROKERAGE_COST']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Ship Owner','Brokerage',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['DD_BROKERAGE_COST']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
							
							$cost_1 = 0; $vendor = ''; $pay_name = '';
							if($obj->getVendorListNewBasedOnID($qrows['DDN_VENDOR']) != '')
							{
								$vendor .= $obj->getVendorListNewBasedOnID($qrows['DDN_VENDOR']).'('.$qrows['DDN_VENDOR'].')';
								
								$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='8' and GRADEID='1' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
								$res2 = mysql_query($sql2);
								$deduction = 0;
								while($rows2 = mysql_fetch_assoc($res2))
								{ 
									$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
									$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
									
									$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
									$qres1 = mysql_query($qsql1);
									$deduction_1 = 0;
									while($qrows1 = mysql_fetch_assoc($qres1))
									{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
									
									$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
								}
								
								$cost_1 = $qrows['DD_NETT']-$cost_1-$deduction;
								
								$arr1 = $arr2 = $arr3 = array();	
								$i=$i+1;
								if($i % 2 == 0)
								{
									$pdf->SetFillColor(244,244,244);
								}
								else
								{
									$pdf->SetFillColor(255,255,255);
								}
								
								$pdf->SetFont('Arial','',7);
								$pdf->SetTextColor(0,0,0);
								$arr1=array('L','L','L','L','L','L','L','L','L');
								$arr2=array(20,20,20,20,20,25,20,25,20);
								$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Ship Owner','Nett',$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['DD_NETT']),$pay_name,$obj->getNumberFormat($cost_1));
								$pdf->SetAligns($arr1);
								$pdf->SetWidths($arr2);
								$pdf->Row2($arr3);
							}
							
						}
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_dd_shipper where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
							$qqres = mysql_query($qqsql);
							$qqrec = mysql_num_rows($qqres);
							if($qqrec == 0)
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
											
								if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='4' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $qrows['COST']-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
							else
							{
								while($qqrows = mysql_fetch_assoc($qqres))
								{
									$cost_1 = 0; $vendor = ''; $pay_name = '';
										
									if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
									if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
									if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
										
									if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
									{
										$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
									
									
										$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%S_4_%' and GRADEID='".$qqrows2['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
										$res2 = mysql_query($sql2);
										$deduction = 0;
										while($rows2 = mysql_fetch_assoc($res2))
										{ 
											$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
											$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
											$qsql1 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
											$qres1 = mysql_query($qsql1);
											$deduction_1 = 0;
											while($qrows1 = mysql_fetch_assoc($qres1))
											{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
											
											$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
										}
										
										$cost_1 = $value-$cost_1-$deduction;
										
										$arr1 = $arr2 = $arr3 = array();	
										$i=$i+1;
										if($i % 2 == 0)
										{
											$pdf->SetFillColor(244,244,244);
										}
										else
										{
											$pdf->SetFillColor(255,255,255);
										}
										
										$pdf->SetFont('Arial','',7);
										$pdf->SetTextColor(0,0,0);
										$arr1=array('L','L','L','L','L','L','L','L','L');
										$arr2=array(20,20,20,20,20,25,20,25,20);
										$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
										$pdf->SetAligns($arr1);
										$pdf->SetWidths($arr2);
										$pdf->Row2($arr3);
									}
								}
							}
						}
					}
				}
				else
				{
					$query = "select * from fca_vci_dd_shipper where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
							$qqres = mysql_query($qqsql);
							$qqrec = mysql_num_rows($qqres);
							if($qqrec == 0)
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
											
								if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='S_4_' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $qrows['COST']-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
							else
							{
								while($qqrows = mysql_fetch_assoc($qqres))
								{
									$cost_1 = 0; $vendor = ''; $pay_name = '';
										
									if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
									if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
									if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
										
									if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
									{
										$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
									
									
										$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%S_4_%' and GRADEID='".$qqrows2['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
										$res2 = mysql_query($sql2);
										$deduction = 0;
										while($rows2 = mysql_fetch_assoc($res2))
										{ 
											$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
											$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
											$qres1 = mysql_query($qsql1);
											$deduction_1 = 0;
											while($qrows1 = mysql_fetch_assoc($qres1))
											{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
											
											$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
										}
										
										$cost_1 = $value-$cost_1-$deduction;
										
										$arr1 = $arr2 = $arr3 = array();	
										$i=$i+1;
										if($i % 2 == 0)
										{
											$pdf->SetFillColor(244,244,244);
										}
										else
										{
											$pdf->SetFillColor(255,255,255);
										}
										
										$pdf->SetFont('Arial','',7);
										$pdf->SetTextColor(0,0,0);
										$arr1=array('L','L','L','L','L','L','L','L','L');
										$arr2=array(20,20,20,20,20,25,20,25,20);
										$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Shipper','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
										$pdf->SetAligns($arr1);
										$pdf->SetWidths($arr2);
										$pdf->Row2($arr3);
									}
								}
							}
						}
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_dd_receiver where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
							$qqres = mysql_query($qqsql);
							$qqrec = mysql_num_rows($qqres);
							if($qqrec == 0)
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
											
								if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='5' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $qrows['COST']-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
							else
							{
								while($qqrows = mysql_fetch_assoc($qqres))
								{
									$cost_1 = 0; $vendor = ''; $pay_name = '';
										
									if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value1 = 0;}
									if($qqrows['TTL_DEMURRAGE'] == 0){$value1 = $qqrows['TTL_DESPATCH'];}
									if($qqrows['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows['TTL_DEMURRAGE'];}  
										
									if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
									{
										$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
									
									
										$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%R_5_%' and GRADEID='".$qqrows['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
										$res2 = mysql_query($sql2);
										$deduction = 0;
										while($rows2 = mysql_fetch_assoc($res2))
										{ 
											$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
											$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
											$qres1 = mysql_query($qsql1);
											$deduction_1 = 0;
											while($qrows1 = mysql_fetch_assoc($qres1))
											{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
											
											$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
										}
										
										$cost_1 = $value-$cost_1-$deduction;
										
										$arr1 = $arr2 = $arr3 = array();	
										$i=$i+1;
										if($i % 2 == 0)
										{
											$pdf->SetFillColor(244,244,244);
										}
										else
										{
											$pdf->SetFillColor(255,255,255);
										}
										
										$pdf->SetFont('Arial','',7);
										$pdf->SetTextColor(0,0,0);
										$arr1=array('L','L','L','L','L','L','L','L','L');
										$arr2=array(20,20,20,20,20,25,20,25,20);
										$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
										$pdf->SetAligns($arr1);
										$pdf->SetWidths($arr2);
										$pdf->Row2($arr3);
									}
								}
							}
						}
					}
				}
				else
				{
					$query = "select * from fca_vci_dd_receiver where FCAID='".$obj->getFun1()."'";
					$qres = mysql_query($query);
					$qrec = mysql_num_rows($qres);
					if($qrec > 0)
					{
						while($qrows = mysql_fetch_assoc($qres))
						{
							$qqsql = "select * from laytime_master where MAPPINGID='".$rows['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$qrows['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
							$qqres = mysql_query($qqsql);
							$qqrec = mysql_num_rows($qqres);
							if($qqrec == 0)
							{
								$cost_1 = 0; $vendor = ''; $pay_name = '';
											
								if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
								{
									$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
								
								
									$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='R_5_' and GRADEID='".$qrows['LOADPORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
									$res2 = mysql_query($sql2);
									$deduction = 0;
									while($rows2 = mysql_fetch_assoc($res2))
									{ 
										$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
										$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
										
										$qres1 = mysql_query($qsql1);
										$deduction_1 = 0;
										while($qrows1 = mysql_fetch_assoc($qres1))
										{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
										
										$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
									}
									
									$cost_1 = $qrows['COST']-$cost_1-$deduction;
									
									$arr1 = $arr2 = $arr3 = array();	
									$i=$i+1;
									if($i % 2 == 0)
									{
										$pdf->SetFillColor(244,244,244);
									}
									else
									{
										$pdf->SetFillColor(255,255,255);
									}
									
									$pdf->SetFont('Arial','',7);
									$pdf->SetTextColor(0,0,0);
									$arr1=array('L','L','L','L','L','L','L','L','L');
									$arr2=array(20,20,20,20,20,25,20,25,20);
									$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Discharge Port '.$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qrows['LOADPORTID']),$obj->getNumberFormat($qrows['COST']),$pay_name,$obj->getNumberFormat($cost_1));
									$pdf->SetAligns($arr1);
									$pdf->SetWidths($arr2);
									$pdf->Row2($arr3);
								}
							}
							else
							{
								while($qqrows = mysql_fetch_assoc($qqres))
								{
									$cost_1 = 0; $vendor = ''; $pay_name = '';
										
									if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value1 = 0;}
									if($qqrows['TTL_DEMURRAGE'] == 0){$value1 = $qqrows['TTL_DESPATCH'];}
									if($qqrows['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows['TTL_DEMURRAGE'];}  
										
									if($obj->getVendorListNewBasedOnID($qqrows['VENDOR']) != '') 
									{
										$vendor .= $obj->getVendorListNewBasedOnID($qqrows['VENDOR']).'('.$qqrows['VENDOR'].')';
									
									
										$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID LIKE '%R_5_%' and GRADEID='".$qqrows['PORTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
										$res2 = mysql_query($sql2);
										$deduction = 0;
										while($rows2 = mysql_fetch_assoc($res2))
										{ 
											$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
											$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
											$qres1 = mysql_query($qsql1);
											$deduction_1 = 0;
											while($qrows1 = mysql_fetch_assoc($qres1))
											{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
											
											$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
										}
										
										$cost_1 = $value-$cost_1-$deduction;
										
										$arr1 = $arr2 = $arr3 = array();	
										$i=$i+1;
										if($i % 2 == 0)
										{
											$pdf->SetFillColor(244,244,244);
										}
										else
										{
											$pdf->SetFillColor(255,255,255);
										}
										
										$pdf->SetFont('Arial','',7);
										$pdf->SetTextColor(0,0,0);
										$arr1=array('L','L','L','L','L','L','L','L','L');
										$arr2=array(20,20,20,20,20,25,20,25,20);
										$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'Demurrage Dispatch Receiver','Load Port '.$obj->getPortNameBasedOnID($qqrows['PORTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),$obj->getPortNameBasedOnID($qqrows['PORTID']),$obj->getNumberFormat($value),$pay_name,$obj->getNumberFormat($cost_1));
										$pdf->SetAligns($arr1);
										$pdf->SetWidths($arr2);
										$pdf->Row2($arr3);
									}
								}
							}
						}
					}
				}
				
				if($obj->getFun2() == 1)
				{
					$query = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
				}
				else
				{
					$query = "select * from fca_vci_other_misc_cost where FCAID='".$obj->getFun1()."'";
				}
				$qres = mysql_query($query);
				$qrec = mysql_num_rows($qres);
				while($qrows = mysql_fetch_assoc($qres))
				{
					$cost_1 = 0; $vendor = ''; $pay_name = '';
						
					if($obj->getVendorListNewBasedOnID($qrows['VENDORID']) != '') 
					{
						$vendor .= $obj->getVendorListNewBasedOnID($qrows['VENDORID']).'('.$qrows['VENDORID'].')';
					
					
						$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='6' and GRADEID='".$qrows['OTHER_MCOSTID']."' and REQUESTED='1' and MAPPINGID=".$rows['MAPPINGID'];
						$res2 = mysql_query($sql2);
						$deduction = 0;
						while($rows2 = mysql_fetch_assoc($res2))
						{ 
							$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; 
							$pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
							
							$qres1 = mysql_query($qsql1);
							$deduction_1 = 0;
							while($qrows1 = mysql_fetch_assoc($qres1))
							{ $deduction = $deduction+$qrows1['COST']; $deduction_1 = $deduction_1+$qrows1['COST'];}
							
							$pay_name .= "Deduction : ".$obj->getNumberFormat($deduction_1)."\n";
						}
						
						$cost_1 = $qrows['AMOUNT']-$cost_1-$deduction;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows['MAPPINGID'],"NOM_NAME"),'All Other Miscellaneous Costs',$obj->getOtherMiscCostNameBasedOnID($qrows['OTHER_MCOSTID']),$vendor,date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),'CP_DATE'))),'',$obj->getNumberFormat($qrows['AMOUNT']),$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
				
				$pdf->Ln(5);
				
			}
			
		}
	}
}

$filename = "Vessel Wise Oustanding Report_".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function create_pda_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$mappingid = $_REQUEST['mappingid'];
	$gen_agency_id = $_REQUEST['gen_agency_id'];
	$vendor_id = $_REQUEST['vendor_id'];
	
	$cost_sheet_id = $obj->getLatestCostSheetID($mappingid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
	$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
	
	$_SESSION['PORT'] = $obj->getAgencyLetterData($gen_agency_id,"PORT");
	$_SESSION['PORT_NAME'] = $obj->getPortNameBasedOnID($obj->getAgencyLetterData($gen_agency_id,"PORTID"));

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('PDA Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('PDA Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(20,5,30,20,5,70);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

if(date("d-M-Y",strtotime($obj->getLoadPortCostData($gen_agency_id,"DATE"))) == "01-Jan-1970")
{ $date = date("d-M-Y",time());}else{ $date = date("d-M-Y",strtotime($obj->getLoadPortCostData($gen_agency_id,"DATE")));}

$pdf->Row1(array("Date",":",$date,"Agent",":",strtoupper($obj->getVendorListNewBasedOnID($vendor_id))." (".$vendor_id.")"));

$pdf->Ln(5);

$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(20,5,30,20,5,40,30,5,30);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Vessel",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Nom ID",":",$obj->getMappingData($mappingid,"NOM_NAME"),"Port",":",$obj->getPortNameBasedOnID($obj->getAgencyLetterData($gen_agency_id,"PORTID"))));

$pdf->Ln(5);

$pdf->Row1(array("Country",":",$obj->getCountryNameBasedOnID($obj->getAgencyLetterData($gen_agency_id,"COUNTRY_ID")),"Currency",":",$obj->getCountryData($obj->getAgencyLetterData($gen_agency_id,"COUNTRY_ID"),"CURRENCY_NAME"),"Exchange Rate",":",$obj->getLoadPortCostData($gen_agency_id,"FINAL_EXCHANGE_RATE")));

$pdf->Ln(5);

$pdf->Row1(array("","","","","","","Initial Exchange Rate",":",$obj->getLoadPortCostData($gen_agency_id,"EXCHANGE_RATE")));

$pdf->Ln(10);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L');
$arr2=array(40,22,25,22,25,30,28);
$arr3=array("Port Cost Type","Estmd Cost(LC)","Estmd Cost(USD)","Actual Cost(LC)","Actual Cost(USD)","Remarks(Operator)","Remarks(Agent)");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql = "select * from port_cost_type_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' order by NAME";
$res = mysql_query($sql);
$i = 0;
while($rows = mysql_fetch_assoc($res))
{
	if(!is_null($rows['COUNTRY_IDS']) && $rows['COUNTRY_IDS'] != "")
	{
		$c_arr = explode(",",$rows['COUNTRY_IDS']);
		if(in_array($obj->getAgencyLetterData($gen_agency_id,"COUNTRY_ID"),$c_arr))
		{
			$lp_costid = $obj->getLoadPortCostData($gen_agency_id,"LP_COST_ID");
			
			$cost_1 = $obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ESTMD_COST_LC");
			$cost_2 = $obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ACTUAL_COST_LC");
			
			if(!empty($cost_1) && $cost_1 !=0)
			{
				$arr1 = $arr2 = $arr3 = array();	
				$i=$i+1;
				if($i % 2 == 0)
				{
					$pdf->SetFillColor(244,244,244);
				}
				else
				{
					$pdf->SetFillColor(255,255,255);
				}
				
				$pdf->SetFont('Arial','',7);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('L','L','L','L','L','L','L','L','L');
				$arr2=array(40,22,25,22,25,30,28);
				$arr3=array($rows['NAME'],$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ESTMD_COST_LC"),$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ESTMD_COST_USD"),$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ACTUAL_COST_LC"),$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"ACTUAL_COST_USD"),$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"REMARKS_OPERATOR"),$obj->getLoadPortCostSlaveData($lp_costid,$rows['PC_TYPE_ID'],"REMARKS_AGENTS"));
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
			}
		}
	}
}

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L');
$arr2=array(40,22,25,22,83);
$arr3=array("Total",$obj->getLoadPortCostData($gen_agency_id,"TTL_ESTMD_COST_LC"),$obj->getLoadPortCostData($gen_agency_id,"TTL_ESTMD_COST_USD"),$obj->getLoadPortCostData($gen_agency_id,"TTL_ACTUAL_COST_LC"),$obj->getLoadPortCostData($gen_agency_id,"TTL_ACTUAL_COST_USD"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr1=array('R','L');
$arr2=array(87,105);
$arr3=array("Advance Requested 1",$obj->getLoadPortCostData($gen_agency_id,"ADV_REQUESTED_1"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$arr3=array("Advance Requested 2",$obj->getLoadPortCostData($gen_agency_id,"ADV_REQUESTED_2"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->Ln(10);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L');
$arr2=array(30,5,80);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Bank Details(Agency)",":",$obj->getLoadPortCostData($gen_agency_id,"BANK_DETAILS")));

$pdf->Ln(5);

$arr1=array('L','C','L','L','C','L');
$arr2=array(30,5,40,40,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Prepared By(Agency)",":",$obj->getLoadPortCostData($gen_agency_id,"PREPARED_BY"),"Authorized By(Agency)",":",$obj->getLoadPortCostData($gen_agency_id,"AUTHORIZED_BY")));

$filename = 'PDA Report ('.$_SESSION['PORT'].' - '.$_SESSION['PORT_NAME'].')_'.date("d-m-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}







function shipment_register_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtFrom_Date 	= $_REQUEST['txtFrom_Date'];
	$txtTo_Date  	= $_REQUEST['txtTo_Date'];
	$selDate_Type 	= $_REQUEST['selDate_Type'];
	$selBType 	    = $_REQUEST['selBType'];
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,157,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"____________________________________________________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF('L','mm','Legal');
$pdf->AddPage();
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Shipment Register Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Shipment Register Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');
$pdf->SetMargins(0,0,0);

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);


$pdf->Ln(5);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);

$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
$arr2=array(12,12,12,20,20,17,17,24,24,28,19,19,19,19,19,19,19,19,19);
$arr3=array("Nom ID","Vessel","CP Date","Owner","Broker","Material Desc","Last Updated Freight","From Port","To Port","BL Date","Qty","Operational Expenses","Port Expenses","Bunker Expenses","Voyage Earnings","Daily Earnings / TCE","Voyage Earnings + Demurrage","Nett Daily Profit","P/L");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

	$sql = "select * 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_estimete_master.ESTIMATE_TYPE='".$selBType."' and freight_cost_estimate_compare.STATUS in (1,2) order by freight_cost_estimate_compare.COMID desc";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res); $j = 0;
	if($rec == 0)
	{
	}
	else
	{
		while($rows = mysql_fetch_assoc($res))
		{
			$fcaid = $obj->getLatestCostSheetID($rows['COMID']);
			$obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
			
			$quantity = $freight = 0;
			if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==1)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
				if($obj->getCompareEstimateData($rows['COMID'],"GAS_MARKET"))
				{
					$freight = $obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY");
				}
				else
				{
					$freight = number_format(($obj->getCompareEstimateData($rows['COMID'],"GAS_BALTIC") + $obj->getCompareEstimateData($rows['COMID'],"ADDNL_PRENIUM"))*$obj->getCompareEstimateData($rows['COMID'],"GAS_QUANTITY"), 2, '.', '');
				}
			}
			else if($obj->getCompareEstimateData($rows['COMID'],"ESTIMATE_TYPE")==2)
			{
				$quantity = $obj->getCompareEstimateData($rows['COMID'],"TANK_QUANTITY");
				if($obj->getFun228()==1)
				{
					if($obj->getCompareEstimateData($comid,"CHK_LUMPSUM") == 1)
					{
						$freight = $obj->getCompareEstimateData($comid,"LUMPSUMAMT");
					}
					else
					{
						$res11 = mysql_query("select sum(TOTAL_AMOUNT) as sum1 from freight_cost_estimete_slave12 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."' and CUSTOMER!='' ");
						$num11 = mysql_num_rows($res11);
						$rows11 = mysql_fetch_assoc($res11);
						$freight = $rows11['sum1'];
					}
				}
				else
				{
					$sql12 = "select sum(AMOUNT_USD) as sum1 from freight_cost_estimete_slave10 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."' group by SHIPPER_CHARTER";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					$freight  = $row12['sum1'];
				}
			}
			else
			{
				if($obj->getCompareEstimateData($rows['COMID'],"QTY_TYPE_RADIO")== 1)
				{
					$quantity = $obj->getCompareEstimateData($rows['COMID'],"QUANTITY");
					$freight  = $obj->getCompareEstimateData($rows['COMID'],"NET_PAYABLE");
				}
				else
				{
					$sql12 = "select sum(QUANTITY) as sum, sum(NET_FREIGHT) as sum2 from freight_cost_estimete_slave7 where FCAID='".$obj->getCompareEstimateData($rows['COMID'],"FCAID")."'";
					$res12 = mysql_query($sql12);
					$row12 = mysql_fetch_assoc($res12);
					$quantity = $row12['sum'];
					$freight  = number_format($row12['sum2'], 2, '.', '');
				}
			}
			
			$addn_qty = $obj->getFun54();
			$dead_freight_qty = $obj->getFun53();				
			$arr  = $obj->getLoadPortAndDischargePortArrBasedOnCommidAndProcessWithoutTBN($rows['COMID'],$fcaid);
			
			$lp_name = ''; $dp_name = '';
			for($i=0;$i<count($arr);$i++)
			{
				$arr_portval = explode('@@',$arr[$i]);
				if($arr_portval[0] == "LP"){$lp_name .= $obj->getPortNameBasedOnID($arr_portval[1]).', ';}
				if($arr_portval[0] == "DP"){$dp_name .= $obj->getPortNameBasedOnID($arr_portval[1]).', ';}
			}
			
			$lp_name = substr($lp_name,0,-6);
			$dp_name = substr($dp_name,0,-6);
			$bl_date_arr = array();
			$bl_qty = 0;
			if($selDate_Type == 1)
			{
				$sql1 = "select * from sof_master where (BL_DATE BETWEEN '".date("Y-m-d",strtotime($txtFrom_Date))."' and '".date("Y-m-d",strtotime($txtTo_Date))."') and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and COMID='".$rows['COMID']."' and LOGIN = 'INTERNAL_USER'";
				$res1 = mysql_query($sql1);
				$res11 = mysql_query($sql1);
			    $rec1 = mysql_num_rows($res1);
				$bl_date_arr = array();
			    while($rows1 = mysql_fetch_assoc($res1))
				{
					for($i=0;$i<count($arr);$i++)
			        {
						$arr_portval = explode('@@',$arr[$i]);
						$sql2 = "select * from sof_master where SOFID='".$rows1['SOFID']."' and PORT='".$arr_portval[0]."' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."'";
						$res2 = mysql_query($sql2);
						$rec2 = mysql_num_rows($res2);
						while($rows2 = mysql_fetch_assoc($res2))
						{
							$bl_date = date("d-M-Y",strtotime($rows2['BL_DATE']));
							$bl_date_arr[] = $arr_portval[0]."-".$obj->getPortNameBasedOnID($arr_portval[1])."-".$bl_date;
							$bl_qty = $bl_qty + $rows2['BL_QTY_LOADED'];
						}
					}
				}
			}
			else
			{
				$sql1 = "select * from freight_cost_estimete_master where (TRANS_DATE BETWEEN '".date("Y-m-d",strtotime($txtFrom_Date))."' and '".date("Y-m-d",strtotime($txtTo_Date))."') and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and COMID='".$rows['COMID']."' and FCAID='".$fcaid."' order by FCAID";
				$res1 = mysql_query($sql1);
				$res11 = mysql_query($sql1);
			    $rec1 = mysql_num_rows($res1);
			    $rows1 = mysql_fetch_assoc($res1);
				
				$bl_date_arr = array();
				for($i=0;$i<count($arr);$i++)
				{
					$arr_portval = explode('@@',$arr[$i]);
					$sql2 = "select * from sof_master where COMID='".$rows1['COMID']."' and PORT='".$arr_portval[0]."' and PORTID='".$arr_portval[1]."' and RANDOMID='".$arr_portval[2]."' and LOGIN = 'INTERNAL_USER'";
					$res2 = mysql_query($sql2) or die($sql2);
					$rec2 = mysql_num_rows($res2);
					while($rows2 = mysql_fetch_assoc($res2))
					{
						if($rows2['BL_DATE']!='' && $rows2['BL_DATE']!='0000-00-00' && $rows2['BL_DATE']!='1970-01-01' && $rows2['BL_DATE']!='01-01-1970')
						{
						   $bl_date = date("d-M-Y",strtotime($rows2['BL_DATE']));
						}
						else
						{
							$bl_date = '';
						}
						$bl_date_arr[] = $arr_portval[0]."-".$obj->getPortNameBasedOnID($arr_portval[1])."-".$bl_date;
						$bl_qty = $bl_qty + $rows2['BL_QTY_LOADED'];
					}
				}
			}
			
			
			if($rec1>0)
			{
				$arr3 = array();	
				$pdf->SetFillColor(255,255,255);
				$pdf->SetTextColor(0,0,0);
				$pdf->SetAligns($arr4);
				$pdf->SetWidths($arr5);
				
				$sql7 = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."' ";
				$res7 = mysql_query($sql7);
				$rec7 = mysql_num_rows($res7);
				$arrvendor = array();
				while($rows7 = mysql_fetch_assoc($res7))
				{
					$arrvendor[] = $obj->getVendorListNewBasedOnID($rows7['VENDORID']);
				}
				
				$arr3=array($obj->getCompareTableData($rows['COMID'],"MESSAGE"),$obj->getVesselIMOData($obj->getFun5(),"VESSEL_NAME"),(($obj->getFun3()=='' || $obj->getFun3()=='0000-00-00' || $obj->getFun3()=='1970-01-01')?'':date("d-m-Y",strtotime($obj->getFun3()))),$obj->getCompanyNameBasedOnID($_SESSION['company'],"COMPANY_NAME"),implode(', ',$arrvendor),$obj->getMaterialCodeDesBasedOnId($obj->getFun52()),$freight,$lp_name,$dp_name,implode(', ',$bl_date_arr),$obj->getNumberFormat($quantity),$obj->getNumberFormat($obj->getFun84()),$obj->getNumberFormat($obj->getFun153()),$obj->getNumberFormat($obj->getFun152()),$obj->getNumberFormat($obj->getFun89()),$obj->getNumberFormat($obj->getFun90()),$obj->getNumberFormat($obj->getFun92()),$obj->getNumberFormat($obj->getFun93()),$obj->getNumberFormat($obj->getFun95()));
				$pdf->SetAligns($arr1);
                $pdf->SetWidths($arr2);
				$pdf->Row2($arr3);
			}
		}
	}
$filename = "Shipment Register Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function cost_sheet_tmp_pdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['fca_tmpid'])){$fca_tmpid = $_REQUEST['fca_tmpid']; }
	$obj->viewFreightCostEstimationTempleteRecords($fca_tmpid);
	$_SESSION["fixtureid"] = $obj->getFun2();
//Create a new PDF file

	class PDF extends FPDF
	{
		function Header()
		{
			
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cost Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cost Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Main Particulars",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($obj->getFun3())),"Vessel Name",":",$obj->getVesselIMOData($obj->getFun4(),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getFun4(),"VESSEL_TYPE"))));

if($obj->getFun21() == 1)
{
	$dwt_str = "DWT(Summer)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getFun4(),"SUMMER_1");
}
else if($obj->getFun21() == 2)
{
	$dwt_str = "DWT(Tropical)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getFun4(),"TROPICAL_1");
}

if($obj->getFun6() == 1)
{
	$cap_str = "Grain Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getFun4(),"GRAIN");
}
else if($obj->getFun6() == 2)
{
	$cap_str = "Bale Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getFun4(),"BALE");
}

$pdf->Row1(array($dwt_str,":",$dwt_value,$cap_str,":",$cap_value,"SF (CBM/MT)",":",$obj->getFun9()."   Loadable (MT)  : ".$obj->getFun24()));
$pdf->Row1(array("Voyage No",":",$obj->getFun10(),"Cost Sheet Name",":",$obj->getFun5(),"TC No",":",$obj->getFun11()));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Market",0,1,'L');

if($obj->getFun12() == 1)
{
	$market_str = "TC Cost Per Day (USD)";
	$market_value = $obj->getFun13();
}
else if($obj->getFun12() == 2)
{
	$market_str = "Lumpsum (USD)";
	$market_value = $obj->getFun14();
}
$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array($market_str,":",$market_value,"","","","","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Cargo",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array("Cargo Qty (MT)",":",$obj->getFun15(),"Cargo Type",":",$obj->getCargoTypeNameBasedOnID(abs($obj->getFun16())),"Cargo Name",":",$obj->getMaterialCodeDesBasedOnId(abs($obj->getFun25()))));
//................start..................//
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Passage Locations",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);


$arr4=array('C','L','L','L','L');
$arr5=array(7,62,65,70,73);
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2(array("#","Location From","Location To","Passage Type","Distance"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql = "select * from fca_tci_sea_passage_location where FCATMPID='".$obj->getFun1()."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows1 = mysql_fetch_assoc($res))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr4);
		$pdf->SetWidths($arr5);
        $pdf->Row2(array($i.".",$rows1['LOCATION_FROM'],$rows['LOCATION_TO'],$obj->getPassageTypeNameBasedOnID($rows['PASSAGE_TYPE'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEED_TYPE'])." )",$rows['DISTANCE']));
	}
}

//.......................and................//
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Sea Passage",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr4=array('C','L','L','L','L','L','L');
$arr5=array(7,30,30,36,44,22,22);
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2(array("#","From Port","To Port","Passage Type","Distance","Weather %","Margin(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql = "select * from fca_tci_tmp_sea_passage where FCATMPID='".$obj->getFun1()."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows = mysql_fetch_assoc($res))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr4);
		$pdf->SetWidths($arr5);
		$pdf->Row2(array($i.".",$obj->getPortNameBasedOnID($rows['FROM_PORTID']),$obj->getPortNameBasedOnID($rows['TO_PORTID']),$obj->getPassageTypeNameBasedOnID($rows['PASSAGETYPEID'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEEDID'])." )",$rows['DISTANCE']."   (".$obj->getDistanceTypeBasedOnID_New($rows['DISTANCE_TYPEID'])." )",$rows['WEATHER'],$rows['MARGIN']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Load Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr6=array('L','L','L','L','L','L','L');
$arr7=array(28,42,23,25,30,22,22);
$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql1 = "select * from fca_tci_tmp_load_port where FCATMPID='".$obj->getFun1()."'";
$res1 = mysql_query($sql1);
$rec1 = mysql_num_rows($res1);
if($rec1 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows1 = mysql_fetch_assoc($res1))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows1['LOADPORTID']),$obj->getMaterialCodeDesBasedOnId($rows1['PURCHASE_ALLOCATIONID']),$rows1['QTY_MT'],$rows1['RATE'],$rows1['PORT_COST'],$rows1['IDLE_DAYS'],$rows1['WORK_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql2 = "select * from fca_tci_tmp_disch_port where FCATMPID='".$obj->getFun1()."'";
$res2 = mysql_query($sql2);
$rec2 = mysql_num_rows($res2);
if($rec2 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows2 = mysql_fetch_assoc($res2))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']),$obj->getMaterialCodeDesBasedOnId($rows2['PURCHASE_ALLOCID']),$rows2['QTY_MT'],$rows2['RATE'],$rows2['PORT_COST'],$rows2['IDLE_DAYS'],$rows2['WORK_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L');
$arr9=array(90,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Transit Port","Port Costs(USD)","Idle Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql3 = "select * from fca_tci_tmp_transit_port where FCATMPID='".$obj->getFun1()."'";
$res3 = mysql_query($sql3);
$rec3 = mysql_num_rows($res3);
if($rec3 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows3 = mysql_fetch_assoc($res3))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr8);
		$pdf->SetWidths($arr9);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows3['LOAD_PORTID']),$rows3['PORT_COST'],$rows3['IDLE_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Totals",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Laden Dist",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"LADEN_DIST"),"Ballast Dist",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"BALLAST_DIST"),"Total Dist",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TOTAL_DIST")));

$pdf->Row1(array("Laden Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"LADEN_DAYS"),"Ballast Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"BALLAST_DAYS"),"Total Sea Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_SEA_DAYS")));

$pdf->Row1(array("Ttl Port Idle Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_PORT_IDLE_DAYS"),"Ttl Port Work Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_PORT_WORK_DAYS"),"Total Days",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_DAYS")));

$pdf->Row1(array("Ttl FO Consp MT",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT"),"Ttl DO Consp MT",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT"),"","",""));

$pdf->Row1(array("Ttl FO Consp MT (Manual)",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL"),"Ttl FO Consp MT (Manual)",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL"),"","",""));

$pdf->Row1(array("Ttl FO Consp Off Hire",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_FO_CONSP_OFFHIRE"),"Ttl DO Consp Off Hire",":",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_DO_CONSP_OFFHIRE"),"","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L');
$arr9=array(90,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Percent","USD"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Total Hire (USD)","",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_HIRE_USD")));
$pdf->Row2(array("Address Commission",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"ADD_COMM_PER"),$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"ADD_COMM_USD")));
$pdf->Row2(array("Brokerage Commission",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PER"),$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"BROKERAGE_COMM_USD")));
$pdf->Row2(array("Nett Hire (USD)","",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"NETT_HIRE_USD")));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(238,238,238);
$arr10=array('L','C','C','C');
$arr11=array(70,40,40,40);
$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("Nett Hire (USD)",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"NETT_HIRE_USD"),"",""));

$sql5 = "select * from fca_tci_tmp_owner_related_cost where FCATMPID='".$obj->getFun1()."'";
$res5 = mysql_query($sql5);
$rec5 = mysql_num_rows($res5);
if($rec5 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows5 = mysql_fetch_assoc($res5))
	{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetAligns($arr10);
			$pdf->SetWidths($arr11);
			if($rows5['AMOUNT'] != 0)
			{
			$pdf->Row2(array($obj->getOwnerRelatedCostNameBasedOnID($rows5['OWNER_RCOSTID']),$rows5['AMOUNT'],"",""));
			}
	}
}

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Shipowner Expenses",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES"),"Cost/MT",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"ORC_COST_MT")));

$pdf->Ln(10);
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);


$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("","MT","PRICE","COST"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);
$name = array("Estimated");
$val_mt = array("EST_MT");
$val_price = array("EST_PRICE");
$val_cost = array("EST_COST");
$sum = 0;
$sql4 = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and STATUS=1";
$res4 = mysql_query($sql4);
$rec4 = mysql_num_rows($res4);
if($rec4 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
	while($rows4 = mysql_fetch_assoc($res4))
	{
		$ttl_bg[] = $rows4['NAME'];
		$ttl_bg1[] = $rows4['BUNKERGRADEID'];
		if($obj->getTempleteBunkerRec($obj->getFun1(),$rows4['BUNKERGRADEID']) > 0)
		{
			$sum += $obj->getTempleteBunkerValues($obj->getFun1(),$rows4['BUNKERGRADEID'],$val_cost[0]);
			$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows4['BUNKERGRADEID'])."  ".$name[0],$obj->getTempleteBunkerValues($obj->getFun1(),$rows4['BUNKERGRADEID'],$val_mt[0]),$obj->getTempleteBunkerValues($obj->getFun1(),$rows4['BUNKERGRADEID'],$val_price[0]),$obj->getTempleteBunkerValues($obj->getFun1(),$rows4['BUNKERGRADEID'],$val_cost[0])));
		}
	}
}


$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Bunker Cost",$sum,"Cost/MT",number_format($sum/$obj->getFun15(),2,'.','')));



$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Shipping Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr12=array('L','C','C');
$arr13=array(110,40,40);
$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql6 = "select * from fca_tci_tmp_other_shipping_cost where FCATMPID='".$obj->getFun1()."'";
$res6 = mysql_query($sql6);
$rec6 = mysql_num_rows($res6);
if($rec6 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows6 = mysql_fetch_assoc($res6))
	{
		$pdf->SetAligns($arr12);
		$pdf->SetWidths($arr13);
		if($rows6['ABSOLUTE'] != 0)
		{
			$pdf->Row2(array($obj->getOtherShippingCostNameBasedOnID($rows6['OTHER_SCOSTID']),$rows6['ABSOLUTE'],$rows6['COST_MT']));
		}
	}
}


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Port Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql7 = "select * from fca_tci_tmp_portcosts where FCATMPID='".$obj->getFun1()."' order by FCA_TMPPORTCOSTID asc";
$res7 = mysql_query($sql7);
$rec7 = mysql_num_rows($res7);
while($rows7 = mysql_fetch_assoc($res7))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);
	if($rows7['PORT'] == "Load"){$port_name = "Load Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Discharge"){$port_name = "Discharge Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Transit"){$port_name = "Transit Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	
	$pdf->Row2(array($port_name,$rows7['COST'],$rows7['COST_MT']));
}

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Port Costs",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_PORT_COSTS"),$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_PORT_COSTS_MT")));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Shipper",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql8 = "select * from fca_tci_tmp_dd_shipper where FCATMPID='".$obj->getFun1()."'";
$res8 = mysql_query($sql8);
$rec8 = mysql_num_rows($res8);
while($rows8 = mysql_fetch_assoc($res8))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows8['LOADPORTID']),$rows8['COST'],$rows8['COST_MT']));
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Receiver",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql9 = "select * from fca_tci_tmp_dd_receiver where FCATMPID='".$obj->getFun1()."'";
$res9 = mysql_query($sql9);
$rec9 = mysql_num_rows($res9);
while($rows9 = mysql_fetch_assoc($res9))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows9['LOADPORTID']),$rows9['COST'],$rows9['COST_MT']));
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Miscellaneous Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql10 = "select * from fca_tci_tmp_other_misc_cost where FCATMPID='".$obj->getFun1()."'";
$res10 = mysql_query($sql10);
$rec10 = mysql_num_rows($res10);
while($rows10 = mysql_fetch_assoc($res10))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	if($rows10['AMOUNT'] != 0)
	{
		$pdf->Row2(array($obj->getOtherMiscCostNameBasedOnID($rows10['OTHER_MCOSTID']),$rows10['AMOUNT'],$rows10['COST_MT']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Total Freight Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(220, 99, 30);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->Row2(array("Total Freight Costs",$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS"),$obj->getFreightCostEstimationTempleteTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS_MT")));

$filename = $obj->getVesselIMOData($obj->getFun4(),"VESSEL_NAME").' '.$obj->getFun5().' '.date("d-M-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function bunker_voyage_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$mappingid = $_REQUEST['mappingid'];
	$vesselid = $_REQUEST['vesselid'];
	
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Bunker Voyage Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Bunker Voyage Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(30,5,40,30,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Vessel",":",$obj->getVesselIMOData($vesselid,"VESSEL_NAME"),"Nom ID",":",$obj->getMappingData($mappingid,"NOM_NAME")));

$pdf->Ln(3);

	$cost_sheet_id = $obj->getLatestCostSheetID($mappingid);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
	$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($mappingid,$cost_sheet_id);
	
	$lp_name = ''; $dp_name = '';
	$obj->viewFreightEstimationRecords($mappingid,$cost_sheet_id);
	for($i=0;$i<count($arr);$i++)
	{
		if(substr($arr[$i],0,2) == "LP"){$lp_name .= substr($arr[$i],5).',';}
		else{$dp_name .= substr($arr[$i],5).',';}
	}
	
	$lp_name = substr($lp_name,0,-1);
	$dp_name = substr($dp_name,0,-1);

$sql = "select * from perf_at_sea where MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER'";
$res = mysql_query($sql);
$stoppage = '';
while($rows = mysql_fetch_assoc($res))
{
	$stoppage .= $rows['STOPPAGE'].',';
}
$stoppage = substr($stoppage,0,-1);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(30,5,40,30,5,40,30,5,60);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Departure Port",":",$dp_name,"Arrival Port",":",$lp_name,"Stoppage",":",$stoppage));

$pdf->Ln(5);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
$arr2=array(17,9,10,10,12,13,12,12,13,12,10,13,13,11,11,13,11,11,13,11,11,13,14);
$arr3=array("Date","Time","Lat","Long","ROB FO","Cons FO","Rate FO","ROB DO","Cons DO","Rate DO","RPM","Duration","Distance","Speed","Cons FO clng","Cons FO Htg","Cons FO G Frg","Cons FO Itg","Cons DO clng","Cons DO Htg","Cons DO G Frg","Cons DO Itg","Condition");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql = "select * from perf_at_sea where MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER'";
$res = mysql_query($sql);
$i = 0; $cons_fo = 0; $cons_do = 0; $cons_fo_clng = 0; $cons_fo_htg = 0; $cons_fo_g_frg = 0; $cons_fo_itg = 0;
		$cons_do_clng = 0; $cons_do_htg = 0; $cons_do_g_frg = 0; $cons_do_itg = 0; $duration = 0;
while($rows = mysql_fetch_assoc($res))
{
	$cons_fo = $cons_fo+$rows['CONS_FO'];
	$cons_do = $cons_do+$rows['CONS_DO'];
	$cons_fo_clng = $cons_fo_clng+$rows['CONS_FO_CLEAN'];
	$cons_fo_htg = $cons_fo_htg+$rows['CONS_FO_HEATING'];
	$cons_fo_g_frg = $cons_fo_g_frg+$rows['CONS_FO_G_FREEING'];
	$cons_fo_itg = $cons_fo_itg+$rows['CONS_FO_INERT'];
	
	$cons_do_clng = $cons_do_clng+$rows['CONS_DO_CLEAN'];
	$cons_do_htg = $cons_do_htg+$rows['CONS_DO_HEATING'];
	$cons_do_g_frg = $cons_do_g_frg+$rows['CONS_DO_G_FREEING'];
	$cons_do_itg = $cons_do_itg+$rows['CONS_DO_INERT'];
	$duration = $duration+$rows['DURATION'];
	
	$arr1 = $arr2 = $arr3 = array();	
	$i=$i+1;
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
	$arr2=array(17,9,10,10,12,13,12,12,13,12,10,13,13,11,11,13,11,11,13,11,11,13,14);
	$arr3=array(date("d-M-Y",strtotime($rows['DATE'])),$rows['TIME'],$rows['LAT'],$rows['LONG'],$rows['ROB_FO'],$rows['CONS_FO'],$rows['RATE_FO'],$rows['ROB_DO'],$rows['CONS_DO'],$rows['RATE_DO'],$rows['RPM'],$rows['DURATION'],$rows['DISTANCE'],$rows['SPEED'],$rows['CONS_FO_CLEAN'],$rows['CONS_FO_HEATING'],$rows['CONS_FO_G_FREEING'],$rows['CONS_FO_INERT'],$rows['CONS_DO_CLEAN'],$rows['CONS_DO_HEATING'],$rows['CONS_DO_G_FREEING'],$rows['CONS_DO_INERT'],$rows['CONDITION']);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}

$pdf->Ln(5);

$pdf->SetFont('Arial','',7);
$pdf->SetFillColor(244,244,244);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L','L');
$arr2=array(17,9,10,10,12,13,12,12,13,12,10,13,13,11,11,13,11,11,13,11,11,13,14);
$arr3=array("Totals","","","","",$cons_fo,"","",$cons_do,"","",$duration,"",$cons_fo_clng,$cons_fo_htg,$cons_fo_g_frg,$cons_fo_itg,$cons_do_clng,$cons_do_htg,$cons_do_g_frg,$cons_do_itg,"","");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$filename = "Bunker Voyage Report(".$obj->getVesselIMOData($vesselid,"VESSEL_NAME").")".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
	

}



function cargo_open_position_pdf_old()
{
	$obj = new data();
	$obj->funConnect();
	
	//$txtDate = $_REQUEST['txtDate'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,128,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(260,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->SetX(10);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			
			
			$this->Ln(1);
			
			$arr1 = $arr2 = $arr3 = array();	
			$this->SetFont('Arial','B',7);
			$this->SetFillColor(0,0,0);
			$this->SetTextColor(255,255,255);
			$this->SetDrawColor(0,0,0);
			$arr1=array('L','C','L','L','L','L','C','C','L');
			$arr2=array(20,20,40,30,30,40,25,20,55);
			$arr3=array("Contract ID","Material Type","Material Desc","Load Port","Discharge Port","Date Range","Material Qty","Tolerance (+/-)","Remarks");
			$this->SetAligns($arr1);
			$this->SetWidths($arr2);
			$this->Row2($arr3);
			
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('L');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cargo Open Position Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cargo Open Position Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');


$sql = "select CONTRACTID,SHIPPING_STAGE from open_cargo_master where CONTRACT_TYPE in ('ZBP1') AND MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' AND STATUS=1 AND CARGO_STATUS=0 and MAP_STATUS=1 and SHIIPING_REQ='Y' GROUP BY CONTRACTID,SHIPPING_STAGE ORDER BY CONTRACTID asc";
$res = mysql_query($sql);
$i = 0;
while($rows = mysql_fetch_assoc($res))
{
	if($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_OVER_TOL") != "0" && $obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_UNDER_TOL") != "0")
	{
		$tolerance = "+/-".$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_OVER_TOL");
	}
	else if($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_OVER_TOL") == "0" && $obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_UNDER_TOL") != "0")
	{
		$tolerance = "-".$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_UNDER_TOL");
	}
	else if($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_OVER_TOL") != "0" && $obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_UNDER_TOL") == "0")
	{
		$tolerance = "+".$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"PURCHASE_OVER_TOL");
	}
	else
	{
		$tolerance = "";
	}
	
	$arr4[$i]=array($rows['CONTRACTID'], $obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"MATERIAL_TYPE"),$obj->getMaterialCodeDesBasedOnCode($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"MATERIAL_CODE")),$obj->getPortNameBasedOnCode($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"LOADPORT")),$obj->getPortNameBasedOnCode($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"DISPORT")),date("d-M-Y",strtotime($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"LAYCAN_START"))).' To '.date("d-M-Y",strtotime($obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"LAYCAN_FINISH"))),$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"MATERIAL_QUANTITY").' ('.$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"UOM").')',$tolerance,$obj->getOpenCargoMasterDataBasedOnContractID($rows['CONTRACTID'],$rows['SHIPPING_STAGE'],"REMARKS"));
	$i=$i+1;
}
$arr4 = $obj->msort_ascending($arr4, array('1','0'));

for($i=0;$i<count($arr4);$i++)
{
	$arr1 = $arr2 = $arr3 = $arr5 = array();	
	
	$pdf->SetFont('Arial','',7);
	
	$arr1=array('L','C','L','L','L','L','C','C','L');
	$arr2=array(20,20,40,30,30,40,25,20,55);
	//$material_type = $arr4[$i][1];
	if($material_type != $arr4[$i][1] && $i != 0)
	{
		$pdf->SetTextColor(0,0,220);
		$pdf->SetFillColor(255,255,255);
		$pdf->Cell(280,3,"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",1,1,'C',1);	
	}
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(255,255,255);
	}
	else
	{
		$pdf->SetFillColor(244,244,244);
	}
	$pdf->SetTextColor(0,0,0);
	$arr3=array($arr4[$i][0], $arr4[$i][1],$arr4[$i][2],$arr4[$i][3],$arr4[$i][4],$arr4[$i][5],$arr4[$i][6],$arr4[$i][7],$arr4[$i][8]);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);	
	$material_type = $arr4[$i][1];
	
}

$filename = "Cargo Open Position Report ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}

function daily_log_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$txtDate = $_REQUEST['txtDate'];
	$_SESSION['Date'] = $txtDate;
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Daily Morning Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Daily Morning Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->Ln(5);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L','L','L');
$arr2=array(15,20,20,15,15,27,30,30,20);
$arr3=array("Vessel","Material Desc.","Fixture Type","Load Port(s)","Discharge Port(s)","Load / Disch (In Last 24 Hrs)","Total Load / Disch","Balance To Load / Disch","Port Status");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$sql = "select * from mapping_master where MODULEID='".$_SESSION['moduleid']."'  AND MCOMPANYID='".$_SESSION['company']."' and STATUS=2 order by MAPPINGID";
$res = mysql_query($sql);
$k = 0;
while($rows = mysql_fetch_assoc($res))
{
	$cost_sheet_id = $obj->getLatestCostSheetID($rows['MAPPINGID']);
	$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($rows['MAPPINGID'],$cost_sheet_id);
	$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($rows['MAPPINGID'],$cost_sheet_id);
	
	$lp_name = ''; $dp_name = '';
	$obj->viewFreightEstimationRecords($rows['MAPPINGID'],$cost_sheet_id);
	for($i=0;$i<count($arr);$i++)
	{
		$sql3 = "select COUNTRY_NAME from PORT_MASTER where PortId='".$port_arr[$i]."'";
		$res3 = mysql_query($sql3);
		$rows3 = mysql_fetch_assoc($res3);
		
		if(substr($arr[$i],0,2) == "LP"){$lp_name .= substr($arr[$i],5).'('.$obj->getCountryNameOnId($rows3['COUNTRY_NAME']).'),'."\n";}
		else{$dp_name .= substr($arr[$i],5).','."\n";}
	}
	
	$lp_name = substr($lp_name,0,-2);
	$dp_name = substr($dp_name,0,-2);
	
	$sql1 = "select * from daily_log where MAPPINGID='".$rows['MAPPINGID']."' and TRANS_DATE='".date("Y-m-d",strtotime($txtDate))."'";
	$res1 = mysql_query($sql1);
	$rows1 = mysql_fetch_assoc($res1);
	
	$arr1 = $arr2 = $arr3 = array();	
	$k=$k+1;
	if($k % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(15,20,20,15,15,27,30,30,20);
	
	$arr3=array($obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),$obj->getCargoContarctForMapping($obj->getMappingData($rows['MAPPINGID'],"CARGO_IDS"),$obj->getMappingData($rows['MAPPINGID'],"CARGO_POSITION"),$obj->getMappingData($rows['MAPPINGID'],"SHIPPING_STAGE")),$obj->getFreightFixtureBasedOnID($obj->getFun2()),$lp_name,$dp_name,$rows1['DAILY_CARGO_QTY'],$rows1['TTL_CARGO_QTY'],$rows1['BAL_QTY'],$rows1['PORT_STATUS']);
	
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
}

$filename = "Daily Morning Report ".date("d-M-Y",strtotime($txtDate)).".pdf";

$pdf->Output($filename,'D');
}


function vendor_wise_request_pdf()
{
	$obj = new data();
	$obj->funConnect();
	
	$vwpr_id = $_REQUEST['vwpr_id'];
	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}

$pdf = new PDF();
$pdf->AddPage('P','Legal');
$pdf->SetMargins(2,0,2);
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Request Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Request Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

/*$qsql = "update vwpr_master set STATUS=1 where VWPR_ID='".$vwpr_id."'";
mysql_query($qsql);*/

$sql = "select * from vwpr_master where VWPR_ID='".$vwpr_id."'";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);

$pdf->Ln(2);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(20,5,55,20,5,20,20,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Vendor",":",$obj->getVendorListNewBasedOnID($rows['VENDORID']),"Vendor Code",":",$rows['VENDORID']));

$pdf->Ln(5);

$pdf->Row1(array("Request No.",":",$rows['REQUEST_NO'],"Request Date",":",date("d-M-Y",strtotime($rows['REQ_DATE']))));

$pdf->Ln(5);

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',7);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L','L','L','L','L','L','L','L','L');
$arr2=array(15,23,12,20,18,20,20,20,25,20,17);
$arr3=array("Nom ID","Cost Type\n(Cost Desc.)","Material Type","Vessel Name","CP Date","Load Port","Disch. Port","TTL Outstanding","Payment","Balance Outstanding","Requested");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$req_id = explode(",",$rows['REQ_ID']);
$vessel = explode(",",$rows['VESSEL']);
$remark = explode(",",$rows['REMARK']);

$i = 0; $string = '';
for($j=0;$j<sizeof($req_id);$j++)
{
	$sql1 = "select * from request_master where REQ_ID='".$req_id[$j]."'";
	$res1 = mysql_query($sql1);
	$rows1 = mysql_fetch_assoc($res1);
	
	$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
	$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
	
	$arr_1  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($rows1['MAPPINGID'],$l_cost_sheet_id);
	$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($rows1['MAPPINGID'],$l_cost_sheet_id);
	
	$lp_name = ''; $dp_name = '';
	for($k=0;$k<count($arr_1);$k++)
	{
		if(substr($arr_1[$k],0,2) == "LP"){$lp_name .= substr($arr_1[$k],5).",\n";}
		else{$dp_name .= substr($arr_1[$k],5).",\n";}
	}
	
	$lp_name = substr($lp_name,0,-2);
	$dp_name = substr($dp_name,0,-2);
	
	$cost_1 = 0; $deduction = 0;
	
	if($rows1['NAME_ID'] == 7)
	{
		$name = 'Owner Related Costs';
		$ttl_outs = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES");
		$port_name = '';
		
		$sql2 = "select * from request_master where VENDOR='".$rows1['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows1['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and REQUESTED='1'";
		$res2 = mysql_query($sql2);
		$pay_name = "";
		while($rows2 = mysql_fetch_assoc($res2))
		{ $cost_1 = $cost_1+$rows2['REQ_TO_PAY']; $pay_name .=  $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n"; }	
		$cost_1 = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost_1;
		$cost_desc = "Total Shipowner Expenses";
	}
	else
	{
		if($rows1['NAME_ID'] == 9)
		{
			$table = 'fca_vci_totals'; $field = 'FREIGHT_PAYMENT'; $cost = 'FREIGHT_PAYMENT'; $name = 'Owner Related Costs'; $cost_desc = 'Owner Related Costs';
			
			$sql3 = "select ".$field." from fca_vci_totals where FCAID='".$obj->getFun1()."'";
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 8)
		{
			if($rows1['GRADEID'] == 0)
			{
				$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_BROKERAGE_COST"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Brokerage';
			}
			else
			{
				$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_NETT"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Nett';
			}
		}
		else if($rows1['NAME_ID'] == 1)
		{
			$table = 'fca_tci_bunker_nett'; $field = 'BUNKERGRADEID'; $cost = 'COST'; $name = 'Bunkers Nett Supply'; $cost_desc = $obj->getBunkerGradeBasedOnID($rows1['GRADEID']).' Nett';
			
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 2)
		{
			if($obj->getFun2() == 1)
			{
				$table = 'fca_tci_other_shipping_cost'; 
			}
			else
			{
				$table = 'fca_vci_other_shipping_cost'; 
			}
				$field = 'OTHER_SCOSTID'; $cost = 'ABSOLUTE'; $name = 'All Other Shipping Costs'; $cost_desc = $obj->getOtherShippingCostNameBasedOnID($rows1['GRADEID']);
		
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 3)
		{
			if($obj->getFun2() == 1)
			{
				$table = 'fca_tci_portcosts'; 
			}
			else
			{
				$table = 'fca_vci_portcosts';
			}
				
				$field = 'LOADPORTID'; $cost = 'COST'; $name = 'Port Costs'; $cost_desc = $rows1['PORT'].' Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
		
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 4)
		{
			$table = 'fca_tci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Shipper'; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
		
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 5)
		{
			$table = 'fca_tci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Receiver'; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
		
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else if($rows1['NAME_ID'] == 6)
		{
			if($obj->getFun2() == 1)
			{
				$table = 'fca_tci_other_misc_cost';
			}
			else
			{
				$table = 'fca_vci_other_misc_cost';
			}  
			$field = 'OTHER_MCOSTID'; $cost = 'AMOUNT'; $name = 'All Other Miscellaneous Costs'; $cost_desc = $obj->getOtherMiscCostNameBasedOnID($rows1['GRADEID']);
		
			$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
			$res3 = mysql_query($sql3);
			$rows3 = mysql_fetch_assoc($res3);
		}
		else
		{
			$str = substr($rows1['NAME_ID'],0,3);
			unset($rows4);
			
			if($str == 'R_5')
			{
				$qqsql1 = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows1['GRADEID']."' and ENTITY='Receiver' and VENDOR='".$rows1['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
				$qqres1 = mysql_query($qqsql1);
				$qqrec1 = mysql_num_rows($qqres1);
				if($qqrec1 == 0)
				{
					$table = 'fca_vci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows1['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
					
					$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
					$res3 = mysql_query($sql3);
					$rows3 = mysql_fetch_assoc($res3);
				}
				else
				{
					while($qqrows1 = mysql_fetch_assoc($qqres1))
					{
						if($qqrows1['TTL_DEMURRAGE'] == 0 && $qqrows1['TTL_DESPATCH'] == 0){$value1 = 0;}
						if($qqrows1['TTL_DEMURRAGE'] == 0){$value1 = $qqrows1['TTL_DESPATCH']; }
						if($qqrows1['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows1['TTL_DEMURRAGE']; }
						
						$cost = 'COST'; $name = $rows1['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
						$rows3[$cost] = $value1;
					}
				}
			}
			else if($str == 'S_4')
			{
				$qqsql = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows1['GRADEID']."' and ENTITY='Shipper' and VENDOR='".$rows1['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
				
				$qqres = mysql_query($qqsql);
				$qqrec = mysql_num_rows($qqres);
				if($qqrec == 0)
				{
					$table = 'fca_vci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows1['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
					
					$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
					$res3 = mysql_query($sql3);
					$rows3 = mysql_fetch_assoc($res3);
				}
				else
				{
					while($qqrows = mysql_fetch_assoc($qqres))
					{
						if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
						if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
						if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];}
						
						$cost = 'COST'; $name = $rows1['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows1['GRADEID']);
						$rows3[$cost] = $value;
					}
				}
			}
		}
		
		$str = substr($rows1['NAME_ID'],0,3);
		if($str == 3 || $str == 4 || $str == 5 || $str == 'R_5' || $str == 'S_4' || $str == 'O_L' || $str == 'O_D')
		{$port_name = $obj->getPortNameBasedOnID($rows1['GRADEID']);}else{$port_name = '';}
		
		/*$sql3 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows1['GRADEID'];
		$res3 = mysql_query($sql3);
		$rows3 = mysql_fetch_assoc($res3);*/
		
		if($rows1['NAME_ID'] == 8)
		{
			$ttl_outs = $cost;
		}
		else
		{
			$ttl_outs = $rows3[$cost];
		}
		
		$sql2 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='".$rows1['NAME_ID']."' and GRADEID='".$rows1['GRADEID']."' and MAPPINGID=".$rows1['MAPPINGID'];
		$res2 = mysql_query($sql2);
		$pay_name = "";
		while($rows2 = mysql_fetch_assoc($res2))
		{ 
			$cost_1 = $cost_1+$rows2['REQ_TO_PAY']; $pay_name .= $rows2['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows2['REQ_TO_PAY'])."\n";
			
			/*if($rows1['NAME_ID'] == 9 || $rows1['NAME_ID'] == 3)
			{*/
				$sql6 = "select * from request_deduction_master where REQ_ID='".$rows2['REQ_ID']."'";
				$res6 = mysql_query($sql6);
				$deduction_1 = 0;
				while($rows6 = mysql_fetch_assoc($res6))
				{$deduction = $deduction+$rows6['COST']; $deduction_1 = $deduction_1+$rows6['COST'];}
				
				$pay_name .= 'Deduction : '.$obj->getNumberFormat($deduction_1)."\n";
			//}
		}	
		
		if($rows1['NAME_ID'] == 8)
		{
			$cost_1 = $cost-$cost_1-$deduction;
		}
		/*else if($rows1['NAME_ID'] == 9 || $rows1['NAME_ID'] == 3)
		{
			$cost_1 = $rows3[$cost]-$cost_1-$deduction;
		}*/
		else
		{
			$cost_1 = $rows3[$cost]-$cost_1-$deduction;
			//$cost_1 = $rows3[$cost]-$cost_1;
		}
	}
	
	$mat_type = substr($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),4,4);
	
	$arr1 = $arr2 = $arr3 = array();	
	$i=$i+1;
	if($i % 2 == 0)
	{
		$pdf->SetFillColor(244,244,244);
	}
	else
	{
		$pdf->SetFillColor(255,255,255);
	}
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','L','L','L','L','L','L','L','L','L');
	$arr2=array(15,23,12,20,18,20,20,20,25,20,17);
	$arr3=array($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),$name."\n( ".$cost_desc." )",$mat_type,$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))),$lp_name,$dp_name,$obj->getNumberFormat($ttl_outs),$pay_name,$obj->getNumberFormat($cost_1),$obj->getNumberFormat($rows1['REQ_TO_PAY']));
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$string .= $vessel[$j].' '.$remark[$j].' ';
}

$pdf->Ln(5);

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,50,35,5,20,20,5,20);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Total(USD)",":",$obj->getNumberFormat($rows['TOTAL'])));

$pdf->Ln(5);

$pdf->Row1(array("Local Currency",":",$obj->getCountryData($rows['CURRENCYID'],'CURRENCY_NAME'),"Ex. Rate(USD to Local)",":",$obj->getNumberFormat($rows['RATE']),"G Total Local",":",$obj->getNumberFormat($rows['GRANDTOTAL'])));

$pdf->Ln(5);

$pdf->Row1(array("Vendor Banking Details",":",$rows['REMARKS']));

$pdf->Ln(5);

$pdf->Row1(array("Prepared By",":",$rows['PREPARED_BY'],"Authorised By",":",$rows['AUTHORISED_BY']));

$pdf->Ln(5);

$pdf->SetFont('Arial','',10);
$pdf->SetTextColor(0,0,0);
$arr1=array('L');
$arr2=array(30);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("ACCOUNTS :",));

if($rows['GRANDTOTAL'] >= 0)
{$rem = "remit";}else{$rem = "recover";}

$pdf->SetFont('Arial','',9);
$pdf->SetTextColor(0,0,0);
$arr1=array('L');
$arr2=array(200);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Kindly arrange to (".$rem." ) ".$obj->getCountryData($rows['CURRENCYID'],'CURRENCY_NAME')." ".$obj->getNumberFormat($rows['GRANDTOTAL'])." towards : ".$string));

$filename = "Vendor Wise Payment Request ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');

}


function vendor_wise_payment_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$Date_From = $_REQUEST['txtFrom_Date'];
	$Date_To = $_REQUEST['txtTo_Date'];
	$Vendor_From = $_REQUEST['selFrom_Vendor'];
	$Vendor_To = $_REQUEST['selTo_Vendor'];
	$chk = $_REQUEST['chk'];
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L');
$arr2=array(35,2,60,32,2,69);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Date From (financial year)",":",$Date_From,"Date To (financial year)",":",$Date_To));
$pdf->Row1(array("Vendor Code from",":",$obj->getVendorListNewBasedOnID($Vendor_From).' ('.$Vendor_From.')',"Vendor Code to",":",$obj->getVendorListNewBasedOnID($Vendor_To).' ('.$Vendor_To.')'));

$pdf->Ln(5);

$sql = "select VENDOR from request_master where (CP_DATE BETWEEN '".date("Y-m-d",strtotime($Date_From))."' and '".date("Y-m-d",strtotime($Date_To))."') and (VENDOR BETWEEN '".$Vendor_From."' and '".$Vendor_To."') and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' group by VENDOR";
$res = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{
	$pdf->SetFont('Arial','',8);
	$pdf->SetTextColor(30,133,190);
	$arr1=array('L');
	$arr2=array(80);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array($obj->getVendorListNewBasedOnID($rows['VENDOR']).' : '.$rows['VENDOR']));
	
	$pdf->Ln(1);
	
	$arr1 = $arr2 = $arr3 = array();	
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(128,128,128);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetDrawColor(238,238,238);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(20,20,20,20,20,25,20,25,20);
	$arr3=array("Nom ID","Cost Type","Cost Desc.","Vessel Name","CP Date","Port","TTL Outstanding","Payment","Balance Outstanding");
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3);
	
	$sql1 = "select MAPPINGID from request_master where (CP_DATE BETWEEN '".date("Y-m-d",strtotime($Date_From))."' and '".date("Y-m-d",strtotime($Date_To))."') and VENDOR='".$rows['VENDOR']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' group by MAPPINGID";
	$res1 = mysql_query($sql1);
	$i = 0;
	while($rows1 = mysql_fetch_assoc($res1))
	{
		$sql2 = "select NAME_ID from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' group by NAME_ID";
		$res2 = mysql_query($sql2);
		while($rows2 = mysql_fetch_assoc($res2))
		{
			if($rows2['NAME_ID'] == 7)
			{
				if($chk == 0)
				{
					$sql4 = "select CP_DATE from request_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and MAPPINGID=".$rows1['MAPPINGID'];
					$res4 = mysql_query($sql4);
					$rows4 = mysql_fetch_assoc($res4);
					
					$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
					$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
					
					$cost = 0;
					
					$sql3 = "select * from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and REQUESTED='1'";
					$res3 = mysql_query($sql3);
					$pay_name = "";
					while($rows3 = mysql_fetch_assoc($res3))
					{ $cost = $cost+$rows3['REQ_TO_PAY']; $pay_name .=  $rows3['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows3['REQ_TO_PAY'])."\n"; }
					$cost = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost;
					
					$arr1 = $arr2 = $arr3 = array();	
					$i=$i+1;
					if($i % 2 == 0)
					{
						$pdf->SetFillColor(244,244,244);
					}
					else
					{
						$pdf->SetFillColor(255,255,255);
					}
					
					$pdf->SetFont('Arial','',7);
					$pdf->SetTextColor(0,0,0);
					$arr1=array('L','L','L','L','L','L','L','L','L');
					$arr2=array(20,20,20,20,20,25,20,25,20);
					$arr3=array($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),$pay_name,$obj->getNumberFormat($cost));
					$pdf->SetAligns($arr1);
					$pdf->SetWidths($arr2);
					$pdf->Row2($arr3);
				}
				else
				{
					$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
					$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
					$cost = 0;
					$sql3 = "select * from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER'";
					$res3 = mysql_query($sql3);
					while($rows3 = mysql_fetch_assoc($res3))
					{ $cost = $cost+$rows3['REQ_TO_PAY'];}
					$cost = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost;
					
					if($cost > 0)
					{
						$sql4 = "select CP_DATE from request_master where MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and MAPPINGID=".$rows1['MAPPINGID'];
						$res4 = mysql_query($sql4);
						$rows4 = mysql_fetch_assoc($res4);
						
						$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
						$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
						$cost = 0;
						
						$sql3 = "select * from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and REQUESTED='1'";
						$res3 = mysql_query($sql3);
						$pay_name = "";
						while($rows3 = mysql_fetch_assoc($res3))
						{ $cost = $cost+$rows3['REQ_TO_PAY']; $pay_name .=  $rows3['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows3['REQ_TO_PAY'])."\n"; }	
						$cost = $obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")-$cost;
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),'Owner Related Costs','Total Shipowner Expenses',$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))),'',$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),$pay_name,$obj->getNumberFormat($cost));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
				}
			}
			else
			{
				$sql3 = "select GRADEID from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and STATUS='1' group by GRADEID";
				$res3 = mysql_query($sql3);
				while($rows3 = mysql_fetch_assoc($res3))
				{
					if($chk == 0)
					{
						$cost_1 = 0; $deduction = 0;
						$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
						$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
						
						$sql4 = "select CP_DATE,PORT,NAME from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and GRADEID=".$rows3['GRADEID'];
						$res4 = mysql_query($sql4);
						$rows4 = mysql_fetch_assoc($res4);
						
						if($rows2['NAME_ID'] == 9)
						{
							$table = 'fca_vci_totals'; $field = 'FREIGHT_PAYMENT'; $cost = 'FREIGHT_PAYMENT'; $name = 'Owner Related Costs'; $cost_desc = 'Owner Related Costs';
							
							$sql6 = "select ".$field." from fca_vci_totals where FCAID='".$obj->getFun1()."'";
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 8)
						{
							if($rows3['GRADEID'] == 0)
							{
								$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_BROKERAGE_COST"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Brokerage';
							}
							else
							{
								$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_NETT"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Nett';
							}
						}
						else if($rows2['NAME_ID'] == 1)
						{
							$table = 'fca_tci_bunker_nett'; $field = 'BUNKERGRADEID'; $cost = 'COST'; $name = 'Bunkers Nett Supply'; $cost_desc = $obj->getBunkerGradeBasedOnID($rows3['GRADEID']).' Nett';
							
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 2)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_other_shipping_cost'; 
							}
							else
							{
								$table = 'fca_vci_other_shipping_cost';
							}
								$field = 'OTHER_SCOSTID'; $cost = 'ABSOLUTE'; $name = 'All Other Shipping Costs'; $cost_desc = $obj->getOtherShippingCostNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 3)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_portcosts';
							}
							else
							{
								$table = 'fca_vci_portcosts';
							}
								
								$field = 'LOADPORTID'; $cost = 'COST'; $name = 'Port Costs'; $cost_desc = $rows4['PORT'].' Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 4)
						{
							$table = 'fca_tci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Shipper'; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 5)
						{
							$table = 'fca_tci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Receiver'; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 6)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_other_misc_cost';
							}
							else
							{
								$table = 'fca_vci_other_misc_cost';
							} 
							$field = 'OTHER_MCOSTID'; $cost = 'AMOUNT'; $name = 'All Other Miscellaneous Costs'; $cost_desc = $obj->getOtherMiscCostNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else
						{
							$str = substr($rows2['NAME_ID'],0,3);
							unset($rows6);
							
							if($str == 'R_5')
							{
								$qqsql1 = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows3['GRADEID']."' and ENTITY='Receiver' and VENDOR='".$rows['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
								$qqres1 = mysql_query($qqsql1);
								$qqrec1 = mysql_num_rows($qqres1);
								if($qqrec1 == 0)
								{
									$table = 'fca_vci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
									
									$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
									$res6 = mysql_query($sql6);
									$rows6 = mysql_fetch_assoc($res6);
								}
								else
								{
									while($qqrows1 = mysql_fetch_assoc($qqres1))
									{
										if($qqrows1['TTL_DEMURRAGE'] == 0 && $qqrows1['TTL_DESPATCH'] == 0){$value1 = 0;}
										if($qqrows1['TTL_DEMURRAGE'] == 0){$value1 = $qqrows1['TTL_DESPATCH']; }
										if($qqrows1['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows1['TTL_DEMURRAGE']; }
										
										$cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
										$rows6[$cost] = $value1;
									}
								}
							}
							else if($str == 'S_4')
							{
								$qqsql = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows3['GRADEID']."' and ENTITY='Shipper' and VENDOR='".$rows['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
								
								$qqres = mysql_query($qqsql);
								$qqrec = mysql_num_rows($qqres);
								if($qqrec == 0)
								{
									$table = 'fca_vci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
									
									$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
									$res6 = mysql_query($sql6);
									$rows6 = mysql_fetch_assoc($res6);
								}
								else
								{
									while($qqrows = mysql_fetch_assoc($qqres))
									{
										if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
										if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
										if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];}
										
										$cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
										$rows6[$cost] = $value;
									}
								}
							}	
						}
						
						$str = substr($rows2['NAME_ID'],0,3);
						if($str == 3 || $str == 4 || $str == 5 || $str == 'R_5' || $str == 'S_4' || $str == 'O_L' || $str == 'O_D')
						{$port_name = $obj->getPortNameBasedOnID($rows3['GRADEID']);}else{$port_name = '';}
						
						$sql5 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='".$rows2['NAME_ID']."' and GRADEID='".$rows3['GRADEID']."' and REQUESTED='1' and MAPPINGID=".$rows1['MAPPINGID'];
						$res5 = mysql_query($sql5);
						$pay_name = ""; $deduction = 0;
						while($rows5 = mysql_fetch_assoc($res5))
						{ 
							$cost_1 = $cost_1+$rows5['REQ_TO_PAY']; $pay_name .= $rows5['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows5['REQ_TO_PAY'])."\n";
							/*if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
							{*/
								$sql7 = "select * from request_deduction_master where REQ_ID='".$rows5['REQ_ID']."'";
								$res7 = mysql_query($sql7);
								$deduction_1 = 0;
								while($rows7 = mysql_fetch_assoc($res7))
								{ $deduction = $deduction+$rows7['COST']; $deduction_1 = $deduction_1+$rows7['COST'];}
								
								$pay_name .= 'Deduction : '.$obj->getNumberFormat($deduction_1)."\n";
							//}
						}	
						if($rows2['NAME_ID'] == 8)
						{
							$cost_1 = $cost-$cost_1-$deduction;
							$cost_ttl = $cost;
						}
						/*else if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
						{
							$cost_1 = $rows6[$cost]-$cost_1-$deduction;
							$cost_ttl = $rows6[$cost];
						}*/
						else
						{
							$cost_1 = $rows6[$cost]-$cost_1-$deduction;
							$cost_ttl = $rows6[$cost];
							//$cost_1 = $rows6[$cost]-$cost_1;
							//$cost_ttl = $rows6[$cost];
						}
						
						$arr1 = $arr2 = $arr3 = array();	
						$i=$i+1;
						if($i % 2 == 0)
						{
							$pdf->SetFillColor(244,244,244);
						}
						else
						{
							$pdf->SetFillColor(255,255,255);
						}
						
						$pdf->SetFont('Arial','',7);
						$pdf->SetTextColor(0,0,0);
						$arr1=array('L','L','L','L','L','L','L','L','L');
						$arr2=array(20,20,20,20,20,25,20,25,20);
						$arr3=array($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),$name,$cost_desc,$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))),$port_name,$obj->getNumberFormat($cost_ttl).$rec,$pay_name,$obj->getNumberFormat($cost_1));
						$pdf->SetAligns($arr1);
						$pdf->SetWidths($arr2);
						$pdf->Row2($arr3);
					}
					else
					{
						$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
						$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
						$cost_1 = 0; $deduction = 0;
						
						$sql4 = "select CP_DATE,PORT,NAME from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and GRADEID=".$rows3['GRADEID'];
						$res4 = mysql_query($sql4);
						$rows4 = mysql_fetch_assoc($res4);
						
						if($rows2['NAME_ID'] == 9)
						{
							$table = 'fca_vci_totals'; $field = 'FREIGHT_PAYMENT'; $cost = 'FREIGHT_PAYMENT'; $name = 'Owner Related Costs'; $cost_desc = 'Owner Related Costs';
							
							$sql6 = "select ".$field." from fca_vci_totals where FCAID='".$obj->getFun1()."'";
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 8)
						{
							if($rows3['GRADEID'] == 0)
							{
								$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_BROKERAGE_COST"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Brokerage';
							}
							else
							{
								$cost = $obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_NETT"); $name = 'Demurrage Dispatch Ship Owner'; $cost_desc = 'Nett';
							}
						}
						else if($rows2['NAME_ID'] == 1)
						{
							$table = 'fca_tci_bunker_nett'; $field = 'BUNKERGRADEID'; $cost = 'COST'; $name = 'Bunkers Nett Supply'; $cost_desc = $obj->getBunkerGradeBasedOnID($rows3['GRADEID']).' Nett';
							
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 2)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_other_shipping_cost';
							}
							else
							{
								$table = 'fca_vci_other_shipping_cost';
							}
								$field = 'OTHER_SCOSTID'; $cost = 'ABSOLUTE'; $name = 'All Other Shipping Costs'; $cost_desc = $obj->getOtherShippingCostNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 3)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_portcosts';
							}
							else
							{
								$table = 'fca_vci_portcosts';
							}
								
								$field = 'LOADPORTID'; $cost = 'COST'; $name = 'Port Costs'; $cost_desc = $rows4['PORT'].' Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 4)
						{
							$table = 'fca_tci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Shipper'; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 5)
						{
							$table = 'fca_tci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = 'Demurrage Dispatch Receiver'; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else if($rows2['NAME_ID'] == 6)
						{
							if($obj->getFun2() == 1)
							{
								$table = 'fca_tci_other_misc_cost';
							}
							else
							{
								$table = 'fca_vci_other_misc_cost';
							}  
							$field = 'OTHER_MCOSTID'; $cost = 'AMOUNT'; $name = 'All Other Miscellaneous Costs'; $cost_desc = $obj->getOtherMiscCostNameBasedOnID($rows3['GRADEID']);
						
							$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
							$res6 = mysql_query($sql6);
							$rows6 = mysql_fetch_assoc($res6);
						}
						else
						{
							$str = substr($rows2['NAME_ID'],0,3);
							unset($rows6);
							
							if($str == 'R_5')
							{
								$qqsql1 = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows3['GRADEID']."' and ENTITY='Receiver' and VENDOR='".$rows['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
								$qqres1 = mysql_query($qqsql1);
								$qqrec1 = mysql_num_rows($qqres1);
								if($qqrec1 == 0)
								{
									$table = 'fca_vci_dd_receiver'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
									
									$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
									$res6 = mysql_query($sql6);
									$rows6 = mysql_fetch_assoc($res6);
								}
								else
								{
									while($qqrows1 = mysql_fetch_assoc($qqres1))
									{
										if($qqrows1['TTL_DEMURRAGE'] == 0 && $qqrows1['TTL_DESPATCH'] == 0){$value1 = 0;}
										if($qqrows1['TTL_DEMURRAGE'] == 0){$value1 = $qqrows1['TTL_DESPATCH']; }
										if($qqrows1['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows1['TTL_DEMURRAGE']; }
										
										$cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Discharge Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
										$rows6[$cost] = $value1;
									}
								}
							}
							else if($str == 'S_4')
							{
								$qqsql = "select * from laytime_master where MAPPINGID='".$rows1['MAPPINGID']."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows3['GRADEID']."' and ENTITY='Shipper' and VENDOR='".$rows['VENDOR']."' and APPLICABLE_STATUS=1 and SUBMITID=2";
								
								$qqres = mysql_query($qqsql);
								$qqrec = mysql_num_rows($qqres);
								if($qqrec == 0)
								{
									$table = 'fca_vci_dd_shipper'; $field = 'LOADPORTID'; $cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
									
									$sql6 = "select * from ".$table." where FCAID='".$obj->getFun1()."' and ".$field."=".$rows3['GRADEID'];
									$res6 = mysql_query($sql6);
									$rows6 = mysql_fetch_assoc($res6);
								}
								else
								{
									while($qqrows = mysql_fetch_assoc($qqres))
									{
										if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
										if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
										if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];}
										
										$cost = 'COST'; $name = $rows4['NAME']; $cost_desc = 'Load Port '.$obj->getPortNameBasedOnID($rows3['GRADEID']);
										$rows6[$cost] = $value;
									}
								}
							}
						}
						
						$sql5 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='".$rows2['NAME_ID']."' and GRADEID='".$rows3['GRADEID']."' and REQUESTED='1' and MAPPINGID=".$rows1['MAPPINGID'];
						$res5 = mysql_query($sql5); $deduction = 0;
						while($rows5 = mysql_fetch_assoc($res5))
						{ 
							$cost_1 = $cost_1+$rows5['REQ_TO_PAY'];
							
							/*if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
							{*/
								$sql7 = "select * from request_deduction_master where REQ_ID='".$rows5['REQ_ID']."'";
								$res7 = mysql_query($sql7);
								while($rows7 = mysql_fetch_assoc($res7))
								{ $deduction = $deduction+$rows7['COST'];}
							//}
						}
						
						if($rows2['NAME_ID'] == 8)
						{
							$cost_1 = $cost-$cost_1-$deduction;
						}
						/*if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
						{
							$cost_1 = $rows6[$cost]-$cost_1-$deduction;
						}*/
						else
						{
							$cost_1 = $rows6[$cost]-$cost_1-$deduction;
							//$cost_1 = $rows6[$cost]-$cost_1;
						}
						
						if($cost_1 > 0 )
						{
							$sql4 = "select CP_DATE from request_master where VENDOR='".$rows['VENDOR']."' and MAPPINGID='".$rows1['MAPPINGID']."' and NAME_ID='".$rows2['NAME_ID']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and GRADEID=".$rows3['GRADEID'];
							$res4 = mysql_query($sql4);
							$rows4 = mysql_fetch_assoc($res4);
							
							$cost_1 = 0; $deduction = 0;
							$l_cost_sheet_id = $obj->getLatestCostSheetID($rows1['MAPPINGID']);
							$obj->viewFreightEstimationRecords($rows1['MAPPINGID'],$l_cost_sheet_id);
							
							$str = substr($rows2['NAME_ID'],0,3);
							if($str == 3 || $str == 4 || $str == 5 || $str == 'R_5' || $str == 'S_4' || $str == 'O_L' || $str == 'O_D')
							{$port_name = $obj->getPortNameBasedOnID($rows3['GRADEID']);}else{$port_name = '';}
							
							$sql5 = "select * from request_master where  MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME_ID='".$rows2['NAME_ID']."' and GRADEID='".$rows3['GRADEID']."' and REQUESTED='1' and MAPPINGID=".$rows1['MAPPINGID'];
							$res5 = mysql_query($sql5);
							$pay_name = ""; $deduction = 0;
							while($rows5 = mysql_fetch_assoc($res5))
							{ 
								$cost_1 = $cost_1+$rows5['REQ_TO_PAY']; $pay_name .= $rows5['PAYMENT_NO'].' : '.$obj->getNumberFormat($rows5['REQ_TO_PAY'])."\n";
								
								/*if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
								{*/
									$sql7 = "select * from request_deduction_master where REQ_ID='".$rows5['REQ_ID']."'";
									$res7 = mysql_query($sql7);
									$deduction_1 = 0;
									while($rows7 = mysql_fetch_assoc($res7))
									{ $deduction = $deduction+$rows7['COST']; $deduction_1 = $deduction_1+$rows7['COST'];}
									
									$pay_name .= 'Deduction : '.$obj->getNumberFormat($deduction_1)."\n";
								//}
							}	
							
							if($rows2['NAME_ID'] == 8)
							{
								$cost_1 = $cost-$cost_1-$deduction;
								$cost_ttl = $cost;
							}
							/*if($rows2['NAME_ID'] == 9 || $rows2['NAME_ID'] == 3)
							{
								$cost_1 = $rows6[$cost]-$cost_1-$deduction;
								$cost_ttl = $rows6[$cost];
							}*/
							else
							{
								$cost_1 = $rows6[$cost]-$cost_1-$deduction;
								$cost_ttl = $rows6[$cost];
								//$cost_1 = $rows6[$cost]-$cost_1;
								//$cost_ttl = $rows6[$cost];
							}
							
							$arr1 = $arr2 = $arr3 = array();	
							$i=$i+1;
							if($i % 2 == 0)
							{
								$pdf->SetFillColor(244,244,244);
							}
							else
							{
								$pdf->SetFillColor(255,255,255);
							}
							
							$pdf->SetFont('Arial','',7);
							$pdf->SetTextColor(0,0,0);
							$arr1=array('L','L','L','L','L','L','L','L','L');
							$arr2=array(20,20,20,20,20,25,20,25,20);
							$arr3=array($obj->getMappingData($rows1['MAPPINGID'],"NOM_NAME"),$name,$cost_desc,$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME"),date("d-M-Y",strtotime($obj->getVesselOpenEntryDeta($obj->getMappingData($rows1['MAPPINGID'],"OPEN_VESSEL_ID"),"CP_DATE"))),$port_name,$obj->getNumberFormat($cost_ttl),$pay_name,$obj->getNumberFormat($cost_1));
							$pdf->SetAligns($arr1);
							$pdf->SetWidths($arr2);
							$pdf->Row2($arr3);
						}
					}
				}
			}
		}
	}
	
	$pdf->Ln(5);
}

$filename = "Vendor Wise Payment ".date("d-M-Y",time()).".pdf";

$pdf->Output($filename,'D');
}


function req_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$comid = $_REQUEST['comid'];
	$req_id = $_REQUEST['req_id'];
	$name = $_REQUEST['name'];
	$vendorid = $_REQUEST['vendorid'];
	$ttl = $_REQUEST['ttl_outs'];
	$fcaid = $obj->getLatestCostSheetID($comid);
    $obj->viewFreightCostEstimationTempleteRecordsNew($fcaid);
	
	//$arr  = $obj->getLoadPortAndDischargePortArrBasedOnMappingidAndProcessWithoutTBN($mappingid,$l_cost_sheet_id);
	//$port_arr  = $obj->getLoadPortAndDischargePortArrBasedOnIDMappingidAndProcessWithoutTBN($mappingid,$l_cost_sheet_id);
	//Create a new PDF file

	class PDF extends FPDF
	{
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
		
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
	
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Payment Report Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Payment Report Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$sql = "select * from request_master where REQ_ID='".$req_id."'";
$res = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{
if($rows['NAME_ID'] == 3)
{
	if($rows['GRADEID'] == 0){$costtype = 'Brokerage Commission';}
	else{$costtype = $obj->getOwnerRelatedCostNameBasedOnID($rows['GRADEID']);}
}
else if($rows['NAME_ID'] == 5){$costtype = "Port Costs (".$obj->getPortNameBasedOnID($rows['GRADEID']).")";}

$pdf->SetFont('daxcondensedlight','',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Account ".$name,0,1,'L');

$pdf->SetFont('daxcondensedlight','',10);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(25,5,32,29,5,31,33,5,35);
$pdf->SetAligns($arr1);$paymentno = $rows['PAYMENT_NO'];
$pdf->SetWidths($arr2);
$pdf->Row1(array("Payment Type",":",$rows['ACCOUNT_TYPE'],"Payment No/Description",":",$rows['PAYMENT_NO'],"CP Date",":",date("d-m-Y",strtotime($obj->getFun3()))));

$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($rows['DATE'])),"Nom ID",":",$obj->getCompareTableData($comid,"MESSAGE"),"Vessel",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")));


$pdf->Row1(array("Vendor",":",$obj->getVendorListNewBasedOnID($vendorid),"Remarks",":",$rows['REMARKS'],"Voyage No.",":",$obj->getFun8()));

if(date("d-M-Y",strtotime($rows['INVOICE_DATE'])) == '01-Jan-1970'){$I_Date = '';}
else{$I_Date = date("d-M-Y",strtotime($rows['INVOICE_DATE']));}
$costtype = explode(" : ",$name);
$pdf->Row1(array("Cost Type Desc.",":",$costtype[0], "Vendor Invoice Amt.",":",$obj->getNumberFormat($rows['INVOICE_AMT']),"Invoice Date",":",$I_Date));

		$pdf->Ln(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$name.": Details",0,1,'L');
		
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Total Payable",":",$obj->getNumberFormat($ttl)));
		
		$sql6 = "select * from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$rows['NAME']."' and NAME_ID='".$rows['NAME_ID']."' and GRADEID='".$rows['GRADEID']."' and VENDOR='".$vendorid."'";
		$res6 = mysql_query($sql6);
		$i = 0;
		$cost = 0; $cost_deduction = 0;
		while($rows6 = mysql_fetch_assoc($res6))
		{
			$i = $i+1; $cost_deduction_1 = 0;
			$cost = $cost+$rows6['REQ_TO_PAY'];
			
			$sql7 = "select * from request_deduction_master where REQ_ID='".$rows6['REQ_ID']."'";
			$res7 = mysql_query($sql7);
			while($rows7 = mysql_fetch_assoc($res7)){$cost_deduction = $cost_deduction+$rows7['COST']; $cost_deduction_1 = $cost_deduction_1+$rows7['COST'];}
			
			if($rows6['REQ_ID'] == $req_id){break;}
			$pdf->Row1(array("Amount Paid ".$i,":",$obj->getNumberFormat($rows6['REQ_TO_PAY'])));
		}
		
		$cost = $ttl-$cost;
		
		$cost = $cost-$cost_deduction;
		
		$pdf->Row1(array("Balance Outstanding",":",$obj->getNumberFormat($cost)));
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Add",0,1,'L');
		
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_master_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='ADD' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		$pdf->Ln(5);
		
		
		$pdf->Ln(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Less",0,1,'L');
		
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(27,119,166);
		$arr1=array('C','C','C');
		$arr2=array(20,90,80);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row(array("S.No.","Description","Amount"));
		$sql_add = "select * from request_master_slave where REQ_ID='".$rows6['REQ_ID']."' and IDENTIFY='SUB' ";
		$res_add = mysql_query($sql_add);
		$i = 0;
		while($rows_add = mysql_fetch_assoc($res_add))
		{$i++;
			$pdf->SetFont('daxcondensedlight','',10);
			$pdf->SetTextColor(0,0,0);
			$arr1=array('C','L','R');
			$arr2=array(20,90,80);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array($i,$rows_add['DESCRIPTION'],$rows_add['AMOUNT']));
		}
		
		
		$pdf->Ln(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Net Payable ",0,1,'L');
		
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['NET_AMT'])));
		
		
		
		$pdf->Ln(5);
		$pdf->SetFont('daxcondensedlight','',12);
		$pdf->SetTextColor(27,119,166);
		$pdf->Cell(190,6,"Account ".$costtype[0]." : Requested To Pay/Recover",0,1,'L');
		
		$pdf->SetFont('daxcondensedlight','',10);
		$pdf->SetTextColor(0,0,0);
		$arr1=array('L','C','R','L','C','L','L','C','L');
		$arr2=array(35,5,27,19,5,31,33,5,40);
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		
		$pdf->Row1(array("Net Payable",":",$obj->getNumberFormat($rows['REQ_TO_PAY'])));
		
		$pdf->Ln(5);
		$sql2 = "select * from request_master where COMID='".$comid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and LOGIN='INTERNAL_USER' and NAME='".$costtype[0]."' and NAME_ID='".$_REQUEST['name_id']."' and GRADEID='".$_REQUEST['grade']."' and VENDOR='".$_REQUEST['vendorid']."' and STATUS='1' and REQ_ID<'".$rows6['REQ_ID']."'";
		$res2 = mysql_query($sql2);
		$rec2 = mysql_num_rows($res2);
		if($rec2>0)
		{
			$pdf->SetFont('daxcondensedlight','',10);
		    $pdf->SetTextColor(27,119,166);
			$arr1=array('C','C','C','C','C','C');
			$arr2=array(20,30,40,40,30,30);
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row(array("S.No.","Cost Type","Cost Desc.","Vendor","Payment No.","Requested To Pay"));
			$i = 0;
			while($rows2 = mysql_fetch_assoc($res2))
			{$i++;
				$pdf->SetFont('daxcondensedlight','',10);
				$pdf->SetTextColor(0,0,0);
				$arr1=array('C','L','L','L','L','R');
			    $arr2=array(20,30,40,40,30,30);
				$pdf->SetAligns($arr1);
				$pdf->SetWidths($arr2);
				$pdf->Row(array($i,$costtype[0],$costtype[1],$obj->getVendorListNewBasedOnID($rows2['VENDOR']),$rows2['PAYMENT_NO'],$rows2['REQ_TO_PAY']));
			}
		}
}

$filename = "Payment Grid ".$obj->getFun8()." ".$paymentno.".pdf";

$pdf->Output($filename,'D');
}


function tc_trip_pdf()
{
	$obj = new data();
	$obj->funConnect();
	$mappingid = $_REQUEST['mappingid'];
	$tc_trip_id = $_REQUEST['tc_trip_id'];
	$l_cost_sheet_id = $obj->getLatestCostSheetID($mappingid);
	$obj->viewFreightEstimationRecords($mappingid,$l_cost_sheet_id);
	//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cost Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cost Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner's Account : Statement",0,1,'L');

$sql = "select * from tc_trip_master where TC_TRIP_MASTER_ID='".$tc_trip_id."'";
$res = mysql_query($sql);
while($rows = mysql_fetch_assoc($res))
{

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(25,5,27,29,5,31,33,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Account Type",":",$rows['ACCOUNT_TYPE'],"Payment No.",":",$rows['PAYMENT_NO'],"CP Date",":",date("d-M-Y",strtotime($rows['CP_DATE']))));

$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($rows['DATE'])),"Nom ID",":",$obj->getMappingData($mappingid,"NOM_NAME"),"Vessel",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME")));

$sql1 = "select * from fca_tci_load_port where FCAID='".$obj->getFun1()."'";
$res1 = mysql_query($sql1);
$i = 0;
while($rows1 = mysql_fetch_assoc($res1))
{ $port_name[$i] = $obj->getPortNameBasedOnID($rows1['LOADPORTID']); $i++;}
$port_name = implode(',',$port_name);

$sql2 = "select * from fca_tci_disch_port where FCAID='".$obj->getFun1()."'";
$res2 = mysql_query($sql2);
$i = 0;
while($rows2 = mysql_fetch_assoc($res2))
{ $dis_name[$i] = $obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']); $i++;}
$dis_name = implode(',',$dis_name);

$pdf->Row1(array("Vendor",":",$obj->getVendorListNewBasedOnID($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_VENDORID")),"Load Port",":",$port_name,"Discharge Port",":",$dis_name));

$pdf->Row1(array("Remarks",":",$rows['REMARKS'],"Vendor Invoice Amount",":",$obj->getNumberFormat($rows['INVOICE_AMT']),"Invoice Date",":",date("d-M-Y",strtotime($rows['INVOICE_DATE']))));

$pdf->Ln(5);

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner's Account : Analysis",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);

if(date("d-M-Y",strtotime($rows['DEL_DATE_LT'])) == '01-Jan-1970'){$del_date_lt = '';}else{$del_date_lt = date("d-M-Y G:i",strtotime($rows['DEL_DATE_LT']));}
if(date("d-M-Y",strtotime($rows['DEL_DATE_GMT'])) == '01-Jan-1970'){$del_date_gmt = '';}else{$del_date_gmt = date("d-M-Y G:i",strtotime($rows['DEL_DATE_GMT']));}

$pdf->Row1(array("Del At",":",$obj->getPortNameBasedOnCode($rows['DEL_PORT']),"Del Date Time LT",":",$del_date_lt,"Del Date Time GMT",":",$del_date_gmt));

if(date("d-M-Y",strtotime($rows['RE_DEL_DATE_LT'])) == '01-Jan-1970'){$re_del_date_lt = '';}else{$re_del_date_lt = date("d-M-Y G:i",strtotime($rows['RE_DEL_DATE_LT']));}
if(date("d-M-Y",strtotime($rows['RE_DEL_DATE_GMT'])) == '01-Jan-1970'){$re_del_date_gmt = '';}else{$re_del_date_gmt = date("d-M-Y G:i",strtotime($rows['RE_DEL_DATE_GMT']));}

$pdf->Row1(array("Re Del At",":",$obj->getPortNameBasedOnCode($rows['RE_DEL_PORT']),"Re Del Date Time LT",":",$re_del_date_lt,"Re Del Date Time GMT",":",$re_del_date_gmt));

$pdf->Row1(array("Total Trip Duration",":",$rows['TTL_TRIP_DUR'],"TC Cost/Day(USD)",":",$obj->getNumberFormat($rows['TC_COST']),"Release Hire Days",":",$rows['REL_HIRE_DAYS']));

$pdf->Row1(array("Less Speed Claim",":",$rows['LESS_SPEED_CLAIM'],"Less Off Hire",":",$rows['LESS_OFF_HIRE'],"Nett Release",":",$rows['NETT_REL']));

$pdf->Row1(array("Reason Off Hire",":",$rows['REASON_OFF_HIRE']));

$pdf->Ln(5);

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);

$pdf->Row1(array("","","","Total Hire(USD)",":",$obj->getNumberFormat($rows['TTL_HIRE'])));

$pdf->Row1(array("Less Add Comm.",":",$rows['LESS_ADD_COMM'],"Add Comm. Abs",":",$obj->getNumberFormat($rows['ADD_COMM'])));

$pdf->Row1(array("Less Brokerage",":",$rows['LESS_BROKERAGE'],"Brokerage Abs",":",$obj->getNumberFormat($rows['BROKERAGE'])));

$pdf->Ln(5);

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Other Owner Related Costs",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(35,5,27,19,5,31,33,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);

$pdf->Row1(array("Nett Hire(USD)",":",$obj->getNumberFormat($rows['NETT_HIRE'])));

$sql1 = "select * from tc_trip_oorc where TC_TRIP_MASTER_ID='".$tc_trip_id."'";
$res1 = mysql_query($sql1);
while($rows1 = mysql_fetch_assoc($res1))
{
$pdf->Row1(array($rows1['OORC_NAME'],":",$obj->getNumberFormat($rows1['OORC'])));
}

$pdf->Row1(array("Bunker Adjustment Account",":",$obj->getNumberFormat($rows['BUNKER_ADJ'])));

$pdf->Row1(array("Total Shipowner Expenses",":",$obj->getNumberFormat($rows['TTL_SHIPOWNER'])));

$pdf->Ln(5);

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Deductions",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);

$sql6 = "select * from tc_trip_master where MAPPINGID='".$mappingid."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' ";
$res6 = mysql_query($sql6);
$i = 0;
while($rows6 = mysql_fetch_assoc($res6))
{
	if($rows6['TC_TRIP_MASTER_ID'] == $tc_trip_id){break;}
	$pdf->Row1(array($rows6['PAYMENT_NO'],":",$obj->getNumberFormat($rows6['BAL_PAYABLE'])));
}

$sql2 = "select * from tc_trip_deduction where TC_TRIP_MASTER_ID='".$tc_trip_id."'";
$res2 = mysql_query($sql2);
while($rows2 = mysql_fetch_assoc($res2))
{
$pdf->Row1(array($rows2['DEDU_NAME'],":",$obj->getNumberFormat($rows2['DEDUCTION'])));
}

$pdf->Ln(5);

$pdf->SetFont('Arial','B',12);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Balance Payable USD",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);

$pdf->Row1(array("Balance Payable USD",":",$obj->getNumberFormat($rows['BAL_PAYABLE'])));

}

$filename = "Owner's Account.pdf";

$pdf->Output($filename,'D');
}

function cost_sheet_pdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['mappingid'])){$mappingid = $_REQUEST['mappingid']; }
	if(isset($_REQUEST['cost_sheet_id'])){$cost_sheet_id = $_REQUEST['cost_sheet_id']; }
	$obj->viewFreightEstimationRecords($mappingid,$cost_sheet_id);
	$_SESSION["fixtureid"] = $obj->getFun2();
	$_SESSION["final"] = $obj->getFun30();
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
				
		function RotatedText($x, $y, $txt, $angle)
		{
			//Text rotated around its origin
			$this->Rotate($angle,$x,$y);
			$this->Text($x,$y,$txt);
			$this->Rotate(0);
		}
		
		var $angle=0;

		function Rotate($angle,$x=-1,$y=-1)
		{
			if($x==-1)
				$x=$this->x;
			if($y==-1)
				$y=$this->y;
			if($this->angle!=0)
				$this->_out('Q');
			$this->angle=$angle;
			if($angle!=0)
			{
				$angle*=M_PI/180;
				$c=cos($angle);
				$s=sin($angle);
				$cx=$x*$this->k;
				$cy=($this->h-$y)*$this->k;
				$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
			}
		}
		
		function _endpage()
		{
			if($this->angle!=0)
			{
				$this->angle=0;
				$this->_out('Q');
			}
			parent::_endpage();
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cost Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cost Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

if($obj->getFun2() == 1)
{
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Main Particulars",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($obj->getFun3())),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE"))));

if($obj->getFun21() == 1)
{
	$dwt_str = "DWT(Summer)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1");
}
else if($obj->getFun21() == 2)
{
	$dwt_str = "DWT(Tropical)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1");
}

if($obj->getFun6() == 1)
{
	$cap_str = "Grain Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN");
}
else if($obj->getFun6() == 2)
{
	$cap_str = "Bale Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE");
}

$pdf->Row1(array($dwt_str,":",$obj->getNumberFormat($dwt_value),$cap_str,":",$obj->getNumberFormat($cap_value),"SF (CBM/MT)",":",$obj->getNumberFormat($obj->getFun9())."   Loadable (MT)  : ".$obj->getNumberFormat($obj->getFun24())));
$pdf->Row1(array("Voyage No",":",$obj->getFun10(),"Cost Sheet No.",":",$obj->getFun5(),"TC No",":",$obj->getFun11()));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Market",0,1,'L');

if($obj->getFun12() == 1)
{
	$market_str = "TC Cost Per Day (USD)";
	$market_value = $obj->getFun13();
}
else if($obj->getFun12() == 2)
{
	$market_str = "Lumpsum (USD)";
	$market_value = $obj->getFun14();
}
$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array($market_str,":",$obj->getNumberFormat($market_value),"","","","","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Cargo",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array("Cargo Qty (MT)",":",$obj->getNumberFormat($obj->getFun15()),"Cargo Type",":",$obj->getCargoTypeNameBasedOnID(abs($obj->getFun16())),"Cargo Name",":",$obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION"))));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Sea Passage",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr4=array('C','L','L','L','L','L','L');
$arr5=array(7,30,30,36,44,22,22);
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2(array("#","From Port","To Port","Passage Type","Distance","Speed Adj.","Margin(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql = "select * from fca_tci_sea_passage where FCAID='".$obj->getFun1()."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows = mysql_fetch_assoc($res))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr4);
		$pdf->SetWidths($arr5);
		$pdf->Row2(array($i.".",$obj->getPortNameBasedOnID($rows['FROM_PORTID']),$obj->getPortNameBasedOnID($rows['TO_PORTID']),$obj->getPassageTypeNameBasedOnID($rows['PASSAGETYPEID'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEEDID'])." )",$obj->getNumberFormat($rows['DISTANCE'])."   (".$obj->getDistanceTypeBasedOnID_New($rows['DISTANCE_TYPEID'])." )",$obj->getNumberFormat($rows['WEATHER']),$obj->getNumberFormat($rows['MARGIN'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Load Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr6=array('L','L','L','L','L','L','L');
$arr7=array(30,40,23,24,29,23,23);
$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql1 = "select * from fca_tci_load_port where FCAID='".$obj->getFun1()."'";
$res1 = mysql_query($sql1);
$rec1 = mysql_num_rows($res1);
if($rec1 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows1 = mysql_fetch_assoc($res1))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows1['LOADPORTID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows1['QTY_MT']),$obj->getNumberFormat($rows1['RATE']),$obj->getNumberFormat($rows1['PORT_COST']),$obj->getNumberFormat($rows1['IDLE_DAYS']),$obj->getNumberFormat($rows1['WORK_DAYS'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql2 = "select * from fca_tci_disch_port where FCAID='".$obj->getFun1()."'";
$res2 = mysql_query($sql2);
$rec2 = mysql_num_rows($res2);
if($rec2 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows2 = mysql_fetch_assoc($res2))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows2['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows2['QTY_MT']),$obj->getNumberFormat($rows2['RATE']),$obj->getNumberFormat($rows2['PORT_COST']),$obj->getNumberFormat($rows2['IDLE_DAYS']),$obj->getNumberFormat($rows2['WORK_DAYS'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L');
$arr9=array(90,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Transit Port","Port Costs(USD)","Idle Days"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql3 = "select * from fca_tci_transit_port where FCAID='".$obj->getFun1()."'";
$res3 = mysql_query($sql3);
$rec3 = mysql_num_rows($res3);
if($rec3 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows3 = mysql_fetch_assoc($res3))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr8);
		$pdf->SetWidths($arr9);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows3['LOAD_PORTID']),$obj->getNumberFormat($rows3['PORT_COST']),$obj->getNumberFormat($rows3['IDLE_DAYS'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Totals",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Laden Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DIST")),"Ballast Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DIST")),"Total Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TOTAL_DIST"))));

$pdf->Row1(array("Laden Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DAYS")),"Ballast Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DAYS")),"Total Sea Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SEA_DAYS"))));

$pdf->Row1(array("Ttl Port Idle Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_IDLE_DAYS")),"Ttl Port Work Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_WORK_DAYS")),"Total Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"))));

$pdf->Row1(array("Ttl FO Consp MT",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT")),"Ttl DO Consp MT",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT")),"","",""));

$pdf->Row1(array("Ttl FO Consp MT (Manual)T",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL")),"Ttl FO Consp MT (Manual)",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT_MANUAL")),"","",""));

$pdf->Row1(array("Ttl FO Consp Off Hire",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_OFFHIRE")),"Ttl DO Consp Off Hire",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_OFFHIRE")),"","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L');
$arr9=array(90,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Percent","USD"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Total Hire (USD)","",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_HIRE_USD"))));
$pdf->Row2(array("Address Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ADD_COMM_PER")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ADD_COMM_USD"))));
$pdf->Row2(array("Brokerage Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PER")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_USD"))));
$pdf->Row2(array("Nett Hire (USD)","",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_HIRE_USD"))));

$pdf->AddPage('P');
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(238,238,238);
$arr10=array('L','C','C','C');
$arr11=array(70,40,40,40);
$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("Nett Hire (USD)",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_HIRE_USD")),"",""));

$sql5 = "select * from fca_tci_owner_related_cost where FCAID='".$obj->getFun1()."'";
$res5 = mysql_query($sql5);
$rec5 = mysql_num_rows($res5);
if($rec5 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows5 = mysql_fetch_assoc($res5))
	{
			$pdf->SetFillColor(255,255,255);
			$pdf->SetAligns($arr10);
			$pdf->SetWidths($arr11);
			if($rows5['AMOUNT'] != 0)
			{
			$pdf->Row2(array($obj->getOwnerRelatedCostNameBasedOnID($rows5['OWNER_RCOSTID']),$obj->getNumberFormat($rows5['AMOUNT']),"",""));
			}
	}
}
$pdf->SetFillColor(238,238,238);
$pdf->Row2(array("Bunker Adjustment Account",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BUNKER_ADUJ_ACC")),"",""));

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Shipowner Expenses",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),"Cost/MT",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_COST_MT"))));


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);


$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("","MT","PRICE","COST"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);
$name = array("Estimated","Nett Supply","Actual Consp");
$val_mt = array("EST_MT","NETT_MT","ACTUAL_MT");
$val_price = array("EST_PRICE","NETT_PRICE","ACTUAL_PRICE");
$val_cost = array("EST_COST","NETT_COST","ACTUAL_COST");
$sum = 0;
$sql4 = "select * from fca_tci_bunker_nett where FCAID='".$obj->getFun1()."'";
$res4 = mysql_query($sql4);
$rec4 = mysql_num_rows($res4);
if($rec4 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows4 = mysql_fetch_assoc($res4))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		for($j=0;$j<count($name);$j++)
		{
			$pdf->SetAligns($arr10);
			$pdf->SetWidths($arr11);
			$sum += $obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_cost[$j]);
			$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows4['BUNKERGRADEID'])."  ".$name[$j],$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_mt[$j])),$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_price[$j])),$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_cost[$j]))));
		}
	}
}
$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Bunker Cost",$obj->getNumberFormat($sum),"Cost/MT",number_format($sum/$obj->getFun15(),2,'.','')));



$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Shipping Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr12=array('L','C','C');
$arr13=array(110,40,40);
$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql6 = "select * from fca_tci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
$res6 = mysql_query($sql6);
$rec6 = mysql_num_rows($res6);
if($rec6 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows6 = mysql_fetch_assoc($res6))
	{
		$pdf->SetAligns($arr12);
		$pdf->SetWidths($arr13);
		if($rows6['ABSOLUTE'] != 0)
		{
			$pdf->Row2(array($obj->getOtherShippingCostNameBasedOnID($rows6['OTHER_SCOSTID']),$obj->getNumberFormat($rows6['ABSOLUTE']),$obj->getNumberFormat($rows6['COST_MT'])));
		}
	}
}


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Port Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql7 = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
$res7 = mysql_query($sql7);
$rec7 = mysql_num_rows($res7);
while($rows7 = mysql_fetch_assoc($res7))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);
	if($rows7['PORT'] == "Load"){$port_name = "Load Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Discharge"){$port_name = "Discharge Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Transit"){$port_name = "Transit Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	
	$pdf->Row2(array($port_name,$obj->getNumberFormat($rows7['COST']),$obj->getNumberFormat($rows7['COST_MT'])));
}

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Port Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"))));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Shipper",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql8 = "select * from fca_tci_dd_shipper where FCAID='".$obj->getFun1()."'";
$res8 = mysql_query($sql8);
$rec8 = mysql_num_rows($res8);
while($rows8 = mysql_fetch_assoc($res8))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows8['LOADPORTID']),$obj->getNumberFormat($rows8['COST']),$obj->getNumberFormat($rows8['COST_MT'])));
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Receiver",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql9 = "select * from fca_tci_dd_receiver where FCAID='".$obj->getFun1()."'";
$res9 = mysql_query($sql9);
$rec9 = mysql_num_rows($res9);
while($rows9 = mysql_fetch_assoc($res9))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows9['LOADPORTID']),$obj->getNumberFormat($rows9['COST']),$obj->getNumberFormat($rows9['COST_MT'])));
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Miscellaneous Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql10 = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
$res10 = mysql_query($sql10);
$rec10 = mysql_num_rows($res10);
while($rows10 = mysql_fetch_assoc($res10))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	if($rows10['AMOUNT'] != 0)
	{
		$pdf->Row2(array($obj->getOtherMiscCostNameBasedOnID($rows10['OTHER_MCOSTID']),$obj->getNumberFormat($rows10['AMOUNT']),$obj->getNumberFormat($rows10['COST_MT'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Total Freight Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(220, 99, 30);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->Row2(array("Total Freight Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS_MT"))));
}
else if($obj->getFun2() == 2)
{
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Main Particulars",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(29,5,25,29,5,31,21,5,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($obj->getFun3())),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE"))));
	
	if($obj->getFun21() == 1)
	{
		$dwt_str = "DWT(Summer)";
		$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1");
	}
	else if($obj->getFun21() == 2)
	{
		$dwt_str = "DWT(Tropical)";
		$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1");
	}
	
	if($obj->getFun6() == 1)
	{
		$cap_str = "Grain Cap.(CBM)";
		$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN");
	}
	else if($obj->getFun6() == 2)
	{
		$cap_str = "Bale Cap.(CBM)";
		$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE");
	}
	
	$pdf->Row1(array($dwt_str,":",$obj->getNumberFormat($dwt_value),$cap_str,":",$obj->getNumberFormat($cap_value),"SF (CBM/MT)",":",$obj->getNumberFormat($obj->getFun9())));
	$pdf->Row1(array("Voyage No",":",$obj->getFun10(),"Cost Sheet No.",":",$obj->getFun5(),"Loadable (MT)",":",$obj->getNumberFormat($obj->getFun24())));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Market",0,1,'L');
	
	if($obj->getFun12() == 1)
	{
		$market_str = "Agreed Gross Freight (USD/MT)";
		$market_value = $obj->getFun13();
	}
	else if($obj->getFun12() == 2)
	{
		$market_str = "Lumpsum (USD)";
		$market_value = $obj->getFun14();
	}
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->Row1(array($market_str,":",$obj->getNumberFormat($market_value),"Addnl Cargo Rate (USD/MT)",":",$obj->getNumberFormat($obj->getFun25()),"","",""));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Cargo",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->Row1(array("Total Cargo Qty (MT)",":",$obj->getNumberFormat($obj->getFun15()),"Cargo Type",":",$obj->getCargoTypeNameBasedOnID(abs($obj->getFun16())),"Cargo Name",":",$obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION"))));
	$pdf->Row1(array("Actual Qty (MT)",":",$obj->getNumberFormat($obj->getFun26()),"DF Qty (MT)",":",$obj->getNumberFormat($obj->getFun27()),"Addnl Qty (MT)",":",$obj->getNumberFormat($obj->getFun28())));

	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Load Port(s)",0,1,'L');

	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L','L','L','L','L','L','L');
	$arr2=array(30,51,27,27,28,28);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Work Days","Port Costs"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	
	$sql = "select * from fca_vci_load_port where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	if($rec == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows = mysql_fetch_assoc($res))
		{
			$i=$i+1;
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(238,238,238);
			}
			else
			{
				$pdf->SetFillColor(255,255,255);
			}
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array($obj->getPortNameBasedOnID($rows['LOADPORTID']),$obj->getCargoContarctForMapping($rows['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows['QTY_MT']),$obj->getNumberFormat($rows['RATE']),$obj->getNumberFormat($rows['WORK_DAYS']),$obj->getNumberFormat($rows['PORTCOSTS'])));
		}
	}
	
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');

	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Work Days","Port Costs"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	
	$sql1 = "select * from fca_vci_disch_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	if($rec1 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows1 = mysql_fetch_assoc($res1))
		{
			$i=$i+1;
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(238,238,238);
			}
			else
			{
				$pdf->SetFillColor(255,255,255);
			}
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array($obj->getPortNameBasedOnID($rows1['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows1['QTY_MT']),$obj->getNumberFormat($rows1['RATE']),$obj->getNumberFormat($rows1['WORK_DAYS']),$obj->getNumberFormat($rows1['PORTCOSTS'])));
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr3=array('L','L','L','L');
	$arr4=array(100,30,30,30);
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("","Percent","USD","Per MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("Gross Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"GROSS_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"GROSS_FREIGHT_PERMT"))));
	$pdf->Row2(array("Dead Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DEAD_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DEAD_FREIGHT_PERMT"))));
	$pdf->Row2(array("Addnl Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ADDNL_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ADDNL_FREIGHT_PERMT"))));
	$pdf->Row2(array("Total Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_FREIGHT_PERMT"))));
	$pdf->Row2(array("Address Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_PERCENT")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_PERMT"))));
	$pdf->Row2(array("Brokerage",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AGC_PERCENT")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AGC_USD")),""));
	$pdf->Row2(array("Net Freight Payable","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"NETT_FRT_PAYABLE")),""));

	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr5=array('L','L','L','L');
	$arr6=array(70,30,70,20);
	$pdf->SetAligns($arr5);
	$pdf->SetWidths($arr6);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->SetAligns($arr5);
	$pdf->SetWidths($arr6);
	$pdf->Row2(array("Freight Payment",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")),"Cost/MT",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_COSTMT"))));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"All Other Shipping Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr7=array('L','C','C');
	$arr8=array(110,40,40);
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql2 = "select * from fca_vci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
	$res2 = mysql_query($sql2);
	$rec2 = mysql_num_rows($res2);
	if($rec2 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows2 = mysql_fetch_assoc($res2))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows2['ABSOLUTE'] != 0)
			{
				$pdf->Row2(array($obj->getOtherShippingCostNameBasedOnID($rows2['OTHER_SCOSTID']),$obj->getNumberFormat($rows2['ABSOLUTE']),$obj->getNumberFormat($rows2['COST_MT'])));
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"All Other Miscellaneous Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql3 = "select * from fca_vci_other_misc_cost where FCAID='".$obj->getFun1()."'";
	$res3 = mysql_query($sql3);
	$rec3 = mysql_num_rows($res3);
	if($rec3 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows3 = mysql_fetch_assoc($res3))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows3['AMOUNT'] != 0)
			{
				$pdf->Row2(array($obj->getOtherMiscCostNameBasedOnID($rows3['OTHER_MCOSTID']),$obj->getNumberFormat($rows3['AMOUNT']),$obj->getNumberFormat($rows3['COST_MT'])));
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Port Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr12=array('L','C','C');
	$arr13=array(110,40,40);
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql7 = "select * from fca_vci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
	$res7 = mysql_query($sql7);
	$rec7 = mysql_num_rows($res7);
	while($rows7 = mysql_fetch_assoc($res7))
	{
		$pdf->SetAligns($arr12);
		$pdf->SetWidths($arr13);
		if($rows7['PORT'] == "Load"){$port_name = "Load Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		if($rows7['PORT'] == "Discharge"){$port_name = "Discharge Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		if($rows7['PORT'] == "Transit"){$port_name = "Transit Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		
		$pdf->Row2(array($port_name,$obj->getNumberFormat($rows7['COST']),$obj->getNumberFormat($rows7['COST_MT'])));
	}
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$pdf->Row2(array("Total Port Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_PORT_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"))));
	$pdf->Ln(10);
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Total Freight Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',9);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->Row2(array("Total Freight Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_SHIPPING_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_SHIPPING_COSTMT"))));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Ship Owner",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql4 = "select * from fca_vci_shipowner where FCAID='".$obj->getFun1()."'";
	$res4 = mysql_query($sql4);
	$rec4 = mysql_num_rows($res4);
	if($rec4 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows4 = mysql_fetch_assoc($res4))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows4['PORT'] == "Load")
			{
				$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($rows4['COST']),$obj->getNumberFormat($rows4['COST_MT'])));
			}
			else if($rows4['PORT'] == "Discharge")
			{
				$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($rows4['COST']),$obj->getNumberFormat($rows4['COST_MT'])));
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Shipper",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql5 = "select * from fca_vci_dd_shipper where FCAID='".$obj->getFun1()."'";
	$res5 = mysql_query($sql5);
	$rec5 = mysql_num_rows($res5);
	if($rec5 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows5 = mysql_fetch_assoc($res5))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows5['LOADPORTID']),$obj->getNumberFormat($rows5['COST']),$obj->getNumberFormat($rows5['COST_MT'])));
		}
	}
	//$pdf->Ln(2);
	//$pdf->AddPage('P');
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Receiver",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql6 = "select * from fca_vci_dd_receiver where FCAID='".$obj->getFun1()."'";
	$res6 = mysql_query($sql6);
	$rec6 = mysql_num_rows($res6);
	if($rec6 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows6 = mysql_fetch_assoc($res6))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows6['LOADPORTID']),$obj->getNumberFormat($rows6['COST']),$obj->getNumberFormat($rows6['COST_MT'])));
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Nett Results",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->Row2(array("Load Port",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_LP_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_LP_COSTMT"))));
	$pdf->Row2(array("Discharge Port",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_DP_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_DP_COSTMT"))));

}

$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME").' '.$obj->getFun5().' '.date("d-M-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function cost_sheet_pdf_actual()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['mappingid'])){$mappingid = $_REQUEST['mappingid']; }
	if(isset($_REQUEST['cost_sheet_id'])){$cost_sheet_id = $_REQUEST['cost_sheet_id']; }
	$obj->viewFreightEstimationRecords($mappingid,$cost_sheet_id);
	$_SESSION["fixtureid"] = $obj->getFun2();
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Cost Sheet Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Cost Sheet Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

if($obj->getFun2() == 1)
{
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Main Particulars",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($obj->getFun3())),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE"))));

if($obj->getFun21() == 1)
{
	$dwt_str = "DWT(Summer)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1");
}
else if($obj->getFun21() == 2)
{
	$dwt_str = "DWT(Tropical)";
	$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1");
}

if($obj->getFun6() == 1)
{
	$cap_str = "Grain Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN");
}
else if($obj->getFun6() == 2)
{
	$cap_str = "Bale Cap.(CBM)";
	$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE");
}

$pdf->Row1(array($dwt_str,":",$obj->getNumberFormat($dwt_value),$cap_str,":",$obj->getNumberFormat($cap_value),"SF (CBM/MT)",":",$obj->getNumberFormat($obj->getFun9())."   Loadable (MT)  : ".$obj->getNumberFormat($obj->getFun24())));
$pdf->Row1(array("Voyage No",":",$obj->getFun10(),"Cost Sheet No.",":",$obj->getFun5(),"TC No",":",$obj->getFun11()));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Market",0,1,'L');

if($obj->getFun12() == 1)
{
	$market_str = "TC Cost Per Day (USD)";
	$market_value = $obj->getFun13();
}
else if($obj->getFun12() == 2)
{
	$market_str = "Lumpsum (USD)";
	$market_value = $obj->getFun14();
}
$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array($market_str,":",$obj->getNumberFormat($market_value),"","","","","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Cargo",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->Row1(array("Cargo Qty (MT)",":",$obj->getNumberFormat($obj->getFun15()),"Cargo Type",":",$obj->getCargoTypeNameBasedOnID(abs($obj->getFun16())),"Cargo Name",":",$obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION"))));

if(date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE"))) != "01-Jan-1970")
{
	$cp_date = date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE")));
}
else
{
	$cp_date = "";
}

$pdf->Row1(array("Total BL Net Qty (MT)",":",number_format($obj->getTTLBlNetQtyBasedOnMappingid($mappingid),3,'.',''),"CP Date",":",$cp_date,"","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Sea Passage",0,1,'L');

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr4=array('C','L','L','L','L','C','C','C','C');
$arr5=array(7,23,23,28,42,17,18,15,18);
$pdf->SetAligns($arr4);
$pdf->SetWidths($arr5);
$pdf->Row2(array("#","From Port","To Port","Passage Type","Distance","Speed Adj.","Margin(days)","Est (days)","Actual(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$actual_sp = $obj->getActualSeaPassageData($obj->getFun1());
$actual_lp = $obj->getActualLoadPortData($obj->getFun1());
$actual_dp = $obj->getActualDeschargePortData($obj->getFun1());
$actual_tp = $obj->getActualTransitPortData($obj->getFun1());

$sql = "select * from fca_tci_sea_passage where FCAID='".$obj->getFun1()."'";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows = mysql_fetch_assoc($res))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr4);
		$pdf->SetWidths($arr5);
		$pdf->Row2(array($i.".",$obj->getPortNameBasedOnID($rows['FROM_PORTID']),$obj->getPortNameBasedOnID($rows['TO_PORTID']),$obj->getPassageTypeNameBasedOnID($rows['PASSAGETYPEID'])." (".$obj->getPassageSpeedBasedOnID($rows['SPEEDID'])." )",$obj->getNumberFormat($rows['DISTANCE'])."   (".$obj->getDistanceTypeBasedOnID_New($rows['DISTANCE_TYPEID'])." )",$obj->getNumberFormat($rows['WEATHER']),$obj->getNumberFormat($rows['MARGIN']),$obj->getEstimatedDays($mappingid,$rows['MARGIN'],$rows['DISTANCE'],$rows['SPEEDID'],$rows['PASSAGETYPEID'],$rows['WEATHER']),$actual_sp[$i]['ACTUAL_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Load Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr6=array('L','L','L','L','L','C','C','L','C','C');
$arr7=array(22,36,15,18,22,14,15,17,15,18);
$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days","BL Date","Est (days)","Actual(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql1 = "select * from fca_tci_load_port where FCAID='".$obj->getFun1()."'";
$res1 = mysql_query($sql1);
$rec1 = mysql_num_rows($res1);
if($rec1 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows1 = mysql_fetch_assoc($res1))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows1['LOADPORTID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows1['QTY_MT']),$obj->getNumberFormat($rows1['RATE']),$obj->getNumberFormat($rows1['PORT_COST']),$obj->getNumberFormat($rows1['IDLE_DAYS']),$obj->getNumberFormat($rows1['WORK_DAYS']),$obj->getBLDateBasedOnMappingidAndPort($mappingid,'LP',$rows1['LOADPORTID']),$rows1['IDLE_DAYS'] + $rows1['WORK_DAYS'],$actual_lp[$rows1['LOADPORTID']][$i]['ACTUAL_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',7);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr6);
$pdf->SetWidths($arr7);
$pdf->Row2(array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","Port Costs(USD)","Idle Days","Work Days","BL Date","Est (days)","Actual(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql2 = "select * from fca_tci_disch_port where FCAID='".$obj->getFun1()."'";
$res2 = mysql_query($sql2);
$rec2 = mysql_num_rows($res2);
if($rec2 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows2 = mysql_fetch_assoc($res2))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr6);
		$pdf->SetWidths($arr7);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows2['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows2['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows2['QTY_MT']),$obj->getNumberFormat($rows2['RATE']),$obj->getNumberFormat($rows2['PORT_COST']),$obj->getNumberFormat($rows2['IDLE_DAYS']),$obj->getNumberFormat($rows2['WORK_DAYS']),$obj->getBLDateBasedOnMappingidAndPort($mappingid,'DP',$rows2['DIS_PORT_ID']),$rows2['IDLE_DAYS'] + $rows2['WORK_DAYS'],$actual_dp[$rows2['DIS_PORT_ID']][$i]['ACTUAL_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Transit Port(s)",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L','L','L');
$arr9=array(70,30,30,30,30);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Transit Port","Port Costs(USD)","Idle Days","Est (days)","Actual(days)"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);

$sql3 = "select * from fca_tci_transit_port where FCAID='".$obj->getFun1()."'";
$res3 = mysql_query($sql3);
$rec3 = mysql_num_rows($res3);
if($rec3 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows3 = mysql_fetch_assoc($res3))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$pdf->SetAligns($arr8);
		$pdf->SetWidths($arr9);
		$pdf->Row2(array($obj->getPortNameBasedOnID($rows3['LOAD_PORTID']),$obj->getNumberFormat($rows3['PORT_COST']),$obj->getNumberFormat($rows3['IDLE_DAYS']),$rows3['IDLE_DAYS'],$actual_tp[$rows3['LOAD_PORTID']][$i]['ACTUAL_DAYS']));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Totals",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','C','L','L','C','L','L','C','L');
$arr2=array(29,5,25,29,5,31,21,5,40);
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1(array("Laden Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DIST")),"Ballast Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DIST")),"Total Dist",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TOTAL_DIST"))));

$pdf->Row1(array("Laden Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"LADEN_DAYS")),"Ballast Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BALLAST_DAYS")),"Total Sea Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SEA_DAYS"))));

$pdf->Row1(array("Ttl Port Idle Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_IDLE_DAYS")),"Ttl Port Work Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_WORK_DAYS")),"Total Days",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DAYS"))));

$pdf->Row1(array("Ttl FO Consp MT",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_MT")),"Ttl DO Consp MT",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_MT")),"","",""));

$pdf->Row1(array("Ttl FO Consp Off Hire",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_FO_CONSP_OFFHIRE")),"Ttl DO Consp Off Hire",":",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_DO_CONSP_OFFHIRE")),"","",""));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr8=array('L','L','L');
$arr9=array(90,50,50);
$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("","Percent","USD"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->SetAligns($arr8);
$pdf->SetWidths($arr9);
$pdf->Row2(array("Total Hire (USD)","",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_HIRE_USD"))));
$pdf->Row2(array("Address Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ADD_COMM_PER")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ADD_COMM_USD"))));
$pdf->Row2(array("Brokerage Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_PER")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BROKERAGE_COMM_USD"))));
$pdf->Row2(array("Nett Hire (USD)","",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_HIRE_USD"))));

$pdf->AddPage('P');
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(238,238,238);
$arr10=array('L','C','C','C');
$arr11=array(70,40,40,40);
$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("Nett Hire (USD)",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"NETT_HIRE_USD")),"",""));

$sql5 = "select * from fca_tci_owner_related_cost where FCAID='".$obj->getFun1()."'";
$res5 = mysql_query($sql5);
$rec5 = mysql_num_rows($res5);
if($rec5 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;$orc_text = "";
while($rows5 = mysql_fetch_assoc($res5))
	{
			$pdf->SetFillColor(255,255,255);
			$arr55=array('L','C','L');
			$arr56=array(70,40,80);
			$pdf->SetAligns($arr55);
			$pdf->SetWidths($arr56);
			if($rows5['AMOUNT'] != 0)
			{
				 if($obj->getOwnerRelatedCostNameBasedOnID($rows5['OWNER_RCOSTID']) == "CVE"){
					$orc_text = $obj->getOwnerRelatedCostNameBasedOnID($rows5['OWNER_RCOSTID'])."                                       ( ".$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"CVE"))." ) ";
				 }
				 else
				 {
				 	$orc_text = $obj->getOwnerRelatedCostNameBasedOnID($rows5['OWNER_RCOSTID']);
				 }
				 $pdf->Row2(array($orc_text,$obj->getNumberFormat($rows5['AMOUNT']),$rows1['REMARKS']));
			}
	}
}

$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);

$pdf->SetFillColor(238,238,238);
$pdf->Row2(array("Bunker Adjustment Account",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"BUNKER_ADUJ_ACC")),"",""));

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Shipowner Expenses",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPOWNER_EXPENSES")),"Cost/MT",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"ORC_COST_MT"))));


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Bunker Adjustment",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);


$pdf->SetAligns($arr10);
$pdf->SetWidths($arr11);
$pdf->Row2(array("","MT","PRICE","COST"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);
$name = array("Estimated","Nett Supply","Actual Consp");
$val_mt = array("EST_MT","NETT_MT","ACTUAL_MT");
$val_price = array("EST_PRICE","NETT_PRICE","ACTUAL_PRICE");
$val_cost = array("EST_COST","NETT_COST","ACTUAL_COST");
$sum = 0;
$sql4 = "select * from fca_tci_bunker_nett where FCAID='".$obj->getFun1()."'";
$res4 = mysql_query($sql4);
$rec4 = mysql_num_rows($res4);
if($rec4 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows4 = mysql_fetch_assoc($res4))
	{
		$i=$i+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(238,238,238);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		for($j=0;$j<count($name);$j++)
		{
			$pdf->SetAligns($arr10);
			$pdf->SetWidths($arr11);
			$sum += $obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_cost[$j]);
			$pdf->Row2(array($obj->getBunkerGradeBasedOnID($rows4['BUNKERGRADEID'])."  ".$name[$j],$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_mt[$j])),$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_price[$j])),$obj->getNumberFormat($obj->getBunkerValues($obj->getFun1(),$mappingid,$rows4['BUNKERGRADEID'],$val_cost[$j]))));
		}
	}
}
$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Bunker Cost",$obj->getNumberFormat($sum),"Cost/MT",number_format($sum/$obj->getFun15(),2,'.','')));



$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Shipping Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$arr12=array('L','C','C');
$arr13=array(110,40,40);
$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql6 = "select * from fca_tci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
$res6 = mysql_query($sql6);
$rec6 = mysql_num_rows($res6);
if($rec6 == 0)
{
	$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
}
else
{$i = 0;
while($rows6 = mysql_fetch_assoc($res6))
	{
		$pdf->SetAligns($arr12);
		$pdf->SetWidths($arr13);
		if($rows6['ABSOLUTE'] != 0)
		{
			$pdf->Row2(array($obj->getOtherShippingCostNameBasedOnID($rows6['OTHER_SCOSTID']),$obj->getNumberFormat($rows6['ABSOLUTE']),$obj->getNumberFormat($rows6['COST_MT'])));
		}
	}
}


$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Port Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql7 = "select * from fca_tci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
$res7 = mysql_query($sql7);
$rec7 = mysql_num_rows($res7);
while($rows7 = mysql_fetch_assoc($res7))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);
	if($rows7['PORT'] == "Load"){$port_name = "Load Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Discharge"){$port_name = "Discharge Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	if($rows7['PORT'] == "Transit"){$port_name = "Transit Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
	
	$pdf->Row2(array($port_name,$obj->getNumberFormat($rows7['COST']),$obj->getNumberFormat($rows7['COST_MT'])));
}

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);
$pdf->Row2(array("Total Port Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"))));

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Shipper",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$per_mt = $obj->getFun15();

$sql8 = "select * from fca_tci_dd_shipper where FCAID='".$obj->getFun1()."'";
$res8 = mysql_query($sql8);
$rec8 = mysql_num_rows($res8);
while($rows8 = mysql_fetch_assoc($res8))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$qqsql = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows8['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
	$qqres = mysql_query($qqsql);
	$qqrec = mysql_num_rows($qqres);
	
	if($qqrec == 0)
	{
		$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows8['LOADPORTID']),$obj->getNumberFormat($rows8['COST']),$obj->getNumberFormat($rows8['COST_MT'])));
	}else{
		$j=1;
		while($qqrows = mysql_fetch_assoc($qqres))
		{
			if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
			if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
			if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
			$pdf->Row2(array("Shipper".$j."  ".$obj->getPortNameBasedOnID($rows8['LOADPORTID']),$obj->getNumberFormat($value),$obj->getNumberFormat(($value/$per_mt))));
			$j++;
		}
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Demurrage Dispatch Receiver",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql9 = "select * from fca_tci_dd_receiver where FCAID='".$obj->getFun1()."'";
$res9 = mysql_query($sql9);
$rec9 = mysql_num_rows($res9);
while($rows9 = mysql_fetch_assoc($res9))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	$qqsql1 = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows9['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
	$qqres1 = mysql_query($qqsql1);
	$qqrec1 = mysql_num_rows($qqres1);
	
	if($qqrec1 == 0)
	{
		$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows9['LOADPORTID']),$obj->getNumberFormat($rows9['COST']),$obj->getNumberFormat($rows9['COST_MT'])));
	}else{
		$j=1;
		while($qqrows1 = mysql_fetch_assoc($qqres1))
		{
			if($qqrows1['TTL_DEMURRAGE'] == 0 && $qqrows1['TTL_DESPATCH'] == 0){$value1 = 0;}
			if($qqrows1['TTL_DEMURRAGE'] == 0){$value1 = $qqrows1['TTL_DESPATCH'];}
			if($qqrows1['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows1['TTL_DEMURRAGE'];} 
			$pdf->Row2(array("Receiver".$j."  ".$obj->getPortNameBasedOnID($rows9['LOADPORTID']),$obj->getNumberFormat($value1),$obj->getNumberFormat(($value1/$per_mt))));
			$j++;
		}
	}
	
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"All Other Miscellaneous Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(27,119,166);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$sql10 = "select * from fca_tci_other_misc_cost where FCAID='".$obj->getFun1()."'";
$res10 = mysql_query($sql10);
$rec10 = mysql_num_rows($res10);
while($rows10 = mysql_fetch_assoc($res10))
{
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);	
	if($rows10['AMOUNT'] != 0)
	{
		$pdf->Row2(array($obj->getOtherMiscCostNameBasedOnID($rows10['OTHER_MCOSTID']),$obj->getNumberFormat($rows10['AMOUNT']),$obj->getNumberFormat($rows10['COST_MT'])));
	}
}

$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(27,119,166);
$pdf->Cell(190,6,"Total Freight Costs",0,1,'L');

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(255,255,255);
$pdf->SetFillColor(220, 99, 30);
$pdf->SetDrawColor(255,255,255);

$pdf->SetAligns($arr12);
$pdf->SetWidths($arr13);
$pdf->Row2(array("","Cost","Cost/MT"));

$pdf->SetFont('Arial','',7);
$pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->Row2(array("Total Freight Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalRecords($obj->getFun1(),"TTL_SHIPPING_COSTS_MT"))));
}
else if($obj->getFun2() == 2)
{
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Main Particulars",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$arr1=array('L','C','L','L','C','L','L','C','L');
	$arr2=array(29,5,25,29,5,31,21,5,40);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row1(array("Date",":",date("d-M-Y",strtotime($obj->getFun3())),"Vessel Name",":",$obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME"),"Vessel Type",":",$obj->getVesselTypeBasedOnID($obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_TYPE"))));
	
	if($obj->getFun21() == 1)
	{
		$dwt_str = "DWT(Summer)";
		$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"SUMMER_1");
	}
	else if($obj->getFun21() == 2)
	{
		$dwt_str = "DWT(Tropical)";
		$dwt_value = $obj->getVesselMaster1Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"TROPICAL_1");
	}
	
	if($obj->getFun6() == 1)
	{
		$cap_str = "Grain Cap.(CBM)";
		$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"GRAIN");
	}
	else if($obj->getFun6() == 2)
	{
		$cap_str = "Bale Cap.(CBM)";
		$cap_value = $obj->getVesselMaster8Data($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"BALE");
	}
	
	$pdf->Row1(array($dwt_str,":",$obj->getNumberFormat($dwt_value),$cap_str,":",$obj->getNumberFormat($cap_value),"SF (CBM/MT)",":",$obj->getNumberFormat($obj->getFun9())));
	$pdf->Row1(array("Voyage No",":",$obj->getFun10(),"Cost Sheet No.",":",$obj->getFun5(),"Loadable (MT)",":",$obj->getNumberFormat($obj->getFun24())));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Market",0,1,'L');
	
	if($obj->getFun12() == 1)
	{
		$market_str = "Agreed Gross Freight (USD/MT)";
		$market_value = $obj->getFun13();
	}
	else if($obj->getFun12() == 2)
	{
		$market_str = "Lumpsum (USD)";
		$market_value = $obj->getFun14();
	}
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->Row1(array($market_str,":",$obj->getNumberFormat($market_value),"Addnl Cargo Rate (USD/MT)",":",$obj->getNumberFormat($obj->getFun25()),"","",""));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Cargo",0,1,'L');
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->Row1(array("Quantity (MT)",":",$obj->getNumberFormat($obj->getFun15()),"Cargo Type",":",$obj->getCargoTypeNameBasedOnID(abs($obj->getFun16())),"Cargo Name",":",$obj->getCargoContarctForMapping($obj->getMappingData($mappingid,"CARGO_IDS"),$obj->getMappingData($mappingid,"CARGO_POSITION"))));
	$pdf->Row1(array("","","","DF Qty (MT)",":",$obj->getNumberFormat($obj->getFun27()),"Addnl Qty (MT)",":",$obj->getNumberFormat($obj->getFun28())));
	
	if(date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE"))) != "01-Jan-1970")
	{
		$cp_date = date("d-M-Y",strtotime($obj->getNomDetailsData($mappingid,"CP_DATE")));
	}
	else
	{
		$cp_date = "";
	}
	
	$pdf->Row1(array("Total BL Net Qty (MT)",":",number_format($obj->getTTLBlNetQtyBasedOnMappingid($mappingid),3,'.',''),"CP Date",":",$cp_date,"","",""));

	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Load Port(s)",0,1,'L');

	$pdf->SetFont('Arial','B',7);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$arr1=array('L','L','L','L','L','L','L');
	$arr2=array(30,51,22,22,22,22,22);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Load Port","Cargo Name","Qty MT","Rate(MT/Day)","BL Date","Work Days","Port Costs"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	
	$sql = "select * from fca_vci_load_port where FCAID='".$obj->getFun1()."'";
	$res = mysql_query($sql);
	$rec = mysql_num_rows($res);
	if($rec == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows = mysql_fetch_assoc($res))
		{
			$i=$i+1;
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(238,238,238);
			}
			else
			{
				$pdf->SetFillColor(255,255,255);
			}
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array($obj->getPortNameBasedOnID($rows['LOADPORTID']),$obj->getCargoContarctForMapping($rows['PURCHASE_ALLOCATIONID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows['QTY_MT']),$obj->getNumberFormat($rows['RATE']),$obj->getBLDateBasedOnMappingidAndPort($mappingid,'LP',$rows['LOADPORTID']),$obj->getNumberFormat($rows['WORK_DAYS']),$obj->getNumberFormat($rows['PORTCOSTS'])));
		}
	}
	
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Discharge Port(s)",0,1,'L');

	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2(array("Discharge Port","Cargo Name","Qty MT","Rate(MT/Day)","BL Date","Work Days","Port Costs"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	
	$sql1 = "select * from fca_vci_disch_port where FCAID='".$obj->getFun1()."'";
	$res1 = mysql_query($sql1);
	$rec1 = mysql_num_rows($res1);
	if($rec1 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows1 = mysql_fetch_assoc($res1))
		{
			$i=$i+1;
			if($i % 2 == 0)
			{
				$pdf->SetFillColor(238,238,238);
			}
			else
			{
				$pdf->SetFillColor(255,255,255);
			}
			$pdf->SetAligns($arr1);
			$pdf->SetWidths($arr2);
			$pdf->Row2(array($obj->getPortNameBasedOnID($rows1['DIS_PORT_ID']),$obj->getCargoContarctForMapping($rows1['PURCHASE_ALLOCID'],$obj->getMappingData($mappingid,"CARGO_POSITION")),$obj->getNumberFormat($rows1['QTY_MT']),$obj->getNumberFormat($rows1['RATE']),$obj->getBLDateBasedOnMappingidAndPort($mappingid,'DP',$rows1['DIS_PORT_ID']),$obj->getNumberFormat($rows1['WORK_DAYS']),$obj->getNumberFormat($rows1['PORTCOSTS'])));
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Freight Adjustment",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr3=array('L','L','L','L');
	$arr4=array(100,30,30,30);
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("","Percent","USD","Per MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->SetAligns($arr3);
	$pdf->SetWidths($arr4);
	$pdf->Row2(array("Gross Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"GROSS_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"GROSS_FREIGHT_PERMT"))));
	$pdf->Row2(array("Dead Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DEAD_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DEAD_FREIGHT_PERMT"))));
	$pdf->Row2(array("Addnl Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ADDNL_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ADDNL_FREIGHT_PERMT"))));
	
	$per_mt = $obj->getFun15();
	if($obj->getBAFDataBasedOnID($mappingid,"APPLY_BAF") != 1){$baf_qty = 0.00;$baf = 0.00;}
	else
	{
		$baf = $obj->getBAFDataBasedOnID($mappingid,"APPLICABLE_BAF");
		if($obj->getFun27() == "" || $obj->getFun27() == 0){$df_qty = 0;}else{$df_qty = $obj->getFun27();}
		if($obj->getFun28() == "" || $obj->getFun28() == 0 ){$addnl_qty = 0;}else{$addnl_qty = $obj->getFun28();}
		$baf_qty = ($per_mt + $df_qty + $addnl_qty) * $baf;
	}
	
	$pdf->Row2(array("BAF","",$obj->getNumberFormat($baf_qty),$obj->getNumberFormat($baf)));
	
	$pdf->Row2(array("Total Freight","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_FREIGHT_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_FREIGHT_PERMT"))));
	$pdf->Row2(array("Address Commission",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_PERCENT")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_USD")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AC_PERMT"))));
	$pdf->Row2(array("Brokerage",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AGC_PERCENT")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"AGC_USD")),""));
	$pdf->Row2(array("Net Freight Payable","",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"NETT_FRT_PAYABLE")),""));

	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Owner Related Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr5=array('L','L','L','L');
	$arr6=array(70,30,70,20);
	$pdf->SetAligns($arr5);
	$pdf->SetWidths($arr6);
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->SetAligns($arr5);
	$pdf->SetWidths($arr6);
	$pdf->Row2(array("Freight Payment",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"FREIGHT_PAYMENT")),"Cost/MT",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"ORC_COSTMT"))));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"All Other Shipping Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr7=array('L','C','C');
	$arr8=array(110,40,40);
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql2 = "select * from fca_vci_other_shipping_cost where FCAID='".$obj->getFun1()."'";
	$res2 = mysql_query($sql2);
	$rec2 = mysql_num_rows($res2);
	if($rec2 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows2 = mysql_fetch_assoc($res2))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows2['ABSOLUTE'] != 0)
			{
				$pdf->Row2(array($obj->getOtherShippingCostNameBasedOnID($rows2['OTHER_SCOSTID']),$obj->getNumberFormat($rows2['ABSOLUTE']),$obj->getNumberFormat($rows2['COST_MT'])));
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"All Other Miscellaneous Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql3 = "select * from fca_vci_other_misc_cost where FCAID='".$obj->getFun1()."'";
	$res3 = mysql_query($sql3);
	$rec3 = mysql_num_rows($res3);
	if($rec3 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows3 = mysql_fetch_assoc($res3))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows3['AMOUNT'] != 0)
			{
				$pdf->Row2(array($obj->getOtherMiscCostNameBasedOnID($rows3['OTHER_MCOSTID']),$obj->getNumberFormat($rows3['AMOUNT']),$obj->getNumberFormat($rows3['COST_MT'])));
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Port Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$arr12=array('L','C','C');
	$arr13=array(110,40,40);
	$pdf->SetAligns($arr12);
	$pdf->SetWidths($arr13);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql7 = "select * from fca_vci_portcosts where FCAID='".$obj->getFun1()."' order by FCA_PORTCOSTID asc";
	$res7 = mysql_query($sql7);
	$rec7 = mysql_num_rows($res7);
	while($rows7 = mysql_fetch_assoc($res7))
	{
		$pdf->SetAligns($arr12);
		$pdf->SetWidths($arr13);
		if($rows7['PORT'] == "Load"){$port_name = "Load Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		if($rows7['PORT'] == "Discharge"){$port_name = "Discharge Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		if($rows7['PORT'] == "Transit"){$port_name = "Transit Port  ".$obj->getPortNameBasedOnID($rows7['LOADPORTID']);}
		
		$pdf->Row2(array($port_name,$obj->getNumberFormat($rows7['COST']),$obj->getNumberFormat($rows7['COST_MT'])));
	}
	
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	$pdf->Row2(array("Total Port Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_PORT_COSTS")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_PORT_COSTS_MT"))));
	$pdf->Ln(10);
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Total Freight Costs",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',9);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->Row2(array("Total Freight Costs",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_SHIPPING_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"TTL_SHIPPING_COSTMT"))));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Ship Owner",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$per_mt = $obj->getFun15();
	
	$sql4 = "select * from fca_vci_shipowner where FCAID='".$obj->getFun1()."'";
	$res4 = mysql_query($sql4);
	$rec4 = mysql_num_rows($res4);
	if($rec4 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows4 = mysql_fetch_assoc($res4))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			if($rows4['PORT'] == "Load")
			{
				$qqsql2 = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='INTERNAL_USER' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows4['LOADPORTID']."' and ENTITY='SHIP_OWNER' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
				$qqres2 = mysql_query($qqsql2);
				$qqrec2 = mysql_num_rows($qqres2);
				if($qqrec2 == 0)
				{
					$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($rows4['COST']),$obj->getNumberFormat($rows4['COST_MT'])));
				}
				else
				{
					$k=1;while($qqrows2 = mysql_fetch_assoc($qqres2))
					{
						if($qqrows2['TTL_DEMURRAGE'] == 0 && $qqrows2['TTL_DESPATCH'] == 0){$value = 0;}
						if($qqrows2['TTL_DEMURRAGE'] == 0){$value = "-".$qqrows2['TTL_DESPATCH'];}
						if($qqrows2['TTL_DESPATCH'] == 0){$value = $qqrows2['TTL_DEMURRAGE'];} 
						
						$pdf->Row2(array("Owner ".$k." Load Port ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($value),$obj->getNumberFormat(($value/$per_mt))));	
						$k++;
					}
				}	
			}
			else if($rows4['PORT'] == "Discharge")
			{
				$qqsql3 = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='INTERNAL_USER' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows4['LOADPORTID']."' and ENTITY='SHIP_OWNER' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
				$qqres3 = mysql_query($qqsql3);
				$qqrec3 = mysql_num_rows($qqres3);
				if($qqrec3 == 0)
				{
					$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($rows4['COST']),$obj->getNumberFormat($rows4['COST_MT'])));
				}
				else
				{
					$l=1;while($qqrows3 = mysql_fetch_assoc($qqres3))
					{
						if($qqrows3['TTL_DEMURRAGE'] == 0 && $qqrows3['TTL_DESPATCH'] == 0){$value = 0;}
						if($qqrows3['TTL_DEMURRAGE'] == 0){$value = "-".$qqrows3['TTL_DESPATCH'];}
						if($qqrows3['TTL_DESPATCH'] == 0){$value = $qqrows3['TTL_DEMURRAGE'];} 
						
						$pdf->Row2(array("Owner ".$l." Discharge Port  ".$obj->getPortNameBasedOnID($rows4['LOADPORTID']),$obj->getNumberFormat($value),$obj->getNumberFormat(($value/$per_mt))));
						$l++;
					}
				}
			}
		}
	}
	
	$pdf->Row2(array("","",""));
	
	$pdf->Row2(array("Address Commission                                                                                                ".$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_ADD_COMM")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_ADD_COMM_COST")),""));
	
	$pdf->Row2(array("Brokerage                                                                                                                 ".$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_BROKERAGE")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_BROKERAGE_COST")),""));
	
	$pdf->Row2(array("Nett",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_NETT")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DD_NETT_COST"))));
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Shipper",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql5 = "select * from fca_vci_dd_shipper where FCAID='".$obj->getFun1()."'";
	$res5 = mysql_query($sql5);
	$rec5 = mysql_num_rows($res5);
	if($rec5 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows5 = mysql_fetch_assoc($res5))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			$qqsql = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='LP' and PORTID='".$rows5['LOADPORTID']."' and ENTITY='Shipper' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
			$qqres = mysql_query($qqsql);
			$qqrec = mysql_num_rows($qqres);
			if($qqrec == 0)
			{
				$pdf->Row2(array("Load Port  ".$obj->getPortNameBasedOnID($rows5['LOADPORTID']),$obj->getNumberFormat($rows5['COST']),$obj->getNumberFormat($rows5['COST_MT'])));
			}
			else
			{
				$j=1;while($qqrows = mysql_fetch_assoc($qqres))
				{
					if($qqrows['TTL_DEMURRAGE'] == 0 && $qqrows['TTL_DESPATCH'] == 0){$value = 0;}
					if($qqrows['TTL_DEMURRAGE'] == 0){$value = $qqrows['TTL_DESPATCH'];}
					if($qqrows['TTL_DESPATCH'] == 0){$value = "-".$qqrows['TTL_DEMURRAGE'];} 
					$pdf->Row2(array("Shipper ".$j." ".$obj->getPortNameBasedOnID($rows5['LOADPORTID']),$obj->getNumberFormat($value),$obj->getNumberFormat(($value/$per_mt))));
					$j++;
				}
			}
		}
	}
	//$pdf->Ln(2);
	//$pdf->AddPage('P');
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Receiver",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$sql6 = "select * from fca_vci_dd_receiver where FCAID='".$obj->getFun1()."'";
	$res6 = mysql_query($sql6);
	$rec6 = mysql_num_rows($res6);
	if($rec6 == 0)
	{
		$pdf->Cell(190,6,strtoupper('sorry currently there are zero(0)  Records'),0,1,'C','1');
	}
	else
	{$i = 0;
	while($rows6 = mysql_fetch_assoc($res6))
		{
			$pdf->SetAligns($arr7);
			$pdf->SetWidths($arr8);
			$qqsql1 = "select * from laytime_master where MAPPINGID='".$mappingid."' and LOGIN='TRADERS' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' and PORT='DP' and PORTID='".$rows6['LOADPORTID']."' and ENTITY='Receiver' and APPLICABLE_STATUS=1 and SUBMITID=2"; 
			$qqres1 = mysql_query($qqsql1);
			$qqrec1 = mysql_num_rows($qqres1);
			if($qqrec1 == 0)
			{
				$pdf->Row2(array("Discharge Port  ".$obj->getPortNameBasedOnID($rows6['LOADPORTID']),$obj->getNumberFormat($rows6['COST']),$obj->getNumberFormat($rows6['COST_MT'])));
			}
			else
			{
				$j=1;while($qqrows1 = mysql_fetch_assoc($qqres1))
				{
					if($qqrows1['TTL_DEMURRAGE'] == 0 && $qqrows1['TTL_DESPATCH'] == 0){$value1 = 0;}
					if($qqrows1['TTL_DEMURRAGE'] == 0){$value1 = $qqrows1['TTL_DESPATCH'];}
					if($qqrows1['TTL_DESPATCH'] == 0){$value1 = "-".$qqrows1['TTL_DEMURRAGE'];} 
					$pdf->Row2(array("Receiver ".$j." ".$obj->getPortNameBasedOnID($rows6['LOADPORTID']),$obj->getNumberFormat($value1),$obj->getNumberFormat(($value1/$per_mt))));
					$j++;
				}
			}
		}
	}
	
	$pdf->SetFont('Arial','B',10);
	$pdf->SetTextColor(27,119,166);
	$pdf->Cell(190,6,"Demurrage Dispatch Nett Results",0,1,'L');
	
	$pdf->SetFont('Arial','B',8);
	$pdf->SetTextColor(255,255,255);
	$pdf->SetFillColor(27,119,166);
	$pdf->SetDrawColor(255,255,255);
	
	$pdf->SetAligns($arr7);
	$pdf->SetWidths($arr8);
	$pdf->Row2(array("","Cost","Cost/MT"));
	
	$pdf->SetFont('Arial','',7);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->SetFillColor(255,255,255);
	
	$pdf->Row2(array("Load Port",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_LP_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_LP_COSTMT"))));
	$pdf->Row2(array("Discharge Port",$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_DP_COST")),$obj->getNumberFormat($obj->getFreightEstimationTotalVCIRecords($obj->getFun1(),"DDNR_DP_COSTMT"))));

}

$filename = $obj->getVesselIMOData($obj->getCompareEstimateData($comid,"VESSEL_IMO_ID"),"VESSEL_NAME").' '.$obj->getFun5().' '.date("d-M-Y",time()).'.pdf';
$pdf->Output($filename,'D');
}


function create_generate_agency_app_letter_pdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['gen_agency_id'])){$g_agency_id = $_REQUEST['gen_agency_id']; }
//Create a new PDF file

	class PDF extends FPDF
	{
		
		function Header()
		{
			$obj = new data();
			$obj->funConnect();
			$this->SetFillColor(255,255,255);
			$image_path1 = '../../img/slogo.jpg';
			$this->Image($image_path1,83,5,40,18);
			$this->SetTextColor(27,119,166);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',25);
			$this->SetX(20);
			$this->SetY(7);
			$this->SetX(21);
			
			$this->Ln(1);
			$this->SetFont('Arial','',10);
			$this->SetX(20);
			$this->Cell(170,6,"",0,1,'C',0);
			$this->SetTextColor(177,175,175);
		    $this->Ln(12);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(2);
		}
			
		function Footer()
		{
			$this->SetY(-20);
			$this->SetFillColor(255,255,255);
			$this->SetTextColor(177,175,175);
			$this->SetFont('Arial','',10);
			$this->SetX(0);
			$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
			$this->Ln(1);
			$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
			$this->SetFont('daxcondensedlight','',8);
			$this->SetTextColor(027,119,166);
			$this->Ln(1);
			$obj = new data();
			$this->Cell(0,4,$obj->getCompanyNameBasedOnID($_SESSION['company'],"ADDRESS"),0,1,'C');
			$this->Cell(0,4,"Tel: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"PHONE_NO")."  email: ".$obj->getCompanyNameBasedOnID($_SESSION['company'],"EMAIL_ID"),0,1,'C');
			
		}
	}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Agency Letter Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Agency Letter Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

$sql = "select * from generate_agency_letter where GEN_AGENCY_ID='".$g_agency_id."'";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(128,128,128);
$pdf->SetDrawColor(238,238,238);
$pdf->SetFillColor(255,255,255);

$pdf->Cell(25,6,"Date",0,0,'L');
$pdf->Cell(5,6,":",0,0,'L');
$pdf->Cell(160,6,date("d-M-Y",strtotime($rows['DATE'])),0,1,'L');
$pdf->Ln(1);
$pdf->Cell(190,6,"To,",0,1,'L');
$pdf->Ln(1);
$pdf->Cell(4,6,"",0,0,'L');
$pdf->Cell(186,6,$obj->getVendorListNewBasedOnID($rows['VENDORID']),0,1,'L');
$arr1=array('L','L');
$arr2=array(4,90);
$arr3=array("",$obj->getVendorListNewData($rows['VENDORID'],"ADDRESS"));
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row1($arr3);
$pdf->Ln(3);
$pdf->Cell(25,6,"Kind Attn",0,0,'L');
$pdf->Cell(5,6,":",0,0,'L');
$pdf->Cell(160,6,$rows['KIND_ATTN_TO'],0,1,'L');
$pdf->Ln(3);

if($rows['PORT'] == "LP"){$port = "Load";}
else if($rows['PORT'] == "DP"){$port = "Discharge";}

$pdf->MultiCell(190,6,"Subject                   :    ( ".$obj->getVesselIMOData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESSEL_NAME")." ) Agency appointment for ( ".$port." ) of about ( ".$rows['QTY']." ) MT of ( ".$obj->getContractMaterialTypeBasedOnID($obj->getMappingData($rows['MAPPINGID'],"CARGO_POSITION"),$obj->getMappingData($rows['MAPPINGID'],"CARGO_IDS"))." ) at the port of ( ".$obj->getPortNameBasedOnID($rows['PORTID'])." ) .",0,'L',1);
$pdf->Ln(3);

$sql1 = "select FEE from agency_fee_record_master where AGENTMASTERID='".$rows['VENDORID']."' and PORTID='".$rows['PORTID']."'";
$res1 = mysql_query($sql1);
$rows1 = mysql_fetch_assoc($res1);

$pdf->MultiCell(190,6,"This is with reference to your PDA, we are pleased to appoint you as vessel agent to handle above vessel calling at ( ".$obj->getPortNameBasedOnID($rows['PORTID'])." ) for [ ".$port." ]      ( ".$obj->getContractMaterialTypeBasedOnID($obj->getMappingData($rows['MAPPINGID'],"CARGO_POSITION"),$obj->getMappingData($rows['MAPPINGID'],"CARGO_IDS"),$obj->getMappingData($rows['MAPPINGID'],"SHIPPING_STAGE"),$obj->getMappingData($rows['MAPPINGID'],"LINE_ITEM_NO"))." ) with a lump sum agency fee & other charges (including in/ out clearance, documentation, telecom & communication, misc. expenses, transport, conveyance, postage etc) of ( USD ".$rows1['FEE'].") plus actual cost as per port invoices. Any expenses not supported by port invoices, will be part of above lump sum agency fees.",0,'L',1);

$pdf->Ln(3);
$pdf->MultiCell(190,6,"The contact details of the vessel are -",0,'L',1);

$pdf->Ln(3);
$pdf->MultiCell(190,6,"Satcom Phone No.      :      ".$obj->getVesselData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESS_PHONE_NO"),0,'L',1);
$pdf->MultiCell(190,6,"Fax No.                         :      ".$obj->getVesselData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESS_FAX_NO"),0,'L',1);
$pdf->MultiCell(190,6,"Telex No.                      :      ".$obj->getVesselData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESS_TELEX_NO"),0,'L',1);
$pdf->MultiCell(190,6,"Email Address             :      ".$obj->getVesselData($obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID"),"VESS_EMAIL_ADD"),0,'L',1);

$pdf->Ln(3);
$pdf->MultiCell(190,6,"Please do the needful so that the vessel can be berthed on soonest possible after her arrival and please contact directly the Master for any further information required. Following operational instructions to be followed strictly:",0,'L',1);
$pdf->MultiCell(190,6,"  a)    Proper relevant instructions to the master to be given in writing under copy to us.",0,'L',1);
$pdf->MultiCell(190,6,"  b)    Daily message to be sent to us regarding documentation formalities / expected berthing of the vessel / vessel movements when the vessel is in port and other critical matters.",0,'L',1);
$pdf->MultiCell(190,6,"  c)    NOR to all the concerned parties to be tendered immediately upon arrival until and unless instructed otherwise by BW.",0,'L',1);
$pdf->MultiCell(190,6,"  d)    Free Pratique certificate from the port authorities should be obtained on the same date and time of vessel’s arrival.",0,'L',1);
$pdf->MultiCell(190,6,"  e)    Copies of any documentation not to be shared with owners / master or third parties without taking permission from BW.",0,'L',1);
$pdf->MultiCell(190,6,"  f)    Draft copy of the Statement of Facts to be sent for our perusal atleast two to three days prior to vessel completion. BW’s interest to be fully protected for all the remarks entered by vessel / shippers / receivers.",0,'L',1);
$pdf->MultiCell(190,6,"  g)    Any services given to the master / owners eg: Fresh Water supply, crew medical expenses or other amenities supplied to the vessel on owner’s behalf is to be charged and recovered directly from the master / owners of the vessel. BW takes no responsibility of reimbursing such expenses if the same are not recovered by the agents directly.",0,'L',1);
$pdf->MultiCell(190,6,"  h)    No sundry expense to be incurred without taking a prior approval from BW other than that mentioned and approved by BW in the Performa Disbursement Account.",0,'L',1);

$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(128,128,128);
$pdf->Ln(4);
$pdf->MultiCell(190,6,"Please confirm as above per return and arrange the original port invoices as early as possible after sailing of the vessel to remit the balance amount towards final payment. We look forward for smooth operations on the vessel during her stay at the port.",0,'L',1);

$pdf->Ln(3);
$pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(128,128,128);
$pdf->MultiCell(190,6,"Thanks and Best Regards",0,'L',1);
$pdf->MultiCell(190,6,$obj->getCompanyNameBasedOnID($_SESSION['company'],'COMPANY_NAME'),0,'L',1);

$id = $obj->getVesselOpenEntryDeta($obj->getMappingData($rows['MAPPINGID'],"OPEN_VESSEL_ID"),"VESSEL_IMO_ID");


$pdf->AddPage('P');

$arr1 = $arr2 = $arr3 = array();	
$pdf->SetFont('Arial','B',10);
$pdf->SetFillColor(128,128,128);
$pdf->SetTextColor(255,255,255);
$pdf->SetDrawColor(238,238,238);
$arr1=array('L','L');
$arr2=array(10,181);
$arr3=array("1.","CHAPTER 8");
$pdf->SetAligns($arr1);
$pdf->SetWidths($arr2);
$pdf->Row2($arr3);

$pdf->SetFont('Arial','',8);
$pdf->SetFillColor(255,255,255);
$pdf->SetTextColor(0,0,0);
$arr1=array('L','L','L');
$arr2=array(10,90,91);
$arr3[1]=array('1.1','NAME',strtoupper($obj->getVesselIMOData($id,"VESSEL_NAME")));
$arr3[2]=array('1.2','TYPE',$obj->getVesselTypeBasedOnID($obj->getVesselParticularData('VESSEL_TYPE','vessel_imo_master',$id)));

if(date("M, Y",strtotime($obj->getVesselIMOData($id,"YEARBUILT"))) == 'Jan, 1970')
{
	$built_date = '';
}
else
{
	$built_date = date("M, Y",strtotime($obj->getVesselIMOData($id,"YEARBUILT")));
}

$arr3[3]=array('1.3','BUILT DATE',$obj->getVesselIMOData($id,"YEARBUILT"));
$arr3[4]=array('1.4','FLAG',$obj->getCountryNameOnId($obj->getVesselParticularData('FLAG','vessel_imo_master',$id)));
$arr3[5]=array('1.5','SUMMER DWAT',$obj->getVesselIMOData($id,"DWT"));
$arr3[6]=array('1.6','SUMMER DRAFT',$obj->getVesselIMOData($id,"DRAFTM"));
$arr3[7]=array('1.7','LOA (M)',$obj->getVesselParticularData('LOA','vessel_imo_master',$id));
$arr3[8]=array('1.8','EXTREME BREADTH (M)',$obj->getVesselParticularData('EXT_BREADTH','vessel_imo_master',$id));
$arr3[9]=array('1.9','GRT / NRT : International',$obj->getVesselParticularData('GRT_NRT','vessel_imo_master',$id));
//$arr3[10]=array('1.10','NRT',$obj->getVesselParticularData('NRT','vessel_master_8',$_REQUEST['id']));
//$arr3[10]=array('1.10','GRAIN (M³)',$obj->getVesselParticularData('GRAIN','vessel_master_8',$id));
//$arr3[11]=array('1.11','BALE (M³)',$obj->getVesselParticularData('BALE','vessel_master_8',$id));
//$arr3[12]=array('1.12','NUMBER OF HOLDS',$obj->getVesselParticularData('NOH','vessel_master_4',$id));
//$arr3[13]=array('1.13','NUMBER OF HATCHES',$obj->getVesselParticularData('NOHA','vessel_master_4',$id));
//$arr3[14]=array('1.14','HATCH SIZES (METRES)',$obj->getVesselParticularData('HATCH_SIZE','vessel_master_4',$id));
//$arr3[15]=array('1.15','CARGO GEAR (MAIN DETAILS)',$obj->getVesselParticularData('MAKE_TYPE','vessel_master_4',$id));
//$arr3[16]=array('1.16','CRANE SIZE',$obj->getVesselParticularData('NOCS','vessel_master_4',$id));
//$arr3[17]=array('1.17','GRAB (MAIN DETAILS)',$obj->getVesselParticularData('TYPE_CAP','vessel_master_4',$id));
$arr3[18]=array('1.10','IMO NUMBER',$obj->getVesselParticularData('IMO_NO','vessel_imo_master',$id));
$arr3[19]=array('1.11','NAME OF OWNERS P AND I INSURERS',$obj->getVesselParticularData('P_I','vessel_imo_master',$id));
$arr3[20]=array('1.12','NAME OF CLASSIFICATION SOCIETY',$obj->getClaSocNameOnId($obj->getVesselParticularData('CLA_SOC_ID','vessel_imo_master',$id)));

for($i=1;$i<21;$i++)
{
	$pdf->SetAligns($arr1);
	$pdf->SetWidths($arr2);
	$pdf->Row2($arr3[$i]);
	unset($arr3[$i]);
}

$filename = 'Agency Appointment Letter.pdf';
$pdf->Output($filename,'D');
}


function create_port_positions_pdf()
{
	$obj = new data();
	$obj->funConnect();
	if(isset($_REQUEST['txtDate'])){$date = $_REQUEST['txtDate']; }
	if(isset($_REQUEST['selMType'])){$selMType = $_REQUEST['selMType']; }
	$_SESSION['date'] = $date;
	$_SESSION['selMType'] = $selMType;
	
	$selMType_1 = explode("@@@",$_REQUEST['selMType']);
	
	$_SESSION['selMType_1'] = $selMType_1[1];
	$_SESSION['date_1'] = date('Y-m-d', strtotime($date. '- 7 day'));
	
//Create a new PDF file

class PDF extends FPDF
		{
		
			function Header()
				{
					$obj = new data();
					$obj->funConnect();
					$this->SetFillColor(255,255,255);
					$image_path1 = '../../img/slogo.jpg';
					$this->Image($image_path1,83,5,40,18);
					$this->SetTextColor(27,119,166);
					$this->AddFont("daxcondensedlight",'',"daxcondensedlight.php");
					$this->SetFont('daxcondensedlight','',25);
					$this->SetX(20);
					$this->SetY(7);
					$this->SetX(21);
					
					$this->Ln(1);
					$this->SetFont('Arial','',10);
					$this->SetX(20);
					$this->Cell(170,6,"",0,1,'C',0);
					$this->SetTextColor(177,175,175);
					$this->Ln(12);
					$this->Cell(0,1,"___________________________________________________________________________________________________________________________________________________________________________",0,1,'C','1');
					$this->Ln(2);
					
					$this->SetFont('Arial','B',11);
					$this->SetTextColor(0,0,0);
					$this->Cell(190,10,"Weekly ".$obj->getMaterialCodeDesBasedOnCode($_SESSION['selMType_1'])." Report ".date("d-M-Y",strtotime($_SESSION['date'])),0,1,'C');
					$this->Ln(2);
					
					$arr1 = $arr2 = $arr3 = array();	
					$this->SetFont('Arial','B',9);
					$this->SetFillColor(128,128,128);
					$this->SetTextColor(255,255,255);
					$this->SetDrawColor(238,238,238);
					$arr1=array('L','L','L','L');
					$arr2=array(40,50,50,50);
					$arr3=array("PORT","UNDER LOADING","EXPECTED","LAST LOADED");
					$this->SetAligns($arr1);
					$this->SetWidths($arr2);
					$this->Row2($arr3);
				}
			
			function Footer()
				{
					$this->SetY(-5);
					//Select Arial italic 8
					$this->SetFont('Arial','',6);
					$this->SetFillColor(255,255,255);
					$this->SetTextColor(177,175,175);
					$this->Cell(152,4,"This report is a property of bw Singapore and no part may be copied or reproduced without their permission",0,0,'L');
					$image_path = '../../img/Logo2.jpg';
					$this->Image($image_path,160,292,3);
					$link='http://sevenoceansconsulting.com';
					$this->SetLink($link);
					$this->Write(4,' A Seven Oceans Holdings production',$link);
				}
				
		}
$pdf = new PDF();
$pdf->AddPage('P');
$pdf->SetDisplayMode('real','single');
$pdf->SetTitle('Certificate and Survey Pdf');
$pdf->SetAuthor('Seven Oceans Holdings');
$pdf->SetSubject('Certificate and Survey Pdf');
$pdf->SetKeywords('Designed and Developed By Seven Oceans Holdings pvt. Ltd.');

/*$sql = "select PORTCODE from global_port_position where (TRANS_DATE BETWEEN '".date("Y-m-d",strtotime($_SESSION['date_1']))."' and '".date("Y-m-d",strtotime($_SESSION['date']))."') and MATERIAL_CODE='".$_SESSION['selMType']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' group by PORTCODE";*/

$sql = "select PORTCODE from global_port_position where MATERIAL_CODE='".$_SESSION['selMType']."' and MODULEID='".$_SESSION['moduleid']."' and MCOMPANYID='".$_SESSION['company']."' group by PORTCODE";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
if($rec == 0)
{
	$pdf->SetFont('Arial','B',7);
	$pdf->SetFillColor(238,238,238);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$pdf->Cell(190,6,"SORRY CURRENTLY THERE ARE ZERO(0) RECORDS FOUND",0,1,'C',1);
}
else
{
	$pdf->SetFont('Arial','',6);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetDrawColor(238,238,238);
	$j = 11;
	while($rows = mysql_fetch_assoc($res))
	{
		if($rows['PORTCODE'] == "AE06"){$i=0;}
		else if($rows['PORTCODE'] == "KW01"){$i=1;}
		else if($rows['PORTCODE'] == "QA02"){$i=2;}
		else if($rows['PORTCODE'] == "QA01"){$i=3;}
		else if($rows['PORTCODE'] == "SA01"){$i=4;}
		else if($rows['PORTCODE'] == "IR04"){$i=5;}
		else if($rows['PORTCODE'] == "IR03"){$i=6;}
		else if($rows['PORTCODE'] == "IR08"){$i=7;}
		else if($rows['PORTCODE'] == "IR01"){$i=8;}
		else if($rows['PORTCODE'] == "IR07"){$i=9;}
		else if($rows['PORTCODE'] == "BH05"){$i=10;}
		else {$i = $j++;}
		$arr4[]= array( 'id' => $i,'PORTCODE' => $rows['PORTCODE']);	
	}
	$arr4 = msort($arr4, array('id'));
	//echo "<pre>";print_r($arr4);die();
	for($k=0;$k<count($arr4);$k++)
	{
		$arr1 = $arr2 = $arr3 = array();	
		$i=$k+1;
		if($i % 2 == 0)
		{
			$pdf->SetFillColor(244,244,244);
		}
		else
		{
			$pdf->SetFillColor(255,255,255);
		}
		$arr1=array('L','L','L','L');
		$arr2=array(40,50,50,50);
		$arr3= array(strtoupper($obj->getPortNameBasedOnCode($arr4[$k]['PORTCODE'])),$obj->getPortPositionDataUnder($arr4[$k]['PORTCODE'],$_SESSION['date'],$_SESSION['selMType']),$obj->getPortPositionDataExpected($arr4[$k]['PORTCODE'],$_SESSION['date'],$_SESSION['selMType']),$obj->getPortPositionDataLast($arr4[$k]['PORTCODE'],$_SESSION['date'],$_SESSION['selMType']));
		$pdf->SetAligns($arr1);
		$pdf->SetWidths($arr2);
		$pdf->Row2($arr3);
	}
}

$filename = 'Vessels in Port '.date("d M Y",time()).'.pdf';
$pdf->Output($filename,'D');
}

function msort($array, $key, $sort_flags = SORT_REGULAR) {
    if (is_array($array) && count($array) > 0) {
        if (!empty($key)) {
            $mapping = array();
            foreach ($array as $k => $v) {
                $sort_key = '';
                if (!is_array($key)) {
                    $sort_key = $v[$key];
                } else {
                    foreach ($key as $key_key) {
                        $sort_key .= $v[$key_key];
                    }
                    $sort_flags = SORT_REGULAR;
                }
                $mapping[$k] = $sort_key;
            }
            asort($mapping, $sort_flags);
            $sorted = array();
            foreach ($mapping as $k => $v) {
                $sorted[] = $array[$k];
            }
            return $sorted;
        }
    }
    return $array;
}





?>