Beispiel #1
0
 public function merchant_check_balance($merchant_id, $exclude_this_month = 0, $search_year_month = NULL)
 {
     $this->m_merchant->merchant_balance_update($merchant_id);
     if ($exclude_this_month == 0) {
         $history_query = $this->db->get_where('merchant_balance', array('merchant_id' => $merchant_id));
     } else {
         //            $current_month = ltrim(get_part_of_date('month'), '0');
         //            $current_year = get_part_of_date('year');
         //            $condition = "(month_id !=" . $current_month . " or year !=" . $current_year . ")";
         $search_date = $search_year_month == NULL ? date_for_db_search() : $search_year_month;
         $condition = "month_last_date <= '" . $search_date . "'";
         $this->db->where($condition);
         $history_query = $this->db->get_where('merchant_balance', array('merchant_id' => $merchant_id));
     }
     $current_balance = 0;
     $history_result = $history_query->result_array();
     foreach ($history_result as $history_row) {
         $current_balance += $history_row['balance'];
     }
     return number_format($current_balance, 2);
 }
Beispiel #2
0
 function balance_page()
 {
     if (check_correct_login_type($this->main_group_id)) {
         if (isset($_POST) && !empty($_POST)) {
             if ($this->input->post('button_action') == "search_history") {
                 $search_month = $this->input->post('the_month');
             }
         }
         $month_list = limited_month_select(5, 1);
         $this->data['month_list'] = $month_list;
         $this->data['the_month'] = array('name' => 'the_month', 'id' => 'the_month');
         $selected_month = empty($search_month) ? date_for_db_search() : $search_month;
         $this->data['the_month_selected'] = $selected_month;
         $selected_month_text = $this->m_custom->explode_year_month($selected_month);
         $this->data['the_month_selected_text'] = $selected_month_text['month_year_text'];
         $month_last_date = $selected_month_text['month_last_date'];
         $this->data['previous_month_selected_text'] = $this->m_custom->explode_year_month(month_previous($month_last_date, 1));
         $user_id = $this->ion_auth->user()->row()->id;
         $this->m_user->user_balance_update($user_id);
         $this->data['previous_end_month_balance'] = $this->m_user->user_check_balance($user_id, 1, month_previous($month_last_date));
         $this->data['end_month_balance'] = $this->m_user->user_check_balance($user_id, 1, $month_last_date);
         $this->data['current_balance'] = $this->m_user->user_check_balance($user_id, 0, $month_last_date);
         $this->data['this_month_transaction'] = $this->m_user->user_this_month_transaction($user_id, $selected_month);
         $this_month_transaction_user_balance_23 = $this->m_user->get_transaction_extra($user_id, 23, $selected_month);
         $this_month_transaction_user_balance_26 = $this->m_user->get_transaction_extra($user_id, 26, $selected_month);
         $this->data['this_month_transaction_user_balance'] = array_merge($this_month_transaction_user_balance_23, $this_month_transaction_user_balance_26);
         $this->data['message'] = $this->session->flashdata('message');
         $this->data['page_path_name'] = 'user/balance_page';
         $this->load->view('template/index', $this->data);
     } else {
         redirect('/', 'refresh');
     }
 }
Beispiel #3
0
 public function check_is_new_user($user_id, $month_id = NULL, $year = NULL)
 {
     $the_user = $this->getUser($user_id);
     $created_on = date($this->config->item('keppo_format_date_time_db'), $the_user['created_on']);
     $search_date = date_for_db_search($month_id, $year);
     if (strpos($created_on, $search_date) !== false) {
         //return $created_on . " is new";
         return TRUE;
     } else {
         //return $created_on . " is old";
         return FALSE;
     }
 }