/**
  * add a delegation
  * @param \library\httpRequest $request
  * @return void
  */
 public function addAction(\library\httpRequest $request)
 {
     $this->page->setLayout('modal');
     //get all users except me
     $usersService = new \applications\modules\users\services\usersService();
     $users = $usersService->getAllActiveUsers($_SESSION['users']->id);
     //build delegation entity
     $this->currentEntity->setUsers1($_SESSION['users']->id);
     //set categories and instances
     if ($request->getGET('categories') != "") {
         $this->currentEntity->setCategories($request->getGET('categories'));
     }
     if ($request->getGET('instances') != "") {
         $this->currentEntity->setInstances($request->getGET('instances'));
     }
     // create form
     $formBuilder = new \applications\modules\instances\forms\delegationsForm($this->currentEntity);
     $formBuilder->build();
     $form = $formBuilder->getForm();
     if ($request->isPosted() && $form->isValid()) {
         if ($this->currentService->add($this->currentEntity)) {
             $this->page->addVar('msgSuccess', _TR_DelegationAddSuccessfully);
         }
     }
     $this->page->addVar('form', $form->createView());
 }
 /**
  * build code form
  */
 public function build()
 {
     $usersService = new \applications\modules\users\services\usersService();
     foreach ($usersService->getAllActiveUsers($_SESSION['users']->id) as $value) {
         $users2List[$value->id] = $value->name;
     }
     $this->form->add(new \library\webComponents\select(array("title" => _TR_Users2, "name" => "users2", "value" => $this->form->getEntity()->getUsers2(), "values" => $users2List)));
     $this->form->add(new \library\webComponents\hidden(array("title" => _TR_Categories, "name" => "categories", "value" => $this->form->getEntity()->getCategories())));
     $this->form->add(new \library\webComponents\hidden(array("title" => _TR_Instance, "name" => "instances", "value" => $this->form->getEntity()->getInstances())));
     $this->form->add(new \library\webComponents\hidden(array("title" => "id", "name" => "id", "readonly" => "readonly", "value" => $this->form->getEntity()->getId())));
     $this->form->add(new \library\webComponents\hidden(array("title" => _TR_Users1, "name" => "users1", "value" => $this->form->getEntity()->getUsers1())));
 }
 /**
  * build descr form
  */
 public function build()
 {
     $usersService = new \applications\modules\users\services\usersService();
     foreach ($usersService->getAllActiveUsers() as $value) {
         $usersList[$value->id] = $value->name;
     }
     $this->form->add(new \library\webComponents\select(array("title" => _TR_Users, "name" => "users", "value" => $this->form->getEntity()->getUsers(), "values" => $usersList, "validators" => array(new \library\validators\notNullValidator("<b>" . _TR_Users . '</b> : ' . _TR_NotNull)))));
     $this->form->add(new \library\webComponents\bool(array("title" => _TR_CanSeeTheInstance, "name" => "whoCanSeeTheInstance", "value" => $this->form->getEntity()->getWhoCanSeeTheInstance())));
     $this->form->add(new \library\webComponents\bool(array("title" => _TR_CanVote, "name" => "whoCanVote", "value" => $this->form->getEntity()->getWhoCanVote())));
     $this->form->add(new \library\webComponents\bool(array("title" => _TR_CanWriteVote, "name" => "whoCanWriteVote", "value" => $this->form->getEntity()->getWhoCanWriteVote())));
     $this->form->add(new \library\webComponents\hidden(array("title" => _TR_Id, "name" => "id", "readonly" => "readonly", "value" => $this->form->getEntity()->getId())));
     $this->form->add(new \library\webComponents\hidden(array("title" => _TR_Instance, "name" => "instances", "readonly" => "readonly", "value" => $this->form->getEntity()->getInstances())));
 }