diff --git a/application/models/companydetailsmodel.php b/application/models/companydetailsmodel.php new file mode 100644 index 00000000..d04421c6 --- /dev/null +++ b/application/models/companydetailsmodel.php @@ -0,0 +1,110 @@ +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'); + $this->db->from('T_Company_Details com'); + $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(); + } + + + // dropdown for file description @ companydetails// + /*function getfilename($Configvalue = '') + { + $ConfigID = 'C021'; + $this->db->select('ConfigValue'); + $this->db->from('t_configdetails'); + $this->db->where('Config_ID ',$ConfigID ); + $query = $this->db->get(); + return $query->result(); + }*/ + + + //display the name for createdby @companydetails// + + + + +} +?> \ No newline at end of file diff --git a/application/models/configmodel.php b/application/models/configmodel.php new file mode 100644 index 00000000..82e714db --- /dev/null +++ b/application/models/configmodel.php @@ -0,0 +1,190 @@ +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'); + + + $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; + } + + + 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/department_model.php b/application/models/department_model.php new file mode 100644 index 00000000..48dfce2d --- /dev/null +++ b/application/models/department_model.php @@ -0,0 +1,129 @@ +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($searchText = '') + { + $this->db->select('BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive'); + $this->db->from('T_DepartmentDetails as BaseT'); + 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() +{ + $this->db->distinct(); + $this->db->select('HeadDept'); + $this->db->from('T_DepartmentDetails'); + $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