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.116.61
<?php
function getstockItemlist($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$query="select masitem.FITEMCODE as FITEMCODE, masitem.FITEMNAME as FITEMNAME, '' as FORDQTY,
ifnull(masitem.FPACKQTY,'') as FPACKQTY from masitem
where IFNULL(masitem.FDELETED,'') <> 'T' order by masitem.FITEMNAME";
$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");
}
}
function saveStockentry($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include_once("/JSON.php");
$json = new Services_JSON();
$mrndate = $aobj_context->mobj_data["mrndate"];
$barcode_arr = stripslashes($aobj_context->mobj_data["barcode_arr"]);
$mobj_jsondata = $json->decode($barcode_arr);
$barcode_arr = get_object_vars($mobj_jsondata);
$aobj_context->mobj_db->StartTrans();
$lstmrnno = "select fmrnno+1 as mrnno from autono";
$lobj_lstmrnno= $aobj_context->mobj_db->getRow($lstmrnno);
$auto_mrnno = $lobj_lstmrnno[mrnno];
session_start();
$username = $_SESSION['usr'];
$status = 'D';
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'),'DUMMY','DUMMY','DUMMY',
date_format(str_to_date('{$mrndate}','%d/%m/%Y'),'%Y-%m-%d'),'DUMMY',
date_format(str_to_date('{$mrndate}','%d/%m/%Y'),'%Y-%m-%d'),'{$username}','D')";
$lobj_result = $aobj_context->mobj_db->Execute($inser_query);
for($k=1;$k<=count($barcode_arr);$k++)
{
$qury = "select * from recmrn
where FMRNNO = '{$auto_mrnno}' and FITEMCODE = '{$barcode_arr[$k]->itemcode}'
and FBATCHNO = '{$barcode_arr[$k]->batchno}'";
$rst = $aobj_context->mobj_db->getRow($qury);
if(count($rst) == 0)
{
$uqury = "update masitem set FPACKQTY = '{$barcode_arr[$k]->packqty}'
where FITEMCODE = '{$barcode_arr[$k]->itemcode}'";
$rst = $aobj_context->mobj_db->Execute($uqury);
$mrp = floatval($barcode_arr[$k]->mrp)/floatval($barcode_arr[$k]->packqty);
$inser_query="INSERT INTO recmrn(FMRNNO,FITEMCODE,FBATCHNO,FEXPDATE,FRECQTY,FBILLQTY,FFREEQTY,FMRP,FPRICE) VALUES
('{$auto_mrnno}','{$barcode_arr[$k]->itemcode}','{$barcode_arr[$k]->batchno}',date_format(str_to_date('{$barcode_arr[$k]->expdate}','%d/%m/%Y'),'%Y-%m-%d'),
'{$barcode_arr[$k]->totqty}','{$barcode_arr[$k]->totqty}','0','{$barcode_arr[$k]->mrp}','{$mrp}')";
$rst = $aobj_context->mobj_db->Execute($inser_query);
$recmrnid = $aobj_context->mobj_db->Insert_ID();
if($recmrnid)
{
//$avlqty = $barcode_arr[$k]->qty*$barcode_arr[$k]->packqty;
$avlqty = $barcode_arr[$k]->qty;
$query="INSERT INTO salemrn(FRECMRNNO,FBARCODE,FBQTY,FQTY,FBALQTY,FSTATUS)
values('{$recmrnid}','{$barcode_arr[$k]->barcode}','{$barcode_arr[$k]->qty}','{$barcode_arr[$k]->qty}','{$avlqty}','{$status}')";
$rst = $aobj_context->mobj_db->Execute($query);
}
}
else if(count($rst)>0)
{
$recmrnid = $rst[FRECMRNNO];
if($recmrnid)
{
//$avlqty = $barcode_arr[$k]->qty*$barcode_arr[$k]->packqty;
$avlqty = $barcode_arr[$k]->qty;
$query="INSERT INTO salemrn(FRECMRNNO,FBARCODE,FBQTY,FQTY,FBALQTY,FSTATUS)
values('{$recmrnid}','{$barcode_arr[$k]->barcode}','{$barcode_arr[$k]->qty}','{$barcode_arr[$k]->qty}','{$avlqty}','{$status}')";
$rst = $aobj_context->mobj_db->Execute($query);
}
}
}
$aobj_context->mobj_db->CompleteTrans();
$arr['mrnno'] = $auto_mrnno;
if($rst)
{
$arr['message'] = "Updated Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
else
{
$arr['message'] = "Some Failure as occured";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
}
}
function getstockbarcodeItemDetails($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);
$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,
masitem.FITEMCODE,
masitem.FITEMNAME,IFNULL(masitem.FPACKQTY,'') AS FPACKQTY,
GROUP_CONCAT(salemrn.FBARCODE,'->',salemrn.FBQTY ORDER BY salemrn.FBARCODE SEPARATOR '~') AS barcodelist
FROM masmrn,recmrn,masitem,salemrn
WHERE 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";
$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($error_msg ,-1,"Disabled");
return;
}
}
?>
|