123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- function fechaConstancia($fechaTxt){
- $fechaTxt = trim($fechaTxt);
- if(substr($fechaTxt,2,1) == "/" && substr($fechaTxt,5,1) == "/"){// dd/mm/aaaa
- $fechaArr = explode("/", $fechaTxt);
- return mesNombre($fechaArr[1])." ".intval($fechaArr[0])." de ".$fechaArr[2];
- }
- if(substr($fechaTxt,4,1) == "-" && substr($fechaTxt,7,1) == "-"){// aaaa-mm-dd
- $fechaArr = explode("-", $fechaTxt);
- return mesNombre($fechaArr[1])." ".intval($fechaArr[2])." de ".$fechaArr[0];
- }
- return "";
- }
- function generaMarcaDeAgua($marca, $carpeta) {
- $imagen = imagecreatetruecolor(344,143); // Crear la imagen de 591x379
- $textColor = imagecolorallocate($imagen, 224, 224, 224); //Colores del texto
- $transparente = imagecolorallocate ($imagen, 0, 0, 0); //Color que cambiará a transparene
- imagecolortransparent($imagen, $transparente); // Hacer el fondo transparente
- for ($cont = 0; $cont < 5; $cont++) { $marca .= $marca; }
- // Escribirlo
- for ($cont=1; $cont <= 50; $cont++){
- if ($cont%2 == 0)
- $val = -5;
- else
- $val = 5;
- imagestring($imagen,1, $val, 10*$cont, $marca, $textColor); //Escribe el texto
- }
- header('Content-Type: image/png');
- imagepng($imagen, $carpeta.'marca.png'); //Genera la imagen
- //imagedestroy($imagen);
-
- }
- function creaFolio($pdo, $sist, $pag, $fecha, $participante, $motivo, $tipo, $evento, $desc, $evento_id, $img) {
- $folio = '';
- //echo 'Select * from fi_constanciaLog(:sist, :evento_id, :part, :motivo, :fecha, :tipo, :evento, :desc, :usr)<br>';
- //echo 'Select * from fi_constanciaLog('.$sist.', '.$evento_id.', '.$participante.', '.$motivo.', '.$fecha.', '.$tipo.', '.$evento.', '.htmlentities($desc).', '.$_SESSION["usuario_id"].')<br>';
- if($img==NULL)
- $stmt = $pdo->prepare('Select * from fi_constanciaLog(:sist, :evento_id, :part, :motivo, :fecha, :tipo, :evento, :desc, NULL, :usr)');//firmas
- else{
- $stmt = $pdo->prepare('Select * from fi_constanciaLog(:sist, :evento_id, :part, :motivo, :fecha, :tipo, :evento, :desc, :img, :usr)');//firmas
- $stmt->bindParam(":img", $img);
- }
- $stmt->bindParam(":sist", $sist);
- $stmt->bindParam(":evento_id", $evento_id);
- $stmt->bindParam(":part", $participante);
- $stmt->bindParam(":motivo", $motivo);
- $stmt->bindParam(":fecha", $fecha);
- $stmt->bindParam(":tipo", $tipo);
- $stmt->bindParam(":evento", $evento);
- $stmt->bindParam(":desc", $desc);
- $stmt->bindParam(":usr", $_SESSION["usuario_id"]);
- if(!$stmt->execute()){
- $pdo->rollBack();
- header("Location:".$pag."?error=3");
- //print_r($stmt->errorInfo());
- exit();
- }
- $rs=$stmt->fetch();
- $folio = $rs["ConstanciaLog_id"];
- if (!empty($folio))
- return $folio;
- return "";
- }
- function generaFooter($pdo, $sist, $pag, $fecha, $numFirmas, $firmasArr, $participante, $motivo, $tipo, $evento, $desc, $evento_id, $img=NULL){
- //echo "generaFooter: ".$evento_id."<br>";
- $folio = creaFolio($pdo, $sist, $pag, $fecha, $participante, $motivo, $tipo, $evento, $desc, $evento_id, $img);
- if (!empty($folio)){
- $folio_text = 'FI - ';
- switch($sist){
- case GEMA: $folio_text.='G'; break;
- case CIDIT: $folio_text.='C'; break;
- case EXPOING: $folio_text.='E'; break;
- default: $folio_text.='X'; break;
- }
- $folio_text .= $evento_id . ' - ' . sprintf("%04d", $folio);
-
- } else{
- $pdo->rollBack();
- header("Location:".$pag."?error=3");
- exit();
- }
- $xtpl = new XTemplate('../tpl/footer.tpl.html');
- $xtpl->assign('FOLIO', $folio_text);
- $fechaConst = fechaConstancia($fecha);
- $xtpl->assign('FECHA_CARTA', $fechaConst);
- if($numFirmas >= 2)
- $numFirmas = 2; // 1 -> sólo una firma / 2 -> 2 o más firmas
- $orden = 1;
- foreach($firmasArr as $firma_pie){
- $xtpl->assign('NUM', $numFirmas);
- if($firma_pie["lleva_firma"]){
- $xtpl->assign('MARCA', './zip/marca.png');
- $xtpl->assign('FIRMA', $firma_pie["firma"]);
- }else{
- $xtpl->assign('MARCA', '../../img/firmas/marca_blanco.png');
- $xtpl->assign('FIRMA', "blanco.png");
- }
- $xtpl->assign('NOMBRE', $firma_pie["grado"]." ".$firma_pie["nombre"]);
- $xtpl->assign('PUESTO', $firma_pie["puesto"]);
- $xtpl->parse('main.firma');
- if($firma_pie["lleva_firma"]){
- $stmt = $pdo->prepare('Select * from fi_constancialogfirma(:sist, :evento, :serial, :firma, :orden, :puesto, true)');//firmas
- }else{
- $stmt = $pdo->prepare('Select * from fi_constancialogfirma(:sist, :evento, :serial, :firma, :orden, :puesto, false)');//firmas
- }
- $stmt->bindParam(":sist", $sist);
- $stmt->bindParam(":evento", $evento_id);
- $stmt->bindParam(":serial", $folio);
- $stmt->bindParam(":firma", $firma_pie["id"]);
- $stmt->bindParam(":orden", $orden);
- $stmt->bindParam(":puesto", $firma_pie["puesto"]);
- if(!$stmt->execute()){
- $pdo->rollBack();
- header("Location:".$pag."?error=3");
- exit();
- }
- $orden++;
- }
- $xtpl->assign('NUM', $numFirmas);
-
- $xtpl->parse('main');
- return $xtpl->text('main');
- }
- // -- Solo CIDIT ---
- function cambiaTextos($texto, $codeArr){
- $buscaArr = array();
- $reemplazaArr = array();
- foreach($codeArr as $opt){
- $buscaArr[] = $opt["busca"];
- $reemplazaArr[] = $opt["reemplaza"];
- }
- return str_replace ($buscaArr, $reemplazaArr, $texto);
- }
- function textoLugar($num){
- switch($num){
- case 1: return $num."er";
- case 2: return $num."do";
- case 3: return $num."er";
- }
- return $num."to";
- }
- // -- Consulta de constancias --
- function imprimeFooter($fecha, $numFirmas, $firmasArr, $sistema, $evento_id, $folio){
-
- $folio_text = 'FI - ';
- switch($sistema){
- case GEMA: $folio_text.='G'; break;
- case CIDIT: $folio_text.='C'; break;
- default: $folio_text.='X'; break;
- }
- $folio_text.=$evento_id . ' - ' . sprintf("%04d", $folio);
- $xtpl = new XTemplate('../tpl/footer.tpl.html');
- $xtpl->assign('FOLIO', $folio_text);
- if(empty($fecha))
- $fecha = date("Y-m-d");
- $fechaConst = fechaConstancia($fecha);
- $xtpl->assign('FECHA_CARTA', $fechaConst);
- if($numFirmas >= 2)
- $numFirmas = 2; // 1 -> sólo una firma / 2 -> 2 o más firmas
- foreach($firmasArr as $firma_pie){
- $xtpl->assign('NUM', $numFirmas);
- if($firma_pie["lleva_firma"]){
- $xtpl->assign('MARCA', './zip/marca.png');
- $xtpl->assign('FIRMA', $firma_pie["firma"]);
- }else{
- $xtpl->assign('MARCA', '../../img/firmas/marca_blanco.png');
- $xtpl->assign('FIRMA', "blanco.png");
- }
- $xtpl->assign('NOMBRE', $firma_pie["grado"]." ".$firma_pie["nombre"]);
- $xtpl->assign('PUESTO', $firma_pie["puesto"]);
- $xtpl->parse('main.firma');
- }
- $xtpl->assign('NUM', $numFirmas);
-
- $xtpl->parse('main');
- return $xtpl->text('main');
- }
- function supText($texto){
- $textoArr = explode(".", $texto);
- return $textoArr[0].".<sup>".$textoArr[1]."</sup>";
- }
- ?>
|