public function getMerchantAnalysisReportRedeem($merchant_id, $status_id, $month_id = NULL, $year = NULL) { $start_time = getFirstLastTime($year, $month_id); $end_time = getFirstLastTime($year, $month_id, 'last'); $condition = "redeem_time >= '" . $start_time . "' AND redeem_time <= '" . $end_time . "'"; $this->db->where($condition); $this->db->select('*'); $this->db->from('user_redemption'); $this->db->join('advertise', 'user_redemption.advertise_id = advertise.advertise_id', 'inner'); $this->db->where(array('advertise.advertise_type' => 'pro', 'advertise.merchant_id' => $merchant_id, 'user_redemption.status_id' => $status_id)); $query = $this->db->get(); return $query->result_array(); }
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'); } }
public function getAdminAnalysisReportUser($the_type, $month_id = NULL, $year = NULL) { $return = array(); $start_time = getFirstLastTime($year, $month_id); $end_time = getFirstLastTime($year, $month_id, 'last'); $start_timestamp = strtotime($start_time); $end_timestamp = strtotime($end_time); $group_id_user = $this->config->item('group_id_user'); $type_list = $this->m_custom->get_static_option_array($the_type, NULL, NULL, 1); $type_list_intial_new = array(); $type_list_intial_old = array(); foreach ($type_list as $row) { $row['option_desc'] = 0; //Use option_desc as a counter, set to 0 $type_list_intial_new[] = $row; $type_list_intial_old[] = $row; } $field_name = ''; switch ($the_type) { case 'gender': $field_name = 'us_gender_id'; break; case 'race': $field_name = 'us_race_id'; break; case 'age_group': $field_name = 'us_age'; break; } $condition = "created_on >= '" . $start_timestamp . "' AND created_on <= '" . $end_timestamp . "'"; $this->db->where($condition); $this->db->select('*'); $this->db->from('users'); $this->db->where(array('main_group_id' => $group_id_user)); $query_new = $this->db->get(); $result_new = $query_new->result_array(); foreach ($result_new as $row) { //echo $row['username'] . " : "; $age_group_min = 0; foreach ($type_list_intial_new as &$row_type) { if ($the_type == 'age_group') { $us_age = $row[$field_name]; $age_group_max = $row_type['option_value']; if ($us_age >= $age_group_min && $us_age < $age_group_max) { $row_type['option_desc']++; //echo $us_age . " , "; } $age_group_min = $row_type['option_value']; } else { if ($row_type['option_id'] == $row[$field_name]) { $row_type['option_desc']++; //echo $row_type['option_value'] . " , "; } } } } //var_dump($type_list_intial_new); $condition = "created_on < '" . $start_timestamp . "'"; $this->db->where($condition); $this->db->select('*'); $this->db->from('users'); $this->db->where(array('main_group_id' => $group_id_user)); $query_old = $this->db->get(); $result_old = $query_old->result_array(); foreach ($result_old as $row) { //echo $row['username'] . " : "; $age_group_min = 0; foreach ($type_list_intial_old as &$row_type) { if ($the_type == 'age_group') { $us_age = $row[$field_name]; $age_group_max = $row_type['option_value']; if ($us_age >= $age_group_min && $us_age < $age_group_max) { $row_type['option_desc']++; //echo $us_age . " , "; } $age_group_min = $row_type['option_value']; } else { if ($row_type['option_id'] == $row[$field_name]) { $row_type['option_desc']++; //echo $row_type['option_value'] . " , "; } } } } //var_dump($type_list_intial_old); $return['new_list'] = $type_list_intial_new; $return['old_list'] = $type_list_intial_old; return $return; }
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); }