Ejemplo n.º 1
0
 public static function fechaDeHoy($fecha)
 {
     $fechaActual = explode('/', $fecha);
     if (count($fechaActual) > 0) {
         return $fechaActual[0] . ' de ' . Mes::nombreMes($fechaActual[1]) . ' de ' . $fechaActual[2];
     }
     $fechaActual = explode('-', $fecha);
     if (count($fechaActual) > 0) {
         return $fechaActual[0] . ' de ' . Mes::nombreMes($fechaActual[1]) . ' de ' . $fechaActual[2];
     }
     throw new \InvalidArgumentException("El formato del parámetro {$fecha} es inválido");
 }
Ejemplo n.º 2
0
 public function getDataPDF($model)
 {
     date_default_timezone_set('America/Caracas');
     $meridiano = array('AM' => 'a.m.', 'PM' => 'p.m.');
     $dias = array(1 => 'Uno', 2 => 'Dos', 3 => 'Tres', 4 => 'Cuatro', 5 => 'Cinco', 6 => 'Seis', 7 => 'Siete', 8 => 'Ocho', 9 => 'Nueve', 10 => 'Diez', 11 => 'Once', 12 => 'Doce', 13 => 'Trece', 14 => 'Catorce', 15 => 'Quince', 16 => 'Dieciseis', 17 => 'Diecisiete', 18 => 'Dieciocho', 19 => 'Diecinueve', 20 => 'Veinte', 21 => 'Veintiuno', 22 => 'Veintidos', 23 => 'Veintitres', 24 => 'Veinticuatro', 25 => 'Veinticinco', 26 => 'Veintiseis', 27 => 'Veintisiete', 28 => 'Veintiocho', 29 => 'Veintinueve', 30 => 'Treinta', 31 => 'Treinta y Uno');
     $data = array();
     $data['fecha_numerica'] = date('Y-m-d H:i:s');
     $fd = preg_split("/[\\s-:]+/", $model->fecha);
     $mes = Mes::model()->findByPk($fd[1]);
     $data['fecha'] = $dias[(int) $fd[2]] . " ({$fd['2']}) de " . ucfirst($mes->descripcion) . " de {$fd['0']}";
     if ($fd[3] == 12) {
         $hh = $fd[3];
         $tt = 'm.';
     } else {
         if ($fd[3] > 12) {
             $hh = $fd[3] - 12;
             $tt = 'p.m.';
         } else {
             $hh = $fd[3];
             $tt = 'a.m.';
         }
     }
     $data['hora'] = $hh . ':' . $fd[4] . ' ' . $tt;
     $data['sede'] = $model->dependencia->sede->descripcion;
     $data['direccion'] = $model->dependencia->sede->direccion_larga;
     $data['emisor'] = $model->emisor->persona->pdata->nombre;
     $data['emisor_ttl'] = $model->emisor->persona->pdata->profesion->cod;
     $data['emisor_ci'] = number_format($model->emisor->persona->pdata->cedula, 0, ',', '.');
     $data['emisor_cargo'] = $model->emisor->persona->cargo->descripcion;
     $data['dp_emisora'] = $model->emisor->persona->dependencia->descripcion;
     if ($model->emisor->dependencia->genero_id == 1) {
         $data['dp_emisora_g'] = 'en el';
     } else {
         $data['dp_emisora_g'] = 'en la';
     }
     $data['receptor'] = $model->receptor->persona->pdata->nombre;
     $data['receptor_ttl'] = $model->receptor->persona->pdata->profesion->cod;
     $data['receptor_ci'] = number_format($model->receptor->persona->pdata->cedula, 0, ',', '.');
     $data['receptor_cargo'] = $model->receptor->persona->cargo->descripcion;
     $data['dp_receptora'] = $model->receptor->persona->dependencia->descripcion;
     if ($model->receptor->dependencia->genero_id == 1) {
         $data['dp_receptora_g'] = 'en el';
     } else {
         $data['dp_receptora_g'] = 'en la';
     }
     return $data;
 }
Ejemplo n.º 3
0
function myExceptionHandler($e)
{
    $message = $e->getMessage();
    if ($e->getCode() != 0) {
        // 画面表示不可メッセージの場合
        $message = Mes::getMessage($e->getCode());
        // 汎用メッセージ取得
        // ログ採り
    }
    switch (get_class($e)) {
        case 'SysException':
            break;
        case 'UsrException':
            break;
        default:
            break;
    }
    echo $message;
}
Ejemplo n.º 4
0
 public function actionGenerar($formulario)
 {
     $meses = Mes::model()->findAll();
     $user_id = Yii::app()->user->getId();
     $user = Usuario::model()->findbyPk($user_id);
     $dp_id = $user->dependencia_id;
     date_default_timezone_set('America/Caracas');
     $anho_actual = date('Y');
     $i = 0;
     $t_anho = $anho_actual;
     $anhos = array();
     while ($t_anho > 2011) {
         $anhos[$i] = $t_anho;
         $i++;
         $t_anho--;
     }
     switch ($formulario) {
         case 1:
             $model = new Fbm1();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm1'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id, 'status_id' => 1));
                 $model->attributes = $_POST['Fbm1'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     if ($model->informativo == 1) {
                         $header['columna'] = 4;
                         $header['formulario'] = 1;
                     } else {
                         $header['columna'] = 5;
                         $header['formulario'] = 2;
                     }
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $this->render('pdf', array('header' => $header, 'data' => $data));
                 }
             }
             break;
         case 2:
             $model = new Fbm2();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm2'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id));
                 $model->attributes = $_POST['Fbm2'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     $header['columna'] = 6;
                     $header['formulario'] = 3;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $this->render('pdf', array('header' => $header, 'data' => $data));
                 }
             }
             break;
         case 3:
             $this->redirect(array('/fbm3/index'));
             break;
         case 4:
             $model = new Fbm4();
             $model->dependencia_id = $dp_id;
             if (isset($_POST['Fbm4'])) {
                 $fecha = date('Y-m-d H:i:s');
                 $responsable = Responsable::model()->findByAttributes(array('dependencia_id' => $model->dependencia_id));
                 $model->attributes = $_POST['Fbm4'];
                 if (isset($responsable) && $model->validate()) {
                     $model->anho = $anhos[$model->anho];
                     $data = $model->getData();
                     $mes = Mes::model()->find(array('condition' => 'id=' . $model->mes_id));
                     $info = Dependencia::model()->getInfo($model->dependencia_id);
                     $header = array();
                     $header['columna'] = 6;
                     $header['formulario'] = 5;
                     $header['responsable'] = $responsable->persona->pdata->nombre;
                     $header['cargo'] = $responsable->persona->cargo->descripcion;
                     $header['dependencia'] = $info['dp'];
                     $header['estado'] = 'BOLIVARIANO DE MIRANDA';
                     $header['municipio'] = 'SUCRE';
                     $header['servicio'] = $info['servicio'];
                     $header['direccion'] = $info['direccion_corta'];
                     $header['fecha'] = $mes->descripcion . '/' . $model->anho;
                     $header['hoja'] = $mes->id;
                     $this->render('pdf4', array('header' => $header, 'data' => $data));
                 } else {
                     echo 1;
                     exit;
                 }
             }
             break;
     }
     $this->render('generar', array('model' => $model, 'meses' => $meses, 'anhos' => $anhos));
 }
Ejemplo n.º 5
0
 public function getCalendarioStr($url, $selectedDay)
 {
     $larg = 100.0 / 7.0;
     $str = "";
     $str .= "<table border='0' width='100%' cellpadding='0' cellspacing='0' align='center' class='" . self::TABLE_CSS_CLASS . "' >\n";
     $str .= "<thead>";
     $str .= "<tr>";
     $str .= "<th colspan=7>";
     $str .= "<div class='" . self::MES_CSS_CLASS . "'>";
     $str .= "<a title='Mês Anterior' href='{$url}-{$this->mes}-anterior-{$this->ano}' style='float: left; width: 20px; text-align: center;'> &laquo; </a>";
     $str .= "<a title='Próximo Mês' href='{$url}-{$this->mes}-proximo-{$this->ano}' style='float: right; width: 20px; text-align: center;'>&raquo;</a>";
     $str .= ucfirst(Mes::getMesNome($this->mes)) . " " . $this->ano;
     $str .= "</div>";
     $str .= "</th>";
     $str .= "</tr>";
     $str .= "</thead>";
     $str .= "<tr class='" . self::SEMANA_CSS_CLASS . "'>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['domingo'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['segunda'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['terca'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['quarta'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['quinta'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['sexta'] . "</th>\n";
     $str .= "<th align='center' width='" . $larg . "%'>" . $this->semana['sabado'] . "</th>\n";
     $str .= "</tr>\n";
     $ccol = 0;
     $casa = 0;
     while (checkdate($this->mes, $this->dia, $this->ano)) {
         if ($this->linhafechada) {
             $str .= "<tr>\n";
             $this->linhafechada = false;
         }
         if ($casa < $this->dsprimdia) {
             $str .= "<td>&nbsp;</td>\n";
         } else {
             $str .= "<td align='center'>\n";
             if ($this->dia == $selectedDay) {
                 $class = self::SELECTED_DAY_CSS_CLASS;
             } else {
                 $class = "";
             }
             $str .= "<a class='{$class}' title='Eventos Após {$this->dia} de " . ucfirst(Mes::getMesNome($this->mes)) . " de " . $this->ano . " ' href='{$url}-{$this->mes}-{$this->dia}-{$this->ano}'>";
             $str .= $this->dia . "\n";
             $str .= "</a>";
             $str .= "</td>\n";
             $this->proximo_dia();
         }
         $ccol++;
         $ccol = $ccol % 7;
         $casa++;
         if ($casa % 7 == 0) {
             $str .= "</tr>\n";
             $this->linhafecha = true;
         }
     }
     while ($ccol != 0) {
         $ccol++;
         $ccol = $ccol % 7;
         $str .= "<td>&nbsp;</td>\n";
     }
     $str .= "</tr>\n";
     $str .= "<tfoot>";
     $str .= "<tr>";
     $str .= "<th colspan=7 class='" . self::HOJE_CSS_CLASS . "'>";
     $str .= "<a title='Hoje' href='{$url}-hoje'>HOJE</a>";
     $str .= "</th>";
     $str .= "</tfoot>";
     $str .= "</table>\n";
     return $str;
 }