PO
This commit is contained in:
parent
7e1b04b0e5
commit
314c068ece
@ -76,10 +76,14 @@ class purchaseorder_model extends CI_Model
|
||||
* This function is used to get the SupplierID and SupplierName information
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
function getSupplierName()
|
||||
function getSupplierName($supID='')
|
||||
{
|
||||
$this->db->select('SupplierID, SupplierName,Address');
|
||||
$this->db->from('T_SupplierDetailsN');
|
||||
if($supID != '')
|
||||
{
|
||||
$this->db->where('SupplierID',$supID);
|
||||
}
|
||||
//$this->db->where('roleId !=', 1);
|
||||
$query = $this->db->get();
|
||||
|
||||
@ -103,18 +107,37 @@ class purchaseorder_model extends CI_Model
|
||||
* This function is used to get the Raw Material information
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
function getRawMaterialList()
|
||||
function getRawMaterialList($MatType='',$ReqNoList='')
|
||||
{
|
||||
|
||||
$this->db->select('MaterialCode, MaterialName');
|
||||
$this->db->from('T_MaterialMaster');
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
$this->db->select('ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity');
|
||||
$this->db->from('T_Requestion_Details Req');
|
||||
$this->db->join('T_MaterialMaster mat', 'Req.MaterialCode = mat.MaterialCode');
|
||||
$this->db->where('mat.MaterialType', $MatType);
|
||||
$this->db->where_in('Req.ReqNo', $ReqNoList);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is used to get the Requsition List for the login user
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
function getRequistDetails($ReqNoList='')
|
||||
{
|
||||
$this->db->distinct();
|
||||
$this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate');
|
||||
$this->db->from('T_Requestion_Master mast');
|
||||
$this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID');
|
||||
$this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode');
|
||||
$this->db->where_in('mast.ReqNo', $ReqNoList);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
/**
|
||||
* This function is used to get the Cost center information
|
||||
* @return array $result : This is result of the query
|
||||
@ -131,7 +154,53 @@ class purchaseorder_model extends CI_Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* This function is used to get the CostCenter for the Selected Requistion Number
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
function getCostCenterbyRequist($ReqNo='',$BudYear='',$ReqType='')
|
||||
{
|
||||
|
||||
$this->db->distinct();
|
||||
$this->db->select('Mast.CostCenterCode,Mast.CostCenterName,Bud.BudgetAmount,ReqNo');
|
||||
$this->db->from('T_CostCenter_Master Mast');
|
||||
$this->db->join('T_CostCenter_Departments CostDept', 'CostDept.CostCenterCode = Mast.CostCenterCode');
|
||||
$this->db->join('T_CostCenter_Budget Bud', 'Bud.CostCenterCode = Mast.CostCenterCode');
|
||||
$this->db->join('T_Employee_Details emp', 'CostDept.DEPCode = emp.Departmentcode');
|
||||
$this->db->join('T_Requestion_Master req', 'req.Requestedby = emp.EmpID');
|
||||
|
||||
$this->db->where('BudgetType ',$ReqType );
|
||||
$this->db->where('BudgetYear ',$BudYear );
|
||||
if($ReqNo != '')
|
||||
{
|
||||
$this->db->where('ReqNo ',$ReqNo);
|
||||
}
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to get the Config value from configuration table
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
function getFormula($FormulaID='' ,$Type = '')
|
||||
{
|
||||
|
||||
$this->db->select('FormulaID,Condition1,Condition2,Condition3,value1,value2,value3');
|
||||
$this->db->from('T_Formula_Details');
|
||||
if($FormulaID != '')
|
||||
{
|
||||
$this->db->where('FormulaID ',$FormulaID );
|
||||
}
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is used to get the Config value from configuration table
|
||||
* @return array $result : This is result of the query
|
||||
*/
|
||||
@ -170,26 +239,53 @@ class purchaseorder_model extends CI_Model
|
||||
* This function is used to add New Purchase order to the system
|
||||
|
||||
*/
|
||||
function addNewPO($PO_Type,$PO_Date,$Supplier_ID,$Special_Order,$User_ID,$Requester_Email,$Requester_Ph,$Requested_Date,$Budget_Manager,
|
||||
$Budget_Manager_Department,$Purchasing_Category,$Purchasing_Justification,$Created_By,$BasicValue,$DiscountType,$txtDiscount,$PackagingType,
|
||||
$txtPackaging,$Exciseduty,$txtVat,$txtFreight,$AfterDiscount,$AfterPackaging,$AferExciseduty,$txtAfterVat,$txtOrderValue)
|
||||
{
|
||||
|
||||
$result = $this->db-> query("CALL P_PURCHASEORDER_DETAILS('".$PO_Type."',STR_TO_DATE('".$PO_Date."','%m-%d-%Y %H:%i:%s'),'".$Supplier_ID."','".$Special_Order."','".$User_ID."'
|
||||
,'".$Requester_Email."','".$Requester_Ph."',STR_TO_DATE('".$Requested_Date."','%m-%d-%Y %H:%i:%s'),'".$Budget_Manager."','".$Budget_Manager_Department."','".$Purchasing_Category."','".$Purchasing_Justification."','".$Created_By."','".$BasicValue."','".$DiscountType."','".$txtDiscount."','".$PackagingType."','".$txtPackaging."','".$Exciseduty."','".$txtVat."','".$txtFreight."','".$AfterDiscount."','".$AfterPackaging."','".$AferExciseduty."','".$txtAfterVat."','".$txtOrderValue."')") or die(mysql_error());
|
||||
|
||||
// print_r($this->db->last_query());
|
||||
|
||||
$result ->next_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
//echo $result->num_rows;
|
||||
return $result->result_array();
|
||||
}
|
||||
function addPOMaster($POMaster)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('T_PurchaseOrder_Master', $POMaster);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
// print_r($this->db->last_query());
|
||||
if($insert_id>0)
|
||||
{
|
||||
$subQuery = 'select max(PONO) as PONO from T_PurchaseOrder_Master';
|
||||
|
||||
$query = $this->db->query($subQuery);
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This function is used to add New Purchase order Line Item to the system
|
||||
*/
|
||||
function addPOLineItem($POLineItem)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('T_PurchaseOrder_LineItem', $POLineItem);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
// print_r($this->db->last_query());
|
||||
if($insert_id>0)
|
||||
{
|
||||
$subQuery = 'select max(LineItemNo) as LineItemNo from T_PurchaseOrder_LineItem';
|
||||
|
||||
$query = $this->db->query($subQuery);
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is used to add New Purchase order Line Item to the system
|
||||
*/
|
||||
function addRevenueTax($RevenueTaxList)
|
||||
{
|
||||
$this->db->trans_start();
|
||||
$this->db->insert('T_Revenue_Tax', $RevenueTaxList);
|
||||
$insert_id = $this->db->affected_rows();
|
||||
$this->db->trans_complete();
|
||||
return $insert_id;
|
||||
}
|
||||
/**
|
||||
* This function is used to add new PO Line Item to T_PurchaseOrderLineItem table
|
||||
* @return number $insert_id : This is last inserted id
|
||||
@ -286,6 +382,118 @@ class purchaseorder_model extends CI_Model
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* This Method to get all the Department name for the requistion */
|
||||
function getDepartmentListForAllReq()
|
||||
{
|
||||
$subQuery ='SELECT DISTINCT DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ
|
||||
JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID
|
||||
JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode WHERE REQ.Status not in(?,?,?,?)';
|
||||
|
||||
$query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED));
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getStatusListforAllReq()
|
||||
{
|
||||
$subQuery ='SELECT DISTINCT STAT.StatusCode, STAT.StatusName FROM T_Requestion_Master REQ
|
||||
JOIN T_Status STAT on REQ.Status = STAT.StatusCode where STAT.StatusCode not in (?,?,?,?)';
|
||||
$query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED));
|
||||
|
||||
// print_r( $this->db->last_query());
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getStatusByDepartment($DepNo='')
|
||||
{
|
||||
|
||||
$subQuery ='SELECT DISTINCT STAT.StatusCode ,STAT.StatusName FROM T_Requestion_Master REQ
|
||||
JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID
|
||||
JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode
|
||||
JOIN T_Status STAT ON REQ.Status = STAT.StatusCode
|
||||
WHERE DEPT.DEPCode=? AND REQ.Status NOT IN (?,?,?,?)';
|
||||
$query = $this->db->query($subQuery,array($DepNo,REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED));
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
function getRequistionListbySearch($Depid='',$Status='',$FromDate='',$ToDate='')
|
||||
{
|
||||
$subQuery =' SELECT ReqNo,ReqType,Requestedby,EMP.FirstName,EMP.Designation,STAT.StatusCode ,STAT.StatusName,ReqDate,DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ
|
||||
JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID
|
||||
JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode
|
||||
JOIN T_Status STAT on REQ.Status = STAT.StatusCode
|
||||
where REQ.Status NOT IN (?,?,?,?)';
|
||||
|
||||
$appendQuery = $subQuery ;
|
||||
|
||||
if($Depid != '' && $Status != '' && $FromDate != '' && $ToDate != '')
|
||||
{
|
||||
$appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Depid ,$Status,$FromDate,$ToDate));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid != '' && $Status == '' && $FromDate == '' && $ToDate == '')
|
||||
{
|
||||
$appendQuery .= ' AND DEPT.DEPCode=?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Depid));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid == '' && $Status != '' && $FromDate == '' && $ToDate == '')
|
||||
{
|
||||
$appendQuery .= ' AND STAT.StatusCode=?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Status));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid == '' && $Status == '' && $FromDate != '' && $ToDate != '')
|
||||
{
|
||||
$appendQuery .= ' AND ReqDate >= ? AND ReqDate <= ?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$FromDate,$ToDate));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid != '' && $Status != '' && $FromDate == '' && $ToDate == '')
|
||||
{
|
||||
$appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Depid ,$Status));
|
||||
// print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid != '' && $Status == '' && $FromDate != '' && $ToDate != '')
|
||||
{
|
||||
$appendQuery .= ' AND DEPT.DEPCode=? AND ReqDate >= ? AND ReqDate <= ?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Depid ,$FromDate,$ToDate));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else if($Depid == '' && $Status != '' && $FromDate != '' && $ToDate != '')
|
||||
{
|
||||
$appendQuery .= ' AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?';
|
||||
|
||||
$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,$Status ,$FromDate,$ToDate));
|
||||
// print_r($this->db->last_query());
|
||||
return $query->result_array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED));
|
||||
//print_r($this->db->last_query());
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -227,7 +227,7 @@ class requistion_model extends CI_Model
|
||||
function getRequistDetails($ReqID,$NoArray='')
|
||||
{
|
||||
|
||||
$subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName
|
||||
$subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate
|
||||
from T_Requestion_Master mast
|
||||
join T_Employee_Details emp on mast.Requestedby = emp.EmpID
|
||||
join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user