public function index($main_category_id = 0) { //QUERY MAIN CATEGORY $data['query_main_category'] = $this->albert_model->read_main_category(); //QUERY MERCHANT $where_read_merchant = array('me_category_id' => $main_category_id); $data['query_merchant'] = $this->albert_model->read_merchant($where_read_merchant); //QUERY BANNER $banner_where_position_1 = array('category_id' => $main_category_id, 'banner_position' => 1); $data['query_banner_position_1'] = $this->albert_model->read_banner($banner_where_position_1); $banner_where_position_2 = array('category_id' => $main_category_id, 'banner_position' => 2); $data['query_banner_position_2'] = $this->albert_model->read_banner($banner_where_position_2); $banner_where_position_3 = array('category_id' => $main_category_id, 'banner_position' => 3); $data['query_banner_position_3'] = $this->albert_model->read_banner($banner_where_position_3); $banner_where_position_4 = array('category_id' => $main_category_id, 'banner_position' => 4); $data['query_banner_position_4'] = $this->albert_model->read_banner($banner_where_position_4); $banner_where_position_5 = array('category_id' => $main_category_id, 'banner_position' => 5); $data['query_banner_position_5'] = $this->albert_model->read_banner($banner_where_position_5); $banner_where_position_6 = array('category_id' => $main_category_id, 'banner_position' => 6); $data['query_banner_position_6'] = $this->albert_model->read_banner($banner_where_position_6); $banner_where_position_7 = array('category_id' => $main_category_id, 'banner_position' => 7); $data['query_banner_position_7'] = $this->albert_model->read_banner($banner_where_position_7); $banner_where_position_8 = array('category_id' => $main_category_id, 'banner_position' => 8); $data['query_banner_position_8'] = $this->albert_model->read_banner($banner_where_position_8); $data['main_category_id'] = $main_category_id; //TEMPLATE $data['page_path_name'] = 'home'; $meta = array(array('property' => 'og:type', 'content' => 'article'), array('property' => 'og:image', 'content' => base_url('image/logo-keppo-fb.png'))); $data['meta_fb'] = meta_fb($meta); $this->load->view('template/index_home', $data); }
function create_user() { $controller = $this->uri->segment(2); $function_use_for = 'user/create_user'; if ($controller == 'create_user') { $this->data['title'] = "Create User"; if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) { redirect('user', 'refresh'); } } else { $this->data['title'] = "User Sign Up"; $function_use_for = 'user/register'; } $this->data['function_use_for'] = $function_use_for; $this->load->library('user_agent'); $hide_fb = 0; if ($this->agent->is_mobile('android') && $this->agent->is_browser('Chrome')) { $hide_fb = 1; } $this->data['hide_fb'] = $hide_fb; $tables = $this->config->item('tables', 'ion_auth'); if (isset($_POST) && !empty($_POST)) { $this->d_year = $_POST['year']; $this->d_month = $_POST['month']; $this->d_day = $_POST['day']; $_POST['dob'] = $this->d_year . '-' . $this->d_month . '-' . $this->d_day; } // validate form input $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required'); $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label')); //$this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'required|valid_contact_number'); $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'required'); $this->form_validation->set_rules('dob', $this->lang->line('create_user_validation_dob_label'), 'callback_date_check'); $this->form_validation->set_rules('gender_id', $this->lang->line('create_user_validation_gender_label'), 'callback_check_gender_id'); $this->form_validation->set_rules('race_id', $this->lang->line('create_user_validation_race_label'), 'callback_check_race_id'); $this->form_validation->set_rules('race_other', $this->lang->line('create_user_race_other_label')); $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'trim|required|valid_email|is_unique[' . $tables['users'] . '.email]'); $this->form_validation->set_rules('username', $this->lang->line('create_user_validation_username_label'), 'trim|required|is_unique[' . $tables['users'] . '.username]'); if ($this->strong_password == 1) { $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|matches[password_confirm]|min_length[8]|callback_password_check'); } else { $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); } $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); $this->form_validation->set_rules('promo_code', $this->lang->line('create_user_promo_code_label2')); $this->form_validation->set_rules('accept_terms', '...', 'callback_accept_terms'); if ($this->form_validation->run() == true) { $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); //$phone = '+60'.$this->input->post('phone'); $phone = $this->input->post('phone'); $username = strtolower($this->input->post('username')); $email = strtolower($this->input->post('email')); $password = $this->input->post('password'); $race_other = $this->input->post('race_other'); $additional_data = array('first_name' => $first_name, 'last_name' => $last_name, 'phone' => $phone, 'us_birthday' => $this->input->post('dob'), 'us_age' => age_count($this->input->post('dob')), 'us_gender_id' => $this->input->post('gender_id'), 'us_race_id' => $this->input->post('race_id'), 'us_race_other' => $race_other, 'username' => $username, 'password_visible' => $password, 'main_group_id' => $this->main_group_id, 'us_promo_code_temp' => $this->input->post('promo_code')); } $group_ids = array($this->main_group_id); if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data, $group_ids)) { $this->session->set_flashdata('message', $this->ion_auth->messages()); $get_status = send_mail_simple($email, 'Your Keppo User Account Success Created', 'Name : ' . $first_name . ' ' . $last_name . '<br/>Contact Number : ' . $phone . '<br/>Username : '******'<br/>E-mail : ' . $email . '<br/>Password : '******'create_user_send_email_success'); if ($get_status) { redirect("user/login", 'refresh'); } else { $this->session->set_flashdata('message', $this->ion_auth->errors()); redirect("user/register", 'refresh'); } } else { $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')); $this->data['username'] = array('name' => 'username', 'id' => 'username', 'type' => 'text', 'value' => $this->form_validation->set_value('username')); $this->data['first_name'] = array('name' => 'first_name', 'id' => 'first_name', 'type' => 'text', 'value' => $this->form_validation->set_value('first_name')); $this->data['last_name'] = array('name' => 'last_name', 'id' => 'last_name', 'type' => 'text', 'value' => $this->form_validation->set_value('last_name')); $this->data['email'] = array('name' => 'email', 'id' => 'email', 'type' => 'text', 'value' => $this->form_validation->set_value('email')); $this->data['day_list'] = generate_number_option(1, 31); $this->data['day'] = array('name' => 'day', 'id' => 'day'); $this->data['month_list'] = $this->ion_auth->get_static_option_list('month'); $this->data['month'] = array('name' => 'month', 'id' => 'month'); $this->data['year_list'] = generate_number_option(1930, 2010); $this->data['year'] = array('name' => 'year', 'id' => 'year'); //$this->data['gender_list'] = $this->ion_auth->get_static_option_list('gender'); $this->data['gender_list'] = $this->m_custom->get_static_option_array('gender', '0', 'Please Select'); $this->data['gender_id'] = array('name' => 'gender_id', 'id' => 'gender_id', 'value' => $this->form_validation->set_value('gender_id')); //$this->data['race_list'] = $this->ion_auth->get_static_option_list('race'); $this->data['race_list'] = $this->m_custom->get_static_option_array('race', '0', 'Please Select'); $this->data['race_id'] = array('name' => 'race_id', 'id' => 'race_id', 'onchange' => 'showraceother()', 'value' => $this->form_validation->set_value('race_id')); $this->data['race_other'] = array('name' => 'race_other', 'id' => 'race_other', 'type' => 'text', 'style' => 'display:none', 'value' => $this->form_validation->set_value('race_other')); $this->data['phone'] = array('name' => 'phone', 'id' => 'phone', 'type' => 'text', 'value' => $this->form_validation->set_value('phone'), 'class' => 'phone_blur'); $this->data['password'] = array('name' => 'password', 'id' => 'password', 'type' => 'password', 'placeholder' => $this->config->item('password_example'), 'value' => $this->form_validation->set_value('password')); $this->data['password_confirm'] = array('name' => 'password_confirm', 'id' => 'password_confirm', 'type' => 'password', 'placeholder' => $this->config->item('password_example'), 'value' => $this->form_validation->set_value('password_confirm')); $this->data['promo_code'] = array('name' => 'promo_code', 'id' => 'promo_code', 'type' => 'text', 'value' => $this->form_validation->set_value('promo_code')); $meta = array(array('property' => 'og:type', 'content' => 'article'), array('property' => 'og:image', 'content' => base_url('image/logo-keppo-fb.png'))); $this->data['meta_fb'] = meta_fb($meta); $this->data['page_path_name'] = 'user/create_user'; $this->load->view('template/layout', $this->data); } }
function create_user() { $controller = $this->uri->segment(2); $function_use_for = 'merchant/create_user'; if ($controller == 'create_user') { $this->data['title'] = "Create Merchant"; if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) { redirect('merchant', 'refresh'); } } else { $this->data['title'] = "Merchant Sign Up"; $function_use_for = 'merchant/register'; } $this->data['function_use_for'] = $function_use_for; $tables = $this->config->item('tables', 'ion_auth'); if (isset($_POST) && !empty($_POST)) { $_POST['slug'] = generate_slug($_POST['company']); $slug = $_POST['slug']; } // validate form input $this->form_validation->set_rules('accept_terms', '...', 'callback_accept_terms'); $this->form_validation->set_rules('company_main', $this->lang->line('create_merchant_validation_company_main_label'), "trim|required|min_length[3]"); $this->form_validation->set_rules('me_ssm', $this->lang->line('create_merchant_validation_companyssm_label'), 'required'); $this->form_validation->set_rules('company', $this->lang->line('create_merchant_validation_company_label'), "trim|required|min_length[3]"); $this->form_validation->set_rules('slug', $this->lang->line('create_merchant_validation_company_label'), 'trim|is_unique[' . $tables['users'] . '.slug]'); $this->form_validation->set_rules('address', $this->lang->line('create_merchant_validation_address_label'), 'required'); $this->form_validation->set_rules('postcode', $this->lang->line('create_merchant_validation_postcode_label'), 'required|numeric'); $this->form_validation->set_rules('me_state_id', $this->lang->line('create_merchant_validation_state_label'), 'callback_check_state_id'); $this->form_validation->set_rules('me_country', $this->lang->line('create_merchant_validation_country_label'), 'required'); $this->form_validation->set_rules('me_category_id', $this->lang->line('create_merchant_category_label'), 'callback_check_main_category'); $this->form_validation->set_rules('me_sub_category_id', $this->lang->line('create_merchant_sub_category_label'), 'callback_check_sub_category'); //$this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label'), 'required|valid_contact_number'); $this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label')); $this->form_validation->set_rules('username', $this->lang->line('create_merchant_validation_username_label'), 'trim|required|is_unique[' . $tables['users'] . '.username]'); $this->form_validation->set_rules('email', $this->lang->line('create_merchant_validation_email_label'), 'trim|required|valid_email|is_unique[' . $tables['users'] . '.email]'); if ($this->strong_password == 1) { $this->form_validation->set_rules('password', $this->lang->line('create_merchant_validation_password_label'), 'required|matches[password_confirm]|min_length[8]|callback_password_check'); } else { $this->form_validation->set_rules('password', $this->lang->line('create_merchant_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); } $this->form_validation->set_rules('password_confirm', $this->lang->line('create_merchant_validation_password_confirm_label'), 'required'); if ($this->form_validation->run() == true) { //$username = strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name')); $username = strtolower($this->input->post('username')); $email = strtolower($this->input->post('email')); $password = $this->input->post('password'); $company_main = $this->input->post('company_main'); $company = $this->input->post('company'); $me_ssm = $this->input->post('me_ssm'); $address = $this->input->post('address'); $postcode = $this->input->post('postcode'); $state = $this->input->post('me_state_id'); $country = $this->input->post('me_country'); //$phone = '+60' . $this->input->post('phone'); $phone = $this->input->post('phone'); //$me_is_halal = $this->input->post('me_is_halal') == NULL ? 0 : 1; $me_halal_way = $this->input->post('me_halal_way'); $additional_data = array('username' => $username, 'company_main' => $company_main, 'company' => $company, 'slug' => $slug, 'address' => $address, 'postcode' => $postcode, 'country' => $country, 'me_state_id' => $state, 'me_category_id' => $this->input->post('me_category_id'), 'me_sub_category_id' => $this->input->post('me_sub_category_id'), 'phone' => $phone, 'me_ssm' => $me_ssm, 'main_group_id' => $this->main_group_id, 'password_visible' => $password, 'me_halal_way' => $me_halal_way); } $group_ids = array($this->main_group_id); if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data, $group_ids)) { $this->session->set_flashdata('message', $this->ion_auth->messages()); $get_status = send_mail_simple($email, 'Keppo Merchant Account Success Created', 'Company Name : ' . $company_main . '<br/>Register No(SSM) : ' . $me_ssm . '<br/>Shop Name : ' . $company . '<br/>Company Address : ' . $address . '<br/>Contact Number : ' . $phone . '<br/>Username : '******'<br/>E-mail : ' . $email . '<br/>Password : '******'create_user_send_email_success', 1, 1); if ($get_status) { redirect("merchant/login", 'refresh'); } else { $this->session->set_flashdata('message', $this->ion_auth->errors()); redirect("merchant/register", 'refresh'); } } else { $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')); $this->data['username'] = array('name' => 'username', 'id' => 'username', 'type' => 'text', 'value' => $this->form_validation->set_value('username')); $this->data['email'] = array('name' => 'email', 'id' => 'email', 'type' => 'text', 'value' => $this->form_validation->set_value('email')); $this->data['company_main'] = array('name' => 'company_main', 'id' => 'company_main', 'type' => 'text', 'value' => $this->form_validation->set_value('company_main')); $this->data['company'] = array('name' => 'company', 'id' => 'company', 'type' => 'text', 'value' => $this->form_validation->set_value('company')); $this->data['address'] = array('name' => 'address', 'id' => 'address', 'value' => $this->form_validation->set_value('address')); $this->data['postcode'] = array('name' => 'postcode', 'id' => 'postcode', 'type' => 'text', 'value' => $this->form_validation->set_value('postcode')); $this->data['state_list'] = $this->m_custom->get_static_option_array('state', '0', 'Please Select'); $this->data['me_state_id'] = array('name' => 'me_state_id', 'id' => 'me_state_id', 'value' => $this->form_validation->set_value('me_state_id')); $this->data['country_list'] = array('Malaysia' => 'Malaysia'); $this->data['me_country'] = array('name' => 'me_country', 'id' => 'me_country', 'value' => $this->form_validation->set_value('me_country')); $me_category_id = $this->form_validation->set_value('me_category_id') == '' ? '' : $this->form_validation->set_value('me_category_id'); $this->data['category_list'] = $this->m_custom->getCategoryList('0', 'Please Select'); $this->data['me_category_id'] = array('name' => 'me_category_id', 'id' => 'me_category_id', 'value' => $me_category_id, 'onChange' => "get_SubCategory()"); $this->data['sub_category_list'] = $this->m_custom->getSubCategoryList(NULL, NULL, $me_category_id); $this->data['me_sub_category_id'] = array('name' => 'me_sub_category_id', 'id' => 'me_sub_category_id', 'value' => $this->form_validation->set_value('me_sub_category_id')); $this->data['phone'] = array('name' => 'phone', 'id' => 'phone', 'type' => 'text', 'value' => $this->form_validation->set_value('phone'), 'class' => 'phone_blur'); $this->data['me_ssm'] = array('name' => 'me_ssm', 'id' => 'me_ssm', 'type' => 'text', 'value' => $this->form_validation->set_value('me_ssm')); $this->data['password'] = array('name' => 'password', 'id' => 'password', 'type' => 'password', 'placeholder' => $this->config->item('password_example'), 'value' => $this->form_validation->set_value('password')); $this->data['password_confirm'] = array('name' => 'password_confirm', 'id' => 'password_confirm', 'type' => 'password', 'placeholder' => $this->config->item('password_example'), 'value' => $this->form_validation->set_value('password_confirm')); // $this->data['me_is_halal'] = array( // 'name' => 'me_is_halal', // 'id' => 'me_is_halal', // 'value' => '1', //Just to have some value, checkbox have to have value // ); $this->data['halal_way_list'] = $this->ion_auth->get_static_option_list('halal_way'); $this->data['me_halal_way'] = array('name' => 'me_halal_way', 'id' => 'me_halal_way'); $meta = array(array('property' => 'og:type', 'content' => 'article'), array('property' => 'og:image', 'content' => base_url('image/logo-keppo-fb.png'))); $this->data['meta_fb'] = meta_fb($meta); $this->data['page_path_name'] = 'merchant/create_user'; $this->load->view('template/layout', $this->data); } }
public function merchant_dashboard($slug = NULL, $bottom_part = NULL, $user_id = NULL) { $the_row = FALSE; if ($user_id != NULL) { $the_row = $this->m_custom->get_one_table_record('users', 'id', $user_id, 0, 0, 'main_group_id', $this->group_id_merchant, 1); } if (!$the_row) { $the_row = $this->m_custom->get_one_table_record('users', 'id', $bottom_part, 0, 0, 'main_group_id', $this->group_id_merchant, 1); } if (!$the_row) { $the_row = $this->m_custom->get_one_table_record('users', 'id', $slug, 0, 0, 'main_group_id', $this->group_id_merchant, 1); } if (!$the_row) { $the_row = $this->m_custom->get_one_table_record('users', 'slug', $slug, 0, 0, 'main_group_id', $this->group_id_merchant, 1); } if ($the_row) { $user_id = $the_row->id; $this->data['image_path'] = $this->album_merchant_profile; $this->data['image'] = $the_row->profile_image; $this->data['company_name'] = $the_row->company; $this->data['browser_title'] = $the_row->company; $this->data['address'] = $the_row->address; $this->data['description'] = $the_row->description; $this->data['phone'] = $the_row->phone; $this->data['show_outlet'] = base_url() . 'all/merchant_outlet/' . $slug . '/' . $user_id; $this->data['website_url'] = $the_row->me_website_url; $this->data['facebook_url'] = $the_row->me_facebook_url; //$this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); $this->data['message'] = NULL; $this->data['page_path_name'] = 'merchant/dashboard'; $this->data['hot_deal'] = base_url() . 'all/merchant-dashboard/' . $slug . '//' . $user_id . '#dashboard-navigation'; $this->data['candie_promotion'] = base_url() . 'all/merchant-dashboard/' . $slug . '/promotion/' . $user_id . '#dashboard-navigation'; $this->data['user_picture'] = base_url() . 'all/merchant-dashboard/' . $slug . '/picture/' . $user_id . '#dashboard-navigation'; $this->data['user_upload_for_merchant'] = base_url() . 'user/upload_for_merchant/' . $user_id; $this->data['show_expired'] = "<a href='" . base_url() . "all/album_merchant/'. {$slug}>Show Expired</a><br/>"; $this->data['user_id'] = $user_id; //$this->data['me_is_halal'] = $the_row->me_is_halal; $this->data['me_halal_way'] = $the_row->me_halal_way; // $me_is_halal = $the_row->me_is_halal; // $this->data['checkbox_halal'] = array( // 'name' => 'checkbox_halal', // 'id' => 'checkbox_halal', // 'checked' => $me_is_halal == "1" ? TRUE : FALSE, // 'value' => $the_row->me_is_halal, // ); //FOLLOWER or FOLLOWING COUNT $this->data['follower_count'] = $this->albert_model->follower_count($user_id); $this->data['following_count'] = $this->albert_model->following_count($user_id); $this->data['temp_folder'] = $this->temp_folder; $meta = array(array('property' => 'og:type', 'content' => 'article'), array('property' => 'og:title', 'content' => $the_row->company), array('property' => 'og:description', 'content' => limit_character($the_row->address, 150)), array('property' => 'og:image', 'content' => base_url() . $this->album_merchant_profile . $the_row->profile_image)); $this->data['meta_fb'] = meta_fb($meta); if ($bottom_part == 'promotion') { $this->data['hotdeal_list'] = $this->m_custom->getAdvertise('pro', NULL, $user_id, 1, NULL, NULL, 0, 0, 0, 0, 1); $this->data['title'] = "Redemption"; $this->data['bottom_path_name'] = 'share/redemption_grid_list5_old'; //ADVERTISE SUGGESTION $where_user = array('id' => $user_id); $main_category_id = $this->albert_model->read_user($where_user)->row()->me_category_id; $where_read_category2 = array('main_category_id' => $main_category_id); $result_array_sub_category_id = $this->albert_model->read_category($where_read_category2)->result_array(); $array_sub_category_id = array_column($result_array_sub_category_id, 'category_id'); $this->data['query_advertise_suggestion'] = $this->albert_model->read_advertise_redemption_suggestion($array_sub_category_id)->result_array(); $this->data['advertise_suggestion_page_path_name'] = 'all/hot_deal_list_suggestion'; $this->data['advertise_suggestion_page_title'] = 'Redemption Suggestion'; } else { if ($bottom_part == 'picture') { $this->data['album_list'] = $this->m_custom->getAlbumUserMerchant(NULL, $user_id); $this->data['title'] = "User's Pictures"; $this->data['bottom_path_name'] = 'all/album_user_merchant'; } else { $this->data['hotdeal_list'] = $this->m_custom->getAdvertise('hot', NULL, $user_id, 1, NULL, NULL, 0, 0, 0, 0, 1); $this->data['title'] = "Food & Beverage"; $this->data['bottom_path_name'] = 'share/hot_deal_grid_list5_old'; //ADVERTISE SUGGESTION $where_user = array('id' => $user_id); $main_category_id = $this->albert_model->read_user($where_user)->row()->me_category_id; $where_read_category2 = array('main_category_id' => $main_category_id); $result_array_sub_category_id = $this->albert_model->read_category($where_read_category2)->result_array(); $array_sub_category_id = array_column($result_array_sub_category_id, 'category_id'); $this->data['query_advertise_suggestion'] = $this->albert_model->read_advertise_hot_deal_suggestion($array_sub_category_id)->result_array(); $this->data['advertise_suggestion_page_path_name'] = 'all/hot_deal_list_suggestion'; $this->data['advertise_suggestion_page_title'] = 'Food & Beverage Suggestion'; } } $this->data['message'] = $this->session->flashdata('message'); $this->load->view('template/index_background_blank', $this->data); } else { redirect('/', 'refresh'); } }