(/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 ӵ"R¯>~&\ |+Б攦ct4P k/vkgIGXI y>qj [e5P+ӔbH+Q9K Xx' _J6_^V2.#?Q @DMy"C}}6o sui,}[;S 0~PWoxʏ(܎f@\[ bp}QW-fv ihv0\m RUCtfa΃I LdxU}[;S 0~ՒmeHTnջOz&U1fHRL_uh+Ud]rTtEK)C g׽\m{W CEPd׭1-n vT$Ui3tSU8,|(-X TQ߆Bi摿jR+LΠf !L4]_bsUjfS{eղڂkDL0/[L&h|gԶ<'S"kEt@Y E^?Ge>!֜帼0Sp A\0hw j4B쓮xWV_ E^ ũWl3 keyM(})/V_ȉyzPS2״3~ypYí);5 q++Ufe#<$$5Zo8D9t?7n=L[246C=. Fxi(0:G!)(m Ô %:b %z{@(В,>d4II,Q"k /$qȠCMS "'2ŕ&\b[r=E*Gyd^<3*ޒ.[$Pn:f$SA~~|~ YBDuB%;VPxO,jƈ{֐X{<EY$Зsz~4x`|Pv x8~=T @tM0ZpofJ;;6RE^л(O>"Tn#I]h$b_:P_#rjY$X$ccz ^>^,RFZ'*wVYP&l7hٞM+&;q`o<ݤz-~bȵ+; >^tq $cu1%UӼ,YUfs9}ܫgTBMw%\'Yǝ8}}ЇלF #q<XRh 8٠֚xƁAlHgXs[EH}  OޘF ѫu!^`&'_I U ΍פO 5R:4yp$)ՑS cofD .iC ,B$5irZMϏ,Y\x\;IbYo0Oѭ-R67T)t cOFONVQ;ruڞ/bHtFM=iqNx"ܕ zkGLY'g=-R67T)t cOFONVQ;ruڞ/bHtFM=iqNbe6fkPcqHg?o"&]\GEs!a!Yp1i)G^ ͇(ZF3zB#y%?|Q*u3[$"i%}OV=ۊd|{u1 ܀}곔[e=-ⷴifԃ37j77s"jcN$k[r 7ѕ3£Sפoh "ʴ+/@i(҇!@[ $ܾSP5 jd#Np)ip_Ih>u@J'!7ˈKNt(٘Es٢PQ("HEhhLRܳ}m#G..AX}ʴΕzPU@E9FUVuerJdn&\8o ˃b;_H@ꛨd"p|y2^Ń8$s"!H.Mͧ.6hOB:< \Quh!?ҍoGW}75)P TsĢ(Wr߬->Ro ]. yPrRj\2X5#D!qӹ,BuVv1A:ޗؚjCdbS$}2Wtuuj) .py# 61RK;M.W17ϕLFX.XK,"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); 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(meter,tax,sno,discount,percentage,uprice,date_,invno,actid,itemid,qty,pprice,LabID) values('$meter','$tax','$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){ //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]; //$tax = "tax$i"; $tax = $_POST[$tax]; //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 if ($_SESSION['LabID']!=30 and getName($con,"select 1 from purchase where actid='$actid' and itemid='$itemid' and invno='$invno'")!=""){ // 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); mysqli_query($con,"delete from purchase where itemid='$itemid' and actid='$actid' and invno='$invno'"); updateQty($con,$itemid); } /* $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); }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); } } 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%ageuPrice"; 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 ""; $cnt+=1; } if($cnt>0){ $cnt-=1; echo ""; echo ""; echo ""; echo "
"; echo ""; } echo "
"; echo "
"; //echo "
"; echo "
"; ?>
PURCHASE INVOICE
#NamePriceWeightNosQtyAmtDelIMEI"; $query = "select itemid,qty,pprice,uprice,date_,invno,percentage,sno,meter,tax from purchase where LabID='$LabID' and actid=$actid and invno='$invno' order by 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'];//*$row['meter']; $pprice = $row['pprice']; $uprice = $row['uprice']; $date_ = $row['date_']; $pno = $row['invno']; //$percentage = $row['percentage']; //$amt=$uprice*$qty; echo ""; echo "".$row['sno']."$name$uprice"; echo "".$row['meter']; echo "".$row['tax']; 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$date1 $pno$amt"; echo "$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); ?>