Exemple #1
0
 /**
  * @param str/string valor es una cadena con cualquier serie de simbolos
  * @param int/integer valor es una cadena con cualquier serie de simbolos
  * @return str/string      si es la entrada cumple con los requerimientos
  * @soap
  */
 public function verBoletos($referencia = false, $numeroBoletos = false)
 {
     $error = array('codigo' => -1, 'popsae' => 1, 'msg' => "No se encontro el error.", "visible" => 1);
     $formatoInterno = 'BoletoFormatoSimple';
     $eventos = array(539, 558);
     $servicios = new Servicios($referencia);
     // echo CHtml::openTag("pre");
     //Validar que el numero de boletos que se vendieron sea igual al de la referencia xxxxxxxxxxNN
     $lugares = $servicios->buscarBoletos($referencia, $numeroBoletos);
     $tickets = array();
     $coords = Formatosimpresionlevel1::model()->findAllByAttributes(array('FormatoId' => 3));
     $matrizCoord = array();
     require_once dirname(__FILE__) . '/../extensions/cbarras/ean.php';
     foreach ($coords as $coord) {
         $matrizCoord[$coord->FormatoObj] = array($coord->FormatoX, $coord->FormatoY);
     }
     foreach ($lugares as $lugar) {
         // print_r($lugar);
         $encoder = new EAN13($lugar->LugaresNumBol, 2);
         $fila = explode(',', str_replace('  ', ' ', $lugar->fila->FilasAli));
         $fali = array_pop($fila);
         $imaBol = "";
         try {
             if (in_array($lugar->EventoId, $eventos)) {
                 $formatoInterno = 'BoletoFormatoUdlap';
             }
             if (strlen($lugar->evento->EventoImaBol) > 0) {
                 $imaBol = base64_encode(@file_get_contents('http://taquillacero.com/imagesbd/' . $lugar->evento->EventoImaBol));
             }
         } catch (Exception $e) {
             // $error['codigo']=601;
             // $error['msg']="No se encontro la imagen del boleto.";
             // $error['popsae']=2;
         }
         $tickets[] = array('SubzonaAcc' => $lugar->subzona->SubzonaAcc, 'ZonasAli' => $lugar->zona->ZonasAli . " " . array_pop($fila), 'FilasAli' => $fali, 'LugaresLug' => $lugar->lugar->LugaresLug, 'VentasBolTip' => $lugar->VentasBolTip, 'VentasCosBol' => number_format($lugar->precios->VentasCosBol, 0), 'VentasCarSer' => number_format($lugar->precios->VentasCarSer), 'EventoDesBol' => $lugar->evento->EventoDesBol, 'EventoNom' => $lugar->evento->EventoNom, 'ForoNom' => $lugar->foro->ForoNom, 'funcionesTexto' => $lugar->funcion->funcionesTexto, 'VentasCon' => $lugar->VentasCon, 'LugaresNumBol' => $lugar->LugaresNumBol, 'codigo' => base64_encode($encoder->display()), 'contenedor1' => $imaBol);
     }
     $boletos = array('boletos' => $tickets);
     // echo "<pre>";
     $e = Yii::app()->mustache->render($formatoInterno, $boletos, null, null, false);
     $jes = CJSON::decode($e);
     $ret = array();
     array_pop($jes);
     // var_export($jes);
     foreach ($jes as $boleto) {
         foreach ($boleto as $key => $item) {
             try {
                 if (array_key_exists($key, $matrizCoord)) {
                     $boleto[$key][0] += $matrizCoord[$key][0];
                     $boleto[$key][1] += $matrizCoord[$key][1];
                 }
             } catch (Exception $e) {
             }
         }
         $ret[] = array_values($boleto);
     }
     // print_r($ret);
     // echo "</pre>";
     // echo CHtml::closeTag('pre');
     return CJSON::encode(array("error" => $error, "venta" => $ret));
 }
Exemple #2
0
 public function actionImpresionBoletosAjax2()
 {
     $this->perfil();
     ini_set('memory_limit', '-1');
     set_time_limit(0);
     if (!empty($_POST['formatoId'])) {
         $pv = $_POST['pv'];
         $EventoId = $_POST['EventoId'];
         $FuncionId = $_POST['FuncionId'];
         $todos = "";
         $ref = "";
         if ($_POST['tipo_impresion'] == "no_impresos") {
             $todos = "  ventaslevel1.VentasCon='' AND ";
         }
         if ($_POST['tipo_impresion'] == "referencia") {
             $ref = "  ventas.VentasNumRef IN(" . $_POST['refs'] . ") AND ";
         }
         $data = array();
         $query = "(SELECT  ventas.VentasId as id, \n                                    funciones.funcionesTexto as fnc, \n                                    lugares.LugaresLug,\n                                    filas.FilasAli,\n                                    zonas.ZonasAli,\n                                    subzona.SubzonaAcc,\n                                    evento.EventoDesBol,\n                                    evento.EventoNom,\n                                    evento.EventoImaBol,\n                                    foro.ForoNom,\n                                    ventaslevel1.EventoId,\n                                    ventaslevel1.FuncionesId,\n                                    ventaslevel1.ZonasId,\n                                    ventaslevel1.SubzonaId,\n                                    ventaslevel1.FilasId,\n                                    ventaslevel1.LugaresId,\n                                    ventaslevel1.VentasBolTip,\n                                    ventaslevel1.VentasCon,\n                                    ventaslevel1.VentasCarSer,\n                                    ventaslevel1.LugaresNumBol,\n                                    (ventaslevel1.VentasCosBol-ventaslevel1.VentasMonDes) as cosBol,\n                                    (ventaslevel1.VentasCosBol-ventaslevel1.VentasMonDes + ventaslevel1.VentasCarSer) as cosBolCargo,\n                                    ventas.UsuariosId,\n                                    ventas.VentasNumRef,\n                                    ventas.PuntosventaId,\n                                    ventas.VentasFecHor,\n                                    ventas.VentasNumTar,\n                                    ventas.VentasNomDerTar\n\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\tlugares\n\t\t\t\t\t\t\t\t\tINNER JOIN funciones ON funciones.FuncionesId = lugares.FuncionesId AND funciones.EventoId = lugares.EventoId\n\t\t\t\t\t\t\t\t\tINNER JOIN ventaslevel1 ON (lugares.EventoId=ventaslevel1.EventoId)\n\t\t\t\t\t\t\t\t\tAND (lugares.FuncionesId=ventaslevel1.FuncionesId)\n\t\t\t\t\t\t\t\t\tAND (lugares.ZonasId=ventaslevel1.ZonasId)\n\t\t\t\t\t\t\t\t\tAND (lugares.SubzonaId=ventaslevel1.SubzonaId)\n\t\t\t\t\t\t\t\t\tAND (lugares.FilasId=ventaslevel1.FilasId)\n\t\t\t\t\t\t\t\t\tAND (lugares.LugaresId=ventaslevel1.LugaresId)\n                                    INNER JOIN evento ON evento.EventoId = ventaslevel1.EventoId\n                                    INNER JOIN foro ON foro.ForoId = evento.ForoId\n\t\t\t\t\t\t\t\t\tINNER JOIN filas ON (filas.EventoId=lugares.EventoId)\n\t\t\t\t\t\t\t\t\tAND (filas.FuncionesId=lugares.FuncionesId)\n\t\t\t\t\t\t\t\t\tAND (filas.ZonasId=lugares.ZonasId)\n\t\t\t\t\t\t\t\t\tAND (filas.SubzonaId=lugares.SubzonaId)\n\t\t\t\t\t\t\t\t\tAND (filas.FilasId=lugares.FilasId)\n\t\t\t\t\t\t\t\t\tINNER JOIN zonas ON (zonas.EventoId=filas.EventoId)\n\t\t\t\t\t\t\t\t\tAND (zonas.FuncionesId=filas.FuncionesId)\n\t\t\t\t\t\t\t\t\tAND (zonas.ZonasId=filas.ZonasId)\n\t\t\t\t\t\t\t\t\tINNER JOIN ventas ON (ventas.VentasId=ventaslevel1.VentasId)\n\t\t\t\t\t\t\t\t\tINNER JOIN subzona ON (subzona.EventoId=filas.EventoId)\n\t\t\t\t\t\t\t\t\tAND (subzona.FuncionesId=filas.FuncionesId)\n\t\t\t\t\t\t\t\t\tAND (subzona.ZonasId=filas.ZonasId)\n\t\t\t\t\t\t\t\t\tAND (subzona.SubzonaId=filas.SubzonaId)\n\t\t\t\t\t\t\t\t\tAND (zonas.EventoId=subzona.EventoId)\n\t\t\t\t\t\t\t\t\tAND (zonas.FuncionesId=subzona.FuncionesId)\n\t\t\t\t\t\t\t\t\tAND (zonas.ZonasId=subzona.ZonasId)\n\t\t\t\t\t\t\t\t\tWHERE\n                                    {$todos} \n                                    {$ref}\n                                    ventaslevel1.VentasSta not like '%CANCELADO%' AND \n\t\t\t\t\t\t\t\t\t(lugares.EventoId = {$EventoId} ) AND \n\t\t\t\t\t\t\t\t\t(lugares.FuncionesId = {$FuncionId} ) AND\n\t\t\t\t\t\t\t\t\t((ventas.PuntosventaId = '{$pv}')) AND \n\t\t\t\t\t\t\t\t\tNOT (ventas.VentasNumRef = ''))\n\t\t\t\t\t\t\t\t\tORDER BY  fnc ,ZonasAli,filasAli,LugaresLug;";
         $dataCodigo = new CSqlDataProvider($query, array('pagination' => false));
         $data = $dataCodigo->getData();
         $newdata = array();
         foreach ($data as $key => $boletoreimpresion) {
             $codigo = $this->verificaCodigos();
             if (empty($boletoreimpresion['LugaresNumBol'])) {
                 //$this->imprimeBoleto($codigo,$boletoreimpresion['id'],$boletoreimpresion['EventoId'],$boletoreimpresion['FuncionesId'],$boletoreimpresion['ZonasId'],$boletoreimpresion['SubzonaId'],$boletoreimpresion['FilasId'],$boletoreimpresion['LugaresId'],$boletoreimpresion['UsuariosId']);
                 $contra = $boletoreimpresion['EventoId'] . "." . $boletoreimpresion['FuncionesId'] . "." . $boletoreimpresion['ZonasId'] . "." . $boletoreimpresion['SubzonaId'];
                 $contra .= "." . $boletoreimpresion['FilasId'] . "." . $boletoreimpresion['LugaresId'] . "-" . date("m") . "." . date("d") . "-" . $boletoreimpresion['UsuariosId'];
                 $contra .= "R";
                 $ventaslevel1 = Ventaslevel1::model()->findByAttributes(array('VentasId' => $boletoreimpresion['id'], 'EventoId' => $boletoreimpresion['EventoId'], 'FuncionesId' => $boletoreimpresion['FuncionesId'], 'ZonasId' => $boletoreimpresion['ZonasId'], 'SubzonaId' => $boletoreimpresion['SubzonaId'], 'FilasId' => $boletoreimpresion['FilasId'], 'LugaresId' => $boletoreimpresion['LugaresId']));
                 $ventaslevel1->LugaresNumBol = $codigo;
                 $ventaslevel1->VentasCon = $contra;
                 $ventaslevel1->update();
                 $newdata[$key]['LugaresNumBol'] = $codigo;
                 $newdata[$key]['VentasCon'] = $contra;
                 $newdata[$key]['cosBolCargo'] = $boletoreimpresion['cosBolCargo'];
                 $newdata[$key]['FilasAli'] = $boletoreimpresion['FilasAli'];
                 $newdata[$key]['LugaresLug'] = $boletoreimpresion['LugaresLug'];
                 $newdata[$key]['ZonasAli'] = $boletoreimpresion['ZonasAli'];
                 $newdata[$key]['VentasNumRef'] = $boletoreimpresion['VentasNumRef'];
                 $newdata[$key]['EventoNom'] = $boletoreimpresion['EventoNom'];
                 $newdata[$key]['ForoNom'] = $boletoreimpresion['ForoNom'];
                 $newdata[$key]['SubzonaAcc'] = $boletoreimpresion['SubzonaAcc'];
                 $newdata[$key]['EventoDesBol'] = $boletoreimpresion['EventoDesBol'];
                 $newdata[$key]['fnc'] = $boletoreimpresion['fnc'];
                 $newdata[$key]['VentasBolTip'] = $boletoreimpresion['VentasBolTip'];
                 $newdata[$key]['cosBol'] = $boletoreimpresion['cosBol'];
                 $newdata[$key]['VentasCarSer'] = $boletoreimpresion['VentasCarSer'];
                 $newdata[$key]['EventoImaBol'] = $boletoreimpresion['EventoImaBol'];
                 $newdata[$key]['id'] = $boletoreimpresion['id'];
                 $newdata[$key]['PuntosventaId'] = $boletoreimpresion['PuntosventaId'];
                 $newdata[$key]['VentasFecHor'] = $boletoreimpresion['VentasFecHor'];
                 $newdata[$key]['VentasNumTar'] = $boletoreimpresion['VentasNumTar'];
                 $newdata[$key]['VentasNomDerTar'] = $boletoreimpresion['VentasNomDerTar'];
             } else {
                 //$this->reimprimeBoleto($codigo,$boletoreimpresion['id'],$boletoreimpresion['EventoId'],$boletoreimpresion['FuncionesId'],$boletoreimpresion['ZonasId'],$boletoreimpresion['SubzonaId'],$boletoreimpresion['FilasId'],$boletoreimpresion['LugaresId'],$boletoreimpresion['UsuariosId'],$boletoreimpresion['LugaresNumBol'],$boletoreimpresion['VentasBolTip'],$boletoreimpresion['cosBol']);
                 $reimpresiones = Reimpresiones::model()->count(array('condition' => "EventoId=" . $boletoreimpresion['EventoId'] . " AND FuncionesId=" . $boletoreimpresion['FuncionesId'] . " AND ZonasId=" . $boletoreimpresion['ZonasId'] . " AND SubzonaId=" . $boletoreimpresion['SubzonaId'] . " AND FilasId=" . $boletoreimpresion['FilasId'] . " AND LugaresId=" . $boletoreimpresion['LugaresId']));
                 $contra = $boletoreimpresion['EventoId'] . "." . $boletoreimpresion['FuncionesId'] . "." . $boletoreimpresion['ZonasId'] . "." . $boletoreimpresion['SubzonaId'];
                 $contra .= "." . $boletoreimpresion['FilasId'] . "." . $boletoreimpresion['LugaresId'] . "-" . date("m") . "." . date("d") . "-" . $boletoreimpresion['UsuariosId'];
                 $contra .= "PR{$reimpresiones}";
                 $ventaslevel1 = Ventaslevel1::model()->findByAttributes(array('VentasId' => $boletoreimpresion['id'], 'EventoId' => $boletoreimpresion['EventoId'], 'FuncionesId' => $boletoreimpresion['FuncionesId'], 'ZonasId' => $boletoreimpresion['ZonasId'], 'SubzonaId' => $boletoreimpresion['SubzonaId'], 'FilasId' => $boletoreimpresion['FilasId'], 'LugaresId' => $boletoreimpresion['LugaresId']));
                 $ventaslevel1->LugaresNumBol = $codigo;
                 $ventaslevel1->VentasCon = $contra;
                 $ventaslevel1->update();
                 $ultimo = Reimpresiones::model()->findAll(array('limit' => 1, 'order' => 't.ReimpresionesId DESC'));
                 $ultimo = $ultimo[0]->ReimpresionesId + 1;
                 $hoy = date("Y-m-d G:i:s");
                 $user_id = Yii::app()->user->id;
                 Yii::app()->db->createCommand("INSERT INTO reimpresiones VALUES({$ultimo}," . $boletoreimpresion['EventoId'] . "," . $boletoreimpresion['FuncionesId'] . "," . $boletoreimpresion['ZonasId'] . "," . $boletoreimpresion['SubzonaId'] . "," . $boletoreimpresion['FilasId'] . "," . $boletoreimpresion['LugaresId'] . ",'PANEL ADMINISTRATIVO','',{$user_id},'{$hoy}','" . $boletoreimpresion['LugaresNumBol'] . "')")->execute();
                 $ultimologreimp = Logreimp::model()->findAll(array('limit' => 1, 'order' => 't.LogReimpId DESC'));
                 $ultimologreimp = $ultimologreimp[0]->LogReimpId + 1;
                 Yii::app()->db->createCommand("INSERT INTO logreimp VALUES({$ultimologreimp},'{$hoy}','" . $boletoreimpresion['VentasBolTip'] . "'," . $boletoreimpresion['cosBol'] . ",'" . $boletoreimpresion['VentasBolTip'] . "',{$user_id},0," . $boletoreimpresion['EventoId'] . "," . $boletoreimpresion['FuncionesId'] . "," . $boletoreimpresion['ZonasId'] . "," . $boletoreimpresion['SubzonaId'] . "," . $boletoreimpresion['FilasId'] . "," . $boletoreimpresion['LugaresId'] . ")")->execute();
                 $newdata[$key]['LugaresNumBol'] = $codigo;
                 $newdata[$key]['VentasCon'] = $contra;
                 $newdata[$key]['cosBolCargo'] = $boletoreimpresion['cosBolCargo'];
                 $newdata[$key]['FilasAli'] = $boletoreimpresion['FilasAli'];
                 $newdata[$key]['LugaresLug'] = $boletoreimpresion['LugaresLug'];
                 $newdata[$key]['ZonasAli'] = $boletoreimpresion['ZonasAli'];
                 $newdata[$key]['VentasNumRef'] = $boletoreimpresion['VentasNumRef'];
                 $newdata[$key]['EventoNom'] = $boletoreimpresion['EventoNom'];
                 $newdata[$key]['ForoNom'] = $boletoreimpresion['ForoNom'];
                 $newdata[$key]['SubzonaAcc'] = $boletoreimpresion['SubzonaAcc'];
                 $newdata[$key]['EventoDesBol'] = $boletoreimpresion['EventoDesBol'];
                 $newdata[$key]['fnc'] = $boletoreimpresion['fnc'];
                 $newdata[$key]['VentasBolTip'] = $boletoreimpresion['VentasBolTip'];
                 $newdata[$key]['cosBol'] = $boletoreimpresion['cosBol'];
                 $newdata[$key]['VentasCarSer'] = $boletoreimpresion['VentasCarSer'];
                 $newdata[$key]['EventoImaBol'] = $boletoreimpresion['EventoImaBol'];
                 $newdata[$key]['id'] = $boletoreimpresion['id'];
                 $newdata[$key]['PuntosventaId'] = $boletoreimpresion['PuntosventaId'];
                 $newdata[$key]['VentasFecHor'] = $boletoreimpresion['VentasFecHor'];
                 $newdata[$key]['VentasNumTar'] = $boletoreimpresion['VentasNumTar'];
                 $newdata[$key]['VentasNomDerTar'] = $boletoreimpresion['VentasNomDerTar'];
             }
         }
         $formato = Formatosimpresionlevel1::model()->findAll(array('condition' => 'FormatoId=' . $_POST['formatoId']));
         $imagen = Evento::model()->findByAttributes(array('EventoId' => $_POST['EventoId']));
         //$data->getData();
         if ($imagen->EventoImaBol == "") {
             if (!file_exists($_SERVER["DOCUMENT_ROOT"] . '/' . Yii::app()->baseUrl . '/imagesbd/blanco.jpg')) {
                 copy('https://taquillacero.com/imagesbd/blanco.jpg', $_SERVER["DOCUMENT_ROOT"] . '/' . Yii::app()->baseUrl . '/imagesbd/blanco.jpg');
             }
         } else {
             if (!file_exists($_SERVER["DOCUMENT_ROOT"] . '/' . Yii::app()->baseUrl . '/imagesbd/' . $imagen->EventoImaBol)) {
                 copy('https://taquillacero.com/imagesbd/' . $imagen->EventoImaBol, $_SERVER["DOCUMENT_ROOT"] . '/' . Yii::app()->baseUrl . '/imagesbd/' . $imagen->EventoImaBol);
             }
         }
         $this->renderPartial('_impresionBoletosAjax', array('formato' => $formato, 'data' => $newdata, 'FormatoId' => $_POST['formatoId']));
     }
 }