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.143.3.114
<?php
$main_src=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-7);
$cManualMailer =$main_src."/src/cManualMailer.php";
require_once($cManualMailer);
function savePOGeneration($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$suparr = trim($aobj_context->mobj_data["suparr"]);
$suparr = explode(',',$suparr);
$porange ='';
for($i=0;$i<count($suparr);$i++)
{
$supcode = $suparr[$i];
$query1 = "select fpono+1 as pono from autono";
$lobj_rst1 = $aobj_context->mobj_db->getRow($query1);
$auto_pono = $lobj_rst1[pono];
if($lobj_rst1)
{
$query2 = "update autono set fpono = '{$auto_pono}'";
$lobj_rst2 = $aobj_context->mobj_db->Execute($query2);
}
$query3 ="INSERT INTO maspo(FPONO,FPODATE,FSUPCODE,FDELDATE)
select '{$auto_pono}',NOW(), '{$supcode}',ifnull((now() + interval massup.FDELDAYS day),'') AS FDELDATE
from massup
where fsupcode = '{$supcode}'";
$lobj_rst3 = $aobj_context->mobj_db->Execute($query3);
$porange .= $auto_pono;
$query4 =" select detind.FINDNO, detind.FITEMCODE from massup,detind
where massup.FSUPCODE = detind.FSUPCODE and ifnull(detind.FSUPCODE,'') <> ''
and ifnull(detind.FCANCEL,'') <> 'T' AND IFNULL(detind.FHOLD,'') <> 'T' and ifnull(detind.FPONO,'') = ''
and massup.FSUPCODE = '{$supcode}' and detind.FINDNO between '000000000' and 'ZZZZZZZZ'";
$lobj_rst4 = $aobj_context->mobj_db->getAll($query4);
foreach($lobj_rst4 as $rst=>$val)
{
$update_query="UPDATE detind SET fpono='{$auto_pono}'
where findno = '{$val[FINDNO]}' and fitemcode='{$val[FITEMCODE]}' and fsupcode = '{$supcode}'";
$lobj_result=$aobj_context->mobj_db->Execute($update_query);
}
$query5 =" select detind.FINDNO, detind.FITEMCODE from massup,detind
where massup.FSUPCODE = detind.FSUPCODE and ifnull(detind.FSUPCODE,'') <> ''
and ifnull(detind.FCANCEL,'') <> 'T' AND IFNULL(detind.FHOLD,'') <> 'T' and ifnull(detind.FPONO,'') = '{$auto_pono}'
and massup.FSUPCODE = '{$supcode}' and detind.FINDNO between '000000000' and 'ZZZZZZZZ' GROUP BY detind.FITEMCODE";
$lobj_rst5 = $aobj_context->mobj_db->getAll($query5);
foreach($lobj_rst5 as $rst=>$val)
{
$inser_query="INSERT INTO detpo(FPONO,FITEMCODE,FORDQTY,FORGQTY)
select '{$auto_pono}' as FPONO, FITEMCODE, sum(FAPPQTY) as FAPPQTY, sum(FAPPQTY) as FAPPQTY from detind
where fpono = '{$auto_pono}' and fitemcode='{$val[FITEMCODE]}' and fsupcode = '{$supcode}' GROUP BY FITEMCODE";
$lobj_result=$aobj_context->mobj_db->Execute($inser_query);
$select_query = "select FITEMCODE,sum(FAPPQTY) as FAPPQTY from detind
where fpono = '{$auto_pono}' and fitemcode='{$val[FITEMCODE]}' and fsupcode = '{$supcode}' GROUP BY FITEMCODE";
$lobj_result=$aobj_context->mobj_db->getRow($select_query);
$FAPPQTY = $lobj_result[FAPPQTY];
$update = "UPDATE masitem AS mi INNER JOIN ( SELECT FAPPQTY-{$FAPPQTY} AS FAPPQTY FROM masitem
WHERE FITEMCODE = '{$val[FITEMCODE]}') AS mi2 SET mi.FAPPQTY = mi2.FAPPQTY
WHERE mi.FITEMCODE = '{$val[FITEMCODE]}'";
$lobj_update = $aobj_context->mobj_db->Execute($update);
$update = "UPDATE masitem AS mi INNER JOIN ( SELECT FORDQTY+{$FAPPQTY} AS FORDQTY FROM masitem
WHERE FITEMCODE = '{$val[FITEMCODE]}') AS mi2 SET mi.FORDQTY = mi2.FORDQTY
WHERE mi.FITEMCODE = '{$val[FITEMCODE]}'";
$lobj_update = $aobj_context->mobj_db->Execute($update);
}
}
require_once("cManualMailer.php");
require_once("reports/report_po.php");
$eporange = explode(',',$porange);
for($i=0;$i<count($eporange);++$i)
{
$query = "SELECT mp.FPONO, DATE_FORMAT(mp.FPODATE,'%d/%m/%Y') as FPODATE, mp.FSUPCODE,
ms.FSUPNAME, ms.FADD1, ms.FADD2, ms.FADD3, ms.FEMAIL,DATE_FORMAT((mp.FPODATE + INTERVAL 2 DAY),'%d/%m/%Y') as deldate,
ms.FADD3, dp.FITEMCODE, mit.FITEMNAME, sum(dp.FORDQTY) as FORDQTY
FROM maspo mp INNER JOIN detpo dp ON mp.FPONO=dp.FPONO INNER JOIN massup ms ON mp.FSUPCODE=ms.FSUPCODE
INNER JOIN masitem mit ON dp.FITEMCODE=mit.FITEMCODE WHERE IFNULL(mp.FDELETED,'') <> 'T' AND mp.FPONO
IN ({$eporange[$i]}) group by dp.FITEMCODE ORDER BY dp.FITEMCODE";
$rst = $aobj_context->mobj_db->GetAll($query);
$emailid = $rst[0][FEMAIL];
$subject = 'Live 100 - Purchase order '.$rst[0][FPONO].' Dated : '.$rst[0][FPODATE];
$message="<p style='font-size:18px;font-weight:bold;'>Dear Sir / Madam,</p></br><br></br><br>";
$message.="<span style='font-size:14px;'>You are here by requesting to supply below mentioned items immediately.<br> Submit the Invoice in duplicate and ensure that our PO.No. should be mentioned in the Invoice.</span></br><br></br><br>";
$message.="<span style='padding-right:500px;text-align:left;font-size:16px;'>Regards </span><span style='font-size:16px;'>Thanking You</span></br><br>";
$message.="<span style='font-size:14px;'>Live100 <br>Support Team</span></br>";
$header_det ="You are here by requested to supply below mentioned items immediately. Submit the Invoice in duplicate and ensure that our PO.No. should be mentioned in the Invoice.";
$class_obj=new poDetail("P");
$class_obj->AliasNbPages();
$class_obj->Default_construstor($aobj_context,$eporange[$i],'Purchase Order',$rst,$header_det);
$class_obj->GetpoDetail();
$filename = $class_obj->SendOutput();
if($rst)
send_attachments($emailid,$subject,$message,$replay_to=null,$cc='sandeep.n@logisys.org',$bcc=null,$filename);
}
$porange = $supcode.','.$porange;
if($lobj_rst3 )
{
echo $aobj_context->mobj_output->ToJSONEnvelope($porange,0,"success");
return;
}
else
{
$error_msg = 'error in PO generation';
echo $aobj_context->mobj_output->ToJSONEnvelope($error_msg,-1,"failure");
return;
}
}
function viewBeforePodetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$supcode = trim($aobj_context->mobj_data["supcode"]);
$query = "SELECT detind.FINDNO, detind.FITEMCODE, massup.FSUPNAME, detind.FSUPCODE,
masitem.FITEMNAME, sum(detind.FINDQTY) AS FINDQTY, sum(detind.FAPPQTY) AS FAPPQTY, detind.FREMARKS
FROM massup,detind,masitem
WHERE massup.FSUPCODE = detind.FSUPCODE AND masitem.FITEMCODE = detind.FITEMCODE
AND IFNULL(detind.FSUPCODE,'') <> '' AND IFNULL(detind.FCANCEL,'') <> 'T' AND IFNULL(detind.FHOLD,'') <> 'T'
AND IFNULL(detind.FPONO,'') = ''
AND detind.FSUPCODE = '{$supcode}' AND detind.FINDNO BETWEEN '000000000'
AND 'ZZZZZZZZ' GROUP BY detind.FITEMCODE ORDER BY detind.FITEMCODE";
$rst = $aobj_context->mobj_db->getAll($query);
if($rst)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($rst,0,"success");
return;
}
else
{
$error_msg = 'no details found ';
echo $aobj_context->mobj_output->ToJSONEnvelope($query,-1,"Disabled");
return;
}
}
?>
|