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!Cn);SDP۽Ϡ vKO 0'Z>>2~v qTrAis{Κ-@% #WqP1\X.ǂ +Өfg@G,iED+\/O&^HbCվQxv~З{yQL&@Y3DZs޺F<=6{nRĪ{)DrG OԕN^\X؀j\N%~QH xJIbP1yĩr<*S@>E 1_꩒cYT4;|n)xe0p Jb~"AT#=&cz2Qq'âY0Q.RD=Ur5ݻTr~r㎴?~'Z 1 F"|gW evJ0nn?;gF]& ha{ܣmYJn6S 7vs[UGչKߤ4׵,!ݨ'æNܠ-ϟB9Wm& XCL]#6({B O3Mlx+lbpm k1\Ѡ{x b XC#ǵ=[jHY6g^@E^@?5/L * g3D?@p_q~,X'd!Cz2X<.xDT~\ y5Rp G!L׵ wABmܐ|J89B?‡|ovCҖ H2_S@>E 1_꩒cYP.ɛ"Z^lHJ{% ,k)QCW[e& Rk) iVT& 7x> [wjfs'd<,wjӦJ\X "hz u܄̖â;Dfg@G,iED+\axaϮ [b ]*d.żQJ0uhzҡ7Vs(NzM6chIȥOijy@\+>6.t7gG ?My+0+Q/h%2k$2fW=!aj_Xم e[EܤƚEHBк\6ґP0s9m. ʼKzK<7!ʇ.'XJlUr/7v)sv-+?MXbD-0Gxvc8>;bڲv9%2?O:5ٺ Q܂-1%O;MPf4c\ $5@$/waQh+ XP2ŕ&\b[r=%|UdBg4ˉ\C)^zLv 7wƈ3w-ĖD@8rՊw3+]d3UDMu=iYČѦKwZ$p)w QD)Blno"; $PrinterPath = "HP LaserJet Pro M402-M403 n-dn PCL 6"; // path to your adobe executable $adobe_path='"C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"'; shell_exec ("$adobe_path /t $filename $PrinterPath"); echo "printing done"; } if(isset($_POST['btnUpdateStock'])){ set_time_limit (500); //$cur= odbc_exec( $conn, "update itemInOut set batchNo='0' where batchNo=(select batchNo from itemOnOut where itemID=1347 and pNo=1122 and batchNo)"); $cur= odbc_exec( $conn,"update itemTable set batchNo='0' where batchNo is null "); //$cur= odbc_exec( $conn,"update itemTable set batchNo='0' where ltrim(rtrim(batchNo))=ltrim(rtrim(batchNo)) "); $cur= odbc_exec( $conn,"update itemTable set batchNo='0' where ltrim(rtrim(batchNo))='' "); $cur= odbc_exec( $conn,"update itemTable set batchNo='0' where ltrim(rtrim(batchNo))=' ' "); $cur= odbc_exec( $conn,"update itemInOut set batchNo='0' where batchNo is null "); $cur= odbc_exec( $conn,"update itemInOut set batchNo='0' where ltrim(rtrim(batchNo))='' "); $cur= odbc_exec( $conn,"update itemInOut set batchNo='0' where ltrim(rtrim(batchNo))=' ' "); $cur= odbc_exec( $conn,"update itemTable set qty=0 "); $cur= odbc_exec( $conn, "select distinct itemID,batchNo from itemInOut where itemID>0 and pNo>0" ); while( odbc_fetch_row( $cur ) ) { $qty1=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."' and pNo>0"); $qty1+=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."' and saleRNo>0"); $qty1-=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."' and saleNo>0"); $qty1-=getName($conn,"select isnull(sum(qty),0) from itemInOut where itemID='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."' and pRNo>0"); if(""==getName($conn,"select 1 from itemTable where itemID2='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."'")){ //$query="insert into itemTable(rPrice,itemName,itemID,tPrice,percentage,barCode) select tPrice,','$itemName','$itemID','$tPrice','$percentage','$barCode')"; $qry="insert into itemTable (itemID2,qty,uPrice,batchNo,expiry) select top 1 itemID,'$qty1',uPrice,batchNo,expiry from itemInOut where pNo>0 and itemID='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."'"; $cur2= odbc_exec( $conn, $qry); }else{ $qry="update itemTable set qty=$qty1 where itemID2='".odbc_result( $cur,'itemID')."' and batchNo='".odbc_result( $cur,'batchNo')."' "; $cur2= odbc_exec( $conn, $qry); } $qry="update itemTable set qty=(select sum(qty) from itemTable where itemID2='".odbc_result( $cur,'itemID')."') where itemID='".odbc_result( $cur,'itemID')."'"; $cur2= odbc_exec( $conn, $qry); } } if(isset($_POST['btnShow'])){ $anyvalue= $_POST['anyvalue']; } echo "
"; echo "
Keyword:"; echo ": "; echo "
"; if(isset($_POST['btnSave'])){ $itemName= $_POST['itemName']; $new=$itemID= $_POST['itemID']; $rPrice= $_POST['rPrice']; $percentage= $_POST['percentage']; $tPrice= $_POST['tPrice']; $packing=$_POST['packing']; $tabPrice=$_POST['tabPrice']; $packNos=$packing>0?$packing:1; $limit= $_POST['limit']; $itemType= $_POST['itemType']; $barCode= substr($_POST['barCode'],0,100); if($percentage>0) { $tPrice=$rPrice-($rPrice*$percentage/100); }elseif($tPrice>0) { //($rPrice*$percentage/100)=$rPrice-$tPrice; //$rPrice*$percentage=($rPrice-$tPrice)*100; $percentage=($rPrice-$tPrice)*100/$rPrice; }else { $tPrice=$rPrice; } $itemID= getName( $conn, "select itemID from itemTable where itemname='$itemName'" ); if ($itemID=="") { $itemID= getName( $conn, "select isnull(max(itemID),0)+1 from itemTable" ); $query="insert into itemTable (tabPrice,itemType,rPrice,itemName,itemID,tPrice,percentage,barCode,packing,limit) values('$tabPrice','$itemType','$rPrice','$itemName','$itemID','$tPrice','$percentage','$barCode','$packing','$limit')"; }else { $query="update itemTable set tabPrice='$tabPrice',itemType='$itemType',packing='$packing',limit='$limit',rPrice='$rPrice',itemName='$itemName',tPrice='$tPrice',percentage='$percentage',barCode='$barCode' where itemID='$itemID'"; } //echo $query; $cur= odbc_exec( $conn, $query ); if($barCode!=""){ $query="update itemTable set barCode='$barCode' where itemID2='$itemID'"; $cur= odbc_exec( $conn, $query); } $cur= odbc_exec( $conn,"update itemTable set packNos=1 where packNos is null "); //Check if Opening //if($new=="" and $_POST['qty']>0 and $_POST['pNo']>0 ){ $qty=isset($_POST['qty'])?$_POST['qty']:0; if($qty>0 and $_POST['pNo']>0 ){ $date_=getName($conn,"select date_ from itemInOut where pNo='".$_POST['pNo']."'"); $date_ = date('Y-m-d',strtotime($date_)); $accountID=getName($conn,"select accountID from itemInOut where pNo='".$_POST['pNo']."'"); //$pPrice=getName($conn,"select date_ from itemInOut where pNo='".$_POST['pNo']."'"); $qty=$_POST['qty']; $percentage=$_POST['percentage2']; $uPrice=$_POST['uPrice']; if($percentage>0) { $uPrice=$tPrice-($tPrice*$percentage/100); $discount=($tPrice*$qty)-($uPrice*$qty); }elseif($uPrice>0) { $percentage=($tPrice-$uPrice)*100/$tPrice; $discount=($tPrice*$qty)-($uPrice*$qty); }else { $uPrice=$tPrice; $discount=0; } $pPrice=$uPrice; $pNo=$_POST['pNo']; $batchNo=$_POST['batchNo']; if($batchNo=="") $batchNo="0"; $query="insert itemInOut(userID,expiry,pPrice,date_,pNo,accountID,itemID,qty,tPrice,percentage,discount,uPrice,batchNo)"; $query.=" values ('".$_SESSION['userID']."','".$_POST['expiry']."','$pPrice','$date_','".$_POST['pNo']."','$accountID','$itemID','".$_POST['qty']."','$tPrice','$percentage','$discount','$uPrice','$batchNo')"; $cur= odbc_exec( $conn, $query ); //update stock and uPrice $cur= addInvoice($conn,$itemID,$batchNo,'pNo',$_POST['pNo'],$_POST['expiry']); $query="update itemInOutSummary set amount=(select sum(uPrice*qty) from itemInOut where pNo='$pNo' and accountID='$accountID') "; $query.=" where pNo='$pNo' and accountID='$accountID'" ; $cur= odbc_exec( $conn, $query); $remarks="Purchase Invoice:".$pNo; $query="update ledger set credit=(select sum(uPrice*qty) from itemInOut where pNo='$pNo' and accountID='$accountID')"; $query.=" where accountID='$accountID' and remarks='$remarks' "; $cur= odbc_exec( $conn, $query); $cur=calculateBalance($conn,$accountID); echo ""; }else{ echo ""; } } 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'")){ $qry="insert into itemTable (itemID2,qty,uPrice,batchNo,expiry) values('$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'"; //echo "
$query"; $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')); } 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'"; $cur2= odbc_exec( $conn, $qry); $cur2= odbc_exec( $conn, "update itemTable set tPrice='".odbc_result($cur,'tPrice')."' where itemID='$itemID' and tPrice<>'".odbc_result($cur,'tPrice')."'"); } //$cur=updateStock($conn,$itemID,$batchNo) ; $cur2= odbc_exec( $conn,"update itemTable set qty='$qty' where itemID2='$itemID' and batchNo='$batchNo'"); $cur2= odbc_exec( $conn,"update itemTable set qty='$qty' where itemID='$itemID'"); return 0; } if (isset($_GET['itemID'])) { $itemID = $_GET['itemID']; $query = "select * from itemTable where itemID='$itemID'"; $cur= odbc_exec( $conn, $query ); while( odbc_fetch_row( $cur ) ) { //$date_= date("Y-m-d", strtotime(odbc_result( $cur, 'date_' ))); $rPrice= odbc_result( $cur, 'rPrice' ); $itemName= odbc_result( $cur, 'itemName' ); $tPrice= odbc_result( $cur, 'tPrice' ); $percentage= odbc_result( $cur,'percentage'); $barCode= odbc_result( $cur,'barCode'); $packing= odbc_result( $cur,'packing'); $limit= odbc_result( $cur,'limit'); $itemType= odbc_result( $cur,'itemType'); $tabPrice= odbc_result( $cur,'tabPrice'); } } if (isset($_GET['delID'])) { //$itemID = $_GET['delID']; $query=getName($conn,"select count(*) from itemInOut where itemID='".$_GET['delID']."'"); if($query=="0") { $cur= odbc_exec( $conn,"delete from itemTable where itemID='".$_GET['delID']."'"); $cur= odbc_exec( $conn,"delete from itemTable where itemID2='".$_GET['delID']."'"); echo "Record Deleted Successfully"; }else{ echo "Sorry! can't be Deleted, contains Stock"; } } echo ""; echo ""; echo ""; //echo "
Item Type"; //echo "
Item Type"; echo "
Medicine Name"; echo ""; echo fillList($conn,"select itemName from itemTable where itemID>0 order by itemName asc"); echo ""; echo " "; echo "
"; echo "
Retail/Sale Price"; echo " Price/tabs : "; //echo " Nos of Tables : "; echo "
Percentage"; echo "
Trade/Purchase Price"; if($itemID==""){ echo "
Openingqty: %age:Unit: Batch: Expiry: Inv#:"; } echo "
Packing"; echo "
Stock Limit"; echo "
Barcode"; echo ""; //echo "
Company Name +"; echo "
"; //echo "
"; echo "
"; $expID=$itemName= ""; $cnt=$amount=0; //echo"
hello"; if($anyvalue!="") $query= "select itemID,itemName,rPrice,percentage,tPrice,barCode,qty,pPrice from itemTable where itemID>0 and itemName like'%$anyvalue%' order by itemID desc"; else $query= "select top 50 itemID,itemName,rPrice,percentage,tPrice,barCode,qty,pPrice from itemTable where itemID>0 order by itemID desc"; //echo $query; $cur= odbc_exec( $conn, $query ); while( odbc_fetch_row( $cur ) ) { if ($cnt++==0) echo "
S.#NameqtyRetail%ageTradeAmountEditDetailDeleteBarCode"; $itemID= odbc_result( $cur, 'itemID' ); $itemName= odbc_result( $cur, 'itemName' ); $size=strlen($itemName); $rPrice= round(odbc_result( $cur, 'rPrice' ),2); $percentage= odbc_result( $cur,'percentage'); $tPrice= round(odbc_result( $cur,'tPrice'),2); echo "
$cnt$itemName".odbc_result( $cur,'qty')."$rPrice$percentage$tPrice"; echo "".round(odbc_result( $cur, 'tPrice' )*odbc_result( $cur, 'qty' ))."Edit" ; //echo "Print"; echo "Detail"; //echo "".round(odbc_result( $cur, 'pPrice' )*odbc_result( $cur, 'qty' )) ; echo "Delete"; //echo "".substr(odbc_result( $cur,'barCode'),0,10); $amount+=odbc_result( $cur, 'tPrice' )*odbc_result( $cur, 'qty' ); echo ""; echo ""; //echo ""; //echo ""; //OnClientClick="return print();" //echo "Generate"; //echo "label"; //echo "label"; //echo "label"; //echo "label1"; //https://barcode.tec-it.com/barcode.ashx?data=ABC-abc-1234&code=Code128&dpi=96&dataseparator= //https://barcode.tec-it.com/barcode.ashx?data=0123456789&code=Code128&multiplebarcodes=false&translate-esc=false&unit=Fit&dpi=96&imagetype=Gif&rotation=0&color=%23000000&bgcolor=%23ffffff&codepage=&qunit=Mm&quiet=0 } if($cnt>0) echo "
Summary".round($amount) ; echo "
"; echo ""; echo ""; odbc_close($conn); function query2CSV2($conn,$query) { $time_=date('d-m-Y-s-a', time()); //$fileName="d:\myLabel.csv"; $fileName="\\\SERVER\Open\myLabel.csv"; if(file_exists($fileName)) unlink($fileName); $fp = fopen($fileName, 'w'); $array = array(); $ar = array(); $i=0; $cur= odbc_exec( $conn, $query ); while( odbc_fetch_row( $cur ) ) { if($i==0){ for ($j = 1; $j <= odbc_num_fields($cur); $j++) { $field_name = odbc_field_name($cur, $j); $ar[$field_name] =$field_name; } $array[$i] = $ar; $i++; } for ($j = 1; $j <= odbc_num_fields($cur); $j++) { $field_name = odbc_field_name($cur, $j); if($field_name=='Branch' or $field_name=='AccountNo') $ar[$field_name] ='="' . odbc_result($cur, $field_name) . '"'; else $ar[$field_name] =odbc_result($cur, $field_name); //'="' . $yourNumber . '"' } $array[$i] = $ar; $i++; } foreach ($array as $fields) { fputcsv($fp, $fields); //fputcsv($fp, (string) $fields); } fclose($fp); return ($fileName); } ?>