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.16.50.1
<?php
/*
Author : M.Srikanth
Date : 2009-10-25
Module : Mrn Approval
*/
class mrnapproval
{
//Start : Constructor
function __construct($aobj_context)
{
session_start();
$this->aobj_context=$aobj_context;
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
require_once($aobj_context->main_src."\custom_src\inventory_master.php");
$this->obj_master=new inventoryMaster($aobj_context);
$this->obj_master->getMaterialReturnDetails();
$this->user_id = $_SESSION['user_id'];
$this->login_ctr = $aobj_context->mobj_data["login_ctr"];
}
//End : Constructor
function getMrnApprovalDetails()
{
$delete_qc_approval = "delete from mrn_approval_status where login_cnt = {$this->login_ctr} ";
$lobj_delete_qc_approval = $this->aobj_context->mobj_db->Execute($delete_qc_approval);
$insert_qry="insert into mrn_approval_status
(select 0,{$this->login_ctr},
mr.mr_deviation_ref_no,
mr.mr_date,
mr.internal_code,
mr.mr_mrn_no,
mr.mr_work_order,
mri.internal_code,
mri.mr_items,
mri.mr_stage,
mri.mr_quantity,
mri.mr_notes,
mr.ref_mr_work_order_code,
mri.ref_mr_items_code,
mri.ref_mr_stage_code,
mri.it_qa_approved_by,
mri.it_qa_approved_date,
mri.qa_approved_notes,
mri.mr_status
from material_return mr
inner join material_return_items mri on mri.ref_s_ref_data_code = mr.internal_code
where mri.mr_status is null or mri.mr_status = 'New' or mri.mr_status = '' or mri.mr_status = '0'
)";
$lobj_insert_qry = $this->aobj_context->mobj_db->Execute($insert_qry);
$get_material_approval_qry = "select internal_code as id ,
deviation,
date,mrn_no as mrn_no,bmr_no,item,stage,quantity,item_notes,ref_mrn_code,ref_mrn_item_code,ref_bmr_code,
ref_item_code,ref_stage_code,approved_by,approved_date,notes as approved_notes,status
from mrn_approval_status
where login_cnt = {$this->login_ctr}";
return $get_material_approval_qry;
}
function saveMRNApproval()
{
$update_approval = "update {$this->obj_master->material_return_item_group_table} a , {$this->table_id} b
set {$this->obj_master->material_return_it_qa_approved_by} = b.approved_by,
{$this->obj_master->material_return_it_qa_approved_date} = b.approved_date ,
{$this->obj_master->material_return_qa_approved_notes} = b.approved_notes ,
{$this->obj_master->material_return_mr_status} = b.status
where a.internal_code = b.ref_mrn_item_code and a.ref_s_ref_data_code = b.ref_mrn_code
and (b.status = 'Approved' or b.status = 'Rejected')
;";
$lobj_update_approval = $this->aobj_context->mobj_db->Execute($update_approval);
/* $select_ex_approved = "select ref_bmr_code,ref_item_code,ref_stage_code,quantity
from {$this->table_id} where status = 'Approved' ";
$lobj_select_ex_approved = $this->aobj_context->mobj_db->GetAll($select_ex_approved);
for($up = 0 ; $up < count($lobj_select_ex_approved); $up++)
{
$ref_bmr_code = $lobj_select_ex_approved[$up]['ref_bmr_code'];
$ref_item_code = $lobj_select_ex_approved[$up]['ref_item_code'];
$ref_stage_code = $lobj_select_ex_approved[$up]['ref_stage_code'];
$quantity = $lobj_select_ex_approved[$up]['quantity'];
$update_bmr_req = "update bmr_requirement
set excess_qty = ifnull(excess_qty,0)+{$quantity}
where ref_bmr_code = {$ref_bmr_code} and stage = {$ref_stage_code} and item = {$ref_item_code} ";
$lobj_update_bmr_req = $this->aobj_context->mobj_db->Execute($update_bmr_req);
} */
if($lobj_update_approval)
{
$data="Successfully Approved";
echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
}
else
{
$data="Updation Failed ->".mysql_error();
echo $this->aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
}
}
function cancelMRNApproval()
{
$drop_tem_table = "drop table {$this->table_id}";
$lobj_drop_tem_table = $this->aobj_context->mobj_db->execute($drop_tem_table);
}
function getMRNFilterData()
{
if($this->mrn_from == 'undefined' and $this->mrn_to == 'undefined')
{
$date_filter = "";
}
else
{
$date_filter = "and (mr.mr_date >= '{$this->mrn_from}' and mr.mr_date <= '{$this->mrn_to}')";
}
$delete_mrn_entry = "delete from mrn_approval_status where login_cnt = {$this->login_ctr} ";
$lobj_delete_mrn_entry = $this->aobj_context->mobj_db->Execute($delete_mrn_entry);
if(strtolower($this->fetch_status)=='new')
{
$accp_type_cond=" where (mri.mr_status = '' or mri.mr_status ='New' or mri.mr_status is null)";
}
else
$accp_type_cond=" where (mri.mr_status = '{$this->fetch_status}' )";
$insert_qry="insert into mrn_approval_status
(select 0,{$this->login_ctr},
mr.mr_deviation_ref_no,
mr.mr_date,
mr.internal_code,
mr.mr_mrn_no,
mr.mr_work_order,
mri.internal_code,
mri.mr_items,
mri.mr_stage,
mri.mr_quantity,
mri.mr_notes,
mr.ref_mr_work_order_code,
mri.ref_mr_items_code,
mri.ref_mr_stage_code,
mri.it_qa_approved_by,
mri.it_qa_approved_date,
mri.qa_approved_notes,
mri.mr_status
from material_return mr
inner join material_return_items mri on mri.ref_s_ref_data_code = mr.internal_code
{$accp_type_cond} {$date_filter}
)";
// echo $insert_qry;
// die();
$lobj_insert_qry = $this->aobj_context->mobj_db->Execute($insert_qry);
$truncate_mrn_app = "truncate {$this->table_id} ";
$lobj_truncate_mrn_app = $this->aobj_context->mobj_db->Execute($truncate_mrn_app);
$select_mrn_query = "insert into {$this->table_id}
(select internal_code as id ,
deviation,
date,mrn_no as mrn_no,bmr_no,item,stage,quantity,item_notes,ref_mrn_code,ref_mrn_item_code,ref_bmr_code,
ref_item_code,ref_stage_code,approved_by,approved_date,notes as approved_notes,status
from mrn_approval_status
where login_cnt = {$this->login_ctr}
)
";
$lobj_select_mrn_query = $this->aobj_context->mobj_db->Execute($select_mrn_query);
}
}
function saveMRNApproval($aobj_context)
{
$class_obj=new mrnapproval($aobj_context);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$class_obj->schema_id=$aobj_context->mobj_data["schema_id"];
$class_obj->table_id=$aobj_context->mobj_data["table_id"];
$lobj_insert_qry = $class_obj->saveMRNApproval();
//echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_insert_qry,0,"success");
}
function cancelMRNApproval($aobj_context)
{
$class_obj=new mrnapproval($aobj_context);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$class_obj->schema_id=$aobj_context->mobj_data["schema_id"];
$class_obj->table_id=$aobj_context->mobj_data["table_id"];
$lobj_insert_qry = $class_obj->cancelMRNApproval();
//echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_insert_qry,0,"success");
}
function getMRNFilterData($aobj_context)
{
$class_obj=new mrnapproval($aobj_context);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$class_obj->module_id=$aobj_context->mobj_data["module_id"];
$class_obj->log_ctr=$aobj_context->mobj_data["login_ctr"];
$class_obj->fetch_status=$aobj_context->mobj_data["fetch_status"];
$class_obj->mrn_from=$aobj_context->mobj_data["mrn_from"];
$class_obj->mrn_to=$aobj_context->mobj_data["mrn_to"];
$class_obj->table_id=$aobj_context->mobj_data["table_id"];
$lobj_insert_qry = $class_obj->getMRNFilterData();
echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_insert_qry,0,"success");
}
?>
|