Ejemplo n.º 1
0
 /**
  * @param REQUEST service_code
  */
 public function services()
 {
     // If a service_id is provided, they want the service info
     if (isset($_REQUEST['service_code'])) {
         try {
             $category = new Category($_REQUEST['service_code']);
             if ($category->allowsPosting($this->person)) {
                 $this->template->blocks[] = new Block('open311/serviceInfo.inc', array('category' => $category));
             } else {
                 // Not allowed to post to this category
                 header('HTTP/1.0 403 Forbidden', true, 403);
                 $_SESSION['errorMessages'][] = new \Exception('noAccessAllowed');
             }
         } catch (\Exception $e) {
             // Unknown service
             header('HTTP/1.0 404 Not Found', true, 404);
             $_SESSION['errorMessages'][] = new \Exception('open311/unknownService');
         }
     } else {
         $table = new CategoryTable();
         $categoryList = $table->find();
         $this->template->blocks[] = new Block('open311/serviceList.inc', array('categoryList' => $categoryList));
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns an array of Category objects, indexed by Id
  * @return array
  */
 public function getCategories()
 {
     if (!count($this->categories) && $this->getId()) {
         $table = new CategoryTable();
         $list = $table->find(['department_id' => $this->getId()]);
         foreach ($list as $c) {
             $this->categories[$c->getId()] = $c;
         }
     }
     return $this->categories;
 }
 /**
  * A form for updating the SLA times for all categories at once
  */
 public function sla()
 {
     $this->template->setFilename('backend');
     if (isset($_POST['categories'])) {
         try {
             foreach ($_POST['categories'] as $id => $post) {
                 $category = new Category($id);
                 $category->setSlaDays($post['slaDays']);
                 $category->save();
             }
             header('Location: ' . BASE_URL . '/categories');
             exit;
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $t = new CategoryTable();
     $list = $t->find();
     $this->template->blocks[] = new Block('categories/slaForm.inc', ['categoryList' => $list]);
 }
Ejemplo n.º 4
0
 public function testGetByDepartment()
 {
     $table = new CategoryTable();
     $list = $table->find(['department_id' => $this->unusedDepartment]);
     $this->assertEquals(2, count($list));
 }
Ejemplo n.º 5
0
 /**
  * @return Zend\Db\ResultSet
  */
 public function getCategories()
 {
     $table = new CategoryTable();
     return $table->find(['categoryGroup_id' => $this->getId()]);
 }