Beispiel #1
0
 function get_premium_general_for_business_aggregate()
 {
     if (isset($_GET['for_premium_general'])) {
         $for_premium_general = $_GET['for_premium_general'];
         $explode_for_premium_general = explode(',', $for_premium_general);
         $dates = explode('_', $explode_for_premium_general[1]);
         $premium_register_general_report = array();
         $WStartDtObj = new DateTime($this->input->post('from_date'));
         $premium_register_general_report['from_date'] = $WStartDtObj->format('Y-m-d');
         $WEndDtObj = new DateTime($this->input->post('to_date'));
         $premium_register_general_report['to_date'] = $WEndDtObj->format('Y-m-d');
         $premium_register_general_report['type'] = $this->input->post('type');
         $condition_array = array();
         $conditions = '';
         if ($explode_for_premium_general[0] != '') {
             if (trim($explode_for_premium_general[0]) != trim('ALL BRANCHES')) {
                 array_push($condition_array, " pod.branch_id =" . $explode_for_premium_general[0]);
             } else {
                 $conditions = '';
             }
         }
         if ($explode_for_premium_general[3] != '') {
             if ($explode_for_premium_general[3] != 'All') {
                 array_push($condition_array, " mt.product_category_id =" . $explode_for_premium_general[3]);
             } else {
                 $conditions = '';
             }
         }
         $date_string = '';
         if ($dates[0] != '' && $dates[1] != '') {
             if ($explode_for_premium_general[2] == 'AD') {
                 $date_type = "(Approval Date)";
                 array_push($condition_array, " pod.approved_date BETWEEN '" . $dates[0] . "' AND '" . $dates[1] . "'");
             } else {
                 $date_type = "(Policy Date)";
                 array_push($condition_array, " pod.from_date_details BETWEEN '" . $dates[0] . "' AND '" . $dates[1] . "'");
             }
             $from_date = $dates[0];
             $to_date = $dates[1];
             $date_string = ' for ' . $from_date . ' - ' . $to_date . $date_type;
         }
         $result = $this->report_model->get_premium_register_general_report_info($condition_array, $conditions);
         $folder = 'timesheet/reports/production/premium_register_general';
         if (sizeof($result) > 0) {
             if ($this->input->post('branch') != 'All') {
                 $branch = $result[0]['branch'];
             } else {
                 $branch = 'ALL BRANCHES';
             }
             $report_heading = 'Premium Register (General) - ' . $branch . $date_string;
             $name = 'Premium_Register_(General)';
             $show_data['premium_register_general_report'] = $result;
             $this->load->helper('amountinwords');
             $this->load->helper(array('timesheet', 'file'));
             $timesheet_result = create_timesheet_premium_register($result, $folder, $name, $report_heading);
             if ($timesheet_result != '') {
                 redirect(base_url() . 'timesheet/reports/production/premium_register_general/' . $timesheet_result . '.xlsx');
                 exit;
             }
         } else {
             $show_data['error'] = 'No Data Found';
         }
     }
 }
Beispiel #2
0
 function index()
 {
     $show_data = array();
     $show_data['error'] = '';
     $show_data['success'] = $this->session->userdata('success');
     $this->clearmessage();
     /*  Intermediary Commission Report  */
     if (isset($_POST['intermediary_commision_report'])) {
         $this->load->library('form_validation');
         $config = array(array('field' => 'branch', 'label' => 'Branch Name', 'rules' => 'required'));
         $this->form_validation->set_rules($config);
         if ($this->form_validation->run() != false) {
             $intermediary_commision_report = array();
             $intermediary_commision_report['branch'] = $this->input->post('branch');
             $intermediary_commision_report['intermediary'] = $this->input->post('intermediary');
             $intermediary_commision_report['intermediary_users'] = $this->input->post('intermediary_users');
             $WStartDtObj = new DateTime($this->input->post('from_date'));
             $intermediary_commision_report['from_date'] = $WStartDtObj->format('Y-m-d');
             $WEndDtObj = new DateTime($this->input->post('to_date'));
             $intermediary_commision_report['to_date'] = $WEndDtObj->format('Y-m-d');
             $intermediary_commision_report['paid_status'] = $this->input->post('paid_status');
             $condition_array = array();
             if ($this->input->post('branch') != '') {
                 array_push($condition_array, " mt.branch_id =" . $this->input->post('branch'));
             }
             if ($this->input->post('intermediary') != '') {
                 array_push($condition_array, " pod.source_of_business =" . $this->input->post('intermediary'));
             }
             if ($this->input->post('intermediary_users') != '') {
                 if ($this->input->post('intermediary') == 1 || $this->input->post('intermediary') == 2 || $this->input->post('intermediary') == 3) {
                     array_push($condition_array, " inter.user_type_id =" . $this->input->post('intermediary_users'));
                 } else {
                     if ($this->input->post('intermediary') == 4) {
                         array_push($condition_array, " tia_ud.user_details_id =" . $this->input->post('intermediary_users'));
                     }
                 }
             }
             if ($this->input->post('from_date') != '' && $this->input->post('to_date') != '') {
                 array_push($condition_array, " pod.created_date BETWEEN '" . $intermediary_commision_report['from_date'] . "' AND '" . $intermediary_commision_report['to_date'] . "'");
             }
             $result = $this->report_model->get_intermediary_commision_report_info($condition_array);
             $folder = 'timesheet/reports/production/intermediary_commission';
             if (sizeof($result) > 0) {
                 $report_heading = 'Agency / Broker Commission Payable';
                 $name_1 = $result[0]['created_date'];
                 $row = explode(" ", $name_1);
                 $name = $row[0];
                 $show_data['freedate_report'] = $result;
                 $this->load->helper('amountinwords');
                 $this->load->helper(array('timesheet', 'file'));
                 $timesheet_result = create_timesheet_intermediary_commission($result, $folder, $name, $report_heading);
                 if ($timesheet_result != '') {
                     redirect(base_url() . 'timesheet/reports/production/intermediary_commission/' . $timesheet_result . '.xlsx');
                     exit;
                 }
             } else {
                 $show_data['error'] = 'No Data Found';
             }
         }
     }
     /*  Premium Register General Report  */
     if (isset($_POST['premium_register_general_report'])) {
         $this->load->library('form_validation');
         $config = array(array('field' => 'branch', 'label' => 'Branch Name', 'rules' => 'required'), array('field' => 'businesslines', 'label' => 'Business line', 'rules' => 'required'), array('field' => 'product_category', 'label' => 'Product Category', 'rules' => 'required'), array('field' => 'from_date', 'label' => 'From Date', 'rules' => 'required'), array('field' => 'to_date', 'label' => 'To Date', 'rules' => 'required'), array('field' => 'type', 'label' => 'Type', 'rules' => 'required'));
         $this->form_validation->set_rules($config);
         if ($this->form_validation->run() != false) {
             $premium_register_general_report = array();
             $premium_register_general_report['branch'] = $this->input->post('branch');
             $premium_register_general_report['businesslines'] = $this->input->post('businesslines');
             $premium_register_general_report['product_category'] = $this->input->post('product_category');
             $WStartDtObj = new DateTime($this->input->post('from_date'));
             $premium_register_general_report['from_date'] = $WStartDtObj->format('Y-m-d');
             $WEndDtObj = new DateTime($this->input->post('to_date'));
             $premium_register_general_report['to_date'] = $WEndDtObj->format('Y-m-d');
             $premium_register_general_report['type'] = $this->input->post('type');
             $condition_array = array();
             if ($this->input->post('branch') != '') {
                 array_push($condition_array, " mt.branch_id =" . $this->input->post('branch'));
             }
             if ($this->input->post('businesslines') != '') {
                 array_push($condition_array, " c.business_line_id =" . $this->input->post('businesslines'));
             }
             if ($this->input->post('product_category') != '') {
                 array_push($condition_array, " mt.product_category_id =" . $this->input->post('product_category'));
             }
             if ($this->input->post('from_date') != '' && $this->input->post('to_date') != '') {
                 array_push($condition_array, " pod.created_date BETWEEN '" . $premium_register_general_report['from_date'] . "' AND '" . $premium_register_general_report['to_date'] . "'");
             }
             if ($this->input->post('type') != '') {
                 array_push($condition_array, " pod.invoice_type =" . $this->input->post('type'));
             }
             $result = $this->report_model->get_premium_register_general_report_info($condition_array);
             $folder = 'timesheet/reports/production/premium_register_general';
             if (sizeof($result) > 0) {
                 $report_heading = 'Premium Register (General)';
                 // $name_1 = $result[0]['created_date'];
                 // $row = explode(" ",$name_1);
                 // $name = $row[0];
                 $name = 'Premium_Register_(General)';
                 $show_data['premium_register_general_report'] = $result;
                 $this->load->helper('amountinwords');
                 $this->load->helper(array('timesheet', 'file'));
                 $timesheet_result = create_timesheet_premium_register($result, $folder, $name, $report_heading);
                 if ($timesheet_result != '') {
                     redirect(base_url() . 'timesheet/reports/production/premium_register_general/' . $timesheet_result . '.xlsx');
                     exit;
                 }
             } else {
                 $show_data['error'] = 'No Data Found';
             }
         }
     }
     $this->load->view('underwriter/reports_view', $show_data);
 }