Example #1
0
 function getUserRedemption($promotion_id, $status_id, $hide_expired = 0, $search_word = '')
 {
     $this->db->order_by('voucher', 'asc');
     if ($hide_expired == 1) {
         $this->db->where('expired_date >=', get_part_of_date('all'));
     }
     $redeem_query = $this->db->get_where('user_redemption', array('advertise_id' => $promotion_id, 'status_id' => $status_id));
     $result = $redeem_query->result_array();
     $return = array();
     foreach ($result as $row) {
         if (!empty($search_word)) {
             $user_info = $this->m_custom->getUserInfo($row['user_id']);
             if (searchWord($user_info['id'], $search_word) || searchWord($user_info['name'], $search_word) || searchWord($user_info['email'], $search_word) || searchWord($row['voucher'], $search_word)) {
                 $return[] = $row;
             }
         } else {
             $return[] = $row;
         }
     }
     return $return;
 }
Example #2
0
 public function remove_row_log($the_table, $the_id, $do_by = NULL, $do_by_type = NULL)
 {
     $query = $this->db->get_where('table_row_activity', array('table_type' => $the_table, 'table_row_id' => $the_id), 1);
     if ($query->num_rows() == 0) {
         $this->insert_row_log($the_table, $the_id, $do_by, $do_by_type);
         $query = $this->db->get_where('table_row_activity', array('table_type' => $the_table, 'table_row_id' => $the_id), 1);
     }
     $activity_row = $query->row();
     $admin_login_as = $this->session->userdata('admin_login_as');
     //If is admin login as this user
     $the_data = array('hide_time' => get_part_of_date('all'), 'hide_by' => $do_by, 'hide_by_type' => $do_by_type, 'admin_login_as' => $admin_login_as == 0 ? NULL : $admin_login_as);
     $this->db->where('activity_id', $activity_row->activity_id);
     $this->db->update('table_row_activity', $the_data);
 }
Example #3
0
 public function promotion_admin_redemption_done($redeem_id, $mark_expired = 0, $mark_active = 0)
 {
     if ($this->m_admin->check_is_any_admin(71)) {
         $login_id = $this->ion_auth->user()->row()->id;
         $login_type = $this->session->userdata('user_group_id');
         $status_id = $this->config->item('voucher_used');
         if ($mark_expired == 1) {
             $status_id = $this->config->item('voucher_expired');
         }
         if ($mark_active == 1) {
             $status_id = $this->config->item('voucher_active');
         }
         $the_data = array('status_id' => $status_id, 'redeem_at_date' => get_part_of_date('all'), 'done_by' => $login_id, 'done_by_type' => $login_type);
         $this->db->where('redeem_id', $redeem_id);
         if ($this->db->update('user_redemption', $the_data)) {
             return TRUE;
         }
     }
     return FALSE;
 }
Example #4
0
 function analysis_report($search_month = NULL, $search_year = NULL, $search_adv_type = NULL, $search_new_user = NULL)
 {
     $message_info = '';
     if (check_correct_login_type($this->main_group_id)) {
         //$this->data['charts'] = $this->getChart($merchant_id);
         $merchant_id = $this->ion_auth->user()->row()->id;
         $merchant_data = $this->m_custom->getUser($merchant_id);
         if (isset($_POST) && !empty($_POST)) {
             if ($this->input->post('button_action') == "search_history") {
                 $search_month = $this->input->post('the_month');
                 $search_year = $this->input->post('the_year');
                 $search_adv_type = $this->input->post('the_adv_type');
                 $search_new_user = $this->input->post('the_new_user');
             }
         }
         $year_list = generate_number_option(get_part_of_date('year', $merchant_data['created_on'], 1), get_part_of_date('year'));
         $this->data['year_list'] = $year_list;
         $this->data['the_year'] = array('name' => 'the_year', 'id' => 'the_year');
         $selected_year = empty($search_year) ? get_part_of_date('year') : $search_year;
         $this->data['the_year_selected'] = $selected_year;
         $month_list = $this->m_custom->month_group_list();
         $this->data['month_list'] = $month_list;
         $this->data['the_month'] = array('name' => 'the_month', 'id' => 'the_month');
         $selected_month = empty($search_month) ? get_part_of_date('month') : $search_month;
         $this->data['the_month_selected'] = $selected_month;
         $adv_type_list = array('' => 'All Advertise', 'hot' => 'Food & Beverage', 'pro' => 'Promotion');
         $this->data['adv_type_list'] = $adv_type_list;
         $this->data['the_adv_type'] = array('name' => 'the_adv_type', 'id' => 'the_adv_type');
         $this->data['the_adv_type_selected'] = empty($search_adv_type) ? "" : $search_adv_type;
         $new_user_list = array('' => 'All User', '1' => 'New User Only');
         $this->data['new_user_list'] = $new_user_list;
         $this->data['the_new_user'] = array('name' => 'the_new_user', 'id' => 'the_new_user');
         $this->data['the_new_user_selected'] = empty($search_new_user) ? "" : $search_new_user;
         $first_day = displayDate(getFirstLastTime($selected_year, $selected_month));
         $last_day = displayDate(getFirstLastTime($selected_year, $selected_month, 1));
         $this->data['first_day'] = $first_day;
         $this->data['last_day'] = $last_day;
         $this->data['message'] = $this->session->flashdata('message');
         $this->data['page_path_name'] = 'merchant/analysis_report';
         $this->load->view('template/index', $this->data);
     } else {
         redirect('/', 'refresh');
     }
 }
Example #5
0
 function analysis_report_user($search_month = NULL, $search_year = NULL)
 {
     $message_info = '';
     if (!$this->m_admin->check_is_any_admin(63)) {
         redirect('/', 'refresh');
     }
     if (isset($_POST) && !empty($_POST)) {
         if ($this->input->post('button_action') == "search_history") {
             $search_month = $this->input->post('the_month');
             $search_year = $this->input->post('the_year');
         }
     }
     $year_list = generate_number_option(2015, get_part_of_date('year'));
     $this->data['year_list'] = $year_list;
     $this->data['the_year'] = array('name' => 'the_year', 'id' => 'the_year');
     $selected_year = empty($search_year) ? get_part_of_date('year') : $search_year;
     $this->data['the_year_selected'] = $selected_year;
     $month_list = $this->m_custom->month_group_list();
     $this->data['month_list'] = $month_list;
     $this->data['the_month'] = array('name' => 'the_month', 'id' => 'the_month');
     $selected_month = empty($search_month) ? get_part_of_date('month') : $search_month;
     $this->data['the_month_selected'] = $selected_month;
     $first_day = displayDate(getFirstLastTime($selected_year, $selected_month));
     $last_day = displayDate(getFirstLastTime($selected_year, $selected_month, 1));
     $this->data['first_day'] = $first_day;
     $this->data['last_day'] = $last_day;
     $this->data['message'] = $this->session->flashdata('message');
     $this->data['page_path_name'] = 'admin/analysis_report_user';
     $this->load->view('template/index', $this->data);
 }
Example #6
0
 function displayLastDay($year = '', $month = '', $until_today = 0)
 {
     if (empty($month)) {
         $month = date('m');
     }
     if (empty($year)) {
         $year = date('Y');
     }
     $add_argument = '+1 month';
     if ($until_today == 1 && $month == date('m') && $year == date('Y')) {
         $add_argument = "+" . get_part_of_date('day') . " day";
     }
     $result = strtotime("{$year}-{$month}-01");
     $result = strtotime('-1 second', strtotime($add_argument, $result));
     return date('d-m-Y', $result);
 }