/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new PacienteBaul();
     $paciente = Paciente::model()->findByPk($_GET['idPaciente']);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PacienteBaul'])) {
         $model->attributes = $_POST['PacienteBaul'];
         $model->paciente_id = $_GET['idPaciente'];
         $model->personal_id = Yii::app()->user->usuarioId;
         $model->detalle = $_POST['PacienteBaul']['detalle'];
         $model->fecha = date("Y-m-d H:i:s");
         if ($model->save()) {
             $losarchivos = TempImagenes::model()->findAll();
         }
         foreach ($losarchivos as $los_archivos) {
             $losAdjuntos = new PacienteBaulDetalle();
             //Tabla que queda
             $losAdjuntos->paciente_baul_id = $model->id;
             $losAdjuntos->archivo = $los_archivos->archivo;
             $losAdjuntos->save();
         }
         TempImagenes::model()->deleteAll();
         $this->redirect(array('view', 'id' => $model->id));
     }
     $this->render('create', array('model' => $model, 'paciente' => $paciente));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PacienteFotografias'])) {
         $model->attributes = $_POST['PacienteFotografias'];
         if ($model->save()) {
             $losarchivos = TempImagenes::model()->findAll();
             foreach ($losarchivos as $los_archivos) {
                 $losAdjuntos = new PacienteFotografiasDetalle();
                 //Tabla que queda
                 $losAdjuntos->paciente_fotografias_id = $model->id;
                 $losAdjuntos->archivo = $los_archivos->archivo;
                 $losAdjuntos->save();
             }
             TempImagenes::model()->deleteAll();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }
 private function onFileUploaded($filePath, $userdata, $tipoFoto)
 {
     /*Yii::app()->user->setFlash('success',".".$filePath."  -  ".$userdata.".");	*/
     // will invoke method in a class defined when you setup the widget:
     // using: receptorClassName and methodName attributes.
     $this->_invokeMethod($filePath, $userdata, $tipoFoto);
     //Darle vuelta
     $elarchivo = substr($filePath, strpos($filePath, '/') + 1, strlen($filePath));
     $elarchivo = substr($elarchivo, strpos($elarchivo, '/'), strlen($elarchivo));
     $elarchivo = str_replace(' ', '', $elarchivo);
     if ($tipoFoto == "T") {
         $losTemporales = new TempImagenes();
         $losTemporales->archivo = $elarchivo;
         if ($losTemporales->save()) {
             # code...
         }
     }
     if ($tipoFoto == "B") {
         $losTemporales = new TempImagenes();
         $losTemporales->archivo = $elarchivo;
         if ($losTemporales->save()) {
             # code...
         }
     }
     if ($tipoFoto == "TP") {
         $losTemporales = new TempExamenes();
         $losTemporales->archivo = $elarchivo;
         if ($losTemporales->save()) {
             # code...
         }
     }
 }