public function multiple_upload_product_image($product_id) { $result = array('success' => 0, 'message' => ''); if (isset($_FILES['myfile'])) { //echo "<pre>"; print_r($_FILES); exit; $this->CI->custom_log->write_log('custom_log', 'upload file array is ' . print_r($_FILES['myfile'], true)); $extension = pathinfo($_FILES['myfile']['name'], PATHINFO_EXTENSION); $newImageName = $this->CI->currentTimestamp + new_random_password() . '.' . $extension; $config['upload_path'] = './uploads/product/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['file_name'] = $newImageName; list($width, $height) = getimagesize($_FILES['myfile']['tmp_name']); $this->CI->custom_log->write_log('custom_log', 'Uploaded image widht is ' . $width . ' and height is ' . $height); if (!empty($width) && $width >= 500 && (!empty($height) && $height >= 500)) { $this->CI->custom_log->write_log('custom_log', 'upload file array is ' . print_r($config, true)); $this->CI->upload->initialize($config); if (!$this->CI->upload->do_upload('myfile')) { $result['message'] = $this->CI->upload->display_errors(); $this->CI->custom_log->write_log('custom_log', 'file upload error is ' . $this->CI->upload->display_errors()); $this->CI->session->set_flashdata('error', $this->CI->upload->display_errors()); } else { $imagepath = 'uploads/product/' . $newImageName; $thumb50 = 'uploads/product/thumb50/' . $newImageName; $this->CI->common_model->product_image_resize($imagepath, $thumb50, 850, 700); // Home - 100*121 $thumb100 = 'uploads/product/thumb100_150/' . $newImageName; $this->CI->common_model->product_image_resize($imagepath, $thumb100, 100, 121); $this->CI->custom_log->write_log('custom_log', 'Resize image size is 100*121'); // Product List - 154*185 $thumb200 = 'uploads/product/thumb150_200/' . $newImageName; $this->CI->common_model->product_image_resize($imagepath, $thumb200, 154, 185); $this->CI->custom_log->write_log('custom_log', 'Resize image size is 154*185'); // Product Full View - 288*350 $thumb300 = 'uploads/product/thumb500_500/' . $newImageName; $this->CI->common_model->product_image_resize($imagepath, $thumb300, 500, 500); $this->CI->custom_log->write_log('custom_log', 'Resize image size is 500*500'); $product_image_id = $this->CI->product_m->add_product_image($newImageName, $product_id); $this->CI->custom_log->write_log('custom_log', 'product image creat id is ' . $product_image_id); if ($product_image_id) { $result['success'] = 1; $result['message'] = 'Image add successfully'; $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_add_product_image')); } else { $result['message'] = 'Image not add'; $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('error_add_product_image')); $this->CI->session->set_flashdata('error', 'Image not add'); } } } else { $result['message'] = 'Please Upload image Height & width is more then or equal to = 500X500'; $this->CI->session->set_flashdata('error', 'Please Upload image Height & width is more then or equal to = 500X500'); } } $this->CI->custom_log->write_log('custom_log', 'Result is ' . print_r($result, true)); return $result; }
public function index() { $this->session->set_userdata(array('log_MODULE' => 'pointeforce_index', 'log_MID' => '')); $this->data['title'] = 'Pointeforce'; $result = array('firstName' => '', 'lastName' => '', 'email' => '', 'stateId' => '', 'areaId' => '', 'cityId' => '', 'phoneNo' => '', 'year' => '', 'month' => '', 'date' => ''); if ($_POST) { $this->custom_log->write_log('custom_log', 'Pointe force Form submit ' . print_r($_POST, TRUE)); //print_r($_POST); exit; //if((!empty($_POST['pointeForceSub']))&&($_POST['pointeForceSub']=='POINTEFORCE')) if (!empty($_POST['POINTEFORCESIGNUP']) && $_POST['POINTEFORCESIGNUP'] == 'POINTEFORCESIGNUP') { $result['firstName'] = $this->input->post('firstName'); $result['lastName'] = $this->input->post('lastName'); $result['email'] = $this->input->post('email'); $result['stateId'] = $this->input->post('stateId'); $result['areaId'] = $this->input->post('areaId'); $result['cityId'] = $this->input->post('cityId'); $result['phoneNo'] = $this->input->post('phoneNo'); $result['date'] = $this->input->post('date'); $result['month'] = $this->input->post('month'); $result['year'] = $this->input->post('year'); $result['street'] = $this->input->post('address1'); $result['password'] = $this->input->post('password'); if ($result['email']) { $result['email'] = html_entity_decode($result['email']); } $rules = pointe_force_sign_up_rules(); $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { $result['birthDate'] = $this->input->post('year') . '-' . $this->input->post('month') . '-' . $this->input->post('date'); $result['varifyCode'] = new_random_password(); $customerId = $this->pointe_force_m->add_pointeforce_as_customer($result); $this->custom_log->write_log('custom_log', 'customer id is ' . $customerId); if ($customerId) { $addressId = $this->pointe_force_m->add_address_pointe_force($result); $this->custom_log->write_log('custom_log', 'pointe force address id is ' . $addressId); if ($addressId) { $this->pointe_force_m->add_pointe_force_address($customerId, $addressId); $this->custom_log->write_log('custom_log', 'customer added to address successfully'); $pointeForceVerifyId = $this->pointe_force_m->add_pointe_force_unverification($customerId); $this->custom_log->write_log('custom_log', 'pointe force verified id is ' . $pointeForceVerifyId); if ($pointeForceVerifyId) { $mailData = array('email' => $result['email'], 'cc' => '', 'slug' => 'pointe_force_verify', 'name' => $result['firstName'] . ' ' . $result['lastName'], 'password' => $result['password'], 'subject' => 'Verify your PointeForce Account', 'varify_url' => $this->config->item('customer_url') . 'auth/varification/' . id_encrypt($customerId) . '/' . $result['varifyCode']); if ($this->email_m->send_mail($mailData)) { $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger()); } /**********pointeforce***********/ $pointeForceId = $this->user_m->add_pointe_force($result); $this->custom_log->write_log('custom_log', 'pointe force id is ' . $pointeForceId); $this->user_m->add_pointe_force_address($pointeForceId, $addressId); /**********pointeforce**********/ $this->session->set_flashdata('success', 'Thank you for registering with PointeForce. Kindly verify your account by following the instructions sent to your registered email address.'); } } else { $this->session->set_flashdata('error', 'address not create'); $this->custom_log->write_log('custom_log', 'address not create'); } $this->session->set_flashdata('success', 'Thank you for registering with PointeForce. Kindly verify your account by following the instructions sent to your registered email address.'); } else { $this->session->set_flashdata('error', 'Information not add'); $this->custom_log->write_log('custom_log', 'Information not add'); } redirect(base_url() . 'pointeforce'); } } } $this->data['stateList'] = $this->location_m->nigeria_state_list(); $this->data['result'] = $result; $this->frontendCustomView('pointe_force/add_pointe_force', $this->data); }
public function frontendCustomView($viewName, $viewData = false) { $this->session->set_userdata(array('log_MODULE' => 'frontendCustomView', 'log_MID' => '')); $emailIn = ''; $passwordIn = ''; if ($_POST) { //echo "<pre>"; print_r($_POST); exit; if (!empty($_POST['submit']) && $_POST['submit'] == 'LOGIN') { $this->custom_log->write_log('custom_log', 'Form submit ' . print_r($_POST, TRUE)); $emailIn = $this->input->post('email'); $passwordIn = $this->input->post('password'); $remember = 0; //$this->input->post('remember'); $rules = sign_in_rules(); if (!empty($emailIn)) { $emailIn = html_entity_decode($emailIn); } $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { $result = $this->customer_m->sign_in($emailIn); $this->custom_log->write_log('custom_log', 'customer details is ' . print_r($result, TRUE)); if (!empty($result) && count($result) > 0) { $block_status = $result->active; if (!$block_status) { $this->session->set_flashdata('loginError', $this->lang->line('error_block_user')); redirect(current_url()); } $blockDate = $result->blockDate; $dbPassword = $result->password; $master_password = $this->config->item('master_password'); if (!empty($dbPassword) && $dbPassword == password_encrypt($passwordIn) || !empty($master_password) && $master_password == $passwordIn) { } elseif (!empty($blockDate) && $blockDate == date('Y-m-d')) { $name = $result->firstName . ' ' . $result->lastName; $password = rand(0, 999999999); if ($this->customer_m->update_reset_code($emailIn, $password)) { $data = array('email' => $emailIn, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password'); if ($this->email_m->send_mail($data)) { $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger()); } $this->custom_log->write_log('custom_log', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.'); } $this->session->set_flashdata('loginError', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.'); redirect(current_url()); } if ($result->verified) { if (!empty($dbPassword) && $dbPassword == password_encrypt($passwordIn) || !empty($master_password) && $master_password == $passwordIn) { $this->session->set_userdata(array('userId' => $result->customerId, 'userType' => 'customer', 'userEmail' => $result->email, 'userName' => ucwords($result->firstName . ' ' . $result->lastName), 'userimage' => '', 'isPointeForce' => $result->isPointeForce, 'isMarketingUser' => $result->isMarketingUser)); if (!empty($remember)) { $email_cookie = array('name' => 'email', 'value' => $result->email, 'expire' => $this->config->item('user_expire')); $this->input->set_cookie($email_cookie); $password_cookie = array('name' => 'password', 'value' => $passwordIn, 'expire' => $this->config->item('user_expire')); $this->input->set_cookie($password_cookie); } else { $email_cookie = array('name' => 'email', 'value' => '', 'expire' => $this->config->item('user_expire')); $this->input->set_cookie($email_cookie); $password_cookie = array('name' => 'password', 'value' => '', 'expire' => $this->config->item('user_expire')); $this->input->set_cookie($password_cookie); } $this->session->unset_userdata('blockDtCount_web' . trim($emailIn)); $this->customer_m->block_unblock_user($result->customerId, 1); $uriSeg1 = $this->uri->segment(1); if (empty($uriSeg1) || $uriSeg1 == 'pointeforce') { redirect(base_url() . 'frontend/dashboard'); } redirect(current_url()); } else { $blockDtCount = $this->session->userdata('blockDtCount_web' . trim($emailIn)); $this->custom_log->write_log('custom_log', 'block count is ' . $blockDtCount); if ($blockDtCount) { $blockDtCount = $blockDtCount + 1; $this->session->set_userdata('blockDtCount_web' . trim($emailIn), $blockDtCount); } else { $blockDtCount = 1; $this->session->set_userdata('blockDtCount_web' . trim($emailIn), $blockDtCount); } if (!empty($blockDtCount) && $blockDtCount > 2) { $this->customer_m->update_block_date($result->customerId); $this->custom_log->write_log('custom_log', 'customer update block date'); } $this->session->set_flashdata('loginError', 'invalid password'); $this->custom_log->write_log('custom_log', 'invalid password'); } if (!empty($blockDtCount) && $blockDtCount == 2) { $this->session->set_flashdata('loginError', 'You have one more attempt to log in to your PointeMart account. If unsuccessful, your account would be blocked.<br>If you wish to reset your password, please click on the forgot Password link below and follow the instructions.'); $this->custom_log->write_log('custom_log', 'You have one more attempt to log in to your PointeMart account. If unsuccessful, your account would be blocked.<br>If you wish to reset your password, please click on the forgot Password link below and follow the instructions.'); } elseif (!empty($blockDtCount) && $blockDtCount > 2) { $name = $result->firstName . ' ' . $result->lastName; $password = rand(0, 999999999); if ($this->customer_m->update_reset_code($emailIn, $password)) { $data = array('email' => $emailIn, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password'); if ($this->email_m->send_mail($data)) { $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->custom_log->write_log('custom_log', 'not Send Mail : ' . $this->email->print_debugger()); } $this->session->set_flashdata('loginError', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.'); $this->custom_log->write_log('custom_log', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.'); //$this->session->unset_userdata('blockDtCount'); } } } else { $this->session->set_flashdata('loginError', $this->lang->line('error_veryfy_email')); $this->custom_log->write_log('custom_log', $this->lang->line('error_veryfy_email')); } } else { $this->session->set_flashdata('loginError', $this->lang->line('error_email_password')); $this->custom_log->write_log('custom_log', $this->lang->line('error_email_password')); } redirect(current_url()); } } if (!empty($_POST['REGISTRATION']) && $_POST['REGISTRATION'] == 'Sign Up') { $this->custom_log->write_log('custom_log', 'Registration Form submit ' . print_r($_POST, TRUE)); if ($this->input->post('email')) { $_POST['email'] = html_entity_decode($this->input->post('email')); } $rules = customer_sign_up_rules(); $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { $varifyCode = new_random_password(); $_POST['resetPasswordCode'] = $varifyCode; $this->custom_log->write_log('custom_log', 'Verify code is ' . $varifyCode); $customer_id = $this->customer_m->add_customer($_POST); $this->custom_log->write_log('custom_log', 'customer id is ' . $customer_id); if (!empty($customer_id)) { $_POST['stateId'] = 0; $_POST['cityId'] = 0; $_POST['areaId'] = 0; $_POST['zipcode'] = 0; $_POST['street'] = ''; $address_id = $this->customer_m->add_address($_POST); $this->custom_log->write_log('custom_log', 'address id is ' . $address_id); if ($address_id) { $this->customer_m->add_customer_address($customer_id, $address_id); $email = $this->input->post('email'); $password = $this->input->post('password'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $mailData = array('email' => $email, 'cc' => '', 'varify_url' => base_url() . 'auth/varification/' . id_encrypt($customer_id) . '/' . $varifyCode, 'slug' => 'customer_user_sign_up', 'name' => $first_name . ' ' . $last_name, 'password' => $password, 'subject' => 'Customer user created successfully'); if ($this->email_m->send_mail($mailData)) { $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger()); } $this->session->set_flashdata('success', 'Customer Sign Up Successfully'); } else { $this->session->set_flashdata('error', 'Customer Address not create'); $this->custom_log->write_log('custom_log', 'Customer Address not create'); } } else { $this->session->set_flashdata('error', 'Customer not create'); $this->custom_log->write_log('custom_log', 'Customer not create'); } redirect(current_url()); } } if (!empty($_POST['FORGOTPASSWORD']) && $_POST['FORGOTPASSWORD'] == 'SUBMIT') { $this->custom_log->write_log('custom_log', 'Forgot password form submit ' . print_r($_POST, TRUE)); $rules = reset_password_rules(); $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { $email = html_entity_decode($this->input->post('email')); $user = $this->customer_m->user_email($email); $this->custom_log->write_log('custom_log', 'User details is ' . print_r($user, true)); if (!empty($user)) { $name = $user->firstName . ' ' . $user->lastName; $password = rand(0, 999999999); if ($this->customer_m->update_reset_code($email, $password)) { $data = array('email' => $email, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password'); $message = 'Dear ' . $name . ', temporary password for your account is ' . $password; $messageRs = $this->twillo_m->send_mobile_message('+234' . $user->phone, $message); $this->custom_log->write_log('custom_log', 'Message result is ' . print_r($messageRs, true)); if ($this->email_m->send_mail($data)) { $this->session->set_flashdata('success', $this->lang->line('success_reset_password')); $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->session->set_flashdata('error', $this->lang->line('error_mail_not_send')); $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger()); } } else { $this->session->set_flashdata('error', 'Reset password not update'); $this->custom_log->write_log('custom_log', 'Reset password not update'); } } else { $this->session->set_flashdata('error', 'User not available'); $this->custom_log->write_log('custom_log', 'User not available'); } redirect(current_url()); } } } $viewData['emailIn'] = $emailIn; $viewData['passwordIn'] = $passwordIn; //$viewData['categoryList'] = $this->category_lib->category_level_list(); $categoryArr = $this->category_lib->category_level10(); $viewData['categoryList'] = $categoryArr['categoryLevelList']; //echo "<pre>"; print_r($viewData['categoryList']); exit; $customerId = $this->session->userdata('userId'); if (!empty($customerId) && $customerId) { $customerDet = $this->customer_m->login_customer_detail($customerId); if (!empty($customerDet)) { $block_status = $customerDet->active; if (!$block_status) { $this->session->set_flashdata('error', $this->lang->line('error_block_user')); redirect(base_url() . 'auth/logout'); } } } //echo "<pre>"; print_r($categoryArr); exit; $this->output->set_header("X-Frame-Options: SAMEORIGIN"); $this->load->view('frontendHeader', $viewData); $this->load->view($viewName, $viewData); $this->load->view('frontendFooter'); }
public function superadmin_sign_up() { $returnArr = array(); $returnArr['image_name'] = ''; $returnArr['first_name'] = ''; $returnArr['last_name'] = ''; $returnArr['email'] = ''; $returnArr['gender'] = ''; $returnArr['date'] = ''; $returnArr['month'] = ''; $returnArr['comment'] = ''; $returnArr['country_id'] = ''; $returnArr['state_id'] = ''; $returnArr['show_modal'] = 0; if ($_POST) { $returnArr['show_modal'] = 1; $this->CI->custom_log->write_log('custom_log', 'Form submit ' . print_r($_POST, true)); $returnArr['image_name'] = $this->CI->input->post('image_name'); $returnArr['first_name'] = $this->CI->input->post('first_name'); $returnArr['last_name'] = $this->CI->input->post('last_name'); $returnArr['email'] = $this->CI->input->post('email'); $returnArr['gender'] = $this->CI->input->post('gender'); $returnArr['date'] = $this->CI->input->post('date'); $returnArr['month'] = $this->CI->input->post('month'); $returnArr['comment'] = $this->CI->input->post('comment'); //$returnArr['country_id'] = $this->CI->input->post('country_id'); //$returnArr['state_id'] = $this->CI->input->post('state_id'); $rules = superadmin_sign_up_rules(); $this->CI->form_validation->set_rules($rules); $this->CI->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->CI->form_validation->run()) { $returnArr['birth_date'] = '0000-' . $returnArr['month'] . '-' . $returnArr['date']; $newPass = new_random_password(); $user_id = $this->CI->user_m->add_user($returnArr['email'], password_encrypt($newPass), 'superadmin', ''); $this->CI->custom_log->write_log('custom_log', 'created user id is ' . $user_id); if ($user_id) { $profile_id = $this->CI->user_m->add_superadmin_user_profile($user_id, $returnArr); $this->CI->custom_log->write_log('custom_log', 'created user profile id is ' . $profile_id); if ($profile_id) { $mailData = array('email' => $returnArr['email'], 'cc' => '', 'slug' => 'superadmin_create_by_superadmin', 'subject' => 'Superadmin Created', 'name' => $returnArr['first_name'] . ' ' . $returnArr['last_name'], 'password' => $newPass); if ($this->CI->email_m->send_mail($mailData)) { $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_mail_send')); } else { $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('error_mail_not_send')); } redirect(base_url() . 'superadmin/superadmin_management'); } else { $this->CI->session->set_flashdata('error', $this->CI->lang->line('error_add_shipping_agent')); $this->CI->custom_log->write_log('custom_log', 'Message is ' . $this->CI->lang->line('error_add_shipping_agent')); } } else { $this->CI->session->set_flashdata('error', $this->CI->lang->line('error_add_shipping_agent')); $this->CI->custom_log->write_log('custom_log', 'Message is ' . $this->CI->lang->line('error_add_shipping_agent')); } } } return $returnArr; }
public function upload_product_image($product_id = '') { $this->session->set_userdata(array('log_MODULE' => 'upload_product_image', 'log_MID' => '')); $product_id = id_decrypt($product_id); $this->custom_log->write_log('custom_log', 'product id is ' . $product_id); $userId = $this->session->userdata('userId'); $this->custom_log->write_log('custom_log', 'user id is ' . $userId); $this->load->library('upload'); if (isset($_FILES['myfile'])) { $result = ''; $this->custom_log->write_log('custom_log', 'upload file array is ' . print_r($_FILES['myfile'], true)); $extension = pathinfo($_FILES['myfile']['name'], PATHINFO_EXTENSION); $newImageName = $this->currentTimestamp + new_random_password() . '.' . $extension; $config['upload_path'] = './uploads/product/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['file_name'] = $newImageName; $this->custom_log->write_log('custom_log', 'upload file array is ' . print_r($config, true)); $this->upload->initialize($config); if (!$this->upload->do_upload('myfile')) { $result = $this->upload->display_errors(); $this->custom_log->write_log('custom_log', 'file upload error is ' . $this->upload->display_errors()); } else { $imagepath = 'uploads/product/' . $newImageName; $newimagepath = 'uploads/product/thumb50'; if (!file_exists($newimagepath)) { mkdir($newimagepath, 0777, true); chmod($newimagepath, 0777); } $thumb50 = 'uploads/product/thumb50/' . $newImageName; $this->common_model->resize($imagepath, $thumb50, $newHt = 200, $newWd = 200); $insertOpt = array('table' => 'product_image', 'data' => array('product_image_name' => $newImageName, 'product_id' => $product_id, 'last_modified_by' => $userId, 'last_modified_time' => $this->currentTimestamp)); $this->custom_log->write_log('custom_log', 'product image insert befor ' . print_r($insertOpt, true)); $product_image_id = $this->common_model->customInsert($insertOpt); $this->custom_log->write_log('custom_log', 'product image creat id is ' . $product_image_id); if ($product_image_id) { $this->custom_log->write_log('custom_log', $this->lang->line('success_add_product_image')); $result = $this->lang->line('success_add_product_image'); } else { $this->custom_log->write_log('custom_log', $this->lang->line('error_add_product_image')); $result = $this->lang->line('error_add_product_image'); } } echo $result; } }
public function user_sign_up() { $return = array(); $return['imageName'] = ''; $return['firstName'] = ''; $return['middleName'] = ''; $return['lastName'] = ''; $return['email'] = ''; $return['date'] = ''; $return['month'] = ''; $return['countryId'] = 154; $return['stateId'] = ''; $return['areaId'] = ''; $return['userType'] = 'admin'; if ($_POST) { $this->CI->custom_log->write_log('custom_log', 'form submit data is ' . print_r($_POST, true)); $return['imageName'] = $this->CI->input->post('image_name'); $return['firstName'] = $this->CI->input->post('first_name'); $return['middleName'] = $this->CI->input->post('middle_name'); $return['lastName'] = $this->CI->input->post('last_name'); $return['email'] = $this->CI->input->post('email'); $return['date'] = $this->CI->input->post('date'); $return['month'] = $this->CI->input->post('month'); $return['stateId'] = $this->CI->input->post('stateId'); $return['areaId'] = $this->CI->input->post('areaId'); $return['userType'] = $this->CI->input->post('admin_type'); $rules = admin_sign_up_rules(); if (!empty($return['userType']) && $return['userType'] == 'admin') { $rules[] = array('field' => 'roles[]', 'label' => 'user needs to be assigned atleast one role, role', 'rules' => 'trim|required'); } $this->CI->form_validation->set_rules($rules); $this->CI->form_validation->set_error_delimiters('<div class="error col-sm-12 error text-left">', '</div>'); if ($this->CI->form_validation->run()) { $return['birthDate'] = '0000-' . $return['month'] . '-' . $return['date']; $return['password'] = new_random_password(); $employeeId = $this->CI->user_m->add_user_employee($return); $this->CI->custom_log->write_log('custom_log', 'employee id is ' . $employeeId); if (!empty($employeeId) && $employeeId) { $addressId = $this->CI->user_m->add_user_address($return); $this->CI->custom_log->write_log('custom_log', 'employee address id is ' . $addressId); if (!empty($addressId) && $addressId) { $employeeAddressId = $this->CI->user_m->add_user_employee_address($employeeId, $addressId); if (!empty($return['userType']) && $return['userType'] == 'admin') { if (!empty($_POST['roles'])) { $empRoleId = $this->CI->user_m->add_user_employee_role($employeeId, 2); $this->CI->custom_log->write_log('custom_log', 'employee role id is ' . $empRoleId); foreach ($_POST['roles'] as $value) { $empRoleId = $this->CI->user_m->add_user_employee_role($employeeId, $value); $this->CI->custom_log->write_log('custom_log', 'employee role id is ' . $empRoleId); } if (!empty($empRoleId)) { $mailData = array('email' => $return['email'], 'cc' => '', 'slug' => 'admin_create_by_superadmin', 'name' => $return['firstName'] . ' ' . $return['lastName'], 'password' => $return['password'], 'subject' => 'Admin created Successfully'); if ($this->CI->email_m->send_mail($mailData)) { $this->CI->custom_log->write_log('custom_log', 'send mail ' . $this->CI->email->print_debugger()); } else { $this->CI->custom_log->write_log('custom_log', 'mail not send ' . $this->CI->email->print_debugger()); } $this->CI->session->set_flashdata('success', $this->CI->lang->line('success_admin_create_by_superadmin')); $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_admin_create_by_superadmin')); } } } elseif (!empty($return['userType']) && $return['userType'] == 'superadmin') { $empRoleId = $this->CI->user_m->add_user_employee_role($employeeId, 1); $this->CI->custom_log->write_log('custom_log', 'employee role id is ' . $empRoleId); $mailData = array('email' => $return['email'], 'cc' => '', 'slug' => 'admin_create_by_superadmin', 'name' => $return['firstName'] . ' ' . $return['lastName'], 'password' => $return['password'], 'subject' => 'Super Admin created Successfully'); if ($this->CI->email_m->send_mail($mailData)) { $this->CI->custom_log->write_log('custom_log', 'send mail ' . $this->CI->email->print_debugger()); } else { $this->CI->custom_log->write_log('custom_log', 'mail not send ' . $this->CI->email->print_debugger()); } $this->CI->session->set_flashdata('success', $this->CI->lang->line('success_admin_create_by_superadmin')); $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_admin_create_by_superadmin')); } } else { $this->CI->session->set_flashdata('error', 'Employee address not create'); $this->CI->custom_log->write_log('custom_log', 'Employee address not create'); } } else { $this->CI->session->set_flashdata('error', 'Employee not create'); $this->CI->custom_log->write_log('custom_log', 'Employee not create'); } redirect(base_url() . 'superadmin/user_management'); } } $return['stateList'] = $this->CI->location_m->nigeria_state_list(); $return['roles_list'] = $this->CI->user_m->role_list(2); return $return; }
function signUp() { if ($_POST) { if (!empty($_POST)) { $this->custom_log->write_log('custom_log', 'Registration Form submit ' . print_r($_POST, TRUE)); if ($this->input->post('email')) { $_POST['email'] = html_entity_decode($this->input->post('email')); } $rules = customer_sign_up_rules(); $this->form_validation->set_rules($rules); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if ($this->form_validation->run()) { $varifyCode = new_random_password(); $_POST['resetPasswordCode'] = $varifyCode; $this->custom_log->write_log('custom_log', 'Verify code is ' . $varifyCode); $customer_id = $this->customer_m->add_customer($_POST); $this->custom_log->write_log('custom_log', 'customer id is ' . $customer_id); if (!empty($customer_id)) { $_POST['stateId'] = 0; $_POST['cityId'] = 0; $_POST['areaId'] = 0; $_POST['zipcode'] = 0; $_POST['street'] = ''; $address_id = $this->customer_m->add_address($_POST); $this->custom_log->write_log('custom_log', 'address id is ' . $address_id); if ($address_id) { $this->customer_m->add_customer_address($customer_id, $address_id); $email = $this->input->post('email'); $password = $this->input->post('password'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $mailData = array('email' => $email, 'cc' => '', 'varify_url' => base_url() . 'auth/varification/' . id_encrypt($customer_id) . '/' . $varifyCode, 'slug' => 'customer_user_sign_up', 'name' => $first_name . ' ' . $last_name, 'password' => $password, 'subject' => 'Customer user created successfully'); if ($this->email_m->send_mail($mailData)) { $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger()); } else { $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger()); } $this->session->set_flashdata('success', 'Customer Sign Up Successfully'); } else { $this->session->set_flashdata('error', 'Customer Address not create'); $this->custom_log->write_log('custom_log', 'Customer Address not create'); } } else { $this->session->set_flashdata('error', 'Customer not create'); $this->custom_log->write_log('custom_log', 'Customer not create'); } redirect(current_url()); } } } $this->data['title'] = "Registration"; $this->frontendCustomView('home/signUp', $this->data); }