예제 #1
0
 public function removeAction($idVisitcategory)
 {
     $vcat = Visitcategory::findFirst(array('conditions' => 'idVisitcategory = ?1 AND idAccount = ?2', 'bind' => array(1 => $idVisitcategory, 2 => $this->user->idAccount)));
     if (!$vcat) {
         $this->flashSession->error("No se encontró la categoria, por favor valide la información");
         return $this->response->redirect('visitcategory');
     }
     try {
         $vcat->delete();
         $this->flashSession->warning("Se ha eliminado la categoría exitosamente");
     } catch (Exception $ex) {
         $this->logger->log("Exception: {$ex}");
         $this->flashSession->error("Ocurrió un error al eliminar esta Categoría, es posible que esté asociado a una visita, por favor contacte al administrador");
     }
     return $this->response->redirect('visitcategory');
 }
예제 #2
0
 public function editAction($idVisittype)
 {
     $vtype = Visittype::findFirst(array('conditions' => 'idVisittype = ?1', 'bind' => array(1 => $idVisittype)));
     $cat = Visitcategory::find();
     $this->view->setVar("cat", $cat);
     $vcat = Visitcategory::findFirst(array('conditions' => 'idVisitcategory = ?1', 'bind' => array(1 => $vtype->idVisitcategory)));
     $this->view->setVar("vcat", $vcat);
     if (!$vtype) {
         $this->flashSession->error("No se encontró el tipo de visita, por favor valide la información");
         return $this->response->redirect('visittype');
     }
     $form = new VisittypeForm($vtype);
     $this->view->setVar('form', $form);
     $this->view->setVar('vtype', $vtype);
     if ($this->request->isPost()) {
         try {
             $form->bind($this->request->getPost(), $vtype);
             $name = trim($this->request->getPost("name"));
             if ($name == "") {
                 $msg = "El nombre no puede estar vacio, por favor valide la información";
                 throw new Exception($msg);
             }
             $client->updated = time();
             $vtype->idVisitcategory = $this->request->getPost("category");
             if (!$vtype->save()) {
                 foreach ($vtype->getMessages() as $msg) {
                     throw new Exception($msg);
                 }
             }
             $this->flashSession->notice("Se ha editado el tipo de visita: <strong>{$vtype->name}</strong>,  exitosmante");
             return $this->response->redirect('visittype');
         } catch (Exception $ex) {
             $this->flashSession->error($ex->getMessage());
         }
     }
 }