/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Conductor();
     $modelFamiliares = new Familiar();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation(array('model' => $model, 'modelFamiliares' => $modelFamiliares));
     // Ruta de la imagen
     $path_picture = Yii::getPathOfAlias('webroot') . "/images/uploads/";
     if (isset($_POST['Conductor'], $_POST['Familiar'])) {
         $model->attributes = $_POST['Conductor'];
         $modelFamiliares->attributes = $_POST['Familiar'];
         $model->getCodigo();
         // Agregar fecha de ingreso.
         $model->con_fec_ing = date('Y-m-d');
         // Se agrega el conductor para unirse con un familiar.
         $modelFamiliares->id_persona1 = $model->id_persona;
         // Instancia a un objeto para subir archivos
         $uploadedFile = CUploadedFile::getInstance($model, 'con_fot');
         // Fija el nombre del archivo
         $fileName = "{$model->id_persona}-" . date('Ymd');
         if (!empty($uploadedFile)) {
             // Guardar Imagen
             $uploadedFile->saveAs($path_picture . $fileName);
             $model->con_fot = $fileName;
         }
         if ($model->save() && $modelFamiliares->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'modelFamiliares' => $modelFamiliares));
 }