Example #1
0
function mysqlDate2OnlyDate($f)
{
    // yyyy-mm-dd H:m:ss    ==>     13 de Febrero de 2015
    $cadena = "";
    if ($f !== "") {
        $pos = strpos($f, " ");
        $fecha = "";
        if ($pos !== false) {
            list($fecha, $hora) = explode(" ", $f);
        } else {
            $fecha = $f;
        }
        if ($fecha !== "") {
            list($a, $m, $d) = preg_split("/[\\/|-]/", $fecha);
            $cadena = $d . ' de ' . Meses($m) . ' de ' . $a;
        }
    }
    return $cadena;
}
Example #2
0
</strong>
            <span class="form-group pull-right"><label><input type="checkbox" id="ocultar_ceros"> Ocultar ceros</label></span>
        </div>

        <!-- Table -->
        <table class="table">
            <thead>
                <tr>
                    <?php 
    for ($i = 1; $i <= 12; $i++) {
        ?>
<th class="<?php 
        echo !isset($valores[$i]) ? "esCero" : "";
        ?>
"><center><?php 
        echo Meses($i);
        ?>
</center></th><?php 
    }
    ?>
            </tr>
            </thead>
            <tbody>
                <tr>
                    <?php 
    for ($i = 1; $i <= 12; $i++) {
        ?>
<td align="center" class="<?php 
        echo !isset($valores[$i]) ? "esCero" : "";
        ?>
"><?php 
Example #3
0
 /**
  *  Obtiene los necesarios para ver la asistencias de alumnos
  *
  **/
 protected function obtenerDatos()
 {
     Misc::use_helper('Misc');
     //Iniciando Variables
     $alumno_id = -1;
     $cuenta_id = -1;
     $vista_id = 1;
     // default para vista DIARIO
     $division_id = 0;
     $carrera_id = 0;
     $datos = array();
     $idxAlumno = array();
     $aFeriado = array();
     $aIntervalo = array();
     $optionsDivision = array();
     $optionsCarrera = array();
     $aTemp = array();
     $aFechaTemp = array();
     $aTipoasistencias = array();
     $aPorcentajeAsistencia = array();
     $flag_error = 0;
     $nombre_completo_archivo = "";
     $bool_gd = array_search("gd", get_loaded_extensions());
     // Tomando los datos del formulario y completando variable
     $ciclolectivo_id = $this->getUser()->getAttribute('fk_ciclolectivo_id');
     $ciclolectivo = CiclolectivoPeer::retrieveByPK($ciclolectivo_id);
     $ciclolectivo_fecha_inicio = strtotime($ciclolectivo->getFechaInicio());
     $ciclolectivo_fecha_fin = strtotime($ciclolectivo->getFechaFin());
     // Asigno la fecha de inicio del ciclo lectivo por defecto
     $aFechaActual = getdate($ciclolectivo_fecha_inicio);
     // Tomo el año de la fecha de inicio y de fin del ciclo lectivo
     $anio_desde = date("Y", $ciclolectivo_fecha_inicio);
     $anio_hasta = date("Y", $ciclolectivo_fecha_fin);
     if ($this->getRequestParameter('dia')) {
         $d = $this->getRequestParameter('dia');
     } else {
         $d = $aFechaActual['mday'];
     }
     if ($this->getRequestParameter('mes')) {
         $m = $this->getRequestParameter('mes');
     } else {
         $m = $aFechaActual['mon'];
     }
     if ($this->getRequestParameter('ano')) {
         $y = $this->getRequestParameter('ano');
     } else {
         $y = $aFechaActual['year'];
     }
     if ($this->getRequestParameter('alumno_id')) {
         $alumno_id = $this->getRequestParameter('alumno_id');
         $a = AlumnoPeer::retrieveByPK($alumno_id);
         $cuenta_id = $a->getFkCuentaId();
     }
     if ($this->getRequestParameter('carrera_id')) {
         $carrera_id = $this->getRequestParameter('carrera_id');
     }
     if ($this->getRequestParameter('vistas')) {
         $vista_id = $this->getRequestParameter('vistas');
     }
     $establecimiento_id = $this->getUser()->getAttribute('fk_establecimiento_id');
     $criteria = new Criteria();
     $criteria->add(AnioPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id);
     if ($this->getRequestParameter('alumno_id')) {
         $criteria->add(RelAlumnoDivisionPeer::FK_ALUMNO_ID, $alumno_id);
         $criteria->addJoin(RelAlumnoDivisionPeer::FK_DIVISION_ID, DivisionPeer::ID);
     }
     if ($this->getRequestParameter('carrera_id')) {
         $criteria->add(AnioPeer::FK_CARRERA_ID, $carrera_id);
     }
     $criteria->addAscendingOrderByColumn(AnioPeer::DESCRIPCION);
     $criteria->addAscendingOrderByColumn(DivisionPeer::ORDEN);
     $criteria->addAscendingOrderByColumn(DivisionPeer::DESCRIPCION);
     $divisiones = DivisionPeer::doSelectJoinAnio($criteria);
     // divisiones a mostrar
     foreach ($divisiones as $division) {
         $optionsDivision[$division->getId()] = $division->__toString();
     }
     if ($this->getRequestParameter('division_id')) {
         $division_id = $this->getRequestParameter('division_id');
     } else {
         if (count($optionsDivision) > 0) {
             $aTemp = array_keys($optionsDivision);
             $division_id = $aTemp[0];
         } else {
             // Ver si se puede hacer desde el validate
             $this->getRequest()->setError('Division', 'No hay Ninguna División cargada');
             $flag_error = 1;
         }
     }
     $cCarrera = new Criteria();
     $cCarrera->add(CarreraPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id);
     $carreras = CarreraPeer::doSelect($cCarrera);
     foreach ($carreras as $carrera) {
         $optionsCarrera[$carrera->getId()] = $carrera->getDescripcion();
     }
     if (!checkdate($m, $d, $y)) {
         // Ver si se puede hacer desde el validate
         $this->getRequest()->setError('Fecha', 'La fecha ingresada es erronea');
         $flag_error = 1;
     }
     if ($flag_error == 0) {
         // devuelve un intervalo de dias según vista y fecha seleccionada
         $aIntervalo = diasxintervalo($d, $m, $y, $vista_id);
         // chequeo si el intervalo de fechas generados esta o no dentro de las fechas validas del ciclo lectivo
         foreach ($aIntervalo as $fecha) {
             $fecha_intervalo = strtotime($fecha);
             if ($fecha_intervalo >= $ciclolectivo_fecha_inicio and $fecha_intervalo <= $ciclolectivo_fecha_fin) {
                 $aFechaTemp[] = $fecha;
             }
         }
         $aIntervalo = $aFechaTemp;
     }
     // obteniendo los feriados actuales
     $criteria = new Criteria();
     $feriados = FeriadoPeer::doSelect($criteria);
     foreach ($feriados as $feriado) {
         $aFeriado[$feriado->getFecha()] = $feriado->getNombre();
     }
     // esto deberia estar hecho muy diferente guardar en un /tmp con archivo aleatorio
     if (file_exists(sfConfig::get('sf_upload_dir_name') . '/grafico_asistencias.png')) {
         unlink(sfConfig::get('sf_upload_dir_name') . '/grafico_asistencias.png');
     }
     if (count($aIntervalo) > 0) {
         //Obtener los alumnos de la division y asistencias en el rango de fecha
         //$con = sfContext::getInstance()->getDatabaseConnection($connection='propel');
         $con = Propel::getConnection();
         $s = "SELECT alumno.id, alumno.nombre, alumno.apellido, alumno.apellido_materno,";
         $s .= "tipoasistencia.descripcion, tipoasistencia.nombre AS asistencia, asistencia.fecha,";
         $s .= "asistencia.fk_tipoasistencia_id ";
         $s .= "FROM alumno, rel_alumno_division ";
         $s .= "LEFT JOIN asistencia ON ( rel_alumno_division.FK_ALUMNO_ID = asistencia.FK_ALUMNO_ID ";
         $s .= "AND asistencia.FECHA ";
         $s .= "IN (";
         for ($i = 0, $max = count($aIntervalo); $i < $max; $i++) {
             $s .= "'" . $aIntervalo[$i] . " 00:00:00'";
             if ($i < count($aIntervalo) - 1) {
                 $s .= ",";
             }
         }
         $s .= ") ) ";
         $s .= "LEFT JOIN tipoasistencia ON ( asistencia.FK_TIPOASISTENCIA_ID = tipoasistencia.ID ) ";
         $s .= "WHERE ";
         if ($alumno_id >= 0) {
             $s .= "alumno.ID =" . $alumno_id;
         } else {
             $s .= "rel_alumno_division.FK_DIVISION_ID =" . $division_id;
         }
         $s .= " AND rel_alumno_division.FK_ALUMNO_ID = alumno.ID";
         $s .= " ORDER BY alumno.apellido,alumno.apellido_materno,alumno.nombre,asistencia.FECHA";
         $stmt = $con->prepare($s);
         $alumnos = $stmt->execute();
         $totales = array();
         $tot = 0;
         while ($alumno = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $idxAlumno[$alumno['id']] = $alumno['apellido'] . " " . $alumno['apellido_materno'] . " " . $alumno['nombre'];
             if ($alumno['fecha']) {
                 $datos[$alumno['id']][$alumno['fecha']] = $alumno['asistencia'];
                 @$totales[$alumno['asistencia']]++;
             }
         }
         $aTipoasistencias = $this->getTiposasistencias();
         $aPorcentajeAsistencia = array();
         $flag = 0;
         // cantidad de fechas sin fines de semana
         $cantFechas = 0;
         foreach ($aIntervalo as $fecha) {
             if (!(date("w", strtotime($fecha)) == 6) and !(date("w", strtotime($fecha)) == 0)) {
                 $cantFechas++;
             }
         }
         $dias = $cantFechas * count($idxAlumno);
         foreach ($aTipoasistencias as $idx => $Tipoasistencia) {
             $aPorcentajeAsistencia[$idx] = isset($totales[$idx]) ? number_format($totales[$idx] * 100 / $dias, 2) : number_format(0, 2);
             $tot += isset($totales[$idx]) ? number_format($totales[$idx], 2) : number_format(0, 2);
             if ($aPorcentajeAsistencia[$idx] != 0) {
                 $flag = 1;
             }
         }
         if ($flag == 1) {
             $aTitulo = array_keys($aTipoasistencias);
             $aTitulo[] = "No Cargado";
             if ($bool_gd) {
                 // Si no tiene cargado la GD no muestra el grafico
                 // Genera nombre de archivo único
                 $nombre_archivo = uniqid();
                 $nombre_completo_archivo = $nombre_archivo . '.jpg';
                 // nueva clase para grafico de tortas
                 $graph = new ezcGraphPieChart();
                 // uso driver GD pero podria ser SVG o Ming
                 $graph->driver = new ezcGraphGdDriver();
                 $graph->driver->options->supersampling = 1;
                 $graph->driver->options->jpegQuality = 100;
                 $graph->driver->options->imageFormat = IMG_JPEG;
                 // Color de fondo del grafico
                 $graph->background->color = '#FFFFFF';
                 // De donde sacar la letra
                 $graph->options->font = realpath(sfConfig::get('sf_lib_dir') . "/font/FreeSerifBold.ttf");
                 $graph->options->font->maxFontSize = 9;
                 //     $graph->title = "Asistencia";
                 // Cargo datos de la asistencia
                 $graph->data['Asistencia'] = new ezcGraphArrayDataSet($aPorcentajeAsistencia);
                 // tamaño del symbolo de la lista
                 $graph->legend->symbolSize = 10;
                 // se selecciona las opciones graficas
                 $graph->renderer = new ezcGraphRenderer3d();
                 $graph->renderer->options->moveOut = 0.01;
                 $graph->renderer->options->pieChartShadowSize = 10;
                 // $graph->renderer->options->pieChartGleam = .5;
                 $graph->renderer->options->dataBorder = false;
                 $graph->renderer->options->pieChartHeight = 16;
                 $graph->renderer->options->legendSymbolGleam = 0.5;
                 //graba archivo de imagen
                 $graph->render(400, 250, sfConfig::get('app_alba_tmpdir') . DIRECTORY_SEPARATOR . $nombre_completo_archivo);
             }
         }
     }
     //Asignacion de variables para el template
     $this->bool_tmp = is_writable(sfConfig::get('app_alba_tmpdir'));
     $this->bool_gd = $bool_gd;
     $this->nombre_completo_archivo = $nombre_completo_archivo;
     $this->d = $d;
     $this->m = $m;
     $this->y = $y;
     $this->aTipoasistencias = $aTipoasistencias;
     $this->aAlumnos = $idxAlumno;
     $this->aDatos = $datos;
     $this->optionsDivision = $optionsDivision;
     $this->optionsCarrera = $optionsCarrera;
     $this->aVistas = repeticiones();
     $this->aMeses = Meses();
     $this->aIntervalo = $aIntervalo;
     $this->aPorcentajeAsistencia = $aPorcentajeAsistencia;
     $this->aFeriado = $aFeriado;
     $this->alumno_id = $alumno_id;
     $this->cuenta_id = $cuenta_id;
     $this->vista_id = $vista_id;
     $this->division_id = $division_id;
     $this->carrera_id = $carrera_id;
     $this->anio_desde = $anio_desde;
     $this->anio_hasta = $anio_hasta;
 }
Example #4
0
                <i class="fa fa-bar-chart-o fa-fw"></i> Archivo Melate.xls
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="col-xs-6">
                    <h3>Archivo actual</h3>
                    <?php 
$archivoMelate = "Melate.csv";
$rutaArchivoMelate = implode(DIRECTORY_SEPARATOR, array(realpath("."), "resources", $archivoMelate));
if (!file_exists($rutaArchivoMelate)) {
    echo '<p>No se encontró el archivo de MELATE en el directorio: ' . $rutaArchivoMelate . '</p>';
} else {
    $csv = file($rutaArchivoMelate);
    $keys = str_getcsv($csv[0]);
    $values = str_getcsv($csv[1]);
    $datos = array_combine($keys, $values);
    $this->load->helper("varios_helper");
    list($dia, $mes, $anio) = explode("/", $datos['FECHA']);
    echo "<p>La última fecha del archivo <b>" . $archivoMelate . "</b> es: " . $dia . ' de ' . Meses($mes) . ' de ' . $anio . "<br>" . 'Descarga la última versión haciendo <a href="#" id="getArchivoMelateFromURL">clic aquí</a> <span id="result"></span></p>';
}
?>
                </div>
                <div class="col-xs-6">Archivo servidor</div>
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-8 -->
</div>
<!-- /.row -->