$catName = trim($_REQUEST['category']);
         $pcat = new ProcessCategory();
         $pcat->setNew(false);
         $pcat->setCategoryUid($catUID);
         $pcat->setCategoryName($catName);
         $pcat->save();
         g::auditLog("UpdateCategory", "Category Name: " . $catName . " Category ID: (" . $catUID . ") ");
         echo '{success: true}';
     } catch (Exception $ex) {
         echo '{success: false, error: ' . $ex->getMessage() . '}';
     }
     break;
 case 'canDeleteCategory':
     require_once 'classes/model/Process.php';
     $proc = new Process();
     $aProcess = $proc->getAllProcessesByCategory();
     $catUID = $_REQUEST['CAT_UID'];
     $response = isset($aProcess[$catUID]) ? 'false' : 'true';
     echo $response;
     break;
 case 'deleteCategory':
     try {
         require_once 'classes/model/ProcessCategory.php';
         $catUID = $_REQUEST['cat_uid'];
         $cat = new ProcessCategory();
         $cat->setCategoryUid($catUID);
         $catName = $cat->loadByCategoryId($catUID);
         $cat->delete();
         G::auditLog("DeleteCategory", "Category Name: " . $catName . " Category ID: (" . $catUID . ") ");
         echo '{success: true}';
     } catch (Exception $ex) {
Ejemplo n.º 2
0
 /**
  * Get data of a Category
  *
  * @param string $categoryUid   Unique id of Category
  * @param bool   $flagGetRecord Value that set the getting
  *
  * return array Return an array with data of a Category
  */
 public function getCategory($categoryUid, $flagGetRecord = false)
 {
     try {
         //Verify data
         $this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
         //Set variables
         if (!$flagGetRecord) {
             $process = new \Process();
             $arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
         }
         //Get data
         //SQL
         $criteria = $this->getCategoryCriteria();
         $criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $categoryUid, \Criteria::EQUAL);
         $rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $rsCriteria->next();
         $row = $rsCriteria->getRow();
         if (!$flagGetRecord) {
             $row["CATEGORY_TOTAL_PROCESSES"] = isset($arrayTotalProcessesByCategory[$row["CATEGORY_UID"]]) ? (int) $arrayTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0;
         }
         //Return
         return !$flagGetRecord ? $this->getCategoryDataFromRecord($row) : $row;
     } catch (\Exception $e) {
         throw $e;
     }
 }