Esempio n. 1
0
<?php

$this->breadcrumbs = array(DocumentoNuevo::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Crear') . ' ' . DocumentoNuevo::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Administrar') . ' ' . DocumentoNuevo::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(DocumentoNuevo::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
 public function actionLogitech()
 {
     $files = explode('*', $_POST['archivos']);
     $uploads_dir = "C:/imagenes/";
     $rutapath = "..//descargas//";
     $id = $_POST['id'];
     $iddoc = $_POST['iddoc'];
     $dane = $_POST['dane'];
     $tipdoc = $_POST['tipdoc'];
     $doc = $_POST['doc'];
     $retorno = "";
     $tabla = DocumentoAnexo::model()->findBypk($id)->tabla;
     if (!is_dir($uploads_dir)) {
         mkdir($uploads_dir, 7777);
         $retorno = "Asegúrese de ingresar a las preferencias de la camara y cambiar la carpeta por defecto de las imágenes a {$uploads_dir}";
     } else {
         foreach ($files as $file) {
             if (file_exists($uploads_dir . $file) && $file != "") {
                 unset($model);
                 $semilla = md5(date('YmdHisu')) . "_" . Yii::app()->user->getId() . "_";
                 $model = new DocumentoNuevo();
                 switch ($tabla) {
                     case 'matricula':
                         $model->matriculaespejo_id = $iddoc;
                         break;
                     case 'docente':
                         $model->docenteespejo_id = $iddoc;
                         break;
                     case 'administrativo':
                         $model->administrativoespejo_id = $iddoc;
                         break;
                 }
                 $model->documentoanexo_id = $id;
                 $model->archivo = $semilla . $file;
                 $model->CODIGO_DANE_SEDE = $dane;
                 $model->TIPO_DOCUMENTO = $tipdoc;
                 $model->NRO_DOCUMENTO = $doc;
                 if ($model->save()) {
                     if (copy($uploads_dir . $file, $rutapath . $semilla . $file)) {
                         unlink($uploads_dir . $file);
                         $retorno = "ok";
                     }
                 } else {
                     $retorno .= "error al guardar en la base el archivo {$file},";
                 }
             } elseif ($file != "") {
                 $retorno .= "la imagen {$file} no existe en el directorio seleccionado,";
             }
         }
     }
     echo $retorno;
 }