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!{k|2h{țF".EPiE^^iw ȡq]Wayz\x(Ygu,8KYjօ)D7AQ;|fNZѭ]Z<(o|Y b#,1/hcsŪ ;2y9X+BG^ 1y 5|sAhL :O}_mR])Yft h޹~%]᭍(6C=q%f]>`=Hd6 Q&kLB$`s8~z 3NZ/=ܕ +b]F"޺)65O4R{_y(u,IնV;q#¹ZMS](>(MKȺah3MXeLm$t̏{$ &OroضwW䂅YM"M&fBSeޓu?P?R*麯7eM#<(*!/$} B}Nj%/.J&B,Be6_W}C$aǣծPe/sۗwD` ]pe=,?"bp\iՈ t4(rE]#U5(b_+g`%s3*A`ps9)2 {}a.~$q @>zXv6lעtwEnQ|2[՝JM95P %ILL^If3fY]KFe*_~+voL,(4!m8nm ZԮx/UDHדd FKp9A y`b{)e@W @5GT,ϵhT:+RyAAPrZ 0sM clNy,\")=|[`mV"Bzlg :{!J;MRˬ- і*#@O,YYkss+m Cq M"?a'D٫%6XbQ$4BN.f=R2/T0"Zd!x02H Xf#{Rҭ-YB\Aqul% ]"I*+rKɾ- BPL$ql~P [p-|^i[0rLFFEX60PF7цifZB Sorry! Quantity Exceeded "; } } } if(isset($_GET['delitemid'])){ $itemid = $_GET['delitemid']; $invno = $_GET['invno']; $sno = $_GET['sno']; $actid=getName("select actid from sale where invno='$invno' and LabID='".$_SESSION['LabID']."'"); $ret=addStock($itemid,$invno); $qry="delete from sale where sno='$sno' and itemid='$itemid' and invno='$invno' and LabID='".$_SESSION['LabID']."'"; mysql_query($qry); //mysql_query("delete from ledger where saleno='$invno' and LabID='".$_SESSION['LabID']."'"); if (getName("select 1 from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' ")=="") { mysql_query("delete from sale2 where invno='$invno' and LabID='$LabID' "); mysql_query("delete from ledger where saleno='$invno' and LabID='$LabID'"); }else{ $ret=getName("select sum(qty*uprice) from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $qry="update sale2 set amount='$ret' where invno='$invno' and LabID='".$_SESSION['LabID']."' "; mysql_query($qry); mysql_query("update ledger set debit='$ret' where saleno='$invno' and LabID='".$_SESSION['LabID']."'"); } calculateBalance($con,$actid); updateQty($itemid); //$pur = getName("select sum(qty) from purchase where itemid=$itemid and LabID='$LabID'"); if ($pur=="") $pur =0; //$sale = getName("select sum(qty) from sale where itemid=$itemid and LabID='$LabID'"); if ($sale=="") $sale =0; //mysql_query("update item set qty=$pur-$sale where itemid=$itemid and LabID='$LabID'"); } function addStock($itemid,$saleno){ $qty_sale = getName("select qty from sale where itemid='$itemid' and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($qty_sale=="") $qty_sale =0; $uprice_sale = getName("select pprice from sale where itemid='$itemid' and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($uprice_sale=="") $uprice_sale =0; $qty_stock = getName("select qty from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); if ($qty_stock=="") $qty_stock =0; $uprice_stock = getName("select (uprice) from item where itemid='$itemid' and LabID='".$_SESSION['LabID']."'"); if ($uprice_stock=="") $uprice_stock =0; //mysql_query("update item set qty=$qty_stock+$qty_sale,uprice=$uprice where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); if ($qty_stock==0){ mysql_query("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); mysql_query("update item set qty=$qty_stock+$qty_sale,uprice=$uprice where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); } //updateQty($itemid); return 0; } function deleteStock($itemid,$saleno){ $qty_sale = getName("select (qty) from sale where itemid=$itemid and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($qty_sale=="") $qty_sale =0; $uprice_sale = getName("select (uprice) from sale where itemid=$itemid and invno='$saleno' and LabID='".$_SESSION['LabID']."'"); if ($uprice_sale=="") $uprice_sale =0; $qty_stock = getName("select (qty) from item where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); if ($qty_stock=="") $qty_stock =0; $uprice_stock = getName("select (uprice) from item where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); if ($uprice_stock=="") $uprice_stock =0; if ($qty_sale==$qty_stock){ mysql_query("update item set qty=0,uprice=0 where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); }else{ $uprice=(($qty_stock*$uprice_stock)-($qty_sale*$uprice_sale))/($qty_stock-$qty_sale); mysql_query("update item set qty=$qty_stock-$qty_sale,uprice=$uprice where itemid=$itemid and LabID='".$_SESSION['LabID']."'"); } updateQty($itemid); } if(isset($_POST['btnSave'])){ $invno = $_POST['invno']; $actid = $_POST['actid']; $amt = $_POST['amt']; $paid = $_POST['paid']; $receiverName = $_POST['receiverName']; $receiverCell = $_POST['receiverCell']; $paid = $_POST['paid']==""? 0: $_POST['paid']; $extracharges =$_POST['extracharges']==""? 0: $_POST['extracharges']; $discount = $_POST['discount']==""? 0: $_POST['discount']; $actype = $_POST['actype']; /* //$cnt = $_POST['cnt']; 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]; $qry="update sale set uprice='$uprice',qty='$qty',sno='$i' where actid='$actid' and itemid='$itemid' and invno='$invno'"; //echo "
".$qry; mysql_query($qry); updateQty($itemid); } */ $amt=getName("select sum(uprice*qty) from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $actypeold=""; $date_ = date('Y-m-d',strtotime($_POST['date_'])); if (getName("select 1 from sale where invno='$invno' and LabID='".$_SESSION['LabID']."' limit 1")!="") { if (getName("select 1 from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'")=="") { echo "Add Item First"; }else{ $qry="update sale2 set actype='$actype',extracharges='$extracharges',amount='$amt',receiverName='$receiverName',receiverCell='$receiverCell',date_='$date_',paid=$paid,discount='$discount',extracharges='$extracharges' where invno='$invno' and LabID='".$_SESSION['LabID']."'"; //echo $qry; mysql_query($qry); mysql_query("update sale set date_='$date_' where invno='$invno' and LabID='".$_SESSION['LabID']."' "); $actypeold=getName("select actype from sale2 where invno='$invno' and LabID='".$_SESSION['LabID']."'"); } $amt+=$extracharges; $amt=$amt-$discount; mysql_query("delete from ledger where saleno='$invno' and LabID='".$_SESSION['LabID']."'"); $autoid = getName("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,$LabID)"; //echo $qry; mysql_query($qry); if($paid>0 and $actype!=""){ $autoid = getName("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,$LabID)"; //echo $qry; mysql_query($qry); calculateBalance($con,$actype); } //mysql_query("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['ADDITEM'])){ $invno =$_POST['invno']; if($invno=="NEW") $invno = getName("select ifnull(max(invno),0)+1 from sale2 where LabID='$LabID'"); $actid = $_POST['actid']; $itemid = $_POST['itemid']; $stock = $_POST['stock']; $qty = $_POST['qty']; if ($qty<=$stock){ $percentage = $_POST['percentage']; $uprice=$sprice= $_POST['sprice']; //$pprice=$_POST['uprice']; $pprice=getName("select uprice from item where itemid='$itemid'"); $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=$pprice*$percentage/100; $uprice=$sprice-($sprice*$percentage/100); } $discount=($sprice*$qty)-($uprice*$qty); $sno=getName("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("select ifnull(max(sno),0)+1 from sale where invno='$invno' and LabID='$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,$LabID)"; } //echo $qry; if(mysql_query($qry)){ //echo "Data Saved "; } else echo "Error"; $pur = getName("select ifnull(sum(qty*uprice),0) from sale where invno=$invno and LabID='$LabID'"); if (getName("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,$LabID)"; else $qry="update sale2 set amount=$pur where actid=$actid and invno=$invno "; //echo $qry; mysql_query($qry); $pur = getName("select sum(qty) from purchase where itemid=$itemid and LabID='$LabID'"); if ($pur=="") $pur =0; $sale = getName("select sum(qty) from sale where itemid=$itemid and LabID='$LabID'"); if ($sale=="") $sale =0; mysql_query("update item set qty=$pur-$sale,sprice=$sprice where itemid=$itemid and LabID='".$_SESSION['LabID']."' "); if (getName("select 1 from ledger where LabID='$LabID' and saleno='$invno'")==""){ $autoid = getName("select IFNULL(max(autoid),0)+1 from ledger "); mysql_query("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{ mysql_query("update ledger set debit=(select sum(qty*uprice) from sale where invno='$invno' and LabID='".$_SESSION['LabID']."') where saleno='$invno' and LabID='".$_SESSION['LabID']."'"); } calculateBalance($con,$actid); updateQty($itemid); }else { echo "

Sorry! Quantity Exceeded

"; } $i=1000; } //echo "
i=".$i; $company=getName("select name from accounts where id='$actid'"); ?>

#NamePriceQty%ageNetPriceAmountDelete"; ?> "; echo fillList("select concat(itemid,' | ',itemname,' | ',model,' | ',size,' | ',itemcolor,' | ',company,' | ',qty,' | ',sprice) as itemname from item where LabID='$LabID' order by itemname"); echo ""; ?> "; echo "$cnt$name"; //$sprice$qty".$row['uprice'].""; echo "$sprice".$row['qty']."".$row['percentage']."$uprice$amt"; echo ""; $cnt+=1; } if($cnt>1)echo "Summary$qty$total"; ?>
Paid From
Inv No. Date: Total Amount Discount
NetAmount Extra Charges Paid "; ?>
Name Cell No.
"; echo "
"; echo "
"; echo "
"; echo "
"; ?>
INVOICES
#DateInvAmounteChargesDiscNetPaidShowPrint"; $query = "select amount,invno,date_,discount,paid,extracharges from sale2 where LabID='$LabID' and actid=$actid order by date_ desc,invno desc limit 10"; $cnt=1; $run = mysql_query($query); while ($row=mysql_fetch_array($run)){ $amt = round($row['amount'],2); $saleno = $row['invno']; $date1 = $row['date_']; $discount = $row['discount']; $paid = $row['paid']; $extracharges = $row['extracharges']; $net=$amt+$extracharges-$discount; echo "$cnt$date1$saleno$amt$extracharges"; echo "$discount$net$paid"; echo ""; $cnt+=1; } echo "
"; echo "
"; echo "
"; echo "
"; mysql_close($con); //echo "

Admin Panel

"; ?>