Example #1
0
 public function actionAprobar()
 {
     if (isset($_POST['id'])) {
         $comite = $_POST['id'];
         if (isset($_POST['fecha'])) {
             $fecha_aprobacion = $_POST['fecha'];
         }
         if (isset($_POST['acta'])) {
             $acta_aprobacion = $_POST['acta'];
         }
         if (isset($_POST['selection'])) {
             $proyectos[] = strtok($_POST['selection'], ",");
         }
         if (!empty($proyectos)) {
             foreach ($proyectos as $id) {
                 $pc = new ProyectosComite();
                 $pc->comite = $comite;
                 $pc->fecha_aprobacion = $fecha_aprobacion;
                 $pc->acta_aprobacion = $acta_aprobacion;
                 $pc->proyecto = $id;
                 $pc->save();
             }
         }
         Yii::$app->session->setFlash('success', 'Proyectos aprobados');
         $this->redirect(Url::to(['index2', 'id' => $comite]));
     }
 }
 /**
  * Creates a new ProyectosComite model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProyectosComite();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }