(/ESCb6Ѐ_p5MT&.`=%7<8Zz67QI3ۨ&fj8[I|I4 d< X;2G Up]'|2_B?tTZ,qCV46 zU1?с?Iz=$m78\pmQ5?ޣ:G!)(mmBh8-1}[;S 0~Lỿ5}[hೝP'L`:puy[eQ=gxYbMs娽7tvw{:lAN" W}GYjY/FX =Ӣ)oI}Ձ۱b~3DL@\[ bp}QW-fv ihv0\m RUCtfa΃I LdxU}[;S 0~Fpa ϰ_r-G ߌulH! qrMD#''N@`aI}7q·oIQS)A.Ac3}Gy!e!slGuҟ?xB2f~ + mr?6H&\E-84K]9FC>jz P#ٛ)Jq-Zڑ +3d \m<0XZI%)tm>-B{5 ßKv"zCm 6g5(?2ٹԚk/*WxvH 'Mbh|zV)d$j^:bre?k+f~&7CbI_O_x׸?IVCm 6g5(?2ٹԚkhis*_7p_[.7t/'W׌rL<$%@D¿΍ƲPvxtu㓸 "!LqZL](O4zWC3+,b1bC:Y}БX.ˠI1Ւ;H!HF'o&] K9(~0Z5+>g>W{A}H"ݔYqXp0%NeE+Pp$=#VX9]֝]#1"|KMMKdK:;E|-:vEJ|9I2yխ:Axp-H(_teAJh(e2b,0 tSCN?6|O!>p91!&₎i0X0Yʡ_x.5^8zjZRҤxv`]|LQ?QEqPs ՍY^8z^yIIv2y.cp-{)&7DXP g( l@d?.sM^k^h:GZuw4wIJ@ICZynȄa*֤V=ymCxxu# ?\GrZϤ-ɈRn|괎BDŶ8:VAJܿk6Zg Wʶs>m` ?i| udVն6]#A95D|6@LY+HBL"UȨlC>>䪹/k,|#:=@qW}o 'oADTH9h:P.Zl}MA pdt;3l)ߣ.>T{K2eG3bc|mSQvJaגi*CDUW,p /h}jn=(*OdtNķmfϏ ܽ Fϰ7S G/eʵrtfڋDzJMUG 'Y(I^)qW2T ܀QzmAC7.}ױW,MHsD܀CcဵX2^yrT4Tv'Ѡ!hVtj q0{+765,8e[#~>$P͍/ w)闹ҶơV+2Lt" >>X{/tpyڙ -ҷю&֠00axHj?Pq+ 2 {ƔhPol8:GR+rn+7 j6,ذ9 .X=3R׮`9hQv炘}S,Ef$! hΕҨjG 5( j6,ذ9 .X=3R׮`9hQv炘M&~.[!U23*ޒ.[$Pn^G N}6I5AP@j0Ul@eKbՔ+Lʲ)Ǎή8'-"/uA&<%/Ťŭhǭ #&φaWyV\.e~p}ُI{mGxl&4@,r/HB[0Mv` U,8e[#7%V^6\[.1gw0X~\GEs!aewҚ<7ތէkʏy`GZfO{C2Dd%3|>/f"S|#b/{ #{g0!{U`(/8@l!nsFp蘿w b@yTR7eH;Pq8cS @c'MDW N3 #_J_81IBhbae4' @-)"f*Q' 55X%t^RɆ„#Wء q߆ "X[RVQէбBK$fN7)[m6>-OP@v'&A u(q}]Q}%*g00|-&I9썌ڤzB0ף64 R]>V1a@Qp҈qM2kJ]_j`/m)~ C/d)Ze$@^D_S5pT4#'hx]%&ɳ,h/Ĩi]Z>{B@mfrg!׭gøfZ t]ßNwC^{MO4yscY(I^)qW2T+Uw4AI$ ,O}d4u7;$tKs=OV{!YRΏ $+MXH󵹈;C@5 ..(l.+D7;/yIrkwE1D0MREa纚{C2Dd%*M Ag2|t~V'^~JxLxP@,"l]&R%aGz:(4'',I b]O"|*ZRz$ ;v21GFkҚ{C2Dd%& uvҨDVJe where itemid='$itemid' and date_>'$date_' "); if($isSold>0){ echo ""; mysqli_close($con); echo ""; }else{ $isSold=getName($con,"select invno from sale where itemid='$itemid' and date_='$date_' "); if($isSold>0){ $time_=date('H:i:s',strtotime(getName($con,"select time_ from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."' "))); $qry="select distinct invno from sale where date_='$date_' and itemid='$itemid' "; $isSold=getName($con,"select 1 from sale2 where time_>'$time_' and date_='$date_' and invno in($qry) "); if($isSold>0){ echo ""; mysqli_close($con); echo ""; } } }// End if sold $ret=deleteStock($con,$itemid,$invno); mysqli_query($con,"delete from purchase where itemid='$itemid' and actid='$actid' and invno='$invno'"); updateQty($con,$itemid); } $uprice_old =$arr[2]; // getName($con,"select uprice from item where itemid=$itemid and LabID='$LabID'"); if ($uprice_old=="") $uprice_old =0; $qty_old =$arr[3]; //getName($con,"select qty from item where itemid=$itemid and LabID='$LabID'"); if ($qty_old=="") $qty_old =0; /* if ($qty+$qty_old==0) { $itemprice= ($qty*$uprice)/($qty); }else{ $itemprice= ($uprice_old*$qty_old+$qty*$uprice)/($qty+$qty_old); } */ $sno=getName($con,"select ifnull(max(sno),0)+1 from purchase where invno='$invno' and LabID='$LabID' "); $qry="insert into purchase(tax,sno,discount,percentage,uprice,date_,invno,actid,itemid,qty,pprice,LabID) values(0,'$sno','$discount','$percentage','$uprice','$date_',$invno,$actid,$itemid,$qty,$pprice,$LabID)"; mysqli_query($con,$qry); $ret=addStock($con,$itemid,$invno); updateQty($con,$itemid); $anyvalue=""; //purchase2 & ledger $pur = getName($con,"select IFNULL(sum(qty*uprice),0) from purchase where invno='$invno' and LabID='$LabID'"); if ($date2==""){ $qry="insert into purchase2 (time_,date_,invno,actid,amount,LabID) values('$time_','$date_',$invno,$actid,'$pur',$LabID)"; mysqli_query($con,$qry); mysqli_query($con,"delete from ledger where pno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid=getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,pno,actid,debit,credit,LabID) values('$autoid','Purchase #:$invno','$date_',$invno,$actid,0,'$pur',$LabID)"; //echo $qry; mysqli_query($con,$qry); }else{ $qry="update purchase2 set amount='$pur' where actid='$actid' and invno='$invno' "; mysqli_query($con,$qry); mysqli_query($con,"update ledger set credit='$pur' where actid='$actid' and pno='$invno' and LabID='".$_SESSION['LabID']."'"); } } } if(isset($_GET['delitemid'])){ $itemid = $_GET['delitemid']; $invno = $_GET['invno']; $sno = $_GET['sno']; // check for if sold $date_=date('Y-m-d',strtotime(getName($con,"select date_ from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."' "))); $isSold=getName($con,"select invno from sale where itemid='$itemid' and date_>'$date_' "); if($isSold>0){ echo ""; mysqli_close($con); echo ""; }else{ $isSold=getName($con,"select invno from sale where itemid='$itemid' and date_='$date_' "); if($isSold>0){ $time_=date('H:i:s',strtotime(getName($con,"select time_ from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."' "))); $qry="select distinct invno from sale where date_='$date_' and itemid='$itemid' "; $isSold=getName($con,"select 1 from sale2 where time_>'$time_' and date_='$date_' and invno in($qry) "); if($isSold>0){ echo ""; mysqli_close($con); echo ""; } } }// End if sold $ret= deleteStock($con,$itemid,$invno); //log the transaction $time_ = date('Y-m-d H:i:s',time()); $qry="insert into infolog(itemid,number,time_,actid,LabID,date_,remarks,qty,uprice) select itemid,invno,'$time_',actid,LabID,date_,'DEL-Purchase',qty,uprice from purchase where itemid='$itemid' and invno='$invno' and LabID='".$_SESSION['LabID']."' "; mysqli_query($con,$qry); if($_SESSION['LabID']==30 or $_SESSION['LabID']==70){ //Mahmood Steel $qry="delete from purchase where sno='$sno' and itemid='$itemid' and actid='$actid' and invno='$invno'"; }else{ $qry="delete from purchase where itemid='$itemid' and actid='$actid' and invno='$invno'"; } mysqli_query($con,$qry); mysqli_query($con,"delete from imeitbl where invtype='pno' and itemid='$itemid' and invno='$invno' and LabID='".$_SESSION['LabID']."'"); if (getName($con,"select 1 from purchase where invno='$invno' and LabID='".$_SESSION['LabID']."' ")==""){ //log $qry="insert into infolog(actype,number,time_,actid,LabID,date_,remarks,amount,discount,remarks2) select actype,invno,'$time_',actid,LabID,date_,'DEL-PUR2-INV',amount,discount,CONCAT('Paid:',paid) from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."' "; mysqli_query($con,$qry); $qry="delete from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"; mysqli_query($con,$qry); mysqli_query($con,"delete from ledger where pno='$invno' and LabID='".$_SESSION['LabID']."'"); }else{ //$ret=getName($con,"select sum(qty*pprice) from purchase where actid='$actid' and invno='$invno'"); $ret=getName($con,"select sum(qty*uprice) from purchase where actid='$actid' and invno='$invno'"); $qry="update purchase2 set amount='$ret' where invno=$invno and LabID='".$_SESSION['LabID']."'"; //echo $qry; mysqli_query($con,$qry); mysqli_query($con,"update ledger set credit='$ret' where pno='$invno' and LabID='".$_SESSION['LabID']."'"); } //mysqli_query($con,"insert into ledger (remarks,date_,pno,actid,debit,credit,LabID) select 'Purchase #:$invno',date_,invno,actid,amount,paid,LabID from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); calculateBalance($con,$actid); updateQty($con,$itemid); } function deleteStock($con,$itemid,$pno){ $qty_purchase = getName($con,"select (qty) from purchase where itemid='$itemid' and invno='$pno' and LabID='".$_SESSION['LabID']."'"); if ($qty_purchase=="") $qty_purchase =0; $uprice_purchase = getName($con,"select (uprice) from purchase where itemid=$itemid and invno='$pno' and LabID='".$_SESSION['LabID']."'"); if ($uprice_purchase=="") $uprice_purchase =0; $qty_stock = getName($con,"select (qty) from item where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); if ($qty_stock=="") $qty_stock =0; $uprice_stock = getName($con,"select (uprice) from item where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); if ($uprice_stock=="") $uprice_stock =0; if ($qty_purchase-$qty_stock==0){ mysqli_query($con,"update item set qty=0,uprice=0 where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); }else{ $uprice=(($qty_stock*$uprice_stock)-($qty_purchase*$uprice_purchase))/($qty_stock-$qty_purchase); mysqli_query($con,"update item set qty=$qty_stock-$qty_purchase,uprice=$uprice where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); } updateQty($con,$itemid); return 0; } if(isset($_POST['btnSave'])){ $actid=$_POST['actid']; $invno = $_POST['invno']; $amt = $_POST['amt']; $actype = $_POST['actype']; $extracharges = $_POST['extracharges']; $amt+=$extracharges; $paid = $_POST['paid']==""? 0: $_POST['paid']; $transport =0;// $_POST['transport']==""? 0: $_POST['transport']; $Discount = $_POST['Discount']==""? 0: $_POST['Discount']; $date_ = date('Y-m-d',strtotime($_POST['date_'])); $actypeold=""; if (getName($con,"select 1 from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."'")=="") { echo "Add Item First"; }else{ $qry="update purchase2 set extracharges='$extracharges',actype='$actype',date_='$date_',paid=$paid,discount='$Discount',transport='$transport' where invno='$invno' and LabID='".$_SESSION['LabID']."'"; //echo $qry; mysqli_query($con,$qry); $actypeold=getName($con,"select actype from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); } $amt=$amt-$Discount; mysqli_query($con,"delete from ledger where pno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,pno,actid,debit,credit,LabID) values('$autoid','Purchase #:$invno','$date_',$invno,$actid,$paid,$amt,$LabID)"; //echo $qry; mysqli_query($con,$qry); if($paid>0 and $actype!=""){ $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,pno,actid,debit,credit,LabID) values('$autoid','Purchase #:$invno','$date_',$invno,$actype,0,$paid,$LabID)"; //echo $qry; mysqli_query($con,$qry); calculateBalance($con,$actype); } mysqli_query($con,"update purchase set date_='$date_' where invno='$invno' and LabID='".$_SESSION['LabID']."' "); //mysqli_query($con,"update accounts set balance=(select ifnull(sum(debit),0)-ifnull(sum(credit),0) from ledger where actid='$actid') where id='$actid' "); calculateBalance($con,$actid); //if($actypeold!="" and $actypeold!=$actype) calculateBalance($actypeold); } if(isset($_POST['btnSaveInvoice'])){ //btn =Add items(s) $actid=$_POST['actid']; //$date_= date('Y-m-d',strtotime($_POST['date_'])); $time_ = date('H:i:s',time()); $invno = $_POST['invno']; //$accountID = $_POST['accountID']; $cnt = $_POST['cnt']; $selected=false; for ($i=1; $i<=$cnt; $i++) { $qty = "qty$i";$qty = $_POST[$qty]; if($qty>0){ $selected=true; $date_ = "date_$i"; $date_ =date('Y-m-d',strtotime($_POST[$date_])); $itemid = "itemid$i"; $itemid=$_POST[$itemid]; $pprice = "pprice$i"; $uprice=$pprice=$_POST[$pprice]; $percentage = "percentage$i";$percentage = $_POST[$percentage]; $unitPrice = "unitPrice$i"; $unitPrice = $_POST[$unitPrice]; $batchno = "batchno$i"; $batchno = $_POST[$batchno]; // bilty No $truckno = "truckno$i"; $truckno = $_POST[$truckno]; //if($tax=="") $tax=0; $amount=$qty*$pprice; $discount= 0; if($percentage>0){ $uprice=$pprice-($pprice*$percentage/100); }elseif($unitPrice>0){ if($unitPrice>$pprice){ $uprice=$pprice=$unitPrice; $percentage=0; }else{ $percentage=(100*(($pprice*$qty)-($qty*$unitPrice)))/($pprice*$qty); $uprice=$pprice-($pprice*$percentage/100); } } $discount=($pprice*$qty)-($uprice*$qty); mysqli_query($con,"update item set pprice='$pprice' where itemid='$itemid' "); //update the purchase price $sno=getName($con,"select ifnull(max(sno),0)+1 from purchase where invno='$invno' and LabID='$LabID' "); $qry="insert into purchase(batchno,truckno,tax,sno,discount,percentage,uprice,date_,invno,actid,itemid,qty,pprice,LabID) values('$batchno','$truckno',0,'$sno','$discount','$percentage','$uprice','$date_',$invno,$actid,$itemid,$qty,$pprice,$LabID)"; mysqli_query($con,$qry); $ret=addStock($con,$itemid,$invno); updateQty($con,$itemid); } } if($selected==true){ //purchase2 & ledger $pur = getName($con,"select IFNULL(sum(qty*uprice),0) from purchase where invno='$invno' and LabID='$LabID'"); if (getName($con,"select 1 from purchase2 where invno='$invno' and LabID='$LabID' ")==""){ $qry="insert into purchase2 (time_,date_,invno,actid,amount,LabID) values('$time_','$date_',$invno,$actid,'$pur',$LabID)"; mysqli_query($con,$qry); mysqli_query($con,"delete from ledger where pno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid=getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,pno,actid,debit,credit,LabID) values('$autoid','Purchase #:$invno','$date_',$invno,$actid,0,'$pur',$LabID)"; //echo $qry; mysqli_query($con,$qry); }else{ $qry="update purchase2 set amount='$pur' where actid='$actid' and invno='$invno' "; mysqli_query($con,$qry); mysqli_query($con,"update ledger set credit='$pur' where actid='$actid' and pno='$invno' and LabID='".$_SESSION['LabID']."'"); } } } if(isset($_POST['ADDITEM'])){ $actid = $_POST['actid']; $date_ = date('Y-m-d',strtotime($_POST['date_'])); $time_ = date('H:i:s',time()); $invno = $_POST['invno']; $itemid = $_POST['itemid']; $qty = $_POST['qty']; $uprice=$pprice= $_POST['pprice']; $amount=$qty*$pprice; $discount= 0; $percentage = $_POST['percentage']; $unitPrice = $_POST['unitPrice']; if($percentage>0){ $uprice=$pprice-($pprice*$percentage/100); }elseif($unitPrice>0){ $percentage=(100*(($pprice*$qty)-($qty*$unitPrice)))/($pprice*$qty); $uprice=$pprice-($pprice*$percentage/100); } $discount=($pprice*$qty)-($uprice*$qty); $uprice_old = getName($con,"select uprice from item where itemid=$itemid and LabID='$LabID'"); if ($uprice_old=="") $uprice_old =0; $qty_old = getName($con,"select qty from item where itemid=$itemid and LabID='$LabID'"); if ($qty_old=="") $qty_old =0; if ($qty+$qty_old==0) $itemprice= ($qty*$uprice)/($qty); $itemprice= ($uprice_old*$qty_old+$qty*$uprice)/($qty+$qty_old); if($_SESSION['LabID']!=30){ //Mahmood Steel if (getName($con,"select 1 from purchase where actid='$actid' and itemid='$itemid' and invno='$invno'")!=""){ $ret=deleteStock($con,$itemid,$invno); mysqli_query($con,"delete from purchase where itemid='$itemid' and actid='$actid' and invno='$invno'"); } } $sno=getName($con,"select ifnull(max(sno),0)+1 from purchase where invno='$invno' and LabID='$LabID' "); $qry="insert into purchase (sno,discount,percentage,uprice,date_,invno,actid,itemid,qty,pprice,LabID) values('$sno','$discount','$percentage','$uprice','$date_',$invno,$actid,$itemid,$qty,$pprice,$LabID)"; mysqli_query($con,$qry); $ret=addStock($con,$itemid,$invno); $pur = getName($con,"select sum(qty*uprice) from purchase where invno=$invno and LabID='$LabID'"); if ($pur=="") $pur =0; if (getName($con,"select 1 from purchase2 where invno='$invno' and actid='$actid'")=="") $qry="insert into purchase2 (time_,date_,invno,actid,amount,LabID) values('$time_','$date_',$invno,$actid,$pur,$LabID)"; else $qry="update purchase2 set amount='$pur' where actid='$actid' and invno='$invno' "; mysqli_query($con,$qry); if (getName($con,"select 1 from ledger where pno='$invno' and LabID='$LabID'")==""){ $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); mysqli_query($con,"insert into ledger (autoid,remarks,date_,pno,actid,debit,credit,LabID) select '$autoid','Purchase #:$invno',date_,invno,actid,paid,amount,LabID from purchase2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); }else{ $ret=getName($con,"select sum(qty*uprice) from purchase where actid='$actid' and invno='$invno'"); mysqli_query($con,"update ledger set credit='$ret' where pno='$invno' and LabID='".$_SESSION['LabID']."'"); } calculateBalance($con,$actid); updateQty($con,$itemid); } function addStock($con,$itemid,$pno){ $qry=getName($con,"select ifnull(sum(qty),0),ifnull(sum(uprice),0) from purchase where itemid=$itemid and invno='$pno' and LabID='".$_SESSION['LabID']."'"); $qty_purchase=$qry[0]; $uprice_purchase=$qry[1]; $uprice_stock =0; $qry=getName($con,"select ifnull(sum(qty),0),ifnull(sum(uprice),0) from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); $qty_stock=$qry[0];$uprice_stock=$qry[1]; if ($qty_purchase+$qty_stock==0){ mysqli_query($con,"update item set qty=0,uprice=0 where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); }else{ $uprice=(($qty_stock*$uprice_stock)+($qty_purchase*$uprice_purchase))/($qty_stock+$qty_purchase); mysqli_query($con,"update item set qty=$qty_stock+$qty_purchase,uprice=$uprice where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); } updateQty($con,$itemid); return 0; } echo "
"; if($invno>0){ $date2=getName($con,"select date_ from purchase2 where invno='$invno' and LabID='$LabID' "); if($date2!="") $date_=date('Y-m-d',strtotime($date2)); }else{ $date_=date('Y-m-d',time()); } $company= getName($con,"select CONCAT(name,' (Balance=', balance,')') from accounts where id='$actid'") ; echo "
"; echo "
"; ?>

"; echo " "; ?>

"; echo fillList($con,"select distinct itemname from item where LabID='$LabID' order by itemname"); echo ""; ?>
"; echo "
Item Name
Size/Model
DatePriceQty%ageuPriceBiltyNotruckno"; echo "
"; $cnt=1; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $id = $row['itemid']; $name = $row['itemname']; $stock = round($row['qty'],2); $pprice = $row['pprice']; $size = $row['size']; //$model = $row['model']; if($row['model']!="") $size.="/".$row['model']; echo ""; echo "
$name
$size"; echo "
"; //echo ""; echo ":$stock"; echo ""; echo ""; echo ""; // bilty No. echo ""; //echo ""; $cnt+=1; } if($cnt>0){ $cnt-=1; echo ""; echo ""; echo ""; echo "
"; echo ""; } echo "
"; echo "
"; //echo "
"; echo "
"; ?>
PURCHASE INVOICE
#BiltyNoTruckNoNamePriceQtyAmtDelIMEI"; //$query = "select tax,itemid,qty,pprice,uprice,date_,invno,percentage,sno from purchase where LabID='$LabID' and actid=$actid and invno='$invno' order by sno desc"; $query = "select p.batchno,p.truckno,p.tax,p.itemid,p.qty,p.pprice,p.uprice,p.date_,p.invno,p.percentage,p.sno,i.itemname from purchase p,item i where p.itemid=i.itemid and p.LabID='$LabID' and p.actid=$actid and p.invno='$invno' order by p.sno desc"; $cnt=1; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $itemid = $row['itemid']; //$name = getName($con,"select itemname from item where itemid=$itemid and LabID='$LabID'"); $qty = $row['qty']; $pprice = $row['pprice']; $uprice = $row['uprice']; $date_ = $row['date_']; $pno = $row['invno']; //$percentage = $row['percentage']; //$amt=$uprice*$qty; echo ""; echo "".$row['sno']; echo "".$row['batchno']; echo "".$row['truckno']; echo "".$row['itemname']."$uprice"; echo "$qty".$uprice*$qty.""; echo ""; echo ""; $cnt+=1; } echo "
"; $query = "select amount,discount,paid,date_,actype,extracharges from purchase2 where LabID='$LabID' and invno='$invno'"; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $amt = $row['amount']; $Discount = $row['discount']; $actype = $row['actype']; $extracharges = $row['extracharges']; $paid = $row['paid']; $date_ = date('Y-m-d',strtotime($row['date_'])); } ?>
Date Invoice No : New Inv
Total Amount Discount
Extra Charges Amount Paid Paid From"; ?> Print
INVOICES
#DateInv NoAmountDiscPaidPrint"; $query = "select amount,discount,paid,date_,invno from purchase2 where LabID='$LabID' and actid='$actid' order by date_ desc,invno desc limit 10"; $cnt=1; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $amt = round($row['amount'],2); $pno = $row['invno']; //$date1 = $row['date_']; //$discount = $row['discount']; $paid = $row['paid']; //$transport = $row['transport']; echo "$cnt".$row['date_']." $pno$amt"; echo "".$row['discount']."$paid"; echo ""; $cnt+=1; } echo "
"; echo "
"; echo "
"; function deletePurchase($pno,$itemid){ $del_qty =getName($con, "select qty from purchase where itemid='$itemid' and invno='$pno' and LabID='". $_SESSION['LabID']."'"); if ($del_qty=="") $del_qty =0; $del_price =getName($con, "select uprice from purchase where itemid='$itemid' and invno='$pno' and LabID='". $_SESSION['LabID']."'"); if ($del_price=="") $del_price =0; $uprice_old = getName($con,"select uprice from item where itemid=$itemid and LabID='$LabID'"); if ($uprice_old=="") $uprice_old =0; $qty_old = getName($con,"select qty from item where itemid=$itemid and LabID='$LabID'"); if ($uprice_old=="") $uprice_old =0; if ($qty_old-$del_qty==0) $itemprice=0; else $itemprice= ($uprice_old*$qty_old-$del_qty*$del_price)/($qty_old-$del_qty); mysqli_query($con,"update item set uprice='$itemprice',qty=$qty_old-$del_qty where itemid=$itemid and LabID='". $_SESSION['LabID']."'"); } mysqli_close($con); ?>