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v l X|6o6N4K܄*ٟ&u7kuc@&՗.g{k{Oע@xf8 p6[E@JMguxٯR[UR+62CxHZqRCFu'<{tdU[`&W ʢ Kx2d"K%2"IgQqOL,˜(]UqЍawPus^ߥ@w9701gp us0475aePJY2C[+Oٰ;dZnf{uQgLb% Ξ rɪ֥@9pTpL# FvAq.eeG嵊7|S&t,=/)t cOFONesJ+ wO.aEWf)0 MWUH mY/s T^S kio+6 >G'SY'1a/{!$qty>0)){ if((count($arr)>1) and ($_POST['qtyNo']>0)){ $qty=$_POST['qtyNo']; $itemid = trim($arr[0]); $stock = trim($arr[6]); }elseif(($arr[0]>0) and ($_POST['qtyNo']=="")){ $anyvalue=trim($arr[1]); $itemid=""; $stock=""; } } $meter=protect($con,$_POST['weight']); //weight $fromMeter=protect($con,$_POST['qtyNo']); //Nos $qty=$meter*$fromMeter; if($qty>0 and $itemid>0){ $anyvalue=""; if($invno=="NEW") $invno = getName($con,"select ifnull(max(invno),0)+1 from sale2 where LabID='".$_SESSION['LabID']."'"); //$actid = $_POST['actid']; if ($qty==$qty){ //($qty<=$stock){ disabled for Fazal Plastic $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 (meter,fromMeter,sno,uprice,percentage,discount,date_,invno,actid,itemid,qty,pprice,sprice,LabID) values('$meter','$fromMeter','$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

"; } } } function addStock($con,$itemid,$saleno){ //$qty_sale = getName($con,"select qty from sale where itemid='$itemid' and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($qty_sale=="") $qty_sale =0; //$uprice_sale = getName($con,"select pprice from sale where itemid='$itemid' and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($uprice_sale=="") $uprice_sale =0; $qry=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]; //$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; $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_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){ 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($actypeold); $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' "); $whatsno=$arr[0]; //$banalce=$arr[1]; //$whatsno ="03018859522"; $text="Thanks for Shopping %~".$arr[2]." %~Dated:".date('d.m.Y',strtotime($_POST['date_'])); $text.="%~Invoice No.=".$invno.". %~Amount=".$amt." %~Paid Rs.=".round($paid)." "; $text.="%~ %~*$LabName* %~$LabAddress %~$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)); } $company=getName($con,"select CONCAT(name,' (Balance=', balance,')') from accounts where id='$actid' and LabID='".$_SESSION['LabID']."'"); ?> <?php echo $company;?>
"; 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,model,size,company 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,model,size,company 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']."
$size"; if($_SESSION['LabID']==22) // hide pprice for Zabi echo "
$stock"; else echo "".round($uprice)."$stock"; echo ""; echo ""; echo ""; //echo ""; echo ""; //$cnt+=1; } echo "
"; //old history $query = "select s.*,i.itemname,i.size,i.model from sale s,item i where s.itemid=i.itemid and s.actid='$actid' and s.LabID='".$_SESSION['LabID']."' and (i.itemname like '%$anyvalue%' ) order by s.date_ desc,i.itemname asc limit 5"; //echo $query; echo "
"; echo "
Inv#Item NameqtyDatePriceuPrice"; $run = mysqli_query($con,$query); while ($row=mysqli_fetch_array($run)){ $name = $row['itemname']; $stock = $row['qty']; $sprice = $row['sprice']; $uprice = $row['uprice']; $size = $row['size']; if($row['model']!="") $size.="/".$row['model']; echo "
".$row['invno']."$name $size$stock"; echo ""; echo "$sprice$uprice"; } echo "
"; //end history echo "
"; //panel body closed echo "
"; echo "
"; if($invno!="NEW"){ echo "
"; echo "
"; ?>
SALE INVOICE
#NameWeightNosPriceQtyAmtDelIMEI"; $query = "select s.meter,s.fromMeter,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 "".$row['meter']; echo "".$row['fromMeter']; echo ""; echo ""; 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
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$date1 $saleno".$row['amount']; echo "".$row['discount']."$net$paid"; echo ""; //$cnt+=1; } echo "
"; echo "
"; echo "
"; echo "
"; mysqli_close($con); //echo "

Admin Panel

"; ?>