function main_album_change($edit_id = NULL) { if (!check_correct_login_type($this->main_group_id)) { redirect('/', 'refresh'); } $message_info = ''; $login_id = $this->ion_auth->user()->row()->id; $login_type = $this->session->userdata('user_group_id'); $is_edit = 0; $main_table = 'main_album'; $main_table_id_column = 'album_id'; $main_table_filter_column = 'user_id'; $main_table_fiter_value = $login_id; if ($edit_id != NULL) { $allowed_list = $this->m_custom->get_list_of_allow_id($main_table, $main_table_filter_column, $main_table_fiter_value, $main_table_id_column); if (!check_allowed_list($allowed_list, $edit_id)) { redirect('/', 'refresh'); } $is_edit = 1; } if (isset($_POST) && !empty($_POST)) { $can_redirect_to = 0; $edit_id = $this->input->post('edit_id'); $album_title = $this->input->post('album_title'); // validate form input $this->form_validation->set_rules('album_title', $this->lang->line('main_album_title_label'), 'required'); if ($edit_id == 0) { $is_edit = 0; } else { $is_edit = 1; } if ($this->input->post('button_action') == "save") { if ($this->form_validation->run() === TRUE) { if ($is_edit == 0) { $data = array('album_title' => $album_title, 'user_id' => $login_id, 'user_type' => $login_type); $new_id = $this->m_custom->get_id_after_insert($main_table, $data); if ($new_id) { $message_info = add_message_info($message_info, $album_title . ' success create.'); $edit_id = $new_id; $can_redirect_to = 2; } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); $can_redirect_to = 1; } } else { $data = array('album_title' => $album_title); if ($this->m_custom->simple_update($main_table, $data, $main_table_id_column, $edit_id)) { $message_info = add_message_info($message_info, $album_title . ' success update.'); $can_redirect_to = 2; } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); $can_redirect_to = 3; } } } } if ($this->input->post('button_action') == "back") { $can_redirect_to = 2; } if ($this->input->post('button_action') == "remove_real") { $message_info = add_message_info($message_info, $album_title . ' success remove. All image in this album also removed.'); $this->m_custom->update_hide_flag(1, $main_table, $edit_id); $can_redirect_to = 2; } direct_go: if ($message_info != NULL) { $this->session->set_flashdata('message', $message_info); } if ($can_redirect_to == 1) { redirect(uri_string(), 'refresh'); } elseif ($can_redirect_to == 2) { redirect('user/main_album/' . $login_id, 'refresh'); } elseif ($can_redirect_to == 3) { redirect('user/main_album_change/' . $edit_id, 'refresh'); } } // set the flash data error message if there is one $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')); $result = $this->m_custom->get_one_table_record($main_table, $main_table_id_column, $edit_id, 1); $this->data['result'] = $result; $this->data['edit_id'] = array('edit_id' => empty($result) ? '0' : $result[$main_table_id_column], 'is_edit' => $is_edit); $this->data['is_edit'] = $is_edit; $this->data['album_title'] = array('name' => 'album_title', 'id' => 'album_title', 'value' => empty($result) ? $this->form_validation->set_value('album_title') : $this->form_validation->set_value('album_title', $result['album_title'])); $this->data['page_path_name'] = 'user/main_album_change'; $this->load->view('template/index_background_blank', $this->data); }
function remove_mua_picture() { if (isset($_POST) && !empty($_POST)) { if ($this->input->post('button_action') == "hide_picture") { $login_id = $this->ion_auth->user()->row()->id; $login_type = $this->session->userdata('user_group_id'); $merchant_id = $login_id; if (check_correct_login_type($this->group_id_supervisor)) { $merchant_id = $this->ion_auth->user()->row()->su_merchant_id; } $picture_id = $this->input->post('hid_picture_id'); $upload_by_user_id = $this->input->post('hid_upload_by_user_id'); $hide_remark = $this->input->post('hide_remark'); $group_id_merchant = $this->config->item('group_id_merchant'); $group_id_supervisor = $this->config->item('group_id_supervisor'); $merchant_allowed_list = $this->m_custom->get_list_of_allow_id('merchant_user_album', 'merchant_id', $merchant_id, 'merchant_user_album_id', 'post_type', 'mer'); if (check_allowed_list($merchant_allowed_list, $picture_id)) { $merchant = $this->m_custom->getMerchantInfo($merchant_id); $data = array('hide_flag' => 1, 'hide_remark' => $hide_remark); if ($this->m_custom->simple_update('merchant_user_album', $data, 'merchant_user_album_id', $picture_id)) { $this->m_custom->remove_row_log('merchant_user_album', $picture_id, $login_id, $login_type); $this->m_merchant->mua_hide($picture_id); //$this->m_user->user_trans_history_insert($upload_by_user_id, 22, $picture_id); //Temporary comment this because user upload image for merchant cannot get cash back already } redirect('all/merchant_dashboard/' . $merchant['slug'] . "/picture/" . $merchant_id, 'refresh'); } } } redirect('/', 'refresh'); }
echo $edit_url; ?> " class="a-href-button">Edit Picture</a> </div> <?php } $group_id_merchant = $this->config->item('group_id_merchant'); $group_id_supervisor = $this->config->item('group_id_supervisor'); if (check_correct_login_type($group_id_merchant) || check_correct_login_type($group_id_supervisor)) { $merchant_id = $login_id; if (check_correct_login_type($group_id_supervisor)) { $merchant_id = $this->ion_auth->user()->row()->su_merchant_id; } $merchant_allowed_list = $this->m_custom->get_list_of_allow_id('merchant_user_album', 'merchant_id', $merchant_id, 'merchant_user_album_id', 'post_type', 'mer'); $hide_url = base_url() . "merchant/remove_mua_picture/" . $picture_id; if (check_allowed_list($merchant_allowed_list, $picture_id)) { ?> <button type="submit" data-toggle = "modal" data-target = "#myModal_Remove" style="float:right">Remove Picture</button> <div class="modal fade" id="myModal_Remove" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="bootstrap-close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class ="modal-title" id="myModalLabel"> Why Need To Remove? </h4> </div> <div class="modal-body"> <?php $action_url = base_url() . "merchant/remove_mua_picture"; $confirm_message = "Confirm that you want to remove this picture that user upload for your company? ";
function manage_merchant_fee_change($edit_id = NULL) { if (!$this->m_admin->check_is_any_admin(76)) { redirect('/', 'refresh'); } $message_info = ''; $login_id = $this->login_id; $login_type = $this->login_type; $is_edit = 0; $main_table = 'dynamic_option'; $main_table_id_column = 'option_id'; $main_table_filter_column = 'option_type'; $main_table_fiter_value = 'merchant_fee'; if ($edit_id != NULL) { $allowed_list = $this->m_custom->get_list_of_allow_id($main_table, $main_table_filter_column, $main_table_fiter_value, $main_table_id_column); if (!check_allowed_list($allowed_list, $edit_id)) { redirect('/', 'refresh'); } $is_edit = 1; } if (isset($_POST) && !empty($_POST)) { $can_redirect_to = 0; $edit_id = $this->input->post('edit_id'); $option_desc = $this->input->post('option_desc'); $option_value = check_is_positive_decimal($this->input->post('option_value')); // validate form input $this->form_validation->set_rules('option_desc', 'Merchant Fee Charge Type Name', 'required'); $this->form_validation->set_rules('option_value', 'Amount (RM)', 'required|numeric'); if ($edit_id == 0) { $is_edit = 0; } else { $is_edit = 1; } if ($this->input->post('button_action') == "save") { if ($this->form_validation->run() === TRUE) { if ($is_edit == 0) { $data = array('option_desc' => $option_desc, 'option_value' => $option_value, 'option_type' => $main_table_fiter_value); $new_id = $this->m_custom->get_id_after_insert($main_table, $data); if ($new_id) { $this->m_custom->insert_row_log($main_table, $new_id, $login_id, $login_type); $message_info = add_message_info($message_info, $option_desc . ' success create.'); $edit_id = $new_id; $can_redirect_to = 2; } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); $can_redirect_to = 1; } } else { $data = array('option_desc' => $option_desc, 'option_value' => $option_value); if ($this->m_custom->simple_update($main_table, $data, $main_table_id_column, $edit_id)) { $this->m_custom->update_row_log($main_table, $edit_id, $login_id, $login_type); $message_info = add_message_info($message_info, $option_desc . ' success update.'); $can_redirect_to = 2; } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); $can_redirect_to = 3; } } } } if ($this->input->post('button_action') == "back") { $can_redirect_to = 2; } direct_go: if ($message_info != NULL) { $this->session->set_flashdata('message', $message_info); } if ($can_redirect_to == 1) { redirect(uri_string(), 'refresh'); } elseif ($can_redirect_to == 2) { redirect('admin/manage_merchant_fee', 'refresh'); } elseif ($can_redirect_to == 3) { redirect('admin/manage_merchant_fee_change/' . $edit_id, 'refresh'); } } // set the flash data error message if there is one $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')); $result = $this->m_custom->get_one_table_record($main_table, $main_table_id_column, $edit_id, 1); $this->data['result'] = $result; $this->data['edit_id'] = array('edit_id' => empty($result) ? '0' : $result[$main_table_id_column], 'is_edit' => $is_edit); $this->data['is_edit'] = $is_edit; $this->data['option_desc'] = array('name' => 'option_desc', 'id' => 'option_desc', 'style' => 'width:500px', 'value' => empty($result) ? $this->form_validation->set_value('option_desc') : $this->form_validation->set_value('option_desc', $result['option_desc'])); $this->data['option_value'] = array('name' => 'option_value', 'id' => 'option_value', 'type' => 'text', 'value' => empty($result) ? $this->form_validation->set_value('option_value') : $this->form_validation->set_value('option_value', $result['option_value'])); $this->data['page_path_name'] = 'admin/manage_merchant_fee_change'; $this->load->view('template/index', $this->data); }
public function read_photographer($search, $search_type = NULL) { //QUERY $this->db->select('*'); $this->db->from('users'); $this->db->where('us_is_photographer =', "1"); $this->db->where('remove_flag =', "0"); //SEARCH if ($search) { $this->db->where("concat_ws(' ', first_name, last_name) LIKE", '%' . $search . '%'); $this->db->or_where('us_photography_url LIKE', '%' . $search . '%'); } $this->db->order_by('first_name', 'asc'); $query = $this->db->get(); //TO SEARCH IS THERE ANY USER HAVE THIS PHOTOGRAPHER TYPE if ($search_type) { $query_process = $query->result_array(); $user_have_this_type = array(); foreach ($query_process as $row) { $user_id = $row['id']; $result_type_list = $this->m_custom->get_list_of_allow_id('many_to_many', 'many_parent_id', $user_id, 'many_child_id', 'many_type', 'photography'); if (check_allowed_list($result_type_list, $search_type)) { $user_have_this_type[] = $user_id; } if (!empty($user_have_this_type)) { $this->db->where_in('id', $user_have_this_type); } else { $this->db->where_in('id', '0'); //If don't have any user is belong to this type } //Generate a new query to overwrite previous search result $this->db->select('*'); $this->db->from('users'); $this->db->order_by('first_name', 'asc'); $query = $this->db->get(); } } //RETURN return $query; }