?
Current Path : /home1/savoy/public_html/savoyglobal.net/rms/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/rms/application/models/reportmodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Reportmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function search_report() { $data = array(); $this->db->select('*'); $this->db->from('report'); $this->db->where('report_module_id', $_SESSION['current_mode']); $this->db->order_by('report_sort', 'asc'); $data['results'] = $this->db->get(); return $data; } function get_customer_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("customer"); $this->db->join('location', 'location.location_id=customer.customer_location_id'); $this->db->join('master', 'master.master_id=customer.customer_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['customer_location_id'] != '') { $this->db->where('location.location_id', $postdata['customer_location_id']); } if ($postdata['customer_status'] != '') { $this->db->where('customer_status', $postdata['customer_status']); } if ($postdata['customer_type'] != '') { $this->db->where('customer_type', $postdata['customer_type']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_customer_lease_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("customer"); $this->db->join('location', 'location.location_id=customer.customer_location_id'); $this->db->join('lease_agreement', 'lease_agreement.lease_customer_id=customer.customer_id'); $this->db->join('building_details', 'building_details.building_id=lease_agreement.lease_building_id'); $this->db->join('master', 'master.master_id=customer.customer_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('lease_start_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('lease_end_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['customer_location_id'] != '') { $this->db->where('location.location_id', $postdata['customer_location_id']); } if ($postdata['lease_customer_id'] != '') { $this->db->where('customer.customer_id', $postdata['lease_customer_id']); } if ($postdata['customer_type'] != '') { $this->db->where('customer_type', $postdata['customer_type']); } if ($postdata['lease_agreement_code'] != '') { $this->db->where('lease_agreement_code', $postdata['lease_agreement_code']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_vendor_report($postdata) { $log_in_type = $_SESSION['login_type']; $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $location = $postdata['location']; $where_loc = ''; if ($location != '') { $where_loc = "vendor.vendor_location= $location and "; } $data = array(); $res = $this->db->query("select $searchstr from vendor JOIN master ON master_id=vendor_id JOIN location ON location_id=vendor_location where $where_loc master.login_type_id ='$log_in_type' "); foreach ($res->result_array() as $row) { $data[] = $row; } return $data; } function get_maintenanace_contract_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("maintenance_contract"); $this->db->join('building_details', 'building_details.building_id=maintenance_contract.maintenance_contract_building_id'); $this->db->join('maintenance_cc', 'maintenance_cc.maintenance_cc_id=maintenance_contract.maintenance_contracting_company_id'); $this->db->join('master', 'master.master_id=maintenance_contract.maintenance_contract_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('maintenance_contract_start_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('maintenance_contract_end_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['maintenance_contract_building_id'] != '') { $this->db->where('building_details.building_id', $postdata['maintenance_contract_building_id']); } if ($postdata['maintenance_contracting_company_id'] != '') { $this->db->where('maintenance_cc.maintenance_cc_id', $postdata['maintenance_contracting_company_id']); } $this->db->order_by('maintenance_contract_start_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_purchase_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); if (isset($postdata['total_amount'])) $searchstr .= ',vendor_purchase_details.vendor_purchase_inventory_qty * vendor_purchase_details.vendor_purchase_inventory_amount -vendor_purchase_details. vendor_purchase_discount as Total'; $this->db->select($searchstr . ',vendor_purchase.vendor_purchase_id'); $this->db->from("vendor_purchase"); $this->db->join('vendor_purchase_details', 'vendor_purchase_details.vendor_purchase_id=vendor_purchase.vendor_purchase_id'); $this->db->join('vendor', 'vendor.vendor_id=vendor_purchase.vendor_id'); $this->db->join('inventory', 'inventory.inventory_id=vendor_purchase_details.vendor_purchase_inventory_id'); $this->db->join('master', 'master.master_id=vendor_purchase.vendor_purchase_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('vendor_purchase_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('vendor_purchase_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['vendor_id'] != '') { $this->db->where('vendor_purchase.vendor_id', $postdata['vendor_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_inventory_utilization_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('' . $searchstr . ',inventory_utilization.inventory_utilization_id '); $this->db->from("inventory_utilization"); $this->db->join('inventory_utilization_details', 'inventory_utilization_details.inventory_utilization_id=inventory_utilization.inventory_utilization_id'); $this->db->join('building_details', 'building_details.building_id=inventory_utilization.inventory_utilization_building_id'); $this->db->join('employee', 'employee.employee_id=inventory_utilization.inventory_utilization_supervisor_id'); $this->db->join('inventory', 'inventory.inventory_id=inventory_utilization_details.inventory_utilization_stock_id'); $this->db->join('master', 'master.master_id=inventory_utilization.inventory_utilization_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['inventory_utilization_building_id'] != '') { $this->db->where('inventory_utilization.inventory_utilization_building_id', $postdata['inventory_utilization_building_id']); } if ($postdata['inventory_utilization_supervisor_id'] != '') { $this->db->where('inventory_utilization.inventory_utilization_supervisor_id', $postdata['inventory_utilization_supervisor_id']); } if ($postdata['start_date'] != '') { $this->db->where('inventory_utilization_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('inventory_utilization_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_inventory_return_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('' . $searchstr . ',inventory_return.inventory_return_id'); $this->db->from("inventory_return"); $this->db->join('inventory_return_details', 'inventory_return_details.inventory_return_id=inventory_return.inventory_return_id'); $this->db->join('building_details', 'building_details.building_id=inventory_return.inventory_return_building_id'); $this->db->join('employee', 'employee.employee_id=inventory_return.inventory_return_supervisor_id'); $this->db->join('inventory', 'inventory.inventory_id=inventory_return_details.inventory_return_stock_id'); $this->db->join('master', 'master.master_id=inventory_return.inventory_return_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['inventory_return_building_id'] != '') { $this->db->where('inventory_return.inventory_return_building_id', $postdata['inventory_return_building_id']); } if ($postdata['inventory_return_supervisor_id'] != '') { $this->db->where('inventory_return.inventory_return_supervisor_id', $postdata['inventory_return_supervisor_id']); } if ($postdata['start_date'] != '') { $this->db->where('inventory_return_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('inventory_return_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_current_stock_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $this->db->select('*,stock.stock_id as stock_id'); $this->db->from("stock"); $this->db->join('inventory', 'inventory.inventory_id=stock.stock_inventory_id'); $this->db->join('master', 'master.master_id=stock.stock_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['stock_inventory_id'] != '') { $this->db->where('stock.stock_inventory_id', $postdata['stock_inventory_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_project_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); if (isset($postdata['balance_amount'])) $searchstr .= ',project_details.contracting_value -project_details.paid_amount as Balance'; $this->db->select('' . $searchstr . ',project.project_id'); $this->db->from("project"); $this->db->join('project_details', 'project_details.project_id=project.project_id'); $this->db->join('contracting_company', 'contracting_company.cc_id=project_details.contracting_company_id'); $this->db->join('master', 'master.master_id=project.project_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('project_start_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('project_end_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['project_title'] != '') { $this->db->where('project_title', $postdata['project_title']); } $this->db->order_by('project_start_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_employee_details_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("employee"); $this->db->join('department', 'department.department_id=employee.employee_department_id'); $this->db->join('designation', 'designation.designation_id=employee.employee_designation_id'); $this->db->join('grade', 'grade.grade_id=employee.employee_grade_id'); $this->db->join('master', 'master.master_id=employee.employee_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['employee_name'] != '') { $this->db->where('employee_name', $postdata['employee_name']); } if ($postdata['employee_department_id'] != '') { $this->db->where('employee.employee_department_id', $postdata['employee_department_id']); } if ($postdata['employee_designation_id'] != '') { $this->db->where('employee.employee_designation_id', $postdata['employee_designation_id']); } if ($postdata['employee_grade_id'] != '') { $this->db->where('employee.employee_grade_id', $postdata['employee_grade_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_leave_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("leave_application"); $this->db->join('employee', 'employee.employee_id=leave_application.employee_id'); $this->db->join('leave_type', 'leave_type.leave_type_id=leave_application.leave_type_id'); $this->db->join('master', 'master.master_id=leave_application.leave_application_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('from_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('to_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } if ($postdata['leave_type_id'] != '') { $this->db->where('leave_type.leave_type_id', $postdata['leave_type_id']); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_tool_allocation_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('' . $searchstr . ',tool_allocation.tool_allocation_id'); $this->db->from("tool_allocation"); $this->db->join('tool_allocation_details', 'tool_allocation_details.tool_allocation_id=tool_allocation.tool_allocation_id'); $this->db->join('tool_kit_details', 'tool_kit_details.id=tool_allocation_details.tool_allocation_kit_id'); $this->db->join('tool_kit', 'tool_kit.tool_id=tool_kit_details.tool_id'); $this->db->join('employee', 'employee.employee_id=tool_allocation.employee_id'); $this->db->join('master', 'master.master_id=tool_allocation.tool_allocation_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('tool_allocation_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('tool_allocation_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } $this->db->order_by('tool_allocation_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_tool_return_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('' . $searchstr . ',tool_return.tool_return_id'); $this->db->from("tool_return"); $this->db->join('tool_return_details', 'tool_return_details.tool_return_id=tool_return.tool_return_id'); $this->db->join('tool_kit_details', 'tool_kit_details.id=tool_return_details.tool_kit_id'); $this->db->join('tool_kit', 'tool_kit.tool_id=tool_kit_details.tool_id'); $this->db->join('employee', 'employee.employee_id=tool_return.employee_id'); $this->db->join('master', 'master.master_id=tool_return.tool_return_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['start_date'] != '') { $this->db->where('tool_return_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('tool_return_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } $this->db->order_by('tool_return_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_salary_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("employee_salary_slip"); $this->db->join('employee', 'employee.employee_id=employee_salary_slip.employee_id'); $this->db->join('master', 'master.master_id=employee_salary_slip.employee_salary_slip_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['employee_id'] != '') { $this->db->where('employee.employee_id', $postdata['employee_id']); } if ($postdata['start_date'] != '') { $this->db->where('salary_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('salary_date<=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_maintenance_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("building_maintenance"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=building_maintenance.bm_lease_id'); $this->db->join('maintenance_cc', 'maintenance_cc.maintenance_cc_id=building_maintenance.bm_contractor_id'); $this->db->join('master', 'master.master_id=building_maintenance.bm_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['bm_contractor_id'] != '') { $this->db->where('maintenance_cc.maintenance_cc_id', $postdata['bm_contractor_id']); } if ($postdata['bm_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['bm_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('bm_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('bm_date<=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_complaint_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("building_complaint"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=building_complaint.complaint_lease_id'); $this->db->join('master', 'master.master_id=building_complaint.complaint_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['complaint_code'] != '') { $this->db->where('complaint_code', $postdata['complaint_code']); } if ($postdata['complaint_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['complaint_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('complaint_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('complaint_date<=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_letter_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("disciplinary_letter"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=disciplinary_letter.disciplinary_lease_id'); $this->db->join('master', 'master.master_id=disciplinary_letter.disciplinary_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['disciplinary_code'] != '') { $this->db->where('disciplinary_code', $postdata['disciplinary_code']); } if ($postdata['disciplinary_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['disciplinary_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('disciplinary_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('disciplinary_date<=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_renewal_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("extension"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=extension.extension_lease_id'); $this->db->join('master', 'master.master_id=extension.extension_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['extension_code'] != '') { $this->db->where('extension_code', $postdata['extension_code']); } if ($postdata['extension_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['extension_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('renewal_contract_start_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('renewal_contract_end_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_termination_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as " . $column_name[1] . ","; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select('' . $searchstr . ',contract_termination.termination_id'); $this->db->from("contract_termination"); $this->db->join('contract_termination_appliance', 'contract_termination_appliance.termination_id=contract_termination.termination_id'); $this->db->join('appliance', 'appliance.appliance_id=contract_termination_appliance.termination_appliance_id'); $this->db->join('lease_agreement', 'lease_agreement.lease_id=contract_termination.termination_lease_id'); $this->db->join('master', 'master.master_id=contract_termination.termination_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['termination_code'] != '') { $this->db->where('termination_code', $postdata['termination_code']); } if ($postdata['start_date'] != '') { $this->db->where('termination_effective_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('termination_effective_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } if ($postdata['termination_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['termination_lease_id']); } $this->db->order_by('termination_effective_date', 'desc'); $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_misuse_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("building_misuse"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=building_misuse.misuse_lease_id'); $this->db->join('master', 'master.master_id=building_misuse.misuse_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['misuse_code'] != '') { $this->db->where('misuse_code', $postdata['misuse_code']); } if ($postdata['misuse_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['misuse_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('misuse_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('rmisuse_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_service_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("building_service"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=building_service.building_service_lease_id'); $this->db->join('master', 'master.master_id=building_service.building_service_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['building_service_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['building_service_lease_id']); } if ($postdata['building_service_code'] != '') { $this->db->where('building_service_code', $postdata['building_service_code']); } if ($postdata['start_date'] != '') { $this->db->where('building_service_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('building_service_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_penalty_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("building_penalty"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=building_penalty.building_penalty_lease_id'); $this->db->join('customer', 'customer.customer_id=lease_agreement.lease_customer_id'); $this->db->join('master', 'master.master_id=building_penalty.building_penalty_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['building_penalty_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['building_penalty_lease_id']); } if ($postdata['building_penalty_code'] != '') { $this->db->where('building_penalty_code', $postdata['building_penalty_code']); } if ($postdata['start_date'] != '') { $this->db->where('building_penalty_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('building_penalty_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_legal_notice_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("legal_notice"); $this->db->join('lease_agreement', 'lease_agreement.lease_id=legal_notice.legal_notice_lease_id'); $this->db->join('customer', 'customer.customer_id=lease_agreement.lease_customer_id'); $this->db->join('master', 'master.master_id=legal_notice.legal_notice_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['legal_notice_lease_id'] != '') { $this->db->where('lease_agreement.lease_id', $postdata['legal_notice_lease_id']); } if ($postdata['start_date'] != '') { $this->db->where('legal_notice_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('legal_notice_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_lease_agreement_report($postdata) { $log_in_type = $_SESSION['login_type']; $data = array(); $i = 1; $searchstr = ''; while ($i <= $postdata['field_count']) { if (isset($postdata['field_name_' . $i])) { $column_name = explode('~', $postdata['field_name_' . $i]); $searchstr .= $column_name[0] . " as '" . $column_name[1] . "',"; } $i++; } $searchstr = substr($searchstr, 0, -1); $this->db->select($searchstr); $this->db->from("lease_agreement"); $this->db->join('customer', 'customer.customer_id=lease_agreement.lease_customer_id'); $this->db->join('building_details', 'building_details.building_id=lease_agreement.lease_building_id'); $this->db->join('master', 'master.master_id=lease_agreement.lease_id'); $this->db->where('master.login_type_id', $log_in_type); if ($postdata['lease_agreement_code'] != '') { $this->db->where('lease_agreement_code', $postdata['lease_agreement_code']); } if ($postdata['lease_customer_id'] != '') { $this->db->where('customer.customer_id', $postdata['lease_customer_id']); } if ($postdata['lease_building_id'] != '') { $this->db->where('building_details.building_id', $postdata['lease_building_id']); } if ($postdata['lease_status'] != '') { $this->db->where('lease_status', $postdata['lease_status']); } if ($postdata['lease_flat_no'] != '') { $this->db->where('lease_flat_no', $postdata['lease_flat_no']); } if ($postdata['start_date'] != '') { $this->db->where('lease_start_date >=', $this->mastermodel->convertdateformat($postdata['start_date']) . " 00:00:00"); } if ($postdata['end_date'] != '') { $this->db->where('lease_end_date <=', $this->mastermodel->convertdateformat($postdata['end_date']) . " 23:59:59"); } $res = $this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } function get_occupancy_status_report($postdata) { $log_in_type = $_SESSION['login_type']; $data=array(); $this->db->select('*,lease_agreement.lease_id as lease_id'); $this->db->from("lease_agreement"); $this->db->join('customer','customer.customer_id=lease_agreement.lease_customer_id'); $this->db->join('building_details','building_details.building_id=lease_agreement.lease_building_id'); $this->db->join('building_type','building_type.building_type_id=building_details.building_type_id'); // $this->db->join('building_commercial_building_details','building_commercial_building_details.building_id=lease_agreement.lease_building_id','left'); // // $this->db->join('building_apartment_details','building_apartment_details.building_id=lease_agreement.lease_building_id','left'); // // $this->db->join('building_commercial_villa_details','building_commercial_villa_details.building_id=lease_agreement.lease_building_id','left'); $this->db->join('master','master.master_id=lease_agreement.lease_id'); $this->db->where('master.login_type_id', $log_in_type); if($postdata['building_type_id']!='') { $this->db->where('building_details.building_type_id',$postdata['building_type_id']); } if($postdata['lease_customer_id']!='') { $this->db->where('customer.customer_id',$postdata['lease_customer_id']); } if ($postdata['lease_building_id'] != '') { $this->db->where('building_details.building_id', $postdata['lease_building_id']); } if ($postdata['lease_status'] != '') { $this->db->where('lease_status', $postdata['lease_status']); } $res=$this->db->get(); if ($res->num_rows() > 0) { foreach ($res->result_array() as $row) { $data[] = $row; } } $res->free_result(); return $data; } }