Exemplo n.º 1
0
 function notificacion($id_usuario, $id_venta)
 {
     // include_once("../controller/cMensajesEmail.php");
     include_once "../controller/cMensajesSMS.php";
     include_once "../controller/cFallidos.php";
     include_once "../model/mUsuarios.php";
     include_once "../model/mVentas.php";
     include_once '../model/mSistema.php';
     require_once '../controller/PHPMailer/PHPMailerAutoload.php';
     //Create a new PHPMailer instance
     $mail = new PHPMailer();
     //Set who the message is to be sent from
     $mail->setFrom('*****@*****.**', 'Temposatis');
     $mail->addReplyTo('*****@*****.**', 'Temposatis');
     $mail->CharSet = 'UTF-8';
     $cFallidos = new cFallidos();
     $mSistema = new mSistema();
     // $mail=new cMensajesEmail();
     $sms = new cMensajesSMS();
     $mUsuarios = new mUsuarios();
     $mVentas = new mVentas();
     $correosNotificaciones = $mSistema->getCorreos();
     $datosUsuario = $mUsuarios->getDatosUsuario($id_usuario);
     $datosVenta = $mVentas->getVenta($id_venta);
     $tipoContacto = $mUsuarios->getRelUsuariosContacto($id_usuario);
     /*****obtención de datos del usuario***/
     while ($row = $datosUsuario->fetch_array(MYSQLI_ASSOC)) {
         $nombre = $row['paterno'] . " " . $row['materno'] . " " . $row['nombre'];
         $correo = $row['correo'];
         $sucursal = $row['sucursal'];
         $telefono_movil = "52" . $row['telefono_movil'];
         $telefono = $row['telefono'];
     }
     /*****obtención de datos de la venta***/
     while ($row = $datosVenta->fetch_array(MYSQLI_ASSOC)) {
         $referencia = $row['referencia'];
         $marca = $row['marca'];
         $descripcion = $row['descripcion'];
         $numero_serie = $row['numero_serie'];
         $incentivo = $row['incentivo'];
     }
     /***envio de correos a los adminsitradores o quien este como nueva notificacion***/
     while ($fila = $correosNotificaciones->fetch_array(MYSQLI_ASSOC)) {
         //Set who the message is to be sent to
         $mail->ClearAddresses();
         $mail->addAddress($fila['descripcion']);
         //Set the subject line
         $mail->Subject = "Vendedor Registro nueva venta";
         $body = "<table border='1px'>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>SUCURSAL</th>\n\t\t\t\t\t\t\t<th>VENDEDOR</th>\n\t\t\t\t\t\t\t<th>CORREO DEL VENDEDOR</th>\n\t\t\t\t\t\t\t<th>TELÉFONO(S) DEL VENDEDOR</th>\n\t\t\t\t\t\t\t<th>REFERENCIA</th>\n\t\t\t\t\t\t\t<th>MARCA</th>\n\t\t\t\t\t\t\t<th>DESCRIPCIÓN</th>\n\t\t\t\t\t\t\t<th>NÚMERO DE SERIE</th>\n\t\t\t\t\t\t\t<th>INCENTIVO</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . strtoupper($sucursal) . "</td>\n\t\t\t\t\t\t\t<td>" . strtoupper($nombre) . "</td>\n\t\t\t\t\t\t\t<td>" . $correo . "</td>\n\t\t\t\t\t\t\t<td>" . $telefono . " " . $telefono_movil . "</td>\n\t\t\t\t\t\t\t<td>" . $referencia . "</td>\n\t\t\t\t\t\t\t<td>" . $marca . "</td>\n\t\t\t\t\t\t\t<td>" . $descripcion . "</td>\n\t\t\t\t\t\t\t<td>" . $numero_serie . "</td>\n\t\t\t\t\t\t\t<td>" . $incentivo . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>";
         $mail->msgHTML("<h1>SE HA REGISTRADO UNA NUEVA VENTA CON EL FOLIO: {$id_venta}. </h1>" . $body);
         //Replace the plain text body with one created manually
         $mail->AltBody = "Vendedor Registro nueva venta SUCURSAL:" . strtoupper($sucursal) . ". VENDEDOR:" . strtoupper($nombre) . ". CORREO:" . $correo . ". TELÉFONO:" . $telefono . " " . $telefono_movil . ". REFERENCIA:" . $referencia . ". MARCA:" . $marca . ". DESCRIPCIÓN:" . $descripcion . ". NÚMERO DE SERIE:" . $numero_serie . ". INCENTIVO:" . $incentivo;
         if (!$mail->send()) {
             // echo "Mailer Error: " . $mail->ErrorInfo;
             $cFallidos->setFallido($_SESSION['id_usuario'], $_SESSION['id_sucursal'], "Ocurrio error al enviar correo a :" . $fila['descripcion'] . " " . $mail->ErrorInfo, 2);
         }
         /*$mail->setDestinatario($fila['descripcion']);
         		$mail->setAsunto("Vendedor Registro nueva venta");
         		$mail->setBody("<h1>SE HA REGISTRADO UNA NUEVA VENTA CON EL FOLIO: $id_venta. </h1>".$body);
         		$mail->send();*/
     }
     /*****Envio de notificaciones al vendedor***/
     while ($row = $tipoContacto->fetch_array(MYSQLI_ASSOC)) {
         //mensaje al vendedor
         if ($row['id_tipo_contacto'] == 1) {
             //correo
             $body = "<table border='1px'>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>REFERENCIA</th>\n\t\t\t\t\t\t\t<th>MARCA</th>\n\t\t\t\t\t\t\t<th>DESCRIPCIÓN</th>\n\t\t\t\t\t\t\t<th>NÚMERO DE SERIE</th>\n\t\t\t\t\t\t\t<th>INCENTIVO</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . $referencia . "</td>\n\t\t\t\t\t\t\t<td>" . $marca . "</td>\n\t\t\t\t\t\t\t<td>" . $descripcion . "</td>\n\t\t\t\t\t\t\t<td>" . $numero_serie . "</td>\n\t\t\t\t\t\t\t<td>" . $incentivo . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>";
             $mail->ClearAddresses();
             $mail->addAddress($correo, $nombre);
             $mail->SUBJECT = "REGISTRO DE NUEVA VENTA";
             $mail->msgHTML("<h1>SE HA REGISTRADO UNA NUEVA VENTA CON EL FOLIO: {$id_venta}. </h1>" . $body);
             //Replace the plain text body with one created manually
             $mail->AltBody = "REGISTRO DE NUEVA VENTA. REFERENCIA:" . $referencia . ". MARCA:" . $marca . ". DESCRIPCIÓN:" . $descripcion . ". NÚMERO DE SERIE:" . $numero_serie . ". INCENTIVO:" . $incentivo;
             if (!$mail->send()) {
                 // echo "Mailer Error: " . $mail->ErrorInfo;
                 $cFallidos->setFallido($_SESSION['id_usuario'], $_SESSION['id_sucursal'], "Ocurrio error al enviar correo a :{$correo}" . $mail->ErrorInfo, 2);
             }
             /*$mail->setDestinatario($correo);
             		$mail->setAsunto("Registro de nueva venta");
             		$mail->setBody("<h1>SE HA REGISTRADO UNA NUEVA VENTA CON EL FOLIO: $id_venta.</h1>".$body);
             		$mail->send();*/
         } else {
             //sms
             if ($telefono_movil != "") {
                 //si contiene un telefono movil
                 // echo $telefono_movil;
                 include_once "../controller/cMensajesSMS.php";
                 $cMensajes = new cMensajesSMS();
                 $resp = $cMensajes->send($telefono_movil, "Se a registrado una nueva venta con el folio: {$id_venta}", false);
                 if (!$resp) {
                     return "\nmensaje enviado al numero " . $telefono_movil;
                 } else {
                     return strstr($resp, 'ERROR');
                 }
             }
             //fin if
         }
     }
 }
Exemplo n.º 2
0
<?php

if ($_POST) {
    include_once "../controller/cFallidos.php";
    include_once "../controller/cLibreria.php";
    $cLibreria = new cLibreria();
    $cFallidos = new cFallidos();
    switch ($_POST['opcion']) {
        case 'get':
            $datos = $cFallidos->getFallido($_POST['tipo'], $cLibreria->getFechaYMD($_POST['fecha_inicio']), $cLibreria->getFechaYMD($_POST['fecha_fin']));
            ?>
			<table class="table table-hover table-bordered table-striped" id="tabla" border="1" cellpadding="10" cellspacing="0">
			<thead>
				<tr>
					<th>Fecha de generación</th>
					<th>Tipo</th>
					<th>Descripción</th>
					<th>Vendedor</th>
					<th>Sucursal</th>
				</tr>
			</thead>
			<tbody>
				<?php 
            while ($row = $datos->fetch_array(MYSQLI_ASSOC)) {
                if ($row['tipo'] == 1) {
                    $msg = "<label class='bold'>PEDIDO FALLIDO</label>";
                } else {
                    $msg = "<label class='bold'>ENVIO DE CORREO FALLIDO</label>";
                }
                $vendedor = $row['paterno'] . " " . $row['materno'] . " " . $row['nombre'];
                echo "<tr>";
Exemplo n.º 3
0
 $cLibreria = new cLibreria();
 switch ($_POST['opcion']) {
     case 'setVentas':
         try {
             $id_ventas = $cVentas->setVentas($_POST['id_sucursal'], $_POST['id_usuario'], $_POST['comision_total']);
             //guardo la venta
             $cVentas->setVentasProductos($id_ventas, $_POST['id_producto'], $_POST['comision_total'], $_POST['num_serie']);
             //guardo la relacion de la venta con los productos
             $cVentas->notificacion($_POST['id_usuario'], $id_ventas);
             //envio un mensaje de notificacion
             $respuesta = array('resultado' => 1);
             echo json_encode($respuesta);
         } catch (Exception $e) {
             include_once '../controller/cFallidos.php';
             include_once '../controller/cProductos.php';
             $cFallidos = new cFallidos();
             $cProductos = new cProductos();
             $datos = $cProductos->getProducto($_POST['id_producto']);
             while ($row = $datos->fetch_array(MYSQLI_ASSOC)) {
                 $producto = $row['clave'] . "/" . $row['descripcion'];
             }
             $descripcion = "<h4>EL REGISTRO DE LA VENTA NO SE REALIZO CON EXITO.</h4>EL PRODUCTO A REGISTRAR ES: <b>" . strtoupper($producto . "/" . $_POST['num_serie']) . "</b> CON UNA COMISIÓN TOTAL DE: <b>" . $_POST['comision_total'] . "</b>";
             $cFallidos->setFallido($_POST['id_usuario'], $_POST['id_sucursal'], $descripcion, 1);
             $respuesta = array('error' => $e->getMessage());
             echo json_encode($respuesta);
         }
         break;
     case 'getDatosVenta':
         try {
             $datos = $cVentas->getDatosVenta($_POST['id_venta']);
             while ($row = $datos->fetch_array()) {