I:ܫc+]YF3KD $ײ >W\x6t)" >k0)H2${#B+vl-БUPoiXFhFTW +3翿1vW(gZsd *,6{@)13L넑EFwzʙڿ% E$IhgꅓBwϚ6;j@AZ[_q-|'ѡ'l!L{B9RO<{ΨXɦ_=2(J* 9?d\.GX,")- zuO`)K?|¼eMtJLHBgTHm{ёL|Î$CmرkO]mFP#ʹm1RFȺn7mϷoƃtK \,3n4L Oݮ$ΖdF_RxVr #}fŦ[|vbTVOEdMɱ0XGX$Ey*xX.׊SDDP^pF˲`7̻կIYW`T3V&ZThCZQ+ipn: QOR,LKPXI7V MM#a+ f<"7gvyv.ުftqwB/QBCW;-Z!+TP˵{4ܱOWM)KRߡǾu:I..Q0(O/'H7b5υ#DxIQkkٰZr}WF^Hf_lҫ}qW8?O`)j! lf[~f跥 y}]?Lj,,\n=ԇA?.KH~V}k2IRa!3:[dps  {! ] 杻\MR s6COfժװk k}V9 7oUYuNh N8*R\g Ro7b5υ#DxIQk#Tfl1G(e٫w7Nk[z-=T9xo)UPl^ɮFWH1N4vK HC|*gC$PagﻟTyp;ﻟTyp;lLE&1G[B~96rvzO'.JJ$4CtAu7➤,&n&SkE9KljYך!7u7 Pc{NuUKjMcoO$I%Mjdn렔xoԮ&q\N{4brffMmG)Čj|sL ;ﻟTyp;ﻟTyp;ﻟTyp;V$7P$#: }g]K=̒Ofsɲvn gK!'L ީ:z8pŎSz0h{X 0)wgᡵw-eIv` 阺jVFB-]e=uS%a+Ф8 ވ\R#o g-l3R-< +dOyuhGge5_r2Y֏Uݼ nһ7ybIVvєz+Zk~F s D8a0Co5-jhUX>m%Pdle-˯mq !2ac|boD]WI>G?wVU9Z> I`d4̮zjL77)}B)_)U zG~5i:ehN$wM݂J<5X^ XE/#KBvsn|xرS,(bX[W8D_OBB8+HM,hUD$*[]N+M|u߷ȉyzm<z[ᑠMO0<CPTY>}=N4lakʓ5J:*'ߊ:v-k)5?MMy0Tsu9Ixԕ~21G*;ZTPmVEw.BTD;%94BϵP@ Kó'Kziܠa-R0=PjҋYMaY.wç<|\tؐUB.;٫: >AoPC^WV0V۫/Rk,j] Kj69jrRSsZ(kDN~ cd8*ukӮ4dىO4yo!6߿}o?" SVJf4]Es>ү)_up\'퇊Lxzc`vw)]*3VuJ) Rb-=O9PܩT頓DŽtL%Ύ,ۋU >xb/Z㰊nMi`]BX#eek4'5(i :=df̍ evPDj@Uk%~oR_* b~ d, Yh0GG/miǞEyR@6J0mq돬0:t!=5y i <]`*Dp>F<ܤVK(-:sSKƨ-Rә_Fwg/ۃyES?j֛MNfΎWR">\?0<CPTSU=\)/"!H'|lu1jP62[`hAqGAqs,u͔T37rӟT /%N> 1.! P'FX>Î9x-L"bBakS-6&~颺L֖}u8f\LNuFAd}ik kh v&lsv,p4x"fZJ+;M8[:QJ7y6tREyڣ_8'ǔ(t˶X)/,V pQBmr\i^}`iu#T-:m,.O0]kRBgL~\ {%2qgj$LCddColumn($conn,"itemInOutSummary","labid","int",1); $cur= odbc_exec( $conn,"update itemTable set labid='".$_SESSION['labid']."' where labid is null"); $cur= odbc_exec( $conn,"update itemInOut set labid='".$_SESSION['labid']."' where labid is null"); $cur= odbc_exec( $conn,"update itemInOutSummary set labid='".$_SESSION['labid']."' where labid is null"); $cur=addColumn($conn,"itemInOutSummary","paymentTo","int"); $cur=addColumn($conn,"itemInOut","sTax","float"); $cur=addColumn($conn,"itemInOut","sno","tinyint"); $cur2= odbc_exec( $conn,"update itemInOut set sTax=0 where sTax is null"); function addStock($conn,$itemID,$qty,$batchNo,$expiry,$uPrice,$tPrice) { if($qty>0){ //$isPresent=getName($conn,"select 1 from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); if(""==getName($conn,"select 1 from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'")){ $qry="insert into itemTable (labid,itemID2,qty,uPrice,batchNo,expiry) values('".$_SESSION['labid']."','$itemID','$qty','$uPrice','$batchNo','$expiry')"; $cur2= odbc_exec( $conn, $qry); }else{ $qty1=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='$itemID' and batchNo='$batchNo' and pNo>0"); $qty1+=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='$itemID' and batchNo='$batchNo' and saleRNo>0"); $qty1-=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='$itemID' and batchNo='$batchNo' and saleNo>0"); $qty1-=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='$itemID' and batchNo='$batchNo' and pRNo>0"); $qty2=getName($conn,"select qty from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $uPrice2=getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); if(($qty+$qty2)>0){ $uPrice=(($qty*$uPrice)+($qty2*$uPrice2))/($qty+$qty2); } $qry="update itemTable set qty=$qty1,uPrice=$uPrice where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } $qry="update itemTable set qty=(select sum(qty) from itemTable where itemID2='$itemID') where itemID='$itemID'"; $cur2= odbc_exec( $conn, $qry); if($tPrice>0) $cur2= odbc_exec( $conn, "update itemTable set tPrice='$tPrice' where itemID='$itemID'"); }else{ } return 0; } function deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo) { $uPrice="";$qty=""; $query= "select qty,uPrice,pPrice from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur= odbc_exec( $conn, $query ); while( odbc_fetch_row( $cur ) ) { $qty= odbc_result( $cur, 'qty' ); $uPrice= round(odbc_result( $cur,'uPrice')); $pPrice= round(odbc_result( $cur,'pPrice')); } $query= "select qty,uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur1= odbc_exec( $conn, $query ); while(odbc_fetch_row( $cur1 ) ) { $qtyTotal= odbc_result( $cur1, 'qty' ); $uPriceTotal= round(odbc_result( $cur1,'uPrice')); } if($invType=="pNo"){ if($qty<$qtyTotal){ $uPrice=(($qtyTotal*$uPriceTotal)-($qty*$uPrice))/($qtyTotal-$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); }else{ $cur2= odbc_exec( $conn, "update itemTable set uPrice='0' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); } }elseif($invType=="pRNo"){ $uPrice=(($qtyTotal*$uPriceTotal)+($qty*$uPrice))/($qtyTotal+$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); }elseif(($invType=="saleNo") and ($qtyTotal+$qty>0)){ $uPrice=(($qtyTotal*$uPriceTotal)+($qty*$pPrice))/($qtyTotal+$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); }elseif(($invType=="saleRNo") and($qtyTotal-$qty>0)){ $uPrice=(($qtyTotal*$uPriceTotal)-($qty*$pPrice))/($qtyTotal-$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } $cur= odbc_exec( $conn, "delete from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'" ); $cur=updateStock($conn,$itemID,$batchNo) ; $isAny=getName($conn,"select top 1 qty from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); if($isAny==""){ odbc_exec( $conn, "delete from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' " ); $remarks="Purchase Invoice:".$invNo; odbc_exec( $conn, "delete from Ledger where remarks='$remarks' and labid='".$_SESSION['labid']."'" ); } return 0; } function addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry) { $uPrice=0;$qty=0; if(""==getName($conn,"select 1 from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'")){ $qry="insert into itemTable (labid,itemID2,qty,uPrice,batchNo,expiry) values('".$_SESSION['labid']."','$itemID','$qty','$uPrice','$batchNo','$expiry')"; $cur2= odbc_exec( $conn, $qry); } $query= "select qty,uPrice,pPrice,tPrice from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'"; $cur= odbc_exec( $conn, $query ); while( odbc_fetch_row( $cur ) ) { $qty= odbc_result( $cur, 'qty' ); $uPrice= round(odbc_result( $cur,'uPrice')); $pPrice= round(odbc_result( $cur,'pPrice')); } $query= "select qty,uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur1= odbc_exec( $conn, $query ); while(odbc_fetch_row( $cur1 ) ) { $qtyTotal= odbc_result( $cur1, 'qty' ); $uPriceTotal= round(odbc_result( $cur1,'uPrice')); } if($invType=="pNo"){ $uPrice=(($qtyTotal*$uPriceTotal)+($qty*$uPrice))/($qtyTotal+$qty); $qry="update itemTable set uPrice='$uPrice',expiry='$expiry',tPrice='".odbc_result($cur,'tPrice')."' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); $cur2= odbc_exec( $conn, "update itemTable set tPrice='".odbc_result($cur,'tPrice')."' where itemID='$itemID'"); }elseif($invType=="pRNo"){ if($qtyTotal-$qty>0){ $uPrice=(($qtyTotal*$uPriceTotal)-($qty*$pPrice))/($qtyTotal-$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } }elseif($invType=="saleNo"){ $cur="do nothing just update stock";//updateStock($conn,$itemID,$batchNo) ; }elseif($invType=="saleRNo"){ $uPrice=(($qtyTotal*$uPriceTotal)+($qty*$pPrice))/($qtyTotal+$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } $cur=updateStock($conn,$itemID,$batchNo) ; return 0; } function updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,$paidAmount,$discount,$paymentTo){ if($visitNo=="") $visitNo=0; if($patientID=="") $patientID=0; $amount=getName($conn,"select sum(uPrice*qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."'"); $cur= odbc_exec( $conn, "delete from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."'" ); $isAny=getName($conn,"select top 1 qty from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); if($isAny!=""){ $query="insert into itemInOutSummary(labid,paymentTo,time_,visitNo,patientID,userID,date_,$invType,accountID,amount,paid,discount) values ('".$_SESSION['labid']."','$paymentTo',getdate(),'$visitNo','$patientID','".$_SESSION['userID']."','$date_','$invNo','$accountID','$amount','$paidAmount','$discount')"; $cur= odbc_exec( $conn, $query ); } //$cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' and labid='".$_SESSION['labid']."' " ); //Update Ledger if($invType=="pNo"){ $remarks="Purchase Invoice:".$invNo; $query="insert into ledger(date_,accountID,debit,credit,remarks,labid)"; $query.=" select '$date_',accountID,paid,amount-discount,'$remarks',labid from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "; $cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' " ); if($paidAmount>0)$cur= odbc_exec( $conn,"insert into ledger(labid,date_,accountID,debit,credit,remarks) select labid,'$date_','$paymentTo',0,paid,'$remarks' from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "); }elseif($invType=="pRNo"){ $remarks="Purchase Return Invoice:".$invNo; $query="insert into ledger(date_,accountID,debit,credit,remarks,labid)"; $query.=" select '$date_',accountID,amount-discount,paid,'$remarks',labid from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "; $cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' and labid='".$_SESSION['labid']."' " ); if($paidAmount>0)$cur= odbc_exec( $conn,"insert into ledger(labid,date_,accountID,debit,credit,remarks) select labid,'$date_','$paymentTo',paid,0,'$remarks' from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' ") ; }elseif($invType=="saleNo"){ $remarks="Sale Invoice:".$invNo; $query="insert into ledger(date_,accountID,debit,credit,remarks,labid)"; $query.=" select '$date_',accountID,amount-discount,paid,'$remarks',labid from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "; $cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' and labid='".$_SESSION['labid']."' " ); if($paidAmount>0)$cur= odbc_exec( $conn,"insert into ledger(labid,date_,accountID,debit,credit,remarks) select labid,'$date_','$paymentTo',paid,0,'$remarks' from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' " ); }elseif($invType=="saleRNo"){ $remarks="Sale Return Invoice:".$invNo; $query="insert into ledger(date_,accountID,debit,credit,remarks,labid)"; $query.=" select '$date_',accountID,paid,amount-discount,'$remarks',labid from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "; $cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' and labid='".$_SESSION['labid']."' " ); if($paidAmount>0)$cur= odbc_exec( $conn,"insert into ledger(labid,date_,accountID,debit,credit,remarks) select labid,'$date_','$paymentTo',0,paid,'$remarks' from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' " ); } $cur= odbc_exec( $conn, $query ); $qty=getName($conn,"select sum(qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."'"); if($qty==""){ $cur= odbc_exec( $conn, "delete from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."'" ); $cur= odbc_exec( $conn, "delete from ledger where remarks='$remarks' and labid='".$_SESSION['labid']."' " ); } $cur=calculateBalance($conn,$accountID); return 0; } if(isset($_POST['visitNo'])) $visitNo= $_POST['visitNo']; if(isset($_POST['patientName'])) $patientName= $_POST['patientName']; if(isset($_POST['patientID'])) $patientID= $_POST['patientID']; if(isset($_POST['invType'])) $invType= $_POST['invType']; if(isset($_POST['accountID'])) $accountID= $_POST['accountID']; if(isset($_POST['invNo'])) $invNo= $_POST['invNo']; if(isset($_GET['ID'])) $accountID= $_GET['ID']; if(isset($_POST['ID'])) $accountID= $_POST['ID']; if(isset($_GET['visitNo'])) $visitNo= $_GET['visitNo']; if(isset($_GET['accountID'])) $accountID= $_GET['accountID']; if(isset($_GET['patientID'])) $patientID= $_GET['patientID']; if(isset($_GET['invType'])) $invType= $_GET['invType']; if(isset($_GET['pNo'])) $invNo= $_GET['pNo']; if(isset($_GET['pRNo'])) $invNo= $_GET['pRNo']; if(isset($_GET['saleNo'])) $invNo= $_GET['saleNo']; if(isset($_GET['saleRNo'])) $invNo= $_GET['saleRNo']; if(isset($_GET['invNo'])) $invNo= $_GET['invNo']; if(isset($_POST['anyvalue'])) $anyvalue= trim($_POST['anyvalue']); if($anyvalue!=""){ $anyvalue= substr($anyvalue,0,100); $itemID=getName($conn,"select itemID2 from itemTable where barCode='$anyvalue'"); if($itemID==""){ if(is_numeric($anyvalue)){ if(strlen($nyvalue)>7) $itemID =(int)(substr($anyvalue,0,strlen($anyvalue)-1)); else $itemID =$anyvalue; //echo ""; } } if($itemID!=""){ //echo ""; $batchNo=getName($conn,"select top 1 batchNo from itemTable where itemID2='$itemID' and qty>=1 order by expiry asc"); //echo ""; if($batchNo!=""){ if(($invNo=="") or (strtoupper($invNo)=="NEW")) $invNo=getName($conn,"select isnull(max($invType),0)+1 from itemInOut"); $qty= (int) getName( $conn, "select qty from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" ); if($qty!=""){ $sno= (int) getName( $conn, "select sno from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" ); $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); //$qty+=1; if($_POST['qtyInSeach']=="") $qty+=1; else $qty=$_POST['qtyInSeach']; }else{ if($_POST['qtyInSeach']=="") $qty=1; else $qty=$_POST['qtyInSeach']; } if($sno=="") $sno=(int) getName( $conn, "select isnull(max(sno),0)+1 from itemInOut where $invType='$invNo' " ); $tPrice = getName($conn,"select rPrice from itemTable where itemID='$itemID' "); $query="insert into itemInOut(labid,sno,userID,expiry,pPrice,date_,$invType,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" select '".$_SESSION['labid']."','$sno','".$_SESSION['userID']."',expiry,uPrice,'$date_','$invNo','$accountID','$itemID','$qty','$tPrice',0,0,'$tPrice','$batchNo' from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; //echo $query; $cur= odbc_exec( $conn, $query ); //update stock and uPrice //$expiry= getName( $conn, "select qty from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" ); //$expiry=getName($conn,"select max(expiry) from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $expiry=getName($conn,"select min(expiry) from itemTable where qty>=1 and itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $expiry = date('Y-m-d',strtotime($expiry)); $cur= addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry); $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,0,0,0); echo ""; }else{ $anyvalue=getName($conn,"select itemName from itemTable where itemID='$itemID'"); $itemID=""; } //echo ""; } $str=explode(':',$anyvalue); $anyvalue=trim($str[0]); } if(isset($_POST['btnSaveInvoiceTotal2'])){ $date_= date('Y-m-d',strtotime($_POST['date_'])); $invType = $_POST['invType']; $invNo = $_POST['invNo']; $accountID = $_POST['accountID']; $amount=getName($conn,"select sum(uPrice*qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); //$discount = $_POST['discount']; $paidAmount = $_POST['paidAmount']; $patientID = $_POST['patientID']; $visitNo = $_POST['visitNo']; $cnt = $_POST['cnt']; for ($i=1; $i<=$cnt; $i++) { $itemID = "itemID$i"; $itemID = $_POST[$itemID]; $qty = "qty$i"; $qty = $_POST[$qty]; $percentage = "percentage$i"; $percentage = $_POST[$percentage]; $tPrice = "tPrice$i"; $tPrice = $_POST[$tPrice]; $uPrice = "uPrice$i"; $uPrice = $_POST[$uPrice]; $sTax = "sTax$i"; $sTax = $_POST[$sTax]; if($percentage>0 and $qty>0){ $uPrice=(($tPrice*$qty)-($tPrice*$qty*$percentage/100))/$qty; $discount=($tPrice*$qty)-($uPrice*$qty); }elseif($uPrice>0 and $qty>0){ $percentage=(100*(($tPrice*$qty)-($qty*$uPrice)))/($tPrice*$qty); $discount=($tPrice*$qty)-($uPrice*$qty); }else{ $uPrice=$tPrice; $discount=0; } $batchNo = "batchNo$i"; $batchNo = $_POST[$batchNo]; if($batchNo=="") $batchNo='0'; $expiry = "expiry$i"; $expiry = date('Y-m-d',strtotime($_POST[$expiry])); if($qty>0){ //if("1"==getName( $conn, "select 1 from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" )){ $sno=getName( $conn, "select sno from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' "); if($sno!=""){ $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); }else{ $sno=getName( $conn, "select isnull(max(sno),0)+1 from itemInOut where $invType='$invNo' "); } $pPrice = getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $query="insert into itemInOut(labid,sno,sTax,userID,expiry,pPrice,date_,$invType,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" values ('".$_SESSION['labid']."','$sno','$sTax','".$_SESSION['userID']."','$expiry','$pPrice','$date_','$invNo','$accountID','$itemID','$qty','$tPrice','$percentage','$discount','$uPrice','$batchNo')"; $cur= odbc_exec( $conn, $query ); //update stock and uPrice $cur= addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry); } } $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,$paidAmount,$_POST['discount'],$_POST['paymentTo']); echo ""; } if(isset($_POST['btnSaveInvoiceTotal'])){ $date_= date('Y-m-d',strtotime($_POST['date_'])); $invType = $_POST['invType']; $invNo = $_POST['invNo']; $accountID = $_POST['accountID']; $amount=getName($conn,"select sum(uPrice*qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); //$discount = $_POST['discount']; $paidAmount = $_POST['paidAmount']; $patientID = $_POST['patientID']; $visitNo = $_POST['visitNo']; $cnt = $_POST['cnt']; for ($i=1; $i<=$cnt; $i++) { $itemID = "itemID$i"; $itemID = $_POST[$itemID]; $qty = "qty$i"; $qty = $_POST[$qty]; $percentage = "percentage$i"; $percentage = $_POST[$percentage]; $tPrice = "tPrice$i"; $tPrice = $_POST[$tPrice]; $uPrice = "uPrice$i"; $uPrice = $_POST[$uPrice]; $sTax = "sTax$i"; if(isset($_POST[$sTax])) $sTax = $_POST[$sTax]; else $sTax =0; if($percentage>0 and $qty>0){ $uPrice=(($tPrice*$qty)-($tPrice*$qty*$percentage/100))/$qty; $discount=($tPrice*$qty)-($uPrice*$qty); }elseif($uPrice>0 and $qty>0){ $percentage=(100*(($tPrice*$qty)-($qty*$uPrice)))/($tPrice*$qty); $discount=($tPrice*$qty)-($uPrice*$qty); }else{ $uPrice=$tPrice; $discount=0; } $batchNo = "batchNo$i"; $batchNo = $_POST[$batchNo]; if($batchNo=="") $batchNo='0'; $expiry = "expiry$i"; $expiry = date('Y-m-d',strtotime($_POST[$expiry])); //if($qty>0 and $tPrice>0){ if($qty>0){ //if("1"==getName( $conn, "select 1 from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" )){ $sno=getName( $conn, "select sno from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' "); if($sno!=""){ $cur=deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); }else{ $sno=getName( $conn, "select isnull(max(sno),0)+1 from itemInOut where $invType='$invNo' "); } $pPrice = getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $query="insert into itemInOut(labid,sno,sTax,userID,expiry,pPrice,date_,$invType,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" values ('".$_SESSION['labid']."','$sno','$sTax','".$_SESSION['userID']."','$expiry','$pPrice','$date_','$invNo','$accountID','$itemID','$qty','$tPrice','$percentage','$discount','$uPrice','$batchNo')"; $cur= odbc_exec( $conn, $query ); //update stock and uPrice $cur= addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry); } } //$discount = $_POST['discount']; $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,$paidAmount,$_POST['discount'],$_POST['paymentTo']); echo ""; } if($patientID!="") $patientName=getName($conn,"select name from patientTab where patientID='$patientID'"); //Delete item in Invoice if(isset($_GET['delID'])){ $itemID= $_GET['delID']; $accountID= $_GET['accountID']; $invType= $_GET['invType']; $invNo= $_GET['invNo']; $batchNo= $_GET['batchNo']; $qty= $_GET['qty']; $date_ = date('Y-m-d',time()); $patientID= $_GET['patientID']; $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,0,0,0); } if(isset($_GET['showID'])){ $accountID= $_GET['showID']; $invType= $_GET['invType']; $invNo= $_GET['invNo']; $date_=getName($conn,"select date_ from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "); $date_ = date('Y-m-d',strtotime($date_)); } //if(isset($_POST['btnSearch'])){ if(isset($_POST['qtyInSeach']) and $_POST['qtyInSeach']>0){ $invType= $_POST['invType']; $qtyInSeach=$_POST['qtyInSeach']; //$patientID=$_POST['patientID']; //$accountID=$_POST['accountID']; $itemID=getName($conn,"select itemID from itemTable where itemName='$anyvalue'"); $batchNo=getName($conn,"select top 1 batchNo from itemTable where itemID2='$itemID' and qty>='$qtyInSeach' order by expiry"); if($batchNo!=""){ if(($invNo=="") or (strtoupper($invNo)=="NEW")) $invNo=getName($conn,"select isnull(max($invType),0)+1 from itemInOut"); //if("1"==getName( $conn, "select 1 from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" )){ // $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); //} $sno=getName( $conn, "select sno from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."' "); if($sno!=""){ $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); }else{ $sno=getName( $conn, "select isnull(max(sno),0)+1 from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); } //$tPrice = getName($conn,"select tPrice from itemTable where itemID='$itemID' "); $tPrice = getName($conn,"select rPrice from itemTable where itemID='$itemID' and labid='".$_SESSION['labid']."' "); $query="insert into itemInOut(labid,sno,userID,expiry,pPrice,date_,$invType,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" select '".$_SESSION['labid']."','$sno','".$_SESSION['userID']."',expiry,uPrice,'$date_','$invNo','$accountID','$itemID','$qtyInSeach','$tPrice',0,0,'$tPrice','$batchNo' from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; //echo $query; $cur= odbc_exec( $conn, $query ); //update stock and uPrice $expiry=getName($conn,"select top 1 expiry from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."' "); $cur= addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry); $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,0,0,0); } echo ""; } if(isset($_POST['btnSaveInvoice'])){ $date_= date('Y-m-d',strtotime($_POST['date_'])); $invType = $_POST['invType']; $invNo = $_POST['invNo']; if(($invNo=="") or (strtoupper($invNo)=="NEW")) $invNo=getName($conn,"select isnull(max($invType),0)+1 from itemInOut where labid='".$_SESSION['labid']."'"); $accountID = $_POST['accountID']; $patientID = $_POST['patientID']; $visitNo = $_POST['visitNo']; $cnt = $_POST['cnt']; for ($i=1; $i<=$cnt; $i++) { $itemID = "itemID$i"; $itemID = $_POST[$itemID]; $qty = "qty$i"; $qty = $_POST[$qty]; $stock = "stock$i"; $stock = $_POST[$stock]; //if($invType=='saleNo' $qty>$stock) echo "stock excedded" $percentage = "percentage$i"; $percentage = $_POST[$percentage]; $tPrice = "tPrice$i"; $tPrice = $_POST[$tPrice]; $uPrice = "uPrice$i"; $uPrice = $_POST[$uPrice]; $sTax = "sTax$i"; $sTax = $_POST[$sTax]; if($percentage>0 and $qty>0){ $uPrice=(($tPrice*$qty)-($tPrice*$qty*$percentage/100))/$qty; $discount=($tPrice*$qty)-($uPrice*$qty); }elseif($uPrice>0 and $qty>0){ $percentage=(100*(($tPrice*$qty)-($qty*$uPrice)))/($tPrice*$qty); $discount=($tPrice*$qty)-($uPrice*$qty); }else{ $uPrice=$tPrice; $discount=0; } $batchNo = "batchNo$i"; $batchNo = $_POST[$batchNo]; if($batchNo=="") $batchNo='0'; $barCode = "barCode$i"; //$barCode = $_POST[$barCode]; $barCode= substr($_POST[$barCode],0,100); $expiry = "expiry$i"; $expiry = date('Y-m-d',strtotime($_POST[$expiry])); //if($qty>0 and $tPrice>0){ //if($qty>0 and $qty<=$stock){ // Sale Invoice & Purchase Return if($qty>0){ //if("1"==getName( $conn, "select 1 from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'" )){ $sno=getName( $conn, "select sno from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' "); if($sno!=""){ $cur= deleteInvoice($conn,$itemID,$batchNo,$invType,$invNo); }else{ $sno=getName( $conn, "select isnull(max(sno),0)+1 from itemInOut where $invType='$invNo' "); } $pPrice = getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $query="insert into itemInOut(labid,sno,sTax,userID,expiry,pPrice,date_,$invType,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" values ('".$_SESSION['labid']."','$sno','$sTax','".$_SESSION['userID']."','$expiry','$pPrice','$date_','$invNo','$accountID','$itemID','$qty','$tPrice','$percentage','$discount','$uPrice','$batchNo')"; $cur= odbc_exec( $conn, $query ); //update stock and uPrice $cur= addInvoice($conn,$itemID,$batchNo,$invType,$invNo,$expiry); } } //$amount=getName($conn,"select sum(uPrice*qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' "); $cur=updateSummaryLedger($visitNo,$patientID,$date_,$conn,$accountID,$invType,$invNo,0,0,0); if($barCode!=""){ //echo "update itemTable set barCode='$barCode' where itemID2='$itemID' and batchNo='$batchNo' "; $cur= odbc_exec( $conn,"update itemTable set barCode='$barCode' where itemID2='$itemID' and batchNo='$batchNo' "); $cur= odbc_exec( $conn,"update itemTable set barCode='$barCode' where barCode is null and itemID2='$itemID' "); $cur= odbc_exec( $conn,"update itemTable set barCode='$barCode' where barCode is null and itemID='$itemID' "); } //echo ""; } //$accountName=getName($conn,"select name from patientTab where accountID='$accountID'"); $accountName=getName($conn,"select stdName from student where ID='$accountID' and recordType='Account'"); echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if($invType=="saleNo") echo " :
Medicine : "; echo " "; echo ""; //echo fillList($conn,"select itemName+'-'+qty from itemTable where itemID>0 order by itemName asc"); echo fillList($conn,"select itemName + ':' + CAST(qty AS varchar(10)) from itemTable where itemID>0 and labid='".$_SESSION['labid']."' order by itemName asc"); echo ""; //if($invType=="saleNo") echo " : "; echo " : "; echo "
"; if($invType=="saleNo" or $invType=="saleRNo"){ echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo "
Patient: VisitNo:"; echo "
"; } echo "
"; if($invType=="pNo"){ $invName="Purchase No"; }elseif($invType=="pRNo"){ $invName="Purchase Return No"; }elseif($invType=="saleNo"){ $invName="Sale No"; }elseif($invType=="saleRNo"){ $invName="Sale Return No"; } if($patientName!="" and $patientID==""){ if(is_numeric($patientName)){ $patientID =(int)(substr($patientName,0,strlen($patientName)-1)); $visitNo=getName($conn,"select max(visitNo) from patientVisits where patientID='$patientID'"); echo ""; }else{ //$query= "select * from patientTab where name like'%$patientName%' order by name"; $query= "select top 20 patientID,name,visitNo,fname,doa,address,contacts from patientVisitsView where name like'%$patientName%' and labid='".$_SESSION['labid']."' order by doa desc,name"; //echo $query; $cur= odbc_exec( $conn, $query ); $cnt=0; while( odbc_fetch_row( $cur ) ) { $patientID= odbc_result( $cur, 'patientID' ); $patientName= odbc_result( $cur, 'name' ); $visitNo= odbc_result( $cur, 'visitNo' ); echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if ($cnt++==0) echo "
AdmissionPatient NameVisitNoFatherAddressContactSelect"; //echo ""; //$date_= date('Y-m-d',strtotime($_POST['date_'])); echo "
".date('d-m-Y',strtotime(odbc_result($cur,'doa')))."$patientName".odbc_result($cur,'visitNo')."".odbc_result($cur,'fname')."".odbc_result($cur,'address')."".odbc_result($cur,'contacts').""; echo ""; echo ""; } echo "

"; } } echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if($anyvalue==""){ $query= "select top 5 * from itemTable where 1=2 order by itemID desc"; }else{ if($invType=="pNo"){ $query= "select * from itemTable where itemID>0 and itemName like'%$anyvalue%' and labid='".$_SESSION['labid']."' order by itemName asc"; }elseif($invType=="pRNo"){ $query= "select i.itemID,i.itemName,i2.qty,i2.pPrice,i2.sPrice,i2.batchNo,i2.barCode,i2.expiry,i2.uPrice from itemTable i, itemTable i2 where i.itemID=i2.itemID2 and i2.itemID2>0 and i.itemName like'%$anyvalue%' and i.labid='".$_SESSION['labid']."' and i2.itemID2 in(select distinct itemID from itemInOut where accountID='$accountID' and pNo>0) order by i.itemName asc"; }elseif($invType=="saleRNo"){ $query= "select i.itemID,i.itemName,i2.qty,i2.pPrice,i2.sPrice,i2.batchNo,i2.barCode,i2.expiry,i2.uPrice from itemTable i, itemTable i2 where i.itemID=i2.itemID2 and i2.itemID2>0 and i.itemName like'%$anyvalue%' and i.labid='".$_SESSION['labid']."' and i2.itemID2 in(select distinct itemID from itemInOut where accountID='$accountID' and saleNo>0) order by i.itemName asc"; }elseif($invType=="saleNo"){ $query= "select i.itemID,i.itemName,i2.qty,i2.pPrice,i2.sPrice,i2.batchNo,i2.barCode,i2.expiry,i2.uPrice from itemTable i, itemTable i2 where i.itemID=i2.itemID2 and i2.itemID2>0 and i.itemName like'%$anyvalue%' and i.labid='".$_SESSION['labid']."' and i2.qty>0 order by i.itemName asc"; } } //echo $query; $cur= odbc_exec( $conn, $query ); $cnt=0; while( odbc_fetch_row( $cur ) ) { if ($cnt++==0) echo "
S.#NameExpiryBatchNoqty: Stock Price%age UnitPricesTaxbarCode"; $itemID= odbc_result( $cur, 'itemID' ); $itemName= odbc_result( $cur, 'itemName' ); $stock= odbc_result( $cur, 'qty' ); //$pPrice= odbc_result( $cur, 'pPrice' ); $sPrice= odbc_result( $cur, 'sPrice' ); $uPrice=round(odbc_result( $cur, 'uPrice' )); $batchNo= odbc_result( $cur, 'batchNo' ); $barCode= odbc_result( $cur, 'barCode' ); if("" != odbc_result( $cur, 'expiry' )){ $expiry = date('Y-m-d',strtotime(odbc_result( $cur, 'expiry' ))); }else{ $expiry=date('Y-m-d',strtotime(getName($conn,"select isnull(max(expiry),getdate()) from itemTable where itemID2='$itemID'"))); } echo ""; echo "
$cnt$itemName " ; echo ""; if($invType=="pNo"){ $tPrice=(getName($conn,"select tPrice from itemTable where itemID='$itemID'")); if($tPrice=="") $tPrice=(getName($conn,"select openingPrice from itemTable where itemID='$itemID'")); $percentage=(getName($conn,"select top 1 percentage from itemInOut where itemID='$itemID' order by date_ desc")); $batchNo=getName($conn,"select top 1 batchNo from itemInOut where batchNo<>'0' and itemID='$itemID' order by date_ desc "); //$arr=getName($conn,"select top 1 batchNo,percentage,tPrice from itemInOut where batchNo<>'0' and itemID='$itemID' order by date_ desc "); }elseif($invType=="pRNo"){ //$tPrice=round5.4333333333333336(getName($conn,"select tPrice from itemTable where itemID='$itemID'")); $tPrice=(getName($conn,"select max(tPrice) from itemInOut where accountID='$accountID' and itemID='$itemID' and batchNo='$batchNo'")); $percentage=(getName($conn,"select max(percentage) from itemInOut where accountID='$accountID' and itemID='$itemID' and batchNo='$batchNo'")); if($percentage=="") $percentage=0; }elseif($invType=="saleNo" or $invType=="saleRNo"){ //$tPrice=round(getName($conn,"select rPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'")); $tPrice=round(getName($conn,"select tPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'")); //$tPrice=(getName($conn,"select rPrice from itemTable where itemID='$itemID' ")); //if($tPrice=="") $tPrice=(getName($conn,"select openingPrice from itemTable where itemID='$itemID'")); $percentage=(getName($conn,"select max(percentage) from itemInOut where accountID='$accountID' and itemID='$itemID'")); if($percentage=="") $percentage=0; } echo ""; echo ""; echo " $stock"; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; echo ""; if($cnt>0){ echo "
"; echo ""; echo "
"; //if ($cnt==0) echo "No Record Found"; } echo "
"; if($invNo>0) $date_= date('Y-m-d',strtotime(getName($conn,"select date_ from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' "))); //$invAmount=round(getName($conn,"select amount from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' ")); $invAmount=round(getName($conn,"select sum(uPrice*qty) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' ")); $paidAmount=round(getName($conn,"select paid from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' ")); $discount=round(getName($conn,"select discount from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' ")); $paymentTo=round(getName($conn,"select paymentTo from itemInOutSummary where $invType='$invNo' and labid='".$_SESSION['labid']."' ")); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Account : "; echo "Date : "; echo "$invName : "; echo "
"; //$query= "select * from itemInOut where $invType='$invNo' order by itemID"; $query= "select i.itemID,i.qty,i.batchNo,i.tPrice,i.percentage,i.uPrice,i2.itemName,i.expiry from itemInOut i,itemTable i2 where i.itemID=i2.itemID and i.$invType='$invNo' and i.labid='".$_SESSION['labid']."' order by i.sno,i.itemID"; $cur= odbc_exec( $conn, $query ); $cnt=0; while( odbc_fetch_row( $cur ) ) { if ($cnt++==0){ if(getName($conn,"select count(*) from itemInOut where $invType='$invNo' and labid='".$_SESSION['labid']."' ")>10) echo "
"; else echo "
S.#NameBatchNoqtyprice%ageUnitPriceAmountdelete
"; } $itemID= odbc_result( $cur, 'itemID' ); //$itemName= getName($conn,"select itemName from itemTable where itemID='".odbc_result( $cur, 'itemID' )."'"); $qty= odbc_result( $cur, 'qty' ); $batchNo= odbc_result( $cur, 'batchNo' ); $expiry= odbc_result( $cur, 'expiry' ); $tPrice= round(odbc_result( $cur,'tPrice'),2); $percentage= round(odbc_result( $cur,'percentage'),2); $uPrice= round(odbc_result( $cur,'uPrice'),2); $amount=$uPrice*$qty; echo ""; //echo ""; echo ""; echo ""; echo ""; echo "
S.#NameBatchNoqtyprice%ageUnitPriceAmountdelete
$cnt".odbc_result($cur,'itemName').""; echo ""; echo "$tPrice"; echo ""; echo"$uPrice$amountdelete" ; //$cnt+=1; } echo "
"; echo ""; if($cnt>=1){ echo "
Amount : "; echo " Discount : "; echo "Paid : "; echo " Account :
"; echo "
"; echo "
"; } $itemName= ""; $query= "select top 20 $invType,amount,paid,discount,date_,patientID,visitNo from itemInOutSummary where $invType>0 and accountID='$accountID' order by $invType desc"; $cur= odbc_exec( $conn, $query ); $cnt=0; while( odbc_fetch_row( $cur ) ) { if ($cnt++==0) echo "
S.#Inv No.DateAmountDiscPaidShowPrintPrint2"; $invNo= odbc_result( $cur, "$invType"); $amount= round(odbc_result( $cur, 'amount' )); $paid= round(odbc_result( $cur, 'paid' )); $discount= round(odbc_result( $cur, 'discount' )); $date_=date('d-m-Y',strtotime(odbc_result( $cur, "date_" ))); $patientID= round(odbc_result( $cur, 'patientID' )); $visitNo= round(odbc_result( $cur, 'visitNo' )); echo "
$cnt$invNo$date_$amount$discount$paidShowprint" ; echo "print2" ; //echo "print3" ; //$cnt+=1; } echo "
"; //odbc_close($conn); function addStock2($conn,$itemID,$qty,$batchNo,$invType,$invNo) { //$uPrice=getName($conn,"select uPrice from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'"); $uPrice=getName($conn,"select pPrice from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo'"); $uPrice1=getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); if($uPrice!=$uPrice1){ $qty1=getName($conn,"select qty from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); $uPrice=(($qty*$uPrice)+($qty1*$uPrice1))/($qty+$qty1); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } $cur= odbc_exec( $conn, "delete from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'" ); $cur=updateStock($conn,$itemID,$batchNo,$invType,$invNo) ; return 0; } function stockBack($conn,$itemID,$qty,$invType,$invNo,$batchNo) { $qty1=getName($conn,"select isnull(sum(qty),0) from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."' "); if($qty==$qty1){ $cur2= odbc_exec( $conn, "delete from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"); }else{ $uPrice1=getName($conn,"select uPrice from itemTable where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."' "); $uPrice=getName($conn,"select uPrice from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' "); if($uPrice!=$uPrice1){ $uPrice=(($qty1*$uPrice1)-($qty*$uPrice))/($qty1-$qty); $qry="update itemTable set uPrice='$uPrice' where itemID2='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'"; $cur2= odbc_exec( $conn, $qry); } } $cur= odbc_exec( $conn, "delete from itemInOut where $invType='$invNo' and itemID='$itemID' and batchNo='$batchNo' and labid='".$_SESSION['labid']."'" ); $cur=updateStock($conn,$itemID,$batchNo) ; return 0; } ?>
Example Card