Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Transport extends Public_Controller {
- public $email;
- public $data;
- function __construct() {
- parent::__construct();
- $this->email = 'gvmitrev@gmail.com';
- $this->load->model('transport_m');
- }
- function index($type_id = NULL) {
- if (is_null($type_id)) {
- $this->index(1, NULL);
- }
- /**
- * Show all types of transport
- */ else if (is_numeric($type_id)) {
- $this->data['results'] = $this->transport_m->getType($type_id);
- $this->data['main_content'] = 'main/transport/index';
- }
- $this->data['type_id'] = $type_id;
- $this->data['types'] = $this->transport_m->getTypes();
- // echo '<pre>';
- // var_dump($this->data);
- // echo '</pre>';
- $this->data['title'] = 'Eurograde';
- $this->load->view('main/includes/template', $this->data);
- }
- function item($type_id, $item_id) {
- if (is_numeric($type_id) && is_numeric($item_id)) {
- /**
- * Send an email if form is entered and is valid
- */
- if ($this->input->post('submit')) {
- $this->load->library('form_validation');
- //set validation rules
- $this->form_validation->set_rules('name', 'Name', 'trim|alpha_numeric');
- $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
- $this->form_validation->set_rules('startdate', 'Начална дата', 'trim|');
- $this->form_validation->set_rules('enddate', 'Крайна дата', 'trim|');
- $this->form_validation->set_rules('duration', 'Времетраене', 'trim|');
- $this->form_validation->set_rules('destination', 'Дестинация', 'trim|');
- $this->form_validation->set_rules('beziPoint', 'Краен пункт', 'trim|');
- $this->form_validation->set_rules('enquiry', 'Enquiry', 'required|trim');
- if ($this->form_validation->run() == false) {
- } else {
- /**
- * Send mailвсички
- */
- $this->load->library('email');
- $config['protocol'] = 'mail';
- // $config['mailpath'] = '/usr/sbin/sendmail -t -i';
- $config['wordwrap'] = TRUE;
- $this->email->initialize($config);
- $this->email->from($this->input->post('email'), $this->input->post('name'));
- // $this->email->to('p_arnaudov@yahoo.com');
- $this->email->to('gvmitrev@gmail.com');
- $this->email->subject('Запитване относно ' . $this->data['item']->name);
- $this->email->message(
- 'Начална дата: ' . $this->input->post('startdate') . " \r\n" .
- 'Крайна дата: ' . $this->input->post('enddate') . " \r\n" .
- 'Времетраене: ' . $this->input->post('duration') . " \r\n" .
- 'Дестинация: ' . $this->input->post('destination') . " \r\n" .
- 'Краен пункт: ' . $this->input->post('beziPoint') . " \r\n" .
- $this->input->post('enquiry'));
- if ($this->email->send()) {
- $this->session->set_flashdata('message', 'Email sent successfully.
- We will contact you on the email provided in max 2 days. Thank you');
- redirect('');
- } else {
- echo 'lose' . $this->email->print_debugger();
- exit();
- }
- }
- }
- $this->data['type_id'] = $type_id;
- $this->data['item_id'] = $item_id;
- $this->data['types'] = $this->transport_m->getTypes();
- //get images in an array
- $this->data['images'] = directory_map('assets/files/transport/' . $item_id);
- $this->data['item'] = $this->transport_m->getItem($item_id);
- $this->data['main_content'] = 'main/transport/item';
- $this->data['title'] = 'Eurograde';
- $this->load->view('main/includes/template', $this->data);
- }
- }
- }
- /* End of file welcome.php */
- /* Location: ./application/controllers/welcome.php */
Add Comment
Please, Sign In to add comment