/sistema/formularios/certificados.php
PHP | 214 lines | 186 code | 22 blank | 6 comment | 34 complexity | c3298fa562eb071db16be24702485bf8 MD5 | raw file
- <?php
- include("sistema/comunes/verificar_admin_diseno_atc.php");
- $codg_aper=$_POST['codg_aper'];
- $codg_secc=$_POST['codg_secc'];
- $cedu_part=$_POST['cedu_part'];
-
- //CONSULTAS COMBOS
- $consulta_eventos_aperturas = mysql_query("SELECT * FROM eventos_apertura, eventos where eventos_apertura.codg_evnt=eventos.codg_evnt AND eventos_apertura.codg_aper!='$codg_aper' order by eventos.nomb_evnt ");
- if ($codg_aper!='')
- {
- $consulta_eventos_aperturas1 = mysql_query("SELECT * FROM eventos_apertura, eventos where eventos_apertura.codg_aper='$codg_aper' and eventos.codg_evnt=eventos_apertura.codg_evnt ");
- $conev=mysql_fetch_assoc($consulta_eventos_aperturas1);
- $nomb_evnt=$conev[nomb_evnt]." del ".$conev[fini_aper]." al ".$conev[ffin_aper];
- $nomb_evnt_print = $conev[nomb_evnt];
- $fecha_print = "Del ".$conev[fini_aper]." al ".$conev[ffin_aper];
-
-
- }
-
- if ($codg_aper!='')
- {
- $consulta_apertura_secciones = mysql_query("SELECT * FROM eventos_secciones WHERE codg_aper='$codg_aper' ORDER BY nomb_secc");
- }
-
- if ($_POST['Imprimir']=='Imprimir Seleccionados'){
- $codigos = '';
- $cuenta_sel = 0;
- for ($i=1;$i<$_POST[total];$i++){
- if ($_POST['sel'.$i]){
- $cuenta_sel += 1;
- }
- }
- for ($i=1;$i<$_POST[total];$i++){
- if ($_POST['sel'.$i]){
- $codigos .= $_POST['sel'.$i];
- $ncertificados .= $_POST['cert_num'.$i];
- $cuenta_gen += 1;
- if ($cuenta_gen<$cuenta_sel){
- $codigos.='-';
- $ncertificados .= '-';
- }
- }
- }
- $url_post = 'sistema/formularios/certificado.php?usuario='.$_SESSION[usuario_nom_ape].'&codg_insc='.$codigos.'&cert_num='.$ncertificados;
- echo "<script type='text/javascript'>window.open('".$url_post."','_new');</script>";
- if ($_SESSION['tipo_usuario']!=1) {
- echo "<script>window.location='user.php?menu=".$_GET[menu]."&formulario=certificados';</script>";
- }else {
- echo "<script>window.location='sys.php?menu=eventos&formulario=certificados';</script>";
- }
- }
- ?>
-
- <meta charset="utf-8" />
- <div class="titulo_formulario" align="center">GENERAR CERTIFICADOS</div>
- <?php include('sistema/general/mensaje.php'); ?>
- <form id="form1" onsubmit="return jQuery(this).validationEngine('validate');" method="post" action="">
- <table cellpaddig="0" cellspacing="0" border="0" align="center">
- </br>
- </br>
- <?php
- echo '
- <tr>
- <td align="center" colspan="2">
-
- <input type="text" class="validate[custom[integer], minSize[3],maxSize[30]] text-input, cajas_entrada" value="'.$_POST[cedu_part].'" id="cedu_part" name="cedu_part" placeholder="Cédula participante" onchange="submit()"/>
-
- </td>
- </tr>';
-
- if ($cedu_part==NULL)
- {
-
- echo '<tr>
- <td align="center">
- <select name="codg_aper" id="codg_aper" class="validate[required], combo_form" onchange="submit()" >';
- echo ' <option value="" selected disabled style="display:none;">Seleccione la apertura de evento</option>';
- if($nomb_evnt){
- echo' <option value="'.$codg_aper.'" selected>'.$nomb_evnt.'</option> ';
- }
- while($fila=mysql_fetch_array($consulta_eventos_aperturas))
- {
-
- echo "<option value=".$fila[codg_aper].">".$fila[nomb_evnt]." del ".$fila[fini_aper]." al ".$fila[ffin_aper]."</option>";
- }
- echo '</select>
- </td>
- <td align="center">
- <select name="codg_secc" id="codg_secc" class="validate[required], combo_form" onchange="submit()" >';
- echo ' <option value="" selected disabled style="display:none;">Seleccione la Sección</option>';
- while($fila=mysql_fetch_array($consulta_apertura_secciones))
- {
- if ($fila[codg_secc]==$_POST[codg_secc]) { $add_sel = "selected"; } else { $add_sel=''; }
- echo "<option ".$add_sel." value=".$fila[codg_secc].">".$fila[nomb_secc]."</option>";
- }
- echo '</select>
-
- </td>
- </tr>';
- }
-
-
- echo '</table>';
- if (($_POST[codg_secc] && $_POST[codg_aper]) or ($_POST[cedu_part])) { ?>
- <table width="98%" border="0" align="center" cellspacing="0" id="listados">
- <tr align="center" style="font-size: 11px;">
- <th>Sel</th><th width="80px">Cédula</th><th>Nombre y Apellido</th><th>Empresa</th><th>Evaluación</th><th>Nº Certificado</th>
- </tr>
- <?php
-
- if ($cedu_part==NULL)
- {
- $sql_part = "SELECT *, (SELECT nota_eval FROM participantes_evaluacion WHERE codg_insc=vi.codg_insc) as nota_eval, (SELECT nomb_empr FROM empresas WHERE codg_empr=vi.codg_empr) as empresa FROM vista_inscripciones vi, participantes part WHERE vi.codg_aper = ".$codg_aper." AND vi.codg_secc=".$codg_secc." AND part.codg_part=vi.codg_part AND apro_insc='A'" ;
- $bus_part = mysql_query($sql_part);
-
-
- }
- else
- {
-
- $sql_part = "SELECT *, (SELECT nota_eval FROM participantes_evaluacion WHERE codg_insc=vi.codg_insc) as nota_eval, (SELECT nomb_empr FROM empresas WHERE codg_empr=vi.codg_empr) as empresa FROM vista_inscripciones vi, participantes part WHERE part.cedu_part=".$cedu_part." and vi.codg_part=part.codg_part AND apro_insc='A'" ;
- $bus_part = mysql_query($sql_part);
-
- }
- $counter = 1;
- while ($res_part = mysql_fetch_array($bus_part)){
- if ($_POST['sel'.$counter]){ $checked = 'checked="checked"'; } else { $checked=''; }
-
- $sql_certificado1 = "SELECT * FROM certificados WHERE cedu_part = $res_part[cedu_part] AND codg_aper=$res_part[codg_aper]";
- $res1 = mysql_fetch_array(mysql_query($sql_certificado1));
- if ($res1[nume_cert]!=NULL)
- {
- $valor_cert_num=$res1[nume_cert];
- }
- else
- {
- $valor_cert_num="";
- }
-
-
- ///////
- $res_part[deuda_final] = 0;
- $deuda = 0;
- $totalizar = 0;
- $descuento = 0;
- $total_conformado = 0;
- //// pagos que debe efectuar
- $participante = buscar("participantes","cedu_part",$res_part[cedu_part],'individual');
-
- if ($participante[0][codg_tpar]==1) { $precio = 'prec_aper'; $tcuot='estu_cuot';}
- if ($participante[0][codg_tpar]==2) { $precio = 'prep_aper'; $tcuot='prof_cuot';}
- if ($participante[0][codg_tpar]==3) { $participante[0][codg_tpar]=2; $precio = 'prep_aper'; $tcuot='prof_cuot';}
-
- $sql_deuda = "SELECT vi.tipo_insc, vi.base_insc, vi.codg_aper, vi.pgen_aper, vi.prec_aper, vi.prep_aper, vi.prem_aper, (SELECT SUM(".$tcuot.") FROM aperturas_cuotas WHERE codg_aper = vi.codg_aper ) as monto_cuotas FROM vista_inscripciones vi WHERE codg_insc = ".$res_part[codg_insc];
- $bus_deuda = mysql_query($sql_deuda);
- $res_deuda = mysql_fetch_array($bus_deuda);
- if ($res_deuda[tipo_insc]=='Contado'){
- $deuda = $res_deuda[base_insc];
- }
- if ($res_deuda[tipo_insc]=='Financiada'){
- $deuda = $res_deuda[monto_cuotas];
- $sql_cuotas = "SELECT * FROM aperturas_cuotas WHERE codg_aper = ".$res_deuda[codg_aper];
- $bus_cuotas = mysql_query($sql_cuotas);
- while ($res_cuotas = mysql_fetch_array($bus_cuotas)){
- $totalizar += $res_cuotas[$tcuot];
- }
- }
- ///// Descuento recibido en esta Apertura
- $sql_desc = "SELECT * from aperturas_descuentos WHERE codg_insc = ".$res_part[codg_insc].";";
- $bus_desc = mysql_query($sql_desc);
- if ($res_desc = mysql_fetch_array($bus_desc)){
- if ($res_desc[tipo_desc]=='%'){ $mostrar_desc = '('.$res_desc[mont_desc].'%)'; $descuento = $deuda * $res_desc[mont_desc] / 100; }
- if ($res_desc[tipo_desc]=='Bs.') { $descuento = $res_desc[mont_desc]; }
- $deuda = $deuda - $descuento;
- }
- ///// pagos efectuados
- $sql_pago="select pa.*, CONCAT(bn.nomb_banc,' (',bn.numr_cuen,')') as banc_pago FROM pagos pa, banco bn where pa.codg_insc='".$res_part[codg_insc]."' AND pa.codg_banc=bn.codg_banc ORDER BY pa.fech_pago,pa.refe_pago ASC";
- $busq_pago=mysql_query($sql_pago);
- if($reg_pago=mysql_fetch_array($busq_pago)){
- $i=0;
- do{
- $i+=1;
- $res=$i%2;
- if($res==0){ $clase="lista_tabla2"; }else{ $clase="lista_tabla1"; }
- if($reg_pago[apro_pago]=="A"){ $total_conformado += $reg_pago[mont_pago]; }
- }while($reg_pago=mysql_fetch_array($busq_pago));
- }
- ///// totalizando
- $res_part[deuda_final] = $deuda - $total_conformado;
- $add_box = '';
- $add_deuda = '';
- if ($res_part[deuda_final]<=0) {
- $add_box = '<input type="checkbox" name="sel'.$counter.'" value="'.$res_part[codg_insc].'" '.$checked.'>';
- } else {
- $add_deuda = ' title="Deuda: ';
- $add_deuda .= number_format($res_part[deuda_final],2,',','.').'"';
- }
- echo '
- <tr'.$add_deuda.'>
- <td align="center"> '.$add_box.'</td><td align="right">'.number_format($res_part[cedu_part],0,'','.').' </td><td> '.$res_part[nomb_part].' '.$res_part[apel_part].'</td><td align="center">'.$res_part[empresa].'</td><td align="center">'.$res_part[nota_eval].'</td><td><input type="text" class="validate[minSize[3],maxSize[30]] text-input, cajas_entrada_peq" value="'.$valor_cert_num.'" id="cert_num'.$counter.'" name="cert_num'.$counter.'" placeholder="Nº Certicado"/>
- </td>
- </tr>';
- $counter++;
- }
- ?>
- </table>
- <table width="98%" border="0" align="center" cellspacing="0">
- <tr>
- <td width="80%"> </td><td><input type="hidden" name="total" value="<?php echo $counter; ?>"><input type="submit" value="Imprimir Seleccionados" name="Imprimir" class="buscar_curso"></td>
- <tr>
- </table>
- <?php } ?>
-
- </form>