Viewing file: pedido-finalizar.php (17.37 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? $pagina_actual="administrar-productos"; $categoria_actual="productos"; require_once("includes/config.php"); require_once("includes/funciones.php");
require('../PHPMailer-master/PHPMailerAutoload.php');
if (isset($_POST["id"])){ extract($_POST, EXTR_SKIP);
$nuevo_estado='finalizado'; $result=$mysqli->query(" UPDATE pedido_carrito SET estado='".$nuevo_estado."', texto_oca='".$texto_oca."' WHERE id='".$id."' ");
$id_pedido=$id;
$result=$mysqli->query(" SELECT * FROM pedido_carrito WHERE id='".$id_pedido."' "); $pedido=mysqli_fetch_array($result);
$result=$mysqli->query(" SELECT tipo, valor FROM cupon WHERE id='".$pedido["id_cupon"]."' "); $cupon=mysqli_fetch_array($result);
$productos=$mysqli->query(" SELECT rpp.cantidad, rpp.precio, p.nombre, p.codigo, p.sku_individual, p.stock, p.id, rpp.atributos FROM renglon_pedido_producto rpp INNER JOIN producto p ON p.id=rpp.id_producto WHERE rpp.id_pedido='".$id_pedido."' ");
$result=$mysqli->query(" SELECT email FROM usuario_carrito WHERE id='".$pedido["id_usuario_carrito"]."' "); $usuario=mysqli_fetch_array($result);
$total=0; while ($item=mysqli_fetch_array($productos)){ $total+=$item["precio"]*$item["cantidad"];
//actualizo stock $result=$mysqli->query(" UPDATE producto SET stock='".($item["stock"]-$item["cantidad"])."', WHERE id='".$item["id"]."' "); }
$total_solo_productos=$total;
if ($cupon!=""){ if ($cupon["tipo"]=='$'){ $total-=$cupon["valor"]; } if ($cupon["tipo"]=='%'){ $total=$total*(100-$cupon["valor"])/100; } }
$total+=$pedido["costo_envio"];
$mail=' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>'.$nombre_empresa.'</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body style="margin: 0; padding: 0;"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="padding-top: 10px; padding-bottom 30px;"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="720" style="border: 1px solid #cccccc; border-collapse: collapse;"> <tr> <td bgcolor="'.$color_fondo_logo_email.'" style="padding: 15px; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;"> <img src="'.$url_instalacion.'mail/logo.png?e='.$nombre_empresa.'" alt="'.$nombre_empresa.'" width="402" height="134" style="display: block;" /> </td> </tr> <tr> <td bgcolor="#ffffff" style="padding-top: 40px; padding-right: 30px; padding-bottom: 40px; padding-left: 30px;"> <!-- MENSAJE BIENVENIDO --> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-top: 10px;border-bottom: 1px solid #D0D0D0;"> <tr> <td style="padding-bottom: 10px; padding-top:0; color: '.$color_texto_resaltado_email.'; font-family: Arial, sans-serif; font-size: 18px;"> <b>Hola '.$pedido["personal_nombre"].'!</b> </td> </tr> <tr> <td style="padding-bottom: 10px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> <b>Información adicional de su compra:</b> </td> </tr> <tr> <td style="padding-bottom: 10px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> <b>'.$texto_oca.'</b> </td> </tr> <tr> <td style="padding-bottom: 10px; padding-top:0; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> Detallamos el pedido solicitado a través de nuestra tienda en línea</td> </tr> </table> <!-- FIN MENSAJE BIENVENIDO --> <!-- MENSAJE ORDEN DE COMPRA --> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-top: 20px;"> <tr> <td style="padding-bottom: 10px; padding-top: 20px; color: '.$color_texto_resaltado_email.'; font-family: Arial, sans-serif; font-size: 16px;"> <b>ORDEN DE COMPRA Nº '.$id_pedido.'</b> </td> </tr> <tr> <td style="padding-bottom: 6px; padding-top:0px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> <b>Fecha: </b>'.ver_fecha_mysql_lindo($pedido["fecha"]).'</b> </td> </tr>'; $productos->data_seek(0); while ($item=mysqli_fetch_array($productos)){ $mail.=' <tr> <td style="padding-top: 5px; padding-bottom: 5px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px; border-bottom: 1px solid #D0D0D0;"><table width="100%"> <tbody> <tr> <td width="19%">Cod: '.$item["sku_individual"].'</td> <td width="59%">'.utf8_encode($item["nombre"]).utf8_encode($item["atributos"]).'</td> <td width="8%">Cant: '.$item["cantidad"].'</td> <td width="3%">$</td> <td width="9%" align="right">'.$item["precio"]*$item["cantidad"].'</td> <td width="2%"> </td> </tr> </tbody></table></td> </tr> '; }
$mail.=' <tr> <td style="padding-top: 5px; padding-bottom: 5px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px; border-bottom: 1px solid #D0D0D0;"> '; if (isset($cupon["valor"])){
$mail.='
<table width="100%" style="background-color:#669933;"> <tbody> <tr> <td width="86%" style="color: #fff;">Cupón de descuento aplicado</td> <td width="3%" style="color: #fff;"><b>'.$cupon["tipo"].'-</b></td> <td width="9%" align="right" style="color: #fff;">'.$cupon["valor"].'</td> <td width="2%" style="color: #fff;"> </td> </tr> </tbody> </table> ';
}
$mail.=' <table width="100%"> <tbody> <tr> <td width="86%">Costo de envío (<b>'.$pedido["tipo_envio"].'</b>)</td> <td width="3%">$</td> <td width="9%" align="right">'.$pedido["costo_envio"].'</td> <td width="2%"> </td> </tr> </tbody> </table> </td> </tr> ';
$mail.=' <tr> <td align="right" style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px; border-bottom: 1px solid #D0D0D0; background-color:#EEE;"> <b>TOTAL DE LA COMPRA $ '.$total.'</b> </td> </tr> </table> <!-- FIN MENSAJE ORDEN DE COMPRA -->
';
$mail.=' <!-- MENSAJE METODO DE ENVIO --> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-top: 20px;border-bottom: 1px solid #D0D0D0;"> ';
$mail.=' </table> <!-- FIN MENSAJE METODO DE ENVIO --> <!-- MENSAJE SALUTE --> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-top: 20px;"> <tr> <td style="padding-bottom: 10px; padding-top:20px; font-family: Arial, sans-serif; font-size: 14px;"> <b>Gracias por utilizar nuestra tienda y servicios On-line</b> </td> </tr> <tr> <td style="padding-bottom: 10px; padding-top:0; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> Ante cualquier duda, puede enviarnos un mail a '.$email_pedidos.' con el número de su pedido o llámenos '.$telefonos_pedidos.'. </td> </tr> <tr> <td style="padding-bottom: 10px; padding-top:0; color: #153643; font-family: Arial, sans-serif; font-size: 12px; line-height: 20px;"> Saludos!<br /> El equipo de '.$nombre_empresa.' </td> </tr> </table> <!-- FIN MENSAJE SALUTE --> </td> </tr> <tr> <td bgcolor="'.$color_fondo_logo_email.'" style="padding-top: 30px; padding-left: 30px; padding-bottom: 30px; padding-right: 30px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="color: #fff; font-family: Arial, sans-serif; font-size: 14px;" width="71%"> © 2016 '.$nombre_empresa.'<br/> <a href="'.$url_instalacion.'" style="color: #ffffff;"><font color="#fff">'.$url_instalacion.'</font></a><br/> '.$direccion_retira_en_local.' </td> <td align="right" width="29%"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> <a href="'.$redes_sociales["facebook"].'" target="_blank" style="color: #ffffff;"> <img src="'.$url_instalacion.'mail/fb.gif" alt="Twitter" width="38" height="38" style="display: block;" border="0" /> </a> </td> <td style="font-size: 0; line-height: 0;" width="10"> </td> <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> <a href="'.$redes_sociales["twitter"].'" target="_blank" style="color: #ffffff;"> <img src="'.$url_instalacion.'mail/tw.gif" alt="Twitter" width="38" height="38" style="display: block;" border="0" /> </a> </td> <td style="font-size: 0; line-height: 0;" width="10"> </td> <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> <a href="'.$redes_sociales["pinterest"].'" target="_blank" style="color: #ffffff;"> <img src="'.$url_instalacion.'mail/pt.gif" alt="Twitter" width="38" height="38" style="display: block;" border="0" /> </a> </td> <td style="font-size: 0; line-height: 0;" width="10"> </td> <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;"> <a href="'.$redes_sociales["instagram"].'" target="_blank" style="color: #ffffff;"> <img src="'.$url_instalacion.'mail/in.gif" alt="Facebook" width="38" height="38" style="display: block;" border="0" /> </a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table>
</body> </html> ';
//echo $mail;
$titulo = 'Detalle de envío de su compra | '.$nombre_empresa;
$php_email = new PHPMailer();
/* autentificacion */ $php_email->IsSMTP(); //$php_email->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $php_email->Host = "smtp.gmail.com"; $php_email->Port = 587; $php_email->SMTPSecure = 'tls'; $php_email->SMTPAuth = true; $php_email->Username = "posicionamientocds@gmail.com"; $php_email->Password = "nacho123"; /* Fin autentificacion */
$php_email->From = $email_para_enviar; $php_email->FromName = $nombre_empresa; $php_email->Subject = utf8_decode($titulo); $php_email->Body = utf8_decode($mail); $php_email->IsHTML(true);
$php_email->AddAddress( $usuario["email"] );
$php_email->Send();
//email para le empresa
$titulo = 'Detalle de envío de su compra | '.$nombre_empresa;
$php_email = new PHPMailer();
/* autentificacion */ $php_email->IsSMTP(); //$php_email->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $php_email->Host = "smtp.gmail.com"; $php_email->Port = 587; $php_email->SMTPSecure = 'tls'; $php_email->SMTPAuth = true; $php_email->Username = "posicionamientocds@gmail.com"; $php_email->Password = "nacho123"; /* Fin autentificacion */
$php_email->From = $email_para_enviar; $php_email->FromName = $nombre_empresa; $php_email->Subject = utf8_decode($titulo); $php_email->Body = utf8_decode($mail); $php_email->IsHTML(true);
foreach ($array_emails_pedidos as $clave => $valor){ $php_email->AddAddress( $valor ); }
$php_email->Send();
header('Location: administrar-pedidos.php?filtro=finalizado'); }
if (isset($_GET["id"])){ $id=cadena_segura($_GET["id"],11); $result=$mysqli->query(" SELECT c.id, c.fecha, c.total, u.email FROM pedido_carrito c INNER JOIN usuario_carrito u ON u.id=c.id_usuario_carrito WHERE c.id='$id' "); $item = mysqli_fetch_assoc($result); $productos = $mysqli->query(" SELECT p.id, p.nombre, rpc.cantidad, rpc.precio, p.codigo, rpc.atributos FROM producto p INNER JOIN renglon_pedido_producto rpc ON rpc.id_producto=p.id WHERE rpc.id_pedido='".$item["id"]."' "); ?> <div class="modal-content"> <form method="post" action="pedido-finalizar.php"> <input type="hidden" name="id" value="<?=$id?>"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title"></h4> </div> <div class="modal-body"> <div class="form-group"> <h4>Orden de compra #<?=$item["id"]?></h4> <table border="1" class="table-padding-10"> <thead> <tr><th>Codigo</th> <th> Producto </th> <th> Cant</th> <th> Precio/u</th> <th> Total </th> </tr> </thead> <tbody> <? while ($producto = mysqli_fetch_assoc($productos)){?> <tr> <td> <?=$producto["codigo"]?> </td> <td> <?=utf8_encode($producto["nombre"]).utf8_encode($producto["atributos"])?> </td> <td> <?=$producto["cantidad"]?> </td> <td> <?=$producto["precio"]?> </td> <td> <?=$producto["precio"]*$producto["cantidad"]?> </td> </tr> <? }?> </tbody> </table> </div>
<div class="form-horizontal">
<div class="form-group"> <label class="col-sm-3">Información adicional: </label> <div class="col-sm-9"> <textarea name="texto_oca" class="seis_lineas form-control" placeholder="Código de seguimiento Oca o información adicional"></textarea> </div>
</div>
</div> </div> <div class="modal-footer"> <p class="text-info">Al finalizar el pedido, confirmará que el mismo ya fue recibido por el cliente y se moverá a pedidos finalizados</p> <a href="#" class="btn btn-white" data-dismiss="modal">Cerrar</a> <input type="submit" class="btn btn-primary" value="Finalizar"> </div> </form> </div><!-- /.modal-content --> <? }?>
|