Example #1
0
 /**
  * Save process and task propeties
  *
  * @param object $httpData{UID, type, property, value}
  */
 public function saveProperties($httpData)
 {
     switch ($httpData->type) {
         case 'process':
             require_once 'classes/model/ProcessCategory.php';
             require_once 'classes/model/CalendarDefinition.php';
             G::LoadClass('processMap');
             $oProcessMap = new ProcessMap();
             $process['PRO_UID'] = $httpData->UID;
             switch ($httpData->property) {
                 case 'Title':
                     $fieldName = 'PRO_TITLE';
                     break;
                 case 'Description':
                     $fieldName = 'PRO_DESCRIPTION';
                     break;
                 case 'Debug':
                     $fieldName = 'PRO_DEBUG';
                     $httpData->value = $httpData->value == 'true' ? '1' : '0';
                     break;
                 case 'Category':
                     $fieldName = 'PRO_CATEGORY';
                     $category = ProcessCategory::loadByCategoryName($httpData->value);
                     $httpData->value = $category['CATEGORY_UID'];
                     break;
                 case 'Calendar':
                     $fieldName = 'PRO_CALENDAR';
                     $calendar = CalendarDefinition::loadByCalendarName($httpData->value);
                     G::LoadClass("calendar");
                     $calendarObj = new Calendar();
                     $calendarObj->assignCalendarTo($process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS');
                     break;
             }
             if ($fieldName != 'PRO_CALENDAR') {
                 $process[$fieldName] = $httpData->value;
                 $oProcessMap->updateProcess($process);
             }
             break;
         case 'task':
             require_once 'classes/model/Task.php';
             $oTask = new Task();
             $task['TAS_UID'] = $httpData->UID;
             switch ($httpData->property) {
                 case 'Title':
                     $fieldName = 'TAS_TITLE';
                     break;
                 case 'Description':
                     $fieldName = 'TAS_DESCRIPTION';
                     break;
                 case 'Variable for case priority':
                     $fieldName = 'TAS_PRIORITY_VARIABLE';
                     break;
                 case 'Starting Task':
                     $fieldName = 'TAS_START';
                     $httpData->value = strtoupper($httpData->value);
                     break;
             }
             $task[$fieldName] = $httpData->value;
             $oTask->update($task);
             break;
     }
     $this->sucess = true;
 }
Example #2
0
    /**

     * Create ProcessCategory record

     *

     * @param $ProcessCategory array.

     * @return void

     */

    public function createProcessCategoryRow ($row)

    {

        if ($row && is_array( $row ) && isset( $row['CATEGORY_UID'] )) {

            $record = ProcessCategoryPeer::retrieveByPK( $row['CATEGORY_UID'] );

            // create only if the category doesn't exists

            if (! $record) {

                $processCategory = new ProcessCategory();

                $processCategory->fromArray( $row, BasePeer::TYPE_FIELDNAME );

                $processCategory->save();

            }

        }

    }
                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) {
                echo '{success: false, error: ' . $ex->getMessage() . '}';
            }
            break;
        default:
            echo 'default';
    }
}
Example #4
0
 public function getCategoriesList()
 {
     require_once "classes/model/ProcessCategory.php";
     $processCategory = new ProcessCategory();
     $defaultOption = array();
     $defaultOption[] = array('CATEGORY_UID' => '', 'CATEGORY_NAME' => '');
     $response->rows = array_merge($defaultOption, $processCategory->getAll('array'));
     print G::json_encode($response);
 }
 <?php 
try {
    $form = $_POST['form'];
    $CategoryUid = $form['CATEGORY_UID'];
    $CategoryParent = $form['CATEGORY_PARENT'];
    $CategoryName = $form['CATEGORY_NAME'];
    $CategoryIcon = $form['CATEGORY_ICON'];
    require_once "classes/model/ProcessCategory.php";
    //if exists the row in the database propel will update it, otherwise will insert.
    $tr = ProcessCategoryPeer::retrieveByPK($CategoryUid);
    $processCategory = new ProcessCategory();
    $aProcessCategory = $processCategory->loadByCategoryName($CategoryName);
    if (!is_array($aProcessCategory)) {
        if (!(is_object($tr) && get_class($tr) == 'ProcessCategory')) {
            $tr = new ProcessCategory();
        }
        $tr->setCategoryUid($CategoryUid);
        $tr->setCategoryParent($CategoryParent);
        $tr->setCategoryName($CategoryName);
        $tr->setCategoryIcon($CategoryIcon);
        if ($tr->validate()) {
            // we save it, since we get no validation errors, or do whatever else you like.
            $res = $tr->save();
        } else {
            // Something went wrong. We can now get the validationFailures and handle them.
            $msg = '';
            $validationFailuresArray = $tr->getValidationFailures();
            foreach ($validationFailuresArray as $objValidationFailure) {
                $msg .= $objValidationFailure->getMessage() . "<br/>";
            }
            //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
 /**
  * Delete Category
  *
  * @param string $categoryUid Unique id of Category
  *
  * return void
  */
 public function delete($categoryUid)
 {
     try {
         //Verify data
         $this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
         $process = new \Process();
         $arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
         if (isset($arrayTotalProcessesByCategory[$categoryUid]) && (int) $arrayTotalProcessesByCategory[$categoryUid] > 0) {
             throw new \Exception(\G::LoadTranslation("ID_MSG_CANNOT_DELETE_CATEGORY"));
         }
         //Delete
         $category = new \ProcessCategory();
         $category->setCategoryUid($categoryUid);
         $category->delete();
     } catch (\Exception $e) {
         throw $e;
     }
 }
Example #7
0
 /**
  * Validate cat_uid
  *
  * @param string $cat_uid, Uid for category
  * @param string $nameField . Name of field for message
  *
  * @access public
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return string
  */
 public static function catUid($cat_uid, $nameField = 'cat_uid')
 {
     $cat_uid = trim($cat_uid);
     if ($cat_uid == '') {
         throw new \Exception(\G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, '')));
     }
     $oCategory = new \ProcessCategory();
     if (!$oCategory->exists($cat_uid)) {
         throw new \Exception(\G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField, $cat_uid)));
     }
     return $cat_uid;
 }
                $pcat->setCategoryName($catName);
                $pcat->save();
                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);
                $cat->delete();
                echo '{success: true}';
            } catch (Exception $ex) {
                echo '{success: false, error: ' . $ex->getMessage() . '}';
            }
            break;
        default:
            echo 'default';
    }
}
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 *
 */
if (isset($_POST['function'])) {
    switch ($_POST['function']) {
        case 'checkCategoryName':
            $CategoryName = $_POST['CategoryName'];
            require_once "classes/model/ProcessCategory.php";
            $processCategory = new ProcessCategory();
            $aProcessCategory = $processCategory->loadByCategoryName($CategoryName);
            if (is_array($aProcessCategory)) {
                return print '1';
            } else {
                return print '0';
            }
            break;
        default:
            echo 'default';
    }
}