Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Galeria();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Galeria'])) {
         $model->attributes = $_POST['Galeria'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Galeria();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Galeria'])) {
         $model->attributes = $_POST['Galeria'];
         if ($model->save()) {
             Yii::app()->db->createCommand("insert into Actividad (mensaje, usuario) Values ('Creó la Galería " . $model->nombre . "', '" . Yii::app()->user->name . "')")->execute();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #3
0
 function addgaleria(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $id = $request->getAttribute("id");
         $galeria = new Galeria();
         $galeria->logo = $data['logo'];
         $galeria->idSucursal = $data['idsucursal'];
         $galeria->fecha = fechaHoraActual();
         $galeria->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }