0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.14.255.58


Current Path : /proc/thread-self/root/var/www/misc/public_html/live100/src/
Upload File :
Current File : //proc/thread-self/root/var/www/misc/public_html/live100/src/sales24022016.php

<?php

	function slbrcItemDetails($aobj_context)
	{
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
		$barcode = $aobj_context->mobj_data["barcode"]; 
		session_start();
		$qry="select  mi.FITEMCODE AS id,mi.FITEMCODE ,mi.FITEMNAME,mi.FBINNO,dm.FMRP,(dm.FMRP/dm.FPACKQTY) as PRICE,sum(dm.FBALQTY),
		DATE_FORMAT(dm.FEXPDATE,'%d/%m/%Y') AS FEXPDATE,dm.FBATCHNO from masitem mi left join detmrn dm
		on mi.FITEMCODE = dm.FITEMCODE 
		where dm.FBARCODE='{$barcode}' and ifnull(dm.FBALQTY,0) > 0 
		group by dm.FBARCODE, dm.FITEMCODE order by dm.FEXPDATE,dm.FBATCHNO";
		$rst = $aobj_context->mobj_db->GetRow($qry);				 

		if($rst)	
		{
			echo $aobj_context->mobj_output->ToJSONEnvelope($rst,0,"success"); 
		}
		else
		{
			$err_data="Invalid Barcode code"; 	 	
			echo $aobj_context->mobj_output->ToJSONEnvelope($qry,-1,"Failure");
		}
	}

	function saveItemSales($aobj_context)
	{
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
		include_once("/JSON.php");
		
		$json = new Services_JSON();
		$item_arrjson = stripslashes($aobj_context->mobj_data["item_arrjson"]);
		$mobj_jsondata = $json->decode($item_arrjson);
		$item_arr = get_object_vars($mobj_jsondata);
		$invdate = $aobj_context->mobj_data["invdate"];
		$patientid = $aobj_context->mobj_data["patientid"];
		$contactno = $aobj_context->mobj_data["contactno"];
		$patientname = $aobj_context->mobj_data["patientname"];
		$addres = $aobj_context->mobj_data["addres"];
		$totalamount = $aobj_context->mobj_data["totalamount"];
		
		session_start();
		$username = $_SESSION['usr'];
		
		
		$brcode = "";
		$flag = 9999;
		for($k=0;$k<=count($item_arr);$k++)
		{	
			$query3 = "SELECT IF(FBALQTY>={$item_arr[$k]->qty},'',{$item_arr[$k]->barcode}) as qty FROM detmrn 
			WHERE FBARCODE = {$item_arr[$k]->barcode}";
			$rst3 = $aobj_context->mobj_db->getRow($query3); 
			$qty = $rst3[qty];
			if($qty != '')
			{	
				$flag = 0000;
				$brcode .= "'".$rst3[qty]."',";
			}	
			
		}	

		if($flag!=9999)
		{
			$brcode = $brcode."'"." "."'";
			$query7 = "select FBARCODE,FBALQTY from detmrn where FBARCODE IN ({$brcode}) ";
			$rst7 = $aobj_context->mobj_db->getAll($query7);
			echo $aobj_context->mobj_output->ToJSONEnvelope($rst7,-1,"error");
			return;	
		}	
			
		$query1 = "select FINVNO+1 as invno from autono";	
		$rst1= $aobj_context->mobj_db->getRow($query1);
		$invno = $rst1[invno];
		
		if($invno)
		{
			$query2 = "update autono set FINVNO = '{$invno}'";	
			$rst2= $aobj_context->mobj_db->Execute($query2);
		}
	
		
		$query4 = "INSERT INTO masinv(FINVNO, FINVDATE, FINVTIME, FCUSTCODE, FCUSTNAME, FADDRESS,FCONTACTNO,
		FREFBY, FTOTAL, FDISCCODE, FDISCAMT, FNETAMT, FUSERNAME ) VALUES 
		('{$invno}',date_format(str_to_date('{$invdate}','%d/%m/%Y'),'%Y-%m-%d'),TIME_FORMAT(NOW(), '%h:%i %p'),'{$patientid}',
	'{$patientname}','{$addres}','{$contactno}','','{$totalamount}','','','','{$username}')";
		$rst4 = $aobj_context->mobj_db->Execute($query4); 
		for($k=1;$k<=count($item_arr);$k++)
		{	
			$query5="INSERT INTO detinv(FINVNO, FITEMCODE, FBATCHNO, FBARCODE, FQTY, FRATE, FAMOUNT ) VALUES 
			('{$invno}','{$item_arr[$k]->itemcode}','{$item_arr[$k]->batchno}','{$item_arr[$k]->barcode}',
			'{$item_arr[$k]->qty}','{$item_arr[$k]->mrp}','{$item_arr[$k]->amount}')";
			$rst5 = $aobj_context->mobj_db->Execute($query5); 
			
			$query6 = "update detmrn SET FISSQTY = FISSQTY+{$item_arr[$k]->qty},FBALQTY = FBALQTY-{$item_arr[$k]->qty}
			where FBARCODE ='{$item_arr[$k]->barcode}' and FITEMCODE='{$item_arr[$k]->itemcode}'";
			$rst6 = $aobj_context->mobj_db->Execute($query6);
			
			$update = "UPDATE masitem set FBALQTY = FBALQTY -{$item_arr[$k]->qty}
			WHERE FITEMCODE = '{$item_arr[$k]->itemcode}'";
			$rst = $aobj_context->mobj_db->Execute($update); 
		}
		
		$reponce['success'] = 'Updated Successfully';
		$reponce['invno'] = $invno;
		$error_reports="Some Failure as occured ";
		if($rst)
			echo $aobj_context->mobj_output->ToJSONEnvelope($reponce,0,"success"); 
		else
			echo $aobj_context->mobj_output->ToJSONEnvelope($error_reports,-1,"error");   
	
	}
		
?>