| Server IP : 103.48.194.25 / Your IP : 216.73.216.182 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/nguyenlieumyphamgiasi.vn/public_html/site/components/sanpham/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Sanpham extends MX_Controller
{
protected $_templates;
function __construct()
{
parent::__construct();
$this->load->model('sanpham_model','sanpham');
$this->load->helper('common') ;
//$this->load->model('home_model','home');
/*$this->load->model('payment_model','payment');
$this->load->model('viewcart_model','viewcart');
$this->load->model('customer_model','customer');*/
}
public function index($catid=0,$start=0)
{
$data['list_cate'] = $this->sanpham->get_category();
$data['display'] = $display = 10 ;
/*$data['start'] = (int) $start ;
$config['base_url'] = site.'san-pham/';
$data['num'] = $this->sanpham->count_product($catid);
$config['total_rows'] = $data['num'];
$config['per_page'] = $display;
$config['uri_segment'] = 3;
$config['num_links'] = 3;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();*/
$page = ($start/$display) + 1;
$page = "-Tg ".$page;
$data['metatitle'] = "Danh mục sản phẩm, nguyên liệu pha chế mỹ phẩm".$page;
$data['metadesc'] = "Nguyên liệu mỹ phẩm,nguyên liêu dầu nền, vitamin khoáng chất,chất bảo quản, gia công mỹ phẩm".$page;
$data['metakey'] = "Nguyên liệu mỹ phẩm,nguyên liêu dầu nền, vitamin khoáng chất,chất bảo quản, gia công mỹ phẩm";
$data['metaimg'] = "";
$data['canonical'] = site."san-pham.html";
$data['title'] = 'Sản phẩm' ;
$data['page'] = "sanpham/index" ;
$this->load->view('html/skin', $data);
}
public function detail($alias='')
{
$proid = get_id_from_alias($alias);
$data['rs'] = $this->sanpham->get_id($proid) ;
if($data['rs'])
{
//SEO
$data['title'] = $data['rs']->pro_name ;
$data['list_img'] = $this->sanpham->get_product_img($proid) ;
$data['list_pro'] = $this->sanpham->get_product_category($data['rs']->catid, 8,0) ;
$page = 0;
$data['metatitle'] = $data['rs']->metatitle;
$data['metadesc'] = $data['rs']->metadesc;
$data['metakey'] = $data['rs']->metakey;
$data['metaimg'] = urlimg."products/800/".$data['rs']->proimg;
$data['canonical'] = site."san-pham/".$data['rs']->pro_alias.'-'.$proid.".html";
$data['page'] = 'detail';
$this->load->view('html/skin',$data);
}
else
{
log_message('error', "Product Not found :" .$alias);
redirect("error/index");
}
}
public function viewcart()
{
$ses_login = get_ses_login() ;
if(!empty($ses_login)) redirect('profile/shopping') ;
$data['cart'] = get_ses_cart() ;
if(isset($_POST['update_cart']))
{
$soluong = isset($_POST['soluong'])? $_POST['soluong'] : '';
for ($i=0;$i<count($data['cart']);$i++):
foreach ($soluong as $b=>$c):
if($data['cart'][$i]['proid'] == $b)
$data['cart'][$i]['nb_order'] = $c ;
endforeach ;
endfor ;
}
$data['title'] = 'Xem đơn hàng' ;
$data['page'] = 'sanpham/viewcart';
$this->load->view('html/skin', $data);
}
public function thanhtoan()
{
$data['title'] = 'Thanh toán' ;
$data['page'] = 'sanpham/thanhtoan';
$this->load->view('html/skin', $data);
}
function sendcart()
{
$pass = $this->getRandomString(6) ;
$req = $this->_frm_customer($pass) ;
$rs_cus = $this->sanpham->chkemail($req['cusmail']) ;
if(empty($rs_cus))
$cusid = $this->sanpham->save('customer',$req);
else
$cusid = $rs_cus->cusid;
$cart = get_ses_cart() ;
for($i=0;$i<count($cart);$i++)
{
$req2 = $this->_frm_cart($i, $cart, $cusid) ;
$this->sanpham->save_cart($req2);
}
// goi mailo
/*$this->load->helper('mail') ;
$subject = 'Xác nhận mua quà tại huynhgiatrading.com';
$content = 'Bạn đã đặt hàng thành công tại <a href="http://huynhgiatrading.com">huynhgiatrading.com</a><br>
Click vào link dưới đay để xác nhận lại:>br>
<a href="http://huynhgiatrading.com/confirm/order/'.$oid.'">huynhgiatrading.com/confirm/order/'.$oid.'</a><br>
<br>
Cảm ơn bạn đã đặt hàng tại <a href="http://huynhgiatrading.com">huynhgiatrading.com</a><br>
huynhgiatrading.com';
sendmail($req['cusmail'], $req['cusname'], $subject, $content) ;
//sendmail($req['cusmail'], $req['cusname'], $subject, $content) ;
sendmail('quatangmythuat@gmail.com', 'huynhgiatrading.com', 'Dat hang tai huynhgiatrading.com', 'Co đơn hang moi tai huynhgiatrading.com') ;*/
$_SESSION['cart'] = array();
redirect('thanh-cong') ;
}
function _frm_cart($i, $cart, $cusid='')
{
$data['oid'] = 0 ;
$data['cusid'] = $cusid ;
$data['cusname'] = $this->input->post('fullname');
$data['address'] = $this->input->post('address') ;
$data['email'] = $this->input->post('email') ;
$data['phone'] = $this->input->post('phone') ;
$data['cusnote'] = $this->input->post('note') ;
$data['proid'] = $cart[$i]['proid'] ;
$data['pro_name'] = $cart[$i]['pro_name'] ;
$data['pro_img'] = $cart[$i]['pro_img'] ;
$data['pro_price'] = $cart[$i]['pro_price'] ;
$data['nb_order'] = $cart[$i]['nb_order'] ;
$data['bl_name'] = $this->input->post('bl_name') ;
$data['bl_address'] = $this->input->post('bl_address') ;
$data['bl_email'] = $this->input->post('bl_email') ;
$data['bl_phone'] = $this->input->post('bl_phone') ;
$data['dt_create'] = date('Y-m-d H:i:s') ;
$data['dt_modify'] = date('Y-m-d H:i:s') ;
return $data ;
}
function _frm_customer($pass='')
{
$data['cusmail'] = trim($this->input->post('email')) ;
$data['cuspass'] = md5($pass);
$data['cusname'] = $this->input->post('fullname') ;
$data['address'] = $this->input->post('address') ;
$data['cusphone'] = $this->input->post('phone') ;
$data['dt_create'] = date('Y-m-d H:i:s') ;
$data['bl_active'] = 1 ;
return $data ;
}
function getRandomString($length = 6)
{
$validCharacters = "abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ+-*#&@!?";
$validCharNumber = strlen($validCharacters);
$result = "";
for ($i = 0; $i<$length; $i++)
{
$index = mt_rand(0, $validCharNumber - 1);
$result .= $validCharacters[$index];
}
return $result;
}
function thanhcong()
{
$data['title'] = 'Đặt hàng thành công' ;
$data['cont'] = 'Cảm ơn bạn đã mua hàng tại website. Chúng tôi sẽ liên hệ trong thời gian sớm nhất';
$data['page'] = 'sanpham/thanhcong';
$this->load->view('html/skin', $data);
}
public function search()
{
$data['title'] = 'Tìm kiếm' ;
$keyword = $this->uri->segment(3) ;
$data['start'] = (int) $this->uri->segment(4) ;
$config['base_url'] = base_url().'sanpham/search/'.(int)$this->uri->segment(3);
$data['num'] = $this->sanpham->count_search($keyword);
$config['total_rows'] = $data['num'];
$config['per_page'] = 20;
$config['uri_segment'] = 4;
$config['num_links'] = 3 ;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['list'] = $this->sanpham->get_search($keyword, $config['per_page'],$data['start']);
$data['page'] = 'home/product';
$this->load->view('html/skin_product', $data);
}
}
?>