// ASTPP Version 3.0 and above // License https://www.gnu.org/licenses/agpl-3.0.html // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // ############################################################################## class Frauddetection extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('template_inheritance'); $this->load->library('session'); $this->load->library("frauddetection_form"); // $this->load->library('astpp/form'); $this->load->library('astpp/form',"frauddetection_form"); $this->load->model('frauddetection_model'); $this->load->library('csvreader'); $this->load->library('ASTPP_Sms'); if ($this->session->userdata('user_login') == FALSE) redirect(base_url() . '/astpp/login'); } function frauddetection_list() { $data['page_title'] = gettext('Fraud Detection'); $data['search_flag'] = true; $this->session->set_userdata('advance_search', 0); $data['grid_fields'] = $this->frauddetection_form->build_frauddetection_list_for_admin(); $data["grid_buttons"] = $this->frauddetection_form->build_grid_buttons(); $data['form_search'] = $this->form->build_serach_form($this->frauddetection_form->get_search_frauddetection_form()); $this->load->view('view_frauddetection_list', $data); } function frauddetection_list_json() { $json_data = array(); $count_all = $this->frauddetection_model->get_frauddetection_list(false); $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); $json_data = $paging_data["json_paging"]; $query = $this->frauddetection_model->get_frauddetection_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); //print_r($this->db->last_query()); die; $grid_fields = json_decode($this->frauddetection_form->build_frauddetection_list_for_admin()); $json_data['rows'] = $this->form->build_grid($query, $grid_fields); echo json_encode($json_data); } function frauddetection_add($type = "") { $data['username'] = $this->session->userdata('user_name'); $data['flag'] = 'create'; $data['page_title'] = gettext('Create Fraud Detection'); $data['form'] = $this->form->build_form($this->frauddetection_form->get_frauddetection_form_fields(), ''); $country_array = array(); $this->db->select('id,country,countrycode'); $country_array=$this->db->get('countrycode')->result_array(); $data['CountryListArr'] = $country_array; $this->load->view('view_frauddetection_add_edit', $data); } function frauddetection_edit($edit_id = '') { $accountinfo = $this->session->userdata('accountinfo'); if ($accountinfo['type'] == - 1 || $accountinfo['type'] == 2) { $data['page_title'] = gettext('Edit Fraud Detection'); $where = array( 'id' => $edit_id ); $account = $this->db_model->getSelect("*", "fraud_conf", $where); $edit_data = $account->row_array(); $data['form'] = $this->form->build_form($this->frauddetection_form->get_frauddetection_form_fields($edit_id), $edit_data); $data['filter'] = $edit_data['filter']; $this->load->view('view_frauddetection_add_edit', $data); } else { $this->session->set_flashdata('astpp_notification', gettext('Permission Denied!')); redirect(base_url() . 'frauddetection/frauddetection_list/'); exit(); } } function frauddetection_save() { $add_array = $this->input->post(); $data['form'] = $this->form->build_form($this->frauddetection_form->get_frauddetection_form_fields($add_array['id']), $add_array); if ($add_array['id'] != '') { $data['page_title'] = gettext('Edit Frauddetection'); if ($this->form_validation->run() == FALSE) { $data['validation_errors'] = validation_errors(); echo $data['validation_errors']; exit(); } else { $filter=''; if($add_array['filter_by'] == 'PER_COUNTRY' || $add_array['filter_by'] == 'GRP_BY_COUNTRY'){ foreach ($add_array['filter'] as $key => $value) { $filter .= $value . ','; } }else{ foreach ($add_array['filter'] as $key => $value) { $filter .= '^'. $value . '.*,'; } } $filter=rtrim($filter,','); $add_array['filter']=$filter; $this->frauddetection_model->edit_frauddetection($add_array, $add_array['id']); echo json_encode(array( "SUCCESS" => $add_array["access_number"] . gettext("Frauddetection Updated Successfully!") )); exit(); } } else { $data['page_title'] = gettext('frauddetection Details'); if ($this->form_validation->run() == FALSE) { $data['validation_errors'] = validation_errors(); echo $data['validation_errors']; exit(); } else { $filter=''; if($add_array['filter_by'] == 'PER_COUNTRY' || $add_array['filter_by'] == 'GRP_BY_COUNTRY'){ foreach ($add_array['filter'] as $key => $value) { $filter .= $value . ','; } }else{ foreach ($add_array['filter'] as $key => $value) { $filter .= '^'. $value . '.*,'; } } $filter=rtrim($filter,','); $add_array['filter']=$filter; $this->frauddetection_model->add_frauddetection($add_array); echo json_encode(array( "SUCCESS" => $add_array["access_number"] . gettext("Frauddetection Added Successfully!") )); exit(); } } } function frauddetection_list_search() { $ajax_search = $this->input->post('ajax_search', 0); // echo 123122;exit; if ($this->input->post('advance_search', TRUE) == 1) { $this->session->set_userdata('advance_search', $this->input->post('advance_search')); $action = $this->input->post(); // print_r($action['name']);exit; unset($action['action']); unset($action['advance_search']); $this->session->set_userdata('frauddetection_list_search', $action); } if (@$ajax_search != 1) { redirect(base_url() . 'frauddetection/frauddetection_list/'); } } function frauddetection_list_clearsearchfilter() { $this->session->set_userdata('advance_search', 0); $this->session->set_userdata('frauddetection_list_search', ""); } function frauddetection_remove($id) { $this->frauddetection_model->remove_frauddetection($id); $this->session->set_flashdata('astpp_notification', gettext('Frauddetection Removed Successfully!')); redirect(base_url() . 'frauddetection/frauddetection_list/'); } function frauddetection_multiple_delete() { $ids = $this->input->post("selected_ids", true); $where = "id IN (" . $ids . ")"; $this->db->where($where); echo $this->db->delete("fraud_conf"); } /*function frauddetection_filter_by() { $filter_value = $_POST['filter']; $filter_array = explode(',',$filter_value); $filter_by = $_POST['filter_by']; $filter = array(); if(!empty($filter_array)){ foreach($filter_array as $key => $value) { $filter[$key] = ltrim(rtrim($value,'.*'),'^'); } } if($filter_by != '' ) { if($filter_by == "PER_DST_PREFIX" || $filter_by == "GRP_BY_PREFIX" ) { $this->db->where('status',0); $this->db->where('id',1); $this->db->select('pattern'); $this->db->group_by('pattern'); $accounts_arrays=$this->db->get('routes')->result_array(); foreach($accounts_arrays as $key => $accounts_array) { $accounts[ltrim(rtrim($accounts_array['pattern'],'.*'),'^')] = ltrim(rtrim($accounts_array['pattern'],'.*'),'^'); } $did_info = array("name" => "filter[]", "id" => "filter_value_new", "class" => "form-control"); echo form_dropdown_multiselect($did_info, $accounts, $filter); exit; } else { $this->db->select('id,country'); $this->db->group_by('countrycode'); $accounts_arrays=$this->db->get('countrycode')->result_array(); $accounts = array(); foreach($accounts_arrays as $key => $accounts_array) { $accounts[$accounts_array['id']] = $accounts_array['country']; } $did_info = array("name" => "filter[]", "id" => "filter_value_new", "class" => "form-control"); echo form_dropdown_multiselect($did_info, $accounts, $filter); exit; } return false; } }*/ function frauddetection_filter_by() { $filter_value = $_POST['filter']; $filter_array = explode(',',$filter_value); $filter_by = $_POST['filter_by']; $filter = array(); if(!empty($filter_array)){ foreach($filter_array as $key => $value) { $filter[$key] = ltrim(rtrim($value,'.*'),'^'); } } if($filter_by != '' ) { if($filter_by == "PER_DST_PREFIX" || $filter_by == "GRP_BY_PREFIX" ) { $where = array("status"=>0, "pricelist_id"=>1); $this->db->where($where); $this->db->select("pattern"); $this->db->group_by('pattern'); $accounts_arrays=$this->db->get('routes')->result_array(); //echo "
"; print_r($accounts_arrays); exit;
                      //echo $this->db->last_query(); exit;
                          /*foreach($accounts_arrays as $key => $accounts_array) {
                            $accounts[ltrim(rtrim($accounts_array['pattern'],'.*'),'^')] = ltrim(rtrim($accounts_array['pattern'],'.*'),'^');
                      }*/
                          $did_info = array("name" => "filter[]", "id" => "filter_value_new", "class" => "form-control");
                          echo $this->build_dropdown_pattern($did_info, $accounts_arrays, $filter);
                          exit;
                } else {
                    $this->db->select('id,country');
                    //$this->db->group_by('countrycode');
                    $accounts_arrays=$this->db->get('countrycode')->result_array();
                    $accounts = array();
                    foreach($accounts_arrays as $key => $accounts_array) {
                           $accounts[$accounts_array['id']] = $accounts_array['country'];
                    }
                    //echo "
"; print_r($accounts); exit;
                    $did_info = array("name" => "filter[]", "id" => "filter_value_new", "class" => "form-control");
                    echo $this->build_dropdown_pattern($did_info, $accounts, $filter,"","country");
                    exit;
            }
                                return false;
            }
        }
 
         function build_dropdown_pattern($name = '', $options = array(), $selected = array(), $extra = '', $flag='')
    {
        if ( ! is_array($selected))
        {
            $selected = array($selected);
        }
//echo "
"; print_r($selected); exit;
        if ($extra != '') {
            $extra = ' '.$extra;
        }
 
        $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
        $form = '';
 
        return $form;
    }
 
}
?>