|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/serbaantik.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class New_product_development extends Public_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('pagination');
}
public function index()
{
$this->data_header['browser_title'] = 'New Product Development';
$this->data_header['meta_description'] = 'Serba Antik - New Product Development';
//get slideshows
$this->db->select('title, image, text_content')->from('home_slideshow')->where('status', '1')->where('type', 'products')->where('id', 100000)->order_by('priority', 'ASC');
$data['slideshows'] = $this->db->get()->result_array();
$data['widget'] = $this->recaptcha->getWidget();
$data['script'] = $this->recaptcha->getScriptTag();
$this->load->view('template/header', $this->data_header);
$this->load->view('newproduct', $data);
$this->load->view('template/footer', $this->data_footer);
}
public function send_inquiry()
{
//validation check
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="form_error">', '</div>');
$config = array(
array(
'field' => 'name',
'label' => 'Name',
'rules' => 'trim|required|min_length[3]'
),
array(
'field' => 'email',
'label' => 'Email',
'rules' => 'trim|required|valid_email'
),
array(
'field' => 'handphone',
'label' => 'Handphone',
'rules' => 'trim|required|min_length[6]'
),
array(
'field' => 'category',
'label' => 'category',
'rules' => 'trim|required'
),
array(
'field' => 'message',
'label' => 'message',
'rules' => 'trim|required'
),
);
$this->form_validation->set_rules($config);
if($this->form_validation->run($this))
{
$recaptcha = $this->input->post('g-recaptcha-response');
if(!empty($recaptcha))
{
$response = $this->recaptcha->verifyResponse($recaptcha);
if (isset($response['success']) and $response['success'] === true)
{
$this->send_email($_POST);
}
}
else
{
$this->session->set_flashdata('error', 'Sorry Recaptcha Error');
redirect('cart');
}
}
$this->index();
}
private function send_email($email_data)
{
$email_conf = $this->db->select('email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1)->get()->row();
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = $email_conf->email_smtp_host;
$config['smtp_port'] = $email_conf->email_smtp_port;
$config['smtp_user'] = $email_conf->email_smtp;
$config['smtp_pass'] = $email_conf->email_smtp_password;
$config['mailtype'] = 'html';
$config['smtp_crypto'] = 'ssl';
$config['charset'] = 'iso-8859-1';
//$config['charset'] = 'UTF-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard
$this->email->set_crlf( "\r\n" ); //add this for hotmail
$this->email->initialize($config);
$this->email->from('noreply@serbaantik.com', 'Serba Antik');
$this->email->to('inquiry@serbaantik.com');
$this->email->subject('Serba Antik New Product Product Development Inquiry');
$this->email->message(
'Hello Admin, You have new product development inquiry:<br><br>
Customer Name: ' . ucwords($email_data['name']) . '<br><br>
Email: ' . $email_data['email'] . '<br><br>
Handphone: ' . $email_data['handphone'] . '<br><br>
Category: ' . $email_data['category'] . '<br><br>
Message: ' . $email_data['message'] . '<br><br>');
$respon_email = $this->email->send();
if(!$respon_email)
{
var_dump($this->email->print_debugger()); exit();
}
$this->session->set_flashdata('success', 'Your inquiry have been sent. Thank you.');
redirect('new-product-development');
}
}