/** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html */ public function index() { $send_mail = false; if ($send_mail) { $this->load->helper('email'); $email = array('to' => array('*****@*****.**' => 'Amrit Man Shrestha'), 'from' => array('*****@*****.**' => 'Exercusion Nepal'), 'subject' => 'this is email subject', 'body' => 'this is email body'); if ($rtn = email_simple_send($email)) { echo 'email sent'; } else { echo 'mail not sent'; var_dump($rtn); } // var_dump($rtn); } $this->load->view('welcome_message'); }
function _send_booking_confirmed_emails($booking_details) { if ($client_detail = $this->ion_auth->user($booking_details->booking_to)->row()) { /* * email to client */ $body = <<<EOD Dear {$booking_details->client_name},<br><br> Congratulation, Your booking of {$booking_details->booking_item_title} has been confirmed by our Agent. Please <a href="base_url('login')">log in</a> and make payment to purchase this booking. The booking confirmation is valid for 2 days. <br/> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; if ($client_detail->email) { // $email_data = array( // 'to' => $this->session->userdata("email"), // 'subject' => 'hotel/package booking confirmation', // 'body' => $body // ); // $this->_sendMail($email_data); //send mail method $email = array('to' => array($this->session->userdata("email") => $this->session->userdata("username")), 'subject' => 'hotel/package ' . @$booking_details->booking_item_title . ' booking confirmation', 'body' => $body); email_simple_send($email); } } /* * email to agent */ if ($agent_detail = $this->ion_auth->user($booking_details->agent_id)->row()) { $body = <<<EOD Dear {$agent_detail->username}, <br> We have notified our client for payment. We will inform you once payment is done. The maximum waiting period for payment is 1 week. <br> Thank you <br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; if ($agent_email = $agent_detail->email) { // // $email_data = array( // 'to' => $agent_email,// to agent email // 'subject' => 'hotel/package booking confirmation', // 'body' => $body // ); // $this->_sendMail($email_data); //send mail method $email = array('to' => array($agent_email => @$agent_detail->first_name . ' ' . @$agent_detail->last_name), 'subject' => "client has made successful payment for @{$booking_details->booking_item_title}", 'body' => $body); email_simple_send($email); } } /* * email to admin */ if ($admin_email = $this->data['metadata']['site_email_info']) { $body = <<<EOD Dear Admin, <br> We have receive a booking confirmation though admin for {$booking_details->booking_item_title}. Please <a href="base_url('admin')">click here<a> to visit and view the package/hotel confirmation. <br> Thank you <br><br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal EOD; //get email of admin // $email_data = array( // 'to' => $admin_email, // 'subject' => 'hotel/package booking confirmation', // 'body' => $body // ); // $this->_sendMail($email_data); //send mail method $email = array('to' => array($admin_email => $this->data['metadata']['site_name']), 'subject' => "hotel/package booking confirmation of @{$booking_details->booking_item_title}", 'body' => $body); email_simple_send($email); } }
function create_agent() { $this->title = "Create User"; $layout = 'cms_layout'; $tables = $this->config->item('tables', 'ion_auth'); //validation rule $validation_rules = array('first_name' => array('field' => 'first_name', 'label' => 'First Name', 'rules' => 'trim|htmlspecialchars|required|xss_clean|max_length[100]'), 'last_name' => array('field' => 'last_name', 'label' => 'Last Name', 'rules' => 'trim|htmlspecialchars|required|xss_clean|max_length[100]'), 'email' => array('field' => 'email', 'label' => 'Email', 'rules' => 'required|valid_email|is_unique[' . $tables['users'] . '.email]'), 'phone' => array('field' => 'phone', 'label' => 'Phone', 'rules' => 'trim|xss_clean'), 'country' => array('field' => 'country', 'label' => 'Country', 'rules' => 'trim|xss_clean'), 'street' => array('field' => 'street', 'label' => 'street', 'rules' => 'trim|xss_clean'), 'state' => array('field' => 'state', 'label' => 'State', 'rules' => 'trim|xss_clean'), 'suburb' => array('field' => 'suburb', 'label' => 'suburb', 'rules' => 'trim|xss_clean'), 'postCode' => array('field' => 'postCode', 'label' => 'Post Code', 'rules' => 'trim|xss_clean'), 'company_name' => array('field' => 'company_name', 'label' => 'Company Name', 'rules' => 'trim|xss_clean'), 'company_website' => array('field' => 'company_website', 'label' => 'Company Website', 'rules' => 'trim|xss_clean'), 'company_facebook' => array('field' => 'company_facebook', 'label' => 'Company Facebook', 'rules' => 'trim|xss_clean'), 'agent_position' => array('field' => 'agent_position', 'label' => 'Agent Position', 'rules' => 'trim|xss_clean'), 'agent_mobile' => array('field' => 'agent_mobile', 'label' => 'Agent Mobile', 'rules' => 'trim|xss_clean'), 'agent_type' => array('field' => 'agent_type', 'label' => 'Agent Type', 'rules' => 'required'), 'company_reg_no' => array('field' => 'company_reg_no', 'label' => 'Company Registration Number', 'rules' => 'trim|xss_clean')); $this->form_validation->set_rules($validation_rules); $this->form_validation->set_error_delimiters('<p class="validation_errors">', '</p>'); if ($this->form_validation->run() == true) { $username = strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name')); $email = strtolower($this->input->post('email')); //$password = $this->input->post('password'); $password = $this->generate_password(); $additional_data = array('first_name' => $this->input->post('first_name'), 'last_name' => $this->input->post('last_name'), 'country' => $this->input->post('country'), 'suburb' => $this->input->post('suburb'), 'activate' => 0); } $group = $this->ion_auth_model->get_groupid_from_group('Agents'); if ($this->form_validation->run() == true && ($user_id = $this->ion_auth->register($username, $password, $email, $additional_data, array($group->id)))) { //check to see if we are creating the user // $this->ion_auth_model->add_to_group($group_id, $user_id); // insert into clients or agents table // preparing for insertion $data = array('agent_id' => is_array($user_id) ? $user_id['id'] : $user_id, 'agent_country' => $this->input->post('country'), 'agent_suburb' => $this->input->post('suburb'), 'agent_phoneNumber' => $this->input->post('phone'), 'agent_emailId' => $this->input->post('email'), 'agent_firstName' => $this->input->post('first_name'), 'agent_lastName' => $this->input->post('last_name'), 'agent_companyName' => $this->input->post('company_name'), 'agent_position' => $this->input->post('agent_position'), 'agent_mobile' => $this->input->post('agent_mobile'), 'agent_type' => $this->input->post('agent_type'), 'agent_website' => $this->input->post('company_website'), 'agent_status' => 0); $this->ion_auth_model->set_table_name('agents'); $this->ion_auth_model->save($data); /* * @author Amrit Man Shrestha <amritms@gmail.com * sending email when agent registers */ if (is_array($user_id)) { $this->load->helper('email'); $fullname = $data['agent_firstName'] . ' ' . $data['agent_lastName']; // ----------------- email to admin -------------- $admin_agent_url = base_url('admin/agents'); $message = <<<EOD {$fullname} ({$data['agent_emailId']}) of {$data['agent_companyName']} has registered as an agent. <a href="{$admin_agent_url}">Click here</a> to activate the agent.<br><br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal EOD; $email = array('to' => array($this->config->item('admin_email', 'ion_auth') => $this->config->item('site_title', 'ion_auth')), 'subject' => "Activation Request for New Agent [" . $fullname . ", " . $data['agent_companyName'] . ']', 'body' => $message); email_simple_send($email); // --------------- email to agent ------------------ $message = <<<EOD Thank you {$fullname} for becoming our agent.<br> Please login to the system using the system auto-generated password provided below: <br> <strong>Password: </strong>{$password}<br> You can always change your password through the profile section in your account.<br> Your account is currently deactivated. We will review your account and activate it.<br><br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal EOD; $email = array('to' => array($user_id['email'] => $fullname), 'from' => array($this->config->item('admin_email', 'ion_auth') => $this->config->item('site_title', 'ion_auth')), 'subject' => $this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_activation_subject'), 'body' => $message); email_simple_send($email); } //-------------------------------------------------------------- //redirect them back to the admin page // $this->session->set_flashdata('message', $this->ion_auth->messages()); $this->session->set_flashdata('message', 'Thank you ' . $fullname . '. We will review and activate your account'); redirect("login", 'refresh'); } else { //display the create user form //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'))); $this->data['message'] = $this->session->flashdata('message'); $this->data['edit_data'] = $this->ion_auth_model->array_from_post(array_keys($validation_rules)); $this->template->set_breadcrumb('Create Agent', '#'); $build = 'create_agent'; } $this->template->title($this->title . ' :: ')->set_layout($layout)->build($build, $this->data); }
function _change_status_after_update($post_array, $primary_key) { $agent_detail = $post_array; if ($agent_detail['agent_status'] == '1') { // if the agent is activated /* * email to agent */ $agent_fullname = @$agent_detail['agent_firstName'] . ' ' . @$agent_detail['agent_lastName']; $agent_login = FRONT_BASE_URL . '/login'; $body = <<<EOD Dear {$agent_fullname}, <br> Your account have been activated. Please <a href='{$agent_login}'>click here</a> to login. <br><br> Thank you <br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; if ($agent_email = $agent_detail['agent_emailId']) { $email = array('to' => array($agent_email => $agent_fullname), 'subject' => "The Excursion Nepal Account Activation", 'body' => $body); email_simple_send($email); } } return true; }
/** * process booking after login / create user */ private function _ajax_process_booking() { if (!$this->ion_auth->logged_in()) { echo "not loggedin"; die; } /* * redirect to package search if not tried to access directly */ if (!$this->input->post()) { show_404(); } $booking_details['package_id'] = $this->input->post('package_id'); $booking_details['package_title'] = $this->input->post('package_title'); $no_persons = $this->input->post('no_persons'); $checkin = $this->input->post('check_in'); $message = ''; $status = 1; if (!$checkin) { $message = 'Please choose checkin date'; $status = 0; } elseif (!$booking_details['package_title']) { $message = 'Please search package and try again'; $status = 0; } if (!$status) { echo $message; } else { //additional information about booking $booking_details['checkin'] = $checkin; // $i = 0; // $total = 0; // $items_array = array(); // foreach ($rooms as $room) { //// echo $room; // $splits = explode('_', $room); //// var_dump($splits); // if ($splits[2] != 0) { // $items_array[$i]['room_id'] = $splits[1]; // $items_array[$i]['room_count'] = $splits[2]; // $items_array[$i]['total_nights'] = $total_nights; // $items_array[$i]['room_title'] = $room_types[$splits[1]]->room_title; // $items_array[$i]['room_price'] = (int)$room_types[$splits[1]]->room_basic_discount ? (int)$room_types[$splits[1]]->room_basic_price - (int)$room_types[$splits[1]]->room_basic_discount : (int)$room_types[$splits[1]]->room_basic_price; // $items_array[$i]['room_subtotal'] = $total_nights * $items_array[$i]['room_price']; // $items_array[$i]['total'] = $items_array[$i]['room_subtotal'] * $items_array[$i]['room_count']; //// $total += $items_array[$i]['room_subtotal'] * $items_array[$i]['room_count']; // $total += $items_array[$i]['total']; // ++$i; // } // } $package_detail = $this->packages_m->get($booking_details['package_id'], true); $total = floatval($package_detail->package_basic_price) - floatval($package_detail->package_basic_discount); $booking_details['ItemTotalPrice'] = $total; $booking_details['payment_type'] = 'PayPal_Express'; // @todo added this manually. it should be set when payment is being made. inside client dashboard $possible_payments = array('PayPal_Express', 'PayPal_Pro'); $booking_ref_no = getRandomString(12, date('Ymd')); $booking_details_insert = array("booking_ref_no" => $booking_ref_no, "booking_total" => $total, "booking_to" => $this->session->userdata("user_id"), "booking_agent" => '', "booking_type" => 'packages', "booking_item_title" => $booking_details['package_title'], "booking_date" => date("Y-m-d H:i:s"), "booking_status" => '0', "booking_checkin" => $booking_details['checkin'], "booking_nights" => $no_persons, "booking_payment_date" => date("Y-m-d H:i:s"), "booking_payment_type" => in_array($booking_details['payment_type'], $possible_payments) ? $booking_details['payment_type'] : 'PayPal_Express', "booking_paymethod_tax" => 0, "booking_item" => $booking_details['package_id'], 'agent_id' => $this->packages_m->get_agent_id_from_package_id($booking_details['package_id']), "ip_address" => $this->input->ip_address()); if ($this->db->insert('bookings', $booking_details_insert)) { /* * email to client */ $client_email = $this->session->userdata("email"); if ($client_email) { $client_name = $this->session->userdata("username"); /* * email to client */ $body = <<<EOD Dear {$client_name},<br><br> Thank you for booking our {$booking_details_insert['booking_item_title']}. Our Agent will confirm your booking within 2 working day and get back to you for payment confirmation. <br><br> Thank you<br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; $email = array('to' => array($this->session->userdata("email") => $this->session->userdata("username")), 'subject' => @$booking_details_insert['booking_item_title'] . " was successfully booked ", 'body' => $body); @email_simple_send($email); // var_dump($email); } /* * email to agent */ if ($agent_id = $this->packages_m->get_agent_id_from_package_id($booking_details['package_id'])) { if ($agent_detail = $this->ion_auth->user($booking_details_insert['agent_id'])->row()) { $agent_dashboard = base_url('agents'); $body = <<<EOD Dear {$agent_detail->username}, <br> We have receive a booking enquiry though our client for your {$booking_details_insert['booking_item_title']}. Please <a href="{$agent_dashboard}">click here</a> to visit and confirm the package. <br> Once the package is confirm, client will make the payment. All the booking needs to be confirmed within 1 working day. Please email client if you need to provide alternative option. <br><br> Thank you <br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; if ($agent_email = $agent_detail->email) { $email = array('to' => array($agent_email => @$agent_detail->first_name . ' ' . @$agent_detail->last_name), 'subject' => @$booking_details_insert[booking_item_title] . " was successfully booked ", 'body' => $body); @email_simple_send($email); } } } /* * email to admin */ if ($admin_email = $this->data['metadata']['site_email_info']) { $admin_dashboard = base_url('admin'); $body = <<<EOD Dear Admin, <br> We have receive a booking enquiry though our client for your {$booking_details_insert['booking_item_title']}. <br>Please <a href="{$admin_dashboard}">click here</a> to visit and view / confirm the package/hotel. <br> Thank you <br><br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal EOD; $email = array('to' => array($this->data['metadata']['site_email_info'] => $this->data['metadata']['site_name']), 'subject' => @$booking_details_insert['booking_item_title'] . " was successfully booked ", 'body' => $body); @email_simple_send($email); } //agent commission is calcualted in database as per rate set in settings //echo json_encode(array('status' => 1, 'redirect' => base_url("clients"), 'popup' => '')); } else { echo 'sorry, could not process your booking'; } } }
function forgot_password() { $this->form_validation->set_rules('email', $this->lang->line('forgot_password_validation_email_label'), 'required'); if ($this->form_validation->run() == false) { //setup the input $this->data['email'] = array('name' => 'email', 'id' => 'email'); if ($this->config->item('identity', 'ion_auth') == 'username') { $this->data['identity_label'] = $this->lang->line('forgot_password_username_identity_label'); } else { $this->data['identity_label'] = $this->lang->line('forgot_password_email_identity_label'); } //set any errors and display the form $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message'); // $this->_render_page('auth/forgot_password', $this->data); // $this->data['main_content'] = 'login/forgot_password'; // $this->load->view('login_wrapper', $this->data); $build = 'forgot_password'; $layout = 'login_layout'; $this->title = 'Forgot Password'; $this->template->title($this->title . ' :: ')->set_layout($layout)->build($build, $this->data); } else { // get identity for that email $identity = $this->db->where('email', strtolower($this->input->post('email')))->get('io_users')->row(); if (empty($identity)) { $this->ion_auth->set_message('forgot_password_email_not_found'); $this->session->set_flashdata('message', $this->ion_auth->messages()); redirect("login/forgot_password", 'refresh'); } //run the forgotten password method to email an activation code to the user $forgotten = $this->ion_auth->forgotten_password($identity->{$this->config->item('identity', 'ion_auth')}); if ($forgotten) { //if there were no errors $this->session->set_flashdata('message', $this->ion_auth->messages()); /** * password reset link email to client */ $forgotten_password_code_row = $this->db->select('forgotten_password_code')->where('email', $identity->email)->get('io_users')->row(); $fullname = $identity->first_name . ' ' . $identity->last_name; $email_forgot_password_heading = sprintf(lang('email_forgot_password_heading'), $this->input->post('email')); $email_forgot_password_subheading = sprintf(lang('email_forgot_password_subheading'), anchor('login/reset_password/' . $forgotten_password_code_row->forgotten_password_code, lang('email_forgot_password_link'))); $message = <<<EOD <html> <body> \t<h1>{$email_forgot_password_heading}</h1> \t<p>{$email_forgot_password_subheading}</p> \t<p> \tRegards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal</p> </body> </html> EOD; $email = array('to' => array($identity->email => $fullname), 'from' => array($this->config->item('admin_email', 'ion_auth') => $this->config->item('site_title', 'ion_auth')), 'subject' => $this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgot_password_link'), 'body' => $message); email_simple_send($email); redirect("login", 'refresh'); //we should display a confirmation page here instead of the login page } else { $this->session->set_flashdata('message', $this->ion_auth->errors()); redirect("login/forgot_password", 'refresh'); } } }
function _send_booking_confirmed_emails($booking_details) { /* * email to client */ $client_login = base_url('login'); $body = <<<EOD Dear {$booking_details->client_name},<br><br> Congratulation, Your booking of {$booking_details->booking_item_title} has been confirmed by our Agent. Please <a href="{$client_login}">log in</a> and make payment to purchase this booking. The booking confirmation is valid for 2 days. <br/> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; $client_email = $this->ion_auth->user($booking_details->booking_to)->row()->email; if ($client_email) { $email = array('to' => array($client_email => $booking_details->client_name), 'subject' => 'hotel/package booking confirmation of ' . $booking_details->booking_item_title, 'body' => $body); @email_simple_send($email); } /* * email to agent */ if ($agent_detail = $this->ion_auth->user($booking_details->agent_id)->row()) { $body = <<<EOD Dear {$agent_detail->username}, <br> We have notified our client for payment. We will inform you once payment is done. The maximum waiting period for payment is 1 week. <br> Thank you <br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal<br> EOD; if ($agent_email = $agent_detail->email) { $email = array('to' => array($agent_email => @$agent_detail->first_name . ' ' . 'last_name'), 'subject' => "hotel/package booking confirmation for @{$booking_details->booking_item_title}", 'body' => $body); @email_simple_send($email); } } /* * email to admin */ if ($admin_email = $this->data['metadata']['site_email_info']) { $admin_login = base_url('admin'); $body = <<<EOD Dear Admin, <br> We have receive a booking confirmation though agent for {$booking_details->booking_item_title}. Please <a href="{$admin_login}">click here</a> to visit and view the package/hotel confirmation. <br> Thank you <br><br> Regards,<br> The Excursion Nepal (Powered by The Explorer Magazine)<br> Australia | Nepal EOD; $email = array('to' => array($admin_email => $this->data['metadata']['site_name']), 'subject' => "hotel/package booking confirmation of " . @$booking_details->booking_item_title, 'body' => $body); email_simple_send($email); } }