Example #1
0
 public function saveProperties($param)
 {
     try {
         $result->sucess = true;
         $result->msg = '';
         switch ($param['type']) {
             case 'process':
                 require_once 'classes/model/ProcessCategory.php';
                 require_once 'classes/model/CalendarDefinition.php';
                 G::LoadClass('processMap');
                 $oProcessMap = new ProcessMap();
                 $process['PRO_UID'] = $param['UID'];
                 switch ($param['property']) {
                     case 'Title':
                         $fieldName = 'PRO_TITLE';
                         break;
                     case 'Description':
                         $fieldName = 'PRO_DESCRIPTION';
                         break;
                     case 'Debug':
                         $fieldName = 'PRO_DEBUG';
                         $param['value'] = $param['value'] == 'true' ? '1' : '0';
                         break;
                     case 'Category':
                         $fieldName = 'PRO_CATEGORY';
                         $category = ProcessCategory::loadByCategoryName($param['value']);
                         $param['value'] = $category[0]['CATEGORY_UID'];
                         break;
                     case 'Calendar':
                         $fieldName = 'PRO_CALENDAR';
                         $calendar = CalendarDefinition::loadByCalendarName($param['value']);
                         G::LoadClass("calendar");
                         $calendarObj = new Calendar();
                         $calendarObj->assignCalendarTo($process['PRO_UID'], $calendar['CALENDAR_UID'], 'PROCESS');
                         break;
                 }
                 if ($fieldName != 'PRO_CALENDAR') {
                     $process[$fieldName] = $param['value'];
                     $oProcessMap->updateProcess($process);
                 }
                 break;
             case 'task':
                 require_once 'classes/model/Task.php';
                 $oTask = new Task();
                 $task['TAS_UID'] = $param['UID'];
                 switch ($param['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';
                         $param['value'] = strtoupper($param['value']);
                         break;
                 }
                 $task[$fieldName] = $param['value'];
                 print_r($task);
                 $oTask->update($task);
                 break;
         }
     } catch (Exception $e) {
         $result->sucess = false;
         $result->msg = $e->getMessage();
     }
     print G::json_encode($result);
 }
Example #2
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;
 }
 <?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 );