/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Administrador();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Administrador'])) {
         $model->attributes = $_POST['Administrador'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->RUTADMIN));
         }
     }
     $this->render('create', array('model' => $model));
 }
 function postadminsucursal(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $administrador = new Administrador();
         $administrador->nombres = $data['nombres'];
         $administrador->apellidos = $data['apellidos'];
         $administrador->identificacion = $data['identificacion'];
         $administrador->pass = sha1($data['pass']);
         $administrador->telefono = $data['telefono'];
         $administrador->estado = "ACTIVO";
         $administrador->idperfil = $data['idperfil'];
         $administrador->idSucursal = $data['idSucursal'];
         $administrador->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;
 }