assign("header_banner_url",$banner[0]['url']); $smarty->assign("header_banner_title",$banner[0]['title']); $smarty->assign("header_banner_img",$banner[0]['filename']); if(!empty($_GET['audio_id'])) $audio_id = $_GET['audio_id']; if(!empty($_POST['audio_id'])){ $error_msg = ''; if(empty($_POST['email']) OR empty($_POST['nombre']) OR empty($_POST['apellidos']) OR empty($_POST['condiciones_legales']) OR empty($_POST['pais'])) $error_msg = 'Por favor rellene TODOS los campos y acepte las Condiciones Legales.'; $smarty->assign('post_data',$_POST); if(!strlen($error_msg)) { $audio_id = $_POST['audio_id']; $email = $_POST['email']; $name = $_POST['nombre'].' '.$_POST['apellidos']; $pais = $_POST['pais']; mysql_query("INSERT INTO tmp_shop (email, name, guia_id, pais) values ('".$email."', '".addslashes($name)."', '".$audio_id."','".$pais."')"); $shop_id = mysql_insert_id(); $smarty->assign('email',$_POST['email']); $smarty->assign('guia_id',$_POST['audio_id']); $smarty->assign('shop_id',$shop_id); $buy = true; if(!empty($_POST['cupon'])){ $active = 0; $code = $_POST['cupon']; $active = check_cupon($code, $audio_id); if($active){ //################################################################################### send order per email $shop = get_shop_data($shop_id); $audio_id = $shop['guia_id']; $guia = get_guia($audio_id); $file_url = 'http://www.audioguiasonline.es/downloads/'.$guia['filename']; if($guia['amazon']) $file_url = 'https://s3.amazonaws.com/audioguias/'.$guia['filename']; $subject = 'Compra de la Audioguia '.$guia['titulo']; $body = '

Hola '.$shop['name'].'

Ha comprado la '.$guia['titulo'].' la cual la puede descargar desde esta direccion:

'.$file_url.'

Si tiene alguna duda puede contactarnos en info@audioguiasonline.com y le contestaremos por correo electrónico o teléfono o consulte el apartado de ayuda

Muchas Gracias por su compra

AudioguiasOnline.es

'; require_once ABS_PATH.'/system/swiftmailer5/swift_required.php'; //Create the Transport $transport = Swift_SmtpTransport::newInstance('mail.audioguiasonline.com', 25) ->setUsername('sales@audioguiasonline.com') ->setPassword('ventas2016') ; //Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); //Create a message $message = Swift_Message::newInstance($subject) ->setFrom(array('sales@audioguiasonline.com' => 'AudioguiasOnline')) ->setTo(array($shop['email'] => $shop['name'])) ->setBcc(array("info@audioguiasonline.com" => "AudioguiasOnline")) ->setBody($body, 'text/html', 'utf-8') ; //Send the message $result = $mailer->send($message); mysql_query("INSERT INTO ventas (email, nombre, guia_id, guia_titulo, precio, date, member_id, pais, cupon) values ('".$shop['email']."', '".addslashes($shop['name'])." ".$_SESSION["shop"]['apellidos']."', '".$audio_id."', '".addslashes($guia['titulo'])."', '".$guia['precio']."', now(), '".$guia['member_id']."','".$shop['pais']."','".$code."')"); mysql_query("UPDATE guia_cupones SET status = 0 WHERE guia_id = '$audio_id' AND code = '$code'"); //################################################################################### send order per email $buy_cupon = true; } else { $error_msg = 'El Cupón no es correcto o a caducado.'; $smarty->assign('error_msg',$error_msg); $buy = false; $buy_cupon = false; } } } else { $_SESSION["shop"] = array(); $smarty->assign('error_msg',$error_msg); } } $guia = get_guia($audio_id); //print_r($guia); $smarty->assign('guia',$guia); $css = get_cssbackground(); $smarty->assign("css",$css); if($buy_cupon) { $smarty->display($templatepath.'gracias.tpl'); } elseif($buy) { $smarty->display($templatepath.'pago.tpl'); } else { $smarty->display($templatepath.'comprar_audioguia.tpl'); } ?>