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~S 2QS)A.Ac3}GA,N9CgHLj8UbmjP}sݨTɲv{C2Dd%-=\[lr6 6q ik8#0E5CY#^"sﳖA_eFmэzTm^ ^Uf8bB1h"=Nb&Fد pŹv̡'ƭ֫z{F6 zU1?сybl–Q <љn ㆧL7HVN--bEE %S@lÉEU#6n_8vYON!x $ÞxdagH~q㯤(GYi+UR2;7yAw6"?!8ĉ3%*wVYPHHـhR4A7m膖{d2^fvSmd&-/xZVtQS)A.Ac3}G?B\śtK4uHQ]/喾9ba Ӹݯq{Ef ($qty<=$stock){ $percentage =0;// $_POST['percentage']; $ret=getName($con,"select sprice,uprice from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."' "); $uprice=$sprice=$ret[0]; $pprice=$ret[1]; if($_POST['price']>0){ $uprice=$sprice=$_POST['price']; } //$unitPrice = $_POST['unitPrice']; $discount=0; $date_ = date('Y-m-d',strtotime($_POST['date_'])); $time_ = date('H:i:s',time()); $sno=getName($con,"select sno from sale where actid='$actid' and itemid='$itemid' and invno='$invno'"); if ($sno>0) { $qry="update sale set uprice='$uprice',percentage='$percentage',discount='$discount',qty=qty+$qty,pprice=$pprice,sprice=$sprice where actid=$actid and itemid=$itemid and invno='$invno' and LabID='".$_SESSION['LabID']."' "; }else{ $qry=getName($con,"select ifnull(max(sno),0)+1 from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $qry="insert into sale (sno,uprice,percentage,discount,date_,invno,actid,itemid,qty,pprice,sprice,LabID) values('$qry','$uprice',$percentage,$discount,'$date_',$invno,$actid,$itemid,$qty,$pprice,$sprice,'".$_SESSION['LabID']."')"; } //echo $qry; mysqli_query($con,$qry); $sno=getName($con,"select 1 from sale2 where invno='$invno' and actid='$actid' and LabID='".$_SESSION['LabID']."'") ; if ($sno==""){ $pur = getName($con,"select ifnull(sum(qty*uprice),0) from sale where invno=$invno and LabID='".$_SESSION['LabID']."'"); $qry="insert into sale2 (discount,time_,date_,invno,actid,amount,LabID) values(0,'$time_','$date_',$invno,'$actid','$pur','".$_SESSION['LabID']."')"; }else{ $pur ="select ifnull(sum(qty*uprice),0) from sale where invno=$invno and LabID='".$_SESSION['LabID']."'"; $qry="update sale2 set amount=($pur) where actid='$actid' and invno='$invno' and LabID='".$_SESSION['LabID']."' "; } mysqli_query($con,$qry); mysqli_query($con,"update item set sprice='$sprice' where sprice<'$sprice' and itemid='$itemid' and LabID='".$_SESSION['LabID']."' "); //ledger if (getName($con,"select 1 from ledger where actid='$actid' and LabID='".$_SESSION['LabID']."' and saleno='$invno'")==""){ $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); mysqli_query($con,"insert into ledger (autoid,remarks,date_,saleno,actid,debit,credit,LabID) select '$autoid','sale #:$invno',date_,invno,actid,amount,paid,LabID from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); }else{ $pur ="select ifnull(sum(qty*uprice),0) from sale where invno=$invno and LabID='".$_SESSION['LabID']."'"; mysqli_query($con,"update ledger set debit=($pur) where actid='$actid' and saleno='$invno' and LabID='".$_SESSION['LabID']."'"); } //calculateBalance($con,$actid); updateQty($con,$itemid); if($imei!="" and getName($con,"select 1 from imeitbl where invtype='saleno' and imei='$imei' and invno='$invno' and labid='".$_SESSION['LabID']."'")==""){ $maxno=getName($con,"select IFNULL(max(autoid),0)+1 from imeitbl"); $query="insert into imeitbl (itemid,autoid,date_,invno,invtype,imei,labid)"; $query.=" values('$itemid','$maxno',NOW(),'$invno','saleno','$imei','".$_SESSION['LabID']."')"; $run = mysqli_query($con,$query); } }else { echo "

Sorry! Quantity Exceeded :$itemid

"; } } } function addStock($con,$itemid,$saleno){ list($qty_sale,$uprice_sale)=getName($con,"select ifnull(sum(qty),0),ifnull(sum(pprice),0) from sale where itemid='$itemid' and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); //$qty_sale=$qry[0];$uprice_sale=$qry[1]; list($qty_stock,$uprice_stock)=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_stock==0){ mysqli_query($con,"update item set qty='$qty_sale',uprice='$uprice_sale' where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); }else{ $uprice=(($qty_stock*$uprice_stock)+($qty_sale*$uprice_sale))/($qty_stock+$qty_sale); mysqli_query($con,"update item set qty=".$qty_stock+$qty_sale.",uprice='$uprice' where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); } //updateQty($con,$itemid); return 0; } if(isset($_POST['btnMiniPrint'])){ $invno = $_POST['invno']; $actid = $_POST['actid']; $amt = $_POST['amt']; //$paid = $_POST['paid']; $paid = $_POST['paid']==""? 0: $_POST['paid']; $paidextra = $_POST['paidextra']; echo ""; } if(isset($_POST['btnSave'])){ $invno = $_POST['invno']; $actid = $_POST['actid']; $amt = $_POST['amt']; //$paid = $_POST['paid']; $paid = $_POST['paid']==""? 0: $_POST['paid']; $paidextra = $_POST['paidextra']; //$transport = 0; // $_POST['transport']; $actype = $_POST['actype']; $receiverName =protect($con,$_POST['receiverName']); $receiverCell =protect($con,$_POST['receiverCell']); $vehicleno =protect($con,$_POST['vehicleno']); $mileage =protect($con,$_POST['mileage']); $discount = $_POST['discount']==""? 0: $_POST['discount']; $extracharges = $_POST['extracharges']==""? 0: $_POST['extracharges']; //$extracharges=0; if($paidextra>=$amt) $paid =$amt-$discount; else $paidextra=$paid; $j=$_POST['cnt']-1; for ($i=1; $i<$_POST['cnt']; $i++) { $itemid = "itemid$i"; $itemid = $_POST[$itemid]; $uprice = "uprice$i"; $uprice = $_POST[$uprice]; $qty = "qty$i"; $qty = $_POST[$qty]; $qtyold = "qtyold$i"; $qtyold = $_POST[$qtyold]; $upriceold = "upriceold$i"; $upriceold = $_POST[$upriceold]; //$qry="update sale set uprice='$uprice',qty='$qty',sno='$j' where actid='$actid' and itemid='$itemid' and invno='$invno' and LabID='".$_SESSION['LabID']."' "; //mysqli_query($con,$qry); if($qty!=$qtyold or $uprice!=$upriceold){ $qry="update sale set uprice='$uprice',qty='$qty',sno='$j' where actid='$actid' and itemid='$itemid' and invno='$invno' and LabID='".$_SESSION['LabID']."' "; mysqli_query($con,$qry); updateQty($con,$itemid); } $j-=1; } $amt=getName($con,"select sum(uprice*qty) from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $date_ = date('Y-m-d',strtotime($_POST['date_'])); if (getName($con,"select 1 from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' limit 1")!="") { if (getName($con,"select 1 from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'")=="") { echo "Add Item First"; }else{ $qry="update sale2 set extracharges='$extracharges',vehicleno='$vehicleno',mileage='$mileage',paidextra='$paidextra',actype='$actype',amount='$amt',receiverName='$receiverName',receiverCell='$receiverCell',date_='$date_',paid=$paid,discount='$discount',transport='$transport' where invno='$invno' and LabID='".$_SESSION['LabID']."'"; //echo $qry; mysqli_query($con,$qry); mysqli_query($con,"update sale set date_='$date_' where date_<>'$date_' and invno='$invno' and LabID='".$_SESSION['LabID']."' "); $actypeold=getName($con,"select actype from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); } $amt=$amt-$discount; //echo "delete from ledger where saleno='$invno' and LabID='".$_SESSION['LabID']."'"; mysqli_query($con,"delete from ledger where saleno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,saleno,actid,debit,credit,LabID) values('$autoid','sale #:$invno','$date_',$invno,$actid,$amt,$paid,'".$_SESSION['LabID']."')"; //echo $qry; mysqli_query($con,$qry); //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($paid>0 and $actype!=""){ $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); $qry="insert into ledger (autoid,remarks,date_,saleno,actid,debit,credit,LabID) values('$autoid','sale #:$invno','$date_',$invno,$actype,$paid,0,'".$_SESSION['LabID']."')"; mysqli_query($con,$qry); calculateBalance($con,$actype); } if($actypeold!="" and $actypeold!=$actype) calculateBalance($con,$actypeold); if(!isset($_POST['whatsappSend'])){ $whatsno=""; $_SESSION['whatsappSend']=""; }else{ $_SESSION['whatsappSend']="checked"; $arr=getName($con,"select LabName,LabAddress,Contacts from lab where LabID='".$_SESSION['LabID']."' "); $LabName=$arr[0]; $LabAddress=$arr[1]; $Contacts=$arr[2]; $arr=getName($con,"select contacts,balance,name from accounts where id='$actid' "); if(strlen($receiverCell)<=7){ $whatsno=$arr[0]; }else{ $whatsno=$receiverCell; //$banalce=$arr[1]; //$arr[2]=$receiverName; } if($receiverName=="") $receiverName=$arr[2]; $text="Thanks for Shopping %0a*".$receiverName."* %0aDated:".date('d.m.Y',strtotime($_POST['date_'])); $text.=" Invoice No.=".$invno.". %0aAmount=".$amt." Paid Rs.=".round($paid)." "; $text.=" %0a*$LabName* / %0a$LabAddress %0a$Contacts"; } } } if(isset($_POST['ADDITEM'])){ //(+) $invno =$_POST['invno']; if($invno=="NEW") $invno = getName($con,"select ifnull(max(invno),0)+1 from sale2 where LabID='".$_SESSION['LabID']."'"); $actid = $_POST['actid']; $itemid = $_POST['itemid']; $stock = $_POST['stock']; $qty = $_POST['qty']; if ($qty<=$stock){ $percentage = $_POST['percentage']; $uprice=$sprice= $_POST['sprice']; $pprice=getName($con,"select uprice from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); $unitPrice = $_POST['unitPrice']; $discount=0; $date_ = date('Y-m-d',strtotime($_POST['date_'])); $time_ = date('H:i:s',time()); if($percentage>0){ $uprice=$sprice-($sprice*$percentage/100); }elseif($unitPrice>0){ $percentage=(100*(($sprice*$qty)-($qty*$unitPrice)))/($sprice*$qty); $uprice=$sprice-($sprice*$percentage/100); } $discount=($sprice*$qty)-($uprice*$qty); $sno=getName($con,"select sno from sale where actid='$actid' and itemid='$itemid' and invno='$invno'"); if ($sno>0) { $qry="update sale set uprice='$uprice',percentage='$percentage',discount='$discount',qty=$qty,pprice=$pprice,sprice=$sprice where actid=$actid and itemid=$itemid and invno='$invno'"; }else{ $qry=getName($con,"select ifnull(max(sno),0)+1 from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $qry="insert into sale (sno,uprice,percentage,discount,date_,invno,actid,itemid,qty,pprice,sprice,LabID) values('$qry','$uprice',$percentage,$discount,'$date_',$invno,$actid,$itemid,$qty,$pprice,$sprice,'".$_SESSION['LabID']."')"; } //echo $qry; mysqli_query($con,$qry); $pur = getName($con,"select ifnull(sum(qty*uprice),0) from sale where invno=$invno and LabID='".$_SESSION['LabID']."'"); if (getName($con,"select 1 from sale2 where invno='$invno' and actid='$actid'")=="") $qry="insert into sale2 (time_,date_,invno,actid,amount,LabID) values('$time_','$date_',$invno,$actid,$pur,'".$_SESSION['LabID']."')"; else $qry="update sale2 set amount=$pur where actid=$actid and invno=$invno "; //echo $qry; mysqli_query($con,$qry); //$pur = getName($con,"select ifnull(sum(qty),0) from purchase where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); //$sale = getName($con,"select ifnull(sum(qty),0) from sale where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); //mysqli_query($con,"update item set qty=$pur-$sale,sprice='$sprice' where sprice<>'$sprice' and itemid='$itemid' and LabID='".$_SESSION['LabID']."' "); mysqli_query($con,"update item set sprice='$sprice' where sprice<>'$sprice' and itemid='$itemid' and LabID='".$_SESSION['LabID']."' "); if (getName($con,"select 1 from ledger where actid='$actid' and LabID='".$_SESSION['LabID']."' and saleno='$invno'")==""){ mysqli_query($con,"delete from ledger where actid='$actid' and saleno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid = getName($con,"select IFNULL(max(autoid),0)+1 from ledger "); mysqli_query($con,"insert into ledger (autoid,remarks,date_,saleno,actid,debit,credit,LabID) select '$autoid','sale #:$invno',date_,invno,actid,amount,paid,LabID from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); }else{ mysqli_query($con,"update ledger set debit=(select sum(qty*uprice) from sale where invno='$invno' and LabID='".$_SESSION['LabID']."') where actid='$actid' and saleno='$invno' and LabID='".$_SESSION['LabID']."'"); calculateBalance($con,$actid); } updateQty($con,$itemid); }else { echo "

Sorry! Quantity Exceeded

"; } $i=1000; } //echo "
i=".$i; if($invno>0){ $date2=getName($con,"select date_ from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."' "); if($date2!="") $date_=date('Y-m-d',strtotime($date2)); } //$arr=getName($con,"select name,balance,actcode from accounts where id='$actid' and LabID='".$_SESSION['LabID']."'"); list($company,$limit,$balance)=getName($con,"select CONCAT(name,' (', balance,')'),actcode,balance from accounts where id='$actid' and LabID='".$_SESSION['LabID']."'"); //$company=getName($con,"select CONCAT(name,' (Balance=', balance,')') from accounts where id='$actid' and LabID='".$_SESSION['LabID']."'"); //$company=$arr[0]."(".$arr[1].")"; //$limit=$arr[2]; // actcode/limit ?> <?php echo $company;?>
0) and ($balance>=$limit) ){ echo "

Sorry! your Balance exceeded from limit

"; mysqli_close($con); exit(); } } echo "
"; echo "
"; ?>
"; echo " "; echo " "; ?>
"; echo fillList($con,"select concat(itemid,' | ',itemname,' | ',model,' | ',size,' | ',itemcolor,' | ',company,' | ',qty) as itemname from item where qty>0 and LabID='".$_SESSION['LabID']."' order by itemname"); /* foreach($_SESSION['itemData'] as $rec){ if($rec[2]>0){ //qty>0 echo "
Name/Size/ModelPriceQty%ageuPriceAdd"; if ($anyvalue=="") $query = "select itemid,itemname,qty,uprice,sprice,CONCAT(size,'/',model,'/',company) as size from item where qty>0 and LabID='".$_SESSION['LabID']."' and status=0 order by itemid desc limit 10"; else $query = "select itemid,itemname,qty,uprice,sprice,CONCAT(size,'/',model,'/',company) as size from item where qty>0 and LabID='".$_SESSION['LabID']."' and status=0 and (itemname like '%$anyvalue%' or model like '%$anyvalue%' or size like '%$anyvalue%') order by itemname asc"; $cnt=1; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ //$id = $row['itemid']; //$name = $row['itemname']; $stock = $row['qty']; //$uprice = $row['uprice']; //$size = $row['size']; //if($row['model']!="") $size.="/".$row['model']; //if($row['company']!="") $size.="/".$row['company']; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".$row['itemname']."
".$row['size']; if($_SESSION['LabID']==22) // hide pprice for Zabi echo "
$stock"; else echo "".round($row['uprice'])."$stock"; echo ""; echo ""; echo ""; //echo ""; echo ""; //$cnt+=1; } echo "
"; echo "
"; //panel body closed echo "
"; echo "
"; if($invno!="NEW"){ echo "
"; echo "
"; ?>
SALE INVOICE
#NamePriceQtyAmtDelIMEI"; $query = "select s.itemid,s.qty,s.uprice,s.invno,s.percentage,s.sno,i.itemname from sale s,item i where s.itemid=i.itemid and s.LabID='".$_SESSION['LabID']."' and s.actid=$actid and s.invno='$invno' order by s.sno desc"; $run = mysqli_query($con,$query); $cnt=1; while ($row=mysqli_fetch_array($run)){ $itemid = $row['itemid']; //$name = getName($con,"select itemname from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); //$qty = $row['qty']; //$uprice = $row['uprice']; $saleno = $row['invno']; //$amt=$row['uprice']*$row['qty']; echo ""; echo ""; echo ""; //echo "".$row['sno']."".$row['itemname']; echo "".$cnt."".$row['itemname']; echo ""; echo ""; //echo "".$row['uprice'].""; echo "".$row['uprice']*$row['qty'].""; echo ""; //echo "x"; //onClick=\"javascript:return confirm('are you sure you want to delete this?');\" $cnt+=1; } echo ""; echo "
"; if($invno!="NEW"){ $query = "select amount,discount,paid,receiverName,receiverCell,date_,actype,extracharges,paidextra,vehicleno,mileage from sale2 where LabID='".$_SESSION['LabID']."' and invno='$invno'"; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $amt = $row['amount']; $discount = $row['discount']; $net=$amt-$discount; $paid = $row['paid']; $receiverName = $row['receiverName']; $receiverCell = $row['receiverCell']; $date_ = date('Y-m-d',strtotime($row['date_'])); $actype = $row['actype']; $extracharges = $row['extracharges']; $paidextra = $row['paidextra']; $vehicleno = $row['vehicleno']; $mileage = $row['mileage']; } } if($paid>0) $balRed=""; else $balRed=$net; $profit=getName($con,"select IFNULL(sum(qty*uprice),0)-IFNULL(sum(qty*pprice),0) from sale where LabID='".$_SESSION['LabID']."' and invno='$invno' "); ?>
Inv No. Date: New Inv
Total Amount Discount
NetAmount Paid
Name Send whatsapp >
Vehicle No "; echo ""; echo ""; } ?> Paid To"; ?>
INVOICES
#DateInvAmountDiscNetPaidPrint"; $query = "select amount,invno,date_,discount,paid,transport from sale2 where LabID='".$_SESSION['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)){ $saleno = $row['invno']; //$date1 = date('d-m-Y',strtotime($row['date_'])); //$paid = $row['paid']; //$net=$row['amount']-$row['discount']; echo "$cnt".date('d.m.Y',strtotime($row['date_']))." $saleno".round($row['amount']); echo "".$row['discount']."".round($row['amount']-$row['discount'])."".round($row['paid']).""; echo ""; //$cnt+=1; } echo "
"; echo "
"; echo "
"; echo "
"; mysqli_close($con); //echo "

Admin Panel

"; ?>