".$sql_bof.""; $result_bof = mysql_query($sql_bof) or die("sql_bof records error".mysql_error()); while($fields_bof = mysql_fetch_array($result_bof,MYSQL_BOTH)) { $te_bofqty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_curcur = $fields_bof['sysrno']; $te_vsvexrateo = $fields_bof['vsvexrateo']; $te_vseexrateo = $fields_bof['vseexrateo']; $te_bolexrate = $fields_bof['bolexrate']; if($te_bolexrate>0) $te_invexrate = $te_bolexrate; else if($te_vseexrateo>0) $te_invexrate = $te_vseexrateo; else $te_invexrate = $te_vsvexrateo; if($te_invexrate<=0) { echo "
Exchange rate not found ..?

<< Back
"; die(); } $te_bofamount = 0; if($te_curcur == "USD") { $te_bofamount = $te_bofqty*$te_bofrate*$te_invexrate; } elseif($te_curcur == "LKR") { $te_bofamount = $te_bofqty*$te_bofrate; } else { $te_bofamount = $te_bofqty*$te_bofrate*$te_bofexrate; } $te_invlkramt = $te_invlkramt + $te_bofamount; } $te_invtot_old = $te_invlkramt; $print_flag = "Y"; $sql_pih = "select pilhamt from pihmast left join pilhmast on pihsno=pilhpihsno where pihbl = '$te_bolsnoauto' and pilhnoa = 'N'"; #echo "
".$sql_pih."
"; $result_pih = mysql_query($sql_pih) or die("sql_pih records error".mysql_error()); if(mysql_num_rows($result_pih)) { $te_pilhamt_tot = 0; while ($fields_pih = mysql_fetch_array($result_pih,MYSQL_BOTH)) { $te_pilhamt = $fields_pih['pilhamt']; $te_pilhamt_tot = $te_pilhamt_tot + $te_pilhamt; } if($te_pilhamt_tot<=$te_invlkramt) { $print_flag = "N"; } else { $te_dif_tot = $te_pilhamt_tot - $te_invlkramt; } } if($print_flag == "N") { echo "
Not Required...!
INV Amount = $te_invlkramt [LKR], PIH Amount = $te_pilhamt_tot [LKR]


<< Back
"; die(); } } //==================================================================================== if(isset($_POST['save']) || isset($_POST['draft'])) { $te_vsvsno = $_POST['vsvsno']; $te_bolsno = $_POST['bolsno']; $te_bolydn = $_POST['bolydn']; if($te_bolydn=="") { $te_vsvsno = $_POST['vsvsno']; $te_vsvsnoauto = $_POST['vsvsnoauto']; $te_bolsno = $_POST['bolsno']; $te_bolsnoauto = $_POST['bolsnoauto']; $sql_bolydn = "select bolydn,bolcapyn,bolucdame from bolmast where bolvsvsno='$te_vsvsno' and bolsno='$te_bolsno'"; $result_bolydn = mysql_query($sql_bolydn) or die("SQL Error sql_bolydn"); $fields_bolydn = mysql_fetch_array($result_bolydn, MYSQL_BOTH); $te_bolydn = $fields_bolydn['bolydn']; $te_bolcapyn = $fields_bolydn['bolcapyn']; $te_bolucdame = $fields_bolydn['bolucdame']; } else { $te_bolydn = $_POST['bolydn']; $sql_bolvsv = "select bolvsvsno,bolsno,bolblno,vsvvsv vsvsnoauto,bolcapyn,bolucdame from bolmast left join vsvmast on bolvsvsno=vsvsno where bolydn='$te_bolydn'"; $result_bolvsv = mysql_query($sql_bolvsv) or die("SQL Error sql_bolvsv"); $fields_bolvsv = mysql_fetch_array($result_bolvsv, MYSQL_BOTH); $te_vsvsno = $fields_bolvsv['bolvsvsno']; $te_bolsno = $fields_bolvsv['bolsno']; $te_vsvsnoauto = $fields_bolvsv['vsvsnoauto']; $te_bolsnoauto = $fields_bolvsv['bolblno']; $te_bolcapyn = $fields_bolvsv['bolcapyn']; $te_bolucdame = $fields_bolvsv['bolucdame']; } if(($te_bolcapyn=='Y') and ($te_bolucdame=="")) { die("
B/L Number $te_bolsnoauto is not Confirm..! Please Confirm this B/L Number ..!
"); } //echo "

$te_vsvsno $te_bolsno $te_bolydn

"; if($te_vsvsno==""||$te_bolsno==""||$te_bolydn=="") { echo "
Code not found

<< Back
"; die(); } } if(isset($_POST['save'])||isset($_POST['draft'])) { $te_comsno = $_POST['comsno']; $te_vsvsno = $_POST['vsvsno']; $te_bolsno = $_POST['bolsno']; $te_bolshpsno = $_POST['bolshpsno']; $te_bolcopsno = $_POST['bolcopsno']; $te_invddt = $te_invddt_server; $te_totamount = $_POST['invtot']; $te_invexrate = $_POST['invexrate']; $te_invofpterm = $te_invofpterm; $te_citcount = $_POST['knumrow']; for($i=0;$i<$te_citcount;$i++) { if(isset($_POST['select'][$i])) { $te_bofsno = $_POST['bofsno'][$i]; $sql_chkbof = "select bofsno from bofmast where bofsno='$te_bofsno'"; //echo "$sql_chkbof
"; $result_chkbof = mysql_query($sql_chkbof) or die("Could not Check bofmast - Prepaid :
".mysql_error()); if(!mysql_num_rows($result_chkbof)) { echo "
While you are working on invoice this B/L was amended

<< Back
"; die(); } } } } //--------------------------------------[ Printing ]--------------------------------------// if(isset($_POST['save'])) { if($te_invdno!=next_dno($te_usdcomsno,$te_comsno)) { $te_newdnoyn = "Y"; $te_invdno_old = $te_invdno; } else { $te_newdnoyn = "N"; } $te_pihsno = $_POST['pihsno']; $te_invdno = next_dno($te_usdcomsno,$te_comsno); $sql_inv = "insert into invmast (invmvc,invcomsno,invactcomsno,invdno,invddt,invextrayn,invpihsno, invbolsno,invconsno,invamt,invactamt, invusd,invram,invexrate,invofpterm,invpfl, invucdnew,inventddt,inventtime) values ('O','$te_usdcomsno','$te_comsno','$te_invdno','$te_invddt','Y','$te_pihsno', '$te_bolsno','$te_bolshpsno','".round($te_totamount)."','$te_totamount', '$te_totamountUSD','0.00','$te_invexrate','$te_invofpterm','P', '$te_invucdnew','$te_inventddt','$te_inventtime')"; $te_invsno = next_auto_increment('invmast'); //echo "$sql_inv
"; $result_inv = mysql_query($sql_inv) or die("Could not insert Invoice :
".mysql_error()); $te_invbofamt = 0; for($i=0;$i<$te_citcount;$i++) { if(isset($_POST['select'][$i])) { $te_bofsno = $_POST['bofsno'][$i]; $te_bofinvamt= $_POST['invchgamt'][$i]; $sql_bofinv = "update bofmast set bofextrayn='Y', bofinvsno='$te_invsno', bofinvamt='$te_bofinvamt' where bofsno='$te_bofsno'"; //echo "$sql_bofinv
"; $result_bofinv = mysql_query($sql_bofinv) or die("Could not Update bofmast - Prepaid"); $te_invbofamt+=$te_bofinvamt; } } $sql_invupd = "update invmast set invamt = '".round($te_invbofamt)."', invextrayn= 'Y', invactamt = '$te_invbofamt', invucdame = '$te_invucdnew', invameddt = '$te_inventddt', invametime= '$te_inventtime' where invsno = '$te_invsno'"; $result_invupd = mysql_query($sql_invupd) or die("Could not update invmast"); //Update collect charges----------------------------------------------------------------------------------------// $sql_cchg = "update bofmast set bofextrayn='Y', bofinvsno='$te_invsno' where bofvsvsno='$te_vsvsno' and bofbolsno='$te_bolsno' and bofinvsno<=0 and bofpoc='C'"; $result_cchg = mysql_query($sql_cchg) or die("Could not Update bofmast - Collect"); if(!isset($_POST['print'])) { if($te_newdnoyn=='Y') { echo "
Could not get Invoice No : '$te_invdno_old'
"; } echo "

Invoice No : $te_invdno Saved..!

"; } }//save if((isset($_POST['print'])||isset($_POST['rprint'])||(isset($_POST['draft'])))&&(!isset($_POST['display']))) { if(isset($_POST['rprint'])) { $te_invsno = $_POST['invsno']; $te_rpyn = "Y"; //echo "$te_invsno
"; } //------------------------------------------------ [ Printing ] ------------------------------------------------// $py=396; $px=612; $ly=9999; $pdf = pdf_new(); pdf_open_file($pdf,""); if ($ly > $py-100) { if(isset($_POST['draft'])) p_heading('drf'); else p_heading('inv'); } $ch=10; $te_totamount = 0; $te_totamountUSD = 0; $te_amountLOCAL = 0; $te_amountUSD = 0; $stack_key = array(); //key - citshodes $stack_cit = array(); //citdes $stack_eqt = array(); //eqt $stack_cur = array(); //Cur $stack_qty = array(); //QTY $stack_rate = array(); //Original Rate $stack_poc = array(); //Prepaid or Collect $stack_unt = array(); //Prepaid or Collect $sql_tmp = "CREATE TEMPORARY TABLE tmpmast ( tmpsno INT(4) NOT NULL auto_increment, tmpcitshodes varchar(12) NOT NULL, tmpcituntsno INT(4) NOT NULL , tmpbofrate double(8,2) NOT NULL , tmpbofexrate double(8,2) NOT NULL , tmpeqteqt varchar(12) NOT NULL , tmpcurcur varchar(8) NOT NULL , tmppoc varchar(1) NOT NULL , tmpcitdes varchar(25) NOT NULL , tmpqty double(11,3) NOT NULL , PRIMARY KEY (tmpcitshodes,tmpcituntsno,tmpbofrate, tmpeqteqt,tmpcurcur,tmppoc,tmpbofexrate), UNIQUE KEY tmpsno (tmpsno) )"; $result_tmp = mysql_query($sql_tmp) or die("Could not create tempery file : sql_tmp".mysql_error()); if(isset($_POST['draft'])) { for($d=0;$d<$te_citcount;$d++) { $te_bofsno = $_POST['bofsno'][$d]; if(isset($_POST['select'][$d])) { $sql_bof = "select bofqty,bofrate,bofpoc,bofexrate,citshodes,citdes,cituntsno, concat(eqteqt,' - ',eqttyp) eqteqt,sysrno curcur from (((bofmast left join citmast on bofcitsno=citsno) left join eqtmast on bofeqtsno=eqtsno) left join sysmast on bofcursno=syssno) where bofsno='$te_bofsno'"; //echo "$sql_bof
"; $result_bof = mysql_query($sql_bof) or die("SQL Error sql_bof"); $fields_bof = mysql_fetch_array($result_bof, MYSQL_BOTH); $te_qty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_bofpoc = $fields_bof['bofpoc']; $te_bofexrate = $fields_bof['bofexrate']; $te_citdes = $fields_bof['citdes']; $te_citshodes = $fields_bof['citshodes']; $te_cituntsno = $fields_bof['cituntsno']; $te_eqteqt = $fields_bof['eqteqt']; $te_curcur = $fields_bof['curcur']; if($te_bofrate>0) { $sql_check = "select tmpsno from tmpmast where tmpcitshodes='$te_citshodes' and tmpcituntsno='$te_cituntsno' and tmpbofrate='$te_bofrate' and tmpeqteqt='$te_eqteqt' and tmpcurcur='$te_curcur' and tmppoc='$te_bofpoc' and tmpbofexrate*1='$te_bofexrate'"; //echo "$sql_check
"; $result_check = mysql_query($sql_check) or die("SQL Error sql_check :
".mysql_error()); $fields_check = mysql_fetch_array($result_check,MYSQL_BOTH); $te_tmpsno = $fields_check['tmpsno']; if(mysql_num_rows($result_check)) { $sql_tmpupd = "update tmpmast set tmpqty = (tmpqty + $te_qty) where tmpsno='$te_tmpsno'"; $result_tmpupd = mysql_query($sql_tmpupd) or die("SQL Error sql_tmpupd 1 :
".mysql_error()); } else { $sql_tmpadd = "insert into tmpmast (tmpcitshodes,tmpcituntsno,tmpbofrate,tmpbofexrate, tmpeqteqt,tmpcurcur,tmppoc,tmpcitdes,tmpqty) values ('$te_citshodes','$te_cituntsno','$te_bofrate','$te_bofexrate', '$te_eqteqt','$te_curcur','$te_bofpoc','$te_citdes','$te_qty')"; $result_tmpadd = mysql_query($sql_tmpadd) or die("SQL Error sql_tmpadd 1 :
".mysql_error()); } /* if(in_array($te_citshodes, $stack_key)&&in_array($te_bofrate, $stack_rate)&& in_array($te_eqteqt, $stack_eqt)&&in_array($te_curcur, $stack_cur)&&in_array($te_bofpoc, $stack_poc)) { $key = array_search($te_citshodes, $stack_key); $stack_qty[$key] += $te_qty; } else { //echo "$sysrno----"; array_push($stack_key,$te_citshodes); array_push($stack_unt,$te_cituntsno); array_push($stack_qty,$te_qty); array_push($stack_rate,$te_bofrate); array_push($stack_cit,$te_citdes); array_push($stack_eqt,$te_eqteqt); array_push($stack_cur,$te_curcur); array_push($stack_poc,$te_bofpoc); } */ } }//is checked }//for //---------------------------------------------------------------------------------------------------------------// $sql_bof = "select bofqty,bofrate,bofpoc,bofexrate,citshodes,citdes,cituntsno, concat(eqteqt,' - ',eqttyp) eqteqt,sysrno from (((bofmast left join citmast on bofcitsno=citsno) left join eqtmast on bofeqtsno=eqtsno) left join sysmast on bofcursno=syssno) where bofbolsno='$te_bolsno' and bofpoc='C' and bofinvsno<=0"; //echo "$sql_bof
"; $result_bof = mysql_query($sql_bof) or die("SQL Error sql_bof"); while($fields_bof = mysql_fetch_array($result_bof, MYSQL_BOTH)) { $te_qty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_bofpoc = $fields_bof['bofpoc']; $te_bofexrate = $fields_bof['bofexrate']; $te_cituntsno = $fields_bof['cituntsno']; $te_citdes = $fields_bof['citdes']; $te_citshodes = $fields_bof['citshodes']; $te_eqteqt = $fields_bof['eqteqt']; $te_curcur = $fields_bof['sysrno']; if($te_bofrate>0) { $sql_check = "select tmpsno from tmpmast where tmpcitshodes='$te_citshodes' and tmpcituntsno='$te_cituntsno' and tmpbofrate='$te_bofrate' and tmpeqteqt='$te_eqteqt' and tmpcurcur='$te_curcur' and tmppoc='$te_bofpoc' and tmpbofexrate*1='$te_bofexrate'"; //echo "$sql_check
"; $result_check = mysql_query($sql_check) or die("SQL Error sql_check :
".mysql_error()); $fields_check = mysql_fetch_array($result_check,MYSQL_BOTH); $te_tmpsno = $fields_check['tmpsno']; if(mysql_num_rows($result_check)) { $sql_tmpupd = "update tmpmast set tmpqty = (tmpqty + $te_qty) where tmpsno='$te_tmpsno'"; $result_tmpupd = mysql_query($sql_tmpupd) or die("SQL Error sql_tmpupd 2 :
".mysql_error()); } else { $sql_tmpadd = "insert into tmpmast (tmpcitshodes,tmpcituntsno,tmpbofrate,tmpbofexrate,tmpeqteqt, tmpcurcur,tmppoc,tmpcitdes,tmpqty) values ('$te_citshodes','$te_cituntsno','$te_bofrate','$te_bofexrate','$te_eqteqt', '$te_curcur','$te_bofpoc','$te_citdes','$te_qty')"; $result_tmpadd = mysql_query($sql_tmpadd) or die("SQL Error sql_tmpadd 2 :
".mysql_error()); } /* if(in_array($te_citshodes, $stack_key)&&in_array($te_bofrate, $stack_rate)&& in_array($te_eqteqt, $stack_eqt)&&in_array($te_curcur, $stack_cur)&&in_array($te_bofpoc, $stack_poc)) { $key = array_search($te_citshodes, $stack_key); $stack_qty[$key] += $te_qty; } else { //echo "$sysrno----"; array_push($stack_key,$te_citshodes); array_push($stack_unt,$te_cituntsno); array_push($stack_qty,$te_qty); array_push($stack_rate,$te_bofrate); array_push($stack_cit,$te_citdes); array_push($stack_eqt,$te_eqteqt); array_push($stack_cur,$te_curcur); array_push($stack_poc,$te_bofpoc); } */ } } //---------------------------------------------------------------------------------------------------------------// }//DRAFT else { $sql_bof = "SELECT bofqty,bofrate,bofpoc,bofexrate,citdes,citshodes,cituntsno, concat(eqteqt,' - ',eqttyp) eqteqt,sysrno from((((invmast left join bofmast on bofinvsno = invsno) left join citmast on bofcitsno = citsno) left join eqtmast on bofeqtsno = eqtsno) left join sysmast on bofcursno = syssno) where invsno='$te_invsno' order by citdes"; //echo "$sql_bof
"; $rec_bof = mysql_query($sql_bof) or die("no bof records"); while($fields_bof = mysql_fetch_array($rec_bof,MYSQL_BOTH)) { $te_qty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_bofexrate = $fields_bof['bofexrate']; $te_bofpoc = $fields_bof['bofpoc']; $te_citdes = $fields_bof['citdes']; $te_citshodes = $fields_bof['citshodes']; $te_cituntsno = $fields_bof['cituntsno']; $te_eqteqt = $fields_bof['eqteqt']; $te_curcur = $fields_bof['sysrno']; //echo "$te_bofpoc
"; if($te_bofrate>0) { $sql_check = "select tmpsno from tmpmast where tmpcitshodes='$te_citshodes' and tmpcituntsno='$te_cituntsno' and tmpbofrate='$te_bofrate' and tmpeqteqt='$te_eqteqt' and tmpcurcur='$te_curcur' and tmppoc='$te_bofpoc' and tmpbofexrate*1='$te_bofexrate'"; //echo "$sql_check
"; $result_check = mysql_query($sql_check) or die("SQL Error sql_check :
".mysql_error()); $fields_check = mysql_fetch_array($result_check,MYSQL_BOTH); $te_tmpsno = $fields_check['tmpsno']; if(mysql_num_rows($result_check)) { $sql_tmpupd = "update tmpmast set tmpqty = (tmpqty + $te_qty) where tmpsno='$te_tmpsno'"; $result_tmpupd = mysql_query($sql_tmpupd) or die("SQL Error sql_tmpupd 3 :
".mysql_error()); } else { $sql_tmpadd = "insert into tmpmast (tmpcitshodes,tmpcituntsno,tmpbofrate,tmpbofexrate, tmpeqteqt,tmpcurcur,tmppoc,tmpcitdes,tmpqty) values ('$te_citshodes','$te_cituntsno','$te_bofrate','$te_bofexrate', '$te_eqteqt','$te_curcur','$te_bofpoc','$te_citdes','$te_qty')"; $result_tmpadd = mysql_query($sql_tmpadd) or die("SQL Error sql_tmpadd 3 :
".mysql_error()); } /* //if(in_array($te_citshodes, $stack_key)) if(in_array($te_citshodes, $stack_key)&&in_array($te_bofrate, $stack_rate)&& in_array($te_eqteqt, $stack_eqt)&&in_array($te_curcur, $stack_cur)&&in_array($te_bofpoc, $stack_poc)) { $key = array_search($te_citshodes, $stack_key); $stack_qty[$key] += $te_qty; } else { array_push($stack_key,$te_citshodes); array_push($stack_unt,$te_cituntsno); array_push($stack_qty,$te_qty); array_push($stack_rate,$te_bofrate); array_push($stack_cit,$te_citdes); array_push($stack_eqt,$te_eqteqt); array_push($stack_cur,$te_curcur); array_push($stack_poc,$te_bofpoc); } */ } } }//NOT DRAFT //echo ""; /* for($s=0;$s".mysql_error()); $flg_frgcuryn = "n"; while($fld_tmpdis = mysql_fetch_array($result_tmpdis, MYSQL_BOTH)) { $te_citshodes = $fld_tmpdis['tmpcitshodes']; $te_cituntsno = $fld_tmpdis['tmpcituntsno']; //442-PERBL,443-PERCBM,441-PERCNT $te_bofqty = $fld_tmpdis['tmpqty']; $te_bofrate = $fld_tmpdis['tmpbofrate']; $te_bofexrate = $fld_tmpdis['tmpbofexrate']; $te_citdes = $fld_tmpdis['tmpcitdes']; $te_eqteqt = $fld_tmpdis['tmpeqteqt']; $te_curcur = $fld_tmpdis['tmpcurcur']; $te_bofpoc = $fld_tmpdis['tmppoc']; if($te_cituntsno==442) $te_eqteqt = "PER B/L"; if($te_cituntsno==443) $te_eqteqt = "PER CBM"; $te_amountUSD = ""; $te_amountLOCAL = ""; if($te_curcur=='LKR') { $te_amountUSD = ""; $te_amountLOCAL = $te_bofqty*$te_bofrate; } elseif($te_curcur=='USD') { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_amountUSD*$te_invexrate; } else { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_bofqty*$te_bofrate*$te_bofexrate; $flg_frgcuryn = "y"; } if($te_bofrate>0) { pdf_setfont($pdf, $font, 9); $lx=$spx+2; $cw=$ve_rect1[0]; pdf_show_xy($pdf,$te_citdes, $lx, $py-$ly); $lx=$lx+$cw; $cw=$ve_rect1[1]; pdf_show_xy($pdf," ".$te_eqteqt, $lx, $py-$ly); $lx=$lx+$cw; $cw=$ve_rect1[2]; $font = pdf_findfont($pdf, "Courier-Bold", "host", 0); pdf_setfont($pdf, $font, 10); if($te_cituntsno==443)//PERCBM pdf_show_xy($pdf, str_pad(number_format($te_bofqty,4),9," ",STR_PAD_LEFT) , $lx,$py-$ly); else pdf_show_xy($pdf, str_pad(number_format($te_bofqty),4," ",STR_PAD_LEFT) , $lx,$py-$ly); $lx=$lx+$cw; $cw=$ve_rect1[3]; pdf_show_xy($pdf, str_pad(number_format($te_bofrate,2),10," ",STR_PAD_LEFT) , $lx,$py-$ly); $lx=$lx+$cw; $cw=$ve_rect1[4]; $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 11); pdf_show_xy($pdf," ".$te_curcur, $lx, $py-$ly); $lx=$lx+$cw; $te_lx = $lx; $cw=$ve_rect1[5]; $font = pdf_findfont($pdf, "Courier-Bold", "host", 0); pdf_setfont($pdf, $font, 10); if($te_curcur == "LKR") { $lx+=$cw; pdf_show_xy($pdf," ", $lx, $py-$ly); } else { if($te_bofpoc=='C') { pdf_show_xy($pdf, str_pad(number_format($te_amountUSD,2),11," ",STR_PAD_LEFT) , $lx,$py-$ly); } $lx+=$cw; if($te_bofpoc=='P') { pdf_show_xy($pdf, str_pad(number_format($te_amountUSD,2),11," ",STR_PAD_LEFT) , $lx,$py-$ly); } } $cw=$ve_rect1[6]; $lx+=$cw; $cw=$ve_rect1[7]; if($te_bofpoc=='P') { pdf_show_xy($pdf, str_pad(number_format($te_amountLOCAL,2),14," ",STR_PAD_LEFT) , $lx,$py-$ly); } $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 11); $ly+=$ch; if($te_bofpoc=='P') { $te_totamount += $te_amountLOCAL; } if($te_bofpoc=='C') { $te_totamountUSD += $te_amountUSD; } } } //------------------------------------------------------------------------------------------------------------------- if($te_invprtucd!='' and $te_invrpaprucd == '') { pdf_setfont($pdf, $font, 12); PDF_setcolor($pdf,"fill","rgb", 1, 0.1, 0.1); pdf_show_xy($pdf,"NOT A VALID INVOICE - DISPLAY ONLY", $spx+10,$py-$ly-10); PDF_setcolor($pdf,"fill","rgb", 0, 0, 0); } //$te_totamount = round($te_totamount); //remove this when need round figure of invoice amount if(($te_totamountUSD>0) && ($flg_frgcuryn=='n')) { $font = pdf_findfont($pdf, "Courier-Bold", "host", 0); pdf_setfont($pdf, $font, 10); $ly = $ly_h+$ch2+0.65*$ch; pdf_show_xy($pdf, str_pad("",11,"_",STR_PAD_LEFT) , $te_lx,$py-$ly+$ch); $ly += $ch; pdf_set_parameter($pdf,"underline","true"); pdf_show_xy($pdf, str_pad(number_format($te_totamountUSD,2),11," ",STR_PAD_LEFT) , $te_lx,$py-$ly+$ch); pdf_set_parameter($pdf,"underline","false"); $ly += 0.85*$ch; } else { $ly = $ly_h+$ch2+2.5*$ch; } $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 10); $lx = 365; pdf_show_xy($pdf,"TOTAL AMOUNT Rs.", $lx,$py-$ly); $font = pdf_findfont($pdf, "Courier-Bold", "host", 0); pdf_setfont($pdf, $font, 13); $cw = 100; $lx+=$cw; pdf_set_parameter($pdf,"underline","true"); pdf_show_xy($pdf, str_pad(number_format($te_totamount,2),17," ",STR_PAD_LEFT) , $lx,$py-$ly); pdf_set_parameter($pdf,"underline","false"); $lx=$spx+2; $ch = 40; $ly+=$ch; $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 10); $te_rs = intval($te_totamount); $te_cents = ($te_totamount - $te_rs)*100; if($te_cents>0) { $w = new words($te_cents,"",""); $te_centsword= "And ".ucwords($w->words)."Cents"; } else { $te_centsword=""; } $w = new words($te_rs,"",""); $te_rsword=ucwords($w->words); $te_totword = "Sri Lankan Rupees".$te_rsword.$te_centsword."Only"; pdf_show_boxed($pdf,strtoupper($te_totword),$lx,$py-$ly,340,$ch,'left'); //pdf_rect($pdf,$lx,$py-$ly,340,$ch); //pdf_stroke($pdf); $lx+=300; $ch=25; $ly+=20; if(isset($_POST['draft'])) { pdf_show_boxed($pdf,"PAYMENT BY CASH OR PAY ORDER",$lx,$py-$ly,290,$ch,'right'); } else { pdf_show_boxed($pdf,str_pad("",strlen($te_comnam)*1.5," _ ",STR_PAD_BOTH),$lx,$py-$ly+12,300,$ch,'center'); pdf_show_boxed($pdf,strtoupper($te_comnam).chr(10)."AGENT",$lx,$py-$ly,300,$ch,'center'); //pdf_rect($pdf,$lx,$py-$ly,300,$ch); //pdf_stroke($pdf); } pdf_end_page($pdf); pdf_close($pdf); if(!isset($_POST['draft'])) { $sql_inv = "update invmast set invextrayn= 'Y', invprtucd = '$te_invucdnew', invprtddt = '$te_inventddt', invprttime = '$te_inventtime', invrpaprucd = null, invrpaprddt = null, invrpaprtime= null where invsno='$te_invsno' and ((invprtucd is null) or (invprtucd !='' and invrpaprucd != ''))"; //echo "$sql_inv
"; $result_inv = mysql_query($sql_inv) or die("Could not update invmast"); } $sql_tmpdrop = "DROP TABLE tmpmast"; $result_tmpdrop = mysql_query($sql_tmpdrop) or die("could not DROP TABLE tmpmast :
".mysql_error()); $data = pdf_get_buffer($pdf); header("Content-type: application/pdf"); header("Content-disposition: inline; filename=test.pdf"); header("Content-length: " . strlen($data)); echo $data; break; }//save_inv //--------------------------------------- [ p_heading($te_invdrf) ] ---------------------------------------// function p_heading($te_invdrf) { global $pdf,$pg,$font,$ch,$ch2,$ly,$ly_h,$ly_h2,$py,$px,$spx,$spy,$te_usdcomsno; global $te_invsno,$te_invexrate,$te_comnam,$ve_rect1,$te_vsvsno,$te_bolsno,$te_conno,$te_rpyn; global $te_invprtucd,$te_invrpaprucd; if($te_invdrf=='inv') { $sql_h = "select invdno,invddt,invexrate,invbolsno,invprtucd,invrpaprucd,comnam,comad1,comad2, comad3,connam shpnam,conad1 shpad1,conad2 shpad2,conad3 shpad3,conad4 shpad4, bolblno,bolydn,concat(vsvves,' V.',vsvvoy) vsvvsv,vsvabddt,copnam from (((((invmast left join conmast on invconsno=consno) left join bolmast on invbolsno = bolsno) left join vsvmast on bolvsvsno = vsvsno) left join copmast on bolcopsno = copsno) left join commast on invactcomsno = comsno) where invsno='$te_invsno' and invcomsno='$te_usdcomsno'"; //echo "$sql_h
"; $result_h = mysql_query($sql_h) or die("no header records inv"); $fields_h = mysql_fetch_array($result_h, MYSQL_BOTH); $te_shpnam = $fields_h['shpnam']; $te_shpad1 = $fields_h['shpad1']; $te_shpad2 = $fields_h['shpad2']; $te_shpad3 = $fields_h['shpad3']; $te_shpad4 = $fields_h['shpad4']; $te_invdno = $fields_h['invdno']; $te_invddt = ytod($fields_h['invddt']); $te_invexrate = $fields_h['invexrate']; $te_invprtucd = $fields_h['invprtucd']; $te_invrpaprucd = $fields_h['invrpaprucd']; $te_bolsno = $fields_h['invbolsno']; } else { $sql_h = "select comnam,comad1,comad2,comad3,connam shpnam,conad1 shpad1,conad2 shpad2, conad3 shpad3,conad4 shpad4,bolblno,bolydn,concat(vsvves,' V.',vsvvoy) vsvvsv, vsvabddt,copnam from ((((bolmast left join conmast on bolshpsno=consno) left join vsvmast on bolvsvsno = vsvsno) left join copmast on bolcopsno = copsno) left join commast on copcomsno = comsno) where bolsno='$te_bolsno' and bolvsvsno='$te_vsvsno' and vsvcomsno='$te_usdcomsno'"; //echo "$sql_h
"; //invdno,invddt,invexrate,invfirstyn,bolsno, $result_h = mysql_query($sql_h) or die("no header records drf"); $fields_h = mysql_fetch_array($result_h, MYSQL_BOTH); $te_shpnam = $fields_h['shpnam']; $te_shpad1 = $fields_h['shpad1']; $te_shpad2 = $fields_h['shpad2']; $te_shpad3 = $fields_h['shpad3']; $te_shpad4 = $fields_h['shpad4']; $te_invdno = ""; $te_invddt = $_POST['invddt']; $te_invexrate = $_POST['invexrate']; $te_invprtucd = ""; $te_invrpaprucd= ""; $te_invconsno = $_POST['invconsno']; $te_bolsno = $te_bolsno; } //echo "$sql_h
"; $te_comnam = $fields_h['comnam']; $te_comad1 = $fields_h['comad1']; $te_comad2 = $fields_h['comad2']; $te_comad3 = $fields_h['comad3']; $te_bolblno = $fields_h['bolblno']; $te_bolydn = $fields_h['bolydn']; $te_conno = $te_bolydn; $te_vsvvsv = $fields_h['vsvvsv']; $te_vsvabddt= ytod($fields_h['vsvabddt']); $te_copnam = $fields_h['copnam']; //-------------------------------------------------------------------------------------------------------------// $real_path = realpath("./"); //dl("pdf.so"); if ($ly > $py-30) { if ($pg!=0) { pdf_end_page($pdf); } pdf_begin_page($pdf,$px,$py); if($te_rpyn=='Y') { $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 6); //pdf_show_xy($pdf,"REPRINT", $px-38, $py-8); pdf_show_xy($pdf,"-", $px-38, $py-8); } $font = pdf_findfont($pdf, "Courier-Bold", "host", 0); pdf_setfont($pdf, $font, 14); $pg=$pg+1; } $spx=10; $spy=10; $ly =$spy; //Main Document $ch=15; if($te_invdrf=='inv') { pdf_set_parameter($pdf,"underline","true"); pdf_show_boxed($pdf,"INVOICE - OUTWARD",$spx,$py-$ly,$px-2*$spx,$ch,'center');//420,320 //pdf_rect($pdf,$spx,$py-$ly,$px-2*$spx,$ch); //pdf_stroke($pdf); pdf_set_parameter($pdf,"underline","false"); } else { pdf_set_parameter($pdf,"underline","true"); pdf_show_boxed($pdf,"DRAFT INVOICE - OUTWARD",$spx,$py-$ly,$px-2*$spx,$ch,'center');//420,320 //pdf_rect($pdf,$spx,$py-$ly,$px-2*$spx,$ch); //pdf_stroke($pdf); pdf_set_parameter($pdf,"underline","false"); } $font = pdf_findfont($pdf, "Helvetica-Bold", "host", 0); pdf_setfont($pdf, $font, 11); $ch = 35; $ly+=$ch; /*$te_comdes = str_pad($te_comnam,40,"*",STR_PAD_RIGHT).chr(10).str_pad($te_comad1,40,"#",STR_PAD_RIGHT).chr(10); $te_comdes.= str_pad($te_comad2,40,"*",STR_PAD_RIGHT).str_pad($te_comad3,40,"W",STR_PAD_RIGHT);*/ $te_comdes = $te_comnam.chr(10).$te_comad1." ".$te_comad2." ".$te_comad3; pdf_show_boxed($pdf,$te_comdes,$spx,$py-$ly-5,375,$ch,'left');//420,320 //pdf_rect($pdf,$spx,$py-$ly-5,375,$ch); //pdf_stroke($pdf); $ly-=0.5*$ch; $ch = 15; $cw=70; $lx=445; $font = pdf_findfont($pdf, "Helvetica", "host", 0); pdf_setfont($pdf, $font, 10); pdf_show_xy($pdf,"DATE ", $lx, $py-$ly); pdf_show_xy($pdf,": ".mon($te_invddt), $lx+$cw, $py-$ly); $ly=$ly+$ch; $ch = 20; $ly=$ly+$ch; $lx=$spx; $cw = 65; $ch = 15; pdf_show_xy($pdf,"LINE", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_copnam, $lx+$cw, $py-$ly); //pdf_show_xy($pdf,": ".str_pad($te_copnam,40,"*",STR_PAD_RIGHT), $lx+$cw, $py-$ly); $ly+=$ch; pdf_show_xy($pdf,"VES/VOY ", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_vsvvsv, $lx+$cw, $py-$ly); $ly+=$ch; pdf_show_xy($pdf,"B/L NO", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_bolblno, $lx+$cw, $py-$ly); $ly-=2*$ch; $cw = 70; $lx=300; if($te_demddt!="") { pdf_show_xy($pdf,"DEMURRAGE", $lx, $py-$ly); pdf_show_xy($pdf,": ".mon($te_demddt), $lx+$cw, $py-$ly); } $ly+=$ch; if($te_refddt!="") { pdf_show_xy($pdf,"CLEARING", $lx, $py-$ly); pdf_show_xy($pdf,": ".mon($te_refddt), $lx+$cw, $py-$ly); } $ly+=$ch; /* pdf_show_xy($pdf,"BERTH DATE", $lx, $py-$ly); pdf_show_xy($pdf,": ".mon($te_vsvabddt), $lx+$cw, $py-$ly); */ $ly-=2*$ch; $cw = 70; $lx=445; if($te_invdno!="") { pdf_show_xy($pdf,"INVOICE NO", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_invdno, $lx+$cw, $py-$ly); } $ly+=$ch; pdf_show_xy($pdf,"EX. RATE", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_invexrate, $lx+$cw, $py-$ly); $ly+=$ch; pdf_show_xy($pdf,"BERTH DATE", $lx, $py-$ly); pdf_show_xy($pdf,": ".mon($te_vsvabddt), $lx+$cw, $py-$ly); $ly+=$ch; $lx=$spx; $cw = 65; pdf_show_xy($pdf,"SHIPPER", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_shpnam, $lx+$cw, $py-$ly); $cw = 70; $lx=445; pdf_show_xy($pdf,"CONMNT. NO", $lx, $py-$ly); pdf_show_xy($pdf,": ".$te_conno, $lx+$cw, $py-$ly); $ly+=$ch; $lx=$spx; $cw = 65; pdf_show_xy($pdf,"ADDRESS", $lx, $py-$ly); pdf_show_xy($pdf,": ", $lx+$cw, $py-$ly); $lx+=$cw+5; $ch = 20; $ly+=$ch; $ly_h = $ly; pdf_show_boxed($pdf,$te_shpad1." ".$te_shpad2." ".$te_shpad3." ".$te_shpad4,$lx,$py-$ly+9.5,500,$ch,'left');//420,320 //pdf_rect($pdf,$lx,$py-$ly+9.5,500,$ch); //pdf_stroke($pdf); $lx = $spx; $ch = 13; //HEIGHT 1 $ch2 = 170 ; //HEIGHT 2 $ly += 10; // RECTANGLE 1 ST $ve_rect1 = array(); $ve_rect1[0] = 145; //CHARGE ITEM $ve_rect1[1] = 60; //EQT TYPE $ve_rect1[2] = 60; //QTY $ve_rect1[3] = 65; //RATE $ve_rect1[4] = 30; //CUR $ve_rect1[5] = 70; //COLLECT USD AMOUNT $ve_rect1[6] = 70; //PREPAID USD AMOUNT $ve_rect1[7] = 90; //RS. AMOUNT $cw=$ve_rect1[0]; pdf_show_boxed($pdf,"CHARGE ITEM",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[1]; pdf_show_boxed($pdf,"EQT TYPE",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[2]; pdf_show_boxed($pdf,"QTY",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[3]; pdf_show_boxed($pdf,"RATE",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[4]; pdf_show_boxed($pdf,"CUR",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[5]; pdf_show_boxed($pdf,"COLLECT",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[6]; pdf_show_boxed($pdf,"PREPAID",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $lx+=$cw; $cw=$ve_rect1[7]; pdf_show_boxed($pdf,"RS. AMOUNT",$lx,$py-$ly,$cw,$ch,'center'); pdf_rect($pdf,$lx,$py-$ly,$cw,$ch); pdf_stroke($pdf); pdf_rect($pdf,$lx,$py-$ly-$ch2,$cw,$ch2); pdf_stroke($pdf); $ly+=10; } //==================================================================================== //-------------------------Check User Rights [BEGIN]------------------------------------- $te_usropt="usryn"; $te_prgnam = $_SERVER['PHP_SELF']; //include "usrval.php"; //-------------------------Check User Rights [CLOSE]------------------------------------- ?> Fraight Invoice
B/L NO : GenerateDropDownListauto("bolsno","$te_bolsno","bolsno","bolblno", "this.form.bolsnoauto.value=this.options[this.selectedIndex].text;hidediv()", "return enter(document.oinvp.display)","$w","$t"); $w-=20; ?>
"; $sql_display = "select pihpih,pihddt,vsvvsv,pihattn,pihasddt,pihref,pihbl,pihdmode,pihexrate,pihsno, shp.connam as pihshpsnoauto,co.connam as pihcosnoauto,des.pornam as pihpordestsnoauto, via.pornam as pihviaporsnoauto from pihmast left join pilhmast on pihsno=pilhpihsno left join conmast shp on pihshpsno=shp.consno left join conmast co on pihcosno=co.consno left join vsvmast on pihvsvsno=vsvsno left join pormast des on pihpordestsno=des.porsno left join pormast via on pihviaporsno=via.porsno where pihbl = '$te_bolsnoauto'"; #echo "
".$sql_display."
"; $result_display = mysql_query($sql_display) or die("sql_display records error".mysql_error()); if(mysql_num_rows($result_display)) { echo "
"; echo "
"; echo "

OUTWARD MANUAL INVOICE RECORDS


"; echo ""; echo ""; echo ""; echo ""; $fields = mysql_fetch_array($result_display,MYSQL_BOTH); $te_pihshpsnoauto = $fields['pihshpsnoauto']; $te_pihddt = ytod($fields['pihddt']); $te_pihcosnoauto = $fields['pihcosnoauto']; $te_pihvsvsnoauto = $fields['vsvvsv']; $te_pihattn = $fields['pihattn']; $te_pihasddt = ytod($fields['pihasddt']); $te_pihref = $fields['pihref']; $te_pihpordestsnoauto = $fields['pihpordestsnoauto']; $te_pihviaporsnoauto = $fields['pihviaporsnoauto']; $te_pihdmode = $fields['pihdmode']; $te_pihexrate = $fields['pihexrate']; $te_pihpih = $fields['pihpih']; echo ""; //vsvsno echo ""; echo ""; echo ""; echo "
INVOICE NOINVOICE DATESHIPPERSAILING DATEFINAL DESTINATIONVESSEL/VOYAGE EX.RATE
$te_pihpih$te_pihddt$te_pihshpsnoauto$te_pihasddt$te_pihpordestsnoauto$te_pihvsvsnoauto$te_pihexrate
"; } else { echo "

No PIH Records for the selected B/L : $te_bolsnoauto

"; } echo "
"; echo "
"; $sql_invbol = "select bolshpsno,bolshpnam,bolshpad1,bolshpad2,bolshpad3,bolshpad4, bolexrate,bolydn,bolcopsno,vsvexrateo,vseexrateo,vsvabddt, comsno,comcom,comnam,comad1,comad2,comad3,copnam, consno,connam,conad1,conad2,conad3,conad4,vsvvsv,vsvsno from bolmast left join vsvmast on bolvsvsno = vsvsno left join vsemast on vsevsvsno = vsvsno and bolcopsno=vsecopsno left join copmast on bolcopsno = copsno left join commast on copcomsno = comsno left join conmast on bolshpsno = consno where bolsno='$te_bolsno'"; $rst_invbol = mysql_query($sql_invbol) or die("SQL Error sql_invbol :
".mysql_error()); if(mysql_num_rows($rst_invbol)) { echo "

ACTUAL INVOICE RECORDS


"; echo ""; echo ""; echo ""; echo ""; $flds_invbol = mysql_fetch_array($rst_invbol, MYSQL_BOTH); $te_vsvabddt = ytod($flds_invbol['vsvabddt']); $te_bolshpsno = $flds_invbol['bolshpsno']; $te_bolshpnam = $flds_invbol['bolshpnam']; $te_bolshpad1 = $flds_invbol['bolshpad1']; $te_bolshpad2 = $flds_invbol['bolshpad2']; $te_bolshpad3 = $flds_invbol['bolshpad3']; $te_bolshpad4 = $flds_invbol['bolshpad4']; $te_shpsno = $flds_invbol['consno']; $te_shpnam = $flds_invbol['connam']; $te_shpad1 = $flds_invbol['conad1']; $te_shpad2 = $flds_invbol['conad2']; $te_shpad3 = $flds_invbol['conad3']; $te_shpad4 = $flds_invbol['conad4']; $te_comsno = $flds_invbol['comsno']; $te_comcom = $flds_invbol['comcom']; $te_comnam = $flds_invbol['comnam']; $te_comad1 = $flds_invbol['comad1']; $te_comad2 = $flds_invbol['comad2']; $te_comad3 = $flds_invbol['comad3']; $te_copnam = $flds_invbol['copnam']; $te_bolydn = $flds_invbol['bolydn']; $te_bolcopsno = $flds_invbol['bolcopsno']; $te_bolexrate = $flds_invbol['bolexrate']; $te_vsvexrateo = $flds_invbol['vsvexrateo']; $te_vseexrateo = $flds_invbol['vseexrateo']; $te_vsvvsv = $flds_invbol['vsvvsv']; $te_vsvsno = $flds_invbol['vsvsno']; echo ""; //vsvsno echo ""; //vsvsno echo ""; //CONMNT. NO echo ""; //comsno echo ""; //comsno echo ""; //bolcopsno if($te_bolexrate>0) $te_invexrate = $te_bolexrate; else if($te_vseexrateo>0) $te_invexrate = $te_vseexrateo; else $te_invexrate = $te_vsvexrateo; echo ""; //invexrate if($te_invexrate<=0) { die ('Exchange rate not found ..?'); } if($te_bolshpsno<=0) { die("Shipper code not found and check B/L entry "); } echo ""; echo ""; echo ""; echo "
INVOICE DATESHIPPERCompanyCONMNT. NOBERTH DATEVESSEL/VOYAGE EX.RATE
$te_invddt$te_shpnam$te_copnam$te_bolydn$te_vsvabddt$te_vsvvsv$te_invexrate
"; echo "
"; echo ""; echo ""; $sql_bof="SELECT bofsno,bofinvsno,bofqty,bofrate,bofexrate,bofpoc,citdes,concat(eqteqt,' - ',eqttyp) eqteqt, sys.sysrno sysrno,invdno,sys1.sysrno eqtsize,eqtdr from ((((((bofmast left join bolmast on bofbolsno = bolsno) left join citmast cit on bofcitsno = cit.citsno) left join eqtmast eqt on bofeqtsno = eqt.eqtsno) left join sysmast sys on bofcursno = sys.syssno) left join invmast inv on bofinvsno = inv.invsno and (inv.invcanucd is null or inv.invcanucd='')) left join sysmast sys1 on eqtsizesno = sys1.syssno) where bofpoc='P' and bolsno='$te_bolsno' order by citprtord,eqtsno"; #echo "$sql_bof
"; $rec_bof = mysql_query($sql_bof) or die("no bofmast records : sql_bof
".mysql_error()); $k = 0; $r = 0; $s = 0; while ($fields_bof = mysql_fetch_array($rec_bof, MYSQL_BOTH)) { $r = $k +1; $te_bofsno = $fields_bof['bofsno']; $te_citdes = $fields_bof['citdes']; $te_eqteqt = $fields_bof['eqteqt']; $te_eqtsize = $fields_bof['eqtsize']; $te_eqtdr = $fields_bof['eqtdr']; $te_bofqty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_bofexrate= $fields_bof['bofexrate']; $te_bofpoc = $fields_bof['bofpoc']; $te_bofinvsno= $fields_bof['bofinvsno']; $te_invdno = $fields_bof['invdno']; $te_curcur = $fields_bof['sysrno']; if($te_bofrate>0) { $te_amountUSD = "0"; $te_amountLOCAL = "0"; if($te_curcur == "USD") { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_invexrate*($te_bofqty*$te_bofrate); $te_exrate = $te_invexrate; } elseif($te_curcur == "LKR") { $te_amountUSD = ""; $te_amountLOCAL = $te_bofqty*$te_bofrate; $te_exrate = ""; } else { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_bofqty*$te_bofrate*$te_bofexrate; $te_exrate = $te_bofexrate; } echo ""; echo ""; echo ""; $s = $k%2; echo ""; $k++; } }//end inv while echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
# CHARGE ITEM LOCAL AMOUNT SELECT AMOUNT
".$r.". $te_citdes $te_amountLOCAL
TOTAL EXTRA INVOICE [ $te_dif_tot ] [LKR] AMOUNT :
TOTAL INVOICE [LKR] AMOUNT :
TOTAL MANUAL INVOICE [LKR] AMOUNT :
DIFFERENCE [LKR] AMOUNT :
"; //=======================================Manual Invoice Additionals $sql_pilh ="SELECT pihexrate,pilhcitsno,pilhqty,pilhrate,pilhamt from pihmast left join pilhmast on pihsno=pilhpihsno left join citmast on pilhcitsno = citsno left join eqtmast on pilhtypsno = eqtsno left join sysmast on eqtsizesno = syssno where pilhpihsno='$te_pihsno' and pilhnoa='A' order by pilhcitsno"; #echo "$sql_bof
"; $rec_pilh = mysql_query($sql_pilh) or die("no bofmast records : sql_bof
".mysql_error()); $k = 0; $r = 0; $s = 0; while ($fields_pilh = mysql_fetch_array($rec_pilh, MYSQL_BOTH)) { $r = $k +1; $te_bofsno = $fields_bof['bofsno']; $te_citdes = $fields_bof['citdes']; $te_eqteqt = $fields_bof['eqteqt']; $te_eqtsize = $fields_bof['eqtsize']; $te_eqtdr = $fields_bof['eqtdr']; $te_bofqty = $fields_bof['bofqty']; $te_bofrate = $fields_bof['bofrate']; $te_bofexrate= $fields_bof['bofexrate']; $te_bofpoc = $fields_bof['bofpoc']; $te_bofinvsno= $fields_bof['bofinvsno']; $te_invdno = $fields_bof['invdno']; $te_curcur = $fields_bof['sysrno']; if($te_bofrate>0) { $te_amountUSD = "0"; $te_amountLOCAL = "0"; if($te_curcur == "USD") { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_invexrate*($te_bofqty*$te_bofrate); $te_exrate = $te_invexrate; } elseif($te_curcur == "LKR") { $te_amountUSD = ""; $te_amountLOCAL = $te_bofqty*$te_bofrate; $te_exrate = ""; } else { $te_amountUSD = $te_bofqty*$te_bofrate; $te_amountLOCAL = $te_bofqty*$te_bofrate*$te_bofexrate; $te_exrate = $te_bofexrate; } echo ""; echo ""; echo ""; $s = $k%2; echo " ".$r.". $te_citdes $te_amountLOCAL "; $k++; } }//end inv while echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Print
"; } }//dispaly ?>
\n"; echo""; mysql_data_seek($result,0); while($rec = mysql_fetch_array($result)) { if($HtmlObjectDefaultValue == $rec["$DBFieldToValue"]) { echo " \n"; } else { echo " \n"; } } echo " \n"; } function GenerateDropDownListauto($HtmlObjectName,$HtmlObjectDefaultValue,$DBFieldToValue,$DBFieldToDescription,$action,$onkeyp,$w,$t) { global $result; $w1=$w-20; echo " \n"; } } function ytod($ddt) { if ($ddt=="0000-00-00") return ""; else {$year = substr($ddt, 0, 4); $month = substr($ddt, 5, 2); $day = substr($ddt, 8, 2); return "$day/$month/$year"; } } function dtoy($ddt) { if ($ddt) { //$day = substr($ddt, 0, 2); //$month = substr($ddt, 3, 2); //$year = substr($ddt, 6, 4); $vl=split('/',$ddt); $day = $vl[0]; $month = $vl[1]; $year = $vl[2]; return "$year-$month-$day"; } else {return ""; } } function dtom($ddt) { if ($ddt) { $monarray=array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'); $lines = split("/", $ddt); $day = $lines[0]; $month = $monarray[$lines[1]-1]; $year = $lines[2]; return "$day-$month-$year"; } else {return ""; } } function mon($ddt) { if ($ddt) { //$day = substr($ddt, 0, 2); //$month = substr($ddt, 3, 2); //$year = substr($ddt, 6, 4); $vl=split('/',$ddt); $day = $vl[0]; $month = $vl[1]; $year = $vl[2]; $mon = date("d-M-Y", mktime(0, 0, 0, $month, $day, $year)); return "$mon"; } else {return ""; } } ?>