updated as per SIA : ps

This commit is contained in:
VE10-Sanjeev 2023-06-15 18:59:17 +05:30
parent 6f2bae2ac0
commit 9ac51ff47c
35 changed files with 70 additions and 16128 deletions

View File

@ -56,14 +56,11 @@ $active_record = TRUE;
// $db['default']['password'] = 'ria!1234';
// $db['default']['database'] = 'resicoin_PROD';
// $db['default']['hostname'] = '119.18.54.85';
// $db['default']['username'] = 'venbaehn_ria';
// $db['default']['password'] = 'Ghc7ja3rMPLYNsV';
// $db['default']['database'] = 'venbaehn_ria';
$db['default']['hostname'] = 'vprodb1.mysql.database.azure.com';
$db['default']['username'] = 'dbroot';
$db['default']['password'] = 'root@DB23';
$db['default']['database'] = 'ria_prod';
$db['default']['hostname'] = '119.18.54.85';
$db['default']['username'] = 'venbaehn_ria';
$db['default']['password'] = 'Ghc7ja3rMPLYNsV';
$db['default']['database'] = 'venbaehn_ria';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;

View File

@ -511,17 +511,14 @@ class report extends BaseController
function Viewfiles()
{
$PO= $this->input->post('id');
$PO= $this->input->post('id');
//$PONO= substr($PO,10);
//echo $PONO; die;
$split_id = explode('-', $PO,2);
$PONO=$split_id[1];
$data = $this->dahsboard_Model->getfile($PONO);
$PONO= substr($PO,10);
//echo $PONO; die;
$data = $this->dahsboard_Model->getfile($PONO);
// print_r( $data);die;
echo json_encode($data);
echo json_encode($data);
}

View File

@ -349,9 +349,10 @@ class requisitionform extends BaseController
/**
* This function is used to add new Cost to the system
*/
function addNewRequistion()
function addNewRequistion()
{
log_message('error'," add new Requisition Fns Called");
$this->form_validation->set_rules('RequestType','RequestType','trim|required');
$this->form_validation->set_rules('EmpID','EmpID','trim|required');
@ -361,9 +362,11 @@ class requisitionform extends BaseController
}
else
{
log_message('error'," add new Requisition GET[ID] ".$_GET['ID']);
$Status= $_GET['ID'];
$RequestType = strtoupper(trim($this->input->post('RequestType')));
$Requestedby = strtoupper(trim($this->input->post('EmpID')));
log_message('error'," add new Requisition empid ".$Requestedby);
$RequestedbyDept = $this->session->userdata ( 'DEPCode' );
$CostCenter = $this->input->post('CostCenter');
$CreateBy = $this->session->userdata ( 'userId' );

View File

@ -217,7 +217,8 @@ return $afftectedRows;
//print_r($insert_id);
if($insert_id>0)
{
$subQuery = 'select max(IGRNO) as IGRNO from T_IGR_Master';
// $subQuery = 'select max(IGRNO) as IGRNO from T_IGR_Master';
$subQuery = 'select IGRNO from T_IGR_Master Order by CreatedDate desc limit 1';
$query = $this->db->query($subQuery);
@ -234,7 +235,8 @@ return $afftectedRows;
if($insert_id>0)
{
$subQuery = 'select max(IGRItemNo) as IGRItemNo from T_IGR_Details';
// $subQuery = 'select max(IGRItemNo) as IGRItemNo from T_IGR_Details';
$subQuery = 'select IGRItemNo as IGRItemNo from T_IGR_Details Order by CreatedDate desc limit 1';
$query = $this->db->query($subQuery);
@ -721,7 +723,8 @@ function getPOmaterial($PONO)
//print_r($insert_id);
if($insert_id>0)
{
$subQuery = 'select max(OGRNO) as OGRNO from T_OGR_Master';
//$subQuery = 'select max(OGRNO) as OGRNO from T_OGR_Master';
$subQuery = 'select OGRNO from T_OGR_Master order by CreatedOn desc limit 1';
$query = $this->db->query($subQuery);
@ -734,7 +737,8 @@ function getPOmaterial($PONO)
function getlastogrline()
{
$subQuery = 'select max(OGRItemNO) as OGRItemNO from T_OGR_Details';
//$subQuery = 'select max(OGRItemNO) as OGRItemNO from T_OGR_Details';
$subQuery = 'select OGRItemNO from T_OGR_Details order by CreatedOn desc limit 1';
$query = $this->db->query($subQuery);

View File

@ -1,258 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class assetdetails_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function assetListing()
{
$this->db->select('asd.*,dep.DepartmentName,sup.SupplierName');
$this->db->from('T_Asset_Details asd');
$this->db->join('T_DepartmentDetails dep', ' dep.DEPCode = asd.DEPCode','left');
$this->db->join ('T_SupplierDetailsN sup','sup.SupplierID = asd.SupplierCode','left');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getDepartment($Department = '')
{
$this->db->select('DEPCode,DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive',1 );
if($Department != '')
{
$this->db->where('DEPCode !=',$Department );
}
$query = $this->db->get();
return $query->result();
}
function getSupplierName($SupplierID = '')
{
$this->db->select('SupplierID, SupplierName');
$this->db->from('T_SupplierDetailsN');
$this->db->where('IsActive',1 );
if($SupplierID != '')
{
$this->db->where('SupplierID !=',$SupplierID );
}
$query = $this->db->get();
return $query->result();
}
function getpodetails($PO){
$this->db->distinct();
$this->db->select('POM.PONO,POM.SupplierID,POL.MaterialCode,DeliveryDate,PODate,sup.SupplierName,POL.LineItemNo');
$this->db->from('T_PurchaseOrder_Master POM');
$this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO');
$this->db->join('T_SupplierDetailsN sup', 'sup.SupplierID = POM.SupplierID');
$this->db->where('POM.status',MRIR_APPROVED);
if(!empty($PO)){
$this->db->where('POM.PONO',$PO);
}
$query = $this->db->get();
//print_r($this->db->last_query());
return $query->result();
}
function getPO($PO='')
{
$this->db->distinct();
$this->db->select(' POM.PONO');//,DeliveryDate,PODate,sup.SupplierName,POM.SupplierID');
$this->db->from('T_PurchaseOrder_Master POM');
//$this->db->join ('T_PurchaseOrder_LineItem POL ',' POL.PONO = POM.PONO');
//$this->db->join ('T_SupplierDetailsN sup ',' sup.SupplierID = POM.SupplierID');
$this->db->where('POM.status',MRIR_APPROVED);
if(!empty($PO)){
$this->db->where('POM.PONO',$PO);
}
$query = $this->db->get();
//print_r($this->db->last_query());
return $query->result();
}
function getlineitemre($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POL.Quantity,POM.POType,re.TotalValue,req.ReqNo,emp.firstname,emp.Departmentcode,dep.DepartmentName,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Revenue_Tax re','re.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getlineitemser($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Service_Tax ser','ser.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getlineitemimport($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,ser.TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Import_Tax ser','ser.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getlineitemcap($line){
$this->db->select('POL.LineItemNo,POL.MaterialCode,MM.MaterialName,MM.UOM,POM.POType,POL.Quantity,sum(ser.TotalValue+imp.TotalValue) as TotalValue,req.ReqNo,emp.firstname,dep.DepartmentName,emp.Departmentcode,sup.SupplierName,date(POM.DeliveryDate) as DeliveryDate,POM.PODate,POM.SupplierID');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_Requestion_Master req','req.ReqNo = POL.ReqNo','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = POL.MaterialCode','left');
$this->db->join('T_Employee_Details emp','emp.EmpID = req.Requestedby','left');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode','left');
$this->db->join ('T_Import_Tax imp','imp.LineItemNo = POL.LineItemNo','left');
$this->db->join ('T_Service_Tax ser','ser.LineItemNo = POL.LineItemNo','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID = POM.SupplierID','left');
$this->db->where('POL.LineItemNo',$line);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function gettyp($type)
{
$this->db->select('POM.POType,POL.LineItemNo');
$this->db->from('T_PurchaseOrder_LineItem POL');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO=POL.PONO');
$this->db->where('POL.LineItemNo',$type);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query
*/
function getConfigValue($ConfigID ,$ConfigValue = '')
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if($ConfigValue != '')
{
$this->db->where('ConfigValue != ',$ConfigValue );
}
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewasset($asset)
{
$this->db->trans_start();
$this->db->insert('T_Asset_Details', $asset);
//$Asset_Code = $this->db->insert_id();
$Asset_Code = $this->db->affected_rows();
$this->db->trans_complete();
return $Asset_Code;
}
/**
* This function used to get Asset details by Asset Code
* @param number $Asset_Code : This is AssetCode
* @return array $result : This is Asset information
*/
function getAssetDetails($Asset_Code)
{
//echo $Asset_Code;
$this->db->select('Asset.*,POM.DeliveryDate,Dep.DepartmentName as DepartmentName,MM.MaterialName,MM.UOM,Supp.SupplierName as SupplierName');
$this->db->from('T_Asset_Details Asset');
$this->db->join('T_DepartmentDetails Dep', 'Asset.DEPCode = Dep.DEPCode','left');
$this->db->join('T_SupplierDetailsN Supp', 'Asset.SupplierCode = Supp.SupplierID','left');
$this->db->join('T_MaterialMaster MM ', 'MM.MaterialCode = Asset.MaterialCode','left');
$this->db->join('T_PurchaseOrder_Master POM','POM.PONO = Asset.PONO','left');
$this->db->where('Asset.AssetCode', $Asset_Code);
$query = $this->db->get();
//print_r($this->db->last_query());
return $query->result();
}
function editasset($asset, $Asset_Code)
{
$this->db->where('AssetCode', $Asset_Code);
$this->db->update('T_Asset_Details', $asset);
//print_r($this->db->last_query());
return TRUE;
}
function viewasset($asset, $Asset_Code)
{
$this->db->where('AssetCode', $Asset_Code);
$this->db->update('T_Asset_Details', $asset);
return TRUE;
}
function export_excel(){
$this->db->select('det.*,dep.DepartmentName as DEPCode,sup.SupplierName,MM.MaterialName,emp.firstname,emp1.firstname as Updated_By');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_DepartmentDetails as dep','dep.DEPCode=det.DEPCode','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('T_SupplierDetailsN as sup', 'sup.SupplierID=det.SupplierCode','left');
$this->db->join('T_MaterialMaster MM ', 'MM.MaterialCode = det.MaterialCode','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
return $this->db->get('T_Asset_Details as det')->result_array();
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,165 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class companydetailsmodel extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @return number $count : This is row count
*/
//inserted data into companydetails table//
function Companyadd($Company)
{
$this->db->insert('T_Company_Details', $Company);
$CompID = $this->db->affected_rows();
return $Company;
}
//inserted data into file table//
function filedetails($myfile)
{
$this->db->insert('file',$myfile);
$CompID = $this->db->affected_rows();
return $myfile;
}
//for listing file//
function filelist()
{
$sql=" select ID,filename,filedescription,createdDate from file where isDeleted IS NULL OR isDeleted=0";
$query = $this->db->query($sql);
return $query->result();
}
//for deleting file//
function deletefile($ID,$userInfo)
{
$this->db->where('ID', $ID);
$this->db->update('file', $userInfo);
return $this->db->affected_rows();
}
function Updatecompany($Comp, $CompID)
{
$this->db->where('CompID', $CompID);
$this->db->update('T_Company_Details', $Comp);
$this->db->last_query();
return TRUE;
}
function checkPhotoExists($Pic)
{
$this->db->select('ProfilePic');
$this->db->from('T_Company_Details');
$this->db->where($Pic);
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
// updated by //
function companylisting()
{
$this->db->select('com.*,emp.firstname,pmt.PaymentTerms');
$this->db->from('T_Company_Details com');
$this->db->join('T_PaymentTerms pmt','com.paymentID = pmt.PaymentID','left');
$this->db->join('tbl_users as tbl',' com.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$query = $this->db->get();
$result = $query->result();
return $result;
}
// dropdown for payaple terms @ companydetails//
// function getpayment($Configvalue = '')
// {
// $ConfigID = 'C009';
// $this->db->select('ConfigValue');
// $this->db->from('T_ConfigDetails');
// $this->db->where('Config_ID ',$ConfigID );
// $query = $this->db->get();
// return $query->result();
// }
function getPaymentTerms()
{
$this->db->select('*');
$this->db->from('T_PaymentTerms');
$query = $this->db->get();
$result = $query->result();
return $result;
}
// dropdown for file description @ companydetails//
function getfilename($Configvalue = '')
{
$ConfigID = 'C025';
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_ID ',$ConfigID );
$query = $this->db->get();
return $query->result();
}
// for display the bankdetails//
function getBankDetails()
{
$this->db->select('*');
$this->db->from('T_Bank_Details');
$query = $this->db->get();
$result = $query->result();
return $result;
}
// for add and update the bankdetails//
function BankDetails($Bank)
{
$bankname=$Bank['Bank_name'];
$bankifsc=$Bank['IFSC'];
$count=0;
$this->db->select('count(*) as count');
$this->db->from('T_Bank_Details');
$this->db->where('Bank_name',$bankname);
$this->db->where('IFSC',$bankifsc);
$isExits = $this->db->get();
$res = $isExits->result_array();
if(!empty($res))
{
$count = $res[0]['count'];
}
if($count == 0 )
{
$i = $this->db->insert('T_Bank_Details', $Bank);
return $i;
}
elseif($count == 1)
{
$this->db->where('Bank_name',$bankname);
$this->db->where('IFSC',$bankifsc);
$i = $this->db->update('T_Bank_Details',$Bank);
return $i;
}
}
}
?>

View File

@ -1,194 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class configmodel extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function Configlisting()
{
$this->db->select('Config.Config_ID, Config.ConfigName ,Config.Comments,Config.CreatedDate');
$this->db->from('T_ConfigMaster as Config');
// $this->db->join('t_configdetails as Con','Con.Config_ID=Config.Config_ID');
$this->db->order_by('Config.CreatedDate','desc');
//$this->db->order_by('hourlyid','desc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addconfigmaster($config)
{
$this->db->trans_start();
$this->db->insert('T_ConfigMaster', $config);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
//return $insert_id;
$sql='SELECT MAX(Config_ID) as Config_ID FROM T_ConfigMaster';
$res = $this->db->query($sql);
return $res->result_array();
}
function addconfigdetails($configvalue)
{
//print_r($configvalue);
// $this->db->trans_start();
$this->db->insert('T_ConfigDetails', $configvalue);
$insert_id = $this->db->affected_rows();
// $this->db->trans_complete();
// print_r( $this->db->last_query());
//print_r ($insert_id);die();
return $insert_id;
}
/* This function used to Department list which is not available in the Costcenter master
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetBudgetTypeNotinCostCenter($CostCenterCode,$ConfigID)
{
$subQuery = 'select ConfigValue from T_ConfigDetails Bud where ConfigValue not in
(select BudgetType from T_CostCenter_Budget where CostCenterCode=? and BudgetYear=(select max(BudgetYear) from T_CostCenter_Budget)) and Config_ID=?';
$query = $this->db->query($subQuery, array($CostCenterCode,$ConfigID));
// print_r($this->db->last_query());
return $query->result();
}
function GetConfigCenterMaster($ConfigID='')
{
//echo $ConfigID ;die();
$this->db->select('*' );
$this->db->from('T_ConfigMaster ');
//$this->db->join('T_ConfigDetails con','con.Config_ID = COM.Config_ID','left');
$this->db->where('Config_ID', $ConfigID);
$query = $this->db->get();
return $query->result();
}
function GetConfigCenterDetails($ConfigID='')
{
//echo $ConfigID ;die();
$this->db->select('*' );
$this->db->from('T_ConfigMaster COM');
$this->db->join('T_ConfigDetails con','con.Config_ID = COM.Config_ID','left');
$this->db->where('COM.Config_ID', $ConfigID);
$query = $this->db->get();
return $query->result();
}
function updateconfig($config,$Configid)
{
$this->db->where('Config_ID', $Configid);
$this->db->update('T_ConfigMaster', $config);
return TRUE;
}
function updateconfigvalue($configval,$Key)
{
$this->db->where('Key', $Key);
$this->db->update('T_ConfigDetails', $configval);
return TRUE;
}
function EditBudget($Budget)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Budget', $Budget);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r( $this->db->last_query());
return $insert_id;
}
function DeleteBudget($BudgetType='',$BudgetYear='',$CostCenterCode ='')
{
$this->db->where("BudgetType", $BudgetType);
$this->db->where("BudgetYear", $BudgetYear);
$this->db->where("CostCenterCode", $CostCenterCode);
$this->db->delete('T_CostCenter_Budget');
//print_r( $this->db->last_query());
}
function DeleteDepartment($DepCode='',$CostCode='')
{
$this->db->where("DEPCode", $DepCode);
$this->db->where("CostCenterCode", $CostCode);
$this->db->delete('T_CostCenter_Departments');
//print_r( $this->db->last_query());
}
function checkDeptCostExists($DepCode='',$CostCode='')
{
$this->db->select('CostCenterCode,DEPCode');
$this->db->from('T_CostCenter_Departments');
$this->db->where('DEPCode',$DepCode);
$this->db->where('CostCenterCode',$CostCode);
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query
*/
function getConfigValue($ConfigID )
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
$query = $this->db->get();
return $query->result();
}
}
?>

View File

@ -1,418 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class costcenter_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function CostListing()
{
$this->db->select('Cost.CostCenterCode as code,Cost.CostCenterName as CostCenterName , Cost.ApprovedBy as ApprovedBy,Emp.FirstName as FirstName,Emp.Designation as Designation ,Cost.CreatedDate,Cost.IsActive');
$this->db->from('T_CostCenter_Master as Cost');
$this->db->join('T_Employee_Details as Emp', 'Emp.EmpID=Cost.ApprovedBy');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewcost($Cost)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Master', $Cost);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
}
function getFiscalYear()
{
$this->db->select('year(FiscalYearStartOn) as StartYear,year(FiscalYearEndsOn) as EndYear');
$this->db->from('T_Company_Details');
$query = $this->db->get();
return $query->result();
}
function addCostCenterDepartment($Dept)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Departments', $Dept);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r( $this->db->last_query());
return $insert_id;
}
function addBudget($Budget)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Budget', $Budget);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r( $this->db->last_query());
return $insert_id;
}
function getApproverName()
{
$this->db->select('EmpID,FirstName,LastName,Designation');
$this->db->from('T_Employee_Details');
$this->db->where('Departmentcode ', 'DEP10');
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getuserInfo($CostCenterID)
{
$this->db->select('CostCentreID, CostName,Description,CreatedDate');
$this->db->from('T_CostCentre');
$this->db->where('CostCentreID', $CostCenterID);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get Cost center Master information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetCostCenterMaster($CostCenterCode)
{
$this->db->select('Cost.CostCenterCode,Cost.CostCenterName,Cost.ApprovedBy,emp.FirstName,emp.Designation,max(BudgetYear) as BudYear' );
$this->db->from('T_CostCenter_Master Cost');
$this->db->join('T_Employee_Details emp', 'emp.EmpID = Cost.ApprovedBy');
$this->db->join('T_CostCenter_Budget Bud', ' Bud.CostCenterCode = Cost.CostCenterCode');
$this->db->where('Cost.CostCenterCode', $CostCenterCode);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get Cost center Department information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetCostCenterDepartment($CostCenterCode)
{
$this->db->select('Dept.DEPCode,Det.DepartmentName');
$this->db->from('T_CostCenter_Departments Dept');
$this->db->join('T_DepartmentDetails Det', 'Det.DEPCode = Dept.DEPCode');
$this->db->where('Dept.CostCenterCode', $CostCenterCode);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get Cost center Budget information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetBudgetYear($CostCenterCode)
{
$subQuery = 'select BudgetYear from T_CostCenter_Budget where CostCenterCode=? ';
$query = $this->db->query($subQuery, array($CostCenterCode));
return $query->result();
}
/**
* This function used to get Cost center Budget information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetCostCenterBudget($CostCenterCode)
{
$subQuery = 'select BudgetType,BudgetYear,BudgetAmount,Remarks from T_CostCenter_Budget where CostCenterCode=? and
BudgetYear=(select max(BudgetYear) from T_CostCenter_Budget where CostCenterCode=?)';
$query = $this->db->query($subQuery, array($CostCenterCode,$CostCenterCode));
return $query->result();
}
/**
* This function used to get Cost center Budget information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetCostBudgetTypeByYear($CostCenterCode,$ConfigID,$Year)
{
$subQuery = 'select ConfigValue from T_ConfigDetails Bud where ConfigValue not in
(select BudgetType from T_CostCenter_Budget where CostCenterCode=? and BudgetYear=?) and Config_ID=? ';
$query = $this->db->query($subQuery, array($CostCenterCode,$Year,$ConfigID));
return $query->result_array();
}
/**
* This function used to get Cost center Budget information by Cost center ID
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetCostCenterBudgetByYear($CostCenterCode,$Year)
{
$subQuery = 'select BudgetType,BudgetYear,BudgetAmount,Remarks from T_CostCenter_Budget where CostCenterCode=? and
budgetyear=?';
$query = $this->db->query($subQuery, array($CostCenterCode,$Year));
return $query->result_array();
}
/**
* This function used to Department list which is not available in the Costcenter master
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetDepartmentNotinCostCenter($CostCenterCode)
{
$subQuery = 'select Dept.DEPCode,Dept.DepartmentName from T_DepartmentDetails Dept
where Dept.DEPCode not in
(select DEPCode from T_CostCenter_Departments where CostCenterCode=?) order by Dept.DEPCode asc';
$query = $this->db->query($subQuery, array($CostCenterCode));
return $query->result();
}
function getDepartmentnotadded($Empid)
{
$subQuery = 'select Dept.DEPCode,Dept.DepartmentName from T_DepartmentDetails Dept
left join T_AccessDepartments Ass on Ass.Departmentcode= Dept.DEPCode
where Dept.DEPCode not in
(select Ass.Departmentcode from T_AccessDepartments Ass where EmpID=?) group by Dept.DEPCode';
$query = $this->db->query($subQuery, array($Empid));
return $query->result();
}
function getaccessDept($Empid)
{
$this->db->select('Ass.Departmentcode as AssDep,Dep.DepartmentName');
$this->db->from('T_AccessDepartments Ass');
$this->db->join('T_DepartmentDetails Dep', 'Dep.DEPCode = Ass.Departmentcode','left');
$this->db->where('EmpID ',$Empid);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to Department list which is not available in the Costcenter master
* @param number $CostCenterCode : CostCenterCode as Parameter
* @return array $result : This is user information
*/
function GetBudgetTypeNotinCostCenter($CostCenterCode,$ConfigID)
{
$subQuery = 'select ConfigValue from T_ConfigDetails Bud where ConfigValue not in
(select BudgetType from T_CostCenter_Budget where CostCenterCode=? and BudgetYear=(select max(BudgetYear) from T_CostCenter_Budget)) and Config_ID=?';
$query = $this->db->query($subQuery, array($CostCenterCode,$ConfigID));
// print_r($this->db->last_query());
return $query->result();
}
function EditCost($Cost,$CostCenterCode)
{
$this->db->where('CostCenterCode', $CostCenterCode);
$this->db->update('T_CostCenter_Master', $Cost);
return TRUE;
}
function EditBudget($Budget)
{
$this->db->trans_start();
$this->db->insert('T_CostCenter_Budget', $Budget);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r( $this->db->last_query());
return $insert_id;
}
function DeleteBudget($BudgetType='',$BudgetYear='',$CostCenterCode ='')
{
$this->db->where("BudgetType", $BudgetType);
$this->db->where("BudgetYear", $BudgetYear);
$this->db->where("CostCenterCode", $CostCenterCode);
$this->db->delete('T_CostCenter_Budget');
//print_r( $this->db->last_query());
}
function DeleteDepartment($DepCode='',$CostCode='')
{
// echo "fsds";
// die();
$this->db->where("DEPCode", $DepCode);
$this->db->where("CostCenterCode", $CostCode);
$this->db->delete('T_CostCenter_Departments');
//print_r( $this->db->last_query());
}
function checkDeptCostExists($DepCode='',$CostCode='')
{
$this->db->select('CostCenterCode,DEPCode');
$this->db->from('T_CostCenter_Departments');
$this->db->where('DEPCode',$DepCode);
$this->db->where('CostCenterCode',$CostCode);
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkCostDetailsExists($Code='',$CostName='')
{
$this->db->select('CostCenterCode');
$this->db->from('T_CostCenter_Master');
$this->db->where('CostCenterCode',$Code);
if ($CostName != '')
{
$this->db->where('CostCenterName !=',$CostName);
}
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
/* *//**
* This function is used to get the Department details from T_DepartmentDetails
* @return array $result : This is result of the query
*/
function getDepartment()
{
$this->db->select('DEPCode, DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive =', 1);
$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 getConfigValue($ConfigID )
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
$query = $this->db->get();
return $query->result();
}
function export_excel(){
$where = null;
$this->db->select('Mas.*,bud.*,emp.firstname,emp1.firstname as Updated_By');//count(dep.DEPCode) AS ctvalue');
$this->db->select('sum(distinct case when Mas.budgettype="CAPITAL" then budgetamount else 0 end) as capital',FALSE);
$this->db->select('sum(distinct case when Mas.budgettype="REVENUE" then budgetamount else 0 end) as revenue',FALSE);
$this->db->select('sum(distinct case when Mas.budgettype="SERVICE" then budgetamount else 0 end) as service',FALSE);
$this->db->select('sum(distinct case when Mas.budgettype="IMPORT" then budgetamount else 0 end) as import',FALSE);
$this->db->select('GROUP_CONCAT(distinct part.DepartmentName) as DepartmentName');
$this->db->join('T_CostCenter_Budget as Mas','Mas.CostCenterCode=bud.CostCenterCode','left');
$this->db->join('T_CostCenter_Departments as dep',' dep.CostCenterCode=Mas.CostCenterCode','left');
$this->db->join('T_DepartmentDetails as part','part.DEPCode=dep.DEPCode','left');
$this->db->group_by(array('bud.CostCenterCode','Mas.BudgetYear'));
$this->db->join('tbl_users as tbl',' bud.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('tbl_users as tbl1',' bud.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
$this->db->where('Mas.BudgetYear !=""');
return $this->db->get('T_CostCenter_Master as bud')->result_array();
}
//get exist budget year details
function CheckExistBudget($BudgetType,$BudgetYear,$CostCode){
$this->db->select('CostCenterCode');
$this->db->from('T_CostCenter_Budget');
$this->db->where('CostCenterCode',$CostCode);
$this->db->where('BudgetType',$BudgetType);
$this->db->where('BudgetYear',$BudgetYear);
$query = $this->db->get();
if ($query->num_rows > 0) {
return TRUE;
}
else{
return FALSE;
}
}
//update budget
function updateBudget($Budget,$BudgetType,$BudgetYear,$CostCode)
{
$this->db->where('CostCenterCode',$CostCode);
$this->db->where('BudgetType',$BudgetType);
$this->db->where('BudgetYear',$BudgetYear);
$this->db->update('T_CostCenter_Budget', $Budget);
return TRUE;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,134 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class department_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @return number $count : This is row count
*/
// function departmentListingCount($searchText = '')
// {
// $this->db->select('BaseT.DepartmentID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration,BaseT.TIN,BaseT.PAN,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT');
// $this->db->from('T_DepartmentDetails as BaseT');
// //$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left');
// //$this->db->join('T_SupplierDetails as ID', 'ID.DepartmentID = BaseT.DepartmentID','left');
// if(!empty($searchText)) {
// $likeCriteria = "(BaseT.DepartmentID LIKE '%".$searchText."%'
// OR BaseT.SupplierName LIKE '%".$searchText."%'
// OR BaseT.Address LIKE '%".$searchText."%'
// OR BaseT.ContactNumber LIKE '%".$searchText."%'
// OR BaseT.AlternateContactNumber LIKE '%".$searchText."%'
// OR BaseT.EmailAddress LIKE '%".$searchText."%'
// OR BaseT.Exiseregistration LIKE '%".$searchText."%'
// OR BaseT.TIN LIKE '%".$searchText."%'
// OR BaseT.PAN LIKE '%".$searchText."%'
// OR BaseT.GSTNO LIKE '%".$searchText."%'
// OR BaseT.GSTRange LIKE '%".$searchText."%'
// OR BaseT.CollectrateAddress LIKE '%".$searchText."%'
// OR BaseT.UANumber LIKE '%".$searchText."%'
// OR BaseT.PaymentTerms LIKE '%".$searchText."%'
// OR BaseT.PaymentDays LIKE '%".$searchText."%'
// OR BaseT.PayableAT LIKE '%".$searchText."%')";
// $this->db->where($likeCriteria);
// }
// //$this->db->where('BaseT.isDeleted', 0);
// //$this->db->where('BaseT.userId !=', 1);
// $query = $this->db->get();
// return count($query->result());
// }
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function departmentListing()
{
$this->db->select('BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive');
$this->db->from('T_DepartmentDetails as BaseT');
$this->db->order_by("BaseT.DEPCode", "asc");
$query = $this->db->get();
$result = $query->result();
return $result;
}
// function ($searchText = '')
// {
// if(!empty($searchText)) {
// $likeCriteria = "(BaseT.DepartmentName LIKE '%".$searchText."%'
// OR BaseT.DEPCode LIKE '%".$searchText."%'
// OR BaseT.HeadDept LIKE '%".$searchText."%'
// OR BaseT.IsActive LIKE '%".$searchText."%')";
// $this->db->where($likeCriteria);
// }
// //$this->db->where('BaseT.isDeleted', 0);
// //$this->db->where('BaseT.userId !=', 1);
// // $this->db->limit($page, $segment);
// $query = $this->db->get();
// $result = $query->result();
// return $result;
// }
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewdepartment($department)
{
$this->db->insert('T_DepartmentDetails', $department);
$SID = $this->db->affected_rows();
return $SID;
}
function getdepcode()
{
//$limit = 12;
$this->db->distinct();
$this->db->select('DEPCode, DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive =', 1);
//$this->db->limit($limit);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getDeptInfo($DEPCode='')
{
$this->db->select('*');
$this->db->from('T_DepartmentDetails');
$this->db->where('DEPCode', $DEPCode);
$query = $this->db->get();
// print_r($this->db->last_query());
return $query->result();
}
/* This function to get the Supplier Address on respective Supplier ID */
function Updatedepartment($department, $DEPCode)
{
$this->db->where('DEPCode', $DEPCode);
$this->db->update('T_DepartmentDetails', $department);
return TRUE;
}
}
?>

View File

@ -1,210 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class employeedetails_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function employeeListing()
{
$this->db->select(' Emp.*,Dep.DepartmentName as DepartmentName');
$this->db->from('T_Employee_Details Emp');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left');
$this->db->order_by("Emp.EmpID", "asc");
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getUserRoles()
{
$this->db->select('roleId, role');
$this->db->from('tbl_roles');
$this->db->where('roleId !=', 1);
$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 getConfigValue($ConfigID )
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
$query = $this->db->get();
return $query->result();
}
/* *//**
* This function is used to get the Department details from T_DepartmentDetails
* @return array $result : This is result of the query
*/
function getDepartment()
{
$this->db->select('DEPCode, DepartmentName');
$this->db->from('T_DepartmentDetails');
$this->db->where('IsActive =', 1);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewemployee($Employee)
{
$this->db->insert('T_Employee_Details', $Employee);
$EmpID = $this->db->affected_rows();
return $EmpID;
}
function UpdateEmployee($Emp, $EmpID)
{
//echo $EmpID;
$this->db->where('EmpID', $EmpID);
$this->db->update('T_Employee_Details', $Emp);
//print_r($this->db->last_query());
return TRUE;
}
function viewemployee( $EmpID)
{
$this->db->select('Emp.*,Dep.DepartmentName as DepartmentName');
$this->db->from('T_Employee_Details AS Emp');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode','left');
$this->db->where('Emp.EmpID', $EmpID);
$query = $this->db->get();
$result = $query->result();
// print_r($this->db->last_query());
return $result;
}
/* This function to get the Employee department on respective Employee */
function GetEmployeeDepartment($EmployeeID)
{
$this->db->select('DepartmentName');
$this->db->from('T_EmployeeDetails');
$this->db->where($EmployeeID);
$query = $this->db->get();
return $query->result_array();
}
function checkMailExists($email='',$Empid='')
{
$this->db->select('EmailId');
$this->db->from('T_Employee_Details');
$this->db->where('EmailId',$email);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkAadharExists($AadharNo,$Empid='')
{
$this->db->select('AadharNo');
$this->db->from('T_Employee_Details');
$this->db->where('AadharNo',$AadharNo);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkPANExists($PANNo,$Empid='')
{
$this->db->select('PANNo');
$this->db->from('T_Employee_Details');
$this->db->where('PANNo',$PANNo);
if ($Empid != '')
{
$this->db->where('EmpID !=',$Empid);
}
$query = $this->db->get();
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function checkPhotoExists($Pic)
{
$this->db->select('ProfilePic');
$this->db->from('T_Employee_Details');
$this->db->where($Pic);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result_array();
}
}
function getEmployeeCount( )
{
$this->db->select('count(*) as EmpCount');
$this->db->from('T_Employee_Details');
$this->db->where('IsActive ',1 );
$query = $this->db->get();
return $query->result();
}
function getBankDetails()
{
$this->db->select('*');
$this->db->from('T_Bank_Details');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function export_excel(){
$this->db->select(' det.*,Dep.DepartmentName as DepartmentName,det.firstname,emp1.firstname as UpdatedByName,emp1.firstname as CreatedByName');
$this->db->join('T_DepartmentDetails Dep', 'det.Departmentcode = Dep.DEPCode','left');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
return $this->db->get('T_Employee_Details as det')->result_array();
}
}
?>

View File

@ -1,103 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class emppaydate_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function emppayListing()
{
$this->db->select('T_Emp_Pay_Data.*,T_Employee_Details.FirstName,T_Employee_Details.LastName');
$this->db->from('T_Emp_Pay_Data');
$this->db->join('T_Employee_Details','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function deleteEmployeePay($EmpID)
{
$this->db->where('EmpID',$EmpID);
$query = $this->db->delete('T_Emp_Pay_Data');
return $query;
}
function addNewemppay($emppay)
{
$this->db->trans_start();
$this->db->insert('T_Emp_Pay_Data', $emppay);
$paydataid = $this->db->insert_id();
$this->db->trans_complete();
return $emppay;
}
function addLoanInfo($dataarray,$string)
{
if($string == 'add'){
$this->db->insert('T_Loan_Master', $dataarray);
$loanid = $this->db->affected_rows();
return $loanid;
}
else if($string == 'update')
{
$loanid = $dataarray['Loan_ID'];
$this->db->where('Loan_ID',$loanid);
$this->db->update('T_Loan_Master', $dataarray);
$loanid = $this->db->affected_rows();
return $loanid;
}
}
function getUserInfo($paydataid)
{
$sql = 'select T_Emp_Pay_Data.Pay_Data_ID,T_Emp_Pay_Data.EmpID as PAYEMPID,T_Emp_Pay_Data.Basic_Pay,T_Emp_Pay_Data.HRA_Rate,T_Emp_Pay_Data.Allowances,T_Emp_Pay_Data.Food_Allowances,T_Emp_Pay_Data.Incentives,T_Emp_Pay_Data.PF_Rate,T_Emp_Pay_Data.ESI_Rate,T_Emp_Pay_Data.HRA_Amount,T_Emp_Pay_Data.TotalSalary,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.*from T_Emp_Pay_Data
join T_Employee_Details on T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID
left join T_Loan_Master on T_Emp_Pay_Data.EmpID=T_Loan_Master.EmpID and T_Loan_Master.is_Active = 1
where T_Emp_Pay_Data.Pay_Data_ID = ?;';
$query = $this->db->query($sql,array($paydataid));
return $query->result();
}
function editemppay($emppaydatas)
{
$paydateid=$emppaydatas['Pay_Data_ID'];
//echo $paydateid;
//print_r($emppaydatas);die();
$this->db->where('Pay_Data_ID' ,$paydateid);
$this->db->update('T_Emp_Pay_Data',$emppaydatas);
return TRUE;
}
function viewemppay($emppaydata, $paydateid)
{
$this->db->where('Pay_Data_ID', $paydateid);
$this->db->update('T_Emp_Pay_Data', $emppaydata);
return TRUE;
}
}
?>

View File

@ -1,10 +0,0 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -1,856 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class inwardgateregister_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @return number $count : This is row count
*/
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
/*--------------------------JUN 11Change ----------------------------------*/
function updatefile($bill,$Picture,$oldfile)
{
// if($oldfile != ''){
// //unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too
// }
$this->db->set('FilePath', $Picture); //value that used to update column
$this->db->where('BillNo', $bill); //which row want to upgrade
$this->db->update('T_Inwardgateregister_fileupload');
$afftectedRows = $this->db->affected_rows();
return $afftectedRows;
}
function getfies($igr)
{
$this->db->select('*');
$this->db->from('T_Inwardgateregister_fileupload');
$this->db->where('IGRNO',$igr);
$query = $this->db->get();
return $query->result();
}
function fileupload($myfiles)
{
$this->db->insert('T_Inwardgateregister_fileupload',$myfiles);
$myfile=$this->db->affected_rows();
return $myfile;
}
/*------------------------------------------------------------*/
function addMaterialStockHistory($MaterialstockHistoryadd)
{
$this->db->trans_start();
$this->db->insert('T_Material_stock_history', $MaterialstockHistoryadd);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r($this->db->last_query());
//print_r($insert_id);
if($insert_id>0)
{
$subQuery = 'select * from T_Material_stock_history';
$query = $this->db->query($subQuery);
return $query->result();
}
}
/*------------------------------------------------------------*/
// function igrListing()
// {
// $this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName,igr.file');
// $this->db->from('T_IGR_Master igr');
// $this->db->join('T_PurchaseOrder_Master PO','igr.PONO = PO.PONO');
// $this->db->join('T_SupplierDetailsN` sup','PO.SupplierID = sup.SupplierID');
// $this->db->order_by('igr.CreatedDate','desc');
// $query = $this->db->get();
// $result = $query->result();
// return $result;
// }
function igrListing()
{
$this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName,fileup.FilePath,igr.file');
$this->db->from('T_IGR_Master igr');
$this->db->join('T_PurchaseOrder_Master PO','igr.PONO = PO.PONO');
$this->db->join('T_Inwardgateregister_fileupload fileup',' igr.IGRNO = fileup.IGRNO','left');
$this->db->join('T_SupplierDetailsN` sup','PO.SupplierID = sup.SupplierID');
$this->db->group_by('igr.IGRNO','desc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function viewIGRFile($IGRNO)
{
$this->db->distinct();
$this->db->select('*'); //BillNo,IGRNO,FilePath,PONO
$this->db->from('T_Inwardgateregister_fileupload');
$this->db->where('IGRNO',$IGRNO);
$query = $this->db->get();
$result = $query->result();
// print_r($result);die;
//print_r($this->db->last_query());
return $result;
}
function viewIGRFile1($IGRNO)
{
$this->db->distinct();
$this->db->select('igrm.file,igrm.PONO as pono'); //BillNo,IGRNO,FilePath,PONO
$this->db->from('T_IGR_Master igrm');
//$this->db->join('T_Inwardgateregister_fileupload igrf','igrm.IGRNO = igrf.IGRNO','left');
//$this->db->join('T_IGR_Details igrd','igrm.IGRNO = igrd.IGRNO','left');
$this->db->where('igrm.IGRNO',$IGRNO);
$query = $this->db->get();
$result = $query->result();
// print_r($result);die;
//print_r($this->db->last_query());
return $result;
}
function getpurchaseorder()
{
$this->db->distinct();
$this->db->select('POM.PONO,POM.ServiceDescription,POM.DeliveryDate,sup.SupplierName,sup.Address,POM.status,OGR_Status');
$this->db->from('T_PurchaseOrder_Master POM');
$this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO');
$this->db->join('T_SupplierDetailsN sup', 'POM.SupplierID = sup.SupplierID');
$this->db->join('T_OGR_Master OGM ', 'POM.PONO = OGM.PONO_INV','left');
$this->db->where('POM.Status',PO_RELEASED);
$this->db->where('POM.POType !=',SERVICE);
// $this->db->or_where('POM.Status',IGR_CREATED);
$this->db->or_where('POM.Status',MRIR_CREATED);
$this->db->or_where('POM.Status',MRIR_APPROVED);
$this->db->or_where('POM.Status',OGR_COMPLETE);
$query = $this->db->get();
$result = $query->result();
//print_r($this->db->last_query());
return $result;
}
function viewpurchaseorder($PO)
{
$subQuery ='SELECT distinct POM.PONO,POL.MaterialCode,POL.Quantity,POL.ReceivedQuantity,(POL.Quantity -POL.ReceivedQuantity ) as PendingQty,QuantityRejected,POL.PONO,MM.MaterialName,MM.UOM
from T_PurchaseOrder_Master POM
left join T_PurchaseOrder_LineItem POL on POL.PONO = POM.PONO
left join T_IGR_Master IGM on IGM.PONO =POL.PONO
left join T_IGR_Details igr on igr.MaterialCode = POL.MaterialCode and IGM.PONO =POL.PONO
left join T_MaterialMaster MM on MM.MaterialCode = POL.MaterialCode
left join T_MRIR_Master MRM on POM.PONO=MRM.PONO
left join T_MRIR_Details MRD on MRM.MRIRNO=MRD.MRIRNO and POL.MaterialCode=MRD.MaterialCode
where POM.PONO=? group by POL.MaterialCode';// and POM.Status not in(?) ';
$query = $this->db->query($subQuery, array($PO,IGR_CREATED));
// print_r($this->db->last_query());
return $query->result();
/* $this->db->select('POM.PONO,POL.MaterialCode,POL.Quantity,POL.PONO,MM.MaterialName,MM.UOM');
$this->db->from('T_PurchaseOrder_Master POM');
$this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO','left');
$this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = POL.MaterialCode','left');
$this->db->where('POM.PONO',$PO );
$this->db->where('POL.Status !=',POLINEITEM_IGR_CREATED );
$query = $this->db->get();
$result = $query->result();
$this->db->last_query();
return $result; */
}
function addigrM($igrM)
{
$this->db->trans_start();
$this->db->insert('T_IGR_Master', $igrM);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r($this->db->last_query());
//print_r($insert_id);
if($insert_id>0)
{
$subQuery = 'select max(IGRNO) as IGRNO from T_IGR_Master';
$query = $this->db->query($subQuery);
return $query->result();
}
}
function addigrD($igrD)
{
$this->db->trans_start();
$this->db->insert('T_IGR_Details', $igrD);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(IGRItemNo) as IGRItemNo from T_IGR_Details';
$query = $this->db->query($subQuery);
//print_r($query);
return $query->result();
}
}
function addmaterialhistory($historydetails)
{
$this->db->trans_start();
$this->db->insert('T_Material_stock_history', $historydetails);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return true;
}
function addmaterialmaster($current_qty,$MaterialCode)
{
$this->db->where('MaterialCode',$MaterialCode);
$this->db->update('T_MaterialMaster',$current_qty);
return TRUE;
}
function get_CurrentQty($MaterialCode)
{
$this->db->select('Current_stock');
$this->db->from('T_MaterialMaster');
$this->db->where('T_MaterialMaster.MaterialCode',$MaterialCode);
$query = $this->db->get();
// print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getitemvalue($pono,$MaterialCode)
{
$this->db->select('Rate,SupplierID');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->join('T_PurchaseOrder_Master','T_PurchaseOrder_Master.PONO=T_PurchaseOrder_LineItem.PONO');
$this->db->where('T_PurchaseOrder_LineItem.PONO',$pono);
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function viewigr($IGRNO)
{
$this->db->distinct();
$this->db->select('igr.IGRNO,igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity');
$this->db->select('igr.IGRNO,igr.*,igrd.*,MM.MaterialName,MM.UOM,sup.Address,sup.SupplierName,POM.ServiceDescription,POL.Quantity');
$this->db->from('T_IGR_Master igr');
$this->db->join('T_IGR_Details igrd','igrd.IGRNO = igr.IGRNO');
$this->db->join('T_PurchaseOrder_Master POM','igr.PONO = POM.PONO');
$this->db->join('T_PurchaseOrder_LineItem POL','igr.PONO = POL.PONO and POL.MaterialCode=igrd.MaterialCode ');
$this->db->join('T_SupplierDetailsN sup', 'sup.SupplierID = POM.SupplierID');
$this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = igrd.MaterialCode');
$this->db->where('igr.IGRNO',$IGRNO);
$query = $this->db->get();
// print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function UpdatePOLineItem($LineItem,$PONO,$MaterialCode)
{
$this->db->where('PONO', $PONO);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_PurchaseOrder_LineItem', $LineItem);
return TRUE;
}
function UpdateMRIROUTQty($mrirarray,$MRIRNO,$MaterialCode)
{
$this->db->where('MRIRNO', $MRIRNO);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_MRIR_Details', $mrirarray);
return TRUE;
}
function UpdatePOMasterOGRStatus($pono,$POMasterStatuss)
{
$this->db->where('PONO', $pono);
$this->db->update('T_PurchaseOrder_Master', $POMasterStatuss);
return TRUE;
}
function update_OGR($PONO,$status)
{
$this->db->select('*');
$this->db->from('T_OGR_Master');
$this->db->where('PONO_INV',$PONO);
$query= $this->db->get();
if($query->num_rows!=0)
{
$this->db->where('PONO_INV',$PONO);
$ogrstatus=array('Status'=>$status);
$this->db->update('T_OGR_Master',$ogrstatus);
}
}
function UpdatePOMaster($PONO,$updatedBy)
{
$this->db->select('*');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$PONO);
$this->db->where('Status !=',IGR_CREATED);
$query = $this->db->get();
if ($query->num_rows == 0) {
$this->db->where('PONO', $PONO);
$POStatus = array('status'=>IGR_CREATED,'UpdateBY'=>$updatedBy);
$this->db->update('T_PurchaseOrder_Master', $POStatus);
}
}
function UpdateOGRMasterOGRStatus($OGRNO)
{
$this->db->select('*');
$this->db->from('T_OGR_Details');
$this->db->where('OGRNO',$OGRNO);
$this->db->where('Status !=',OGR_PARTIAL_COMPLETE);
$query = $this->db->get();
if ($query->num_rows == 0) {
$this->db->where('OGRNO', $OGRNO);
$OGRStatus = array('status'=>OGR_PARTIAL_COMPLETE);
$this->db->update('T_OGR_Master', $OGRStatus);
}
else
{
$this->db->where('OGRNO', $OGRNO);
$OGRStatus = array('status'=>OGR_COMPLETE);
$this->db->update('T_OGR_Master', $OGRStatus);
}
}
function UpdateMRIRMasterOGRStatus($MRIRNO,$OGRNO)
{
$this->db->select('*');
$this->db->from('T_OGR_Details');
$this->db->where('OGRNO',$OGRNO);
$this->db->where('Status !=',OGR_PARTIAL_COMPLETE);
$query = $this->db->get();
if ($query->num_rows == 0) {
$this->db->where('MRIRNO', $MRIRNO);
$OGRStatus = array('OGRstatus'=>OGR_PARTIAL_COMPLETE);
$this->db->update('T_MRIR_Master', $OGRStatus);
}
else
{
$this->db->where('MRIRNO', $MRIRNO);
$OGRStatus = array('OGRstatus'=>OGR_COMPLETE);
$this->db->update('T_MRIR_Master', $OGRStatus);
}
}
function updateogrpomaster($pono)
{
$this->db->select('*');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$pono);
$this->db->where('OGR_Status !=','ST064');
$query = $this->db->get();
if ($query->num_rows == 0) {
$this->db->where('PONO',$pono);
$POStatus = array('status'=>'ST063');
$this->db->update('T_PurchaseOrder_Master', $POStatus);
}
}
function getPOLineItemReceivedQty($PONO,$MaterialCode)
{
$this->db->select('ReceivedQuantity');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$PONO);
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
// print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function GetMRIROutQty($MRIRNO,$MaterialCode)
{
$this->db->select('Ogr_Out_Qty');
$this->db->from('T_MRIR_Details');
$this->db->where('MRIRNO',$MRIRNO);
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
// print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getCustomer()
{
$subQuery='select client_id,client_name from ip_clients';
$query = $this->db->query($subQuery);
//print_r( $this->db->last_query());
return $query->result();
}
function getSupplier()
{
$subQuery='select SupplierID,SupplierName from T_SupplierDetailsN';
$query = $this->db->query($subQuery);
//print_r( $this->db->last_query());
return $query->result();
}
function getstoredmaterialcode()
{
$subQuery='select MaterialCode,MaterialName from T_MaterialMaster';
$query = $this->db->query($subQuery);
return $query->result();
}
function getOGRData()
{
$this->db->select('T_OGR_Master.*,T_OGR_Details.*,T_SupplierDetailsN.SupplierName,sup.SupplierName as Servicesupplier');
$this->db->from('T_OGR_Master');
$this->db->join('T_OGR_Details','T_OGR_Details.OGRNO=T_OGR_Master.OGRNO');
$this->db->join('T_PurchaseOrder_Master','T_PurchaseOrder_Master.PONO=T_OGR_Master.PONO_INV','left');
$this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=T_PurchaseOrder_Master.SupplierID','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID=T_OGR_Details.SupplierID','left');
$this->db->group_by('T_OGR_Master.OGRNO');
//$this->db->where();
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getOGRDataforedit($OGRNO)
{
$this->db->select('T_OGR_Master.*,T_SupplierDetailsN.SupplierName,T_OGR_Details.*,sup.SupplierName as ServiceSupname,T_MaterialMaster.MaterialName as Matname,Remark');
$this->db->from('T_OGR_Master');
$this->db->join('T_OGR_Details','T_OGR_Details.OGRNO=T_OGR_Master.OGRNO');
$this->db->join('T_PurchaseOrder_Master','T_PurchaseOrder_Master.PONO=T_OGR_Master.PONO_INV','left');
$this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=T_PurchaseOrder_Master.SupplierID','left');
$this->db->join('T_SupplierDetailsN sup','sup.SupplierID=T_OGR_Details.SupplierID','left');
$this->db->join('T_MaterialMaster','T_MaterialMaster.MaterialCode=T_OGR_Details.MaterialCode','left');
$this->db->where('T_OGR_Master.OGRNO',$OGRNO);
//$this->db->group_by('T_OGR_Master.OGRNO');
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getOGRlineDataforedit($OGRNO,$MRIRNO)
{
$this->db->select('T_OGR_Details.*,MaterialName,ActualQuantityReceived,Quantity,QuantityRejected');
$this->db->from('T_OGR_Details');
$this->db->join('T_MaterialMaster','T_MaterialMaster.MaterialCode=T_OGR_Details.MaterialCode');
$this->db->join('T_OGR_Master','T_OGR_Master.OGRNO=T_OGR_Details.OGRNO');
$this->db->join('T_MRIR_Master','T_MRIR_Master.PONO=T_OGR_Master.PONO_INV','left');
$this->db->join('T_MRIR_Details','T_MRIR_Details.MRIRNO=T_MRIR_Master.MRIRNO and T_MRIR_Details.MaterialCode=T_OGR_Details.MaterialCode');
$this->db->join('T_PurchaseOrder_Master','T_PurchaseOrder_Master.PONO=T_MRIR_Master.PONO');
$this->db->join('T_PurchaseOrder_LineItem','T_PurchaseOrder_Master.PONO=T_PurchaseOrder_LineItem.PONO and T_OGR_Details.MaterialCode=T_PurchaseOrder_LineItem.MaterialCode');
$this->db->where('T_OGR_Details.OGRNO',$OGRNO);
$this->db->where('T_MRIR_Details.MRIRNO',$MRIRNO);
$this->db->group_by('T_OGR_Details.MaterialCode');
$query = $this->db->get();
// print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getInvoice($CustomerId)
{
$this->db->select('ip_invoices.invoice_id,invoice_number,item_product_id,item_name,item_quantity');
$this->db->from('ip_invoices');
$this->db->join('ip_invoice_items','ip_invoice_items.invoice_id = ip_invoices.invoice_id');
$this->db->join('ip_clients','ip_invoices.client_id = ip_clients.client_id');
$this->db->where('ip_invoices.client_id',$CustomerId);
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getPOmrir($PONO)
{
$this->db->select('MRIRNO');
$this->db->from('T_MRIR_Master');
$this->db->where('T_MRIR_Master.PONO',$PONO);
$this->db->where('T_MRIR_Master.OGRstatus !=',OGR_COMPLETE);
// $this->db->where('Status !=',IGR_CREATED);
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function getPO($supplierId)
{
/// echo $supplierId;
$subQuery='select T_PurchaseOrder_Master.PONO from T_PurchaseOrder_Master
join T_MRIR_Master on T_MRIR_Master.PONO= T_PurchaseOrder_Master.PONO
where T_PurchaseOrder_Master.SupplierID=? and (T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=? or T_PurchaseOrder_Master.Status=?) group by T_PurchaseOrder_Master.PONO';
//$query= $this->db->query($subQuery, array($supplierId,ST044,PO,ST063));
$query= $this->db->query($subQuery, array($supplierId,ST044,PO,PO_RELEASED,IGR_CREATED,MRIR_CREATED,PARTIAL_MRIRAPPROVED,OGR_COMPLETE,OGR_PARTIAL_COMPLETE,OGR_CREATED));
//print_r( $this->db->last_query());
return $query->result();
}
function getPODetails($PONO)
{
$subQuery ='select distinct T_PurchaseOrder_Master.PONO,T_PurchaseOrder_LineItem.MaterialCode,
T_PurchaseOrder_LineItem.Quantity as Oqty,T_MRIR_Details.ActualQuantityReceived,
T_MRIR_Details.QuantityRejected,MaterialName,balance_Qty
from T_PurchaseOrder_Master
join T_PurchaseOrder_LineItem on T_PurchaseOrder_LineItem.PONO = T_PurchaseOrder_Master.PONO
join T_MRIR_Master on T_MRIR_Master.PONO = T_PurchaseOrder_Master.PONO
join T_MRIR_Details on T_MRIR_Master.MRIRNO = T_MRIR_Details.MRIRNO and T_PurchaseOrder_LineItem.MaterialCode=T_MRIR_Details.MaterialCode
join T_MaterialMaster on T_MRIR_Details.MaterialCode=T_MaterialMaster.MaterialCode
left join T_OGR_Master on T_PurchaseOrder_Master.PONO=T_OGR_Master.PONO_INV
left join T_OGR_Details on T_OGR_Master.OGRNO=T_OGR_Details.OGRNO and T_PurchaseOrder_LineItem.MaterialCode= T_OGR_Details.MaterialCode
where T_PurchaseOrder_Master.PONO=?';
$query = $this->db->query($subQuery, array($PONO));
//print_r($this->db->last_query());
return $query->result();
}
function getPOMRIRDetails($MRIRno,$PONO,$materialcode)
{
$subQuery='select T_MRIR_Details.MaterialCode,ActualQuantityReceived,QuantityAccepted,QuantityRejected,
MaterialName,Quantity as Oqty,SUM(Ogr_Out_Qty) as allowedQty
from T_MRIR_Details
join T_MaterialMaster on T_MRIR_Details.MaterialCode=T_MaterialMaster.MaterialCode
join T_MRIR_Master on T_MRIR_Details.MRIRNO = T_MRIR_Master.MRIRNO
join T_PurchaseOrder_LineItem on T_MRIR_Master.PONO = T_PurchaseOrder_LineItem.PONO and T_PurchaseOrder_LineItem.MaterialCode=T_MRIR_Details.MaterialCode
where T_MRIR_Details.MRIRNO=? and T_MRIR_Master.PONO=? and T_MRIR_Details.MaterialCode=? group by T_MRIR_Details.MaterialCode;';
$query = $this->db->query($subQuery, array($MRIRno,$PONO,$materialcode));
//print_r($this->db->last_query());
return $query->result();
}
function getPOMRIRMaterial($MRIRno,$PONO)
{
$this->db->select('MaterialCode');
$this->db->from('T_MRIR_Details');
$this->db->join('T_MRIR_Master','T_MRIR_Master.MRIRNO=T_MRIR_Details.MRIRNO');
$this->db->where('T_MRIR_Details.MRIRNO',$MRIRno);
$this->db->where('PONO',$PONO);
$this->db->group_by('T_MRIR_Details.MaterialCode');
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function gettotalout($PONO,$materialcode)
{
$subQuery='select SUM(Ogr_Out_Qty)
from T_MRIR_Details
join T_MRIR_Master on T_MRIR_Master.MRIRNO= T_MRIR_Details.MRIRNO
where PONO =? and MaterialCode = ?; ';
$query = $this->db->query($subQuery, array($PONO,$materialcode));
//print_r($this->db->last_query());
return $query->result();
}
function getPOmaterialDetails($PONO,$materialcode)
{
$subQuery='select distinct T_PurchaseOrder_LineItem.MaterialCode,MaterialName,T_PurchaseOrder_LineItem.Quantity as Oqty,T_MRIR_Details.ActualQuantityReceived,T_MRIR_Details.QuantityRejected,balance_Qty
from T_PurchaseOrder_Master
join T_PurchaseOrder_LineItem on T_PurchaseOrder_LineItem.PONO = T_PurchaseOrder_Master.PONO
join T_MRIR_Master on T_MRIR_Master.PONO = T_PurchaseOrder_Master.PONO
join T_MRIR_Details on T_MRIR_Master.MRIRNO = T_MRIR_Details.MRIRNO and T_PurchaseOrder_LineItem.MaterialCode=T_MRIR_Details.MaterialCode
join T_MaterialMaster on T_MRIR_Details.MaterialCode=T_MaterialMaster.MaterialCode
left join T_OGR_Master on T_PurchaseOrder_Master.PONO=T_OGR_Master.PONO_INV
left join T_OGR_Details on T_OGR_Master.OGRNO=T_OGR_Details.OGRNO and T_PurchaseOrder_LineItem.MaterialCode= T_OGR_Details.MaterialCode
where T_PurchaseOrder_LineItem.PONO=? and T_PurchaseOrder_LineItem.MaterialCode=?'
;
$query = $this->db->query($subQuery, array($PONO,$materialcode));
// print_r($this->db->last_query());
return $query->result();
}
function getPOmaterial($PONO)
{
$subQuery ='select MaterialCode from T_PurchaseOrder_LineItem where PONO=?';
$query = $this->db->query($subQuery, array($PONO));
//print_r($this->db->last_query());
return $query->result();
}
function AddOGR($ogrmaster)
{
$this->db->trans_start();
$this->db->insert('T_OGR_Master', $ogrmaster);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// print_r($this->db->last_query());
//print_r($insert_id);
if($insert_id>0)
{
$subQuery = 'select max(OGRNO) as OGRNO from T_OGR_Master';
$query = $this->db->query($subQuery);
return $query->result();
}
}
function getlastogrline()
{
$subQuery = 'select max(OGRItemNO) as OGRItemNO from T_OGR_Details';
$query = $this->db->query($subQuery);
return $query->result();
}
function UpdateOGR($updateogrmaster,$OGRNO)
{
$this->db->where('OGRNO',$OGRNO);
//$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_OGR_Master', $updateogrmaster);
return TRUE;
}
function AddOgrLine($Ogrline)
{
$this->db->trans_start();
$this->db->insert('T_OGR_Details',$Ogrline);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
}
// function GetIGR_Details($pono)
// {
// $this->db->select('IGRNO,MRIRNO,MaterialCode,');
// $this->db->from('ip_invoices');
// $this->db->join('ip_invoice_items','ip_invoice_items.invoice_id = ip_invoices.invoice_id');
// $this->db->join('ip_clients','ip_invoices.client_id = ip_clients.client_id');
// $this->db->where('ip_invoices.client_id',$CustomerId);
// $query = $this->db->get();
// //print_r( $this->db->last_query());
// $result = $query->result();
// return $result;
// }
function GetPreSavedQty($pono,$MaterialCode)
{
// $subQuery = 'select Total_OutwardQty from T_PurchaseOrder_LineItem where PONO=? and MaterialCode=?';
// $query = $this->db->query($subQuery, array($pono,$MaterialCode));
// //print_r($this->db->last_query());
// return $query->result();
$this->db->select('Total_OutwardQty');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$pono);
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
//print_r( $this->db->last_query());
$result = $query->result();
return $result;
}
function check_PO($pono)
{
$subQuery='select * from T_OGR_Master where PONO_INV=?';
$query=$this->db->query($subQuery,array($pono));
return $query->result();
}
function UpdatePOMasterOGR($postatus,$pono)
{
$this->db->where('PONO',$pono);
//$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_PurchaseOrder_Master', $postatus);
return TRUE;
}
function updateigr($igrarr,$IGRNo){
//$this->db->where('PONO',$PONO);
$this->db->where('IGRNO',$IGRNo);
$this->db->update('T_IGR_Master',$igrarr);
$r = $this->db->affected_rows();
return $r;
}
function getpolineqty($NewPO)
{
$this->db->select('sum(Quantity)as Qty,sum(ReceivedQuantity)as rec');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$NewPO);
$query = $this->db->get();
return $query->result();
}
function POLineItemsupdatestatus($PONO,$Newstatus)
{
$this->db->where('PONO',$PONO);
$this->db->update('T_PurchaseOrder_LineItem',$Newstatus);
$update = $this->db->affected_rows();
return $update;
}
function pomasterupdatestatus($PONO,$Newstatus)
{
$this->db->where('PONO',$PONO);
$this->db->update('T_PurchaseOrder_Master',$Newstatus);
$update = $this->db->affected_rows();
return $update;
}
}

View File

@ -1,198 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Login_model extends CI_Model
{
/**
* This function used to check the login credentials of the user
* @param string $email : This is email of the user
* @param string $password : This is encrypted password of the user
*/
function loginMe($email, $password)
{
$this->db->select('BaseTbl.userId, BaseTbl.password, Emp.EmpID,Emp.FirstName,Emp.Designation, BaseTbl.roleId, Roles.role,DEPT.DEPCode,DEPT.DepartmentName,DEPT.HeadDept,Emp.ProfilePic,CompTbl.CompanyName');
$this->db->from('tbl_users as BaseTbl');
$this->db->join('tbl_roles as Roles','Roles.roleId = BaseTbl.roleId');
$this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID');
$this->db->join('T_DepartmentDetails as DEPT','Emp.Departmentcode = DEPT.DEPCode');
$this->db->where('BaseTbl.isDeleted !=',1);
$this->db->join('T_Company_Details as CompTbl','true','cross');
$this->db->where('BaseTbl.email', $email);
$this->db->or_where('Emp.ContactNumber', $email);
$this->db->where('BaseTbl.isDeleted !=',1);
$query = $this->db->get();
$user = $query->result();
if(!empty($user)){
if(verifyHashedPassword($password, $user[0]->password)){
return $user;
} else {
return array();
}
} else {
return array();
}
}
/**
* This function used to insert reset password data
* @param {array} $data : This is reset password data
* @return {boolean} $result : TRUE/FALSE
*/
function resetPasswordUser($data)
{
$result = $this->db->insert('tbl_reset_password', $data);
if($result) {
return TRUE;
} else {
return FALSE;
}
}
/**
* This function is used to get customer information by email-id for forget password email
* @param string $email : Email id of customer
* @return object $result : Information of customer
*/
function getCustomerInfoByEmail($email)
{
$this->db->select('userId, email, EmpID');
$this->db->from('tbl_users');
$this->db->where('isDeleted', 0);
$this->db->where('email', $email);
$query = $this->db->get();
return $query->result();
}
/**
* This function used to check correct activation deatails for forget password.
* @param string $email : Email id of user
* @param string $activation_id : This is activation string
*/
function checkActivationDetails($email, $activation_id)
{
$this->db->select('id');
$this->db->from('tbl_reset_password');
$this->db->where('email', $email);
$this->db->where('activation_id', $activation_id);
$query = $this->db->get();
return $query->num_rows;
}
// This function used to create new password by reset link
function createPasswordUser($email, $password)
{
$this->db->where('email', $email);
$this->db->where('isDeleted', 0);
$this->db->update('tbl_users', array('password'=>getHashedPassword($password)));
$this->db->delete('tbl_reset_password', array('email'=>$email));
}
/**
* This function used to check email exists or not
* @param {string} $email : This is users email id
* @return {boolean} $result : TRUE/FALSE
*/
function checkEmailExist($email)
{
$this->db->select('userId');
$this->db->where('email', $email);
$this->db->where('isDeleted', 0);
$query = $this->db->get('tbl_users');
if ($query->num_rows() > 0){
return true;
} else {
return false;
}
}
function Accessdep($EmpID)
{
$this->db->select('Departmentcode as AssDep');
$this->db->from('T_AccessDepartments');
$this->db->where('EmpID', $EmpID);
$query = $this->db->get();
// print_r( $this->db->last_query());
return $query->result();
}
/**
* get the user dtl
*/
function getuserid($mobileno,$emailid)
{
$this->db->select('UsrTbl.userId,UsrTbl.email,EmpTbl.ContactNumber,EmpTbl.FirstName');
$this->db->from('tbl_users as UsrTbl');
$this->db->join('T_Employee_Details as EmpTbl','UsrTbl.EmpID = EmpTbl.EmpID');
$this->db->where('EmpTbl.ContactNumber', $mobileno);
$this->db->where('UsrTbl.email',$emailid);
$this->db->where('UsrTbl.isDeleted', 0);
$res = $this->db->get();
return $res->result();
}
/**
* To update opt in our database
**/
function temp2($userId,$otp){
$this->db->set('OTP',$otp);
$this->db->where('userId',$userId);
$this->db->update('tbl_users');
$count = $this->db->affected_rows();
if($count > 0)
{
$subQuery = "select OTP from tbl_users where userId = '".$userId."'";
$query = $this->db->query($subQuery);
return $query->result();
}
}
/**
* To get user id
**/
function getuserdtl($phno){
$this->db->select('BaseTbl.userId');
$this->db->from('tbl_users as BaseTbl');
$this->db->join('T_Employee_Details as Emp','BaseTbl.EmpID = Emp.EmpID');
$this->db->where('Emp.ContactNumber', $phno);
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* To update password and otp
**/
function resetpassword($Array,$userid){
$this->db->where('userId',$userid);
$this->db->update('tbl_users',$Array);
$count = $this->db->affected_rows();
return $count;
}
/**
* To update password only
**/
function updatepassword($userid,$password){
$this->db->set('password',$password);
$this->db->where('userId',$userid);
$this->db->update('tbl_users');
$count = $this->db->affected_rows();
return $count;
}
}
?>

View File

@ -1,545 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class monthlypay_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function monthlyListing($current="")
{
$month = $current;
if(strlen($month) == 6)
{
$month = '0'.$month;
}
//echo $month;
$curr_split = explode('-',$current);
$month_val = $curr_split[0];
$year_val = $curr_split[1];
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
//echo $lastdate ;
// $this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Payroll.Key,T_Loan_Master.Loan_ID');
// $this->db->from('T_Monthly_Pay_Inputs');
// $this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID');
// $this->db->join('T_Payroll','T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID','left');
// $this->db->join('T_Loan_Master','T_Monthly_Pay_Inputs.EmpID=T_Loan_Master.EmpID','left');
// $this->db->order_by('T_Employee_Details.EmpID','asc');
// $this->db->where('T_Employee_Details.DateofJoining <=',$lastdate);
// $this->db->where('Month_Year',$current);
$sql="select T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.Loan_ID,T_Loan_Master.Monthly_Due,T_Payroll.Key
from T_Monthly_Pay_Inputs
left join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID and T_Employee_Details.DateofJoining <= ?
left join T_Payroll on T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID
left join T_Loan_Master on T_Monthly_Pay_Inputs.EmpID=T_Loan_Master.EmpID and T_Loan_Master.is_Active = 1
where Month_Year = ?
order by T_Employee_Details.EmpID asc";
$query = $this->db->query($sql,array($lastdate,$current));
// print_r($query->result());
$result = $query->result();
return $result;
}
function getEmpPayDetails($current="",$s="")
{
$month_val = date('m',strtotime($current));
$year_val = date('Y',strtotime($current));
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
//$monthyear_val = date('Y-m',strtotime($current));
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
$this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining');
$this->db->from('T_Employee_Details');
//$this->db->join('T_Emp_Pay_Data','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID','Left');
$this->db->where('T_Employee_Details.IsActive',1);
$this->db->where('T_Employee_Details.DateofJoining <=',$lastdate);
$this->db->order_by('EmpID','asc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getEmpPayDetailsforMonthInputs($current="")
{
//$month = '0'.$current;
$month = $current;
if(strlen($month) == 6)
{
$month = '0'.$month;
}
//echo $month;
$current = '01-'.$current;
//echo $current;
$current = date_create($current);
$current = date_format($current,'Y-m-d');
//echo 'Final'.$current;
$month_val = date('m',strtotime($current));
$year_val = date('Y',strtotime($current));
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
//$monthyear_val = date('Y-m',strtotime($current));
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
//echo $lastdate;
//left join T_Payroll on T_Employee_Details.EmpID = T_Payroll.EmpID and month(T_Payroll.PayOn) = month(?) and year(T_Payroll.PayOn) = year(?)
$sql ="select T_Emp_Pay_Data.EmpID, T_Emp_Pay_Data.Incentives as MasterIncentives,T_Emp_Pay_Data.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining,T_Attendance.Days_Worked as Days_worked,T_Attendance.Absent as LOP_Days,T_Attendance.Paid_Leave as Paid_leave,T_Attendance.Total_OTHrs as OT_Hrs_Worked,T_Attendance.NoofDays,T_Loan_Master.Loan_ID,T_Loan_Master.Monthly_Due,T_Loan_Master.Due_Start_Date as DueDate,T_Loan_Master.Loan_Amount,T_Loan_Master.Paid_Amount,T_Payroll.Key,T_Monthly_Pay_Inputs.Incentives as MonthlyIncentives,T_Monthly_Pay_Inputs.Loan_Recovered,T_Monthly_Pay_Inputs.Estimate,T_Monthly_Pay_Inputs.Festival_Bonus,T_Monthly_Pay_Inputs.Other_Deductions,T_Loan_History .Balance_Amount
from T_Emp_Pay_Data
left join T_Employee_Details on T_Employee_Details.EmpID = T_Emp_Pay_Data.EmpID
left join T_Payroll on T_Employee_Details.EmpID = T_Payroll.EmpID and T_Payroll.PayOn = ?
left join T_Attendance on T_Emp_Pay_Data.EmpID = T_Attendance.EmpID
left join T_Monthly_Pay_Inputs on T_Monthly_Pay_Inputs.EmpID = T_Emp_Pay_Data.EmpID and T_Monthly_Pay_Inputs.Month_Year = ?
left join T_Loan_Master on T_Emp_Pay_Data.EmpID = T_Loan_Master.EmpID and T_Loan_Master.is_Active = 1
left join T_Loan_History on T_Loan_History .Loan_ID = T_Loan_Master.Loan_ID
where T_Employee_Details.DateofJoining <= ?
and month(T_Attendance.Month_Year) = month(?) and year(T_Attendance.Month_Year) = year(?)
order by T_Employee_Details.EmpID";
$query = $this->db->query($sql,array($month,$month,$lastdate,$current,$current));
return $query->result();
}
function getPublicHoldays($current="")
{
if(!empty($current))
{
$sql = "select * from T_Public_Holidays where month(H_Date) = month(?) and year(H_Date) = year(?)";
$query = $this->db->query($sql,array($current,$current));
return $query->result();
}
else
{
$sql = "select * from T_Public_Holidays where year(H_Date)=year(CURRENT_DATE) order by H_Date";
$query = $this->db->query($sql);
return $query->result();
}
}
function checkHoliday($Date)
{
$Date = date('Y-m-d',strtotime($Date));
//echo $Date;die();[
$sql="select count(*) as count from T_Public_Holidays where H_Date = ?";
$query = $this->db->query($sql,array($Date));
return $query->result_array();
}
function saveHolidays($data,$string)
{
//print_r($data);
if($string == 'i')
{
$this->db->insert('T_Public_Holidays',$data);
$i= $this->db->affected_rows();
return $i;
}
else if($string == 'u')
{
$this->db->where('H_date',$data['H_Date']);
$this->db->update('T_Public_Holidays',$data);
$i = $this->db->affected_rows();
return $i;
}
}
function deleteHoliday($d)
{
$d = date_format(date_create($d),'Y-m-d');
$this->db->where('H_date',$d);
$this->db->delete('T_Public_Holidays');
return $this->db->affected_rows();
}
function monthlyAttendance($current="")
{
$month_val = date('m',strtotime($current));
$year_val = date('Y',strtotime($current));
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
$this->db->select('T_Attendance.*,T_Employee_Details.FirstName,T_Employee_Details.LastName');
$this->db->from('T_Attendance');
$this->db->join('T_Employee_Details','T_Attendance.EmpID=T_Employee_Details.EmpID');
// $this->db->where('year(T_Employee_Details.DateofJoining) <= ',$year_val);
// $this->db->where('month(T_Employee_Details.DateofJoining) <= ',$month_val);
$this->db->where('T_Employee_Details.DateofJoining <= ',$lastdate);
$this->db->where('Month_Year',$current);
//$this->db->where('T_Employee_Details.IsActive',1);
$this->db->order_by('T_Attendance.EmpID', 'asc');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function saveMonthlyData_model($data)
{
$month = $data['Month_Year'];
$empid = $data['EmpID'];
$count=0;
$this->db->select('count(*) as count');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->where('Month_Year',$month);
$this->db->where('EmpID',$empid);
$isExits = $this->db->get();
$res = $isExits->result_array();
if(!empty($res))
{
$count = $res[0]['count'];
}
if($count == 0 )
{
$i = $this->db->insert('T_Monthly_Pay_Inputs',$data);
return $i;
}
elseif($count == 1)
{
$this->db->where('Month_Year',$month);
$this->db->where('EmpID',$empid);
$i = $this->db->update('T_Monthly_Pay_Inputs',$data);
return $i;
}
}
function saveAttendance($monthattendance,$Month_Year,$EmpID)
{
$this->db->select('count(*) as c');
$this->db->from('T_Attendance');
$this->db->where('Month_Year',$Month_Year);
$this->db->where('EmpID',$EmpID);
$isExist = $this->db->get();
$isExist = $isExist->result_array();
$ans = $isExist[0]['c'];
if($ans == 0)
{
//array_pop();
$this->db->insert('T_Attendance',$monthattendance);
return $this->db->affected_rows();
//echo "INS";
// if($this->db->affected_rows() > 0)
// {
// return true;
// }
// else
// {
// return false;
// }
}
else
{
$this->db->where('Month_Year',$Month_Year);
$this->db->where('EmpID',$EmpID);
$this->db->update('T_Attendance',$monthattendance);
//echo "UPDATE";
return $this->db->affected_rows();
}
}
function addNewmonthlisting($m_list)
{
$this->db->trans_start();
$this->db->insert('T_Monthly_Pay_Inputs', $asset);
$Asset_Code = $this->db->insert_id();
$this->db->trans_complete();
return $m_list;
}
function getUserInfo($EmpID,$month_year)
{
$this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID');
$this->db->where('T_Monthly_Pay_Inputs.EmpID', $EmpID);
$this->db->where('T_Monthly_Pay_Inputs.Month_Year', $month_year);
$query = $this->db->get();
return $query->result();
}
function editmonth($monthdata, $EmpID)
{
$monthyear=$monthdata['Month_Year'];
$this->db->where('EmpID' ,$EmpID);
$this->db->where('Month_Year',$monthyear);
$this->db->update('T_Monthly_Pay_Inputs',$monthdata);
return TRUE;
}
function viewmonth($monthdata, $employeeid)
{
$this->db->order_by('Month_Year');
$this->db->where('EmpID', $employeeid);
$this->db->update('T_Monthly_Pay_Inputs', $monthdata);
return TRUE;
}
/*permission form model */
function emplist()
{
$sql="select Emp.EmpID,CONCAT(FirstName,' ',LastName)as name ,Emp.Departmentcode, Dep.DepartmentName FROM T_Employee_Details as Emp
join T_DepartmentDetails as Dep on Dep.DEPCode=Emp.Departmentcode where Emp.IsActive = 1;";
$query =$this->db->query($sql);
return $query->result();
}
function addper($Permissiondata)
{
//if(!empty($Permissiondata){
$this->db->trans_start();
$this->db->insert('T_Permission', $Permissiondata);
//$Asset_Code = $this->db->insert_id();
$Permission = $this->db->affected_rows();
$this->db->trans_complete();
return $Permission;
}
function perlist()
{
$this->db->select('*');
$this->db->from('T_Permission');
$query =$this->db->get();
return $query->result();
}
function pdf($SNO)
{
$this->db->select('per.*,emp.FirstName,LastName,dep.DepartmentName');
$this->db->from('T_Permission per');
$this->db->join('T_Employee_Details emp','emp.EmpID = per.EmpID');
$this->db->join('T_DepartmentDetails dep','dep.DEPCode = emp.Departmentcode');
$this->db->where('per.SNO',$SNO );
$query =$this->db->get();
return $query->result();
}
function reportvalue($fin_year)
{
$curr_split = explode('-',$fin_year);
$pre_year = $curr_split[0];
$curr_year = $curr_split[1];
$sql= "select T_Monthly_Pay_Inputs.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus
from T_Monthly_Pay_Inputs
join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID
where
substr(T_Monthly_Pay_Inputs.Month_Year,4) = ?
and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4
or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ?
and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3
group by T_Monthly_Pay_Inputs.EmpID";
$query = $this->db->query($sql,array($pre_year,$curr_year));
return $query->result();
}
function Monthwisereportvalue($Fin_year,$EmployeeID)
{
$curr_split = explode('-',$Fin_year);
$pre_year = $curr_split[0];
$curr_year = $curr_split[1];
$sql= "select T_Monthly_Pay_Inputs.EmpID,T_Monthly_Pay_Inputs.Month_Year,T_Employee_Details.FirstName,T_Employee_Details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus
from T_Monthly_Pay_Inputs
join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID = T_Employee_Details.EmpID
and T_Monthly_Pay_Inputs.EmpID = ?
where substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) >= 4
or substr(T_Monthly_Pay_Inputs.Month_Year,4) = ? and substr(T_Monthly_Pay_Inputs.Month_Year,1,2) <= 3
group by T_Monthly_Pay_Inputs.Month_Year";
$query = $this->db->query($sql,array($EmployeeID,$pre_year,$curr_year));
return $query->result();
}
//this function Production Salary cost details
function productionsalarycosts($productions)
{
$this->db->insert('T_ProductionSalaryCost',$productions);
$r = $this->db->affected_rows();
return $r;
}
function updateproduction($productions,$sno)
{
$this->db->where('sno',$sno);
$this->db->update('T_ProductionSalaryCost',$productions);
$r = $this->db->affected_rows();
return $r;
}
function productionsalarycost()
{
$this->db->select('*');
$this->db->from('T_ProductionSalaryCost');
$query =$this->db->get();
return $query->result();
}
function attyesterday($WH,$daydate)
{
$sql="select att.EmpID,".$WH.",a.FirstName from T_Attendance as att
join T_Employee_Details as a on a.EmpID= att.EmpID
where Month_Year = ? and att.EmpID in (select EmpID from T_Attendance)";
$query = $this->db->query($sql,array($daydate));
return $query->result_array();
}
function dayAllPersentEmpSalary($WH,$OT,$date)
{
$sql="select EmpID,".$WH.",".$OT." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)";
$query = $this->db->query($sql,array($date));
return $query->result_array();
}
function persentEmployeeDetails($EmpID){
$sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;";
$query = $this->db->query($sql,array($EmpID));
return $query->result();
}
// function cost($ab)
// {
// $sql = "select * from T_ProductionSalaryCost where month(date)=month('".$ab."')";
// //echo $sql;die;
// $query = $this->db->query($sql);
// return $query->result();
// }
function cost($ab,$from,$to)
{
// echo $ab;echo $from;echo $to;
// die;
$sql = "select * from T_ProductionSalaryCost where
month(date)= month('".$ab."')";
if ($from and $to != '')
{
$sql.="or date >= '".$from."'
and date <= '".$to."'";
}
// echo $sql;
$query = $this->db->query($sql);
return $query->result();
}
}
?>

View File

@ -1,387 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class mrir_model extends CI_Model
{
/* This function is used to get the user listing count*/
/* This function is used to display the IGR in dropdown box*/
function getIGRNOonly()
{
$this->db->select('IGRNO');
$this->db->from('T_IGR_Master');
$this->db->order_by('IGRNO', 'asc');
$res=$this->db->get();
return $res->result();
}
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function ViewigrListing()
{
$this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName');
$this->db->from('T_IGR_Master igr');
$this->db->join('T_PurchaseOrder_Master PO','igr.PONO = PO.PONO');
$this->db->join('T_SupplierDetailsN` sup','PO.SupplierID = sup.SupplierID');
$this->db->where('igr.IGRStatus !=',MRIR_CREATED);
$this->db->where('PO.IsQualityChkReqired',1);
$this->db->order_by("CreatedDate","desc");
$query = $this->db->get();
$result = $query->result();
return $result;
}
/* This function is used to get the igr value (button link)*/
function get_IGR($IgrNo)
{
$this->db->distinct();
$this->db->select('IGRM.DeliveryChellanDate,IGRM.CreatedDate,IGRM.IGRNO,IGRM.VehicleNo,IGRM.DeliveryChellanOrInvoiceNo,IGRM.CourierNo,IGRM.PONO,IGRD.MaterialCode,IGRD.QuantityAsPerInvoice,POMR.ServiceDescription,POMR.PODate,POMR.DeliveryDate,POMR.CreatedBy,SUPP.SupplierName,SUPP.Address,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName');
//$this->db->select("DATE_FORMAT(IGRM.DeliveryChellanDate, '%d %m %Y') as DCdate");
$this->db->from('T_IGR_Master IGRM');
$this->db->join('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO');
$this->db->join('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO');
$this->db->join('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID');
$this->db->join('T_MaterialMaster MM',' MM.MaterialCode=IGRD.MaterialCode');
$this->db->join('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO and IGRD.MaterialCode = POLT.MaterialCode');
$this->db->join ('tbl_users user','user.userid=POMR.CreatedBy','left');
$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left');
$this->db->where('IGRM.IGRNO',$IgrNo);
$query = $this->db->get();
$result = $query->result();
//print_r($this->db->last_query());
return $result;
}
function ViewDistributionList()
{
$subQuery = 'Select distinct ReqLine.MaterialCode, MR.PONO, REQ.ReqNo,MM.MaterialName,MM.UOM,
EMP.FirstName,DD.DEPCode,DD.DepartmentName,ReqLine.Quantity as RequestedQty,POL.Quantity
as OrderedQuantity ,(MD.ActualQuantityReceived) as ActualReceivedqty,(MD.QuantityAccepted) as
AcceptedQty,REQ.ReqDate, ReqLine.Status as ReqStatus,
st.StatusCode as ReqStatus,st.StatusName,
ReqLine.Remarks
from T_Requestion_Details ReqLine join T_PurchaseOrder_LineItem POL
on ReqLine.ReqNo = POL.ReqNo and ReqLine.MaterialCode = POL.MaterialCode
join T_Requestion_Master REQ on REQ.ReqNo = ReqLine.ReqNo
join T_PurchaseOrder_Master POMast on POMast.PONO=POL.PONO
join T_Status st on ReqLine.Status = st.StatusCode
join T_MRIR_Master MR on MR.PONO = POL.PONO join T_MRIR_Details MD
on MD.MRIRNO = MR.MRIRNO and ReqLine.MaterialCode = MD.MaterialCode join T_MaterialMaster MM on
MM.MaterialCode = ReqLine.MaterialCode join
T_Employee_Details EMP on EMP.EmpID = REQ.Requestedby join
T_DepartmentDetails DD on DD.DEPCode = EMP.Departmentcode where
POL.status in (?,?)
and ReqLine.Status not in(?) and POMast.status not in(?)
group by ReqLine.MaterialCode ,POL.PONO';
$query = $this->db->query($subQuery,array(MRIR_APPROVED,PARTIAL_MRIRAPPROVED,REQITEM_NEW,PO_AMENDED));
//print_r($this->db->last_query());
return $query->result();
}
/* This function is used to list the MRIR value*/
function view_mrir()
{
$this->db->distinct();
$this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.MRIRStatus,ST.StatusName,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,TMD.StoreInchargeID,TMD.QualityInchargeID,TMD.PlantInchargeID,TMD.UpdateBY,POM.PODate,POM.POType,POM.CreatedBy,ED.FirstName as UpdatedbyName,ED1.FirstName as CreatedByName');
$this->db->from ('T_MRIR_Master TMM');
$this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO=TMD.MRIRNO');
$this->db->join ('T_IGR_Master IGRM','TMM.IGRNO=IGRM.IGRNO');
$this->db->join ('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO');
$this->db->join ('T_PurchaseOrder_Master POM','TMM.PONO=POM.PONO');
$this->db->join ('tbl_users user','user.userid=TMD.UpdateBY','left');
$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left');
$this->db->join ('tbl_users user1','user1.userid = POM.CreatedBy','left');
$this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left');
$this->db->join ('T_Status ST','ST.StatusCode = TMM.MRIRStatus');
//$this->db->where('POM.IsQualityChkReqired !=','0');
$this->db->order_by ('TMM.MRIRNO','desc');
$query = $this->db->get();
return $query->result();
}
function getStatus()
{
$this->db->select('StatusCode,StatusName');
$this->db->from('T_Status');
$this->db->where('StatusType',8);
$query = $this->db->get();
return $query->result();
}
/* This function is used to list the MRIR value*/
function view_mrir_Billing()
{
$this->db->distinct();
$this->db->select('TMM.MRIRNO,TMM.PONO, TMM.IGRNO,IGRM.DeliveryChellanOrInvoiceNo,
IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,TMD.QualityInchargeID,
TMD.PlantInchargeID,TMD.UpdateBY, POM.PODate,POM.POType,POM.ReleasedBy,ED2.FirstName as StoreinchargeName,POM.IsQualityChkReqired,POM.POType,POM.CapitalRange,POM.Status,
ED.FirstName as UpdatedbyName,ED1.FirstName as ReleasedbyName,MM.MaterialCode,MM.MaterialName,
MM.UOM, POL.Quantity,IGRD.QuantityAsPerInvoice, TMD.ActualQuantityReceived,TMD.QuantityAccepted,
TMD.QuantityRejected,ST.StatusName,TMD.Remarks,AdvanceAmount ');
$this->db->from ('T_MRIR_Master TMM');
$this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO=TMD.MRIRNO','left');
$this->db->join ('T_IGR_Master IGRM','TMM.IGRNO=IGRM.IGRNO');
$this->db->join ('T_IGR_Details IGRD','IGRM.IGRNO=IGRD.IGRNO and IGRD.MaterialCode = TMD.MaterialCode');
$this->db->join ('T_PurchaseOrder_Master POM','POM.PONO=IGRM.PONO');
$this->db->join ('T_PurchaseOrder_LineItem POL','POL.PONO=POM.PONO and TMD.MaterialCode = POL.MaterialCode');
$this->db->join('T_PurchaseOrder_AdvanceRequest PUADV','POM.PONO=PUADV.PONO','left');
$this->db->join ('tbl_users user','user.userid=TMD.UpdateBY','left');
$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left');
$this->db->join ('tbl_users user1','user1.userid = POM.ReleasedBy','left');
$this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left');
$this->db->join ('tbl_users user2','user2.userid=TMD.StoreInchargeID','left');
$this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID','left');
$this->db->join ('T_MaterialMaster MM','MM.MaterialCode = IGRD.MaterialCode and POL.MaterialCode = MM.MaterialCode');
$this->db->join ('T_Status ST','ST.StatusCode = TMD.MRIRStatus');
$this->db->where('TMM.MRIRStatus',MRIR_APPROVED);
$this->db->order_by('TMM.UpdatedOn','desc');
$query = $this->db->get();
//print_r($this->db->last_query());
return $query->result();
}
/* This function is used to get the MRIR value for edit*/
function edit_mrir($MrirNo)
{
$this->db->distinct();
$this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.Createdon as MRIRCreatedon,TMD.MRIRItemNo,TMD.ActualQuantityReceived,TMD.QuantityAccepted,TMD.QuantityRejected,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,IGRM.CreatedDate as IGRCreated,IGRD.QuantityAsPerInvoice,SUPP.SupplierName,SUPP.Address,POMR.PODate,POMR.DeliveryDate,POMR.ServiceDescription,TMD.MaterialCode,MM.MaterialName,MM.UOM,Line.Quantity,Line.ReceivedQuantity,ED.FirstName as PORasiedbyName,ED1.FirstName as MRIRRasiedbyName, ED2.FirstName as IGRRasiedbyName,TMM.MRIRStatus,Line.CostCenterCode,COST.CostCenterName,TMD.Remarks');
$this->db->from ('T_MRIR_Master TMM');
$this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO');//to get IGRNO,PONO,MRIRNO,mrirdate,
$this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO = TMM.IGRNO');//to get actualquantity,deliverydate,Invoicedate,vechileno,courierno,igrdate,
$this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO = POMR.PONO');//to get podate,deliverydate,servicedescription
// $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO');//to get receivedquantity,quantity
$this->db->join('T_PurchaseOrder_LineItem Line','TMM.PONO=Line.PONO and TMD.MaterialCode=Line.MaterialCode');
$this->db->join('T_CostCenter_Master COST','Line.CostCenterCode=COST.CostCenterCode','left');
//$this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO = IGRM.IGRNO');//to get invoicequantity
$this->db->join('T_IGR_Details IGRD','IGRD.IGRNO = TMM.IGRNO and TMD.MaterialCode=IGRD.MaterialCode');
$this->db->join ('T_MaterialMaster MM','TMD.MaterialCode = MM.MaterialCode');
$this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID = SUPP.SupplierID');//to get suppliername,supplieraddress
$this->db->join ('tbl_users user','user.userid = POMR.CreatedBy');//to get poraisedby
$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID');
$this->db->join ('tbl_users user1','user1.userid=TMM.CreatedBy');//to get mrirraisedby
$this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID');
$this->db->join ('tbl_users user2','user2.userid=IGRM.CreatedBy');//to get igrraisedby
$this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID');
$this->db->where('TMM.MRIRNO',$MrirNo);
$this->db->group_by('TMM.MRIRNO,TMD.MaterialCode');
$query = $this->db->get();
$result = $query->result();
//print_r( $this->db->last_query());
return $result;
}
/* This function is used to store the MRIR value in master table*/
function master_mrir($mrirmastervalues)
{
$this->db->insert('T_MRIR_Master', $mrirmastervalues);
$insert_id = $this->db->affected_rows();
if($insert_id>0)
{
$subQuery = 'select max(MRIRNO) as MRIRNo from T_MRIR_Master';
$query = $this->db->query($subQuery);
return $query->result();//_array();
}
}
/* This function is used to store the MRIR value in detail table*/
function detail_mrir($mrirdetailvalues)
{
$this->db->insert('T_MRIR_Details',$mrirdetailvalues);
$insert_id = $this->db->affected_rows();
return $insert_id;
}
/* This function is used to update the value in MRIR master table*/
function update_mrirmaster($updatemastervalues,$mrir_no)
{
$this->db->where('MRIRNO', $mrir_no);
$this->db->update('T_MRIR_Master', $updatemastervalues);
$affectedRows = $this->db->affected_rows();
return $affectedRows;
}
function UpdateReqStatus()
{
}
/* This function is used to update the value in MRIR detail table*/
function update_mrirdetail($updatedetailvalues,$Lineitm)
{
$this->db->where('MRIRItemNo',$Lineitm);
$this->db->update('T_MRIR_Details',$updatedetailvalues);
}
/* This function is used to get the value for modal in view MRIR page */
function get_MRIRs($mrir)
{
$this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMD.*,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRD.*,SUPP.SupplierName,SUPP.Address,POMR.DeliveryDate,POMR.ServiceDescription,MM.MaterialCode,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity,POMR.POType,ED.FirstName as StoreinchargeName');
$this->db->from ('T_MRIR_Master TMM');
$this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO');
$this->db->join ('T_MaterialMaster MM','TMD.MaterialCode = MM.MaterialCode');
$this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO=TMM.IGRNO');
$this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO');
$this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO and POLT.MaterialCode=TMD.MaterialCode');
$this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO= IGRM.IGRNO and IGRD.MaterialCode=TMD.MaterialCode');
$this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID');
$this->db->join ('tbl_users user','user.userid=TMD.StoreInchargeID','left');
$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left');
$this->db->where('TMD.MRIRNO',$mrir);
//$this->db->order_by('TMD.MRIRNO','asc');
// $this->db->from ('T_MRIR_Master TMM');
$query = $this->db->get();
//print_r($this->db->last_query());
$result=$query->result();
//print_r($result);
return $result;
function get_IGRdatas()
{
$this->db->select('IGRM.*,IGRD.*,SUPP.SupplierName,SUPP.Address,TMM.PONO,TMD.*,MM.MaterialCode,MM.UOM,MM.MaterialName,POLT.Quantity,POLT.ReceivedQuantity');
$this->db->from ('T_IGR_Master IGRM');
$this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO=POMR.PONO','left');
$this->db->join ('T_MRIR_Master TMM' ,'TMM.IGRNO=IGRM.IGRNO');
$this->db->join ('T_MRIR_Details TMD','TMD.MRIRNO=TMM.MRIRNO');
//$this->db->join ('T_MRIRNO');
$this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO= IGRM.IGRNO','left');
$this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left');
$this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID=SUPP.SupplierID','left');
$this->db->join ('T_MaterialMaster MM',' MM.MaterialCode=TMD.MaterialCode','left');
//$this->db->where('IGRM.IGRNO ');
$query = $this->db->get();
$result = $query->result();
//print_r($result);
return $result;
}
}
function UpdateIGRStatus($IGRDetails,$IGRNO)
{
$this->db->where('IGRNO', $IGRNO);
$this->db->update('T_IGR_Master', $IGRDetails);
return TRUE;
}
function getItemQuantityFromStock($MaterialCode)
{
// echo $MaterialCode;
// die();
$subQuery = 'select Quantity from T_Store_Stockdetails where MaterialCode=?';
$query = $this->db->query($subQuery,array($MaterialCode));
return $query->result_array();
}
function UpdateStock($StockDetails,$MaterialCode)
{
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_Store_Stockdetails', $StockDetails);
return TRUE;
}
function getMRIRBillingList()
{
}
function UpdatePOLineItem($LineItem,$PONO,$MaterialCode)
{
$subQuery = 'select * from T_PurchaseOrder_LineItem where Quantity = ReceivedQuantity and PONO=? and MaterialCode=? ';
$query = $this->db->query($subQuery,array($PONO,$MaterialCode));
$ApprovedCount = $query->num_rows;
$subQuery = 'select * from T_PurchaseOrder_LineItem where Quantity > ReceivedQuantity and ReceivedQuantity != 0 and PONO=? and MaterialCode=?';
$query = $this->db->query($subQuery,array($PONO,$MaterialCode));
$PartialApproved = $query->num_rows;
// echo 'Partialcount'.$PartialApproved;
if($ApprovedCount > 0)
{
$this->db->where('PONO', $PONO);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_PurchaseOrder_LineItem', $LineItem);
return TRUE;
}
elseif($PartialApproved > 0)
{
$updateby=$this->session->userdata('userId');
$date = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
$updateon = $date->format('Y-m-d H:i:s');
$POLineItem = array('Status'=>PARTIAL_MRIRAPPROVED,'UpdateBY'=>$updateby,'UpdatedOn'=>$updateon );
$this->db->where('PONO', $PONO);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_PurchaseOrder_LineItem', $POLineItem);
return TRUE;
}
}
function UpdatePOMaster($PONO,$PoMrirStatus,$updatedBy)
{
$this->db->select('*');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$PONO);
$this->db->where('Status !=',MRIR_APPROVED);
$query = $this->db->get();
$ApprovedCnt = $query->num_rows;
$this->db->select('*');
$this->db->from('T_PurchaseOrder_LineItem');
$this->db->where('PONO',$PONO);
$this->db->where('Status !=',MRIR_REJECTED);
$query1 = $this->db->get();
$RejectedCnt = $query1->num_rows;
if ($ApprovedCnt == 0) {
$this->db->where('PONO', $PONO);
$POStatus = array('status'=>MRIR_APPROVED,'UpdateBY'=>$updatedBy);
$this->db->update('T_PurchaseOrder_Master', $POStatus);
}
elseif ($RejectedCnt == 0) {
$this->db->where('PONO', $PONO);
$POStatus = array('status'=>MRIR_REJECTED,'UpdateBY'=>$updatedBy);
$this->db->update('T_PurchaseOrder_Master', $POStatus);
}
}
}
?>

View File

@ -1,454 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Payroll_model extends CI_Model
{
/**
* This function is used to insert the File details in database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number $Payon : Insert row count will be the return value
*/
function UploadFileName($FileDetails)
{
$this->db->insert('T_Payroll_File', $FileDetails);
$Payon = $this->db->affected_rows();
return $Payon;
}
function model_sp($payon,$employee){
//echo "<script>alert('mod');</script>";
//echo "highlight_file(filename)";
//die();
$result=$this->db->query("call P_FINAL_PAYROLL_DATA('".$payon."','".$employee."')") or die(mysql_error());
//$result->next_result();
return $result;
}
/**
* This function is used to update the File details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function UpdateFileName($FileDetails, $PayOn)
{
//echo $EmpID;
$this->db->where('PayOn', $PayOn);
$this->db->update('T_Payroll_File', $FileDetails);
//print_r($this->db->last_query());
return TRUE;
}
/**
* This function is used to check the File details is already exists in the database or not
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function checkFileDetailsExists($PayOn)
{
$this->db->select('PayOn');
$this->db->from('T_Payroll_File');
$this->db->where('PayOn',$PayOn);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
return $query->result();
}
}
function checkExistPayData($empid,$payon)
{
$this->db->select('PayOn,EmpID');
$this->db->from('T_Payroll');
$this->db->where('PayOn',$payon);
$this->db->where('EmpID',$empid);
$query = $this->db->get();
return $query->result();
}
function checkFileDetailsExists2($PayOn,$EmpId)
{
//echo $EmpId;
//die();
$this->db->select('Month_Year','EmpID');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->where('EmpID',$EmpId);
$this->db->where('Month_Year',$PayOn);
$query = $this->db->get();
// print_r($this->db->last_query());
if ($query->num_rows > 0) {
//echo "success";
//return $query->result();
return TRUE;
}
else{
//echo "fail";
return FALSE;
}
}
/**
* This function is used to insert the File data in database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number $Payon : Insert row count will be the return value
*/
function UploadFileData($FileData)
{
$this->db->insert('T_Payroll', $FileData);
$Payon = $this->db->affected_rows();
//print_r($this->db->last_query());
return $Payon;
}
function UploadFileData2($FileData)
{
$this->db->insert('T_Monthly_Pay_Inputs', $FileData);
$Payon = $this->db->affected_rows();
//print_r($this->db->last_query());
return $Payon;
}
/**
* This function is used to update the File details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function UpdateFiledata($FileData, $PayOn,$EmpId)
{
//echo $EmpID;
$this->db->where('PayOn', $PayOn);
$this->db->where('EmpID', $EmpId);
$this->db->update('T_Payroll', $FileData);
//print_r($this->db->last_query());
//print_r($this->db->last_query());
return TRUE;
}
/**
* This function is used to get the data details in which is already exists in the database
* @FileDetails array : This will have the set of value which we need to insert into database
* @return number boolean: success of the updation
*/
function GetPayslipdata($PayOn='',$EmpId='')
{
//echo "FROM MODEL" . $PayOn . $EmpId;
$this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.DateofBirth as Dob,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.AadharNo,Emp.IFSCCode as IFSCCode,Emp.DateofJoining as DOJ,Emp.Designation as Designation,Dep.DepartmentName as DeptName');
$this->db->from('T_Payroll Pay');
//$this->db->join('T_Payroll_File payfile', 'Pay.PayOn = payfile.PayOn');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode');
if($PayOn != '')
{
$this->db->where('Pay.PayOn', $PayOn);
}
if($EmpId != '')
{
$this->db->where('Pay.EmpID', $EmpId);
}
if($PayOn != '')
{
$this->db->order_by("Pay.EmpID", "asc");
}
if($PayOn == '' && $EmpId == '')
{
$this->db->order_by("Pay.PayOn", "desc");
}
$query = $this->db->get();
return $query->result();
//print_r($query->result());die();
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_File
* @return array $result : This is result of the query
*/
function getPayOn()
{
$this->db->select('DISTINCT(Month_Year)');
$this->db->from('T_Monthly_Pay_Inputs');
$this->db->order_by("Month_Year", "desc");
$query = $this->db->get();
return $query->result();
}
function getBankInfo($bank="")
{
$this->db->select('*');
$this->db->from('T_Bank_Details');
$this->db->where("Is_Active",1);
if(!empty($bank))
{
$this->db->where('Bank_name',$bank);
}
$query = $this->db->get();
return $query->result();
}
function getReportforBank($bank,$payon)
{
$this->db->distinct();
$this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.IFSCCode as IFSC,Bank.Address as BAddress');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_Bank_Details Bank', 'Emp.BankBranchName = Bank.Bank_name');
$this->db->order_by("Pay.EmpID", "asc");
$this->db->where('Emp.BankBranchName',$bank);
$this->db->where('Pay.PayOn',$payon);
$this->db->where('Pay.TotalSalary > 0');
$query = $this->db->get();
return $query->result();
}
function getReportforPFESI($payon)
{
$this->db->distinct();
$this->db->select('Pay.EmployeeESI,Pay.PF,Pay.CompanyESI,Pay.CompanyPF,Pay.NoofDaysWorked,Pay.OTperHours,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PFNO,Emp.ESI');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->where('Pay.PayOn',$payon);
// $this->db->where('Pay.EmployeeESI > 0 ');
// $this->db->where('Pay.CompanyESI > 0');
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query->result();
}
function getLoanReport($source='',$year1="",$year2="")
{
// echo "<br>---------------------------";
// echo "<br>From Model-";
// echo $source.'-'.$year1.'-'.$year2;
$this->db->distinct();
$this->db->select('Pay.EmpID,Emp.FirstName as FName ,Emp.LastName as Lname,sum(loan.Loan_Amount) as Loan_Amount,sum(loan.Paid_Amount) as Paid_Amount');
$this->db->from('T_Emp_Pay_Data Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID');
if($source != 'company'){
$this->db->where('Pay.EmpID',$source);
}
if($year1 != "" and $year2 != ""){
$this->db->where('month(loan.Loan_Issued_Date)>=',4);
$this->db->where('year(loan.Loan_Issued_Date)=',$year1);
$this->db->or_where('month(loan.Loan_Issued_Date)<=',3);
$this->db->where('year(loan.Loan_Issued_Date)=',$year2);
}
$this->db->group_by('Pay.EmpID');
$this->db->order_by('Pay.EmpID','asc');
$query = $this->db->get();
return $query->result();
//print_r($query->result());die();
}
function getEmpDetailsforLoan()
{
$this->db->select('Pay.EmpID,Pay.FirstName as FName ,Pay.LastName as Lname');
$this->db->from('T_Employee_Details Pay');
$this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID');
$this->db->order_by('Pay.EmpID','asc');
$query = $this->db->get();
return $query->result();
}
function getLoanReportforEmp($eid='',$year1="",$year2="",$string="")
{
//$this->db->distinct();
if($string == 'emp'){
$this->db->select('Pay.EmpID,Emp.FirstName as FName ,Emp.LastName as Lname,loan.*');
$this->db->from('T_Emp_Pay_Data Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
$this->db->join('T_Loan_Master loan', 'Pay.EmpID = loan.EmpID','left');
// if($source != 'company'){
$this->db->where('Pay.EmpID',$eid);
//}
if($year1 != "" and $year2 != ""){
$this->db->where('month(loan.Loan_Issued_Date)>=',4);
$this->db->where('year(loan.Loan_Issued_Date)=',$year1);
$this->db->or_where('month(loan.Loan_Issued_Date)<=',3);
$this->db->where('year(loan.Loan_Issued_Date)=',$year2);
//$this->db->group_by('Pay.EmpID');
}
$this->db->order_by('loan.Loan_Issued_Date','asc');
$query = $this->db->get();
return $query->result();
}
elseif($string == 'history')
{
$this->db->select('T_Loan_Master.EmpID,Emp.FirstName,Emp.LastName,T_Loan_Master.Loan_Amount,T_Loan_Master.Loan_Issued_Date,T_Loan_History.*');
$this->db->from('T_Loan_History');
$this->db->join('T_Loan_Master','T_Loan_Master.Loan_ID=T_Loan_History.Loan_ID');
$this->db->join('T_Employee_Details Emp', 'T_Loan_Master.EmpID = Emp.EmpID');
$this->db->where('T_Loan_History.Loan_ID',$eid);
$q = $this->db->get();
// $this->db->order_by('Entry_Date','asc');
// $this->db->where('Loan_ID',$eid);
// $q = $this->db->get('T_Loan_History');
//print_r($q->result());
return $q->result();
// print_r($q->result());
// die();
}
//print_r($query->result());die();
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_FileOTperHours
* @return array $result : This is result of the query
*/
function getEmployeelist($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.PayOn', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query;
}
function getEmployeelist2($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Monthly_Pay_Inputs Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.Month_Year', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query;
}
/* *//**
* This function is used to get the PayOn details from T_Payroll_File
* @return array $result : This is result of the query
*/
function getEmpAll($Payon ='')
{
$this->db->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname');
$this->db->from('T_Payroll Pay');
$this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID');
if($Payon != '')
{
$this->db->where('Pay.PayOn', $Payon);
}
$this->db->order_by("Pay.EmpID", "asc");
$query = $this->db->get();
return $query->result_array();
}
/* *//**
* This function is used to delete the PayOn details from T_Payroll
* @return array $result : This is result of the query
*/
function deleteFileData($PayOn='')
{
$this->db->where("PayOn", $PayOn);
$this->db->delete('T_Payroll');
}
function getEmpID($q='')
{
$this->db->select('EmpID,FirstName,LastName');
$this->db->from('T_Employee_Details');
if($q == "addemppaydate"){
$this->db->where('EmpID NOT IN (SELECT EmpID from T_Emp_Pay_Data)',NULL,FALSE);
}
$query = $this->db->get();
return $query->result();
}
function getEmpIDfromPayData()
{
$this->db->select('EmpID');
$this->db->from('T_Emp_Pay_Data');
$query = $this->db->get();
return $query->result();
}
function updateEmpPayslip($data)
{
$key = $data['Key'];
$PayOn = $data['PayOn'];
$EmpID = $data['EmpID'];
$this->db->where('Key', $key);
$this->db->where('PayOn',$PayOn);
$this->db->where('EmpID',$EmpID);
$result = $this->db->update('T_Payroll',$data);
return $result;
}
function getCompanyInformation()
{
$subQuery = "select CompanyName,Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode
from T_Company_Details ";
$query = $this->db->query($subQuery);
//print_r($query->result());die();
return $query->result();
}
function ChequeDetails($cheque){
$this->db->insert('T_ChequeDetails', $cheque);
}
function getChequeInfo($bank,$payon)
{
$sql = "SELECT Cheque.*
FROM T_ChequeDetails Cheque
WHERE Cheque.BankName = ?
AND Cheque.MonthYear = ? ";
$query = $this->db->query($sql,array($bank,$payon));
//$query_count = $query->num_rows();
//return $query_count;
return $query->result();
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,589 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Quality_model extends CI_Model
{
function getAllInvoiceNo()
{
$this->db->select('invoice_number');
$this->db->from('ip_invoices');
$result = $this->db->get();
return $result->result();
}
function getAllprodcuts()
{
$this->db->select('product_id,product_name,product_description');
$this->db->from('ip_products');
$result = $this->db->get();
return $result->result();
}
function getAllprodcutsInward()
{
$this->db->select('MaterialCode,MaterialName');
$this->db->from('T_MaterialMaster');
$this->db->like('T_MaterialMaster.Category','raw material');
$result = $this->db->get();
return $result->result();
}
function getAllcustomers()
{
$this->db->select('client_id,client_name');
$this->db->from('ip_clients');
$result = $this->db->get();
return $result->result();
}
function getAllcustomersInward()
{
$this->db->select('SupplierID,SupplierName');
$this->db->from('T_SupplierDetailsN');
$this->db->where('IsActive',1);
$result = $this->db->get();
return $result->result();
}
function checkExist($product,$customer,$name,$type)
{
$this->db->select('count(*) as count');
$this->db->from('T_Prodcut_Specification_Master');
$this->db->where('product_id',$product);
$this->db->where('customer_id',$customer);
$this->db->where('testtype',$name);
$this->db->where('type',$type);
$result = $this->db->get();
return $result->result();
}
function addSpecMast($data)
{
//print_r($data);
$this->db->insert('T_Prodcut_Specification_Master',$data);
$r = $this->db->affected_rows();
return $r;
}
function updateSpecMast($data,$product,$customer,$name,$type)
{
//echo $product.$customer.$name;
//print_r($data);
$this->db->where('product_id',$product);
$this->db->where('customer_id',$customer);
$this->db->where('testtype',$name);
$this->db->where('type',$type);
$this->db->update('T_Prodcut_Specification_Master',$data);
$r = $this->db->affected_rows();
//echo $r;die();
return $r;
}
function getAllspec()
{
$this->db->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,count(*) as count');
$this->db->from('T_Prodcut_Specification_Master');
$this->db->join('ip_products','T_Prodcut_Specification_Master.product_id=ip_products.product_id');
$this->db->join('ip_clients','T_Prodcut_Specification_Master.customer_id=ip_clients.client_id');
$this->db->group_by('product_id,customer_id,T_Prodcut_Specification_Master.type');
$result = $this->db->get();
return $result->result();
}
function getAllspecInward()
{
$this->db->select('T_Prodcut_Specification_Master.*,T_MaterialMaster.MaterialCode,T_MaterialMaster.MaterialName,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName,count(*) as count');
$this->db->from('T_Prodcut_Specification_Master');
$this->db->join('T_MaterialMaster','T_Prodcut_Specification_Master.product_id=T_MaterialMaster.MaterialCode');
$this->db->join('T_SupplierDetailsN','T_Prodcut_Specification_Master.customer_id=T_SupplierDetailsN.SupplierID');
$this->db->group_by('product_id,customer_id,T_Prodcut_Specification_Master.type');
$result = $this->db->get();
return $result->result();
}
function getIndividualSpec($prodcutid,$customerid,$type)
{
$this->db->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name');
$this->db->from('T_Prodcut_Specification_Master');
$this->db->join('ip_products','T_Prodcut_Specification_Master.product_id=ip_products.product_id');
$this->db->join('ip_clients','T_Prodcut_Specification_Master.customer_id=ip_clients.client_id');
$this->db->where('T_Prodcut_Specification_Master.product_id',$prodcutid);
$this->db->where('T_Prodcut_Specification_Master.customer_id',$customerid);
$this->db->where('T_Prodcut_Specification_Master.type',$type);
$result = $this->db->get();
//print_r($result->result());
if(empty($result->result()))
{
$this->db->select('T_Prodcut_Specification_Master.*,T_MaterialMaster.MaterialCode,T_MaterialMaster.MaterialName as product_name,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName as client_name');
$this->db->from('T_Prodcut_Specification_Master');
$this->db->join('T_MaterialMaster','T_Prodcut_Specification_Master.product_id=T_MaterialMaster.MaterialCode');
$this->db->join('T_SupplierDetailsN','T_Prodcut_Specification_Master.customer_id=T_SupplierDetailsN.SupplierID');
$this->db->where('T_Prodcut_Specification_Master.product_id',$prodcutid);
$this->db->where('T_Prodcut_Specification_Master.customer_id',$customerid);
$this->db->where('T_Prodcut_Specification_Master.type',$type);
$result = $this->db->get();
}
//exit();
return $result->result();
}
function deleteSpecification($spname,$product,$customer,$type)
{
$this->db->where("testtype", $spname);
$this->db->where("product_id", $product);
$this->db->where("customer_id", $customer);
$this->db->where("type", $type);
$this->db->delete('T_Prodcut_Specification_Master');
$r = $this->db->affected_rows();
return $r;
}
function getDataforReport()
{
$this->db->select('ip_invoices.invoice_number,ip_invoices.client_id,ip_invoice_custom.invoice_custom_fieldvalue,ip_clients.client_name,ip_invoices.invoice_date_created,ip_invoice_items.item_product_id,ip_products.product_name,ip_products.product_description,ip_invoice_items.item_quantity');
$this->db->from('ip_invoices');
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
$this->db->join('ip_invoice_custom','ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62');
$this->db->where('ip_invoices.invoice_number NOT IN (SELECT invoiceid from T_Test_Report_Master where invoiceid is not null)',NULL,false);
$this->db->order_by('ip_invoices.invoice_number','desc');
$res = $this->db->get();
//print_r($res->result());die();
return $res->result();
}
function getSpecifications($productid,$customerid,$ttype="")
{
//echo 'from model'.$productid.'-'.$customerid;
// $this->db->where('product_id',$productid);
// $this->db->where('customer_id',$customerid);
// $res = $this->db->get('T_Prodcut_Specification_Master');
$sql ='';
$res = "";
if(!empty($ttype))
{
$sql = "Select * from T_Prodcut_Specification_Master where product_id = ? and customer_id = ? and type = ?";
$res = $this->db->query($sql,array($productid,$customerid,$ttype));
}
else
{
$sql = "Select * from T_Prodcut_Specification_Master where product_id = ? and customer_id = ?";
$res = $this->db->query($sql,array($productid,$customerid));
}
// print_r($this->db->last_query());
return $res->result();
//print_r($res->result());
}
function getOperatorsListforReport()
{
$r = $this->db->select('EmpID,FirstName,LastName')->from('T_Employee_Details')->get();
return $r->result();
}
function getExistOperatorsListforReport($rbcid)
{
$sql = "select T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName
from T_ResinBatchCard_Operators join T_Employee_Details on T_ResinBatchCard_Operators.EmpID =
T_Employee_Details.EmpID where T_ResinBatchCard_Operators.master_id = ?";
$r = $this->db->query($sql,array($rbcid));
return $r->result();
}
function getEmplistforReport()
{
$this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.Departmentcode,T_DepartmentDetails.shortName,');
$this->db->from('T_Employee_Details');
$this->db->join('T_DepartmentDetails','T_Employee_Details.Departmentcode=T_DepartmentDetails.DEPCode');
//$this->db->join('ip_invoice_items','ip_invoices.invoice_number=ip_invoice_items.invoice_number');
//$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
//$this->db->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
$this->db->order_by('T_Employee_Details.EmpID');
$res = $this->db->get();
return $res->result();
}
function saveMasterTestData($masterreportdata)
{
$this->db->insert('T_Test_Report_Master',$masterreportdata);
$id = $this->db->insert_id();
return $id;
}
function saveResinBatchCardMasterTestData($masterreportdata)
{
$this->db->insert('T_ResinBatchCard_Master',$masterreportdata);
$id = $this->db->insert_id();
return $id;
}
function updateResinBatchCardChildTestData($newArray)
{
$this->db->select('resinbatchcard_iter_id');
$this->db->from('T_ResinBatchCard_Child');
$this->db->where('master_report_id',$newArray['master_report_id']);
$this->db->where('i_time',$newArray['i_time']);
$this->db->where('spec_id',$newArray['spec_id']);
$res = $this->db->get();
$res = $res->result();
if(!empty($res[0]->resinbatchcard_iter_id))
{
$this->db->where('master_report_id',$newArray['master_report_id']);
$this->db->where('i_time',$newArray['i_time']);
$this->db->where('spec_id',$newArray['spec_id']);
$this->db->update('T_ResinBatchCard_Child',$newArray);
}
else
{
$this->saveResinBatchCardChildTestData($newArray);
}
}
function saveResinBatchCardChildTestData($newArray)
{
$this->db->insert('T_ResinBatchCard_Child',$newArray);
}
function updateResinBatchCardMasterTestData($masterreportdata,$MASTERID)
{
$this->db->where('resinbatch_id',$MASTERID);
$this->db->update('T_ResinBatchCard_Master',$masterreportdata);
}
function getResinBatchCardDetails($rbcid)
{
$sql = 'select T_ResinBatchCard_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,T_Machine_Master.Machine_Name,T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,a.FirstName as name from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid = ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid = ip_clients.client_id
join T_Machine_Master on T_ResinBatchCard_Master.machinecode = T_Machine_Master.Machine_Code
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join T_Employee_Details on tbl_users.EmpID = T_Employee_Details.EmpID
join T_Employee_Details as a on a.EmpID = T_ResinBatchCard_Master.operatedby
where T_ResinBatchCard_Master.resinbatch_id = ?';
$res['masterdata'] = $this->db->query($sql,array($rbcid))->result();
//print_r($res['masterdata']);
$sql = 'select T_ResinBatchCard_Child.*,T_Prodcut_Specification_Master.testtype from T_ResinBatchCard_Child
join T_Prodcut_Specification_Master on T_ResinBatchCard_Child.spec_id = T_Prodcut_Specification_Master.productspecmaster_id
where master_report_id = ?;';
$res['childdata'] = $this->db->query($sql,array($rbcid))->result();
$sid = '';
//print_r($res['childdata']);
$index = 0;
$newArray = array();
$allspecs = array('TEST');
foreach($res['childdata'] as $c)
{
if($sid != $c->i_time)
{
$index++;
$newArray[$index] = array($c->i_time,$c->spec_value);
if($index == 1){
array_push($allspecs,strtolower($c->testtype));
}
}
else
{
array_push($newArray[$index],$c->spec_value);
if($index == 1){
array_push($allspecs,strtolower($c->testtype));
}
}
$sid = $c->i_time;
}
$res['childdata'] = $newArray;
//print_r($res['childdata']);
$res['allspec'] = $allspecs;
return $res;
}
function getResinBatchCardTestMasterList()
{
$sql = 'Select resinbatch_id,productid,ip_products.product_name,ip_products.product_description,customerid,client_name,batchdate,igrno,igrlineno,operatedby,T_ResinBatchCard_Master.createdby,approvedby,document,ED.FirstName from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid=ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid=ip_clients.client_id
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join T_Employee_Details ED on ED.EmpID = T_ResinBatchCard_Master.operatedby
join T_Employee_Details EmpDtl on EmpDtl.EmpID = tbl_users.EmpID';
$res = $this->db->query($sql);
return $res->result();
}
function saveTestReportData($testreportdata)
{
$this->db->insert('T_Test_Report',$testreportdata);
$row = $this->db->affected_rows();
return $row;
}
function saveTestReportAFSData($afstabledata)
{
$this->db->insert('T_Test_Report_AFS',$afstabledata);
$row = $this->db->affected_rows();
return $row;
}
function saveTestReportLOIData($loitabledata)
{
$this->db->insert('T_Test_Report_LOI',$loitabledata);
$row = $this->db->affected_rows();
return $row;
}
function getIndividualReportData($reportid)
{
$this->db->select('T_Test_Report_Master.testreport_id,ip_invoices.invoice_date_created,T_Test_Report_Master.invoiceid,T_Test_Report_Master.batchdate,T_Test_Report_Master.chartdata,ip_clients.client_id,ip_clients.client_name,invoice_custom_fieldvalue,ip_products.product_id,ip_products.product_name,ip_products.product_description,T_Employee_Details.FirstName,T_Employee_Details.LastName,ip_invoice_items.item_quantity,T_Test_Report_Master.approvedby');
$this->db->from('T_Test_Report_Master');
$this->db->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
$this->db->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
$this->db->join('ip_invoice_custom','ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62');
$this->db->join('tbl_users','T_Test_Report_Master.createdby=tbl_users.userid');
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
//$this->db->join('T_Employee_Details','T_Test_Report_Master.EmpID=T_Employee_Details.EmpID');
//$this->db->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
$this->db->where('testreport_id',$reportid);
// $this->db->join('T_Test_Report','T_Test_Report_Master.testreport_id=T_Test_Report.testreport_id');
// $this->db->join('T_Test_Report_loi','T_Test_Report_Master.testreport_id=T_Test_Report_loi.testreport_id');
// $this->db->join('T_Test_Report_afs','T_Test_Report_Master.testreport_id=T_Test_Report_afs.testreport_id');
$res = $this->db->get();
$reportdata['master'] = $res->result();
$this->db->select('T_Test_Report.*');
$this->db->from('T_Test_Report');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreport'] = $res1->result();
$this->db->select('T_Test_Report_LOI.*');
$this->db->from('T_Test_Report_LOI');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreportloi'] = $res1->result();
$this->db->select('T_Test_Report_AFS.*');
$this->db->from('T_Test_Report_AFS');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreportafs'] = $res1->result();
$this->db->select('T_Company_Details.CompanyName,T_Company_Details.Address,T_Company_Details.ProfilePic');
$this->db->from('T_Company_Details');
//$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['company'] = $res1->result();
return $reportdata;
}
function getIndividualInwardReportData($reportid)
{
$this->db->select('T_Test_Report_Master.chartdata,T_Test_Report_Master.batchdate,T_Test_Report_Master.testreport_id,T_IGR_Master.IGRNO,T_IGR_Master.DeliveryChellanOrInvoiceNo,T_IGR_Master.DeliveryChellanDate,T_IGR_Details.IGRItemNo,T_IGR_Details.QuantityAsPerInvoice,T_MaterialMaster.MaterialCode,T_MaterialMaster.Materialname,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName,T_Test_Report_Master.approvedby,T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName');
$this->db->from('T_Test_Report_Master');
$this->db->join('T_IGR_Master','T_Test_Report_Master.igrno=T_IGR_Master.IGRNO');
$this->db->join('T_IGR_Details','T_Test_Report_Master.igrlineitemno=T_IGR_Details.IGRItemNo');
$this->db->join('T_PurchaseOrder_Master','T_IGR_Master.PONO=T_PurchaseOrder_Master.PONO');
$this->db->join('T_MaterialMaster','T_IGR_Details.MaterialCode=T_MaterialMaster.MaterialCode');
$this->db->join('T_SupplierDetailsN','T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID');
$this->db->join('tbl_users','T_Test_Report_Master.createdby=tbl_users.userid');
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
$this->db->where('T_Test_Report_Master.testreport_id',$reportid);
$res = $this->db->get();
$reportdata['master'] = $res->result();
$this->db->select('T_Test_Report.*');
$this->db->from('T_Test_Report');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreport'] = $res1->result();
$this->db->select('T_Test_Report_LOI.*');
$this->db->from('T_Test_Report_LOI');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreportloi'] = $res1->result();
$this->db->select('T_Test_Report_AFS.*');
$this->db->from('T_Test_Report_AFS');
$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['masterreportafs'] = $res1->result();
$this->db->select('T_Company_Details.CompanyName,T_Company_Details.Address,T_Company_Details.ProfilePic');
$this->db->from('T_Company_Details');
//$this->db->where('testreport_id',$reportid);
$res1 = $this->db->get();
$reportdata['company'] = $res1->result();
return $reportdata;
}
function getTestMasterforList()
{
$this->db->select('T_Test_Report_Master.testreport_id,T_Test_Report_Master.invoiceid,T_Test_Report_Master.batchdate,T_Test_Report_Master.document,ip_clients.client_id,ip_clients.client_name,ip_products.product_id,ip_products.product_name,ip_products.product_description');
$this->db->from('T_Test_Report_Master');
$this->db->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
$this->db->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
//$this->db->where('T_Test_Report_Master.invoiceid','!=0');
$res = $this->db->get();
return $res->result();
}
function getTestMasterforListInward()
{
// $this->db->select('T_Test_Report_Master.testreport_id,T_Test_Report_Master.igrno,T_Test_Report_Master.igrlineitemno,T_Test_Report_Master.batchdate,ip_clients.client_id,ip_clients.client_name,ip_products.product_id,ip_products.product_name,ip_products.product_description');
// $this->db->from('T_Test_Report_Master');
// $this->db->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
// $this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
// $this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
// $this->db->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
// $res = $this->db->get();
// return $res->result();
$this->db->select('T_Test_Report_Master.batchdate,T_Test_Report_Master.testreport_id,T_IGR_Master.IGRNO,T_IGR_Master.DeliveryChellanOrInvoiceNo,T_IGR_Master.DeliveryChellanDate,T_IGR_Details.IGRItemNo,T_IGR_Details.QuantityAsPerInvoice,T_MaterialMaster.MaterialCode,T_MaterialMaster.Materialname,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName,T_Test_Report_Master.approvedby,T_Test_Report_Master.document,T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName');
$this->db->from('T_Test_Report_Master');
$this->db->join('T_IGR_Master','T_Test_Report_Master.igrno=T_IGR_Master.IGRNO');
$this->db->join('T_IGR_Details','T_Test_Report_Master.igrlineitemno=T_IGR_Details.IGRItemNo');
$this->db->join('T_PurchaseOrder_Master','T_IGR_Master.PONO=T_PurchaseOrder_Master.PONO');
$this->db->join('T_MaterialMaster','T_IGR_Details.MaterialCode=T_MaterialMaster.MaterialCode');
$this->db->join('T_SupplierDetailsN','T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID');
$this->db->join('tbl_users','T_Test_Report_Master.createdby=tbl_users.userid');
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
$this->db->order_by('testreport_id','desc');
$res = $this->db->get();
return $res->result();
}
function getIGRNOforReport()
{
// $this->db->distinct();
// $this->db->select('IGRNO');
// $this->db->from('T_IGR_Details');
// $this->db->join('T_MaterialMaster','T_IGR_Details.MaterialCode=T_MaterialMaster.MaterialCode');
// $this->db->like('T_MaterialMaster.Category','raw material');
$sql = 'select distinct IGRNO from T_IGR_Details
join T_MaterialMaster on T_IGR_Details.MaterialCode = T_MaterialMaster.MaterialCode
where T_MaterialMaster.Category like "%Raw Material%"and date(T_IGR_Details.CreatedDate)
between date(SUBDATE(CURRENT_DATE,1)) and date(CURRENT_DATE)
order by IGRNO desc';
$result = $this->db->query($sql);
return $result->result();
}
function getIGRLineItemNo($igrno)
{
// $this->db->select('IGRItemNo');
// $this->db->from('T_IGR_Details');
// $this->db->where('IGRNO',$igrno);
$sql = 'select IGRItemNo from T_IGR_Details
join T_MaterialMaster on T_IGR_Details.MaterialCode = T_MaterialMaster.MaterialCode
where IGRNO = ? and T_MaterialMaster.Category like "%Raw Material%"';
$result = $this->db->query($sql,array($igrno));
return $result->result();
}
function getIGRNOReport()
{
$this->db->select('igrno,igrlineitemno');
$this->db->from('T_Test_Report_Master');
$res['generated'] = ($this->db->get()->result());
// $this->db->select('IGRNO,IGRItemNo');
// $this->db->from('T_IGR_Details');
// $this->db->where('IGRNO NOT IN (SELECT IGRNO from T_Test_Report_Master)',NULL,false);
// $this->db->or_where('IGRItemNo NOT IN (SELECT IGRItemNo from T_Test_Report_Master)',NULL,false);
$sql= 'select distinct IGRNO,IGRItemNo from T_IGR_Details join T_MaterialMaster on T_IGR_Details.MaterialCode = T_MaterialMaster.MaterialCode
where (T_IGR_Details.IGRNO not in (select igrno from T_Test_Report_Master where igrno != "")
or T_IGR_Details.IGRItemNo not in (select igrlineitemno from T_Test_Report_Master where igrno != "") )
and T_MaterialMaster.Category like "%Raw Material%"
order by T_IGR_Details.IGRNO DESC';
$r = $this->db->query($sql);
$res['notgenerated'] = ($r->result());
return $res;
}
function getIGRDataforReport($igrno,$igrlineitemno)
{
//echo $igrno.'-'.$igrlineitemno;die();
// $this->db->select('T_IGR_Master.DeliveryChellanOrInvoiceNo,T_IGR_Master.DeliveryChellanDate,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName,T_MaterialMaster.MaterialCode,T_MaterialMaster.MaterialName,T_IGR_Details.QuantityAsPerInvoice');
// $this->db->from('T_IGR_Master');
// $this->db->join('T_IGR_Details','T_IGR_Master.IGRNO=T_IGR_Details.IGRNO');
// $this->db->join('T_MaterialMaster','T_IGR_Details.MaterialCode=T_MaterialMaster.MaterialCode');
// $this->db->join('T_PurchaseOrder_Master','T_IGR_Master.PONO=T_PurchaseOrder_Master.PONO');
// $this->db->join('T_SupplierDetailsN','T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID');
// $this->db->where('T_IGR_Details.IGRNO',$igrno);
// $this->db->where('T_IGR_Details.IGRItemNo',$igrlineitemno);
// $this->db->order_by('T_IGR_Master.IGRNO');
// $res = $this->db->get();
// return $res->result();
$sql = 'select T_IGR_Master.DeliveryChellanOrInvoiceNo, date_format(T_IGR_Master.DeliveryChellanDate,"%d-%m-%Y") as DeliveryChellanDate,T_SupplierDetailsN.SupplierID,T_SupplierDetailsN.SupplierName,T_MaterialMaster.MaterialCode,
T_MaterialMaster.MaterialName,T_IGR_Details.QuantityAsPerInvoice
from T_IGR_Master
join T_IGR_Details on T_IGR_Master.IGRNO=T_IGR_Details.IGRNO
join T_MaterialMaster on T_IGR_Details.MaterialCode=T_MaterialMaster.MaterialCode
join T_PurchaseOrder_Master on T_IGR_Master.PONO=T_PurchaseOrder_Master.PONO
join T_SupplierDetailsN on T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID
where T_IGR_Master.IGRNO = ? and T_IGR_Details.IGRItemNo = ?';
$res = $this->db->query($sql,array($igrno,$igrlineitemno));
return $res->result();
}
function getIGRNos()
{
$sql = 'select IGRNO from T_IGR_Master order by IGRNO desc';
$res = $this->db->query($sql);
return $res->result();
}
function getMachineList()
{
$sql = 'select Machine_Code,Machine_Name from T_Machine_Master';
$res = $this->db->query($sql);
return $res->result();
}
function getTRPBatchcardNos()
{
$sql = 'select dailyid from T_daily_batchcard_data';
$res = $this->db->query($sql);
return $res->result();
}
function getIGRItemNos()
{
$sql = 'select IGRItemNo from T_IGR_Details order by IGRItemNo desc';
$res = $this->db->query($sql);
return $res->result();
}
}
?>

View File

@ -1,350 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class rawmaterialdetails_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function rawmaterialListing()
{
$this->db->select('*');
$this->db->from('T_MaterialMaster');
$this->db->where('IsActive',1 );
$query = $this->db->get();
$result = $query->result();
return $result;
}
function getUOM($UOM = '')
{
$ConfigID = 'C001';
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if($UOM != '')
{
$this->db->where('ConfigValue !=',$UOM );
}
$query = $this->db->get();
return $query->result();
}
function getmaterialType($MaterialType = '')
{
$Config_ID = 'C003';
$this->db->select('Config_ID,ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id',$Config_ID );
if($MaterialType != '')
{
$this->db->where('ConfigValue !=',$MaterialType );
}
$query = $this->db->get();
return $query->result();
}
//This function used to get the material category using configdetails table
function getmaterialCategory($MaterialCategory = '')
{
$Config_ID = 'C023';
$this->db->select('Config_ID,ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id',$Config_ID );
if($MaterialCategory != '')
{
$this->db->where('ConfigValue !=',$MaterialCategory );
}
$query = $this->db->get();
return $query->result();
}
//This function used to get the conversionfactor using configdetails table
function getConversionfactorUOM($ConversionFactorUOM ='')
{
$Config_ID = 'C024';
$this->db->select('Config_ID,ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id',$Config_ID );
if($ConversionFactorUOM != '')
{
$this->db->where('ConfigValue !=',$ConversionFactorUOM );
}
$query = $this->db->get();
return $query->result();
}
//AssetCode
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function addNewRawMaterial($RawMaterial='')
{
$this->db->insert('T_MaterialMaster', $RawMaterial);
return TRUE;
}
function insertvalueintoconfig($config){
$this->db->insert('T_ConfigDetails', $config);
return TRUE;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getMaterialDetails($MaterialCode)
{
$sql=" SELECT * FROM T_MaterialMaster WHERE MaterialCode ='$MaterialCode'";
$query = $this->db->query( $sql);
return $query->result();
}
function getMaterialstock($MaterialCode, $currentdate)
{
$dt = date('d',strtotime($currentdate));
$year = date('Y', strtotime($currentdate));
$month = date('m', strtotime($currentdate));
if($month<04)
{
//echo "b4finance";
$newyr = $year - 1;
$startdate = $newyr.'-'.'04'.'-'.'01';
// print_r( $startdate);die();
//echo $startdate;
}
else
{
//echo "after Finance";
$startdate = $year.'-'.'04'.'-'.'01';
// print_r( $startdate);die();
// echo $startdate;
}
$nedt= $dt+1;
$newdate=$year.'-'.$month.'-'.$nedt;
$subquery="SELECT SUM(IF(Transaction_type='Add',Quantity,0)) - SUM(IF(Transaction_type='Reduce',Quantity,0))as remainingqty
FROM T_Material_stock_history
WHERE MaterialCode=? AND CreatedOn >=? AND CreatedOn <=? ";
$query = $this->db->query($subquery,array($MaterialCode,$startdate,$newdate));
// print_r($this->db->last_query());die();
return $query->result_array();
}
function getAssetcode()
{
$this->db->select('AssetCode,AssetName');
$this->db->from('T_Asset_Details');
//$this->db->where('Assetcode',$Assetcode );
//$this->db->where('AssetCode',$Assetcode );
$query = $this->db->get();
return $query->result();
}
function getCostCenterCode()//$CostCenterCode='')
{
$this->db->select('CostCenterCode,CostCenterName');
$this->db->from('T_CostCenter_Master');
//$this->db->where('CostCenterCode', $CostCenterCode);
$query = $this->db->get();
return $query->result();
}
function editRawmaterial($RawMaterial, $MaterialCode)
{
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_MaterialMaster', $RawMaterial);
return TRUE;
}
function viewrawmaterial($RawMaterial, $MaterialCode)
{
echo $MaterialCode; //."and".$RawMaterial ;
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_MaterialMaster', $RawMaterial);
return TRUE;
}
function export_excel(){
$this->db->select('det.*,emp.firstname,emp1.firstname as Updated_By,det.IsActive');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
return $this->db->get('T_MaterialMaster as det')->result_array();
}
/**
* This function is used to delete the user information
* @param number $userId : This is user id
* @return boolean $result : TRUE / FALSE*/
// function deletePO($PO, $POinfo)
// {
// $this->db->where('PO', $PO);
// $this->db->update('T_PurchaseOrderDetails', $POInfo);
// return $this->db->affected_rows();
// }
function checkMaterialExists($material)
{
// $sql="SELECT MaterialCode, MaterialName, MaterialType, Category,REPLACE(MaterialName, ' ', '')
// FROM T_MaterialMaster
// WHERE REPLACE(MaterialName, ' ', '') LIKE REPLACE('%'".$material."'%', ' ', '')";
$this->db->select('MaterialCode,MaterialName,MaterialType,Category');
$this->db->from('T_MaterialMaster');
$this->db->like('REPLACE(MaterialName, " ", "")',$material);
$query = $this->db->get();
//print_r($query->result());
return $query->result();
}
function checkMaterialCategory($mc){
// $this->db->select('ConfigValue');
// $this->db->from('T_ConfigDetails');
// $this->db->where(Config_ID,'C023');
// $this->db->like('ConfigValue',$mc);
// $query = $this->db->get();
// //print_r($query->result());
// return $query->result();
// //return $this->db->get('T_MaterialMaster');
// }
$temp[] = '' ;
// echo $materialcategory;
$this->db->distinct();
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_ID','C023');
$this->db->like('ConfigValue',$mc);
$query = $this->db->get();
//print_r($query->result());die;
$temparr[] = '' ;
foreach($query->result() as $arr){
$temparr[] = $arr->ConfigValue ;
}
$temp['suggestions'] = $temparr;
//print_r($temp);
return $temp;
}
function reOrderListing()
{
//$subQuery='SELECT * from T_MaterialMaster where Current_stock < reorder?';
$today= date("Y-m-d");
$today_month = date('F', strtotime($today));
$today_year = date('Y', strtotime($today));
$pre_year = $today_year -1;
$Fin_year ='';
if($today_month <=3)
{
$Fin_year = '01-04-'.$pre_year;
}
else
{
$Fin_year = '01-04-'.$today_year;
}
$subQuery ="SELECT DISTINCT(p.MaterialCode),mm.MaterialName,opens.CurrentStock,OpeningStock,mm.reorder
FROM T_Material_stock_history AS p
left join T_MaterialMaster mm on mm.MaterialCode = p.MaterialCode
left join
(select StockId,pp.MaterialCode mc,
SUM((IF(pp.Transaction_type='Add',Quantity,0))-(IF(pp.Transaction_type='Reduce',Quantity,0)))
AS CurrentStock,
SUM(
CASE WHEN date(stockdate) > '".$Fin_year."'
THEN stock
ELSE 0
END
) as OpeningStock
FROM T_Material_stock_history AS pp
left join T_MaterialMaster mm on mm.MaterialCode = pp.MaterialCode
GROUP BY pp.MaterialCode
) as opens on opens.mc = p.MaterialCode
where (CurrentStock+OpeningStock)<reorder";
$query=$this->db->query($subQuery,array());
//print_r($this->db->last_query());
return $query->result();
}
function getMaterialAvg($RawMaterialID)
{
$subQuery='select AVG(Rate) as avg_rate from T_PurchaseOrder_LineItem
join T_PurchaseOrder_Master on T_PurchaseOrder_Master.PONO=T_PurchaseOrder_LineItem.PONO
where MaterialCode = ?';
$query = $this->db->query($subQuery,array($RawMaterialID));
//print_r($this->db->last_query());
return $query->result_array();
}
}
?>

View File

@ -1,540 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class requistion_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()
{
$this->db->select('SupplierID, SupplierName,ADeleteRequistionLineItemddress');
$this->db->from('T_SupplierDetailsN');
//$this->db->where('roleId !=', 1);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the userId information
* @return array $result : This is result of the query
*/
function getusers()
{
$this->db->select('userId, name');
$this->db->from('tbl_users');
//$this->db->where('roleId !=', 1);
$query = $this->db->get();
return $query->result();
}
/* This function is used to getEditRequistItemList view the information
* @return array $result : This is result of the query
*/
function getEditRequistItemList($ReqNo)
{
$result = $this->db->query("CALL P_GET_REQUISTITEMLIST('".$ReqNo."')");
//echo 'REQUISTITEMLIST Line item view successfully';
$result ->next_result();
if($result->num_rows > 0)
{
return $result->result();
}
/* $subQuery ='select distinct Req.ReqNo, Req.MaterialCode,Mat.MaterialName,Mat.UOM, Req.Quantity,
ifnull(Po.Quantity,0) as POQTY,sta.StatusName
from T_Requestion_Details Req join T_MaterialMaster Mat on
Req.MaterialCode = Mat.MaterialCode
left join T_PurchaseOrder_LineItem Po on Po.ReqNo = Req.ReqNo
left join T_PurchaseOrder_Master POmast on POmast.PONO=Po.PONO
and Po.MaterialCode = Req.MaterialCode
join T_Status sta on sta.StatusCode = Req.Status
where Req.ReqNo = ? and POmast.Status != ?';
$query = $this->db->query($subQuery, array($ReqNo,PO_AMENDED));
// print_r($this->db->last_query());
return $query->result(); */
}
/**
* This function is used to get the userId information
* @return array $result : This is result of the query
*/
function getStatus()
{
$this->db->select('StatusCode,StatusName ');
$this->db->from('T_Status');
$this->db->where('StatusType', REQUISTSTATUS);
$this->db->where('StatusCode !=', REQ_DRAFT);
$query = $this->db->get();
return $query->result();
}
/* This function is used to get the Raw Material information
* @return array $result : This is result of the query
*/
function getRequistionList($ReqNo,$IsArray='')
{
$result = $this->db-> query("CALL P_GET_AllREQUISTION('".$ReqNo."')") or die(mysql_error());
{
//echo 'PO Line item Inserted successfully';
if($IsArray != '')
{
return $result->result_array();
}
else
{
return $result->result();
}
}
}
/**
* This function is used to get Employee details based on Employee ID Selection
* @return array $result : This is result of the query
*/
function GetEmployeeDetails($EmpID)
{
$this->db->select(' EMP.EmpID,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName');
$this->db->from('T_Employee_Details EMP');
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
$this->db->where('EMP.EmpID ',$EmpID );
$query = $this->db->get();
return $query->result_array();
}
/**
* This function is used to get the Cost Center details for the Login user department
* @return array $result : This is result of the query
*/
function GetCostCenterByDept($DeptId)
{
$this->db->select('Mast.CostCenterCode,Mast.CostCenterName');
$this->db->from('T_CostCenter_Master Mast ');
$this->db->join('T_CostCenter_Departments COST', 'COST.CostCenterCode = Mast.CostCenterCode');
$this->db->where('COST.DEPCode ',$DeptId );
$query = $this->db->get();
// print_r( $this->db->last_query());
return $query->result_array();
}
/**
* This function is used to get the Available BudgetAmount for the Cost center
* @return array $result : This is result of the query
*/
function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType)
{
$this->db->select('BudgetAmount');
$this->db->from('T_CostCenter_Budget');
$this->db->where('CostCenterCode',$CostCode );
$this->db->where('BudgetYear',$Year );
$this->db->where('BudgetType',$BudgetType );
$query = $this->db->get();
return $query->result_array();
}
function EditMaterialCode($ReqNo,$ReqType)
{
$subQuery ='SELECT Mat.MaterialCode,Mat.MaterialName,Mat.UOM
from T_MaterialMaster Mat where Mat.MaterialCode not in (select Req.MaterialCode from T_Requestion_Details Req
join T_Requestion_Master mast on Req.ReqNo = mast.ReqNo where mast.ReqNo=? and mast.ReqType=?
) and Mat.MaterialType=?';
$query = $this->db->query($subQuery, array($ReqNo,$ReqType,$ReqType));
return $query->result();
}
/**
* This function is used to get the Material details for the Request type
* @return array $result : This is result of the query
*/
function GetMaterialCode($ReqType,$NotArray='')
{
$this->db->select('MaterialCode, MaterialName,UOM');
$this->db->from('T_MaterialMaster');
$this->db->where('IsActive',1);
//$this->db->where('MaterialType',$ReqType );
$query = $this->db->get();
if($NotArray == '')
{
return $query->result_array();
}
else
{
return $query->result();
}
}
/**
* This function is used to get the Raw Material information
* @return array $result : This is result of the query
*/
function getRawMaterialList($MaterialCode)
{
$this->db->select('MaterialName,UOM');
$this->db->from('T_MaterialMaster');
$this->db->where('MaterialCode',$MaterialCode );
$query = $this->db->get();
return $query->result_array();
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query
*/
function getConfigValue($ConfigID ,$ConfigValue = '')
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if($ConfigValue != '')
{
$this->db->where('ConfigValue != ',$ConfigValue );
}
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the All employees
* @return array $result : This is result of the query
*/
function getAllEmployees()
{
$this->db->select('EmpID,FirstName,LastName');
$this->db->from('T_Employee_Details');
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the Employee Details
* @return array $result : This is result of the query
*/
function getEmpIdByUserID($UserID)
{
$subQuery ='SELECT EMP.EmpID,EMP.FirstName,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName
FROM T_Employee_Details EMP JOIN T_DepartmentDetails DEPT ON
EMP.Departmentcode = DEPT.DEPCode
WHERE EMP.EmpID=(select EmpID from tbl_users where userId=?)';
$query = $this->db->query($subQuery, array($UserID));
return $query->result();
}
/**
* This function is used to get the CostCenter for the Selected Employee
* @return array $result : This is result of the query
*/
function getCostCenterUserID($UserID)
{
$subQuery ='SELECT Mast.CostCenterCode,Mast.CostCenterName from T_CostCenter_Master Mast
LEFT JOIN T_CostCenter_Departments COST ON COST.CostCenterCode = Mast.CostCenterCode
WHERE COST.DEPCode=(select Departmentcode from T_Employee_Details where EmpID = (select EmpID from tbl_users where userId=?))';
$query = $this->db->query($subQuery, array($UserID));
//print_r($this->db->last_query());
return $query->result();
}
/**
* This function is used to get the Purchase order Type
* @return array $result : This is result of the query
*/
function CheckDraftStatus($UserID)
{
$subQuery = 'select count(ReqNo) as cnt,ReqNo from T_Requestion_Master where
Requestedby= ( select EmpID from tbl_users where userId=?) and status=?';
$query = $this->db->query($subQuery, array($UserID,REQ_DRAFT));
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($ReqID,$NoArray='')
{
$subQuery = 'select distinct ReqNo,ReqType,Status,Requestedby,DATE_FORMAT(mast.CreatedDate, "%d-%m-%Y") as CreatedDate,Schedule_Type,NumberOfService,Service_Period ,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,DATE_FORMAT(mast.ReqDate, "%d-%m-%Y") as ReqDate,mast.CostCenterCode,Cost.CostCenterName
from T_Requestion_Master mast
left join T_CostCenter_Master Cost on Cost.CostCenterCode = mast.CostCenterCode
join T_Employee_Details emp on mast.Requestedby = emp.EmpID
join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode
where ReqNo=?';
$query = $this->db->query($subQuery, array($ReqID));
// print_r($this->db->last_query());
if($NoArray == '')
{
return $query->result_array();
}
else
{
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 getRequistListUserID($UserID)
{
$subQuery = 'select ReqNo, ReqType ,Status,CreatedDate ,StatusName from T_Requestion_Master mast
join T_Status st on st.StatusCode= mast.Status where
Requestedby = ( select EmpID from tbl_users where userId=?) and Status != ? ';
$query = $this->db->query($subQuery, array($UserID,REQ_DELETED));
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 getRequistItemList($ReqID,$NoArray='')
{
/* $subQuery = 'select distinct Req.ReqNo, Mat.MaterialCode,Mat.MaterialName,Mat.UOM, Req.Quantity,sum(Po.Quantity) as POQTY,sta.StatusName from T_MaterialMaster Mat
left join T_Requestion_Details Req on Req.MaterialCode = Mat.MaterialCode
left join T_PurchaseOrder_LineItem Po on Po.ReqNo = Req.ReqNo and Po.MaterialCode = Req.MaterialCode
left join T_Status sta on sta.StatusCode = Req.Status where Req.ReqNo=? group by Po.ReqNo,Req.MaterialCode';
$query = $this->db->query($subQuery, array($ReqID)); */
$result = $this->db-> query("CALL P_GET_REQUISTITEMLIST('".$ReqID."')") or die(mysql_error());
$result ->next_result();
if($result->num_rows > 0)
{
if($NoArray == '')
{
return $result->result_array();
}
else
{
return $result->result();
}
}
}
/**
* This function is used to add the Requistion into the Database
* @return array $result : This is result of the query
*/
function addRequistion($Requistion)
{
$this->db->trans_start();
$this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master';
$query = $this->db->query($subQuery);
return $query->result_array();
}
}
/**
* This function is used to check the Request is in Draft status
* @return array $result : This is result of the query
*/
function RequistionIsExists($ReqBy)
{
$this->db->select('ReqNo');
$this->db->from('T_Requestion_Master');
$this->db->where('Status ',REQ_DRAFT );
$this->db->where('Requestedby ',$ReqBy );
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
/**
* This function is used to check the Request Line Item is in Draft status
* @return array $result : This is result of the query
*/
function LineItemIsExists($ReqNo,$MaterialCode)
{
$this->db->select('ReqNo');
$this->db->from('T_Requestion_Details');
$this->db->where('ReqNo ',$ReqNo );
$this->db->where('MaterialCode ',$MaterialCode );
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
/**
* This function is used to add the Line item details to the Database
* @return array $result : This is result of the query
*/
function addRequistionDetails($Requistion,$RegNo='')
{
$this->db->trans_start();
$this->db->insert('T_Requestion_Details', $Requistion);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
$subQuery = 'select max(ItemNo) as ItemNo from T_Requestion_Details where ReqNo=?';
$query = $this->db->query($subQuery,array($RegNo));
return $query->result_array();
}
function getItemNumber($ReqNo,$MaterialCode)
{
$subQuery = 'select ItemNo from T_Requestion_Details where ReqNo=? and MaterialCode=?';
$query = $this->db->query($subQuery,array($ReqNo,$MaterialCode));
return $query->result_array();
}
/**
* This function is used to delete the Line item from details into Database
* @return array $result : This is result of the query
*/
function DeleteRequistionLineItem( $ReqNo,$MaterialCode)
{
$this->db->where('ReqNo', $ReqNo);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->delete('T_Requestion_Details');
return TRUE;
}
/**
* This function is used to update the details into Database
* @return array $result : This is result of the query
*/
function UpdateRequistionLineItem($Requist, $ReqNo,$MaterialCode)
{
$this->db->where('ReqNo', $ReqNo);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_Requestion_Details',$Requist);
return TRUE;
}
function UpdateAvlQty($BalanceQuantity,$MaterialCode)
{
$this->db->where('MaterialCode',$MaterialCode);
$this->db->update('T_Store_Stockdetails',$BalanceQuantity);
return TRUE;
}
/**
* This function is used to update the details into Database
* @return array $result : This is result of the query
*/
function UpdateRequistion($Requistion, $ReqNo)
{
$this->db->where('ReqNo', $ReqNo);
$this->db->update('T_Requestion_Master', $Requistion);
return TRUE;
}
/**
* This function is used to get the List of Requist details to the approver
* @return array $result : This is result of the query
*/
function getApproverRequistList($UserID,$Status = '',$FromDate='' ,$ToDate='')
{
// echo 'UserId: '.$UserID . 'From: '.$FromDate .'TO: '. $ToDate. 'Status: '. $Status;
$subQuery = 'select distinct ReqNo,Status,mast.CreatedDate,Requestedby,emp.FirstName,mast.Comments,st.StatusName
from T_Requestion_Master mast join T_Employee_Details emp on mast.Requestedby = emp.EmpID
join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode
join T_Status st on st.StatusCode = mast.Status
where status not in(?,?,?) and emp.Departmentcode in (select DEPCode from T_DepartmentDetails where HeadDept=
(select HeadDept from T_DepartmentDetails where DEPCode = (select Departmentcode from T_Employee_Details where
EmpID=(select EmpID from tbl_users where userId=?))))';
$subQuery1 = $subQuery;
$query ='';
if($FromDate != '' && $ToDate != '' && $Status !='' )
{
$Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? and Status=?';
$subQuery1 .= $Where;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate,$Status));
}
else if($FromDate != '' && $ToDate != '' && $Status =='')
{
$Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? ';
$subQuery1 .= $Where;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate));
}
else if($Status != '' && $FromDate == '' && $ToDate == '')
{
$Where = 'and Status = ?';
$subQuery1 .= $Where;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$Status));
}
else
{
$query = $this->db->query($subQuery, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID));
}
//print_r($this->db->last_query());
return $query->result();
}
}

View File

@ -1,81 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class store_model extends CI_Model
{
function viewStock()
{
$this->db->select('st.*,st.Remarks as storeremarks,MM.*');
$this->db->from('T_Store_Stockdetails st ');
$this->db->join('T_MaterialMaster MM','st.MaterialCode=MM.MaterialCode');
$query = $this->db->get();
//print_r($this->db->last_query());
$result = $query->result();
return $result;
}
// function viewStock()
// {
// $this->db->distinct();
// $this->db->select('st.*,st.Remarks as storeremarks,MM.*,RDet.DeliveredQuantity');
// $this->db->from('T_Store_Stockdetails st ');
// $this->db->join('T_MaterialMaster MM','st.MaterialCode=MM.MaterialCode');
// $this->db->join('T_Requestion_Details RDet','st.MaterialCode=RDet.MaterialCode and MM.MaterialCode=RDet.MaterialCode');
// $query = $this->db->get();
// $result = $query->result();
// //print_r($this->db->last_query());
// return $result;
// }
function GetAllMaterialList()
{
$subQuery = 'select MM.* from T_MaterialMaster MM where MaterialCode not in(select MaterialCode from T_Store_Stockdetails)';
$query = $this->db->query($subQuery);
return $query->result();
}
function GetConfigValue($ConfigID)
{
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_ID',$ConfigID);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function addStock($StockDetails)
{
$this->db->trans_start();
$this->db->insert('T_Store_Stockdetails', $StockDetails);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
}
function UpdateStock($StockDetails,$MaterialCode)
{
$this->db->where('MaterialCode',$MaterialCode);
$this->db->update('T_Store_Stockdetails',$StockDetails);
}
function GetStockHisory($MaterialCode)
{
$this->db->select('Quantity,ActualQuantity,Remarks,updatedOn');
$this->db->from('T_Store_Stockdetails_History');
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
$result = $query;
return $result->result_array();
}
}

View File

@ -1,507 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class storerequistion_model extends CI_Model
{
/* completed*/
function getCostUser($userId='',$BudgetType='')
{
$this->db->select ('ED.FirstName,CM.CostCenterCode,CM.CostCenterName,CB.BudgetAmount,CB.BudgetType');
$this->db-> from(' T_CostCenter_Master CM');
$this->db->join ('T_CostCenter_Departments CD ',' CD.CostCenterCode = CM.CostCenterCode');
$this->db->join ('T_CostCenter_Budget CB ',' CB.CostCenterCode = CM.CostCenterCode');
$this->db->join ('T_Employee_Details ED ','ED.Departmentcode = CD.DEPCode');
$this->db->join ('tbl_users TU ',' TU.EmpID = ED.EmpID ');
$this->db->where('TU.userId ',$userId);
//$this->db->where('CB.BudgetType','SERVICE');
$query = $this->db->get();
$result = $query->result();
//print_r( $result );
return $result;
}
function getRawMaterialList($MaterialCode='')
{
$this->db->select('MaterialName,UOM,MaterialCode');
$this->db->from('T_MaterialMaster');
//$this->db->where('MaterialCode',$MaterialCode );
$query = $this->db->get();
$result = $query->result();
// print_r($result);
return $result;
}
/**
* This function is used to add the Raise store Requestion into the Database
* @return array $result : This is result of the query
*/
function addRequistion($ReqDate='')
{
$this->db->trans_start();
$this->db->insert('T_Store_Requestion_Master', $ReqDate);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(StoreReqNo) as StoreReqNo from T_Store_Requestion_Master';
$query = $this->db->query($subQuery);
return $query->result_array();
}
//return $insert_id;
}
/**
* This function is used to update the details into Database
* @return array $result : This is result of the query
*/
function UpdateRequistion($StoreReqNo,$Request)
{
$this->db->where('StoreReqNo',$StoreReqNo);
$this->db->update('T_Store_Requestion_Master',$Request);
return TRUE;
}
function getRequistionList()
{
$this->db->select('Sm.StoreReqNo, Emp.FirstName as Requestedby,Sm.ReqDate,Sm.Status,Sm.Comments as Remarks,St.StatusName,Dept.DepartmentName ');
$this->db->from ('T_Store_Requestion_Master Sm');
$this->db->join('tbl_users user','Sm.CreatedBy = user.userId ');
$this->db->join('T_Employee_Details Emp','Emp.EmpID= user.EmpID');
$this->db->join('T_DepartmentDetails Dept','Dept.DEPCode = Sm.DepartmentCode');
$this->db->join('T_Status St','St.StatusCode = Sm.Status');
$this->db->where('Sm.Status ',STORE_APPROVAL);
$this->db->or_where('Sm.Status ',STORE_PARTIALLYISSUSED);
$query = $this->db->get();
$result = $query->result();
// print_r($this->db->last_query());
//print_r($result);
return $result;
}
/*this function used to Add Store Requistion*/
function addstoreRequistion($Request)
{
//print_r($Request);
//die();
$this->db->trans_start();
$this->db->insert('T_Store_Requestion_Details',$Request);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(StoreReqLineItemNo) as StoreReqLineItemNo from T_Store_Requestion_Details';
$query = $this->db->query($subQuery);
return $query->result_array();
}
}
/*this function used to Update Store Requistion*/
function upstoreRequistion($Request)
{
//print_r($Request);
$this->db->trans_start();
$this->db->update('T_Store_Requestion_Details',$Request);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(StoreReqLineItemNo) as StoreReqLineItemNo from T_Store_Requestion_Details';
$query = $this->db->query($subQuery);
return $query->result_array();
}
/**
* This function is used to check the Request Line Item is in Draft status
* @return array $result : This is result of the query
*/
function LineItemIsExists($StoreReqNo,$MaterialCode)
{
$this->db->select('StoreReqNo');
$this->db->from('T_Store_Requestion_Details');
$this->db->where('StoreReqNo ',$StoreReqNo );
$this->db->where('MaterialCode ',$MaterialCode );
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
}
/**
* This function is used to add the Line item details to the Database
* @return array $result : This is result of the query
*/
function addRequistionDetails($StoreReqLineItemNo)
{
//echo "nsmdnsjkkjasdf"; die();
$this->db->trans_start();
$this->db->insert('T_Store_Requestion_Details', $StoreReqLineItemNo
);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
//print_r($this->db->last_query());
return $insert_id;
}
/**
* This function is used to update the Line item details to the Database
* @return array $result : This is result of the query
*/
function upRequistionDetails($StoreReqLineItemNo)
{
//echo "nsmdnsjkkjasdf"; die();
$this->db->trans_start();
$this->db->update('T_Store_Requestion_Details', $StoreReqLineItemNo
);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
//print_r($this->db->last_query());
return $insert_id;
}
/**
* This function is used to check the Request Line Item is in Draft status
* @return array $result : This is result of the query
*/
function LineItemIsExists($StoreReqNo,$MaterialCode)
{
$this->db->select('StoreReqNo');
$this->db->from('T_Store_Requestion_Details');
$this->db->where('StoreReqNo ',$StoreReqNo );
$this->db->where('MaterialCode ',$MaterialCode );
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
/**
* This function is used to update the details into Database
* @return array $result : This is result of the query
*/
function UpdateRequistionLineItem($Request,$StoreReqNo,$MaterialCode)
{
$this->db->where('StoreReqNo', $StoreReqNo);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_Store_Requestion_Details',($Request));
return TRUE;
}
/**
* This function is used to delete the Line item from details into Database
* @return array $result : This is result of the query
*/
function DeleteRequistionLineItem( $StoreReqNo,$MaterialCode)
{
$this->db->where('StoreReqNo', $StoreReqNo);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->delete('T_Store_Requestion_Details');
return TRUE;
}
/**
* This function is used to get the userId information
* @return array $result : This is result of the query
*/
function getStatus()
{
$this->db->select('StatusCode,StatusName ');
$this->db->from('T_Status');
$this->db->where('Remarks', 'STORE REQUISTION STATUS');
//$this->db->where('StatusCode!=', REQ_DRAFT);
$query = $this->db->get();
// print_r($query);
return $query->result();
}
function editstorerequistions($StoreReqNo)
{
$this->db->select('Sr.StoreReqNo,Sr.MaterialCode,Sr.QuantityRequired,Sr.Status,Sr.Remarks,Mm.MaterialName,Mm.UOM,Sr.QuantityIssued,STM.Status ');
$this->db->from('T_Store_Requestion_Details Sr');
$this->db->join('T_MaterialMaster Mm' ,' Mm.MaterialCode = Sr.MaterialCode');
$this->db->join('T_Store_Requestion_Master STM' ,' STM.StoreReqNo = Sr.StoreReqNo');
$this->db->where('Sr.StoreReqNo',$StoreReqNo);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to check the Request is in Draft status
* @return array $result : This is result of the query
*/
function RequistionIsExists($ReqDate)
{
$this->db->select('StoreReqNo');
$this->db->from('T_Store_Requestion_Master');
//$this->db->where('Status ',REQ_DRAFT );
$this->db->where('ReqDate',$ReqDate );
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
/**
* This function is used to check the Request is in Draft status
* @return array $result : This is result of the query
*/
function Storerequisition($MaterialCode)
{
$this->db->select('StoreReqNo');
$this->db->from('T_Store_Requestion_Details');
//$this->db->where('Status ',REQ_DRAFT );
$this->db->where('MaterialCode',$MaterialCode);
$query = $this->db->get();
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
/** COMPLETED
* This function is used to get the List of Store Requist details to the approver
* @return array $result : This is result of the query
*/
function getApproverRequistList($UserID)
{
// echo 'UserId: '.$UserID . 'From: '.$FromDate .'TO: '. $ToDate. 'Status: '. $Status;
$subQuery = ' select distinct Str.StoreReqNo,Str.Requestedby,Str.ReqDate,Str.Status,Str.CreatedDate,Str.Comments,St.StatusName,Emp1.FirstName
from T_Store_Requestion_Master Str
join T_Status St on St.StatusCode = Str.Status
join T_Employee_Details Emp on Emp.Departmentcode =Str.DepartmentCode
join T_Employee_Details Emp1 on Emp1.EmpID =Str.Requestedby
join T_DepartmentDetails Dept on Dept.DEPCode = Emp.Departmentcode
where Str.Status not in(?,?,?) and Emp.Departmentcode in (select DEPCode from T_DepartmentDetails where HeadDept=
(select HeadDept from T_DepartmentDetails where DEPCode = (select Departmentcode from T_Employee_Details where
EmpID=(select EmpID from tbl_users where userId=?))))';
$query ='';
$query = $this->db->query($subQuery, array(STORE_REJECT,STORE_DRAFT,REQ_DELETED,$UserID));
// print_r($this->db->last_query());
return $query->result();
}
/**
* This function is used to get the Store Requsition List for the login user
* @return array $result : This is result of the query
*/
function getRequistDetails($StoreReqNo='')
{
$subQuery = ' select Str.StoreReqNo,Str.Requestedby,Str.ReqDate,Dept.DEPCode,Dept.DepartmentName,Cm.CostCenterCode,Cm.CostCenterName,Emp.FirstName from T_Store_Requestion_Master Str
join T_DepartmentDetails Dept on Dept.DEPCode = Str.DepartmentCode
join T_CostCenter_Master Cm on Cm.CostCenterCode =Str.CostCenterCode
join T_Employee_Details Emp on Emp.EmpID =Str.Requestedby
where StoreReqNo =? ';
$query = $this->db->query($subQuery, array($StoreReqNo));
// print_r($this->db->last_query());
return $query->result();
}
function editRequistDetails($StoreReqNo)
{
$this->db->select('StoreReqNo,Sr.CostCenterCode,Cc.CostCenterName
');
$this->db->from('T_Store_Requestion_Master Sr');
$this->db->join('T_CostCenter_Master Cc ',' Cc.CostCenterCode=Sr.CostCenterCode');
$this->db->where('StoreReqNo',$StoreReqNo);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to get the Store Requsition List for the login user
* @return array $result : This is result of the query
*/
function getRequistItemListApproval($StoreReqNo,$NoArray='')
{
$subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.Remarks,Mat.MaterialName,Mat.UOM,Ss.StatusName,Str.Status,Str.QuantityIssued
from T_Store_Requestion_Details Str
join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode
join T_Status Ss on Ss.StatusCode = Str.Status
where Str.StoreReqNo =?';
$query = $this->db->query($subQuery, array($StoreReqNo));
if($NoArray == '')
{
return $query->result_array();
}
else
{
return $query->result();
}
}
/**
* This function is used to get the Store Requsition List for the login user
* @return array $result : This is result of the query
*/
function getRequistItemList($StoreReqNo)
{
$subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.QuantityIssued,Str.Remarks,Str.StoreComments,Mat.MaterialName,Mat.UOM,Ss.StatusName,St.Status,St.Quantity
from T_Store_Requestion_Details Str
join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode
join T_Status Ss on Ss.StatusCode = Str.Status
left join T_Store_Stockdetails St on St.MaterialCode=Str.MaterialCode
where Str.StoreReqNo =?';
$query = $this->db->query($subQuery, array($StoreReqNo));
//print_r($this->db->last_query());
return $query->result();
}
function getStoreRequistionStatus($StreReqNo='')
{
$this->db->select('Status');
$this->db->from('T_Store_Requestion_Master Sr');
$this->db->where('StoreReqNo',$StreReqNo);
$query = $this->db->get();
return $query->result();
}
function UpdateStoreRequistionItem($Items,$ReqNo,$MaterialCode)
{
$this->db->where('StoreReqNo', $ReqNo);
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_Store_Requestion_Details', $Items);
return TRUE;
}
function getSavedQty($ReqNO,$MaterialCode)
{
$subQuery='select QuantityIssued from T_Store_Requestion_Details
where StoreReqNo=? and MaterialCode=?';
$query = $this->db->query($subQuery, array($ReqNO,$MaterialCode));
return $query->result();
}
function updatestoremaster($updatestatus,$StoreReqNo)
{
$this->db->where('StoreReqNo', $StoreReqNo);
$this->db->update('T_Store_Requestion_Master', $updatestatus);
return TRUE;
}
function getstatuscount($Status,$StoreReqNo)
{
$this->db->select('count(Status) as SCount');
$this->db->from('T_Store_Requestion_Details');
$this->db->where('Status', $Status);
$this->db->where('StoreReqNo',$StoreReqNo);
//$this->db->where('StoreReqNo', $StoreReqNo);
$query = $this->db->get();
//print_r($this->db->last_query());
return $query->result();
}
/*this function used to get the all store requistion list view*/
function Storeall($StoreReqNo,$IsArray='')
{
$result = $this->db-> query("CALL P_GET_AllSTOREREQUISTION('".$StoreReqNo."')") or die(mysql_error());
{
//echo 'Store Line item Inserted successfully';
if($IsArray != '')
{
return $result->result_array();
}
else
{
return $result->result();
}
}
}
function getItemQuantityFromStock($MaterialCode)
{
$subQuery = 'select Quantity from T_Store_Stockdetails where MaterialCode=?';
$query = $this->db->query($subQuery,array($MaterialCode));
return $query->result_array();
}
function UpdateStock($StockDetails,$MaterialCode)
{
$this->db->where('MaterialCode', $MaterialCode);
$this->db->update('T_Store_Stockdetails', $StockDetails);
return TRUE;
}
}

View File

@ -1,207 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class supplier_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function supplierListing()
{
$this->db->select('BaseT.SupplierID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration, BaseT.TIN, BaseT.PAN,,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.CreatedOn,BaseT.PaymentID,pmt.PaymentTerms,BaseT.CSTDate');//,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT,pmt.Details');
$this->db->from('T_SupplierDetailsN as BaseT');
$this->db->join('T_PaymentTerms as pmt', 'pmt.PaymentID = BaseT.PaymentID','left');
$query = $this->db->get();
$result = $query->result();
return $result;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getpayment($Configvalue = '')
{
$ConfigID = 'C009';
$this->db->select('ConfigValue');
$this->db->from('T_ConfigDetails');
$this->db->where('Config_id ',$ConfigID );
if ($Configvalue!= '')
{
$this->db->where('ConfigValue !=',$Configvalue );
}
$query = $this->db->get();
return $query->result();
}
function getPaymentTerms($payment = '')
{
$this->db->select('*');
$this->db->from('T_PaymentTerms');
$query = $this->db->get();
$result = $query->result();
return $result;
}
function checkPAN($PAN,$SID = '')
{
$this->db->select('PAN');
$this->db->from('T_SupplierDetailsN');
$this->db->where('PAN',$PAN);
if ($SID != '')
{
$this->db->where('SupplierID !=',$SID);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
//echo $result->num_rows;
return $query->result_array();
}
}
function checkGST($GST,$SID = '')
{
$this->db->select('GSTNO');
$this->db->from('T_SupplierDetailsN');
$this->db->where('GSTNO',$GST);
if ($SID != '')
{
$this->db->where('SupplierID !=',$SID);
}
$query = $this->db->get();
//print_r($this->db->last_query());
if ($query->num_rows > 0) {
// echo $query->num_rows;
return $query->result_array();
}
}
function addNewsupplier($supplier)
{
$this->db->insert('T_SupplierDetailsN', $supplier);
$SID = $this->db->affected_rows();
return $SID;
}
// function addNewsupplier($supplier)
// {
// $this->db->insert('T_SupplierDetailsN', $supplier);
// $SID = $this->db->affected_rows();
// // if($SID>0)
// // {
// // $subQuery = 'select max(SupplierID) as suppid from T_SupplierDetailsN';
// // $query = $this->db->query($subQuery);
// // return $query->result();
// // }
// return $SID;
// }
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getSupplierInfo($supplierID='')
{
$this->db->select('SD.*,PT.PaymentTerms');
//$this->db->select('SD.SupplierID, SD.SupplierName, SD.Address, SD.ContactNumber, SD.AlternateContactNumber, SD.EmailAddress, SD.Exiseregistration, SD.TIN, SD.PAN, SD.CSTNO, SD.CSTDate, SD.GSTNO, SD.GSTRange, SD.CollectrateAddress, SD.UANumber, SD.Cert_EMS, SD.Cert_TS, SD.Cert_IMS, SD.Cert_ISO, SD.Cert_OSHAS, SD.BankAcNumber, SD.IsService, SD.IsMaintanance, SD.IsRawMaterial, SD.IFSCCode, SD.BranchName, SD.BankAddress, SD.IsActive, SD.PaymentID,PT.PaymentTerms');
$this->db->from('T_SupplierDetailsN SD');
$this->db->join('T_PaymentTerms PT','PT.PaymentID = SD.PaymentID','left');
$this->db->where('SD.SupplierID', $supplierID);
$query = $this->db->get();
// print_r($this->db->last_query());
return $query->result();
}
/* This function to get the Supplier Address on respective Supplier ID */
function GetSupplierAddress($supplierID)
{
$this->db->select('Address');
$this->db->from('T_SupplierDetailsN');
$this->db->where('SupplierID', $supplierID);
$query = $this->db->get();
return $query->result_array();
}
function UpdateSupplier($supplier, $supplierID)
{
$this->db->where('SupplierID', $supplierID);
$this->db->update('T_SupplierDetailsN', $supplier);
return TRUE;
}
function viewsupplier($supplier, $supplierID)
{
$this->db->where('SupplierID', $supplierID);
$this->db->update('T_SupplierDetailsN', $supplier);
return TRUE;
}
function SupplierCertification($cerificate)
{
$this->db->insert_id('T_Supplier_Certification',$cerificate);
$insert_id = $this->db->affected_rows();
return $insert_id;
}
function export_excel(){
$this->db->select('det.SupplierID,SupplierName,det.Address,det.ContactNumber,det.AlternateContactNumber,det.EmailAddress,det.Exiseregistration,det.TIN,
det.PAN,det.CSTNO,det.CSTDate,det.GSTNO,det.GSTRange,det.CollectrateAddress,det.UANumber,pmt.PaymentTerms,emp.firstname ,emp1.firstname as Update_by,det.IsActive,
det.Cert_EMS,det.Cert_TS,det.Cert_OSHAS,det.Cert_ISO,det.Cert_IMS,det.BankAcNumber,det.IFSCCode,det.BranchName,det.BankAddress,
det.IsService,det.IsMaintanance,det.IsRawMaterial');
$this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left');
$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left');
$this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left');
$this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left');
$this->db->join('T_PaymentTerms as pmt', 'pmt.PaymentID = det.PaymentID','left');
return $this->db->get('T_SupplierDetailsN as det')->result_array();
}
function checkSupplierExists($supp_name)
{
$this->db->select('SupplierID,SupplierName,Address');
$this->db->from('T_SupplierDetailsN');
$this->db->like('REPLACE(SupplierName, " ", "")', $supp_name);
$query = $this->db->get();
return $query->result();
}
/*SUPPLIER */
/*SUPPLIER TYPE */
}
?>

View File

@ -1,315 +0,0 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class User_model extends CI_Model
{
/**
* This function is used to get the user listing count
* @param string $searchText : This is optional search text
* @param number $page : This is pagination offset
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
function userListing()
{
$this->db->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,
DEPT.DEPCode,DEPT.DepartmentName,role.role,user.userId');
$this->db->from('T_Employee_Details EMP');
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
$this->db->join('tbl_users user', 'user.EmpID = EMP.EmpID');
$this->db->join('tbl_roles role', 'user.roleId = role.roleId');
$this->db->where('user.isDeleted !=', 1);
$query = $this->db->get();
$result = $query->result();
return $result;
}
function GetRoleNameByUserID($UserId)
{
$subQuery = 'select roleId, role from tbl_roles
where roleId = (select roleId from tbl_users where userId=?)';
$query = $this->db->query($subQuery, array($UserId));
return $query->result();
}
/**
* This function is used to get the user roles information
* @return array $result : This is result of the query
*/
function getUserRoles()
{
$this->db->select('roleId, role');
$this->db->from('tbl_roles');
$this->db->where("roleid <", 4);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to check whether email id is already exist or not
* @param {string} $email : This is email id
* @param {number} $userId : This is user id
* @return {mixed} $result : This is searched result
*/
function checkEmailExists($email, $userId = 0)
{
$this->db->select("email");
$this->db->from("tbl_users");
$this->db->where("email", $email);
$this->db->where("isDeleted", 0);
if($userId != 0){
$this->db->where("userId !=", $userId);
}
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to add new user to system
* @return number $insert_id : This is last inserted id
*/
function addNewUser($userInfo)
{
$this->db->trans_start();
$this->db->insert('tbl_users', $userInfo);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function getUserInfo($userId)
{
$this->db->select('userId, name, email, mobile, roleId,isDeleted');
$this->db->from('tbl_users');
$this->db->where('isDeleted', 0);
$this->db->where('roleId !=', 1);
$this->db->where('userId', $userId);
$query = $this->db->get();
return $query->result();
}
/**
* This function is used to update the user information
* @param array $userInfo : This is users updated information
* @param number $userId : This is user id
*/
function editUser($userInfo, $userId)
{
$this->db->where('EmpID', $userId);
$this->db->update('tbl_users', $userInfo);
//print_r($this->db->last_query());
return TRUE;
}
/**
* This function is used to delete the user information
* @param number $userId : This is user id
* @return boolean $result : TRUE / FALSE
*/
function deleteUser($userId, $userInfo)
{
$this->db->where('userId', $userId);
$this->db->update('tbl_users', $userInfo);
return $this->db->affected_rows();
}
/**
* This function is used to match users password for change password
* @param number $userId : This is user id
*/
function matchOldPassword($userId, $oldPassword)
{
$this->db->select('userId, password');
$this->db->where('userId', $userId);
$this->db->where('isDeleted', 0);
$query = $this->db->get('tbl_users');
$user = $query->result();
if(!empty($user)){
if(verifyHashedPassword($oldPassword, $user[0]->password)){
return $user;
} else {
return array();
}
} else {
return array();
}
}
/**
* This function is used to change users password
* @param number $userId : This is user id
* @param array $userInfo : This is user updation info
*/
function changePassword($userId, $userInfo)
{
$this->db->where('userId', $userId);
$this->db->where('isDeleted', 0);
$this->db->update('tbl_users', $userInfo);
return $this->db->affected_rows();
}
/**
* This function is used to get Employee details based on Employee ID Selection
* @return array $result : This is result of the query
*/
function GetEmployeeDetails($UserId)
{
//echo $UserId;
$subQuery = 'select EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName from
T_Employee_Details EMP join T_DepartmentDetails DEPT on
EMP.Departmentcode = DEPT.DEPCode where EMP.EmpID= (select EmpID from tbl_users where userId=?)';
$query = $this->db->query($subQuery, array($UserId));
return $query->result();
}
/**
* This function is used to get the All employees
* @return array $result : This is result of the query
*/
function getAllEmployees()
{
/*$this->db->select('EmpID,FirstName,LastName');
$this->db->from('T_Employee_Details');
$query = $this->db->get();
return $query->result(); */
$this->db->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName');
$this->db->from('T_Employee_Details EMP');
$this->db->join('T_DepartmentDetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode');
$this->db->where('EMP.IsActive ',1 );
$query = $this->db->get();
return $query->result();
}
function addAccess($userdept)
{
$this->db->trans_start();
$this->db->insert('T_AccessDepartments', $userdept);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return $insert_id;
}
function DeleteAccess($empid,$Depcode)
{
$this->db->where("Departmentcode",$Depcode);
$this->db->where("EmpID",$empid);
$this->db->delete('T_AccessDepartments');
return TRUE;
}
//this function used to delivery performances
function deliver_perform($fa,$aa,$m)
{
$sql="select ip_invoices.*,ip_invoice_items.item_quantity as qty,
ip_clients.* from ip_invoices
join ip_clients on ip_clients.client_id=ip_invoices.client_id
join ip_invoice_items on ip_invoice_items .invoice_id =ip_invoices.invoice_id
join ip_invoice_custom icf on icf.invoice_id = ip_invoices.invoice_id
where icf.invoice_custom_fieldid = 8 and ip_invoices.invoice_status_id != 1";
if ($fa and $aa != ''){
$sql.=" and (ip_invoices.invoice_date_created >= '".$fa."-04-01' and ip_invoices.invoice_date_created <= '".$aa."-03-31')";
}
if ($m!= ''){
$sql.=" and monthname(ip_invoices.invoice_date_created) = '".$m."'";
}
$sql .= " ORDER BY ip_invoices.invoice_date_created DESC";
$query = $this->db->query($sql);
return $query->result();
}
function fincalYear()
{
$sql="SELECT
CASE WHEN MONTH(invoice_date_created)>=4 THEN
concat(YEAR(invoice_date_created), '-',YEAR(invoice_date_created)+1)
ELSE concat(YEAR(invoice_date_created)-1,'-', YEAR(invoice_date_created)) END AS financial_year
FROM ip_invoices
GROUP BY financial_year ";
$query = $this->db->query($sql);
//print_r($query->result());
return $query->result();
}
/*
*fav model
*/
function favouriteadd($favourite)
{ //echo $favourite['Menu_ID'];die;
if($favourite['Menu_ID'] !=''){
//echo "if";
// $this->db->where('id', $id);
// return $this->db->delete('employee');
$this->db->where('Menu_ID',$favourite['Menu_ID']);
$this->db->delete('T_fav_add');
}else{
//echo "else";
$this->db->insert('T_fav_add',$favourite);
$r = $this->db->affected_rows();
return $r;
}
}
}

View File

@ -189,7 +189,8 @@ TMD.QuantityRejected,ST.StatusName,TMD.Remarks,AdvanceAmount ');
if($insert_id>0)
{
$subQuery = 'select max(MRIRNO) as MRIRNo from T_MRIR_Master';
//$subQuery = 'select max(MRIRNO) as MRIRNo from T_MRIR_Master';
$subQuery = 'select MRIRNO from T_MRIR_Master order by Createdon desc limit 1';
$query = $this->db->query($subQuery);
return $query->result();//_array();
}

View File

@ -357,21 +357,43 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName
* This function is used to add the Requistion into the Database
* @return array $result : This is result of the query
*/
function addRequistion($Requistion)
{
$this->db->trans_start();
$this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
// function addRequistion($Requistion)
// {
// $this->db->trans_start();
// $this->db->insert('T_Requestion_Master', $Requistion);
// $insert_id = $this->db->affected_rows();
// $this->db->trans_complete();
if($insert_id>0)
{
$subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master';
// if($insert_id>0)
// {
// $subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master';
$query = $this->db->query($subQuery);
// $query = $this->db->query($subQuery);
return $query->result_array();
}
// return $query->result_array();
// }
function addRequistion($Requistion){
$this->db->trans_start();
$result = $this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->insert_id();
$affected_rows = $this->db->affected_rows();
$this->db->trans_complete();
try {
$result = ($result) ? $result : false;
if ($result && $affected_rows > 0) {
$subQuery = 'select ReqNo from T_Requestion_Master order by CreatedDate desc limit 1';
$query = $this->db->query($subQuery);
log_message('error','add new Requisition insert_id '.$insert_id);
return $query->result_array();
} else {
throw new Exception("database error occur requisition master details not inserted");
}
} catch (Exception $e) {
log_message('error',$e->getMessage());
return false;
}
}
}
/**
@ -502,6 +524,7 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName
(select HeadDept from T_DepartmentDetails where DEPCode = (select Departmentcode from T_Employee_Details where
EmpID=(select EmpID from tbl_users where userId=?))))';
$subQuery1 = $subQuery;
$order_by = ' order by mast.CreatedDate desc';
$query ='';
if($FromDate != '' && $ToDate != '' && $Status !='' )
@ -509,23 +532,27 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName
$Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? and Status=?';
$subQuery1 .= $Where;
$subQuery1 .= $order_by;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate,$Status));
}
else if($FromDate != '' && $ToDate != '' && $Status =='')
{
$Where = 'and mast.CreatedDate >= ? and mast.CreatedDate <= ? ';
$subQuery1 .= $Where;
$subQuery1 .= $order_by;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$FromDate,$ToDate));
}
else if($Status != '' && $FromDate == '' && $ToDate == '')
{
$Where = 'and Status = ?';
$subQuery1 .= $Where;
$subQuery1 .= $order_by;
$query = $this->db->query($subQuery1, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID,$Status));
}
else
{
$subQuery .= $order_by;
$query = $this->db->query($subQuery, array(REQ_DRAFT,REQ_DELETED,REQ_REJECTED,$UserID));
}

View File

@ -438,7 +438,7 @@ $(function () {
"lengthChange": true,
"searching": true,
"columnDefs" : [{"targets":4, "type":"date-eu"}],
"aaSorting": [[ 4, "desc" ]],
"ordering": true,
"info": true,
"autoWidth": true

View File

@ -383,7 +383,7 @@ $(function () {
"searching": true,
"columnDefs" : [{"targets":2, "type":"date-eu"}],
"aaSorting": [[ 0, "desc" ]],
"aaSorting": [[ 2, "desc" ]],
"ordering": true,
"info": true,
"autoWidth": true

View File

@ -143,7 +143,7 @@ span.highlight {
"ordering": true,
"columnDefs" : [{"targets":7, "type":"date-eu"}],
"aaSorting": [[ 0, "desc" ]],
"aaSorting": [[ 7, "desc" ]],
"info": true,
"autoWidth": true

View File

@ -152,7 +152,7 @@ $ReqDate = $dt->format('d-m-Y'); echo $ReqDate ?>
"searching": true,
"ordering": true,
"columnDefs" : [{"targets":5, "type":"date-eu"}],
"aaSorting": [[ 5, "desc" ]],
"info": true,
"autoWidth": true

View File

@ -583,6 +583,7 @@ function validate()
"searching": true,
"ordering": true,
"columnDefs" : [{"targets":6, "type":"date-eu"}],
"aaSorting": [[ 6, "desc" ]],
"info": true,
"autoWidth": false
});