diff --git a/application/config/database.php b/application/config/database.php index 995466ae..f48f213e 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -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; diff --git a/application/controllers/report.php b/application/controllers/report.php index 5db81fa6..bbd38cd8 100644 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -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); } diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index c113e3c3..a64d7f1c 100644 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -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' ); diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index bf28a512..82b6660f 100644 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -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); diff --git a/application/models/models/assetdetails_model.php b/application/models/models/assetdetails_model.php deleted file mode 100644 index 29514826..00000000 --- a/application/models/models/assetdetails_model.php +++ /dev/null @@ -1,258 +0,0 @@ -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(); - } -} -?> \ No newline at end of file diff --git a/application/models/models/batchcard_model.php b/application/models/models/batchcard_model.php deleted file mode 100644 index 7d39bc35..00000000 --- a/application/models/models/batchcard_model.php +++ /dev/null @@ -1,1685 +0,0 @@ -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 getSupplierlist(){ - - $this->db->select('SupplierName,SupplierID'); - $this->db->from('T_SupplierDetailsN'); - $supp = $this->db->get(); - return $supp->result(); - - } - - - - function Rawsupplier() - { - - $this->db->select('mas.SupplierID,sup.SupplierName,mmas.MaterialCode,mmas.MaterialName'); - $this->db->from('T_PurchaseOrder_Master mas'); - $this->db->join('T_SupplierDetailsN sup','sup.SupplierID=mas.SupplierID'); - $this->db->join('T_PurchaseOrder_LineItem line','line.PONO=mas.PONO'); - $this->db->join('T_MaterialMaster mmas','mmas.MaterialCode=line.MaterialCode'); - $this->db->where('Category','Raw Material'); - $this->db->group_by('SupplierID'); - $supp = $this->db->get(); - - - // print_r($this->db->last_query());die(); - return $supp->result(); - - - } - - - - function Consupplier() - { - $this->db->select('mas.SupplierID,sup.SupplierName'); - $this->db->from('T_PurchaseOrder_Master mas'); - $this->db->join('T_SupplierDetailsN sup','sup.SupplierID=mas.SupplierID'); - $this->db->join('T_PurchaseOrder_LineItem line','line.PONO=mas.PONO'); - $this->db->join('T_MaterialMaster mmas','mmas.MaterialCode=line.MaterialCode'); - $this->db->where('Category','Consumables'); - $this->db->group_by('SupplierID'); - $supp = $this->db->get(); - return $supp->result(); - } - - - - function Pacsupplier() - { - $this->db->select('mas.SupplierID,sup.SupplierName'); - $this->db->from('T_PurchaseOrder_Master mas'); - $this->db->join('T_SupplierDetailsN sup','sup.SupplierID=mas.SupplierID'); - $this->db->join('T_PurchaseOrder_LineItem line','line.PONO=mas.PONO'); - $this->db->join('T_MaterialMaster mmas','mmas.MaterialCode=line.MaterialCode'); - $this->db->where('Category','Packing material'); - $this->db->group_by('SupplierID'); - $supp = $this->db->get(); - return $supp->result(); - - } - - - function getStockValue() - { - $this->db->select('MaterialCode,stock,stockdate'); - $this->db->from('T_MaterialMaster'); - $supp = $this->db->get(); - return $supp->result(); - } - - function saveHourlyBatchInfo($datatostore) - { - $this->db->insert('T_hourly_batch_info',$datatostore); - $res = $this->db->affected_rows(); - - return $res; - } - - function saveDailyBatchCardData($datatostore) - { - $this->db->insert('T_daily_batchcard_data',$datatostore); - $res = $this->db->affected_rows(); - return $res; - } - - function updateHourlyBatchInfo($datatostore,$hid) - { - $this->db->where('hourlyid',$hid); - $this->db->update('T_hourly_batch_info',$datatostore); - $res = $this->db->affected_rows(); - - return $res; - } - - function getAllHourlyData($hid='',$from='',$to='') - { - //echo "Model".$from.'-'.$to; - - $this->db->select('T_hourly_batch_info.*,T_Employee_Details.FirstName as F,T_Employee_Details.LastName as L'); - $this->db->from('T_hourly_batch_info'); - $this->db->join('tbl_users','T_hourly_batch_info.checkedby=tbl_users.userId'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID'); - if(!empty($hid)) - { - $this->db->where('hourlyid',$hid); - } - if(!empty($from) && !empty($to)) - { - $this->db->where('T_hourly_batch_info.report_date <=',$to); - $this->db->where('T_hourly_batch_info.report_date >=',$from); - } - $this->db->order_by('hourlyid','desc'); - $res = $this->db->get(); - //print_r($res->result());die(); - return $res->result(); - } - - - function checkExistHourlyData($bdate,$btime) - { - //echo 'Model'.$bdate.'-'.$btime; - $this->db->select('count(*) as count'); - $this->db->from('T_hourly_batch_info'); - $this->db->where('report_date',$bdate); - $this->db->where('report_time',$btime); - $res = $this->db->get(); - return $res->result(); - } - - - function getPowerConsumptionDetails($rdate) - { - - $this->db->select('hourlyid,report_time,opening_trp_reading,close_trp_reading,auto_start,auto_stop'); - $this->db->from('T_hourly_batch_info'); - $this->db->where('report_date',$rdate); - $res = $this->db->get(); - return $res->result(); - } - - function getDailyBatchCardData($month) - { - // $this->db->select('*'); - // $this->db->from('T_daily_batchcard_data'); - // $this->db->where('month(ddate)',$month); - $sql = 'select T_daily_batchcard_data.*,T_Employee_Details.FirstName,T_Employee_Details.LastName from T_daily_batchcard_data - join tbl_users on T_daily_batchcard_data.createdby = tbl_users.userId - join T_Employee_Details on T_Employee_Details.EmpID = tbl_users.EmpID - where month(ddate) = ?'; - $res = $this->db->query($sql,array($month)); - return $res->result(); - } - - function getIndividualDailyData($did) - { - - $this->db->select('*'); - $this->db->from('T_daily_batchcard_data'); - $this->db->where('dailyid',$did); - $res = $this->db->get(); - return $res->result(); - - } - - function checkExistDaily($rdate) - { - $this->db->select('count(*) as count'); - $this->db->from('T_daily_batchcard_data'); - $this->db->where('ddate',$rdate); - $res = $this->db->get(); - return $res->result(); - } - - function updateDailyBatchCardData($datatostore,$did) - { - $this->db->where('dailyid',$did); - $this->db->update('T_daily_batchcard_data',$datatostore); - $res = $this->db->affected_rows(); - - return $res; - } - - function checkAbstractReport($date) - { - $this->db->select('count(*) as count'); - $this->db->from('T_abstract_report'); - //$this->db->where('abstract_report_date',$date); - $this->db->where("date_format(abstract_report_date,'%Y-%m')",$date); - $res = $this->db->get(); - return $res->result(); - } - - function saveAbstractReport($datatostore) - { - $this->db->insert('T_abstract_report',$datatostore); - $res = $this->db->affected_rows(); - return $res; - } - - function updateAbstractReport($datatostore,$date,$abstract_details) - { - //$this->db->where('abstract_report_date',$date); - $this->db->where("date_format(abstract_report_date,'%Y-%m')",$date); - $this->db->where('abstract_details',$abstract_details); - $this->db->update('T_abstract_report',$datatostore); - $res = $this->db->affected_rows(); - - return $res; - - } - - function getPreviousMonthAbstractDetails($month,$year) - { - //$sql = "select abstract_details,close_stock from T_abstract_report where month(abstract_report_date) =? and year(abstract_report_date) =? "; - $sql = "select abstract_details,close_stock as Available from T_abstract_report where month(abstract_report_date) =? and year(abstract_report_date) =? "; - $res = $this->db->query($sql,array($month,$year)); - return $res->result(); - - } - - function getMonthAbstractDetails($month_year) - { - $sql = "select abstract_details,close_stock,open_stock as Available,physical_stock from T_abstract_report where date_format(abstract_report_date,'%Y-%m') = ? "; - $res = $this->db->query($sql,array($month_year)); - - return $res->result(); - } - - function getPreviousMonthClosedStockDetails($y,$m,$sn) - { - $month = 'month(ddate)'; - $year = 'year(ddate)'; - //$this->db->select($sn); - $this->db->select($sn,'ddate'); - $this->db->from('T_daily_batchcard_data'); - $this->db->where($month,$m); - $this->db->where($year,$y); - $this->db->order_by('ddate','desc'); - $this->db->limit(1); - $res = $this->db->get(); - //print_r($res->result()); - return $res->result(); - } - - function currentMonthStockDetails($m,$y,$sd1,$sd2) - { - $month = 'month(ddate)'; - $year = 'year(ddate)'; - $list = array('ddate',$sd1,$sd2); - $this->db->select($list); - $this->db->from('T_daily_batchcard_data'); - $this->db->where($month,$m); - $this->db->where($year,$y); - $this->db->order_by('ddate','asc'); - $res = $this->db->get(); - //print_r($res->result()); - return $res->result(); - } - - function addmaint_dtl($array) - { - // $this->db->insert('T_Batchcard_MaintanceDetails',$array); - // $bmd = $this->db->affected_rows(); - // return $bmd; - - $this->db->insert('T_Batchcard_MaintanceDetails',$array); - $bmd = $this->db->affected_rows(); - - - if($bmd>0) - { - $this->db->select('max(Maint_ID) as Maint_ID'); - $this->db->from('T_Batchcard_MaintanceDetails'); - $res = $this->db->get(); - return $res->result(); - } - } - function getmaint_dtl($fdate,$tdate,$type ) - { - - - $this->db->select('BMD.*'); - // $this->db->select() - $this->db->select('CONCAT(ED1.FirstName, " - " , ED1.LastName) AS Approver_Name', FALSE); - $this->db->select('CONCAT(ED2.FirstName, " - " , ED2.LastName) AS Worker_Name', FALSE); - $this->db->from('T_Batchcard_MaintanceDetails BMD'); - - $this->db->join('T_Employee_Details ED1', 'ED1.EmpID = BMD.Approved_By', 'left'); - $this->db->join('T_Employee_Details ED2', 'ED2.EmpID = BMD.WorkDone_By', 'left'); - - - - if ($fdate and $tdate != ''){ - - - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - - $date = "date(BMD.CreatedOn) >= '".$fromdate."' - and date( BMD.CreatedOn) <= '". $todate."'"; - $this->db->where($date); - } - - if($type!=""){ - - $this->db->where("BMD.type" ,$type); - - - } - $bmd = $this->db->get(); - return $bmd->result(); - } - - - - function getmaint_dtl_MntID($MntID) - { - - $this->db->select('*'); - $this->db->from('T_Batchcard_MaintanceDetails'); - $this->db->where('Maint_ID',$MntID); - $bmd = $this->db->get(); - return $bmd->result(); - } - - function updatemaint_dtl($array,$MntID) - { - $this->db->where('Maint_ID',$MntID); - $this->db->update('T_Batchcard_MaintanceDetails',$array); - $bmd = $this->db->affected_rows(); - - return $bmd; - } - - function maintenancesdata($date){ - - $this->db->select("bm.*,mm.Machine_Name"); - $this->db->select("DATE_FORMAT(bm.CreatedOn,'%d-%m-%Y') AS date", FALSE); - $this->db->select("DATE_FORMAT(bm.CreatedOn,'%l:%i %p') AS time", FALSE); - $this->db->select("CONCAT(ED1.FirstName, ' - ' , ED1.LastName) AS Approver_Name", FALSE); - $this->db->select("CONCAT(ED2.FirstName, ' - ' , ED2.LastName) AS Worker_Name", FALSE); - $this->db->from("T_Batchcard_MaintanceDetails bm"); - $this->db->join("T_Machine_Master mm", "bm.Machine_Code = mm.Machine_Code", "left"); - $this->db->join("T_Employee_Details ED1", "bm.Approved_By = ED1.EmpID", "left"); - $this->db->join("T_Employee_Details ED2", "bm.WorkDone_By = ED2.EmpID", "left"); - $this->db->where("mm.Machines_Category = 'TRP'"); - //AND DATE_FORMAT(bm.CreatedOn,'%Y-%m-%d') = '19-04-2018' - $this->db->where("DATE_FORMAT(bm.CreatedOn,'%d-%m-%Y')",$date); - $bmd = $this->db->get(); - return $bmd->result(); - - //print_r($this->db->last_query()); - //die(); - - } - - function getmachine_codename(){ - $this->db->select('Machine_Code,Machine_Name'); - $this->db->from('T_Machine_Master'); - $res = $this->db->get(); - return $res->result(); - } - - /** Machines History/Master */ - function getdept_dtls() - { - $this->db->select('T_DepartmentDetails.DEPCode,T_DepartmentDetails.shortName'); - $this->db->from('T_DepartmentDetails'); - $this->db->where('IsActive',1); - $res = $this->db->get(); - return $res->result(); - } - - function getpono(){ - - $this->db->select('PONO'); - $this->db->from('T_PurchaseOrder_Master'); - $this->db->where('Status','ST026'); - $res = $this->db->get(); - return $res->result(); - } - - function getpo_dtls($pono){ - - // $this->db->select('T_PurchaseOrder_Master.PONO,T_PurchaseOrder_Master.SupplierID,T_SupplierDetailsN.SupplierName,DATE_FORMAT(T_PurchaseOrder_Master.PODate,"%d-%m-%Y") as PO_Date'); - // $this->db->from('T_PurchaseOrder_Master'); - // $this->db->join('T_SupplierDetailsN','T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID'); - // $this->db->where('PONO',$pono); - // $res = $this->db->get(); - // return $res->result(); - $sql = "select T_PurchaseOrder_Master.PONO,T_PurchaseOrder_Master.SupplierID,T_SupplierDetailsN.SupplierName,DATE_FORMAT(T_PurchaseOrder_Master.PODate,'%d-%m-%Y') as PO_Date - from T_PurchaseOrder_Master - join T_SupplierDetailsN on T_PurchaseOrder_Master.SupplierID=T_SupplierDetailsN.SupplierID - where PONO = ? "; - $res = $this->db->query($sql,array($pono)); - return $res->result(); - - } - - function addhist_mstr($array) - { - $this->db->insert('T_Machine_Master',$array); - $mstr = $this->db->affected_rows(); - //print_r($this->db->last_query()); - //print_r($mstr); - if($mstr>0) - { - - $this->db->select('max(Machine_Code) as Machine_Code'); - $this->db->from('T_Machine_Master'); - $res = $this->db->get(); - //print_r($res->result()); - return $res->result(); - - - - - - } - - } - function addhist_dtl($array){ - - $this->db->insert('T_Machine_Details',$array); - $child = $this->db->affected_rows(); - return $child; - - } - //This function for multi file upload option (both machine and maint/br screen) - function addfiledetails($array){ - - $this->db->insert('T_Machines_file', $array); - $r = $this->db->affected_rows(); - return $r; - //return TRUE; - - } - function insertvalueintoconfig($config){ - - $this->db->insert('T_ConfigDetails', $config); - return TRUE; - } - - //This function used to get the material category using configdetails table - function getmachineCategory($MaterialCategory = '') - { - $Config_ID = 'C028'; - $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(); - } - - - function getHist_dtls($MachineCode = '') - { - - $this->db->select('*'); - $this->db->from('T_Machine_Details'); - if($MachineCode != '') - { - $this->db->where('Machine_Code',$MachineCode ); - } - $bmd = $this->db->get(); - return $bmd->result(); - } - - //This function for multi file upload option (both machine and maint/br screen) - function getfiledetails($data = '') - { - - $this->db->select('*'); - $this->db->from('T_Machines_file'); - if($data != '') - { - $this->db->where('Machine_code/Maint_id',$data ); - } - $bmd = $this->db->get(); - return $bmd->result(); - } - - function getHist_mstr($MachineCode = '') - { - - $this->db->select('*'); - $this->db->from('T_Machine_Master'); - if($MachineCode != '') - { - $this->db->where('Machine_Code',$MachineCode ); - } - $bmd = $this->db->get(); - return $bmd->result(); - } - - // function getHist_dtlsID($MntID) - // { - - // $this->db->select('*'); - // $this->db->from('T_Batchcard_MaintanceDetails'); - // $this->db->where('Maint_ID',$MntID); - // $bmd = $this->db->get(); - // return $bmd->result(); - // } - - // function getHist_dtlsDate($dateval) - // { - - // $this->db->select('*'); - // $this->db->from('T_Batchcard_MaintanceDetails'); - // $this->db->where('Maint_Date',$dateval); - // $bmd = $this->db->get(); - // return $bmd->result(); - // } - - - function edithist_mstr($array,$machinecode){ - - $this->db->where('Machine_Code',$machinecode ); - $this->db->update('T_Machine_Master',$array); - $mstr = $this->db->affected_rows(); - if($mstr>0) - { - - $this->db->select('max(Machine_Code) as Machine_Code'); - $this->db->from('T_Machine_Master'); - $res = $this->db->get(); - return $res->result(); - } - - } - - function edithist_dtl($array,$machinecode){ - $this->db->where('Machine_Code',$machinecode ); - $this->db->update('T_Machine_Details',$array); - $mdtl = $this->db->affected_rows(); - return $mdtl; - } - - function updatefilelist($array,$fileid){ - - $this->db->where('File_No',$fileid); - $this->db->update('T_Machines_file', $array); - $ar = $this->db->affected_rows(); - return $ar; - - } - - function checkMachineCategory($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[] = '' ; - - $this->db->distinct(); - $this->db->select('ConfigValue'); - $this->db->from('T_ConfigDetails'); - $this->db->where('Config_ID','C028'); - $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; - } - - //This function for multi file upload option (both machine and maint/br screen) - function deletefiledetails($id,$name){ - $sql = "DELETE FROM T_Machines_file WHERE File_No =".$id; - unlink("uploads/images/".$name);//this deletes the file on particular folder too - $query = $this->db->query($sql); - $ar = $this->db->affected_rows(); - return $ar; - } - - - function getHist_tbls($MachineCode){ - - $this->db->select('T_Machine_Master.*,T_Batchcard_MaintanceDetails.*,T_DepartmentDetails.DepartmentName'); - $this->db->select("DATE_FORMAT(T_Batchcard_MaintanceDetails.CreatedOn,'%d-%m-%Y') AS date", FALSE); - $this->db->select("DATE_FORMAT(T_Batchcard_MaintanceDetails.CreatedOn,'%l:%i %p') AS time", FALSE); - $this->db->select("CONCAT(ED1.FirstName, ' - ' , ED1.LastName) AS Approver_Name", FALSE); - $this->db->select("CONCAT(ED2.FirstName, ' - ' , ED2.LastName) AS Worker_Name", FALSE); - $this->db->from('T_Machine_Master'); - $this->db->join('T_Batchcard_MaintanceDetails','T_Batchcard_MaintanceDetails.Machine_Code=T_Machine_Master.Machine_Code'); - $this->db->join('T_DepartmentDetails','T_DepartmentDetails.DEPCode=T_Machine_Master.Machines_Dept'); - $this->db->join('T_Employee_Details ED1', 'ED1.EmpID = T_Batchcard_MaintanceDetails.Approved_By', 'left'); - $this->db->join('T_Employee_Details ED2', 'ED2.EmpID = T_Batchcard_MaintanceDetails.WorkDone_By', 'left'); - $this->db->where('T_Machine_Master.Machine_Code',$MachineCode); - $res = $this->db->get(); - return $res->result(); - - // $sql = "SELECT T_Machine_Master.*,T_Batchcard_MaintanceDetails.*, - // T_DepartmentDetails.DepartmentName, - // DATE_FORMAT(T_Batchcard_MaintanceDetails.CreatedOn, '%d-%m-%Y') as date, - // DATE_FORMAT(T_Batchcard_MaintanceDetails.CreatedOn, '%l:%i %p') as time, - // FROM T_Machine_Master - // LEFT JOIN T_Batchcard_MaintanceDetails ON T_Batchcard_MaintanceDetails.Machine_Code=T_Machine_Master.Machine_Code - // LEFT JOIN T_DepartmentDetails ON T_DepartmentDetails.DEPCode=T_Machine_Master.Machines_Dept - // WHERE T_Machine_Master.Machine_Code = '".$MachineCode."'" ; - // $res = $this->db->query($sql); - // return $res->result(); - - } - - - - - - function getinvoice_products() - { - - $this->db->select('product_id,product_name,product_description'); - $this->db->from('ip_products'); - $supp = $this->db->get(); - return $supp->result(); - - } - - function get_consumablematerials() - { - - $this->db->select('MaterialCode,MaterialName,'); - $this->db->from('T_MaterialMaster'); - //$this->db->where('T_MaterialMaster.Category',Consumables); - $this->db->where('T_MaterialMaster.Category like','%Consumable%'); - $supp = $this->db->get(); - return $supp->result(); - - } - - - function get_rawmaterials() - { - $this->db->select('MaterialCode,MaterialName,'); - $this->db->from('T_MaterialMaster'); - $this->db->where('T_MaterialMaster.Category like','%Raw Material%'); - $supp = $this->db->get(); - //print_r($this->db->last_query()); - return $supp->result(); - } - - - function get_packmaterials() - { - $this->db->select('MaterialCode,MaterialName,'); - $this->db->from('T_MaterialMaster'); - // $this->db->where('T_MaterialMaster.Category',Packingmaterial); - $this->db->where('T_MaterialMaster.Category like','%Packing%'); - $supp = $this->db->get(); - return $supp->result(); - } - - - function GetReclamationMaterial() - { - - $this->db->select('product_id,product_name,product_description'); - $this->db->from('ip_products'); - $this->db->join('ip_families','ip_families.family_id=ip_products.family_id'); - // $this->db->where('T_MaterialMaster.Category',Packingmaterial); - $this->db->where('ip_families.family_name like','%Reclam%'); - $supp = $this->db->get(); - return $supp->result(); - - } - - - function getMaterial() - { - $this->db->select('MaterialCode,MaterialName,'); - $this->db->from('T_MaterialMaster'); - //$this->db->where('T_MaterialMaster.Category',Consumables); - $supp = $this->db->get(); - return $supp->result(); - } - - - - function GettotalQty($MaterialCode,$date) - { - echo $model; - $dt = date('d',strtotime($date)); - $year = date('Y', strtotime($date)); - $month = date('m', strtotime($date)); - if($month<04) - { - //echo "b4finance"; - $newyr = $year - 1; - $startdate = $newyr.'-'.'04'.'-'.'01'; - - //echo $startdate; - } - else - { - //echo "after Finance"; - $startdate = $year.'-'.'04'.'-'.'01'; - // echo $startdate; - } - - $nedt= $dt; - - $newdate=$year.'-'.$month.'-'.$nedt; - - $subQuery='select T_MaterialMaster.MaterialName,T_Material_stock_history.MaterialCode,ifnull((select ifnull(sum(Quantity),0) as AddQty from T_Material_stock_history -where Transaction_type = "Add" and MaterialCode=?),0) as Addqty, -ifnull((select ifnull(sum(Quantity),0) as ReduceQty from T_Material_stock_history where Transaction_type = "Reduce" -and MaterialCode=?),0) as ReduceQty from T_Material_stock_history join T_MaterialMaster on T_Material_stock_history.MaterialCode=T_MaterialMaster.MaterialCode where T_Material_stock_history.MaterialCode=? -and CreatedOn >= ? and CreatedOn<=? group by Addqty'; - - $query = $this->db->query($subQuery,array($MaterialCode,$MaterialCode,$MaterialCode,$startdate,$newdate)); - //print_r($this->db->last_query()); - return $query->result_array(); - - - } - - - function GetNetQty($MaterialCode,$date,$Supplier) - { - //echo $date; - $dt = date('d',strtotime($date)); - $year = date('Y', strtotime($date)); - $month = date('m', strtotime($date)); - - if($month<04) - { - //echo "b4finance"; - $newyr = $year - 1; - $startdate = $newyr.'-'.'04'.'-'.'01'; - - //echo $startdate; - } - - else - { - //echo "after Finance"; - $startdate = $year.'-'.'04'.'-'.'01'; - // echo $startdate; - } - - $nedt= $dt+1; - - $newdate=$year.'-'.$month.'-'.$nedt; - - -// $subQuery='select (select sum(Quantity) as AddQty from T_Material_stock_history where Transaction_type = "Add" and MaterialCode=? -// ) as Addqty,(select sum(Quantity) as ReduceQty from T_Material_stock_history where Transaction_type = "Reduce" and MaterialCode=? -// ) as ReduceQty from T_Material_stock_history where MaterialCode=? and CreatedOn >= ? and CreatedOn<=? and SupplierID=? group by Addqty'; - - - $subQuery='select ifnull((select ifnull(sum(Quantity),0) as AddQty from T_Material_stock_history -where Transaction_type = "Add" and MaterialCode=? and SupplierID=? ),0) as Addqty, -ifnull((select ifnull(sum(Quantity),0) as ReduceQty from T_Material_stock_history where Transaction_type = "Reduce" -and MaterialCode=? and SupplierID=? ),0) as ReduceQty from T_Material_stock_history where MaterialCode=? -and CreatedOn >= ? and CreatedOn<=? and SupplierID=? group by Addqty'; - - $query = $this->db->query($subQuery,array($MaterialCode,$Supplier,$MaterialCode,$Supplier,$MaterialCode,$startdate,$newdate,$Supplier)); - //print_r($this->db->last_query()); - return $query->result_array(); - - - } - - - function GetMaterialHistory($AdjustmentId) - { - $this->db->select('T_Material_Adjustment.*,SupplierName,MaterialName'); - $this->db->from('T_Material_Adjustment'); - $this->db->join('T_SupplierDetailsN',"T_SupplierDetailsN.SupplierID=T_Material_Adjustment.SupplierID"); - $this->db->join('T_MaterialMaster',"T_MaterialMaster.MaterialCode=T_Material_Adjustment.MaterialCode"); - $this->db->where('T_Material_Adjustment.AdjustmentId',$AdjustmentId); - $supp = $this->db->get(); - return $supp->result(); - - join("T_Machine_Master mm", "bm.Machine_Code = mm.Machine_Code", "left"); - } - - - - - function AddmaterialAdjustment($adjustmentaarray) - { - $this->db->trans_start(); - $this->db->insert('T_Material_Adjustment',$adjustmentaarray); - $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(AdjustmentId) as AdjustmentId from T_Material_Adjustment'; - $query = $this->db->query($subQuery); - - return $query->result(); - } - } - - - function AddMaterialHistory($historytable) - { - $this->db->trans_start(); - $this->db->insert('T_Material_stock_history',$historytable); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - - } - - - function insert_final_product($final_master) - { - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_Master',$final_master); - $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(FPId) as PId from T_FinalProduct_Master'; - $query = $this->db->query($subQuery); - - return $query->result(); - } - } - - - function save_finalraw($rawarray) - { - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_RawMaterials',$rawarray); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - - } - - - function save_finalcon($conarray) - { - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_ConsumableMaterials',$conarray); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - } - - function save_finalpacking($packarray) - { - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_PackingMaterials',$packarray); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - } - - - function save_finalcoproduct($coparray) - { - - //print_r($coparray); - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_CoProduct_Materials',$coparray); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - } - - - function getAllMaterialAdjustments() - { - $this->db->select('T_Material_Adjustment.*,SupplierName,MaterialName'); - $this->db->from('T_Material_Adjustment'); - $this->db->join('T_SupplierDetailsN', 'T_Material_Adjustment.SupplierID = T_SupplierDetailsN.SupplierID'); - $this->db->join('T_MaterialMaster', 'T_MaterialMaster.MaterialCode = T_Material_Adjustment.MaterialCode'); - $res = $this->db->get(); - return $res->result(); - } - - - - - function save_rawmaterialto_materialHistory($materialhistory) - { - $this->db->trans_start(); - $this->db->insert('T_Material_stock_history',$materialhistory); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - } - - - function getFinalProductDetaisl() - { - $this->db->select('T_FinalProduct_Master.*,product_name,product_description'); - $this->db->from('T_FinalProduct_Master'); - $this->db->join('ip_products','ip_products.product_id=T_FinalProduct_Master.MaterialCode'); - $this->db->order_by('T_FinalProduct_Master.FPId','desc'); - $res = $this->db->get(); - return $res->result(); - - } - - - function getmasterProductDetails($FPId) - { - $this->db->select('T_FinalProduct_Master.*,product_name,product_description'); - $this->db->from('T_FinalProduct_Master'); - $this->db->join('ip_products','ip_products.product_id=T_FinalProduct_Master.MaterialCode'); - $this->db->where('T_FinalProduct_Master.FPId',$FPId); - $res = $this->db->get(); - return $res->result(); - } - - - function getrawmaterialDetails($FPId) - { - $this->db->select('T_FinalProduct_RawMaterials.*,SupplierName,MaterialName'); - $this->db->from('T_FinalProduct_RawMaterials'); - $this->db->join('T_MaterialMaster','T_MaterialMaster.MaterialCode=T_FinalProduct_RawMaterials.MaterialCode'); - $this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=T_FinalProduct_RawMaterials.SupplierID'); - $this->db->where('T_FinalProduct_RawMaterials.FPId',$FPId); - $res = $this->db->get(); - return $res->result(); - } - - - function getconsumaterialDetails($FPId) - { - $this->db->select('T_FinalProduct_ConsumableMaterials.*,SupplierName,MaterialName'); - $this->db->from('T_FinalProduct_ConsumableMaterials'); - $this->db->join('T_MaterialMaster','T_MaterialMaster.MaterialCode=T_FinalProduct_ConsumableMaterials.MaterialCode'); - $this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=T_FinalProduct_ConsumableMaterials.SupplierID'); - $this->db->where('T_FinalProduct_ConsumableMaterials.FPId',$FPId); - $res = $this->db->get(); - return $res->result(); - } - - - function getpackagematerialDetails($FPId) - { - $this->db->select('T_FinalProduct_PackingMaterials.*,SupplierName,MaterialName'); - $this->db->from('T_FinalProduct_PackingMaterials'); - $this->db->join('T_MaterialMaster','T_MaterialMaster.MaterialCode=T_FinalProduct_PackingMaterials.MaterialCode'); - $this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=T_FinalProduct_PackingMaterials.SupplierID'); - $this->db->where('T_FinalProduct_PackingMaterials.FPId',$FPId); - $res = $this->db->get(); - return $res->result(); - } - - - function getcoproductmaterial($FPId) - { - $subQuery ='select T_FinalProduct_CoProduct_Materials.*,product_name - from T_FinalProduct_CoProduct_Materials - join ip_products on ip_products.product_id = T_FinalProduct_CoProduct_Materials.MaterialCode - where T_FinalProduct_CoProduct_Materials.FPId=?'; - - $query = $this->db->query($subQuery,array($FPId)); - - return $query->result_array(); - - } - - - function update_final_product($final_master,$FPId) - { - //print_r($final_master); - $this->db->where('FPId', $FPId); - $this->db->update('T_FinalProduct_Master', $final_master); - $insert_id = $this->db->affected_rows(); - //return TRUE; - if($insert_id>0) - { - $subQuery = 'select max(FPId) as FPId from T_FinalProduct_Master'; - - $query = $this->db->query($subQuery,array()); - - return $query->result_array(); - } - } - - - - function GetRawid($rawilneno) - { - $this->db->select('*'); - $this->db->from('T_FinalProduct_RawMaterials'); - $this->db->where('RawId',$rawilneno); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - - - - function Getconsuid($consuline) - { - $this->db->select('*'); - $this->db->from('T_FinalProduct_ConsumableMaterials'); - $this->db->where('ConId',$consuline); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - - - function Getpackid($packlineId) - { - - $this->db->select('*'); - $this->db->from('T_FinalProduct_PackingMaterials'); - $this->db->where('PackId',$packlineId); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - - - function Getcopid($coplineId) - { - $this->db->select('*'); - $this->db->from('T_FinalProduct_CoProduct_Materials'); - $this->db->where('CoId',$coplineId); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - - } - - - function update_finalraw($rawarray,$rawilneno) - { - $this->db->where('RawId', $rawilneno); - $this->db->update('T_FinalProduct_RawMaterials', $rawarray); - return TRUE; - } - - - function GetRawCheck($rawmaterial,$final_product_id) - { - $this->db->select('*'); - $this->db->from('T_Material_stock_history'); - $this->db->where('MaterialCode',$rawmaterial); - $this->db->where('Ref_No',$final_product_id); - $this->db->where('Ref_Type',FinalProduct); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - - - function update_rawmaterialto_materialHistory($rawmaterialhistory,$rawmaterial,$FPID) - { - $this->db->where('Ref_No', $FPID); - $this->db->where('MaterialCode', $rawmaterial); - $this->db->update('T_Material_stock_history', $rawmaterialhistory); - return TRUE; - } - - - function update_finalconsu($conarray,$consuline) - { - $this->db->where('ConId', $consuline); - $this->db->update('T_FinalProduct_ConsumableMaterials', $conarray); - return TRUE; - } - - - function update_finalpacking($conarray,$packlineId) - { - $this->db->where('PackId', $packlineId); - $this->db->update('T_FinalProduct_PackingMaterials', $conarray); - return TRUE; - } - - - function update_finalcoproduct($coparray,$coplineId) - { - $this->db->where('CoId', $coplineId); - $this->db->update('T_FinalProduct_CoProduct_Materials', $coparray); - return TRUE; - } - function getEditMaterialAdjustments($AdjustmentId) - { - - $this->db->select('T_Material_Adjustment.*,SupplierName,MaterialName,Description,AdjustmentId,ActualQuantity,T_Material_stock_history.Quantity,Ref_Type,Transaction_type'); - $this->db->from('T_Material_Adjustment'); - $this->db->join('T_Material_stock_history', 'T_Material_Adjustment.AdjustmentId = T_Material_stock_history.Ref_No and T_Material_stock_history.Ref_Type="Adjust"'); - $this->db->join('T_SupplierDetailsN', 'T_Material_Adjustment.SupplierID = T_SupplierDetailsN.SupplierID'); - $this->db->join('T_MaterialMaster', 'T_MaterialMaster.MaterialCode = T_Material_Adjustment.MaterialCode'); - $this->db->where('T_Material_Adjustment.AdjustmentId',$AdjustmentId); - $res = $this->db->get(); - return $res->result(); - } - function material_name(){ - $sql="SELECT distinct MaterialName FROM T_MaterialMaster;"; - $query = $this->db->query($sql); - return $query->result(); - } - function getMaterial_history($prod,$frm,$t) - { - $sql="SELECT msh.StockId,sd.SupplierName,mm.MaterialName,msh.Transaction_type,msh.Ref_Type,msh.Ref_No,msh.Quantity,msh.ItemValue,date_format(msh.UpdatedOn,'%d-%m-%Y') as updatedOn FROM T_Material_stock_history as msh - left join T_SupplierDetailsN as sd on sd.SupplierID=msh.SupplierID - left join T_MaterialMaster as mm on mm.MaterialCode=msh.MaterialCode - where msh.StockId != 'null' "; - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - - $sql.="and date(msh.UpdatedOn) >= '".$fromd."' - and date(msh.UpdatedOn) <= '".$tod."'"; - - } - - - $query =$this->db->query($sql); - return $query->result(); - - - } - //created by TamilBala - //for update quantity stockhistory - function updateQuantityStockHistory($updatequantity,$id) - { - - $this->db->where('Ref_No',$id); - $this->db->where('Ref_Type',Adjust); - $this->db->update('T_Material_stock_history',$updatequantity); - $r = $this->db->affected_rows(); - //return $r->result(); - //echo "HIS"; - - } - - //created by TamilBala - //for update quantity T_Material_Adjustment - - function updateQuantityAdjusment($updatequantitydes,$id) - { - $this->db->where('AdjustmentId',$id); - $this->db->update('T_Material_Adjustment',$updatequantitydes); - $r = $this->db->affected_rows(); - return $r; - - } - //created by TamilBala - //for update isactive T_Material_Adjustment - function updateisactiveadjusment($Updateactive,$AdjustmentId) - { - $this->db->where('AdjustmentId',$AdjustmentId); - $this->db->update('T_Material_Adjustment',$Updateactive); - $r = $this->db->affected_rows(); - return $r; - - } - - //created by TamilBala - //for update isactive stockhistory - function updateisactiveastockhistory($Updateactive,$AdjustmentId) - { - $this->db->where('Ref_No',$AdjustmentId); - $this->db->where('Ref_Type',Adjust); - $this->db->update('T_Material_stock_history',$Updateactive); - $r = $this->db->affected_rows(); - return $r; - } - - - -// function GetFinishedProductList($starting_date,$end_date,$product_id) -// { - - -// $subQuery ='select ip_products.product_id,ip_products.product_name,ip_invoices.invoice_id,ip_invoice_items.item_quantity,ip_invoice_items.item_price,ip_invoices.invoice_number as IDnumber,ip_invoices.receivedstatus as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id join ip_invoices on ip_invoice_items.invoice_id = ip_invoices.invoice_id -// join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where (ip_invoices.invoice_date_modified>=? and ip_invoices.invoice_date_modified<=? and ip_invoice_items.item_product_id=?) union - -// select ip_products.product_id,ip_products.product_name,T_FinalProduct_Master.FPId,T_FinalProduct_Master.Quantity,T_FinalProduct_Master.Price,T_FinalProduct_Master.FPId as IDnumber,T_FinalProduct_Master.ProductType as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id -// join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where -// (T_FinalProduct_Master.ProductDate<=? and T_FinalProduct_Master.ProductDate>=? and T_FinalProduct_Master.MaterialCode=?) group by FPId'; - -// $query = $this->db->query($subQuery,array($starting_date,$end_date,$product_id,$end_date,$starting_date,$product_id)); - -// //print_r($this->db->last_query()); - - -// return $query->result_array(); - - -// } - - -function GetFinishedProductList($starting_date,$end_date,$product_id) -{ - - - // $subQuery = 'select * from T_FinalProduct_History,ip_products.product_name - // join ip_products on T_FinalProduct_History.ProductCode = ip_products.product_id - - // where ProductCode=? - // and Transactiondate >= ? and Transactiondate <= ?'; - - $subQuery='select RefID,ProductCode,product_description,Quantity,Price,Transactiondate,TransactionType,product_name -from T_FinalProduct_History -join ip_products on ip_products.product_id= T_FinalProduct_History.ProductCode -where ProductCode=? and Transactiondate >= ? and Transactiondate <= ?'; - - -// $subQuery='select FPId as RefID,product_id as ProductCode,Quantity,product_description,Price,ProductDate as Transactiondate,ProductType as TransactionType,product_name from T_FinalProduct_Master join ip_products on ip_products.product_id= T_FinalProduct_Master.MaterialCode where MaterialCode=? and ProductDate >= ? and ProductDate <= ?'; - - $query = $this->db->query($subQuery,array($product_id,$starting_date,$end_date)); -// print_r($this->db->last_query()); - return $query->result_array(); - -} - - - function SaveFinalHistory($final_history) - { - $this->db->trans_start(); - $this->db->insert('T_FinalProduct_History',$final_history); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return true; - } - - - function UpdateFinalHistory($final_history,$FPID,$rawmaterial) - { - //print_r($final_history); - $this->db->where('RefID', $FPID); - $this->db->where('ProductCode',$rawmaterial); - $this->db->update('T_FinalProduct_History',$final_history); - //print_r($this->db->last_query()); - return TRUE; - } - - function GetAvgPrice($MaterialCode,$date,$Supplier) - { - $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 = ? and SupplierID=?'; - - $query = $this->db->query($subQuery,array($MaterialCode,$Supplier)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - - - - - function Get_Product_Supplier($MaterialCode,$type) - { - //echo $MaterialCode; - $ltype='%'.$type.'%'; - //echo $ltype; - $this->db->select('mas.SupplierID,sup.SupplierName,mmas.MaterialCode,mmas.MaterialName'); - $this->db->from('T_PurchaseOrder_Master mas'); - $this->db->join('T_SupplierDetailsN sup','sup.SupplierID=mas.SupplierID'); - $this->db->join('T_PurchaseOrder_LineItem line','line.PONO=mas.PONO'); - $this->db->join('T_MaterialMaster mmas','mmas.MaterialCode=line.MaterialCode'); - $this->db->where('Category like',$ltype); - - // $this->db->where('T_MaterialMaster.Category like','%Raw Material%'); - $this->db->where('mmas.MaterialCode',$MaterialCode); - $this->db->group_by('SupplierID'); - $supp = $this->db->get(); - - - //print_r($this->db->last_query());die(); - return $supp->result(); - - } - - - - function getSalesProductvalue() - { - $this->db->select('product_id,product_price'); - $this->db->from('ip_products'); - $price = $this->db->get(); - return $price->result(); - } - - - - function finyear(){ - - $sql="SELECT - CASE WHEN MONTH(MaterialRcvdDate)>=4 - THEN concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1) - ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) - END AS financial_year - FROM T_IGR_Master - GROUP BY financial_year"; - $query = $this->db->query($sql); - - // print_r($this->db->last_query());die(); - return $query->result(); - - } - - - - function GetStockAbstract($search) - { - // echo 'in'; - - $fdate = $search['from_date']; - $fromdate = date("Y-m-d", strtotime($fdate) ); - - $tdate = $search['to_date']; - $todate = date("Y-m-d", strtotime($tdate) ); - - $currentyr = date("Y"); - - - - $finyear = $search['year']; - -$pieces = explode("-", $finyear);///fin year -//print_r($search); die(); -$startyr = $pieces['0']; -$endyr = $pieces['1']; - -//echo $search['month'].'-'.$startyr.'-'. $endyr;die(); - -//echo $endyr;die(); - - -$subquery="SELECT - DISTINCT(p.MaterialCode) AS ProductID,Ref_No,Date(CreatedOn),mm.MaterialName,stock,MaterialType,Category,stockdate,mm.Category,ip.product_name,ip.product_id, - SUM(IF(p.Transaction_type='Add',p.Quantity,0)) AS Addition, - SUM(IF(p.Transaction_type='Reduce',p.Quantity,0)) AS Reduce, - SUM((IF(p.Transaction_type='Add',p.Quantity,0))-(IF(p.Transaction_type='Reduce',p.Quantity,0))) AS AvailableStock,ROUND(AVG(Rate),2) as Avg_rate,ROUND(AVG(ItemValue),2) as Final_avg -FROM - T_Material_stock_history AS p -left join T_MaterialMaster mm on mm.MaterialCode = p.MaterialCode - -left join ip_products ip on ip.product_id=p.MaterialCode -left join T_PurchaseOrder_LineItem pol on pol.MaterialCode = mm.MaterialCode - "; - - -if($search['month']=='' && $startyr =='') -{ - - - if($search['from_date'] != '') - { - - $subquery.=" left join (select StockId,pp.MaterialCode mc, -SUM((IF(pp.Transaction_type='Add',Quantity,0))-(IF(pp.Transaction_type='Reduce',Quantity,0))) -AS OpeningStock -FROM T_Material_stock_history AS pp -where pp.CreatedOn < '".$fromdate."' -GROUP BY pp.MaterialCode -) as opens on opens.mc = p.MaterialCode"; - } - - -} - - -else if($search['month']!='' && $startyr !='') -{ - - - - if($search['month']!='') - { - $subquery.=" left join (select StockId,pq.MaterialCode mc, -SUM((IF(pq.Transaction_type='Add',Quantity,0))-(IF(pq.Transaction_type='Reduce',Quantity,0))) -AS OpeningStock -FROM T_Material_stock_history AS pq -where month(pq.CreatedOn) < '".$search['month']."' -GROUP BY pq.MaterialCode -) as opens on opens.mc = p.MaterialCode"; - - } - -} - -else if($search['month']!='' && $startyr =='') -{ - - - - $subquery.=" left join (select StockId,pq.MaterialCode mc, -SUM((IF(pq.Transaction_type='Add',Quantity,0))-(IF(pq.Transaction_type='Reduce',Quantity,0))) -AS OpeningStock -FROM T_Material_stock_history AS pq -where date(pq.CreatedOn) < '".$currentyr.'-'.$search['month']."-01' -GROUP BY pq.MaterialCode -) as opens on opens.mc = p.MaterialCode"; - -} - - -else if($search['month']=='' && $startyr !='' ) -{ - - // if($search['month']!='') - // { - $subquery.=" left join (select StockId,pq.MaterialCode mc, -SUM((IF(pq.Transaction_type='Add',Quantity,0))-(IF(pq.Transaction_type='Reduce',Quantity,0))) -AS OpeningStock -FROM T_Material_stock_history AS pq -where date(pq.CreatedOn) < '".$startyr."-03-31' -GROUP BY pq.MaterialCode -) as opens on opens.mc = p.MaterialCode"; - - // } - -} - - - - -//$subquery.=" where mm.IsActive='1'"; - -if($search['month']=='' && $startyr =='') -{ - - if($search['from_date'] != '') - { - - $subquery.=" where date(p.CreatedOn)>= '".$fromdate."'"; - } - - if($search['to_date'] != '') - { - //$subquery. = " and date(p.CreatedOn)<='".$todate."'"; - - $subquery.=" and date(p.CreatedOn)<= '".$todate."'"; - } - -} - -else -{ - - if($search['month']!='' && $startyr =='') - { - $subquery.=" where date(p.CreatedOn)>= '".$currentyr.'-'.$search['month']."-01' and - - date(p.CreatedOn)<='".$currentyr.'-'.$search['month']."-31'"; - } - - - if($search['month']!='' && $startyr !='') - { - $subquery.=" where month(p.CreatedOn)= '".$search['month']."' and date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'"; - } - - if($startyr !='' && $search['month']=='') - { - $subquery.=" where date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'"; - } - -} - - -$subquery.=" and (mm.Category like '%Consumable%' or mm.Category like '%Raw Material%' - or mm.Category like '%Packing%' or mm.Category like '%Reclam%' or mm.Category like '%Finish%' or mm.Category like '%Final%' )"; - -$subquery.=" GROUP BY p.MaterialCode"; -//$subquery. = "GROUP BY p.MaterialCode"; - -$query = $this->db->query($subquery,array()); - -//print_r($query->result());die(); - -//print_r($this->db->last_query());die(); - - return $query->result(); - - - } - - - - - function GetStockAbstractdetails($search) - { - // echo 'in'; - - $fdate = $search['fdate']; - - if($fdate != '0') - { - $fromdate = date("Y-m-d", strtotime($fdate) ); - } - - else - { - $fromdate =''; - - } - - $tdate = $search['tdate']; - - if($tdate != '0') - { - $todate = date("Y-m-d", strtotime($tdate) ); - } - - else - { - $todate = ''; - } - //echo $todate;die(); - - $finyear = $search['year']; - -$pieces = explode("-", $finyear);///fin year -//print_r($search); die(); -$startyr = $pieces['0']; -$endyr = $pieces['1']; - -//echo $endyr;die(); - - -$subquery="SELECT - DISTINCT(p.MaterialCode) AS ProductID,Ref_No,Date(CreatedOn) as Cdate,mm.MaterialName,stock,MaterialType,Category,stockdate,p.Transaction_type,Ref_Type, Ref_No,ip.product_name,invoice_number, - SUM(IF(p.Transaction_type='Add',Quantity,0)) AS Addition, - SUM(IF(p.Transaction_type='Reduce',Quantity,0)) AS Reduce, - SUM((IF(p.Transaction_type='Add',Quantity,0))-(IF(p.Transaction_type='Reduce',Quantity,0))) AS AvailableStock -FROM - T_Material_stock_history AS p -left join T_MaterialMaster mm on mm.MaterialCode = p.MaterialCode -left join ip_products ip on ip.product_id=p.MaterialCode -left join ip_invoices inv on inv.invoice_id=p.Ref_No -where p.MaterialCode='".$search['materialcode']."' - "; - - - - -if($search['month']=='' && $startyr =='' && $endyr =='') -{ - - if($fromdate != '') - { - - //echo "sv";die(); - - $subquery.=" and date(p.CreatedOn)>= '".$fromdate."'"; - } - - if($todate != '') - { - //$subquery. = " and date(p.CreatedOn)<='".$todate."'"; - - $subquery.=" and date(p.CreatedOn)<= '".$todate."'"; - } - -} - -else -{ - - if($search['month']!='') - { - $subquery.=" and month(p.CreatedOn)>= '".$search['month']."'"; - } - - if($startyr !='' && $endyr !='') - { - $subquery.=" and date(p.CreatedOn)>= '".$startyr."-04-01' and date(p.CreatedOn)<= '".$endyr."-03-31'"; - } - -} - - - - -$subquery.=" GROUP BY p.CreatedOn"; -//$subquery. = "GROUP BY p.MaterialCode"; - -$query = $this->db->query($subquery,array()); -//print_r($this->db->last_query());die(); - - return $query->result(); - - - } - - - - public function GetMaterialCode($itemproductid) - { - $this->db->select('MaterialCode'); - $this->db->from('ip_products'); - $this->db->where('product_id',$itemproductid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - - - public function Delete_ProductBatchCard($FPId) - { - - $this->db->where('FPId', $FPId); - $this->db->delete('T_FinalProduct_ConsumableMaterials'); - - - $this->db->where('FPId', $FPId); - $this->db->delete('T_FinalProduct_CoProduct_Materials'); - - $this->db->where('RefID', $FPId); - $this->db->delete('T_FinalProduct_History'); - - - $this->db->where('FPId', $FPId); - $this->db->delete('T_FinalProduct_Master'); - - - - $this->db->where('FPId', $FPId); - $this->db->delete('T_FinalProduct_PackingMaterials'); - - - $this->db->where('FPId', $FPId); - $this->db->delete('T_FinalProduct_RawMaterials'); - - $this->db->where('Ref_No', $FPId); - $this->db->delete('T_Material_stock_history'); - - return true; - - - } - - - -} - -?> \ No newline at end of file diff --git a/application/models/models/cashbook_model.php b/application/models/models/cashbook_model.php deleted file mode 100644 index 3910c81a..00000000 --- a/application/models/models/cashbook_model.php +++ /dev/null @@ -1,2191 +0,0 @@ -db->where('status',1); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - function getAccountpay() - { - $this->db->where('type',PAYMENT); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - function getAccounTypes1() - { - $this->db->select('name,type'); - $r = $this->db->get('t_accountcode'); - return $r->result(); - - } - - function saveIncomeExpense($data) - { - $this->db->insert('t_income_expense',$data); - $r = $this->db->affected_rows(); - return $r; - } - // function addcashbook($bankcash1) - // { - // $this->db->insert('T_Bankmappingcashbook',$bankcash1); - // $r = $this->db->affected_rows(); - // return $r; - // } - // function amountpaidcashbook() - // { - // $this->db->select('t_accountcode.namea,total,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - // $this->db->from('t_income_expense'); - // $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - // $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - // $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - // $this->db->where('t_income_expense.IsActive',1); - // $this->db->where('t_income_expense.account_code !=','ADV001'); - // $this->db->group_by('t_income_expense.account_code'); - // // $this->db->order_by("date","desc"); - // $r = $this->db->get(); - // return $r->result(); - - // } - function getIncomeExpenseList($i="") - { - // echo $i; - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - // $this->db->where('t_income_expense.account_code !=','ADV001'); - // $this->db->where('t_income_expense.account_code !=','0013'); - $this->db->order_by("date","desc"); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - function getIncomeExpense($firstyear,$secondyear,$frmdt,$todt) - { - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code !=','ADV001'); - $this->db->where('t_income_expense.account_code !=','0013'); - if ($firstyear and $secondyear != '') - { - $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; - $this->db->where($finyear); - } - if ($frmdt and $todt != ''){ - $fromdate= date("Y-m-d",strtotime($frmdt)); - $todate=date("Y-m-d",strtotime($todt)); - $date = "date(t_income_expense.date) >= '".$fromdate."' - and date(t_income_expense.date) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->order_by("date","desc"); - $r = $this->db->get(); - return $r->result(); - } - - function getAdvanceList($i="") - { - // echo $i; - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code','ADV001'); - $this->db->or_where('t_income_expense.account_code','0013'); - $this->db->order_by("date","desc"); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - function getAdvance($firstyear,$secondyear,$frmdt,$todt) - { - $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->where('t_income_expense.IsActive',1); - $this->db->where('t_income_expense.account_code','ADV001'); - $this->db->or_where('t_income_expense.account_code','0013'); - if ($firstyear and $secondyear != ''){ - $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; - $this->db->where($finyear); - } - if ($frmdt and $todt != ''){ - $fromdate= date("Y-m-d",strtotime($frmdt)); - $todate=date("Y-m-d",strtotime($todt)); - $date = "date(t_income_expense.date) >= '".$fromdate."' - and date(t_income_expense.date) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->order_by("date","desc"); - $r = $this->db->get(); - return $r->result(); - } - -function finyear(){ - - - $sql="SELECT - CASE WHEN MONTH(date)>=4 THEN - concat(YEAR(date), '-',YEAR(date)+1) - ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year - FROM t_income_expense - GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - } - function getCompany() - { - $r = $this->db->get('T_Company_Details'); - return $r->result(); - - - } - - function getAccounutInfo($i) - { - $this->db->select('t_accountcode.name,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - $this->db->order_by("date", "desc"); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - - function Selectcash() - { - $this->db->select('*'); - $this->db->from('t_accountcode'); - $query = $this->db->get(); - $result = $query->result(); - return $result; - - } - - - function Selectadvance($i="") - { - // echo $i; - $this->db->select('T_SupplierDetailsN.SupplierName,t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); - $this->db->from('t_income_expense'); - $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); - $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); - $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); - $this->db->join('T_SupplierDetailsN','T_SupplierDetailsN.SupplierID=t_income_expense.Supplier_id' ); - $this->db->order_by("date","desc"); - $this->db->where_in('t_accountcode.code',[AReceipt,Apayment]); - if(!empty($i)) - { - $this->db->where('t_income_expense.id',$i); - - } - $r = $this->db->get(); - return $r->result(); - } - - - function viewdepartment($sid='') - { - $sql="SELECT ie.*,br.*,br.ID,ie.totalbankamount,ac.name,ie.id,date_format(ie.date,'%d-%m-%Y')as date FROM t_income_expense ie - left join t_accountcode ac on ac.code=ie.account_code - left join T_bankreport br on br.ID=ie.bankid - WHERE ie.id = ?"; - $query = $this->db->query($sql,array($sid)); - //print_r($this->db->last_query()); - //echo $sql; - return $query->result(); - } - function deletefile($cashid) - { - - //echo $cashid; - $sql="UPDATE t_income_expense SET document = NULL - WHERE id = ?"; - $query = $this->db->query($sql,array($cashid)); - //print_r($this->db->last_query()); - //echo $sql; - $r = $this->db->affected_rows(); - return $r; - } - - - function updatedepartment($updateaccount,$id1) - { - $this->db->where('id', $id1); - $this->db->update('t_income_expense',$updateaccount); - $r = $this->db->affected_rows(); - return $r; - - } - function bankfile($FileDetails) - { - $this->db->insert('T_bankingfile',$FileDetails); - $r = $this->db->affected_rows(); - return $r; - } - function bankfiledata($filedataupload) - { - - - $this->db->select('reportdate,Narration,Balance'); - $this->db->from('T_bankreport'); - $this->db->where('reportdate',$filedataupload['reportdate']); - $this->db->where('Narration',$filedataupload['Narration']); - $this->db->where('Balance',$filedataupload['Balance']); - - $query = $this->db->get(); - if ($query->num_rows() > 0){ - return true; - - } - else{ - $this->db->insert('T_bankreport', $filedataupload); - $r = $this->db->affected_rows(); - //print_r($this->db->last_query()); - return $r; - } -} - -function balance($balance){ - - - $this ->db->insert('T_bankbalance',$balance); -} - -function getbalancedetails() -{ - -$subquery="SELECT openingbalance,closingbalance FROM T_bankbalance WHERE balance_keyid in (SELECT MAX(balance_keyid) FROM T_bankbalance)"; -$query = $this->db->query($subquery); -return $query->result(); - -} - - - -function report_finyear(){ - - - $sql="SELECT -CASE WHEN MONTH(reportdate)>=4 THEN - concat(YEAR(reportdate), '-',YEAR(reportdate)+1) -ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year -FROM T_bankreport -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} -function report_amountpaid(){ - - - $sql="SELECT -CASE WHEN MONTH(reportdate)>=4 THEN - concat(YEAR(reportdate), '-',YEAR(reportdate)+1) -ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year -FROM T_bankreport -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} -function report_cashbook(){ - - - $sql="SELECT -CASE WHEN MONTH(date)>=4 THEN - concat(YEAR(date), '-',YEAR(date)+1) -ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year -FROM t_income_expense -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} -function report_finyearunpaid(){ - - - $sql="SELECT -CASE WHEN MONTH(MaterialRcvdDate)>=4 THEN - concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1) -ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) END AS financial_year -FROM T_IGR_Master -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} -function report_finyearamountreceived(){ - - - $sql="SELECT -CASE WHEN MONTH(reportdate)>=4 THEN - concat(YEAR(reportdate), '-',YEAR(reportdate)+1) -ELSE concat(YEAR(reportdate)-1,'-', YEAR(reportdate)) END AS financial_year -FROM T_bankreport -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - -} - -function report_finyearamountunreceived(){ - - - $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); - return $query->result(); - - - -} - -function bankstatement($fdate,$tdate,$fa,$aa){ - - $sql="SELECT *,date_format(reportdate,'%d-%m-%Y')as date,tie.total,date_format(valuedate,'%d-%m-%Y')as valuedate from T_bankreport as br left join t_income_expense as tie on tie.bankid=br.ID where br.reportdate !=0 "; - - - if ($fa and $aa != ''){ - - $sql.=" and (reportdate >= '".$fa."-04-01' and reportdate<= '".$aa."-03-31')"; - - } - if ($fdate and $tdate != '') - { - - $fdate= date("Y-m-d",strtotime($fdate)); - $tdate=date("Y-m-d",strtotime($tdate)); - - $sql.= " and date(reportdate) >= '".$fdate."' - and date(reportdate) <= '".$tdate."'"; - } - - $sql.=" group by(br.ID) "; - $sql.=" ORDER BY br.ID+0 DESC "; - - - $query = $this->db->query($sql); - return $query->result(); - - - -} -function cleareddebitbalance(){ - - $sql = "SELECT SUM(Balancetocleared) as debit FROM T_bankreport where Clearbalance >'0'"; - - $query = $this->db->query($sql); - return $query->result(); - - -} -function clearedcreditbalance(){ - - $sql = "SELECT SUM(cbalancetocleared) as credit FROM T_bankreport where cclearbalance >'0'"; - - $query = $this->db->query($sql); - return $query->result(); - -} - - - - - function suppliertotalfilter($fa,$aa,$m,$fdate,$tdate) - { - - - $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, - sum(total) as total,file,ifile - from igr - where status != 'ST030' and PaymentStatus ='ST072'"; - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(MaterialRcvdDate) >= '".$fromd."' - and date(MaterialRcvdDate) <= '".$tod."'"; - - } - - - $sql.="group by sid"; - $query = $this->db->query($sql); - return $query->result(); - - } - - -function amountunpaid($supplierid1,$fa,$aa,$m,$fdate,$tdate) - { - - $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, - sum(total) as total,file,ifile - from igr - where status != 'ST030' and PaymentStatus = 'ST072' and sid='".$supplierid1."'"; - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(MaterialRcvdDate) >= '".$fromd."' - and date(MaterialRcvdDate) <= '".$tod."'"; - - } - - $sql.="group by pono,igrn"; - $query = $this->db->query($sql); - return $query->result(); - } - function amountunpaidfilter($sd,$fa,$aa,$m,$fdate,$tdate) - { - - $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid, - sum(total) as total,file,ifile - from igr - where status != 'ST030' and PaymentStatus ='ST072' and sid='".$sd."'"; - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (MaterialRcvdDate >= '".$fa."-04-01' and MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(MaterialRcvdDate) = '".$m."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(MaterialRcvdDate) >= '".$fromd."' - and date(MaterialRcvdDate) <= '".$tod."'"; - - } - - - $sql.="group by pono,igrn"; - $query = $this->db->query($sql); - return $query->result(); - } - - - function bankinvoice($Customer,$fdate,$tdate) - { - $this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,ic.client_id,BI.balancetoreceived,BI.amountreceived'); - $this->db->from ('ip_invoice_amounts iva'); - $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id'); - $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI','iv.invoice_number = BI.invoiceno and BI.IsActive= 1','left'); - $this->db->where('iv.invoice_status_id','2'); - $this->db->where('iv.receivedstatus !=','ST065'); - // $this->db->where('BI.IsActive',1); - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(iv.invoice_date_created) >= '".$fromdate."' - and date(iv.invoice_date_created) <= '".$todate."'"; - $this->db->where($date); - } - if ($Customer != ''){ - $this->db->where('ic.client_id',$Customer); - } - $this->db->group_by('iva.invoice_id'); - $query = $this->db->get(); - - return $query->result(); - - } - function debitbankstatemet($SupplierName,$fdate,$tdate) - { - - - $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name,sid,Balancetopay,Amountpaid, - sum(total) as total,file,ifile - from bankdebit - where status != 'ST030' and PaymentStatus != 'ST070'"; - - - - if ($SupplierName!= ''){ - - $sql.="and supplier_name = '".$SupplierName."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(MaterialRcvdDate) >= '".$fromd."' - and date(MaterialRcvdDate) <= '".$tod."'"; - - } - - $sql.="group by igrn"; - $query = $this->db->query($sql); - return $query->result(); - - - } - function supplierledger($suppliername,$fdate,$tdate,$fa,$aa,$m) - { - - - $sql="select date,igrn,ID,narration,sid,supplier_name,amountpaid, - sum(total) as total - from ledgersupplier - where ID != 'null' and Status != 'ST030'"; - - - - if ($suppliername!= ''){ - - $sql.="and sid = '".$suppliername."'"; - - } - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(date) = '".$m."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(date) >= '".$fromd."' - and date(date) <= '".$tod."'"; - - - } - - $sql.="group by date asc"; - $query = $this->db->query($sql); - return $query->result(); - - - } - function customerledger($customer,$fdate,$tdate,$fa,$aa,$m) - { - - - $sql="select date,id,amount,invoice_number,invoice_status_id,customername,customerid,payment - from ledgercustomer - where invoice_number != '' "; - - - - if ($customer!= ''){ - - $sql.="and customerid = '".$customer."'"; - - } - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(date) = '".$m."'"; - - } - - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(date) >= '".$fromd."' - and date(date) <= '".$tod."'"; - - - } - - - - - $sql.="order by date asc"; - $query = $this->db->query($sql); - return $query->result(); - - - } - function openingbalance($customer,$fdate,$tdate,$fa,$aa,$m) - { - // echo $customer; - //echo $fdate; - //echo $tdate; - // echo $fa; - // echo $aa; - // echo $m; - // die(); - $sql="select date as date,sum(payment) as payment - from ledgercustomer - where invoice_number != 'null' "; - - - if ($customer!= ''){ - - $sql.="and customerid = '".$customer."'"; - - } - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(date) >= '".$m."'"; - - } - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime('01-04-2018')); - - $sql.="and date(date) >= '".$tod."' - and date(date) <= '".$fromd."'"; - //$sql.="and date('2018-04-01') <= '".$fromd."'"; - - - } - $query = $this->db->query($sql); - // print_r($this->db->last_query()); - // die(); - - return $query->result(); - } - function openingbalancesupplier($customer,$fdate,$tdate,$fa,$aa,$m) - { - - - $sql="select date as date,sum(amountpaid) as amountpaid - from ledgersupplier - where ID != 'null' "; - - - if ($customer!= ''){ - - $sql.="and customerid = '".$customer."'"; - - } - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(date) >= '".$m."'"; - - } - - if ($fdate and $tdate != ''){ - $fromd= date("Y-m-d",strtotime($fdate)); - $tod=date("Y-m-d",strtotime('01-04-2018')); - - $sql.="and date(date) >= '".$tod."' - and date(date) <= '".$fromd."'"; - //$sql.="and date('2018-04-01') <= '".$fromd."'"; - - - } - $query = $this->db->query($sql); - // print_r($this->db->last_query()); - // die(); - - return $query->result(); - } - function receivedamount($Customer,$fdate,$tdate) - { - // $status='ST065'; - // $this->db->distinct(); - $this->db->select('BI.balancetoreceived,BI.amountreceived'); - $this->db->from ('T_Bankinvoicereport BI'); - //$this->db->where('BI.IsActive',1); - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(BI.BankDate) >= '".$fromdate."' - and date(BI.BankDate) <= '".$todate."'"; - $this->db->where($date); - } - if ($Customer != ''){ - $this->db->where('BI.client_id',$Customer); - } - $this->db->group_by('BI.invoiceno'); - //$this->db->where('inc.type','PAYMENT'); - //print_r($this->db->last_query()); - //die(); - $query = $this->db->get(); - - return $query->result(); - - } - -function receiptdata() - { - - $this->db->distinct(); - $this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total'); - $this->db->from ('t_income_expense inc'); - $this->db->where('inc.type','RECEIPT'); - $query = $this->db->get(); - return $query->result(); - - } - function paymentdata() - { - - $this->db->distinct(); - $this->db->select('inc.type,inc.date,inc.account_code,inc.towhom,inc.total'); - $this->db->from ('t_income_expense inc'); - //$this->db->group_by('inc.account_code'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - - } - - - - function debitimage($igrno,$pono) - { - - $this->db->select('*'); - $this->db->from ('T_PurchaseOrder_BillUpload'); - $this->db->where('IGRNO != "" '); - $this->db->where('IGRNO',$igrno); - $this->db->or_where('PONO',$pono); - $query = $this->db->get(); - $result = $query->result(); - // print_r($result);die; - return $result; - - } - - - - function debitpolistfilter($supplierID,$fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.Totalpoamount,bm.Podate,bm.BankDate, - bm.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance, - inward.FilePath as igrfile,bu.FilePath as pofile'); - $this->db->from ('T_Bankmappingpo bm'); - // $this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo'); - $this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =bm.IGRNO','left'); - $this->db->join('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left'); - $this->db->join('T_bankreport br','br.ID=bm.mid','left'); - $this->db->where('bm.SupplierID',$supplierID); - $this->db->where('bm.IsActive',1); - // $this->db->where('igr.BankStatus !=',ST072); - $this->db->order_by('bm.IGRNO'); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(bm.BankDate) >= '".$fromdate."' - and date(bm.BankDate) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->group_by('bm.id'); - $query = $this->db->get(); - return $query->result(); - - } - - - function igrmastersingle($igrno,$pono) - { - $this->db->distinct(); - $this->db->select('IGRNO,file,PONO as pono'); - $this->db->from('T_IGR_Master'); - if(!empty($igrno) && !empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO',$igrno); - }else if(!empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO != ""'); - }else{ - $this->db->where('IGRNO',$IGRNO); - } - - $query = $this->db->get(); - return $query->result(); - } - function igrmastermultiple($igrno,$pono) - { - $this->db->distinct(); - $this->db->select('BillNo,IGRNO,FilePath,PONO'); - $this->db->from('T_Inwardgateregister_fileupload'); - if(!empty($igrno) && !empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO',$igrno); - }else if(!empty($pono)){ - $this->db->where('PONO',$pono); - $this->db->where('IGRNO != ""'); - }else{ - $this->db->where('IGRNO',$IGRNO); - } - $query = $this->db->get(); - return $query->result(); - - } - function igrmastermultiple1($igrno,$pono) - { - - - $this->db->select('BillNo,IGRNO,FilePath,PONO'); - $this->db->from('T_Inwardgateregister_fileupload'); - // if(!empty($igrno) && !empty($pono)){ - // $this->db->where('PONO',$pono); - $this->db->where('IGRNO',$igrno); - // }else if(!empty($pono)){ - // $this->db->where('PONO',$pono); - // $this->db->where('IGRNO != ""'); - // }else{ - //$this->db->where('IGRNO',$IGRNO); - // } - $query = $this->db->get(); - return $query->result(); - - } - function debitpolist($bankid) - { - $this->db->select('bp.id,bp.mid,igrm.MaterialRcvdDate,bp.PONO,bp.Suppliername,bp.Totalpoamount,br.Debit,bp.Balancetopay,bp.Amountpaid,bp.IGRNO,bp.IGRLineItemNo,igrm.file,bu.FilePath,inward.FilePath as Fpath,bp.IsActive'); - $this->db->from ('T_Bankmappingpo bp'); - $this->db->join ('T_IGR_Master igrm','bp.IGRNO = igrm.IGRNO','left'); - $this->db->join ('T_PurchaseOrder_BillUpload bu','bu.PONO = bp.PONO','left'); - $this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =igrm.IGRNO','left'); - $this->db->join ('T_bankreport br','br.ID=bp.mid'); - $this->db->where('bp.IsActive',1); - $this->db->where('bp.mid',(int)$bankid); - // $this->db->where('igrde.BankStatus !=','ST072'); - $this->db->group_by('bp.id'); - $this->db->order_by('bp.IGRNO'); - $query = $this->db->get(); - - return $query->result(); - - } - - - function creditinvoicelist($bankid) - { - - $this->db->select('bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid, - bm.balancetoreceived,bm.amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared,bm.IsActive'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('T_bankreport br','br.ID=bm.bankid'); - $this->db->where('bm.bankid',(int)$bankid); - $this->db->where('bm.IsActive',1); - $this->db->group_by('bm.ID'); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - // $str = $this->db->last_query(); - // print_r($str); - - //print_r($query); - return $query->result(); - - } - function creditinvoicelistfilter($clientid,$fdate,$tdate,$fa,$aa,$m) - - { - - $this->db->select('bm.ID,bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid, - bm.balancetoreceived,bm.amountreceived,br.cclearbalance,br.cbalancetocleared,bm.BankDate'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno'); - $this->db->join ('ip_clients ic','ic.client_name = bm.customername','left'); - $this->db->join('T_bankreport br','br.ID = bm.bankid'); - $this->db->where('bm.IsActive',1); - $this->db->where('bm.customerid',$clientid); - $this->db->where('iv.receivedstatus !=',ST066); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - - } - if($fdate!='' && $tdate!='') - { - $this->db->where('bm.BankDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - - //$this->db->group_by('invoiceno'); - - $query = $this->db->get(); - return $query->result(); - - } - function uncreditinvoicelistfilter($client,$fdate,$tdate,$fa,$aa,$m) - - { - $this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,BI.amountreceived'); - $this->db->from ('ip_invoice_amounts iva'); - $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id'); - $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left'); - $this->db->where('iv.invoice_status_id','2'); - $this->db->where('iv.receivedstatus',ST066); - $this->db->where('ic.client_id',$client); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $month="monthname(iv.invoice_date_created) = '".$m."'"; - $this->db->where($month); - - } - if($fdate!='' && $tdate!='') - { - $this->db->where('iv.invoice_date_created BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - // $this->db->group_by('iva.invoice_id'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - - - } - //for cashbook edit screen and update bankreport// - function invoiceamonut($bankid) - { - $this->db->select('sum(bm.amountreceived)as amountreceived'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->where('bm.bankid',(int)$bankid); - $this->db->where('bm.IsActive',1); - //$this->db->group_by('bm.ID'); - $query = $this->db->get(); - return $query->result(); - - } - //for cashbook edit screen and update bankreport// - function poamonut($bankid) - { - $this->db->select('sum(Amountpaid)as amountpaid'); - $this->db->from ('T_Bankmappingpo'); - $this->db->where('mid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - function cashbookamount($bankid) - { - $this->db->select('sum(total)as total'); - $this->db->from ('t_income_expense'); - $this->db->where('bankid',$bankid); - $this->db->where('IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - - function mappingcash($accountcode,$fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id,sd.SupplierName'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->join ('T_SupplierDetailsN sd ','sd.SupplierID = ie.Supplier_id','left'); - $this->db->where('ie.account_code',$accountcode); - $this->db->where('ie.amounttype','DEBIT'); - $this->db->where('ie.IsActive',1); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(ie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(ie.date) >= '".$fromdate."' - and date(ie.date) <= '".$todate."'"; - $this->db->where($date); - } - - $query = $this->db->get(); - return $query->result(); - - } - function mappingcashbankid($bankid) - { - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->where('ie.bankid',(int)$bankid); - $this->db->where('ie.amounttype','DEBIT'); - $this->db->where('IsActive',1); - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - function mappingcashcreditbankid($bankid) - { - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->where('ie.bankid',(int)$bankid); - $this->db->where('ie.amounttype','CREDIT'); - $this->db->where('ie.IsActive',1); - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - function mappingcashreceived($accountcode,$fa,$aa,$m,$fdate,$tdate) - { - - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id,sd.SupplierName'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->join ('T_SupplierDetailsN sd ','sd.SupplierID = ie.Supplier_id','left'); - $this->db->where('ie.account_code',$accountcode); - $this->db->where('ie.amounttype','CREDIT'); - $this->db->where('ie.IsActive',1); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(ie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(ie.date) >= '".$fromdate."' - and date(ie.date) <= '".$todate."'"; - $this->db->where($date); - } - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - function mappingcashfilter($accountcode,$fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->where('ie.account_code',$accountcode); - $this->db->where('ie.amounttype','DEBIT'); - $this->db->where('IsActive',1); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(ie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(ie.date) >= '".$fromdate."' - and date(ie.date) <= '".$todate."'"; - $this->db->where($date); - } - - $query = $this->db->get(); - return $query->result(); - - } - function mappingcashreceivedfilter($accountcode,$fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('ie.date,ie.bankid,ie.cashtype,ie.amounttype,ie.total,ac.name,totalbankamount,ie.id'); - $this->db->from ('t_income_expense as ie'); - $this->db->join ('t_accountcode ac ','ac.code = ie.account_code','left'); - $this->db->where('ie.account_code',$accountcode); - $this->db->where('ie.amounttype','CREDIT'); - $this->db->where('IsActive',1); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(ie.date >= '".$fa."-04-01' and ie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(ie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(ie.date) >= '".$fromdate."' - and date(ie.date) <= '".$todate."'"; - $this->db->where($date); - } - - $query = $this->db->get(); - return $query->result(); - - } - function newcashbook() - { - $this->db->select('cdate,mid,btype,amount,boption,mappingamount,totalamount,amounttype,alreadycreditpaid'); - $this->db->from ('T_Bankmappingcashbook'); - //$this->db->where('mid',$bankid); - - //$this->db->group_by('mid'); - $query = $this->db->get(); - return $query->result(); - - } - - function debitlistpo($pono) - { - $this->db->select('bmp.mid,bmp.PONO,bmp.IGRLineItemNo,bmp.Amountpaid,br.Narration'); - $this->db->from ('T_Bankmappingpo as bmp'); - $this->db->join('T_bankreport br','br.ID = bmp.mid'); - $this->db->where('bmp.PONO',$pono); - $this->db->where('bmp.IsActive',1); - $query = $this->db->get(); - return $query->result(); - } - - function creditlistinv($invno) - { - $this->db->select('bmp.bankid,bmp.invoiceno,bmp.amountreceived,br.Narration'); - $this->db->from ('T_Bankmappingiv as bmp'); - $this->db->join('T_bankreport br','br.ID = bmp.bankid'); - $this->db->where('invoiceno',$invno); - $this->db->where('bmp.IsActive',1); - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - - function getsupplier() - { - $this->db->select('SupplierName,SupplierID'); - $this->db->from('T_SupplierDetailsN'); - //$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - - function checkMerchant($mer){ - - $temp[] = '' ; - $this->db->distinct(); - $this->db->select('SupplierID,SupplierName'); - $this->db->from('T_SupplierDetailsN'); - $this->db->like('SupplierName',$mer); - $query = $this->db->get(); - - $temparr[] = '' ; - foreach($query->result() as $arr){ - $temparr[] = $arr->SupplierName; - } - $temp['suggestions'] = $temparr; - - return $temp; - } - - function getsupp_dtls($s){ - $this->db->select('GSTNO'); - $this->db->from('T_SupplierDetailsN'); - $this->db->where('SupplierName',$s); - $r = $this->db->get(); - return $r->result(); - } - - function getcustomer() - { - $this->db->select('client_name,client_id'); - $this->db->from('ip_clients'); - //$this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); - //$this->db->where('t_income_expense.id') - $r = $this->db->get(); - return $r->result(); - - } - function invoicedata($invoicedata) - { - $this->db->insert('T_Bankinvoicereport',$invoicedata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - function bankporeportdata($igrdata) - { - $this->db->insert('T_Bankporeport',$igrdata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - // function invicedata($invoicedata) - // { - // $this->db->insert('T_Bankinvoicereport',$invoicedata); - // $r = $this->db->affected_rows(); - // return $r; - // } - function mappingpo($igrdata1) - { - - $this->db->insert('T_Bankmappingpo',$igrdata1); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - function mappinginvoice($invoicedata) - { - $this->db->insert('T_Bankmappingiv',$invoicedata); - // $this->db->where('PONO',$pono); - $r = $this->db->affected_rows(); - return $r; - } - - - public function getigrno($igrno) - { - $this->db->select('igrno'); - $this->db->from('T_Bankporeport'); - $this->db->where('IGRNO',$igrno); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function invoiceupdate($invid) - { - $this->db->select('invoiceno'); - $this->db->from('T_Bankinvoicereport'); - $this->db->where('invoiceno',$invid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function bankid($pono) - { - $this->db->select('PONO'); - $this->db->from('T_Bankporeport'); - $this->db->where('PONO ',$pono); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function cashbankupdate($cashbookstatus,$bankid) - { - // echo $bankid; - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$cashbookstatus); - return TRUE; - - } - function cashcreditupdate($cashbookstatus1,$bankid) - { - - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$cashbookstatus1); - return TRUE; - } - public function bankupdate($bankdata,$bankid) - { - $this->db->where('ID ',$bankid); - $this->db->update('T_bankreport',$bankdata); - return TRUE; - - } - public function bankcreditupdate($bankcreditdata,$bankid) - { - - - $this->db->where('ID ',$bankid); - $this->db->update('T_bankreport',$bankcreditdata); - - // print_r( $this->db->last_query()); - return TRUE; - - } - public function getearlyamount($igrno) - { - $this->db->select('Amountpaid'); - $this->db->from('T_Bankporeport'); - $this->db->where('IGRNO ',$igrno); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getearlyamountcredit($invid) - { - $this->db->select('amountreceived'); - $this->db->from('T_Bankinvoicereport'); - $this->db->where('invoiceno ',$invid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getearlymappingiv($invid) - { - $this->db->select('sum(amountreceived) as amountreceived'); - $this->db->from('T_Bankmappingiv'); - $this->db->where('invoiceno',$invid); - $this->db->where('IsActive',1); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getalreadypaid($bankid) - { - $this->db->select('Clearbalance'); - $this->db->from('T_bankreport'); - $this->db->where('ID ',$bankid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - public function getalreadyreceived($bankid) - { - $this->db->select('cclearbalance'); - $this->db->from('T_bankreport'); - $this->db->where('ID ',$bankid); - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - - } - - public function bankporeportupdate($igrdata,$igrno) - { - - $this->db->where('IGRNO',$igrno); - $this->db->update('T_Bankporeport',$igrdata); - - return TRUE; - } - public function invoiceupdate1($invoicedata,$invid) - { - //print_r($invoicedata); - //print_r($invid); - $this->db->where('invoiceno',$invid); - $this->db->update('T_Bankinvoicereport',$invoicedata); - - return TRUE; - } - - function paided($supplierid,$fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.Totalpoamount,bm.Podate,bm.BankDate, - bm.Balancetopay,bm.Amountpaid,bm.IGRNO,bm.IGRLineItemNo,br.Balancetocleared,br.Clearbalance, - inward.FilePath as igrfile,bu.FilePath pofile'); - $this->db->from ('T_Bankmappingpo bm'); - //$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo'); - $this->db->join('T_Inwardgateregister_fileupload inward','inward.IGRNO =bm.IGRNO','left'); - $this->db->join('T_PurchaseOrder_BillUpload bu','bm.PONO=bu.PONO','left'); - $this->db->join('T_bankreport br','br.ID=bm.mid','left'); - $this->db->where('bm.SupplierID',$supplierid); - $this->db->where('bm.IsActive',1); - // $this->db->where('igr.BankStatus !=',ST072); - $this->db->order_by('bm.IGRNO'); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(bm.BankDate) >= '".$fromdate."' - and date(bm.BankDate) <= '".$todate."'"; - $this->db->where($date); - } - $this->db->group_by('bm.id'); - $query = $this->db->get(); - return $query->result(); - - } - function amountpaidsupplierwise() - { - $this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,bm.Totalpoamount,bm.Podate, - bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.IGRNO,bm.IGRLineItemNo'); - $this->db->from ('T_Bankmappingpo bm'); - //$this->db->join('T_IGR_Details igr','igr.IGRItemNo=bm.IGRLineItemNo'); - $this->db->where('bm.IsActive',1); - // $this->db->where('igr.BankStatus !=',ST072); - $this->db->group_by('bm.SupplierID'); - $query = $this->db->get(); - return $query->result(); - - } - function amountpaidcashbook() - { - $this->db->select('tac.name,sum(tie.total) as total,tie.account_code'); - $this->db->from ('t_income_expense tie'); - $this->db->join('t_accountcode tac','tac.code=tie.account_code'); - $this->db->where('tie.amounttype','DEBIT'); - $this->db->where('tie.cashtype','Bank'); - $this->db->where('tie.IsActive',1); - //$this->db->where('t_income_expense.account_code !=','ADV001'); - $this->db->group_by('tie.account_code'); - $query = $this->db->get(); - return $query->result(); - - } - function amountreceivedcashbook() - { - $this->db->select('tac.name,sum(tie.total)as total,tie.account_code'); - $this->db->from ('t_income_expense tie'); - $this->db->join('t_accountcode tac','tac.code=tie.account_code'); - $this->db->where('tie.amounttype','CREDIT'); - $this->db->where('tie.IsActive',1); - //$this->db->where('t_income_expense.account_code !=','ADV001'); - $this->db->group_by('tie.account_code'); - $query = $this->db->get(); - return $query->result(); - - } - function amountpaidcashbookfilter($fa,$aa,$m,$fdate,$tdate) - { - //echo $m; - //die(); - $this->db->select('tac.name,sum(tie.total)as total,tie.account_code'); - $this->db->from ('t_income_expense tie'); - $this->db->join('t_accountcode tac','tac.code=tie.account_code'); - $this->db->where('tie.amounttype','DEBIT'); - $this->db->where('tie.cashtype','BANK'); - $this->db->where('tie.IsActive',1); - //$this->db->where('t_income_expense.account_code !=','ADV001'); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(tie.date >= '".$fa."-04-01' and tie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(tie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(tie.date) >= '".$fromdate."' - and date(tie.date) <= '".$todate."'"; - $this->db->where($date); - } - - $this->db->group_by('tie.account_code'); - $query = $this->db->get(); - return $query->result(); - - } - function amountreceivedcashbookfilter($fa,$aa,$m,$fdate,$tdate) - { - $this->db->select('tac.name,sum(tie.total)as total,tie.account_code'); - $this->db->from ('t_income_expense tie'); - $this->db->join('t_accountcode tac','tac.code=tie.account_code'); - $this->db->where('tie.amounttype','CREDIT'); - $this->db->where('tie.IsActive',1); - //$this->db->where('t_income_expense.account_code !=','ADV001'); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(tie.date >= '".$fa."-04-01' and tie.date <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(tie.date) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(tie.date) >= '".$fromdate."' - and date(tie.date) <= '".$todate."'"; - $this->db->where($date); - } - - $this->db->group_by('tie.account_code'); - $query = $this->db->get(); - return $query->result(); - - } - - function amountpaidsupplierwisefilter($fa,$aa,$m,$fdate,$tdate) - { - - $this->db->select('bm.id,bm.mid,bm.PONO,bm.Suppliername,bm.SupplierID,sum(bm.Totalpoamount)as Totalpoamount, - bm.Balancetopay,sum(bm.Amountpaid) as Amountpaid,bm.Podate,bm.IGRLineItemNo,bm.BankDate'); - $this->db->from ('T_Bankmappingpo bm'); - $this->db->where('bm.IsActive',1); - - - if ($fa and $aa != ''){ - - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(bm.BankDate) >= '".$fromdate."' - and date(bm.BankDate) <= '".$todate."'"; - $this->db->where($date); - } - - - $this->db->group_by('bm.SupplierID'); - $query = $this->db->get(); - return $query->result(); - - } - // function unpaided() - // { - // // $this->db->select('igd.IGRNO,igd.IGRItemNo,pom.PONO,sm.SupplierName'); - // // $this->db->from('T_IGR_Details igd'); - // // $this->db->join('T_IGR_Master igm','igm.IGRNO=igd.IGRNO'); - // // $this->db->join('T_PurchaseOrder_LineItem poli','igm.PONO= poli.PONO and igd.MaterialCode=poli.MaterialCode'); - // // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO=poli.PONO'); - // // $this->db->join('T_SupplierDetailsN sm','sm.SupplierID=pom.SupplierID'); - // // $this->db->where('igd.BankStatus','ST072'); - // // $query = $this->db->get(); - // // $result = $query->result(); - // // return $result; - - // } - function received($clientid,$fdate,$tdate,$fa,$aa,$m) - { - $this->db->select('bm.indate,bm.BankDate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,bm.customerid, - bm.balancetoreceived,bm.amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared,bm.IsActive'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno'); - $this->db->join('T_bankreport br','br.ID=bm.bankid'); - $this->db->where('bm.IsActive',1); - $this->db->where('bm.customerid',$clientid); - $this->db->where('iv.receivedstatus !=',ST066); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - - } - if($fdate!='' && $tdate!='') - { - $this->db->where('bm.BankDate BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - //$this->db->group_by('invoiceno'); - $query = $this->db->get(); - return $query->result(); - - } - - function creditinvoicesupplierwise() - { - $this->db->select('bm.indate,bm.invoiceno,bm.customername,bm.totinvoiceamount,bm.bankid,ic.client_id,bm.customerid as customerid, - bm.balancetoreceived,sum(bm.amountreceived)as amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('T_bankreport br','br.ID=bm.bankid'); - $this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno'); - $this->db->join('ip_clients ic','ic.client_name=bm.customername','left'); - $this->db->where('bm.IsActive',1); - $this->db->group_by('bm.customerid'); - $this->db->where('iv.receivedstatus !=',ST066); - $query = $this->db->get(); - return $query->result(); - } - function creditinvoicewisefilter($fdate,$tdate,$fa,$aa,$m) - { - $this->db->select('bm.indate,bm.BankDate,bm.invoiceno,bm.customername,bm.customerid as customerid,bm.totinvoiceamount,bm.bankid,ic.client_id, - bm.balancetoreceived,sum(bm.amountreceived)as amountreceived,bm.ID,br.Credit,br.cclearbalance,br.cbalancetocleared'); - $this->db->from ('T_Bankmappingiv bm'); - $this->db->join('ip_invoices iv','iv.invoice_number=bm.invoiceno'); - $this->db->join('T_bankreport br','br.ID=bm.bankid'); - $this->db->join('ip_clients ic','ic.client_name=bm.customername','left'); - $this->db->where('bm.IsActive',1); - $this->db->where('iv.receivedstatus !=',ST066); - - // $this->db->where('bm.customername',$Customer); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(bm.BankDate >= '".$fa."-04-01' and bm.BankDate <= '".$aa."-03-31')"; - $this->db->where($year); - - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(bm.BankDate) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(bm.BankDate) >= '".$fromdate."' - and date(bm.BankDate) <= '".$todate."'"; - $this->db->where($date); - } - - $this->db->group_by('bm.customerid'); - $query = $this->db->get(); - return $query->result(); - } - function unreceived($clientname,$fdate,$tdate,$fa,$aa,$m) - { - $this->db->distinct(); - $this->db->select('iva.invoice_id,iva.invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_name,BI.balancetoreceived,BI.amountreceived,ic.client_id'); - $this->db->from ('ip_invoice_amounts iva'); - $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left'); - $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left'); - $this->db->where('iv.receivedstatus',ST066); - $this->db->where('iv.invoice_status_id','2'); - $this->db->where('ic.client_id',$clientname); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')"; - $this->db->where($year); - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $month="monthname(iv.invoice_date_created) = '".$m."'"; - $this->db->where($month); - - } - if($fdate!='' && $tdate!='') - { - $this->db->where('iv.invoice_date_created BETWEEN "'. date('Y-m-d', strtotime($fdate)). '" and "'. date('Y-m-d', strtotime($tdate)).'"'); - } - // $this->db->where('iv.receivedstatus','ST066'); - - $this->db->group_by('iva.invoice_id'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - } - function unreceivedsupplier() - { - - $this->db->select('iva.invoice_id,sum(iva.invoice_total)as invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,sum(BI.amountreceived)as amountreceived'); - $this->db->from ('ip_invoice_amounts iva'); - $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left'); - $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left'); - $this->db->where('iv.receivedstatus',ST066); - $this->db->where('iv.invoice_status_id','2'); - - - $this->db->group_by('ic.client_name'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - } - function uncreditinvoicewisefilter($fdate,$tdate,$fa,$aa,$m) - { - - $this->db->select('iva.invoice_id,sum(iva.invoice_total)as invoice_total,iv.invoice_date_created,iv.invoice_number,iva.invoice_paid,ic.client_id,ic.client_name,BI.balancetoreceived,sum(BI.amountreceived)as amountreceived'); - $this->db->from ('ip_invoice_amounts iva'); - $this->db->join ('ip_invoices iv','iva.invoice_id = iv.invoice_id','left'); - $this->db->join ('ip_clients ic','iv.client_id = ic.client_id','left'); - $this->db->join ('T_Bankinvoicereport BI',' iv.invoice_number =BI.invoiceno','left'); - $this->db->where('iv.receivedstatus',ST066); - $this->db->where('iv.invoice_status_id','2'); - - // $this->db->where('bm.customername',$Customer); - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $year="(iv.invoice_date_created >= '".$fa."-04-01' and iv.invoice_date_created <= '".$aa."-03-31')"; - $this->db->where($year); - - } - if ($m!= ''){ - //$this->db->where('MONTH(pel.tgl_pembelian)',$bulan); - $month="monthname(iv.invoice_date_created) = '".$m."'"; - $this->db->where($month); - // $sql.="and monthname(bm.Podate) = '".$m."'"; - - } - if ($fdate and $tdate != ''){ - $fromdate= date("Y-m-d",strtotime($fdate)); - $todate=date("Y-m-d",strtotime($tdate)); - $date = "date(iv.invoice_date_created) >= '".$fromdate."' - and date(iv.invoice_date_created) <= '".$todate."'"; - $this->db->where($date); - } - - - $this->db->group_by('ic.client_name'); - //$this->db->where('inc.type','PAYMENT'); - $query = $this->db->get(); - return $query->result(); - } - - // function podetailstatus($podetails,$pono) - // { - // echo $igrdetails; - // $this->db->where('PONO',$pono); - // $this->db->update('T_PurchaseOrder_Master',$podetails); - // $r = $this->db->affected_rows(); - // return $r; - - // } - function invoiceamountstatus($invoicemaster,$invid) - { - - $this->db->where('invoice_number',$invid); - $this->db->update('ip_invoices',$invoicemaster); - $r = $this->db->affected_rows(); - return $r; - - } - function igrstatus($igrmaster,$igrno) - { - $this->db->where('IGRNO',$igrno); - $this->db->update('T_IGR_Master',$igrmaster); - $r = $this->db->affected_rows(); - return $r; - - } - - function Cashbook($cashbookdatas) - { - $code=$cashbookdatas['code']; - $type=$cashbookdatas['type']; - - $count=0; - - $this->db->select('count(*) as count'); - $this->db->from('t_accountcode'); - $this->db->where('type',$type); - $this->db->where('code',$code); - - $isExits = $this->db->get(); - $res = $isExits->result_array(); - - - if(!empty($res)) - { - $count = $res[0]['count']; - } - - - if($count == 0 )//for cashbook_insert - { - $cbi = $this->db->insert('t_accountcode', $cashbookdatas); - return $cbi; - } - elseif($count == 1)//for cashbook_update - { - $this->db->where('code',$code); - $cbu = $this->db->update('t_accountcode',$cashbookdatas); - return $cbu; - } - - } - function deletemapping($Bankid,$updateamount,$updatebalancetoclear,$Status) - { - $this->db->set('Clearbalance',$updateamount); - $this->db->set('Balancetocleared',$updatebalancetoclear); - $this->db->set('Status',$Status); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function updatebankreportiv($bankid,$bankstatement) - { - $this->db->where('ID',$bankid); - $this->db->update('T_bankreport',$bankstatement); - $r = $this->db->affected_rows(); - return $r; - - } - function IGRStatusUpdate($igrno,$PaymentStatus) - { - - $this->db->set('Paymentstatus',$PaymentStatus); - $this->db->where('IGRNO',$igrno); - $this->db->update('T_IGR_Master'); - $r = $this->db->affected_rows(); - return $r; - } - function deleteBankmappingpo($id,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('id',$id); - $this->db->update('T_Bankmappingpo'); - $r = $this->db->affected_rows(); - return $r; - } - // function updatemappingamount($igrno,$amountpaid) - // { - - // $sql="update T_Bankmappingpo set Balancetopay=$amountpaid+Balancetopay where IGRLineItemNo='$igrno' and - // IsActive='1'"; - // $query = $this->db->query($sql); - // return $query->result(); - - // // $this->db->set('Balancetopay',$amountpaid+'Balancetopay'); - // // //$this->db->set('Balancetopay',$amountpaid); - // // $this->db->where('IGRLineItemNo',$igrno); - // // $this->db->where('IsActive',1); - // // $this->db->update('T_Bankmappingpo'); - // // $r = $this->db->affected_rows(); - // // return $r; - // } - function UpdateIpinvoiceStatus($invoiceno,$receivedstatus) - { - $this->db->set('receivedstatus',$receivedstatus); - $this->db->where('invoice_number',$invoiceno); - $this->db->update('ip_invoices'); - $r = $this->db->affected_rows(); - return $r; - } - - function deletemappinginvoice($mappingid,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('ID',$mappingid); - $this->db->update('T_Bankmappingiv'); - $r = $this->db->affected_rows(); - return $r; - } - // function updatemappinginvoice($invoiceno,$amountreceived) - // { - // $this->db->set('balancetoreceived',$amountreceived+'balancetoreceived'); - // $this->db->where('invoiceno',$invoiceno); - // $this->db->where('IsActive',1); - // $this->db->update('T_Bankmappingiv'); - // $query = $this->db->get(); - // print_r(this->db->last_query()); - // $r = $this->db->affected_rows(); - // return $r; - // } - - function updateBankporeport($igrno,$balancetopayupdate,$amountpaidupdate,$IsAct) - { - $this->db->set('Balancetopay',$balancetopayupdate); - $this->db->set('Amountpaid',$amountpaidupdate); - $this->db->set('IsActive',$IsAct); - $this->db->where('IGRNO',$igrno); - //$this->db->where('mid',$Bankid); - $this->db->update('T_Bankporeport'); - $r = $this->db->affected_rows(); - return $r; - - } - - function updatebankinvoicereport($invoiceno,$balancetoreceivedupdate,$amountreceivedupdate,$IsAct) - { - $this->db->set('balancetoreceived',$balancetoreceivedupdate); - $this->db->set('amountreceived',$amountreceivedupdate); - $this->db->set('IsActive',$IsAct); - $this->db->where('invoiceno',$invoiceno); - //$this->db->where('bankid',$bankid); - $this->db->update('T_Bankinvoicereport'); - $r = $this->db->affected_rows(); - return $r; - } - function gettotalbankmappingpo($id) - { - $this->db->select('sum(Amountpaid)as Amountpaid'); - $this->db->from ('T_Bankmappingpo'); - $this->db->where('id',$id); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function gettotalbankmappingpocount($igrno) - { - $this->db->select('count(Amountpaid)as countAmountpaid'); - $this->db->from ('T_Bankmappingpo'); - $this->db->where('IGRNO',$igrno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function gettotalbankmappinginvoicecount($invoiceno) - { - $this->db->select('count(amountreceived)as countamountreceived'); - $this->db->from ('T_Bankmappingiv'); - $this->db->where('invoiceno',$invoiceno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function gettotalbankpoamount($igrno) - { - $this->db->select('Amountpaid,Balancetopay'); - $this->db->from ('T_Bankporeport'); - $this->db->where('IGRNO',$igrno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function gettotalbankreceivedamount($invoiceno) - { - $this->db->select('amountreceived,balancetoreceived'); - $this->db->from ('T_Bankinvoicereport'); - $this->db->where('invoiceno',$invoiceno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function gettotalbankporeport($igrno) - { - $this->db->select('Amountpaid'); - $this->db->from ('T_Bankporeport'); - $this->db->where('IGRLineItemNo',$igrno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function getlatestamount($mappingid,$invoiceno) - { - $this->db->select('min(balancetoreceived)as balancetoreceived'); - $this->db->from ('T_Bankmappingiv'); - $this->db->where('ID',$mappingid); - $this->db->where('invoiceno',$invoiceno); - $this->db->where('IsActive',1); - //$this->db->group_by('T_Bankmappingpo.IGRLineItemNo'); - $query = $this->db->get(); - return $query->result(); - } - function getlatest($invoiceno) - { - $sql="select ID,balancetoreceived from T_Bankmappingiv where invoiceno='$invoiceno' and - ID in(select max(ID) from T_Bankmappingiv group by invoiceno)"; - $query =$this->db->query($sql); - return $query->result(); - } - function deletecashbookdata($Bankid,$updatebankamount,$clearbalance) - { - $this->db->set('Clearbalance',$clearbalance); - $this->db->set('Balancetocleared',$updatebankamount); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function deletecashbookdatacredit($Bankid,$updateclearbalance,$updatebalancetoclear) - { - $this->db->set('cclearbalance',$updateclearbalance); - $this->db->set('cbalancetocleared',$updatebalancetoclear); - $this->db->where('ID',$Bankid); - $this->db->update('T_bankreport'); - $r = $this->db->affected_rows(); - return $r; - } - function getaccountcode($accountname) - { - $this->db->select('code'); - $this->db->from ('t_accountcode'); - $this->db->where('name',$accountname); - $query = $this->db->get(); - return $query->result(); - } - function StatusUpadateCashbook($id,$IsActive) - { - $this->db->set('IsActive',$IsActive); - $this->db->where('id',$id); - $this->db->update('t_income_expense'); - $r = $this->db->affected_rows(); - return $r; - } - -} - -?> \ No newline at end of file diff --git a/application/models/models/companydetailsmodel.php b/application/models/models/companydetailsmodel.php deleted file mode 100644 index 47235283..00000000 --- a/application/models/models/companydetailsmodel.php +++ /dev/null @@ -1,165 +0,0 @@ -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; - - } - - } - -} - -?> \ No newline at end of file diff --git a/application/models/models/configmodel.php b/application/models/models/configmodel.php deleted file mode 100644 index e74241d0..00000000 --- a/application/models/models/configmodel.php +++ /dev/null @@ -1,194 +0,0 @@ -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(); - } - - -} -?> \ No newline at end of file diff --git a/application/models/models/costcenter_model.php b/application/models/models/costcenter_model.php deleted file mode 100644 index 38c48c1e..00000000 --- a/application/models/models/costcenter_model.php +++ /dev/null @@ -1,418 +0,0 @@ -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; - } -} -?> \ No newline at end of file diff --git a/application/models/models/dahsboard_model.php b/application/models/models/dahsboard_model.php deleted file mode 100644 index 35569d50..00000000 --- a/application/models/models/dahsboard_model.php +++ /dev/null @@ -1,3146 +0,0 @@ -db->query($sql); - return $query->result(); - - } - - /* HR DASHBOART Model START*/ - function totemp() - { - $yes_date = date('Y-m-d',strtotime("-1 days")); - // $sql="select count(*) as emp_count from T_Employee_Details where date(T_Employee_Details.Created_date) <= ? and isActive = 1"; - // $query =$this->db->query($sql,array($yes_date)); - $this->db->select('count(*) as totemp'); - $this->db->where('date(T_Employee_Details.Created_date)<=',$yes_date); - $this->db->where('isActive',1); - $query = $this->db->get('T_Employee_Details'); - // print_r($query->row());die; - return $query->row(); - - } - - - -function getfile($PONO) - { - //$this->db->distinct(); - $this->db->select('*'); - $this->db->from('T_PurchaseOrder_BillUpload'); - $this->db->where('PONO',$PONO); - - - $query = $this->db->get(); - // print_r( $this->db->last_query()); - $result = $query->result_array(); - return $result; - } -function getfiles($igr,$PONO) - { - //$this->db->distinct(); - $this->db->select('*'); - $this->db->from('T_Inwardgateregister_fileupload'); - $this->db->where('IGRNO',$igr); - $this->db->where('PONO',$PONO); - - - $query = $this->db->get(); - // print_r( $this->db->last_query()); - $result = $query->result_array(); - return $result; - } - - - function viewIGRFile1($igr,$PONO) - { - $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->where('igrm.IGRNO',$igr); - $this->db->where('igrm.PONO',$PONO); - - $query = $this->db->get(); - - $result = $query->result(); - // print_r($result);die; - //print_r($this->db->last_query()); - return $result; - -} - - - - function selectigrfiles() - { - $this->db->select('*'); - $this->db->from('T_Inwardgateregister_fileupload'); - //$this->db->where('PONO',$PONO); - - - $query = $this->db->get(); - // print_r( $this->db->last_query()); - $result = $query->result_array(); - return $result; - - } - - function totloan() - { - - $sql="select sum(Loan_Amount)as totloan FROM T_Loan_Master"; - $query =$this->db->query($sql); - return $query->result(); - - } - - - function totpay() - { - - $sql="select sum(Paid_Amount)as totpay FROM T_Loan_Master"; - $query =$this->db->query($sql); - return $query->result(); - - } - - function totrec() - { - - $sql="select sum(Loan_Amount), sum(Paid_Amount),sum(Loan_Amount)-sum(Paid_Amount) as totrec FROM T_Loan_Master"; - $query =$this->db->query($sql); - return $query->result(); - - } - - function emplist() - { - -$sql="select EmpID,CONCAT(FirstName,' ',LastName) as name FROM T_Employee_Details where IsActive ='1'"; - $query =$this->db->query($sql); - return $query->result(); - - - - } - - - function attyesterday($WH,$date) - { - //echo 'model' . $WH.'-'.$date; - // $sql="select EmpID,".$WH." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)" ; - -$yes_date = date('Y-m-d',strtotime("-1 days")); -$sql="select att.EmpID,ifnull(".$WH.",0)".$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) and date(a.Created_date) <= '".$yes_date."' and isActive=1"; - $query = $this->db->query($sql,array($date)); - // print_r($query->result_array());die; - //echo count($query->result()); - return $query->result_array(); -} - - - function dayAllPersentEmpSalary($WH,$OT,$date) - { - // echo $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 - return $query->result_array(); -} - -function yesterdayAllPersentEmpSalary($WH,$OT,$date) - { - // echo $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 - return $query->result_array(); -} - - -function attendance($EmpID,$dates) - { - //echo $EmpID.'-'.$dates; - $sql="select * from T_Attendance where EmpID =? and Month_Year=?"; - $query = $this->db->query($sql,array($EmpID,$dates)); - - return $query->result(); - -} -function getAllAttendance($EmpID,$CURMONTH) -{ - $sql="select * from T_Attendance where EmpID =? and month(Month_Year)=?"; - -// $sql=" select T_Attendance.*,emp.FirstName from T_Attendance -// join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID -// where T_Attendance.EmpID = ? and month(Month_Year)= ? "; - - - $query = $this->db->query($sql,array($EmpID,$CURMONTH)); - - return $query->result(); -} - -function getAllAttendances($EmpID,$JoinedMonth) -{ - //$sql="select * from T_Attendance where EmpID =? and month(Month_Year)=?"; - - $sql=" select T_Attendance.*,emp.FirstName from T_Attendance -join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID -where T_Attendance.EmpID = ? and month(Month_Year)= ? "; - - - $query = $this->db->query($sql,array($EmpID,$JoinedMonth)); - - return $query->result(); -} -function joindate($EmpID) -{ - $sql="select DateofJoining from T_Employee_Details where EmpID =? "; - $query = $this->db->query($sql,array($EmpID)); - - return $query->result(); -} - - - - -function daysalary($EmpID,$dates) -{ - //print_r($dates);die; - $sql= "select * FROM T_Emp_Pay_Data as pay - -join T_Attendance att on att.EmpID = pay.EmpID -where att.Month_Year = ? and att.EmpID = ?;"; - $query = $this->db->query($sql,array($dates,$EmpID)); - - return $query->result(); - -} - - -function persentEmployeeDetails($EmpID){ -//join T_Attendance att on att.EmpID = pay.EmpID -$sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;"; - $query = $this->db->query($sql,array($EmpID)); - - return $query->result(); - -} - - - - function attendanceyear($EmpID,$MONTH) - { - -// //print_r($MONTH); -// $sql="select Att.EmpID,Att.Month_Year,Att.*,NoofDays,Days_Worked,emp.DateofJoining from T_Attendance Att -// join T_Employee_Details as emp on emp.EmpID = Att.EmpID -// where Att.Month_Year between ? and Att.EmpID = ?"; - // else - // (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 ) - // $sql = 'select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where - // case - // when (month(Month_Year) >=4) then - // (YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 )end and EmpID = ? and month(Month_Year) != month(current_date()) - // else - // (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 )'; - - $sql = ' select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where - case - when (MONTH(CURRENT_DATE) >=4) then - ((YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? )) and EmpID = ? and month(Month_Year) != MONTH(CURRENT_DATE) - else - ((YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >=4 and ? >= 4) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 and ? <=3 )) and Month(Month_Year) >= ? and EmpID = ? and month(Month_Year) != MONTH(CURRENT_DATE) - end'; - - -/*$sql='select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance - where EmpID= ? and (MONTH(Month_Year) >=4) or (MONTH(Month_Year) <3) -and (YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? )or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 ) - and MONTH(Month_Year) != MONTH(current_date())';*/ - - - - $query= $this->db->query($sql,array($MONTH,$EmpID,$MONTH,$MONTH,$MONTH,$EmpID)); - return $query->result(); - - - - } - - function getEmployee(){ -$sql="select EmpID,FirstName,LastName,IsActive FROM T_Employee_Details "; - $query =$this->db->query($sql); - return $query->result(); - -} - - - -function get_all_employee($Month) -{ - $sql = "select T_Attendance.*,emp.EmpID,emp.FirstName,emp.LastName,emp.IsActive from T_Attendance -join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID -where Month_Year=?;"; - $query = $this->db->query($sql,array($Month)); - return $query->result(); -} - - -function get_all_employee1($finStart,$finEnd) -{ - - - $sql = "select att.EmpID,att.*,att.Month_Year,emp.FirstName,emp.DateofJoining from T_Attendance att - join T_Employee_Details emp on emp.EmpID = att.EmpID - where att.Month_Year between ? and ?"; - $query = $this->db->query($sql,array($finStart,$finEnd)); - return $query->result(); -} - -function holiDaySalaryMonth($month,$year) -{ - $sql="SELECT H_Date FROM T_Public_Holidays where MONTH(H_Date)= ? and YEAR(H_Date) = ? "; - $query = $this->db->query($sql,array($month,$year)); - return $query->result(); -} -function fy() - { - $sql= "SELECT - CASE WHEN MONTH(Month_year)>=4 THEN - concat(YEAR(Month_year), '-',YEAR(Month_year)+1) - ELSE concat(YEAR(Month_year)-1,'-', YEAR(Month_year)) END AS financial_year - FROM T_Attendance -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - } -function get_employee(){ - - $yes_date = date('Y-m-d',strtotime("-1 days")); - $sql = "select * from T_Employee_Details where date(created_date) <='".$yes_date."' and isActive =1"; - $query = $this->db->query($sql); - return $query->result(); -} -function per($fa,$aa,$m) - { - //echo $m; - $cur_month = date('M'); - //echo $cur_month; - if($cur_month == $m ){ - - $cur_date = date('d'); - }else{ - - $cur_date = date('t',strtotime($m)); - } - //echo $cur_date;die; - $sql= "SELECT month.Eid as Eid,month.ename as ename,month.active as active,month.days as monthdays,month.Days_Worked as monthworked,month.percentage as monthpercentage -from (select em.EmpID as Eid,concat(em.FirstName,'.',em.LastName) as ename,em.IsActive as active,at.NoofDays as days, -Days_Worked,round((Days_Worked/".$cur_date."*100)) as percentage from -T_Employee_Details em -join T_Attendance at on at.EmpID = em.EmpID -where (Month_Year >= '".$fa."-04-01' and Month_Year <= '".$aa."-04-01') and monthname(Month_Year) = '".$m."' -) as month"; - -$query = $this->db->query($sql); - return $query->result(); - } - - - - /* HR DASHBOARD Model END*/ - - - - - function totalpurchaseorder(){ - - - $sql="select count(PONO) as totalpurchaseorder from T_PurchaseOrder_Master pm where Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; - $query = $this->db->query($sql); - return $query->result(); - - } - function totalordervalue(){ - - - $sql="select sum(totalordervalue) as totalordervalue from T_PurchaseOrder_Master pm where Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; - $query = $this->db->query($sql); - return $query->result(); - - } - function pendingpo(){ - - - $sql="select count(PONO) as pending from T_PurchaseOrder_Master pm where status='ST020' and Status != 'ST030' - and case - when (month(pm.PODate) >=4) then - (YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.PODate) <= 3 ) - else - (YEAR(pm.PODate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.PODate) >= 4 ) or ( YEAR(pm.PODate) = YEAR(CURRENT_DATE) and MONTH(pm.PODate) <= 3 ) - end"; - $query = $this->db->query($sql); - return $query->result(); - - } - function req_pending(){ - - - $sql="SELECT count(Status) as TOTAL_PENDING_REQUESTS FROM T_Requestion_Master pm where Status = 'ST002' - and case - when (month(pm.ReqDate) >=4) then - (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)+1 and MONTH(pm.ReqDate) <= 3 ) - else - (YEAR(pm.ReqDate) = YEAR(CURRENT_DATE)-1 and MONTH(pm.ReqDate) >= 4 ) or ( YEAR(pm.ReqDate) = YEAR(CURRENT_DATE) and MONTH(pm.ReqDate) <= 3 ) - end"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - function reqdetail(){ - - $now= date('Y-m-d'); - $sql="SELECT count(Status) as TODAY_REQUESTS FROM T_Requestion_Master where date(ReqDate) = '".$now."' "; - - $query = $this->db->query($sql); - - // echo "from Model"; - // print_r($query->result()); - - return $query->result(); - - - - } - function january(){ - - - $sql="select count(PONO) as pending from T_PurchaseOrder_Master where status='ST020'"; - $query = $this->db->query($sql); - return $query->result(); - - } - // function totalserviceamount() - // { - // $sql="select sum(BudgetAmount) as totalserviceamount from T_CostCenter_Budget where BudgetType='SERVICE'"; - // $query = $this->db->query($sql); - // return $query->result(); - - // } - // function totalcapitalamount() - // { - // $sql="select sum(BudgetAmount) as totalcapitalamount from T_CostCenter_Budget where BudgetType='CAPITAL'"; - // $query = $this->db->query($sql); - // return $query->result(); -// } -// function totalimportamount() - // { - // $sql="select sum(BudgetAmount) as totalimportamount from T_CostCenter_Budget where BudgetType='IMPORT'"; - // $query = $this->db->query($sql); - // return $query->result(); -// } -// function totalrevenueamount() - // { - // $sql="select sum(BudgetAmount) as totalrevenueamount from T_CostCenter_Budget where BudgetType='REVENUE'"; - // $query = $this->db->query($sql); - // return $query->result(); -// } -//totalservice -function getTotalServicePoCount(){ - $i=1; - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - while($i<=12){ - - - $sql="SELECT count(cmast.PONO) as totalService FROM T_PurchaseOrder_Master cmast - where POType='SERVICE' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; - -$query = $this->db->query($sql); -$array_result[]=$query->result(); -$i++; - - } - - return $array_result; - -} - -function getTotalimportPoCount(){ - $i=1; - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - while($i<=12){ - - - $sql="SELECT count(cmast.PONO) as totalImport FROM T_PurchaseOrder_Master cmast - where POType='IMPORT' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; - -$query = $this->db->query($sql); -$array_result[]=$query->result(); -$i++; - - } - - return $array_result; - -} -function getTotalcapitalPoCount(){ - $i=1; - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - while($i<=12){ - - $sql="SELECT count(cmast.PONO) as totalcapital FROM T_PurchaseOrder_Master cmast - where POType='CAPITAL' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; - -$query = $this->db->query($sql); -$array_result[]=$query->result(); -$i++; - - } - - return $array_result; - -} - function getTotalrevenuePoCount(){ - $i=1; - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - while($i<=12){ - - $sql="SELECT count(cmast.PONO) as totalrevenue FROM T_PurchaseOrder_Master cmast - where POType='REVENUE' and Status != 'ST030' and month(PODate) = $i - and date(cmast.PODate) >= '".$fa."-04-01' and date(cmast.PODate) <= '".$aa."-03-31'"; - -$query = $this->db->query($sql); -$array_result[]=$query->result(); -$i++; - - } - - return $array_result; - -} - - - - - -function serviceprogress() - { - $sql="SELECT count(cmast.PONO) as serviceprogress FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='SERVICE' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); -} -function revenueprogress() - { - $sql="SELECT count(cmast.PONO) as revenueprogress FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='REVENUE' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); -} -function importprogress() - { - $sql="SELECT count(cmast.PONO) as importprogress FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='IMPORT' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); -} -function capitalprogress() - { - $sql="SELECT count(cmast.PONO) as capitalprogress FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='CAPITAL' and statusCode='ST018'"; - $query = $this->db->query($sql); - return $query->result(); -} -function totalservicepo () -{ - $sql="SELECT count(cmast.PONO) as totalservicepo FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='SERVICE'"; - $query = $this->db->query($sql); - return $query->result(); -} -function totalrevenuepo () -{ - $sql="SELECT count(cmast.PONO) as totalrevenuepo FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='REVENUE'"; - $query = $this->db->query($sql); - return $query->result(); -} -function totalimportpo () -{ - $sql="SELECT count(cmast.PONO) as totalimportpo FROM T_PurchaseOrder_Master cmast - join T_PurchaseOrder_LineItem line on line.PONO=cmast.PONO - join T_Requestion_Master req on req.ReqNo=line.ReqNo - join T_Status sta on sta.statusCode=req.status - where ReqType='IMPORT'"; - $query = $this->db->query($sql); - return $query->result(); -} - -function importbudgt () -{ - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalimportbudget FROM T_CostCenter_Budget where BudgetType ='IMPORT' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; - $query = $this->db->query($sql); - return $query->result(); -} - -function capitalbud () -{ - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT sum(BudgetAmount) as totalcapitalbudget FROM T_CostCenter_Budget where BudgetType ='CAPITAL' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31' "; - $query = $this->db->query($sql); - return $query->result(); -} - -function servicebudgt () -{ - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalservicebudget FROM T_CostCenter_Budget where BudgetType ='SERVICE' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; - $query = $this->db->query($sql); - return $query->result(); -} - -function revenuebudgt () -{ - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT ROUND(sum(BudgetAmount),2) as totalrevenuebudget FROM T_CostCenter_Budget where BudgetType ='REVENUE' and date(CreatedDate) >= '".$fa."-04-01' and date(CreatedDate) <= '".$aa."-03-31'"; - $query = $this->db->query($sql); - return $query->result(); -} - -function typebal () -{ - if (date('m') >= 4) - { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT BudgetYear, -sum(if(BudgetType = 'SERVICE', -Util_Amount,0)) as sr, -sum(if(BudgetType = 'REVENUE', -Util_Amount,0)) as rv, -sum(if(BudgetType = 'IMPORT', -Util_Amount,0)) as im, -sum(if(BudgetType = 'CAPITAL', -Util_Amount,0)) as ca -FROM cost_center where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31'; -"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); -} - - - - function req_list($fa,$aa,$m,$frm,$t,$agf,$agt){ - $sql="select date_format(mas.ReqDate,'%d-%m-%Y') as ReqDate,mas.ReqNo,emp.FirstName as Requestedby,dep.DepartmentName,mas.ReqType,DATEDIFF(CURDATE(),mas.ReqDate) AS Aging from T_Requestion_Master as mas - join T_CostCenter_Master cos on cos.CostCenterCode = mas.CostCenterCode - join T_Employee_Details emp on emp.EmpID = mas.Requestedby - join T_DepartmentDetails dep on dep.DEPCode=emp.Departmentcode - where mas.Status = 'ST002' - "; - if ($fa and $aa != ''){ - - $sql.=" and (mas.ReqDate >= '".$fa."-04-01' and mas.ReqDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(mas.ReqDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(mas.ReqDate) >= '".$fromd."' - and date(mas.ReqDate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and DATEDIFF(CURDATE(),mas.ReqDate) >= '".$agf."' - and DATEDIFF(CURDATE(),mas.ReqDate) <= '".$agt."'"; - - } - $query = $this->db->query($sql); - //print_r($this->db->last_query()); - return $query->result(); - } - - function report_relpo($fa,$aa,$m,$frm,$t,$agf,$agt){ - $sql="select Mast.PONO,Mast.POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ReleasedOn,'%d-%m-%Y') as ReleasedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue -from T_PurchaseOrder_Master Mast -JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO -left JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo -left JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Req.RequestedDept -left JOIN T_CostCenter_Master as Cost on -Cost.CostCenterCode=Req.CostCenterCode -JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_Bdgt.CostCenterCode -where Mast.Status='ST026' -"; -if ($fa and $aa != ''){ - - $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(Mast.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(Mast.PODate) >= '".$fromd."' - and date(Mast.PODate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and Mast.TotalOrderValue >= '".$agf."' - and Mast.TotalOrderValue <= '".$agt."'"; - - } - $sql.=" group by Mast.PONO"; - $query = $this->db->query($sql); - return $query->result(); - } - - function report_openpending($fa,$aa,$m,$frm,$t,$agf,$agt){ - $sql="select Mast.PONO as PONO,Mast.POType as POType,date_format(Mast.PODate,'%d-%m-%Y') as PODate,date_format(Mast.ApprovedOn,'%d-%m-%Y') as ApprovedDate,Dept_Details.DepartmentName As Dept_Name,Mast.TotalOrderValue -from T_PurchaseOrder_Master Mast -left JOIN T_PurchaseOrder_LineItem Det on Det.PONO=Mast.PONO -left JOIN T_Requestion_Master as Req on Req.ReqNo=Det.ReqNo -left JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Req.RequestedDept -left JOIN T_CostCenter_Master as Cost on -Cost.CostCenterCode=Req.CostCenterCode -JOIN T_CostCenter_Budget as Cost_Center_Bdgt on Cost.CostCenterCode=Cost_Center_Bdgt.CostCenterCode -where (Mast.Status='ST025' or Mast.Status='ST005') - "; -if ($fa and $aa != ''){ - - $sql.=" and (Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(Mast.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(Mast.PODate) >= '".$fromd."' - and date(Mast.PODate) <= '".$tod."'"; - - } - if ($agf and $agt != ''){ - - $sql.="and Mast.TotalOrderValue >= '".$agf."' - and Mast.TotalOrderValue <= '".$agt."'"; - - } - $sql.=" group by PONO,POType,Dept_Name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - - - - } - - function report_total($fa,$aa){ - - - $sql="select ifnull(Dept_Details.DepartmentName,'-') As Dept_Name, - SUM(CASE WHEN Mast.Status = 'ST015' or Mast.Status = 'ST024' THEN 1 ELSE 0 END) AS PO_Created, - SUM(CASE WHEN Mast.Status = 'ST025' THEN 1 ELSE 0 END) AS Approved, - SUM(CASE WHEN Mast.Status = 'ST051' THEN 1 ELSE 0 END) AS Approver_Onhold, - SUM(CASE WHEN Mast.Status = 'ST052' THEN 1 ELSE 0 END) AS Releaser_Onhold, - SUM(CASE WHEN Mast.Status = 'ST053' THEN 1 ELSE 0 END) AS Service_completed, - SUM(CASE WHEN Mast.Status = 'ST026' THEN 1 ELSE 0 END) AS Released, - SUM(CASE WHEN Mast.Status = 'ST027' THEN 1 ELSE 0 END) AS IGR_Created, - SUM(CASE WHEN Mast.Status = 'ST044' THEN 1 ELSE 0 END) AS MRIR_Approved, - SUM(CASE WHEN Mast.Status = 'ST045' THEN 1 ELSE 0 END) AS MRIR_Rejected, -SUM(CASE WHEN Mast.Status = 'ST056' THEN 1 ELSE 0 END) AS Special_po -from T_PO_Detail Mast -left JOIN T_Requestion_Master as Req on Req.ReqNo=Mast.ReqNo -left JOIN T_DepartmentDetails Dept_Details on Dept_Details.DEPCode=Req.RequestedDept -where Mast.PODate >= '".$fa."-04-01' and Mast.PODate <= '".$aa."-03-31' -group by Dept_Name"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function report_ccr($fa,$aa){ - - - $sql="SELECT Cost_Center_Code,Cost_Center_Name,Dept_Name,BudgetType,BudgetYear,sum(Util_Amount) as Util_Amount, -budget - sum(Util_Amount) as Avlbl_Amt -FROM cost_center -where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31' -group by Cost_Center_Code,BudgetYear,BudgetType"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - - } - - - function report_MMSupplier(){ - - - $sql="select po.PODate as Material_Date,po.SupplierID,sup.SupplierName,pl.MaterialCode,mm.MaterialName,mm.MaterialType,mm.UOM,mm.HSNCODE -from T_PurchaseOrder_Master po -join T_PurchaseOrder_LineItem pl on pl.PONO=po.PONO -join T_MaterialMaster mm on mm.MaterialCode=pl.MaterialCode -join T_SupplierDetailsN sup on sup.SupplierID=po.SupplierID -group by po.SupplierID,pl.MaterialCode"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function report_MMItem(){ - - - $sql="SELECT MaterialCode,MaterialName,UOM,Category,HSNCODE FROM T_MaterialMaster group by MaterialCode"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function report_MMReceiptValue($fa,$aa,$m){ - - - $sql="select -DATE_FORMAT(IF(pm.PODate = '0000-00-00', NOW(), pm.PODate), '%b-%Y') AS Month, -matv.MaterialCode,mat.MaterialName,mat.UOM,ROUND(AVG(matv.Rate),2) as Average_Rate -from T_MaterialItem_PO matv -join T_PurchaseOrder_Master pm on pm.CreatedDate = matv.CreatedDate -join T_MaterialMaster mat on matv.MaterialCode=mat.MaterialCode -where pm.PODate != 0 "; -if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - $sql.=" group by matv.MaterialCode"; - $sql.=" order by monthname(pm.PODate)"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - function report_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ - - - $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date, -TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, -ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0) as discount, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, -ifnull(rt.Insurance,0) as insurance, -round(( - if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(pl.Quantity * pl.Rate),0))) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ ifnull(rt.Insurance,0) -- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total - FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027'"; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - - - -$sql.="group by pono,material_name,supplier_name"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function report_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d){ - - - $sql="SELECT pm.PONO as pono,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as created_date, -TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, -ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0) as discount, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) as freight, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) as Package, -ifnull(rt.Insurance,0) as insurance, -round(( - if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(pl.Quantity * pl.Rate),0))) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ ifnull(rt.Insurance,0) -- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total - FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($sid!= ''){ - - $sql.=" and sd.SupplierID = '".$sid."' "; - - } - if ($mid!= ''){ - - $sql.=" and mm.MaterialCode = '".$mid."' "; - - } - if ($d!= ''){ - - $sql.=" and date(pm.PODate) = '".$d."' "; - - } - - - -$sql.="group by pono,material_name,supplier_name"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function report_finyear(){ - - - $sql="SELECT - CASE WHEN MONTH(PODate)>=4 THEN - concat(YEAR(PODate), '-',YEAR(PODate)+1) - ELSE concat(YEAR(PODate)-1,'-', YEAR(PODate)) END AS financial_year - FROM T_PurchaseOrder_Master -GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function ireport_finyear(){ - - $sql="SELECT - CASE WHEN MONTH(MaterialRcvdDate)>=4 - THEN concat(YEAR(MaterialRcvdDate), '-',YEAR(MaterialRcvdDate)+1) - ELSE concat(YEAR(MaterialRcvdDate)-1,'-', YEAR(MaterialRcvdDate)) - END AS financial_year - FROM T_IGR_Master - GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - } - - function report_year_wise($a=null, $b=null){ - - - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,pm.POdate as created_date,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and date(pm.POdate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' -group by month(created_date)"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - function customer_name(){ - $sql="SELECT distinct SupplierName FROM T_SupplierDetailsN;"; - $query = $this->db->query($sql); - return $query->result(); - } - function material_name(){ - $sql="SELECT distinct MaterialName FROM T_MaterialMaster;"; - $query = $this->db->query($sql); - return $query->result(); - } - function category(){ - $sql="SELECT distinct Category FROM T_MaterialMaster;"; - $query = $this->db->query($sql); - return $query->result(); - } - function report_month_wise($mont){ - $month= date("m",strtotime($mont)); - $year = date("Y",strtotime($mont)); - - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and month(pm.PODate)= ? and year(pm.PODate) = ? -group by supplier_name,material_name"; - $query = $this->db->query($sql,array($month,$year)); - return $query->result(); - } - function report_year_wise_total($a,$b){ - - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and date(pm.POdate) >= '$a-04-01' and date(pm.PODate) <= '$b-03-31' -group by supplier_name,material_name"; - $query = $this->db->query($sql,array()); - return $query->result(); - } - - function report_supplier($cname,$fa,$aa,$m,$frm,$t){ - - - $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(pm.PONO) as counts,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as value, - -case pm.POType -when 'IMPORT' -then ifnull((sum(distinct(pl.Quantity * pl.Rate) * pm.ExchangeRate) -),0) + ifnull(rt.Insurance,0) -when 'CAPITAL' -then sum(distinct if(pm.CapitalRange=0,(( pl.Quantity * pl.Rate) * pm.ExchangeRate),( pl.Quantity * pl.Rate) -- st.Afterdiscountval)) -+ ifnull(sum(distinct st.After_SGST),0) -+ ifnull(sum(distinct st.After_CGST),0) -+ ifnull(sum(distinct st.After_IGST),0) -+ ifnull(sum(distinct st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) - - -when 'SERVICE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) -+ ifnull(sum(distinct st.After_SGST),0) -+ ifnull(sum(distinct st.After_CGST),0) -+ ifnull(sum(distinct st.After_IGST),0) -+ ifnull(sum(distinct st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) -- ifnull(sum(distinct st.Afterdiscountval),0) - -when 'REVENUE' -then ifnull(sum(distinct pl.Quantity * pl.Rate),0) -- ifnull(sum(distinct rt.AfterDiscount),0) -+ ifnull(sum(distinct rt.AfterSGST),0) -+ ifnull(sum(distinct rt.AfterCGST),0) -+ ifnull(sum(distinct rt.AfterIGST),0) -+ ifnull(sum(distinct rt.AfterFreightValue),0) -+ ifnull(sum(distinct rt.AfterPackagingValue),0) -+ ifnull(rt.Insurance,0) - -end - as total -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(pm.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; - - } - $sql.= "group by supplier_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - } - function report_consolidate($cname,$fa,$aa){ - - - $sql="select sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,mm.MaterialName as material_name, -SUM(IF(month(pm.PODate) = 4, pl.Quantity, 0)) AS April, -SUM(IF(month(pm.PODate) = 5, pl.Quantity, 0)) AS May, -SUM(IF(month(pm.PODate) = 6, pl.Quantity, 0)) AS June, -SUM(IF(month(pm.PODate) = 7, pl.Quantity, 0)) AS July, -SUM(IF(month(pm.PODate) = 8, pl.Quantity, 0)) AS August, -SUM(IF(month(pm.PODate) = 9, pl.Quantity, 0)) AS September, -SUM(IF(month(pm.PODate) = 10, pl.Quantity, 0)) AS October, -SUM(IF(month(pm.PODate) = 11, pl.Quantity, 0)) AS November, -SUM(IF(month(pm.PODate) = 12, pl.Quantity, 0)) AS December, -SUM(IF(month(pm.PODate) = 1, pl.Quantity, 0)) AS January, -SUM(IF(month(pm.PODate) = 2, pl.Quantity, 0)) AS February, -SUM(IF(month(pm.PODate) = 3, pl.Quantity, 0)) AS March, -sum(pl.Quantity) as qtotal, -SUM(IF(month(pm.PODate) = 4, pl.Quantity * pl.Rate, 0)) AS vApril, -SUM(IF(month(pm.PODate) = 5, pl.Quantity * pl.Rate, 0)) AS vMay, -SUM(IF(month(pm.PODate) = 6, pl.Quantity * pl.Rate, 0)) AS vJune, -SUM(IF(month(pm.PODate) = 7, pl.Quantity * pl.Rate, 0)) AS vJuly, -SUM(IF(month(pm.PODate) = 8, pl.Quantity * pl.Rate, 0)) AS vAugust, -SUM(IF(month(pm.PODate) = 9, pl.Quantity * pl.Rate, 0)) AS vSeptember, -SUM(IF(month(pm.PODate) = 10, pl.Quantity * pl.Rate, 0)) AS vOctober, -SUM(IF(month(pm.PODate) = 11, pl.Quantity * pl.Rate, 0)) AS vNovember, -SUM(IF(month(pm.PODate) = 12, pl.Quantity * pl.Rate, 0)) AS vDecember, -SUM(IF(month(pm.PODate) = 1, pl.Quantity * pl.Rate, 0)) AS vJanuary, -SUM(IF(month(pm.PODate) = 2, pl.Quantity * pl.Rate, 0)) AS vFebruary, -SUM(IF(month(pm.PODate) = 3, pl.Quantity * pl.Rate, 0)) AS vMarch, -sum(pl.Quantity * pl.Rate) as vtotal -FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - - $sql.= "group by supplier_name,material_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - } - function consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and -monthname(pm.PODate) = '".$m."' and sd.SupplierID = '".$sid."' and mm.MaterialCode = '".$mid."' "; -if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select mm.Category as category,sd.SupplierID as sid,sd.SupplierName as supplier_name,mm.MaterialCode as mid,mm.MaterialName as material_name, -sum(pl.Quantity) as quantity, -sum(pl.Quantity * pl.Rate) as total -FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierID = '".$sid."' and mm.MaterialCode = '".$mid."' "; -if ($fa and $aa != ''){ - - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function report_cumulative(){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - - $sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal -FROM (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and -(pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31') -group by supplier_name,material_name -) as year left join -(SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as mquantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as mtotal -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and -month(pm.PODate) = month(current_date()) -group by supplier_name,material_name -) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name -left join -(SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and -date(pm.PODate) = current_date() -group by supplier_name,material_name -) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name -group by supplier_name,material_name -"; - $query = $this->db->query($sql); - return $query->result(); - } - function report_cum_month($sup=null,$mat=null){ - - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and month(pm.PODate) = month(current_date()) and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function report_cum_year($sup=null,$mat=null){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and -(pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31') - and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function report_cum_day($sup=null,$mat=null){ - - $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal -FROM T_PurchaseOrder_Master pm -left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -where pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' and sd.SupplierName is not null and -date(pm.PODate) = current_date() and sd.SupplierID = '".$sup."' and mm.MaterialCode = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_purchase($cname,$prod,$fa,$aa,$m,$frm,$t,$cat){ - - - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), -(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), -(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package, - -round(( -if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) -- round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles -from T_IGR_Master im -left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO -join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode -join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO -left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO -where pm.Status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - // $sql.="and date(im.CreatedDate) >= '".$fromd."' - // and date(im.CreatedDate) <= '".$tod."'"; - $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' - and date(im.MaterialRcvdDate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($cat!= ''){ - - $sql.=" and mm.Category = '".$cat."' "; - - } - - - -$sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_purchase_link($cname,$prod,$fa,$aa,$m,$frm,$t,$sid,$mid,$d,$cat,$da,$po){ - - - $sql ="select im.IGRNO as igrn,pm.POType as potype,im.PONO as pono,date_format(im.CreatedDate,'%d-%m-%Y') as created_date,TIME_FORMAT(im.CreatedDate,'%l:%i %p') as created_time,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as materialrcvddate, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), -(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2) as discount, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), -(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) as freight, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) as Package, - -round(( -if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) -- round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles -from T_IGR_Master im -left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO -join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode -join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO -left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO - -where pm.Status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - // $sql.="and date(im.CreatedDate) >= '".$fromd."' - // and date(im.CreatedDate) <= '".$tod."'"; - - $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' - and date(im.MaterialRcvdDate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - if ($sid!= ''){ - - $sql.=" and sd.SupplierID = '".$sid."' "; - - } - if ($mid!= ''){ - - $sql.=" and mm.MaterialCode = '".$mid."' "; - - } - if ($d!= ''){ - - //$sql.=" and date(im.CreatedDate) = '".$d."' "; - $sql.=" and date(im.MaterialRcvdDate) = '".$d."' "; - - } - if ($cat!= ''){ - - $sql.=" and mm.Category = '".$cat."' "; - - } - if ($da!= ''){ - $ddd= date("Y-m-d",strtotime($da)); - - //$sql.=" and date(im.CreatedDate) = '".$ddd."' "; - $sql.=" and date(im.MaterialRcvdDate) = '".$ddd."' "; - - } - if ($po!= ''){ - - $sql.=" and im.PONO = '".$po."' "; - - } - - - -$sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; -// echo $m; -// echo $sid; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){ - - -// $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, -// sum(total) as total,file,ifile -// from igr - - $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, -sum(total) as total,file,ifile -from igr -where status != 'ST030' -"; - -if ($cname!= ''){ - - $sql.="and supplier_name = '".$cname."'"; - - } - - if ($fa and $aa != ''){ - - //$sql.=" and (created_date >= '".$fa."-04-01' and created_date <= '".$aa."-03-31')"; - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(created_date) = '".$m."'"; - $sql.="and monthname(materialrcvddate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - // $sql.="and date(created_date) >= '".$fromd."' - // and date(created_date) <= '".$tod."'"; - $sql.="and date(materialrcvddate) >= '".$fromd."' - and date(materialrcvddate) <= '".$tod."'"; - - } - - $sql.="group by pono,igrn"; -// echo $m; -// echo $sid; -//echo $sql; - $query = $this->db->query($sql); - - $filequery = $query->result(); - - $resultArray = array(); - - foreach ($filequery as $value) { - - $tempArray['pono'] = $value->pono; - $tempArray['potype'] =$value->potype; - $tempArray['supplier_name'] = $value->supplier_name; - $tempArray['materialrcvddate'] = $value->materialrcvddate; - $tempArray['total'] = $value->total; - $tempArray['created_date'] = $value->created_date; - $tempArray['file'] = $value->file; - $tempArray['ifile'] = $value->ifile; - $tempArray['igrn'] =$value->igrn; - - $sqli ="select FilePath as Infiles from T_Inwardgateregister_fileupload where PONO =? and IGRNO =? "; - $querys = $this->db->query($sqli,array( $tempArray['pono'],$tempArray['igrn'])); - - $filepath = $querys->result(); - $tempArray['Infiles'] = $filepath; - - $resultArray[] = $tempArray; - - } - - - return $resultArray; - - } - -function ireport_year_wise($a,$b){ - - -// $sql="select dat as CreatedDate,sum(quantity)as quantity,sum(value) as value, materialrcvddate -// from year_inward -// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' -// group by month(CreatedDate) -// "; -//echo $sql; - $sql="select materialrcvddate,sum(quantity)as quantity,sum(value) as value - from igr - where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31' - group by month(materialrcvddate)"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - - function ireport_month_wise($mont){ - $month= date("m",strtotime($mont)); - $year = date("Y",strtotime($mont)); - - // $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total - // from year_inward - // where status != 'ST030' and month(dat)= ? and year(dat) = ? - // group by material_name,supplier_name"; - $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate - from igr - where status != 'ST030' and month(materialrcvddate)= ? and year(materialrcvddate) = ? - group by material_name,supplier_name"; - $query = $this->db->query($sql,array($month,$year)); - return $query->result(); - } - function ireport_year_wise_total($a,$b){ - -// $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total -// from year_inward -// where status != 'ST030' and date(dat) >= '$a-04-01' and date(dat) <= '$b-03-31' -// group by material_name,supplier_name"; - $sql="select sid,mid,supplier_name,material_name,sum(quantity)as quantity,sum(value) as total,materialrcvddate - from igr - where status != 'ST030' and date(materialrcvddate) >= '$a-04-01' and date(materialrcvddate) <= '$b-03-31' - group by material_name,supplier_name"; - $query = $this->db->query($sql,array()); - return $query->result(); - } - -function ireport_supplier($cname,$fa,$aa,$m,$frm,$t){ - - - $sql="SELECT sd.SupplierID as sid,sd.SupplierName as supplier_name,count(im.PONO) as counts,ifnull(sum(id.QuantityAsPerInvoice),0) as quantity,round(ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0),2) as value, - -case pm.POType -when 'IMPORT' -then ifnull((sum((id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate) -+ ifnull(rt.Insurance,0) - -),0) -when 'CAPITAL' -then sum( if(pm.CapitalRange=0,(( id.QuantityAsPerInvoice * pl.Rate) * pm.ExchangeRate),( id.QuantityAsPerInvoice * pl.Rate) -- st.Afterdiscountval)) -+ ifnull(sum(st.After_SGST),0) -+ ifnull(sum(st.After_CGST),0) -+ ifnull(sum(st.After_IGST),0) -+ ifnull(sum(st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) - - -when 'SERVICE' -then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) -+ ifnull(sum(st.After_SGST),0) -+ ifnull(sum(st.After_CGST),0) -+ ifnull(sum(st.After_IGST),0) -+ ifnull(sum(st.AfterFreightValue),0) -+ ifnull(rt.Insurance,0) -- ifnull(sum(st.Afterdiscountval),0) - -when 'REVENUE' -then ifnull(sum(id.QuantityAsPerInvoice * pl.Rate),0) -- ifnull(sum(rt.AfterDiscount),0) -+ ifnull(sum(rt.AfterSGST),0) -+ ifnull(sum(rt.AfterCGST),0) -+ ifnull(sum(rt.AfterIGST),0) -+ ifnull(sum(rt.AfterFreightValue),0) -+ ifnull(sum(rt.AfterPackagingValue),0) -+ ifnull(rt.Insurance,0) - -end -as total,im.MaterialRcvdDate -from T_IGR_Master im -left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO -join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode -join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where pm.Status != 'ST030'"; - -if ($cname!= ''){ - - $sql.="and sd.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - //$sql.=" and (im.CreatedDate >= '".$fa."-04-01' and im.CreatedDate <= '".$aa."-03-31')"; - $sql.=" and (im.MaterialRcvdDate >= '".$fa."-04-01' and im.MaterialRcvdDate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - //$sql.="and monthname(im.CreatedDate) = '".$m."'"; - $sql.="and monthname(im.MaterialRcvdDate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - // $sql.="and date(im.CreatedDate) >= '".$fromd."' - // and date(im.CreatedDate) <= '".$tod."'"; - $sql.="and date(im.MaterialRcvdDate) >= '".$fromd."' - and date(im.MaterialRcvdDate) <= '".$tod."'"; - - } - $sql.= "group by supplier_name"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - } -function ireport_consolidate($cname,$fa,$aa){ - - - $sql="select sid,mid,supplier_name,material_name, -SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April, -SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May, -SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June, -SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July, -SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August, -SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September, -SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October, -SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November, -SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December, -SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January, -SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February, -SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March, -sum(quantity) as qtotal, -SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril, -SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay, -SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune, -SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly, -SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust, -SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember, -SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober, -SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember, -SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember, -SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary, -SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary, -SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch, -sum(value) as vtotal -FROM igr -where status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and supplier_name = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - // $sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - - $sql.= "group by supplier_name,material_name"; - // echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - } -function i_consolidate_month($m=null,$sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total -from igr -where status != 'ST030' and -monthname(materialrcvddate) = '".$m."' and sid = '".$sid."' and mid = '".$mid."' "; -if ($fa and $aa != ''){ - - //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function i_consolidate_year($sid=null,$mid=null,$fa=null,$aa=null){ - - $sql="select sid,mid,supplier_name,material_name,sum(quantity) as quantity,sum(value) as total -from igr -where status != 'ST030' and sid = '".$sid."' and mid = '".$mid."' "; -if ($fa and $aa != ''){ - - //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - $sql.= "group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function ireport_cumulative(){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal -FROM (SELECT sid,mid,supplier_name,material_name,sum(Quantity) as quantity,sum(value) as total,materialrcvddate -FROM igr -where status != 'ST030' and -(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') -group by supplier_name,material_name -) as year left join -(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as mquantity,sum(value) as mtotal -FROM igr -where status != 'ST030' and -month(materialrcvddate) = month(current_date()) -group by supplier_name,material_name -) as month on month.supplier_name=year.supplier_name and month.material_name=year.material_name -left join -(SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -date(materialrcvddate) = current_date() -group by supplier_name,material_name -) as today on today.supplier_name=month.supplier_name and today.material_name=month.material_name -group by supplier_name,material_name -"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_month($sup=null,$mat=null){ - - $sql="SELECT sid,mid,supplier_name,material_name,sum(Quantity) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -month(materialrcvddate) = month(current_date()) and sid = '".$sup."' and mid = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_year($sup=null,$mat=null){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') -and sid = '".$sup."' and mid= '".$mat."' -group by supplier_name,material_name -"; - $query = $this->db->query($sql); - return $query->result(); - } - function ireport_cum_day($sup=null,$mat=null){ - - $sql="SELECT sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -date(materialrcvddate) = current_date() and sid = '".$sup."' and mid = '".$mat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cumulative(){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT year.category as category,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal -FROM (SELECT category,sum(Quantity) as quantity,sum(value) as total -FROM igr -where status != 'ST030' and -(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') -group by category -) as year left join -(SELECT category,sum(Quantity) as mquantity,sum(value) as mtotal -FROM igr -where status != 'ST030' and -month(materialrcvddate) = month(current_date()) -group by category -) as month on month.category=year.category -left join -(SELECT category,sum(Quantity) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -date(materialrcvddate) = current_date() -group by category -) as today on today.category=month.category -group by category "; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cum_year($cat=null){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -(materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31') -and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function rawi_report_cum_month($cat=null){ - - $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -month(materialrcvddate) = month(current_date()) and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - return $query->result(); - } - function rawi_report_cum_day($cat=null){ - - $sql="SELECT category,sid,mid,supplier_name,material_name,IF(Quantity IS NULL or Quantity = '', 0, sum(Quantity)) as tquantity,sum(value) as ttotal -FROM igr -where status != 'ST030' and -date(materialrcvddate) = current_date() and category = '".$cat."' -group by supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function rawi_report_consolidate($cname,$fa,$aa){ - - - $sql="select sid,mid,category,supplier_name,material_name, -SUM(IF(month(materialrcvddate) = 4, quantity, 0)) AS April, -SUM(IF(month(materialrcvddate) = 5, quantity, 0)) AS May, -SUM(IF(month(materialrcvddate) = 6, quantity, 0)) AS June, -SUM(IF(month(materialrcvddate) = 7, quantity, 0)) AS July, -SUM(IF(month(materialrcvddate) = 8, quantity, 0)) AS August, -SUM(IF(month(materialrcvddate) = 9, quantity, 0)) AS September, -SUM(IF(month(materialrcvddate) = 10, quantity, 0)) AS October, -SUM(IF(month(materialrcvddate) = 11, quantity, 0)) AS November, -SUM(IF(month(materialrcvddate) = 12, quantity, 0)) AS December, -SUM(IF(month(materialrcvddate) = 1, quantity, 0)) AS January, -SUM(IF(month(materialrcvddate) = 2, quantity, 0)) AS February, -SUM(IF(month(materialrcvddate) = 3, quantity, 0)) AS March, -sum(quantity) as qtotal, -SUM(IF(month(materialrcvddate) = 4, value, 0)) AS vApril, -SUM(IF(month(materialrcvddate) = 5, value, 0)) AS vMay, -SUM(IF(month(materialrcvddate) = 6, value, 0)) AS vJune, -SUM(IF(month(materialrcvddate) = 7, value, 0)) AS vJuly, -SUM(IF(month(materialrcvddate) = 8, value, 0)) AS vAugust, -SUM(IF(month(materialrcvddate) = 9, value, 0)) AS vSeptember, -SUM(IF(month(materialrcvddate) = 10, value, 0)) AS vOctober, -SUM(IF(month(materialrcvddate) = 11, value, 0)) AS vNovember, -SUM(IF(month(materialrcvddate) = 12, value, 0)) AS vDecember, -SUM(IF(month(materialrcvddate) = 1, value, 0)) AS vJanuary, -SUM(IF(month(materialrcvddate) = 2, value, 0)) AS vFebruary, -SUM(IF(month(materialrcvddate) = 3, value, 0)) AS vMarch, -sum(value) as vtotal -FROM igr -where status != 'ST030' "; - -if ($cname!= ''){ - - $sql.="and Category = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - //$sql.=" and (dat >= '".$fa."-04-01' and dat <= '".$aa."-03-31')"; - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - - $sql.= "group by category"; - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - } -function rawi_consolidate_month($m=null,$cat=null,$sup=null,$fa=null,$aa=null){ - - $sql="select category,sid,supplier_name,mid,material_name, -sum(Quantity) as quantity, -sum(value) as total -FROM igr -where status != 'ST030' and -monthname(materialrcvddate) = '".$m."' and category = '".$cat."' "; -if ($fa and $aa != ''){ - - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - $sql.= "group by category,supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function rawi_consolidate_year($cat=null,$sup=null,$fa=null,$aa=null){ - - $sql="select category,sid,supplier_name,mid,material_name, -sum(Quantity) as quantity, -sum(value) as total -FROM igr -where status != 'ST030' and -category = '".$cat."' "; -if ($fa and $aa != ''){ - - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - $sql.= "group by category,supplier_name,material_name"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function pending_purchase($cname,$prod,$fa,$aa,$m,$frm,$t){ - - $sql="select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending -from T_PurchaseOrder_LineItem pl -join T_PurchaseOrder_Master po on po.PONO = pl.PONO -join T_SupplierDetailsN sup on sup.SupplierID=po.SupplierID -join T_MaterialMaster mm on mm.MaterialCode=pl.MaterialCode -where po.Status != 'ST030' and po.Status = 'ST026' - "; -if ($cname!= ''){ - - $sql.="and sup.SupplierName = '".$cname."'"; - - } - - - - if ($fa and $aa != ''){ - - $sql.=" and (po.PODate >= '".$fa."-04-01' and po.PODate <= '".$aa."-03-31')"; - - } - if ($m!= ''){ - - $sql.="and monthname(po.PODate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(po.PODate) >= '".$fromd."' - and date(po.PODate) <= '".$tod."'"; - - } - if ($prod!= ''){ - - $sql.=" and mm.MaterialName = '".$prod."' "; - - } - // if ($cat!= ''){ - - // $sql.=" and mm.Category = '".$cat."' "; - - // } - $sql.="order by po.PONO"; - $query = $this->db->query($sql); - //echo $sql; - return $query->result(); - } - function monthly_gst_purchase($m,$frm,$t,$fa,$aa){ - - $sql="select sum(sgst) as sgst,sum(cgst) as cgst,sum(igst) as igst,sum(sgst + cgst + igst) as total from igr -where pono != 'null' "; - - if ($m!= ''){ - - $sql.="and monthname(materialrcvddate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and materialrcvddate >= '".$fromd."' - and materialrcvddate <= '".$tod."'"; - - } - if ($fa and $aa != ''){ - - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - - - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - public function monthly_gst_sales($m=null,$frm=null,$t=null,$fa=null,$aa=null) - { - - $sql = "select ii.invoice_id as invoice_id,ifnull(iii.invnum,'-') as parent_invoice_id,ii.client_id as client_id,ii.invoice_number as invoice_number,date_format(ii.invoice_date_created,'%d-%m-%Y') as dates,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as item_subtotal, - sum(ifnull(((sgst.tax_rate_percent * (iia.item_subtotal))/100),0)) - as sgst, - sum(ifnull(((iia.item_subtotal) * cgst.tax_rate_percent)/100,0)) - as cgst, - sum(ifnull((igst.tax_rate_percent * (iia.item_subtotal))/100,0)) - as igst, - sum((ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) - + - ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) - + - ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))) - as total - from ip_invoices ii - join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id - join ip_invoice_items iit on iit.invoice_id = ii.invoice_id - join ip_invoice_item_amounts iia on iia.item_id = iit.item_id - join ip_clients ic on ic.client_id = ii.client_id - join ip_products ip on ip.product_id = iit.item_product_id - left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id - left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id - left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id - left join (select inv.invoice_id as inv_id,inv.invoice_number,iii.invnum from ip_invoices inv - left join - (select ii.invoice_id as ii,ii.invoice_number as invnum,ic.invoice_number as icnum,ic.creditinvoice_parent_id as cp from ip_invoices as ii - left join ip_invoices as ic on ii.invoice_id = ic.creditinvoice_parent_id) as iii - on iii.icnum = inv.invoice_number) as iii on iii.inv_id = ii.invoice_id - where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 "; - - - - - if ($m!= ''){ - - $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromdate= date("Y-m-d",strtotime($frm)); - $todate=date("Y-m-d",strtotime($t)); - - $sql.="and ii.invoice_date_created >= '".$fromdate."' - and ii.invoice_date_created <= '".$todate."'"; - - } - if ($fa and $aa != ''){ - - $sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')"; - - } - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - - } - function sales_gst($m=null,$frm=null,$t=null,$fa=null,$aa=null) - { - - $sql = "select ii.invoice_id as invoice_id,'Sales' as doc_type,ip.product_sku as hsn_code,ifnull(iii.invnum,'-') as parent_invoice_id,ii.client_id as client_id,ii.invoice_number as doc_no,date_format(ii.invoice_date_created,'%d-%m-%Y') as date,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as value, - sum(ifnull(((sgst.tax_rate_percent * (iia.item_subtotal))/100),0)) - as sgst, - sum(ifnull(((iia.item_subtotal) * cgst.tax_rate_percent)/100,0)) - as cgst, - sum(ifnull((igst.tax_rate_percent * (iia.item_subtotal))/100,0)) - as igst, - sum((iia.item_subtotal + ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) - + - ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) - + - ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))) - as total - from ip_invoices ii - join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id - join ip_invoice_items iit on iit.invoice_id = ii.invoice_id - join ip_invoice_item_amounts iia on iia.item_id = iit.item_id - join ip_clients ic on ic.client_id = ii.client_id - join ip_products ip on ip.product_id = iit.item_product_id - left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id - left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id - left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id - left join (select inv.invoice_id as inv_id,inv.invoice_number,iii.invnum from ip_invoices inv - left join - (select ii.invoice_id as ii,ii.invoice_number as invnum,ic.invoice_number as icnum,ic.creditinvoice_parent_id as cp from ip_invoices as ii - left join ip_invoices as ic on ii.invoice_id = ic.creditinvoice_parent_id) as iii - on iii.icnum = inv.invoice_number) as iii on iii.inv_id = ii.invoice_id - where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 and ii.invoice_status_id != 1 "; - - - - if ($m!= ''){ - - $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromdate= date("Y-m-d",strtotime($frm)); - $todate=date("Y-m-d",strtotime($t)); - - $sql.="and ii.invoice_date_created >= '".$fromdate."' - and ii.invoice_date_created <= '".$todate."'"; - - } - if ($fa and $aa != ''){ - - $sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')"; - - } - - - // echo $fromdate; - //echo $sql; - $sql.="group by doc_no,product_description"; - $query = $this->db->query($sql); - return $query->result(); - - - } - function purchase_gst($m,$frm,$t,$fa,$aa){ - - - $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as doc_no,'Purchase' as doc_type,mm.HSNCODE as hsn_code,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as date, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst, -round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), -(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst, -(round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) -+ round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), -(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) -- round(ifnull(if(POType = 'REVENUE', -(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), -(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)) as others, -round(( -if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), -ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), - (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), - (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) -+ round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) -- round(ifnull(if(POType = 'REVENUE', - (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), - (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file -from T_IGR_Master im -left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO -join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode -join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO -where pm.Status != 'ST030' "; - - - if ($m!= ''){ - - $sql.="and monthname(materialrcvddate) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(materialrcvddate) >= '".$fromd."' - and date(materialrcvddate) <= '".$tod."'"; - - } - if ($fa and $aa != ''){ - - $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; - - } - - -$sql.="group by doc_no,material_name,category,supplier_name,id.IGRItemNo"; -//echo $sql; - $query = $this->db->query($sql); - return $query->result(); - } - function report_inwardcashbook($cname,$fa,$aa,$m,$frm,$t,$cat){ - - $sql="select tinex.account_code as AccountCode,date_format(tinex.date,'%d-%m-%Y') as Date,ac.name as AccountName,date_format(tinex.created_on,'%d-%m-%Y') as CreatedDate, - tinex.type as type,tinex.cashtype as category ,tinex.merchant as merchantname,tinex.Supplier_id as Supplierid,sup.SupplierName as Suppliername, tinex.sgst as sgst, - tinex.value_before_gst as Value,tinex.cgst as cgst,tinex.igst as igst,tinex.document as cashbookfile, - tinex.total as Total - FROM t_income_expense tinex - join t_accountcode ac on ac.code = tinex.account_code - join T_SupplierDetailsN sup on sup.SupplierID = tinex.Supplier_id - where tinex.gststatus = '1' "; - - if ($cname!= ''){ - // $sql.="and tinex.merchant = '".$cname."'"; - $sql.="and sup.SupplierName = '".$cname."'"; - } - - if ($fa and $aa != ''){ - $sql.=" and (tinex.date >= '".$fa."-04-01' and tinex.date <= '".$aa."-03-31')"; - } - if ($m!= ''){ - $sql.="and monthname(tinex.date) = '".$m."'"; - } - if ($frm and $t != ''){ - $fromd= date("Y-m-d",strtotime($frm)); - $tod=date("Y-m-d",strtotime($t)); - - $sql.="and date(tinex.date) >= '".$fromd."' - and date(tinex.date) <= '".$tod."'"; - } - if ($cat!= ''){ - $sql.=" and tinex.type = '".$cat."' "; - } - $query = $this->db->query($sql); - return $query->result(); - } - - function cashbook() - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code "; - $query = $this->db->query($sql); - return $query->result(); - } - //home --this month// - function monthexpensereport($month,$year) - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then sum(tinc.total) - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then sum(tinc.total) - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,monthname(tinc.date)as month,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where month(tinc.date)= ".$month." and year(tinc.date)=".$year." group by tinc.account_code"; - //tinc.total,tinc.towhom,tinc.description,monthname(tinc.date)as month,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where month(tinc.date)= month(current_date())group by tinc.account_code"; - $query = $this->db->query($sql); - return $query->result(); - - } - //home--this year// - function yearexpensereport($fa,$aa) - { - $sql="select monthname(date) as month, - sum(if(type='PAYMENT',total,0)) as exp, - sum(if(type='RECEIPT',total,0)) as inc, - sum(total) as total - from t_income_expense - where date >= '".$fa."-04-01' and date <= '".$aa."-03-31' - group by month - ORDER BY FIELD(month,'April','May','June','July','August','September','October','November','December','January', 'February', 'March') "; - $query = $this->db->query($sql); - return $query->result(); - - } - - /** //home--report--Day Wise Report // - function today_data($value='') - { - $sql="SELECT type,Sum(total) as todaydata FROM t_income_expense WHERE type = ? AND DATE(date) = CURRENT_DATE"; - $query = $this->db->query($sql,array($value)); - return $query->result(); - - } - - function monthwise_data($value='') - { - $sql="SELECT type,Sum(total) as monthlydata FROM t_income_expense WHERE type = ? AND MONTH(date) = MONTH(curdate())"; - $query = $this->db->query($sql,array($value)); - return $query->result(); - - } - function yearwise_data($value='') - { - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - - $sql="SELECT type,sum(total) as yearlydata from t_income_expense - where - type = ? and (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - $query = $this->db->query($sql,array($value)); - return $query->result(); - - }**/ - //home--report--Day Wise Report // -function today_data() -{ - $sql="SELECT sum(if(type = 'RECEIPT',total,0)) as daily_income_amt, - sum(if(type = 'PAYMENT',total,0)) as daily_expenses_amt - FROM t_income_expense - WHERE DATE(date) = CURRENT_DATE"; - $query = $this->db->query($sql); - return $query->result(); - -} - -function monthwise_data() -{ - //$sql="SELECT type,Sum(total) as monthlydata FROM t_income_expense WHERE type = ? AND MONTH(date) = MONTH(curdate())"; - $sql="SELECT sum(if(type = 'RECEIPT',total,0)) as monthly_income_amt, - sum(if(type = 'PAYMENT',total,0)) as monthly_expenses_amt - FROM t_income_expense - WHERE YEAR(date) = YEAR(curdate()) AND MONTH(date) = MONTH(curdate())"; - $query = $this->db->query($sql); - //,array($value)); - return $query->result(); - -} -function yearwise_data() -{ -if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - - $sql="SELECT sum(if(type = 'RECEIPT',total,0)) as yearly_income_amt, - sum(if(type = 'PAYMENT',total,0)) as yearly_expenses_amt - FROM t_income_expense - WHERE (date >= '".$fa."-04-01' and date <= '".$aa."-03-31')"; - $query = $this->db->query($sql); - return $query->result(); - -} - function departmentwise($sid,$d,$c='',$fy,$ty) - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,.tinc.description, ac.name FROM - t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE tinc.type='$c'"; - if ($sid != ''){ - $sql.="and account_code = '".$sid."'"; - } - if ($d != ''){ - $sql.="and monthname(date)='".$d."'"; - } - if ($fy and $ty != ''){ - - $sql.=" and (tinc.date >= '".$fy."-04-01' and tinc.date <= '".$ty."-03-31')"; - - } - // -- WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; - $query = $this->db->query($sql); - return $query->result(); - - } - //yearwise/month// - function yearmonthwise($sid='') - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then sum(tinc.total) - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then sum(tinc.total) - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.account_code,sum(tinc.total)as total,monthname(tinc.date)as month,tinc.description,tinc.towhom,tinc.account_code,ac.name FROM t_income_expense tinc - join t_accountcode ac on ac.code=tinc.account_code - WHERE monthname(date) = ? group by tinc.account_code"; - $query = $this->db->query($sql,array($sid)); - //print_r($this->db->last_query()); - return $query->result(); - - } - //for dashboard graph in cashbook// - function gettoptotal(){ - $i=1; - - while($i<=12){ - $sql="SELECT sum(total) as tot FROM t_income_expense where month(date)= $i"; - // $sql="SELECT sum(total)as ttl,concat(sum(total),'-',account_code)as atotal FROM t_income_expense where month(date)= $i - // group by account_code order by ttl desc limit 4"; - - $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //return $query->result(); - $array_result[]=$query->result(); - $i++; - - } - - return $array_result; - -} -function INRSymbol() - { - $sql='select FontCode2000 from T_Currency_Details where Currency_Code="INR"'; - $query=$this->db->query($sql); - return $query->result(); - } - - function cashbookfinyear(){ - - - $sql="SELECT - CASE WHEN MONTH(date)>=4 THEN - concat(YEAR(date), '-',YEAR(date)+1) - ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year - FROM t_income_expense - GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - - - } - function today() - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,tinc.document,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE DATE(date) = CURRENT_DATE"; - $query = $this->db->query($sql); - return $query->result(); - } - // $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,tinc.description,tinc.account_code,tac.name FROM t_income_expense tinc - // LEFT JOIN t_accountcode tac ON tac.code = tinc.account_code - // WHERE DATE(date) = CURRENT_DATE"; - // $query = $this->db->query($sql); - // return $query->result(); - //} - - function monthlypayments() - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE MONTH(date) = MONTH(curdate()) group by account_code"; - $query = $this->db->query($sql); - //print_r($this->db->last_query()); - return $query->result(); - - } - - //home page --Reports// - function departmentmenu($fdate,$tdate,$fa,$aa) - { - - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.total - end,'0') as expense, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.total - end, '0') as income, - ifnull(case - when tinc.type = 'PAYMENT' - then tinc.towhom - end,'-') as paymentname, - ifnull(case - when tinc.type = 'RECEIPT' - then tinc.towhom - end, '-') as receiptname, - tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.document,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.date !=0 "; - if ($fdate and $tdate != ''){ - $fdate= date("Y-m-d",strtotime($fdate)); - $tdate=date("Y-m-d",strtotime($tdate)); - - $sql.="and date(tinc.date) >= '".$fdate."' - and date(tinc.date) <= '".$tdate."'"; - } - if ($fa and $aa != ''){ - - $sql.=" and (tinc.date >= '".$fa."-04-01' and tinc.date <= '".$aa."-03-31')"; - - } - - - $query = $this->db->query($sql); - //echo $fdate; - //print_r($this->db->last_query()); - //echo $sql; - return $query->result(); - - } - function menudepartmentwise($sid='') - { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.document,tinc.towhom,tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE account_code = '$sid'"; - $query = $this->db->query($sql); - //print_r($this->db->last_query()); - //echo $sql; - return $query->result(); - - } - function report_cumulative_cashbook(){ - - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - - - $sql = "SELECT year.name as name,year.yearexpense as yexp,year.yearincome as yinc,month.monthexpense as mexp,month.monthincome as minc,today.todayexpense as texp,today.todayincome as tinc - FROM (select ac1.name, ifnull(case - when tinc1.type = 'PAYMENT' - then sum(tinc1.total) - end,'0') as yearexpense, - ifnull(case - when tinc1.type = 'RECEIPT' - then sum(tinc1.total) - end, '0') as yearincome - FROM t_income_expense tinc1 - join t_accountcode ac1 on ac1.code = tinc1.account_code - WHERE (tinc1.date >= '".$fa."-04-01' and tinc1.date <= '".$aa."-03-31') - group by ac1.name ) as year - left join - (select ac2.name ,ifnull(case - when tinc2.type = 'PAYMENT' - then sum(tinc2.total) - end,'0') as monthexpense, - ifnull(case - when tinc2.type = 'RECEIPT' - then sum(tinc2.total) - end, '0') as monthincome - FROM t_income_expense tinc2 - join t_accountcode ac2 on ac2.code = tinc2.account_code - where month(tinc2.date) = month(current_date()) - group by ac2.name) as month on month.name = year.name - left join - (select ac3.name ,ifnull(case - when tinc3.type = 'PAYMENT' - then sum(tinc3.total) - end,'0') as todayexpense, - ifnull(case - when tinc3.type = 'RECEIPT' - then sum(tinc3.total) - end, '0') as todayincome - FROM t_income_expense tinc3 - join t_accountcode ac3 on ac3.code = tinc3.account_code - where date(tinc3.date) = current_date() - group by ac3.name ) as today on today.name=month.name - group by name "; - $query = $this->db->query($sql); - return $query->result(); - } - - /** function monthbeforetotal($month,$year){ - - $sql="SELECT month(date) as monthnum ,year(date) as yearnum, - sum(if(type = 'PAYMENT',total,0)) as payment_amt, - sum(if(type = 'RECEIPT',total,0)) as receipt_amt - FROM t_income_expense - WHERE - month(date) = '".$month."'and year(date) = '".$year."'"; - $query = $this->db->query($sql); - return $query->result(); - - } - - function yearbeforetotal($pre,$curr){ - $sql="SELECT - sum(if(type = 'PAYMENT',total,0)) as payment_amt, - sum(if(type = 'RECEIPT',total,0)) as receipt_amt - FROM t_income_expense - where date >= '".$pre."-04-01' and date <= '".$curr."-03-31'"; - $query = $this->db->query($sql); - return $query->result(); - //print_r($query->result()); - - } - -function daybeforetotal($yesterday){ - $sql="select date, - sum(if(type = 'PAYMENT',total,0)) as payment_amt, - sum(if(type = 'RECEIPT',total,0)) as receipt_amt - from t_income_expense - where date = ? "; - $query = $this->db->query($sql,array($yesterday)); - return $query->result(); - }**/ - - -function getYearlyOpeningAmt($prev_year){ - $sql="SELECT min(date),(sum(if(type = 'RECEIPT',total,0)) - sum(if(type = 'PAYMENT',total,0)) ) as opening_amt - FROM t_income_expense - WHERE date >= (select min(date) from t_income_expense) and date <= '".$prev_year."-03-31' "; - $query = $this->db->query($sql); - return $query->result(); - //print_r($query->result()); - - } - - //function monthbeforetotal($month,$year){ - function getMonthlyOpeningAmt($dateformat){ - - $sql="SELECT month('".$dateformat."') as monthnum ,year('".$dateformat."') as yearnum, - (sum(if(type = 'RECEIPT',total,0)) - sum(if(type = 'PAYMENT',total,0))) as opening_amt - FROM t_income_expense - WHERE date >= (select min(date) from t_income_expense) and date <= '".$dateformat."'"; - //WHERE month(date) between (select month(min(date)) from t_income_expense) and '".$month."' and year(date) = '".$year."'"; - $query = $this->db->query($sql); - return $query->result(); - -} - - -//function daybeforetotal($yesterday){ -function getDailyOpeningAmt($yesterday){ - $sql="select date,(sum(if(type = 'RECEIPT',total,0)) - sum(if(type = 'PAYMENT',total,0))) as opening_amt - from t_income_expense - where date between (select min(date) from t_income_expense) and '".$yesterday."'"; - $query = $this->db->query($sql); - return $query->result(); - } - - function accountname() - { - $sql = "SELECT name from t_accountcode "; - $query = $this->db->query($sql); - return $query->result(); - } - - function cashbook_finyear(){ - - $sql="SELECT - CASE WHEN MONTH(date)>=4 THEN - concat(YEAR(date), '-',YEAR(date)+1) - ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year - FROM t_income_expense - GROUP BY financial_year"; - $query = $this->db->query($sql); - return $query->result(); - - } - - //function report_cumulative_month_cashbook(){ - function report_cumulative_month_cashbook($cname,$yr1,$yr2){ - - if ($yr1 == '' && $yr2 == ''){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - } - else{ - $fa=$yr1; - $aa=$yr2; - } - - $sql = "select tinc.account_code,ac.name,tinc.type, - SUM(IF(month(tinc.date) = 4, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS AprilExpense, - SUM(IF(month(tinc.date) = 4, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS AprilIncome, - SUM(IF(month(tinc.date) = 5, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS MayExpense, - SUM(IF(month(tinc.date) = 5, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS MayIncome, - SUM(IF(month(tinc.date) = 6, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JuneExpense, - SUM(IF(month(tinc.date) = 6, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JuneIncome, - SUM(IF(month(tinc.date) = 7, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JulyExpense, - SUM(IF(month(tinc.date) = 7, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JulyIncome, - SUM(IF(month(tinc.date) = 8, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS AugustExpense, - SUM(IF(month(tinc.date) = 8, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS AugustIncome, - SUM(IF(month(tinc.date) = 9, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS SepExpense, - SUM(IF(month(tinc.date) = 9, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS SepIncome, - SUM(IF(month(tinc.date) = 10, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS OctExpense, - SUM(IF(month(tinc.date) = 10, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS OctIncome, - SUM(IF(month(tinc.date) = 11, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS NovExpense, - SUM(IF(month(tinc.date) = 11, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS NovIncome, - SUM(IF(month(tinc.date) = 12, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS DecExpense, - SUM(IF(month(tinc.date) = 12, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS DecIncome, - SUM(IF(month(tinc.date) = 1, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS JanExpense, - SUM(IF(month(tinc.date) = 1, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS JanIncome, - SUM(IF(month(tinc.date) = 2, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS FebExpense, - SUM(IF(month(tinc.date) = 2, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS FebIncome, - SUM(IF(month(tinc.date) = 3, IF(tinc.type = 'PAYMENT', tinc.total, 0), 0)) AS MarExpense, - SUM(IF(month(tinc.date) = 3, IF(tinc.type = 'RECEIPT', tinc.total, 0), 0)) AS MarIncome, - SUM(IF(tinc.type = 'RECEIPT', tinc.total, 0)) AS receiptoverall, - SUM(IF(tinc.type = 'PAYMENT', tinc.total, 0)) AS paymentoverall, - SUM(tinc.total) as overalltotal - from t_income_expense tinc - join t_accountcode ac on ac.code = tinc.account_code - where (tinc.date >='".$fa."-04-01' and tinc.date <= '".$aa."-03-31')"; - if ($cname!= ''){ - $sql.="and ac.name = '".$cname."'"; - } - $sql.= " group by tinc.account_code"; - $query = $this->db->query($sql); - return $query->result(); - - } -} -?> \ No newline at end of file diff --git a/application/models/models/department_model.php b/application/models/models/department_model.php deleted file mode 100644 index 445c9350..00000000 --- a/application/models/models/department_model.php +++ /dev/null @@ -1,134 +0,0 @@ -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; - } - - - - - - } -?> \ No newline at end of file diff --git a/application/models/models/employeedetails_model.php b/application/models/models/employeedetails_model.php deleted file mode 100644 index 093c1555..00000000 --- a/application/models/models/employeedetails_model.php +++ /dev/null @@ -1,210 +0,0 @@ -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(); - } -} -?> \ No newline at end of file diff --git a/application/models/models/emppaydate_model.php b/application/models/models/emppaydate_model.php deleted file mode 100644 index 62c138bd..00000000 --- a/application/models/models/emppaydate_model.php +++ /dev/null @@ -1,103 +0,0 @@ -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; - } - - -} -?> diff --git a/application/models/models/index.html b/application/models/models/index.html deleted file mode 100644 index c942a79c..00000000 --- a/application/models/models/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - 403 Forbidden - - - -

Directory access is forbidden.

- - - \ No newline at end of file diff --git a/application/models/models/inwardgateregister_model.php b/application/models/models/inwardgateregister_model.php deleted file mode 100644 index bf28a512..00000000 --- a/application/models/models/inwardgateregister_model.php +++ /dev/null @@ -1,856 +0,0 @@ -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; -} - -} \ No newline at end of file diff --git a/application/models/models/login_model.php b/application/models/models/login_model.php deleted file mode 100644 index f4d1400c..00000000 --- a/application/models/models/login_model.php +++ /dev/null @@ -1,198 +0,0 @@ -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; - - } - -} -?> \ No newline at end of file diff --git a/application/models/models/monthlypay_model.php b/application/models/models/monthlypay_model.php deleted file mode 100644 index bff0ab9f..00000000 --- a/application/models/models/monthlypay_model.php +++ /dev/null @@ -1,545 +0,0 @@ -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(); - - - -} - - - - - - - - - } -?> - diff --git a/application/models/models/mrir_model.php b/application/models/models/mrir_model.php deleted file mode 100644 index feb4efc9..00000000 --- a/application/models/models/mrir_model.php +++ /dev/null @@ -1,387 +0,0 @@ -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); - } - - - } - - -} -?> diff --git a/application/models/models/payroll_model.php b/application/models/models/payroll_model.php deleted file mode 100644 index 6f14672a..00000000 --- a/application/models/models/payroll_model.php +++ /dev/null @@ -1,454 +0,0 @@ -db->insert('T_Payroll_File', $FileDetails); - - $Payon = $this->db->affected_rows(); - - return $Payon; - } - - function model_sp($payon,$employee){ - - //echo ""; - //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 "
---------------------------"; - // echo "
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(); - } -} -?> \ No newline at end of file diff --git a/application/models/models/purchaseorder_model.php b/application/models/models/purchaseorder_model.php deleted file mode 100644 index ebf30268..00000000 --- a/application/models/models/purchaseorder_model.php +++ /dev/null @@ -1,2545 +0,0 @@ -db->distinct(); - $this->db->select('PO.PONO'); - $this->db->from('T_PurchaseOrder_Master PO'); - $this->db->join('T_PurchaseOrder_LineItem Line','PO.PONO = Line.PONO'); - $this->db->join('T_Requestion_Master Req','Req.ReqNo = Line.ReqNo'); - - $this->db->where('PO.POType',SERVICE); - $this->db->where('PO.status',PO_RELEASED); - $this->db->where('Req.RequestedDept',$this->session->userdata('DEPCode')); - - - - $query = $this->db->get(); - // print_r( $this->db->last_query()); - return $query->result(); - } - - - - -/*------------jun15------------------*/ - - -function getfies($pono) - { - - $this->db->select('*'); - - - $this->db->from('T_PurchaseOrder_BillUpload bill'); - - $this->db->where('PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } -/*-----------jun15-------------------*/ - - - function updateMatStock($itemNo, - $MaterialstockHistoryupdate){ - //echo'hi'; - - - $this->db->where('Ref_No',$itemNo); - $this->db->update('T_Material_stock_history', $MaterialstockHistoryupdate); - - $r = $this->db->affected_rows(); - return $r; -} - - - - -function updateReqDetails($Reqnumber,$MaterialCode,$ReqDetail){ - //echo'hi'; - - $this->db->where('ReqNo',$Reqnumber); - $this->db->where('MaterialCode',$MaterialCode); - // $this->db->where('Quantity',$Quantity); - - $this->db->update('T_Requestion_Details',$ReqDetail); - - $r = $this->db->affected_rows(); - return $r; -} - - -function IGRDetailsupdate($PONO) -{ - //echo 'hi'; - - - $subQuery ='select IGRM.PONO,IGRD.IGRItemNo,IGRD.IGRNO from -T_IGR_Master IGRM -join T_IGR_Details IGRD on IGRD.IGRNO = IGRM.IGRNO -Where IGRM.PONO = ? '; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result_array(); - - - } - - - function updateIGR($IGRItemNo,$IGRDs) //,$MaterialCode, - { - //print_r(array($IGRDs,$IGRItemNo)); - - $this->db->where('IGRItemNo',$IGRItemNo); //,'IGRNO',$IGRNO,'MaterialCode',$MaterialCode); - //$this->db->where('IGRNO',$IGRNO); - // $this->db->where('MaterialCode',$MaterialCode); - $this->db->update('T_IGR_Details',$IGRDs); - - $r = $this->db->affected_rows(); - - // $this->db->last_query(); - - return $r; - - - - - - - } - - - - - -/*------------------------------*/ - - - /////////////////// start this function used to pono reset financeyear configuration - - function ponoreset($ponoreset) - { - - //print_r($ponoreset); die; - $this->db->insert('T_PONO_Reset_Table',$ponoreset); - - $r = $this->db->affected_rows(); - return $r; - } - - - function updateponoreset($ponoreset,$sno,$potype,$posubtype) -{ - - - $this->db->where('reset_pono_id',$sno,'POType',$potype,'POSubtype',$posubtype); - $this->db->update('T_PONO_Reset_Table',$ponoreset); - $r = $this->db->affected_rows(); - return $r; - -} - - function ponoresetfinyear() - { - $this->db->select('*'); - $this->db->from('T_PONO_Reset_Table'); - $query =$this->db->get(); - return $query->result(); - } - ///////////////////end this function used to pono reset financeyear configuration - - - - - function fileupload($myfile) - { - - //print_r($myfile);die; - - $this->db->insert('T_PurchaseOrder_BillUpload',$myfile); - $myfile=$this->db->affected_rows(); - return $myfile; - } - - /*--------------------------------------------------*/ -/* this function used parendpo igr values get inward report display */ -function updateigrmaster($igrno,$NewPOno) -{ - // $this->db->insert('T_IGR_Master',$IGRaddvalues); - // $myfile=$this->db->affected_rows(); - // return $myfile; - - $this->db->where('IGRNO',$igrno); - $this->db->update('T_IGR_Master',$NewPOno); - $insert_id = $this->db->affected_rows(); - return $insert_id; -} -function updateigrfile($igrno,$NewPOno) -{ - $this->db->where('IGRNO',$igrno); - $this->db->update('T_Inwardgateregister_fileupload',$NewPOno); - $insert_id = $this->db->affected_rows(); - return $insert_id; - -} - -function selectigrmaster($PONO) -{ - -$this->db->select('*'); -$this->db->from('T_IGR_Master'); -$this->db->where('PONO',$PONO); - $query = $this->db->get(); - return $query->result(); - -} - - - -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($NewPO,$Newstatus) -{ - $this->db->where('PONO',$NewPO); - $this->db->update('T_PurchaseOrder_LineItem',$Newstatus); - $update = $this->db->affected_rows(); - return $update; - -} - -function pomasterupdatestatus($NewPO,$Newstatus) -{ - $this->db->where('PONO',$NewPO); - $this->db->update('T_PurchaseOrder_Master',$Newstatus); - $update = $this->db->affected_rows(); - return $update; -} - - -/*--------------------------------------------------*/ - - - - - function getfunction($pono) - { - $this->db->distinct(); - $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - $this->db->from('T_PurchaseOrder_BillUpload bill'); - $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - $this->db->where('bill.PONO',$pono); - //$this->db->or_where('pom.status',SPECIAL_PO); - $this->db->group_by('bill.BillNo'); - - - - - -// $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, -// mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate, -// mstr.CourierNo,bill.BillNo,bill.FilePath,pom.Status,pom.POType'); - -// $this->db->from('T_IGR_Master mstr'); -// $this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); -// $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); -// // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); -// $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); -// $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } - -function getfunctionr($pono) - { - $this->db->distinct(); - // $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - // $this->db->from('T_PurchaseOrder_BillUpload bill'); - // $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - // $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - // $this->db->where('bill.PONO',$pono); - // //$this->db->or_where('pom.status',SPECIAL_PO); - // $this->db->group_by('bill.BillNo'); - - - - - - $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, -mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate, -mstr.CourierNo,pom.Status,pom.POType'); //,bill.BillNo,bill.FilePath, - - $this->db->from('T_IGR_Master mstr'); - //$this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); - $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } - - -function getbillfiesr($pono) - { - $this->db->distinct(); - // $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - // $this->db->from('T_PurchaseOrder_BillUpload bill'); - // $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - // $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - // $this->db->where('bill.PONO',$pono); - // //$this->db->or_where('pom.status',SPECIAL_PO); - // $this->db->group_by('bill.BillNo'); - - - - - - $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, -mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate, -mstr.CourierNo,bill.BillNo,bill.FilePath,pom.Status,pom.POType'); - - $this->db->from('T_IGR_Master mstr'); - $this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); - $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } - - - - function GetPODetailforBillingServicePO($PONO) - { - - $subQuery ='select mast.ReqNo,mast.ReqDate,supp.SupplierName,PODate,st.StatusName as WorkStatus,ServiceWorkStatus,POMast.PaymentTerms, - POMast.ServiceWorkStatus,LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,POMast.TotalOrderValue - from T_PurchaseOrder_Master POMast - join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO - join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID - join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode - join T_Status Stat on Stat.StatusCode = POMast.Status - join T_Status st on st.StatusCode = POMast.ServiceWorkStatus - join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo - join tbl_users users on users.userId = mast.CreatedBy - join T_Employee_Details emp on emp.EmpID = users.EmpID - where POMast.POType=? and POMast.PONO=?'; - - $query = $this->db->query($subQuery,array(SERVICE,$PONO)); - - return $query->result_array(); - - } - - function GetServicePOListforBilling() - { - $subQuery ='select POMast.PONO,supp.SupplierName,PODate,POMast.PaymentTerms,POMast.ServiceWorkStatusRemarks,StatusName,POMast.CapitalRange,POType, - LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,Tax.TotalValue,Cost.CostCenterName,AdvanceAmount - ,Dept.DepartmentName from T_PurchaseOrder_Master POMast - join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - left join T_PurchaseOrder_AdvanceRequest PUADV on POMast.PONO=PUADV.PONO - join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID - join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode - join T_Status Stat on Stat.StatusCode = POMast.Status - join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo - join tbl_users users on users.userId = POMast.CreatedBy - left join T_Employee_Details emp on emp.EmpID = mast.Requestedby - join T_DepartmentDetails Dept on Dept.DEPCode = mast.RequestedDept - join T_CostCenter_Master Cost on Cost.CostCenterCode=LineItem.CostCenterCode - where POMast.POType=? and ServiceWorkStatus=? order by POMast.UpdatedOn desc'; - - $query = $this->db->query($subQuery,array(SERVICE,SERVICE_COMPLETED)); - - //print_r( $this->db->last_query()); - return $query->result(); - - } - - /** - * 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 purchaseorderListingCount() - { - $this->db->distinct(); - $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Req.ReqType,DeliveryDate'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); - // print_r( $this->db->last_query()); - $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 purchaseorderListing($forwhat='') - { - $this->db->distinct(); - $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); - if($forwhat=='amendment') - { - $this->db->where('POMast.Status',PO_RELEASED); - } - else - { - $this->db->where('POMast.Status !=',PO_AMENDED); - // $this->db->order_by('POMast.Status !=',PO_AMENDED); - } - $this->db->order_by('POMast.UpdatedOn','desc'); - $query = $this->db->get(); - //print_r( $this->db->last_query()); - $result = $query->result(); - return $result; - } - - /** - * This function is used to get the SupplierID and SupplierName information - * @return array $result : This is result of the query - */ - function getSupplierName($supID='') - { - $this->db->select('SupplierID, SupplierName,Address,PaymentID'); - $this->db->from('T_SupplierDetailsN'); - $this->db->where('IsActive', 1); - if($supID != '') - { - $this->db->where('SupplierID',$supID); - } - //$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(); - } - - - function getqtycheck($PONO) - { - $this->db->select('IsQualityChkReqired'); - $this->db->from('T_PurchaseOrder_Master'); - $this->db->where('PONO',$PONO); - $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 getRawPOMaterialList($ReqNo,$IsArray='') - { - - $result = $this->db-> query("CALL P_GET_REQUISTIONLIST('".$ReqNo."')") or die(mysql_error()); - - $result ->next_result(); - - //print_r($this->db->last_query()); - - if ($result->num_rows > 0) - { - //echo 'PO Line item Inserted successfully'; - if($IsArray != '') - { - return $result->result_array(); - } - else - { - return $result->result(); - } - } - - } - - /** - This Function to get the List of Requistion which require to create PO - */ - function getAllRequistionListToCreatePO() - { - $result = $this->db-> query("CALL P_PURCHASEORDER_DETAILS()") or die(mysql_error()); - - $result ->next_result(); - - - if ($result->num_rows > 0) - { - - return $result->result(); - } - } - - /** - * This function is used to get the Raw Material information - * @return array $result : This is result of the query - */ - function getRawMaterialList($MatType='',$ReqNoList='') - { - - $this->db->select('ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity'); - $this->db->from('T_Requestion_Details Req'); - $this->db->join('T_MaterialMaster mat', 'Req.MaterialCode = mat.MaterialCode'); - $this->db->where('mat.MaterialType', $MatType); - $this->db->where_in('Req.ReqNo', $ReqNoList); - - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - /** - * This function is used to get the Raw Material information - * @return array $result : This is result of the query - */ - function getRawMaterialListForPO($MatType='',$ReqNo='') - { - $subQuery ='SELECT ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity - FROM T_Requestion_Details Req - JOIN T_MaterialMaster mat ON Req.MaterialCode = mat.MaterialCode - where mat.MaterialType = ? - AND Req.ReqNo = ? - AND mat.MaterialCode != (SELECT MaterialCode FROM T_PurchaseOrder_LineItem WHERE ReqNo =? - )'; - - $query = $this->db->query($subQuery,array($MatType,$ReqNo,$ReqNo)); - - return $query->result_array(); - - - } - //Import PO Available Budget Amount - function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) - { - $subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? - and CostCenterCode=? and Mast.status not in (?) )as Totalvalue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; - $query = $this->db->query($subQuery,array($BudgetType,$CostCode,PO_AMENDED,$CostCode,$Year,$BudgetType)); - //print_r($this->db->last_query()); - return $query->result_array(); - - - } - //get available budget for capital - function GetAvailableCapitalBudgetAmount($CostCode,$Year,$BudgetType) - { - - $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate-tax.Afterdiscountval)),0) as Totalvalue from - T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POMaster on POMaster.PONO=Item.PONO left join T_Service_Tax tax on tax.LineItemNo=Item.LineItemNo where Item.CostCenterCode=? and POMaster.POType=? and POMaster.status not in (?))as Totalvalue - from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and - BudgetYear = ? and BudgetType =?'; - - $query = $this->db->query($subQuery,array($CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); - - return $query->result_array(); - - } - function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) - { - $subQuery ='select distinct Bud.CostCenterCode,BudgetAmount, case WHEN BudgetType = ? then (select - round(ifnull(sum((Quantity*Rate)-ifnull(tax.AfterDiscount,0)),0),2) as - Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Revenue_Tax tax on - tax.LineItemNo = Item.LineItemNo - where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?)) else (select - round(ifnull(sum(Quantity*Rate*ifnull(case when mast.NumberOfService=? - then 1 else mast.NumberOfService end ,1)),0),2) as - Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Requestion_Master ReqMas on ReqMas.ReqNo= Item.ReqNo - where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?) ) end as Totalvalue - from T_CostCenter_Budget Bud join T_CostCenter_Departments dept on dept.CostCenterCode = Bud.CostCenterCode - where Bud.CostCenterCode=? and - BudgetYear = ? and BudgetType =?'; - - - $query = $this->db->query($subQuery,array(REVENUE,$CostCode,$BudgetType,PO_AMENDED,'0.00',$CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); - - - //print_r($this->db->last_query()); - return $query->result_array(); - - } - - //to get POTYpe from ReqNo -function GetPOType($ReqNo) -{ - $this->db->select('POType'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('T_PurchaseOrder_LineItem Line', 'mast.PONO=Line.PONO'); - $this->db->where('Line.ReqNo', $ReqNo); - $query = $this->db->get(); - return $query->result_array(); -} - - /** - * This function is used to get the Requsition List for the login user - * @return array $result : This is result of the query - */ - function getRequistDetails($ReqNoList='') - { - $ReqDeatis = $this->GetRequistionMasterUsingReqNo($ReqNoList); - - foreach ($ReqDeatis as $SID): - $ReqBy = $SID->Requestedby ; - - endforeach; - if($ReqBy=='' || $ReqBy==null){ - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period, - Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); - $this->db->from('T_Requestion_Master mast'); - - $this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - } - - else if($ReqBy!='') { - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); - $this->db->from('T_Requestion_Master mast'); - $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - } - - - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to get the Requsition List for the login user - * @return array $result : This is result of the query - */ - function getRequistDetailsForPO($ReqNoList='') - { - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate'); - $this->db->from('T_Requestion_Master mast'); - $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to get the Cost center information - * @return array $result : This is result of the query - */ - function getCostCenter() - { - - $this->db->select('CostName, Description'); - $this->db->from('T_CostCentre'); - - $query = $this->db->get(); - - return $query->result(); - } - - - /** - * This function is used to get the CostCenter for the Selected Requistion Number - * @return array $result : This is result of the query - */ - function getCostCenterbyRequist($ReqNo='',$BudYear='',$ReqType='') - { - - $this->db->distinct(); - $this->db->select('Mast.CostCenterCode,Mast.CostCenterName,Bud.BudgetAmount,ReqNo'); - $this->db->from('T_CostCenter_Master Mast'); - $this->db->join('T_CostCenter_Departments CostDept', 'CostDept.CostCenterCode = Mast.CostCenterCode'); - $this->db->join('T_CostCenter_Budget Bud', 'Bud.CostCenterCode = Mast.CostCenterCode'); - $this->db->join('T_Employee_Details emp', 'CostDept.DEPCode = emp.Departmentcode'); - $this->db->join('T_Requestion_Master req', 'req.Requestedby = emp.EmpID'); - - $this->db->where('BudgetType ',$ReqType ); - $this->db->where('BudgetYear ',$BudYear ); - if($ReqNo != '') - { - $this->db->where('ReqNo ',$ReqNo); - } - - $query = $this->db->get(); - return $query->result(); - } - -/** - * This function is used to get the Config value from configuration table - * @return array $result : This is result of the query - */ - function getRequistionNoFromPO($PONO='') - { - $this->db->distinct(); - $this->db->select('ReqNo,'); - $this->db->from('T_PurchaseOrder_LineItem'); - if($PONO != '') - { - $this->db->where('PONO ',$PONO ); - } - - $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 ,$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 Company information from T_Company_Details table - * @return array $result : This is result of the query - */ - function getCompanyInformation() - { - - $subQuery = "select CompanyName,replace(Address,'
','') as Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode - from T_Company_Details "; - - - - $query = $this->db->query($subQuery); - - - //print_r($this->db->last_query()); - return $query->result(); - // return $query->result(); - } - /** - * This function is used to get the Company information from T_Company_Details table - * @return array $result : This is result of the query - */ - function getCompanyInformationforPDF() - { - - $subQuery = "select CompanyName,Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode - from T_Company_Details "; - - - - $query = $this->db->query($subQuery); - - - //print_r($this->db->last_query()); - return $query->result(); - // return $query->result(); - } - - /** - * This function is used to get the Employee List - * @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 List - * @return array $result : This is result of the query - */ - function getLastCreatedPODate() - { - $this->db->select('max(PODate) as PODate'); - $this->db->from('T_PurchaseOrder_Master'); - $query = $this->db->get(); - - return $query->result(); - } - - function getLastReleasedPODate() - { - $this->db->select('max(ReleasedOn) as PODate'); - $this->db->from('T_PurchaseOrder_Master'); - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to add New Purchase order to the system - - */ - function addPOMaster($POMaster,$POType,$POSubtype) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_Master', $POMaster); - //$this->db->update('T_PONO_Reset_Table') - - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - if($insert_id>0) - { - $subQuery = 'select PONO from T_PurchaseOrder_Master where POType=? and POSubType=? and isnull(ParentPO) order by CreatedDate desc limit 1 '; - - $query = $this->db->query($subQuery,array($POType,$POSubtype)); - - //print_r($query->result());die(); - return $query->result_array(); - } - } - - - - - - function addAmendPOMaster($POMaster,$CreatedBy,$ParentPO) - { - // print_r($POMaster); - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_Master', $POMaster); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - if($insert_id>0) - { - $subQuery = 'select PONO from T_PurchaseOrder_Master where CreatedBy=? and ParentPO=? order by CreatedDate desc limit 1'; - - $query = $this->db->query($subQuery,array($CreatedBy,$ParentPO)); - - return $query->result_array(); - } - } - - /** - * This function is used to add New Purchase order Line Item to the system - */ - function addPOLineItem($POLineItem) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_LineItem', $POLineItem); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - if($insert_id>0) - { - // $subQuery = 'select max(LineItemNo) as LineItemNo from T_PurchaseOrder_LineItem'; - $subQuery = 'SELECT * FROM T_PurchaseOrder_LineItem where PONO = "'.$POLineItem['PONO'].'" ORDER BY LineItemNo DESC'; - - $query = $this->db->query($subQuery); - - return $query->result_array(); - } - } - - /** - * This function is used to add Revenue Tax to the system - */ - function addRevenueTax($RevenueTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Revenue_Tax', $RevenueTaxList); - $this->db->trans_complete(); - $insert_id = $this->db->insert_id(); - $aff_row = $this->db->affected_rows(); - // print_r( $this->db->last_query()); die(); - // echo "aff_row".$aff_row." $insert_id".$insert_id; - return $aff_row > 0 ? $this->db->insert_id() : 0; - } - /** - * This function is used to add Service Tax to the system - */ - function addServiceTax($ServiceTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Service_Tax', $ServiceTaxList); - $this->db->trans_complete(); - $insert_id = $this->db->affected_rows(); - return $insert_id>0 ? $this->db->insert_id() : 0; - } - - - /** - * This function is used to add Service Tax to the system - */ - function addImportTax($ImportTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Import_Tax', $ImportTaxList); - $this->db->trans_complete(); - $insert_id = $this->db->affected_rows(); - return $insert_id>0 ? $this->db->insert_id() : 0; - } - - - - function addadvanceRequest($advance) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_AdvanceRequest', $advance); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - - - } - - function PONOExists($PONO) - { - - $this->db->select('PONO'); - $this->db->from('T_PurchaseOrder_AdvanceRequest'); - $this->db->where('PONO ',$PONO); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - - - } - - - - function updateadvanceRequest($advance,$PONO) - { - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_AdvanceRequest',$advance); - $insert_id = $this->db->affected_rows(); - 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($PO) - { - $this->db->select('POType, PODate, SupplierID,SpecialOrder,UserID,RequestedDate,RequesterEmail,RequesterPh, PurchasingCategory,BudgetManager,BudgetManagerDepartment,'); - $this->db->from('T_PurchaseOrderDetails'); - $this->db->where('PONO', $PO); - $query = $this->db->get(); - - return $query->result(); - } - - // This Method to get the Service PO Details for Edit the Item - - function GetServicePurchaseOrder($PONO = '') - { - $this->db->distinct(); - $this->db->select('ReqNo,POMast.PONO,POMast.PaymentTerms,POMast.PaymentOtherDescription,ServiceDescription,supp.SupplierID,supp.SupplierName,supp.Address,PODate,Stat.StatusName,DeliveryOption,DeliverySchedule,DeliveryDate,DeliveryAddress,POMast.PaymentTerms,POMast.ExchangeRate,POMast.UpdatedOn,Stat.StatusCode,POMast.ServiceWorkStatus,POMast.*,POMast.TotalOrderValue,POMast.BudgetType,IGR.IGRNO'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - $this->db->join('T_IGR_Master IGR','POMast.PONO = IGR.PONO','left'); - - $this->db->where('POMast.PONO', $PONO); - $query = $this->db->get(); - - $result = $query->result(); - - return $result; - } - - // This Method to get the Service PO Child Details for Edit the Item - - -// This Method to get the Service PO Child Details for Edit the Item - function GetServicePurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,LineItem.Quantity,ReceivedQuantity,Rate,LineItem.Status,(LineItem.Quantity *Rate) as BasicValue ,(After_CGST + After_SGST + After_IGST) as Taxamount,Dept.DepartmentName - ,TotalValue,CGST,After_CGST,SGST,After_SGST,IGST,After_IGST,otherallowance,LineItem.CostCenterCode,LineItem.ServiceFrequency,LineItem.ServiceMaterialDescription,Req.Schedule_Type,Req.NumberOfService,Req.Service_Period,ReqDet.MaterialDescription - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - join T_Requestion_Details ReqDet on ReqDet.ReqNo = LineItem.ReqNo and LineItem.MaterialCode = ReqDet.MaterialCode - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode - where LineItem.PONO =?'; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - // This Method to get the Service PO Child Details for Edit the Item - function GetServicePurchaseOrderDetailsforPdf($PONO = '') - { - - - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,LineItem.ServiceMaterialDescription,Mat.MaterialCode,Mat.MaterialName,POMaster.ParentPO, - Mat.UOM,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue,POMaster.AmendedDetails,LineItem.AmendedDetails as lineamenddetails, - ROUND(( Tax.After_SGST + Tax.After_CGST + Tax.After_IGST ) ,2)as Taxamount,ReqMat.NumberOfService,ReqMat.Schedule_Type,ReqMat.Service_Period, - TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentTerms,AdvanceAmount - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - join T_Requestion_Master ReqMat on ReqMat.ReqNo = LineItem.ReqNo - left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO - where LineItem.PONO =?'; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - - - // This Method to get the Revenue PO Child Details for Edit the Item - function GetRevenuePurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Per,ServiceMaterialDescription,ReceivedQuantity,Rate,Req.Status,(Quantity *Rate) as BasicValue , (( AfterSGST + AfterCGST + - AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - left join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode - where LineItem.PONO =?'; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - // This Method to get the Revenue PO Child Details for Edit the Item - function GetRevenuePurchaseOrderDetailsForPDF($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,ReqNo,Mat.MaterialCode,Mat.MaterialName,POMaster.PaymentOtherDescription,LineItem.ServiceMaterialDescription, - Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , - ROUND(((AfterSGST + AfterCGST + - AfterIGST)) ,2)as Taxamount,AdvanceAmount, - TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.Address,sup.SupplierID,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,LineItem.AmendedDetails as LineAmend,Payment.PaymentTerms - FROM T_PurchaseOrder_LineItem LineItem - left join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - left join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - left join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO - where LineItem.PONO =?'; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - function getRevenueTaxinforforpdf($PONO) - { - $subQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.AfterFreightValue,rt.PackagingValue,rt.AfterPackagingValue,rt.DiscountValue,rt.AfterDiscount FROM T_Revenue_Tax rt - - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=rt.LineItemNo - - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO - - where pm.POType=? and pm.PONO=? - - group by rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.PackagingValue,rt.AfterDiscount,rt.AfterFreightValue,rt.AfterPackagingValue ORDER BY rt.LineItemNo ASC'; - - $query = $this->db->query($subQuery,array("REVENUE",$PONO)); - - return $query->result(); - - } -// This Method to get the Revenue PO Child Details for Edit the Item - - -function GetImportPurchaseOrderDetailsForPDF($PONO = '') - { - - // $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName, - // Mat.UOM,Quantity,ReqMas.Requestedby,Rate,ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount, - // ProductPrice,Tax.*,LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.Address - // FROM T_PurchaseOrder_LineItem LineItem - // join T_Requestion_Master ReqMas on ReqMas.ReqNo=LineItem.ReqNo - // join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - // join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - // join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - // join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - // where LineItem.PONO =?'; - - $subQuery='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Import_DispatchDetails,LineItem.Per,LineItem.ServiceMaterialDescription, -Mat.UOM,Quantity,ReqMas.Requestedby,Rate,ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount , -ProductPrice,Tax.*,LineItem.CostCenterCode ,Date(ReqMast.ReqDate) as ReqDate,POMaster.*,sup.SupplierName,sup.Address,LineItem.AmendedDetails as LineAmend,AdvanceAmount, Pay.PaymentTerms as Pay,ROUND((Quantity *Rate),2 ) as BasicValue,HSNCODE,sup.EmailAddress,sup.SupplierID,sup.PAN,sup.ContactNumber,sup.GSTNO -FROM T_PurchaseOrder_LineItem LineItem -join T_Requestion_Master ReqMas on ReqMas.ReqNo=LineItem.ReqNo -join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode -join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo -join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO -join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID -left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO -join T_Requestion_Master ReqMast on LineItem.ReqNo=ReqMast.ReqNo -join T_PaymentTerms Pay on POMaster.PaymentTerms=Pay.PaymentID -where LineItem.PONO =?'; - - $query = $this->db->query($subQuery,array($PONO)); - //print_r($this->db->last_query()); - - return $query->result(); - - - } - - - function GetCurrencyDetail($Currency='') - { - - $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currency)); - //print_r($query); - return $query->result(); - - } - - - function GerRequesterName($Requester='') - { - $subQuery='SELECT EmpID,FirstName,Departmentcode from T_Employee_Details where EmpID=?'; - - $query=$this->db->query($subQuery,array($Requester)); - - return $query->result(); - } - - - function GerRequesterDep($Depcode='') - { - $subQuery='SELECT DepartmentName from T_DepartmentDetails where DEPCode=?'; - $query=$this->db->query($subQuery,array($Depcode)); - - return $query->result(); - - } - - function GerCurrencyCodeName($Currencycode='') - { - $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currencycode)); - //print_r($this->db->last_query()); - return $query->result(); - - } - - - function GetPOStatus($Status='') - { - $subQuery='SELECT StatusName from T_Status where StatusCode=?'; - $query=$this->db->query($subQuery,array($Status)); - return $query->result(); - - } - - - function GetPaymentTerms($PONO='') - { - $subQuery='SELECT PaymentTerms from T_PurchaseOrder_Master where PONO=?'; - $query=$this->db->query($subQuery,array($PONO)); - //print_r($query); - return $query->result(); - - } - - - - - // function getSupplierPayment($Currency='') - // { - - // $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; - // $query=$this->db->query($subQuery,array($Currency)); - // //print_r($this->db->last_query()); - // return $query->result(); - - // } - - function getSupplierPayment($Config_ID='') - { - - // $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; - $subQuery='select ConfigValue from T_ConfigDetails where Config_ID=?'; - $query=$this->db->query($subQuery,array($Config_ID)); - //print_r($this->db->last_query()); - return $query->result(); - - } - - function GetWorkStatus($Config_ID='') - { - $subQuery = 'select ConfigValue from T_ConfigDetails where Config_ID=?'; - $query=$this->db->query($subQuery,array($Config_ID)); - //print_r($query); - return $query->result(); - } - - - - - -function GetImportPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, -Mat.UOM,Quantity,Rate,Req.Status,ROUND((Quantity *Rate),2 ) as BasicValue,ReceivedQuantity, -QuantityRejected,ROUND(Quantity-ReceivedQuantity)as PendingQty,Per, - ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess, - AfterCustomEdCess,ROUND((Quantity *Rate),2)as TotalOrderValue,ROUND((POMast.ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue,CurrencyType,ReceivedQuantity,Tax.*,LineItem.ServiceMaterialDescription, - - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - - left join T_MRIR_Master Mast on POMast.PONO=Mast.PONO - - left join T_MRIR_Details Det on Det.MaterialCode=LineItem.MaterialCode and Mast.MRIRNO=Det.MRIRNO - - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - - - - -function GetCurrencytype() - { - - $subQuery = 'select * from T_Currency_Details'; - - $query = $this->db->query($subQuery); - - return $query->result(); - } - - function GetINRCurrencytype($Currency_Code='') - { - $subQuery='select * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currency_Code)); - //print_r($this->db->last_query()); - return $query->result(); - - } - - - - - - - // To Update the PO - function updatePOMaster($PONO,$PODetails) - { - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $PODetails); - - return TRUE; - } - - - // To update Parent PO as Amended PO - function updateAmendPOMaster($PONO,$PODetail) - { - //echo $PONO."from model"; - - - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $PODetail); - $insert_id = $this->db->affected_rows(); - - return $insert_id; - } - /** - * This function is used to check the Line Item is already available in the database - * @return array $result : This is result of the query - */ - function LineItemExists($LineItemNo) - { - $this->db->select('LineItemNo,TaxID'); - $this->db->from('T_Service_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - //$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 Revenue Line Item is already available in the database - * @return array $result : This is result of the query - */ - function LineItemExistsinRevenueTax($LineItemNo) - { - $this->db->select('LineItemNo'); - $this->db->from('T_Revenue_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - } - - - function LineItemExistsinImportTax($LineItemNo) - { - $this->db->select('LineItemNo'); - $this->db->from('T_Import_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - } - // To Update the PO Line Item - function updatePOLineItem($PONO,$LineItemNo,$PODetails) - { - $this->db->where('PONO', $PONO); - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_PurchaseOrder_LineItem', $PODetails); - - return TRUE; - } - /*// To Update the Service Tax Item */ - function updateServiceTax($LineItemNo,$PODetails) - { - - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Service_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - /*// To Update the Revenue Tax Item */ - function updateRevenueTax($LineItemNo,$PODetails) - { - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Revenue_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - function updateImportTax($LineItemNo,$PODetails) - { - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Import_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - function getLastInsertedPO() - { - $this->db->select('max(PONO) as PO'); - $this->db->from('T_PurchaseOrderDetails'); - $query = $this->db->get(); - - return $query->result_array(); - } - - - /* This Method to get all the Department name for the requistion */ - function getDepartmentListForAllReq() - { - $subQuery ='SELECT DISTINCT DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode WHERE REQ.Status not in(?,?,?,?)'; - - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - //print_r($query); - return $query->result(); - } - /* - This Method to get all department list - */ - function getDepartmentAllList() - { - $subQuery ='SELECT DISTINCT DEPCode,DepartmentName FROM T_DepartmentDetails'; - - $query = $this->db->query($subQuery); - //print_r($query); - return $query->result(); - } - - - function getStatusListforAllReq() - { - $subQuery ='SELECT DISTINCT STAT.StatusCode, STAT.StatusName FROM T_Requestion_Master REQ - JOIN T_Status STAT on REQ.Status = STAT.StatusCode where STAT.StatusCode not in (?,?,?,?)'; - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - - // print_r( $this->db->last_query()); - - return $query->result(); - } - - function getStatusByDepartment($DepNo='') - { - - $subQuery ='SELECT DISTINCT STAT.StatusCode ,STAT.StatusName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode - JOIN T_Status STAT ON REQ.Status = STAT.StatusCode - WHERE DEPT.DEPCode=? AND REQ.Status NOT IN (?,?,?,?)'; - $query = $this->db->query($subQuery,array($DepNo,REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - - return $query->result_array(); - } - - function getRequistionListbySearch($Depid='',$Status='',$FromDate='',$ToDate='') - { - $subQuery =' SELECT ReqNo,ReqType,Requestedby,EMP.FirstName,EMP.Designation,STAT.StatusCode ,STAT.StatusName,ReqDate,DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode - JOIN T_Status STAT on REQ.Status = STAT.StatusCode - where REQ.Status NOT IN (?,?,?,?,?)'; - - $appendQuery = $subQuery ; - - if($Depid != '' && $Status != '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; - //echo "$appendQuery";die(); - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status == '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND DEPT.DEPCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status != '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND STAT.StatusCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status == '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status != '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status)); - // print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status == '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status != '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status ,$FromDate,$ToDate)); - // print_r($this->db->last_query()); - return $query->result_array(); - } - else - { - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED)); - //print_r($this->db->last_query()); - return $query->result(); - } - - } - - function UpdateRequistItemStatus() - { - $query = $this->db->query("update T_Requestion_Details REQ - JOIN T_PurchaseOrder_LineItem line ON REQ.ReqNo = line.ReqNo - JOIN T_PurchaseOrder_Master PO ON PO.PONO = line.PONO - set REQ.Status = CASE WHEN REQ.Quantity = line.Quantity THEN 'ST022' WHEN REQ.Quantity > line.Quantity THEN 'ST023' ELSE 'ST003' END , - REQ.updatedOn= CURRENT_TIMESTAMP - where PO.Status ='".PO_CREATED."'"); - - //$query ->next_result(); - - } - function UpdateRequistionStatus() - { - $result = $this->db-> query("CALL P_UPDATE_REQUISTIONSTATUS_New()") or die(mysql_error()); - - $result ->next_result(); - - } - /** - * This function is used to delete the Line item from details into Database - * @return array $result : This is result of the query - */ - function DeletePOLineItem( $LineItem='',$ReqNo='',$MaterialCode='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->where('ReqNo', $ReqNo); - $this->db->where('MaterialCode', $MaterialCode); - $this->db->delete('T_PurchaseOrder_LineItem'); - - return TRUE; - } - - /** - * This function is used to delete the Revenue item from details into Database - * @return array $result : This is result of the query - */ - function DeletePORevenueTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Revenue_Tax'); - - return TRUE; - } - - /** - * This function is used to delete Service Tax from details into Database - * @return array $result : This is result of the query - */ - function DeletePOServiceTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Service_Tax'); - - return TRUE; - } - - - function DeletePOImportTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Import_Tax'); - - return TRUE; - } - - /** - * This function is used to get the List of PO details to the approver - * @return array $result : This is result of the query - join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode - */ - function getPOList($type) - { - - $this->db->distinct(); - $this->db->select('mast.PONO,mast.TotalOrderValue,st.StatusCode,st.StatusName,emp.FirstName,mast.CreatedDate,ccm.CostCenterName,ccm.CostCenterCode,mast.POType as RType,mast.Remarks,DepartmentName,mast.ApprovedBy,(select EmpID from tbl_users where userId=mast.ApprovedBy )as EID,rmast.ReqType,mast.Status,mast.CapitalRange, -(select FirstName from T_Employee_Details where EmpID=EID)as Approver'); - $this->db->from('T_PurchaseOrder_Master mast'); - // $this->db->order_by('mast.Status',"PO_CREATED"); - $this->db->join('T_Status st', 'st.StatusCode=mast.Status'); - - $this->db->join('T_PurchaseOrder_LineItem req', 'req.PONO= mast.PONO'); - $this->db->join('T_Requestion_Master rmast','rmast.ReqNo=req.ReqNo'); - //$this->db->join('T_CostCenter_Budget bud','bud.CostCenterCode = req.CostCenterCode and bud.BudgetType = rmast.ReqType'); - $this->db->join('T_CostCenter_Master ccm','ccm.CostCenterCode = req.CostCenterCode','left'); - $this->db->join('tbl_users tbl', 'rmast.createdby=tbl.userid'); - $this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid'); - $this->db->join('T_DepartmentDetails as Dep','Dep.DEPCode=emp.Departmentcode'); - - if($type=='APPROVAL'){ - $this->db->or_where('mast.Status',PO_CREATED); - $this->db->or_where('mast.Status',PO_APPROVER_ONHOLD); - $this->db->or_where('mast.Status',PO_AWAITING_RELEASE); - $this->db->or_where('mast.Status',PO_RELEASED); - $this->db->or_where('mast.Status',REQITEM_Emergency_PO_CREATED); - $this->db->order_by('mast.Status'); - - } - else if($type=='RELEASE'){ - $this->db->or_where('mast.Status',PO_AWAITING_RELEASE); - $this->db->or_where('mast.Status',PO_RELEASER_ONHOLD); - $this->db->or_where('mast.Status',PO_RELEASED); - $this->db->order_by('mast.Status'); - - - - } - $result=$this->db->get(); - // print_r($this->db->last_query()); - return $result->result(); - - } - - - function UpdatePO($store, $PONO) - { - - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $store); - - return TRUE; - } - - function GetReleasedDetails($PONO){ - $this->db->select('mast.ReleasedOn,re.FirstName'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('tbl_users tbl','mast.ReleasedBy=tbl.userid'); - $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); - $this->db->where('mast.PONO',$PONO); - $result=$this->db->get(); - //print_r($this->db->last_query()); -//die(); - return $result->result(); - - } - //This is get the capital po list for edit - -function getCapitalPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, -Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,Tax.*, - ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((POMast.ExchangeRate*BasicPriceInMTon*Quantity),2) as BasicINRValue,Tax.TotalValue as ImportTotalValue,Tax.FreightType,Tax.NoOfTrip,Tax.FreightValue,Tax.AfterFreightValue,POMast.CurrencyType, - - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO -join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - - join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo -left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - -// This Method to get the Capital PO Details for pdf - function GetCapitalPurchaseOrderDetailsForPDF($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.AmendedDetails as lineamd,ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription, - Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , - LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentID,Payment.PaymentTerms,AdvanceAmount,HSNCODE - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - left join T_PurchaseOrder_AdvanceRequest Adv on POMaster.PONO=Adv.PONO - where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - // get requested by details - function GetRequesedByDetails($PONO){ - $this->db->select('mast.CreatedBy,re.FirstName,Dept.DEPCode,Dept.DepartmentName'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('tbl_users tbl','mast.CreatedBy=tbl.userid'); - $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 're.Departmentcode = Dept.DEPCode'); - - $this->db->where('mast.PONO',$PONO); - $result=$this->db->get(); - - return $result->result(); - - } - - // get domestic capital po list - - - function getDomesticCapitalPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, - Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,ROUND((ServiceTax.After_CGST + ServiceTax.After_SGST + ServiceTax.After_IGST),2) as ServiceTaxamount - ,ServiceTax.TotalValue,ServiceTax.CGST,ServiceTax.After_CGST,ServiceTax.SGST,ServiceTax.After_SGST,ServiceTax.IGST,ServiceTax.After_IGST,ServiceTax.otherallowance,ServiceTax.discount,ServiceTax.discountval,ServiceTax.Afterdiscountval, - POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,ROUND((POMast.TotalOrderValue),2) as BasicINRValue,POMast.CurrencyType,FreightType as Ftype,NoOfTrip as NoTrip,FreightValue as Fvalue,AfterFreightValue as Afvalue, - - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax ServiceTax on ServiceTax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - join T_Employee_Details emp on Req.Requestedby = emp.EmpID - - join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - //get pdf po requistion details - - - function GetPdfRequistionDetails($PONO){ - $this->db->select('LineItem.ReqNo'); - $this->db->from('T_PurchaseOrder_LineItem LineItem'); - $this->db->where('LineItem.PONO',$PONO); - $result=$this->db->get(); - $ReqNo=''; - - foreach ($result->result() as $res){ - - if($ReqNo==$res->ReqNo){ - - } - else{ - $ReqNo = $res->ReqNo; - $this->db->select('ReqMast.ReqNo,ReqMast.CostCenterCode,ReqMast.ReqDate,ReqMast.Schedule_Type,ReqMast.NumberOfService,ReqMast.Service_Period,Dept.DEPCode,Dept.DepartmentName,Dept.shortName'); - $this->db->from('T_Requestion_Master ReqMast'); - - $this->db->join('T_DepartmentDetails Dept', 'ReqMast.RequestedDept = Dept.DEPCode'); - $this->db->where('ReqMast.ReqNo',$ReqNo); - $Reqresult=$this->db->get(); - $Details['RequistionNo']= $Reqresult->result()[0]->ReqNo; - $Detaisl['ReqDate']=$Reqresult->result()[0]->ReqDate; - - $Details['RequestedDept']= $Reqresult->result()[0]->shortName; - $Details['CostCenterCode']= $Reqresult->result()[0]->CostCenterCode; - $date = new DateTime($Reqresult->result()[0]->ReqDate,new DateTimeZone('Asia/Kolkata')); - $retDate = $date->format('d-m-Y'); - $Details['ReqDate']= $retDate; - $ScheduleType = $Reqresult->result()[0]->Schedule_Type; - if($ScheduleType!='Recurring'){ - $Details['Frequency']= $Reqresult->result()[0]->Schedule_Type; - - } - else{ - $Details['Frequency']= $Reqresult->result()[0]->Service_Period.' - '.$Reqresult->result()[0]->NumberOfService; - } - - $ResultArray[]=$Details; - } - - } - - $RequistionDetails = $ResultArray; - return $RequistionDetails; - } - function GetLineItemReceivedQty($ParentPO,$MaterialCode) - { - $this->db->select('ReceivedQuantity'); - $this->db->from('T_PurchaseOrder_LineItem'); - - $this->db->where('PONO',$ParentPO); - $this->db->where('MaterialCode',$MaterialCode); - $result=$this->db->get(); - - return $result->result_array(); - } - - //get paymentTerms details - - function getPaymentTermsDetails($Payment_ID='') - { - - - $getpaymentQuery='select distinct PaymentID,PaymentTerms,Details from T_PaymentTerms'; - $paymentQuery=$this->db->query($getpaymentQuery); - - return $paymentQuery->result(); - - } - /** - * This function is used to get status in status table - - */ - function getStatus($StatusType = '') - { - $this->db->select('StatusCode,StatusName '); - $this->db->from('T_Status'); - $this->db->where('StatusType', $StatusType); - $query = $this->db->get(); - - return $query->result(); - } - - - function edit_mrir($MrirNo) - { - $this->db->distinct(); - $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.Createdon,TMD.ActualQuantityReceived,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,IGRM.CreatedDate,IGRD.QuantityAsPerInvoice,SUPP.SupplierName,SUPP.Address,POMR.PODate,POMR.DeliveryDate,POMR.ServiceDescription,TMD.MaterialCode,MM.MaterialName,MM.UOM,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName as PORasiedbyName,ED1.FirstName as MRIRRasiedbyName, ED2.FirstName as IGRRasiedbyName,TMM.MRIRStatus,TMM.Createdon as MRIRCreatedon,POLT.CostCenterCode,CostCenterName,QuantityAccepted,QuantityRejected,TMD.Remarks'); - $this->db->from ('T_MRIR_Master TMM'); - $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO','left');//to get IGRNO,PONO,MRIRNO,mrirdate, - $this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO = TMM.IGRNO','left');//to get actualquantity,deliverydate,Invoicedate,vechileno,courierno,igrdate, - $this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO = POMR.PONO','left');//to get podate,deliverydate,servicedescription - $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left');//to get receivedquantity,quantity - - $this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO = IGRM.IGRNO','left');//to get invoicequantity - $this->db->join ('T_MaterialMaster MM','IGRD.MaterialCode = MM.MaterialCode','left'); - $this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID = SUPP.SupplierID','left');//to get suppliername,supplieraddress - $this->db->join ('tbl_users user','user.userid = POMR.CreatedBy','left');//to get poraisedby - $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); - $this->db->join ('tbl_users user1','user1.userid=TMM.CreatedBy','left');//to get mrirraisedby - $this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left'); - $this->db->join ('tbl_users user2','user2.userid=IGRM.CreatedBy','left');//to get igrraisedby - $this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID','left'); - $this->db->join('T_CostCenter_Master TCOST','POLT.CostCenterCode=TCOST.CostCenterCode'); - $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; - - } - - - - - - function getadvancePONO($Status='') - { - $this->db->select ('Mast.PONO,POType,Mast.CreatedDate,Mast.ReleasedOn,Mast.TotalOrderValue,Mast.SupplierID,DeliveryDate,DeliverySchedule,DeliveryOption,Mast.PaymentTerms as Paycode,Payterm.PaymentTerms,LineItem.ReqNo,Requestedby,Departmentcode,DepartmentName,LineItem.CostCenterCode,SupDet.SupplierName,Import_DispatchDetails,CurrencyType,AdvancePercentage,AdvanceAmount,POAdv.Remarks,Mast.CapitalRange,Mast.PaymentOtherDescription,RequestedDept'); - $this->db->from('T_PurchaseOrder_Master Mast'); - $this->db->join('T_PurchaseOrder_LineItem LineItem','Mast.PONO=LineItem.PONO'); - $this->db->join('T_Requestion_Master ReqMa','LineItem.ReqNo=ReqMa.ReqNo'); - $this->db->join('T_Employee_Details EmpDet','ReqMa.Requestedby=EmpDet.EmpID','left'); - $this->db->join('T_DepartmentDetails DepDet','EmpDet.Departmentcode=DepDet.DEPCode or ReqMa.RequestedDept=DepDet.DEPCode','left'); - $this->db->join('T_SupplierDetailsN SupDet','Mast.SupplierID=SupDet.SupplierID'); - $this->db->join('T_PurchaseOrder_AdvanceRequest POAdv','Mast.PONO=POAdv.PONO','left'); - $this->db->join('T_PaymentTerms Payterm','Mast.PaymentTerms=Payterm.PaymentID'); - $this->db->where('Mast.Status',$Status); - $query = $this->db->get(); - // print_r($this->db->last_query()); - return $query->result(); - - } - - // update req deatail if work status is completed - - function updateReqDetail($PONO,$POStatus,$MaterialCode) - { - - $this->db->set('Req.Status',$POStatus); - $this->db->where('Item.PONO',$PONO); - $this->db->where('Req.MaterialCode',$MaterialCode); - $this->db->update('T_PurchaseOrder_LineItem Item JOIN T_Requestion_Details Req ON Item.ReqNo= Req.ReqNo'); - return TRUE; - } - - function UpdateReceivedQtyforServicePO($PONO,$updateddt,$updatedBy) - { - $this->db->select('LineItemNo,MaterialCode'); - $this->db->from('T_PurchaseOrder_LineItem'); - $this->db->where('PONO ',$PONO ); - $query = $this->db->get(); - $result = $query->result(); - - if(!empty($result)) - { - foreach ($result as $res) - { - $LineItemNo =$res->LineItemNo; - $MaterialCode = $res->MaterialCode; - //echo $LineItemNo; - - $subQuery = 'update T_PurchaseOrder_LineItem - set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=? and LineItemNo=?'; - - $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$LineItemNo)); - $finddot = strpos($PONO,'.'); - if($finddot = true) - { - $subQuery = 'update T_PurchaseOrder_LineItem - set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=substring(?,1,(case when INstr(?,?) > 0 then INstr(?,?)-1 else 0 end)) and MaterialCode=?'; - - $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$PONO,'.',$PONO,'.',$MaterialCode)); - } - - } - - } - - } -//get service tax listusing po number - function GetServiceTaxDetails($PONO = ''){ - - $taxQuery ='SELECT group_concat(@count:=@count+1) Itemcode, -st.CGST,st.SGST,st.IGST,st.otherallowance FROM T_Service_Tax st - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO JOIN - (SELECT @count := 0) count - where pm.POType=? and pm.PONO=? - group by st.CGST,st.SGST,st.IGST,st.otherallowance - ORDER BY Itemcode ASC '; - - - $query = $this->db->query($taxQuery,array("SERVICE",$PONO)); - - return $query->result(); - } - // get capital tax listing by po no - - function GetCapitalTaxListDetails($PONO = '',$CapitalRange=''){ - - if($CapitalRange==1){ - $taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,SUM(st.`After_CGST`) AS TotalCGST,SUM(st.`After_SGST`) AS TotalSGST,SUM(st.`After_IGST`) AS TotalIGST,SUM(st.`otherallowance`) AS TotalOtherAllowance,SUM(st.`Afterdiscountval`) AS TotalDiscount,st.discountval,st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance,SUM(st.`AfterFreightValue`) AS TotalFreight,st.FreightValue FROM T_Service_Tax st - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO - where pm.POType=? and pm.PONO=? - group by st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance ORDER BY st.LineItemNo ASC'; - $query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); - - return $query->result(); - } - else if($CapitalRange==0){ - $taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode, - SUM(it.`AfterFreightValue`) AS TotalFreight,it.FreightValue,it.AfterFreightValue, - it.IGST AS TotalIGSTPer,SUM(it.AfterIGST) as AfterIGST1,it.AfterIGST as AIgst FROM T_Import_Tax it - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=it.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO - where pm.POType=? and pm.PONO=? - group by it.AfterFreightValue ORDER BY it.LineItemNo ASC'; - $query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); - - return $query->result(); - } - - } - // get po format for acedamic year based - function GetPoFormat($PONO=''){ - $poQuery ='select PONO from T_PurchaseOrder_Master where PONO=?'; - $query = $this->db->query($poQuery,array($PONO)); - - return $query->result(); -} -//get Dept Emp Name -function getDepartmentEmpList($DepCode=''){ - $this->db->select('EmpID'); - $this->db->from('T_Employee_Details'); - $this->db->where('Departmentcode', $DepCode); - $this->db->limit('1'); - $query = $this->db->get(); - - return $query->result(); -} -//get req master details using reqno -function GetRequistionMasterUsingReqNo($Req){ - - - $this->db->select('Requestedby'); - $this->db->from('T_Requestion_Master'); - $this->db->where('ReqNo', $Req[0]); - $query = $this->db->get(); - - return $query->result(); - - -} -function amendpdf($PONO='') -{ - $Amend ='select p.PONO,p.ParentPO,p.Status,p.TotalOrderValue, - m.Status as parentpostatus, - m.TotalOrderValue as partenttotalorder - from T_PurchaseOrder_Master as p - join T_PurchaseOrder_Master as m - on m.PONO = p.ParentPO - where p.PONO = ?'; - $amendment = $this->db->query($Amend,array($PONO)); - - return $amendment->result(); -} - - - - function GetClients() - { - $this->db->select('client_id,client_name'); - $this->db->from('ip_clients'); - $query = $this->db->get(); - return $query->result_array(); - } - - - function SaveEnquiry($save) - { - $this->db->trans_start(); - $this->db->insert('T_Enquiry', $save); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - - } - - - function UpdateEnquiry($save,$Id) - { - - $this->db->where('Id',$Id); - $this->db->update('T_Enquiry',$save); - $insert_id = $this->db->affected_rows(); - return $insert_id; - } - - - function GetEnquiryDetails() - { - $this->db->select('T_Enquiry.*,client_name'); - $this->db->from('T_Enquiry'); - $this->db->join('ip_clients','ip_clients.client_id=T_Enquiry.client_id'); - $this->db->order_by('Id','desc'); - $query = $this->db->get(); - return $query->result(); - - } - - - function GetEnquiry($Id) - { - $this->db->select('T_Enquiry.*,client_name'); - $this->db->from('T_Enquiry'); - $this->db->join('ip_clients','ip_clients.client_id=T_Enquiry.client_id'); - $this->db->where('Id',$Id); - $this->db->order_by('Id','desc'); - $query = $this->db->get(); - return $query->result(); - } - - - -function GetEnquiryCount($createddt) -{ - - $this->db->select('count(Id) as Countnumber'); - $this->db->from('T_Enquiry'); - $this->db->where('Created_Date',$createddt); - $query = $this->db->get(); - return $query->result(); -} - - -function SaveActionMaster($master) -{ - - $this->db->trans_start(); - $this->db->insert('T_ActionReport_Master', $master); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - if($insert_id>0) - { - $subQuery = 'select max(Id) as Id from T_ActionReport_Master'; - - $query = $this->db->query($subQuery,array()); - - return $query->result_array(); - } -} - - -function SaveActionDisposition($actionsave) -{ - $this->db->trans_start(); - $this->db->insert('T_Action_Disposition',$actionsave); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; -} - - -function UpdateActionDisposition($actionsave,$LineDisposition) -{ - //echo $LineDisposition; - - $this->db->where('DispositionId', $LineDisposition); - $this->db->update('T_Action_Disposition', $actionsave); - return TRUE; -} - -function UpdateRootCause($rootsave,$Lineroot) -{ - $this->db->where('RootId', $Lineroot); - $this->db->update('T_RootCause', $rootsave); - return TRUE; -} - - -function Updatecounteraction($savecounter,$LineCounter) -{ - $this->db->where('CounterId', $LineCounter); - $this->db->update('T_Action_Counter_Measure', $savecounter); - return TRUE; -} - - -function UpdateActionMaster($master,$Id) -{ - - $this->db->where('Id', $Id); - $this->db->update('T_ActionReport_Master', $master); - $insert_id = $this->db->affected_rows(); - //return TRUE; - if($insert_id>0) - { - $subQuery = 'select max(Id) as Id from T_ActionReport_Master'; - - $query = $this->db->query($subQuery,array()); - - return $query->result_array(); - } -} - - - -function SaveRootCause($rootsave) -{ - - $this->db->trans_start(); - $this->db->insert('T_RootCause',$rootsave); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - -} - -function Savecounteraction($savecounter) -{ - $this->db->trans_start(); - $this->db->insert('T_Action_Counter_Measure',$savecounter); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; -} - -function GetNcrlist() -{ - $this->db->select('*'); - $this->db->from('T_ComplaintRegister'); - $this->db->join('ip_clients','ip_clients.client_id=T_ComplaintRegister.client_id'); - $this->db->order_by('CId','desc'); - $query = $this->db->get(); - return $query->result(); -} - - -function GetncrmasterDetails($Id) -{ - $this->db->select('*'); - $this->db->from('T_ActionReport_Master'); - $this->db->where('Id',$Id); - $query = $this->db->get(); - return $query->result(); -} - - -function GetDispositionDetails($Id) -{ - $this->db->select('*'); - $this->db->from('T_Action_Disposition'); - $this->db->where('Id',$Id); - $query = $this->db->get(); - return $query->result(); - -} - -function GetRootcauseDetails($Id) -{ - $this->db->select('*'); - $this->db->from('T_RootCause'); - $this->db->where('Id',$Id); - $query = $this->db->get(); - return $query->result(); - -} - -function GetCouteractionDetails($Id) -{ - - $this->db->select('*'); - $this->db->from('T_Action_Counter_Measure'); - $this->db->where('Id',$Id); - $query = $this->db->get(); - return $query->result(); -} - - - -function Savecomplaint($save_complaint) -{ - $this->db->trans_start(); - $this->db->insert('T_ComplaintRegister',$save_complaint); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; -} - - -function Get_SavedComplaint($CId) -{ - $this->db->select('*'); - $this->db->from('T_ComplaintRegister'); - $this->db->join('ip_clients','ip_clients.client_id=T_ComplaintRegister.client_id'); - $this->db->where('CId',$CId); - $this->db->order_by('CId','desc'); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); -} - -function Updatecomplaint($save_complaint,$CId) -{ - - $this->db->where('CId', $CId); - $this->db->update('T_ComplaintRegister', $save_complaint); - return TRUE; -} - -function updatecomplaintId($up,$CId) -{ - $this->db->where('CId', $CId); - $this->db->update('T_ComplaintRegister',$up); - return TRUE; -} - - -function GetActionid($LineDisposition) -{ - - $this->db->select('*'); - $this->db->from('T_Action_Disposition'); - $this->db->where('DispositionId',$LineDisposition); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); -} - - - -function GetlastDispositionId() -{ - $subQuery = 'select max(DispositionId) from T_Action_Disposition'; - - $query = $this->db->query($subQuery,array()); - - return $query->result_array(); -} - - - -function Getrootid($Lineroot) -{ - $this->db->select('*'); - $this->db->from('T_RootCause'); - $this->db->where('RootId',$Lineroot); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); -} - - - -function Getcounterid($LineCounter) -{ - $this->db->select('*'); - $this->db->from('T_Action_Counter_Measure'); - $this->db->where('CounterId',$LineCounter); - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); -} - - -function DeleteAction($DelId) -{ - $this->db->where('DispositionId', $DelId); - $this->db->delete('T_Action_Disposition'); - //print_r($this->db->last_query()); - return TRUE; -} - - -function DeleteRoot($DelId) -{ - $this->db->where('RootId', $DelId); - $this->db->delete('T_RootCause'); - //print_r($this->db->last_query()); - return TRUE; -} - - -function DeleteCounter($DelId) -{ - $this->db->where('CounterId', $DelId); - $this->db->delete('T_Action_Counter_Measure'); - //print_r($this->db->last_query()); - return TRUE; -} - - -/*------------------------------------------------------------------------------*/ - -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_PurchaseOrder_BillUpload'); -$afftectedRows = $this->db->affected_rows(); -return $afftectedRows; - -} - - - -// function newlogpo($logpo) -// { - -// $this->db->trans_start(); -// $this->db->insert('T_ponewlogs_Details',$logpo); -// $insert_id = $this->db->affected_rows(); -// $this->db->trans_complete(); -// return $insert_id; - - -// // $this->db->trans_start(); -// // $this->db->insert('T_polog_Details',$logpo); -// // $insert_id = $this->db->affected_rows(); -// // $this->db->trans_complete(); -// // return $insert_id; - -// } - - - -function insertlogpo($logpo){ - - - - - // $this->db->where('MaterialCode',$MaterialCode,'LineItemNos',$POLineItemNo); - // $this->db->update('T_ponewlogs_Details',$logpo); - $this->db->trans_start(); - $this->db->insert('T_polog_Details',$logpo); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - -} -function getlogpodtl($PONO){ - - - - - - -// $SQL = "select distinct log.PONO as LPONO, -// case -// WHEN log.Quantity <> pl.Quantity THEN log.Quantity -// else '-' -// ENd as Lqty, - -// case -// WHEN log.SupplierID <> pm.SupplierID THEN sup.Suppliername -// else '-' -// ENd as LSuppid, -// case -// WHEN log.Date <> pm.PODate THEN log.Date -// else '-' -// ENd as logDate , -// case -// WHEN log.Rate <> pl.Rate THEN log.Rate -// else '-' -// ENd as logRate , - - -// log.LineItemNos,log.MaterialCode,log.UpdatedOn,log.UpdateBy,emp.FirstName - - -// from T_ponewlogs_Details log -// join T_PurchaseOrder_LineItem pl on log.LineItemNos = pl.LineItemNo -// join T_PurchaseOrder_Master pm on pm.PONO = log.PONO -// join tbl_users user on user.userId = log.UpdateBy -// left join T_Employee_Details emp on emp.EmpID= user.EmpID -// left join T_SupplierDetailsN sup on sup.SupplierID = log.SupplierID -// where log.PONO ='".$PONO."'"; - - - -$SQL = "select log.*,sup.SupplierName,emp.FirstName from - T_polog_Details log - join tbl_users user on user.userId = log.UpdateBy - left join T_Employee_Details emp on emp.EmpID= user.EmpID - left join T_SupplierDetailsN sup on sup.SupplierID = log.oldValue - where PONO ='".$PONO."'"; - - -$logpodtl = $this->db->query($SQL); - - return $logpodtl->result(); -} - - - // function EditpoValues($pono) - // { - // $this->db->select('*'); - // $this->db->from('T_ponewlogs_Details'); - // $this->db->where('PONO',$pono); - // // $this->db->where('MaterialCode',$materialcode); - // $query = $this->db->get(); - // return $query->result_array(); - // } - - - function insertfile($filelist) - { - - //print_r($myfile);die; - - $this->db->insert('T_PurchaseOrder_BillUpload',$filelist); - $myfile=$this->db->affected_rows(); - return $myfile; - } - -/*------------------------------------------------------------------------------*/ - -function updateigrM($PONO,$IGRNo,$igrMaster){ - - //print_r($igrMaster);die; - $this->db->where('PONO',$PONO); - $this->db->where('IGRNO',$IGRNo); - - $this->db->update('T_IGR_Master',$igrMaster); - - $r = $this->db->affected_rows(); - return $r; -} -function getigrno($bill){ - - $subQuery ='select bill.BillNo,IGR.IGRNO, IGR.PONO FROM T_IGR_Master IGR - join T_PurchaseOrder_BillUpload bill on bill.IGRNO = IGR.IGRNO - where bill.BillNO = ? '; - - $query = $this->db->query($subQuery,array($bill)); - - return $query->result_array(); - } - /*** ----------------------------- */ -} \ No newline at end of file diff --git a/application/models/models/quality_model.php b/application/models/models/quality_model.php deleted file mode 100644 index 2fe7c161..00000000 --- a/application/models/models/quality_model.php +++ /dev/null @@ -1,589 +0,0 @@ -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(); - } -} -?> \ No newline at end of file diff --git a/application/models/models/rawmaterialdetails_model.php b/application/models/models/rawmaterialdetails_model.php deleted file mode 100644 index d5ff54a8..00000000 --- a/application/models/models/rawmaterialdetails_model.php +++ /dev/null @@ -1,350 +0,0 @@ -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)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(); - } - -} -?> \ No newline at end of file diff --git a/application/models/models/requistion_model.php b/application/models/models/requistion_model.php deleted file mode 100644 index a290c9e8..00000000 --- a/application/models/models/requistion_model.php +++ /dev/null @@ -1,540 +0,0 @@ -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(); - } - - - -} - - \ No newline at end of file diff --git a/application/models/models/store_model.php b/application/models/models/store_model.php deleted file mode 100644 index a45b09bb..00000000 --- a/application/models/models/store_model.php +++ /dev/null @@ -1,81 +0,0 @@ -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(); - } - -} - - \ No newline at end of file diff --git a/application/models/models/storerequistion_model.php b/application/models/models/storerequistion_model.php deleted file mode 100644 index 5341bdb2..00000000 --- a/application/models/models/storerequistion_model.php +++ /dev/null @@ -1,507 +0,0 @@ -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; - } - } \ No newline at end of file diff --git a/application/models/models/supplier_model.php b/application/models/models/supplier_model.php deleted file mode 100644 index 66e3cde2..00000000 --- a/application/models/models/supplier_model.php +++ /dev/null @@ -1,207 +0,0 @@ -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 */ - - } -?> \ No newline at end of file diff --git a/application/models/models/user_model.php b/application/models/models/user_model.php deleted file mode 100644 index 0f5850c1..00000000 --- a/application/models/models/user_model.php +++ /dev/null @@ -1,315 +0,0 @@ -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; - } - } - - -} - - \ No newline at end of file diff --git a/application/models/mrir_model.php b/application/models/mrir_model.php index feb4efc9..7a410308 100644 --- a/application/models/mrir_model.php +++ b/application/models/mrir_model.php @@ -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(); } diff --git a/application/models/requistion_model.php b/application/models/requistion_model.php index a290c9e8..d693b521 100644 --- a/application/models/requistion_model.php +++ b/application/models/requistion_model.php @@ -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)); } diff --git a/application/views/createPOfromRequistion.php b/application/views/createPOfromRequistion.php index 491a19a4..a098115c 100644 --- a/application/views/createPOfromRequistion.php +++ b/application/views/createPOfromRequistion.php @@ -438,7 +438,7 @@ $(function () { "lengthChange": true, "searching": true, "columnDefs" : [{"targets":4, "type":"date-eu"}], - + "aaSorting": [[ 4, "desc" ]], "ordering": true, "info": true, "autoWidth": true diff --git a/application/views/requisitionlistapproval.php b/application/views/requisitionlistapproval.php index 4661661d..31481ec1 100644 --- a/application/views/requisitionlistapproval.php +++ b/application/views/requisitionlistapproval.php @@ -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 diff --git a/application/views/requisitionlisting.php b/application/views/requisitionlisting.php index 491749eb..c72c6225 100644 --- a/application/views/requisitionlisting.php +++ b/application/views/requisitionlisting.php @@ -143,7 +143,7 @@ span.highlight { "ordering": true, "columnDefs" : [{"targets":7, "type":"date-eu"}], - "aaSorting": [[ 0, "desc" ]], + "aaSorting": [[ 7, "desc" ]], "info": true, "autoWidth": true diff --git a/application/views/storerequisition.php b/application/views/storerequisition.php index 0a8c3ba6..85ec2717 100644 --- a/application/views/storerequisition.php +++ b/application/views/storerequisition.php @@ -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 diff --git a/application/views/storestatus.php b/application/views/storestatus.php index f3cd5aa4..a4d11a15 100644 --- a/application/views/storestatus.php +++ b/application/views/storestatus.php @@ -583,6 +583,7 @@ function validate() "searching": true, "ordering": true, "columnDefs" : [{"targets":6, "type":"date-eu"}], + "aaSorting": [[ 6, "desc" ]], "info": true, "autoWidth": false });