コード例 #1
0
 public function editAction($dealerId = NULL)
 {
     $this->view->setVar("title", "Редагування дилера");
     $user = $this->session->get("user");
     $methodistBrands = \BrandsMethodists::find("user_id=" . $user->id)->toArray();
     $methodistActivities = \ActivitiesMethodists::find("user_id=" . $user->id)->toArray();
     $dealer = $dealerId ? \Dealers::findFirst($dealerId) : new \Dealers();
     if ($dealerId and !$dealer->id) {
         // не найден такой диллер
         $this->view->pick("dealer/not-found");
         return;
     }
     $city = $dealer->City;
     $this->view->regionId = $city ? $city->Region->id : NULL;
     $dealerBrands = $dealer->id ? $dealer->DealersBrands->toArray() : array();
     $dealerActivities = $dealer->id ? \DealersActivities::find("dealer_id=" . $dealer->id)->toArray() : array();
     $this->view->dealers = \Dealers::find(array('order' => 'title'));
     $this->view->regions = \Region::find();
     $this->view->regionFirst = $this->view->regions[0];
     $this->view->cities = \City::find();
     $this->view->staffListGroup = \StafflistGroup::find();
     $this->view->brands = BrandsService::getForChosenEntity(\Brands::find()->toArray(), $methodistBrands, $dealerBrands);
     $this->view->activities = ActivitiesService::getForChosenEntity(\Activities::find()->toArray(), $methodistActivities, $dealerActivities);
     $this->view->dealerStatuses = \DealerStatuses::find();
     $controllers = \Users::query()->rightJoin("UserGroups")->where("UserGroups.group_id = 3")->execute();
     $this->view->controllers = $controllers;
     $this->view->dealerControllers = $dealer->DealersControllers;
     $this->view->dealer = $dealer;
     $this->view->saved = $this->request->get("saved");
 }
コード例 #2
0
 function addnewAction($system_id)
 {
     $system = Systems::findFirstById($system_id);
     $last_version_date = Versions::last_version_date();
     $last_version = Versions::last_version();
     $activities = Activities::find(array("date > '{$last_version_date}' "));
     $form = new VersionsForm();
     $this->view->system = $system;
     $this->view->last_version_date = $last_version_date;
     $this->view->last_version = $last_version;
     $this->view->activities = $activities;
     $this->view->form = $form;
 }
コード例 #3
0
 function editAction($activity_id, $system_id)
 {
     $activity = Activities::findFirstById($activity_id);
     $system = Systems::findFirstById($system_id);
     $form = new ActivityForm($activity);
     $bugs_id = new Select('bugs_id', Bugs::find(), array('useEmpty' => true));
     $bugs_id->setLabel('Select Bugs');
     $bugs_id->setDefault(array($activity->bugs_id));
     $array = [];
     foreach (Bugs::find(array('system_id = ' . $system_id)) as $bug) {
         if ($bug->modules_id) {
             $modules_name = '[' . $bug->modules->name . '] - ';
         } else {
             $modules_name = '';
         }
         $array[$bug->id] = $modules_name . ' ' . $bug->description;
     }
     $bugs_id->setOptions($array);
     $form->add($bugs_id);
     /*=======  Modules  =======*/
     $modulesId = new Select('modules_id', Modules::find(array('system_id = ' . $system_id)), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->setDefault(array($activity->modules_id));
     $form->add($modulesId);
     $this->view->activity = $activity;
     $this->view->system = $system;
     $this->view->page = 'Modules';
     $this->view->form = $form;
     if ($this->request->isPost()) {
         $activities = new Activities();
         $activity_id = $this->request->getPost('id');
         $activities = Activities::find($activity_id);
         if ($activities->update($this->request->getPost()) == false) {
             foreach ($activities->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Edit Activity Success');
             $this->response->redirect('activity/system/' . $system_id);
         }
     }
 }
コード例 #4
0
 public function editAction($id = NULL)
 {
     $this->view->title = "Редагувати студента";
     $this->view->nothing = true;
     $this->view->ind_code = $this->request->get("ind_code");
     if (!is_null($this->view->ind_code) && $this->checkINN($this->view->ind_code) || !is_null($id)) {
         $this->view->nothing = false;
         $this->view->student = is_null($id) ? \Students::findFirst("ind_code = " . $this->view->ind_code) : \Students::findFirst($id);
         $this->view->user = $this->session->get("user");
         $methodistBrands = \BrandsMethodists::find("user_id=" . $this->view->user->id)->toArray();
         $methodistActivities = \ActivitiesMethodists::find("user_id=" . $this->view->user->id)->toArray();
         if ($this->view->student != NULL) {
             $this->view->ind_code = $this->view->student->ind_code;
             $this->view->user = \Users::findFirst($this->view->student->user_id);
             $studentBrands = BrandsService::getStudentBrands($this->view->student);
             $studentActivities = ActivitiesService::getStudentActivities($this->view->student);
             $studentPostsJSON = array();
             if ($this->view->student->StudentsPosts != NULL) {
                 foreach ($this->view->student->StudentsPosts as $sp) {
                     //{"dealer":"1","post":"2","brands":["2", "5"],"activities":["1"],"rate":"1.0","appoint_date":"2015-04-01"}
                     $studentPostsJSON[$sp->id] = array();
                     $studentPostsJSON[$sp->id]["dealer"] = $sp->dealer;
                     $studentPostsJSON[$sp->id]["post"] = $sp->post;
                     $array = array();
                     foreach ($sp->StudentsPostsBrands as $spb) {
                         $array[] = $spb->Brands->id;
                     }
                     $studentPostsJSON[$sp->id]["brands"] = $array;
                     $array = array();
                     foreach ($sp->StudentsPostsActivities as $spa) {
                         $array[] = $spa->Activities->id;
                     }
                     $studentPostsJSON[$sp->id]["activities"] = $array;
                     $studentPostsJSON[$sp->id]["rate"] = $sp->rate;
                     $studentPostsJSON[$sp->id]["appoint_date"] = $sp->appoint_date;
                 }
             }
             //$this->view->student->StudentsEducation;
         } else {
             $this->view->student = new \Students();
             $this->view->user = new \Users();
             $studentPostsJSON = array();
             $studentBrands = array();
             $studentActivities = array();
         }
         $this->view->brands = BrandsService::getForChosenEntity(\Brands::find()->toArray(), $methodistBrands, $studentBrands);
         $this->view->activities = ActivitiesService::getForChosenEntity(\Activities::find()->toArray(), $methodistActivities, $studentActivities);
         $this->view->allEducations = \Educations::find("parent_id is NULL");
         $this->view->allDealers = \Dealers::find();
         $this->view->studentPostsJSON = $studentPostsJSON;
     }
 }