Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function thanhtoan($session)
- {
- global $oDb , $oSmarty;
- $sTbl2 = "tblproduct";
- $query = "SELECT * FROM $this->table t1 join {$sTbl2} t2 on(t1.product_id=t2.Product_ID) WHERE t1.sessionid='$session' and completed<>'1' ORDER BY id ";
- $result = $oDb->getAll($query);
- $total = 0;
- $count=0;
- foreach ($result as $key => $value) {
- $subtotal = $value['Product_Price']*$value['quantity'];
- $result[$key]['subtotal'] = $subtotal;
- $total = $total + $subtotal;
- $count = $count+$value['quantity'];
- }
- if (isset($_SESSION['user_id'])) {
- $user = $oDb->getRow("SELECT * FROM user WHERE id= {$_SESSION['user_id']}");
- $oSmarty->assign('user',$user);
- }
- if($_SERVER['REQUEST_METHOD']=='POST')
- {
- //$to = "khanhnk@bsg.vn";
- $info = array(
- "name" => $_POST['shipping_name'],
- "email" => $_POST['shipping_emaill'],
- "address" => $_POST['txt_address'],
- "phone" => $_POST['shipping_phone'],
- "tour_name" => $tour['title'],
- );
- $oSmarty->assign('info',$info);
- $oSmarty->assign('cart',$result);
- $oSmarty->assign('total',$total);
- $content = $oSmarty->fetch('checkout_mail_content.tpl');
- $subject = $oSmarty->get_config_vars('title_mail_shopping');
- $contacts = $this -> getContact();
- if( $contacts )
- {
- foreach( $contacts as $key => $val)
- {
- //@mail( $val['email'], $subject, $content, $headers );
- }
- }
- else
- {
- $contact = getConfig('email_contact');
- //@mail( $contact, $subject, $content, $headers );
- }
- /* remove cart */
- $info_cart="<ul>";
- foreach($result as $key => $value)
- {
- $info_cart.="<li>
- <b>".$value["Product_Title"]."</b><br>
- Mã sản phẩm : ".$value["Product_Code"]."
- <Br>Số lượng đặt mua: ".$value["quantity"]."<br>
- Đơn giá: ".$value["Product_Price"]." vnđ
- </li>";
- }
- $info_cart.="</ul>";
- $oDb->query("insert into tbl_shopping_cart_info (name,email,address,tell,tex_info,info_cart,total) values('{$info['name']}','{$info['email']}','{$info['address']}','{$info['phone']}','{$info['addition_request']}','{$info_cart}',{$total})");
- // $this->removeCart($session);
- $langid = $_SESSION['lang_id'];
- $sql1 = "SELECT email FROM tblconfig WHERE lang_id='{$langid}' LIMIT 1";
- $email = $oDb->getOne($sql1);
- include("lib/phpmailer/class.phpmailer.php");
- $mailer = new PHPMailer(); // khởi tạo đối tượng
- $mailer->IsSMTP(); // gọi class smtp để đăng nhập
- $mailer->CharSet="utf-8"; // bảng mã unicode
- //Đăng nhập Gmail
- $mailer->SMTPAuth = true; // Đăng nhập
- $mailer->SMTPSecure = "ssl"; // Giao thức SSL
- $mailer->Host = "smtp.gmail.com"; // SMTP của GMAIL
- $mailer->Port = 465; // cổng SMTP
- // Phải chỉnh sửa lại
- $mailer->Username = "mr.ken84@gmail.com"; // GMAIL username
- $mailer->Password = "ngockien.tk"; // GMAIL password
- //$contacts = $email;
- $contacts = "hllfrv@gmail.com";
- $mailer->AddAddress($contacts,'Ban quản trị website'); //email người nhận
- //$mailer->AddAddress($contacts1,'Ban quản trị website');
- $mailer->AddReplyTo("{$_POST['txt_email']}","{$_POST['txt_name']}");
- // Chuẩn bị gửi thư nào
- $mailer->FromName = $_POST['txt_name']; // tên người gửi
- $mailer->From = $_POST['txt_email']; // mail người gửi
- $mailer->Subject = 'Đơn đặt hàng từ khách hàng website trang sức!';
- $mailer->IsHTML(true); //Bật HTML không thích thì false
- // Nội dung lá thư
- $mailer->Body = "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
- <tr>
- <td width=\"110\">Họ và tên</td>
- <td width=\"15\"> </td>
- <td width=\"375\">{$_POST['txt_name']}</td>
- </tr>
- <tr>
- <td>Điện thoại di động</td>
- <td> </td>
- <td>{$_POST['txt_phone']}</td>
- </tr>
- <tr>
- <td>Điện thoại cố định</td>
- <td> </td>
- <td>{$_POST['txt_phonehome']}</td>
- </tr>
- <tr>
- <td>Email</td>
- <td> </td>
- <td>{$_POST['txt_email']}</td>
- </tr>
- <tr>
- <td width=\"110\">Địa chỉ</td>
- <td width=\"15\"> </td>
- <td width=\"375\">{$_POST['txt_address']}</td>
- </tr>
- <tr>
- <td colspan=\"3\"><b>Đơn hàng :</b></td>
- </tr>
- <tr>
- <td colspan=\"3\">{$info_cart}</td>
- </tr>
- <tr>
- <td width=\"110\">Tổng tiền </td>
- <td width=\"15\"> </td>
- <td width=\"375\">{$total} vnđ</td>
- </tr>
- <tr>
- <td colspan=\"3\">Nội dung</td>
- </tr>
- <tr>
- <td colspan=\"3\">{$_POST['txt_addition_request']}</td>
- </tr>
- </table>";
- // Gửi email
- $oSmarty -> assign("msg", $oSmarty->get_config_vars('send_contact_succes'));
- $msg=1;
- $oSmarty->assign('msg',$msg);
- if(!$mailer->Send())
- {
- }
- $oSmarty -> assign("msg", $oSmarty->get_config_vars('checkout_success'));
- $_sucess=1;
- $oSmarty->assign('_sucess',$_sucess);
- //$oSmarty -> display("checkout_success.tpl");
- }
- else
- {
- if($_SERVER['REQUEST_METHOD']=='POST')
- {
- $_error=$oSmarty->get_config_vars("error_security");
- }
- $oSmarty -> assign("msg", $_error);
- $_sucess=0;
- $oSmarty->assign('tour',$tour);
- $oSmarty->assign('total',$total);
- $oSmarty->assign('count',$count);
- $oSmarty->display("thanhtoanCart.tpl");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement