Guest User

Untitled

a guest
Jan 4th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('BASEPATH'))
  4. exit('No direct script access allowed');
  5.  
  6. class Transport extends Public_Controller {
  7.  
  8. public $email;
  9. public $data;
  10.  
  11. function __construct() {
  12. parent::__construct();
  13.  
  14. $this->email = 'gvmitrev@gmail.com';
  15.  
  16. $this->load->model('transport_m');
  17. }
  18.  
  19. function index($type_id = NULL) {
  20. if (is_null($type_id)) {
  21. $this->index(1, NULL);
  22. }
  23. /**
  24. * Show all types of transport
  25. */ else if (is_numeric($type_id)) {
  26. $this->data['results'] = $this->transport_m->getType($type_id);
  27. $this->data['main_content'] = 'main/transport/index';
  28. }
  29.  
  30. $this->data['type_id'] = $type_id;
  31. $this->data['types'] = $this->transport_m->getTypes();
  32. // echo '<pre>';
  33. // var_dump($this->data);
  34. // echo '</pre>';
  35. $this->data['title'] = 'Eurograde';
  36. $this->load->view('main/includes/template', $this->data);
  37. }
  38.  
  39. function item($type_id, $item_id) {
  40. if (is_numeric($type_id) && is_numeric($item_id)) {
  41.  
  42. /**
  43. * Send an email if form is entered and is valid
  44. */
  45. if ($this->input->post('submit')) {
  46. $this->load->library('form_validation');
  47.  
  48. //set validation rules
  49. $this->form_validation->set_rules('name', 'Name', 'trim|alpha_numeric');
  50. $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email');
  51. $this->form_validation->set_rules('startdate', 'Начална дата', 'trim|');
  52. $this->form_validation->set_rules('enddate', 'Крайна дата', 'trim|');
  53. $this->form_validation->set_rules('duration', 'Времетраене', 'trim|');
  54. $this->form_validation->set_rules('destination', 'Дестинация', 'trim|');
  55. $this->form_validation->set_rules('beziPoint', 'Краен пункт', 'trim|');
  56. $this->form_validation->set_rules('enquiry', 'Enquiry', 'required|trim');
  57.  
  58.  
  59. if ($this->form_validation->run() == false) {
  60.  
  61. } else {
  62. /**
  63. * Send mailвсички
  64. */
  65. $this->load->library('email');
  66. $config['protocol'] = 'mail';
  67. // $config['mailpath'] = '/usr/sbin/sendmail -t -i';
  68. $config['wordwrap'] = TRUE;
  69.  
  70. $this->email->initialize($config);
  71. $this->email->from($this->input->post('email'), $this->input->post('name'));
  72. // $this->email->to('p_arnaudov@yahoo.com');
  73. $this->email->to('gvmitrev@gmail.com');
  74.  
  75. $this->email->subject('Запитване относно ' . $this->data['item']->name);
  76. $this->email->message(
  77. 'Начална дата: ' . $this->input->post('startdate') . " \r\n" .
  78. 'Крайна дата: ' . $this->input->post('enddate') . " \r\n" .
  79. 'Времетраене: ' . $this->input->post('duration') . " \r\n" .
  80. 'Дестинация: ' . $this->input->post('destination') . " \r\n" .
  81. 'Краен пункт: ' . $this->input->post('beziPoint') . " \r\n" .
  82. $this->input->post('enquiry'));
  83.  
  84. if ($this->email->send()) {
  85. $this->session->set_flashdata('message', 'Email sent successfully.
  86. We will contact you on the email provided in max 2 days. Thank you');
  87. redirect('');
  88. } else {
  89. echo 'lose' . $this->email->print_debugger();
  90. exit();
  91. }
  92. }
  93. }
  94. $this->data['type_id'] = $type_id;
  95. $this->data['item_id'] = $item_id;
  96. $this->data['types'] = $this->transport_m->getTypes();
  97.  
  98. //get images in an array
  99. $this->data['images'] = directory_map('assets/files/transport/' . $item_id);
  100. $this->data['item'] = $this->transport_m->getItem($item_id);
  101. $this->data['main_content'] = 'main/transport/item';
  102. $this->data['title'] = 'Eurograde';
  103. $this->load->view('main/includes/template', $this->data);
  104. }
  105. }
  106.  
  107. }
  108.  
  109. /* End of file welcome.php */
  110. /* Location: ./application/controllers/welcome.php */
Add Comment
Please, Sign In to add comment