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 : 18.191.189.119


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/barcodeItemReceipt.php

<?php
function saveBarcodeItemReceipt($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);
	$mrnno = $aobj_context->mobj_data["mrnno"];
	$mrndate = $aobj_context->mobj_data["mrndate"];
	$pono = $aobj_context->mobj_data["pono"];
	$dcno = $aobj_context->mobj_data["dcno"];
	$dcdate = $aobj_context->mobj_data["dcdate"];
	$invno = $aobj_context->mobj_data["invno"];
	$invdate = $aobj_context->mobj_data["invdate"];
	$supcode = $aobj_context->mobj_data["supcode"];
	$status='';
	session_start();
	$username = $_SESSION['usr'];
	$auto_mrnno = $mrnno;
	if($mrnno == 0)
	{
		$lstmrnno = "select fmrnno+1 as mrnno from autono";	
		$lobj_lstmrnno= $aobj_context->mobj_db->getRow($lstmrnno);
		$auto_mrnno = $lobj_lstmrnno[mrnno];
		
		if($lobj_lstmrnno)
		{
			$update_mrnno = "update autono set fmrnno = '{$auto_mrnno}'";	
			$lobj_update_mrnno= $aobj_context->mobj_db->Execute($update_mrnno);
		}
		$inser_query = "INSERT INTO masmrn(FMRNNO,FMRNDATE,FPONO,FSUPCODE,FDCNO,FDCDATE,FINVVAL,FINVDATE,FRECUSER,FTRANTYPE) VALUES 
		('{$auto_mrnno}',date_format(str_to_date('{$mrndate}','%d/%m/%Y'),'%Y-%m-%d'),'{$pono}','{$supcode}','{$dcno}',
		date_format(str_to_date('{$dcdate}','%d/%m/%Y'),'%Y-%m-%d'),'{$invno}',
		date_format(str_to_date('{$invdate}','%d/%m/%Y'),'%Y-%m-%d'),'{$username}','R')";
		$lobj_result = $aobj_context->mobj_db->Execute($inser_query); 
		
	}


	for($k=1;$k<=count($item_arr);$k++)
	{	
		$qury = "select * from recmrn where FMRNNO = '{$auto_mrnno}' and FITEMCODE = '{$item_arr[$k]->itemcode}'
		and FBATCHNO = '{$item_arr[$k]->batchno}'";
		$rst = $aobj_context->mobj_db->getRow($qury); 
		if(count($rst) == 0)
		{
			$mrp = $item_arr[$k]->mrp/$item_arr[$k]->packqty;
			$inser_query="INSERT INTO recmrn(FMRNNO,FITEMCODE,FBATCHNO,FEXPDATE,FRECQTY,FBILLQTY,FFREEQTY,FMRP,FPACKQTY,FPRICE,FNETVALUE) VALUES 
			('{$auto_mrnno}','{$item_arr[$k]->itemcode}','{$item_arr[$k]->batchno}',date_format(str_to_date('{$item_arr[$k]->expdate}','%d/%m/%Y'),'%Y-%m-%d'),
			'{$item_arr[$k]->recqty}','{$item_arr[$k]->billqty}','{$item_arr[$k]->freeqty}','{$item_arr[$k]->mrp}','{$item_arr[$k]->packqty}','{$mrp}','{$item_arr[$k]->netvalue}')";
			$rst = $aobj_context->mobj_db->Execute($inser_query); 
			
			$last_inserted_id = $aobj_context->mobj_db->Insert_ID();
			
			if($last_inserted_id)
			{ 
				$barcodelist = get_object_vars($item_arr[$k]->barcodedetails);
				for($j=1;$j<=count($barcodelist);$j++)
				{
					//$qty = $barcodelist[$j]->qty*$item_arr[$k]->packqty;
					
					$query="INSERT INTO salemrn(FRECMRNNO,FBARCODE,FBQTY,FQTY,FSTATUS)
					values('{$last_inserted_id}','{$barcodelist[$j]->barcode}','{$barcodelist[$j]->qty}','{$barcodelist[$j]->qty}','{$status}')";		
					
					$rst = $aobj_context->mobj_db->Execute($query); 
				}	
			}	
			
		}
		/* else
		{
			$qury2 = "update detmrn set FBATCHNO = '{$item_arr[$k]->batchno}',
			FMFGDATE = date_format(str_to_date('{$item_arr[$k]->mfgdate}','%d/%m/%Y'),'%Y-%m-%d'),
			FEXPDATE = date_format(str_to_date('{$item_arr[$k]->expdate}','%d/%m/%Y'),'%Y-%m-%d'),
			FRECQTY = {$item_arr[$k]->recqty},FBILLQTY= {$item_arr[$k]->billqty},FFREEQTY= {$item_arr[$k]->freeqty},
			FMRP = {$item_arr[$k]->mrp},FPACKQTY = {$item_arr[$k]->packqty},FPRICE = {$item_arr[$k]->price}
			where FMRNNO = '{$auto_mrnno}' and FITEMCODE = '{$item_arr[$k]->itemcode}' and FBARCODE = '{$item_arr[$k]->barcode}'";
			$rst = $aobj_context->mobj_db->Execute($qury2);
		}	 */
		$query = "update detpo as dp INNER JOIN (SELECT ({$item_arr[$k]->recqty}-FRECQTY)  AS FRECQTY FROM detpo
		WHERE  fpono ='{$pono}' and FITEMCODE = '{$item_arr[$k]->itemcode}') AS dp2 SET dp.FRECQTY = dp.FRECQTY + dp2.FRECQTY
		where dp.fpono ='{$pono}' and dp.fitemcode='{$item_arr[$k]->itemcode}'";
		$rst = $aobj_context->mobj_db->Execute($query);
		
		$update = "UPDATE masitem AS mi INNER JOIN ( SELECT ({$item_arr[$k]->recqty}-FRECQTY)  AS FRECQTY,({$item_arr[$k]->billqty}-FBILLQTY)  AS FBILLQTY FROM masitem
		WHERE  FITEMCODE = '{$item_arr[$k]->itemcode}') AS mi2 SET mi.FRECQTY = mi.FRECQTY+mi2.FRECQTY, 
		mi.FORDQTY = mi.FORDQTY-mi2.FBILLQTY,mi.FBILLQTY = mi.FBILLQTY+mi2.FBILLQTY
		WHERE mi.FITEMCODE = '{$item_arr[$k]->itemcode}'";
		$rst = $aobj_context->mobj_db->Execute($update);  
		
	}
	
	$success_report = 'Updated Successfully';
	$error_reports="Some Failure as Occurred ";
	if($rst)
		echo $aobj_context->mobj_output->ToJSONEnvelope($success_report,0,"success"); 
	else
		echo $aobj_context->mobj_output->ToJSONEnvelope($error_reports,-1,"error");   
}

function validatesaleBarcode($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
	$brcode = $aobj_context->mobj_data["brcode"]; 		
	session_start();
	
	$query = "select * from salemrn where FBARCODE = '{$brcode}'";
	$rst = $aobj_context->mobj_db->GetRow($query);
	
	if(count($rst)==0)
	{
		$succ_data = '';
		echo $aobj_context->mobj_output->ToJSONEnvelope($rst,0,"success"); 
	}	
	else
	{
		$err_data = 'Barcode '.$brcode .' already exist';
		echo $aobj_context->mobj_output->ToJSONEnvelope($err_data,-1,"error"); 
	}	
}

function getbarcoderecItemDetails($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	include_once("/JSON.php");
	$mrnno =$aobj_context->mobj_data["mrnno"];  
	
	$query = "select FPONO from masmrn where FMRNNO ='{$mrnno}'";
	$rst1 =$aobj_context->mobj_db->getRow($query);
	/* if($rst1[FPONO] =='DUMMY' )
	{	
		$qury = "SELECT recmrn.*, DATE_FORMAT(recmrn.FMFGDATE,'%d/%m/%Y') AS FMFGDATE,DATE_FORMAT(recmrn.FEXPDATE,'%d/%m/%Y') AS FEXPDATE, 
		masmrn.FMRNNO, DATE_FORMAT(masmrn.FMRNDATE,'%d/%m/%Y') AS FMRNDATE,
		masmrn.FPONO ,'' AS FPODATE,
		masmrn.FDCNO, DATE_FORMAT(masmrn.FDCDATE,'%d/%m/%Y') AS FDCDATE,masmrn.FINVVAL,
		DATE_FORMAT(masmrn.FINVDATE,'%d/%m/%Y') AS FINVDATE, massup.FSUPCODE, massup.FSUPNAME, masitem.FITEMCODE, 
		masitem.FITEMNAME, '' AS FORDQTY, IFNULL(recmrn.FPACKQTY,'') AS FPACKQTY,
		GROUP_CONCAT(salemrn.FBARCODE,'->',salemrn.FBQTY ORDER BY salemrn.FBARCODE SEPARATOR '~') AS barcodelist	
		FROM masmrn,massup,recmrn,masitem,salemrn
		WHERE  masmrn.FSUPCODE = massup.FSUPCODE AND salemrn.FRECMRNNO = recmrn.FRECMRNNO
		AND recmrn.FMRNNO = masmrn.FMRNNO AND recmrn.FITEMCODE = masitem.FITEMCODE
		AND masmrn.FMRNNO = '{$mrnno}' AND ifnull(masmrn.FDELETED,'') <> 'T' 
		GROUP BY  salemrn.FRECMRNNO ORDER BY recmrn.FITEMCODE";	 
	}
	else
	{ */
		$qury = "SELECT recmrn.*, DATE_FORMAT(recmrn.FMFGDATE,'%d/%m/%Y') AS FMFGDATE,DATE_FORMAT(recmrn.FEXPDATE,'%d/%m/%Y') AS FEXPDATE, 
		masmrn.FMRNNO, DATE_FORMAT(masmrn.FMRNDATE,'%d/%m/%Y') AS FMRNDATE,
		masmrn.FPONO ,DATE_FORMAT(maspo.FPODATE,'%d/%m/%Y') AS FPODATE,
		masmrn.FDCNO, DATE_FORMAT(masmrn.FDCDATE,'%d/%m/%Y') AS FDCDATE,masmrn.FINVVAL,
		DATE_FORMAT(masmrn.FINVDATE,'%d/%m/%Y') AS FINVDATE, massup.FSUPCODE, massup.FSUPNAME, masitem.FITEMCODE, 
		masitem.FITEMNAME, detpo.FORDQTY AS FORDQTY,IFNULL(recmrn.FPACKQTY,'') AS FPACKQTY,
		GROUP_CONCAT(salemrn.FBARCODE,'->',salemrn.FBQTY ORDER BY salemrn.FBARCODE SEPARATOR '~') AS barcodelist	
		FROM masmrn,massup,recmrn,masitem,maspo,detpo,salemrn
		WHERE masmrn.FPONO = maspo.FPONO   
		AND masmrn.FSUPCODE = massup.FSUPCODE AND salemrn.FRECMRNNO = recmrn.FRECMRNNO
		AND recmrn.FMRNNO = masmrn.FMRNNO AND recmrn.FITEMCODE = masitem.FITEMCODE
		AND detpo.FPONO = masmrn.FPONO AND detpo.FITEMCODE = recmrn.FITEMCODE
		and masmrn.FMRNNO = '{$mrnno}' and ifnull(masmrn.FDELETED,'') <> 'T' 
		GROUP BY  salemrn.FRECMRNNO ORDER BY recmrn.FITEMCODE";	 
	//}
	
	$rst = $aobj_context->mobj_db->getAll($qury);
	
	if($rst)
	{
		echo $aobj_context->mobj_output->ToJSONEnvelope($rst,0,"success"); 
		return;
	}
	else 
	{
		$error_msg = 'No details found ';
		echo $aobj_context->mobj_output->ToJSONEnvelope($qury ,-1,"Disabled"); 
		return;		
	}

}

function getSupplierItemlist($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
	$pono =trim($aobj_context->mobj_data["pono"]);  
	$supcode =trim($aobj_context->mobj_data["supcode"]); 
	if($pono == 'DUMMY')
	{
		$query="select massup.FSUPCODE as FSUPCODE, massup.FSUPNAME as FSUPNAME from massup
		where IFNULL(massup.FDELETED,'') <> 'T' order by massup.FSUPNAME";
	}	
	else
	{
		$query="select massup.FSUPCODE as FSUPCODE, massup.FSUPNAME as FSUPNAME from massup
		where  massup.FSUPCODE ='{$supcode}' and IFNULL(massup.FDELETED,'') <> 'T' order by massup.FSUPNAME";
	}	
	
	$rst = $aobj_context->mobj_db->GetAll($query);				 

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

		
}

?>