[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/com_vtiger_workflow/ -> edittask.php (source)

   1  <?php
   2  /*+**********************************************************************************
   3   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   ************************************************************************************/
  10  
  11  require_once ("include/utils/CommonUtils.php");
  12  require_once ("include/events/SqlResultIterator.inc");
  13  require_once ("include/events/VTWSEntityType.inc");
  14  
  15  require_once ("VTWorkflowApplication.inc");
  16  require_once ("VTTaskManager.inc");
  17  require_once ("VTWorkflowManager.inc");
  18  require_once ("VTWorkflowUtils.php");
  19  	function vtTaskEdit($adb, $request, $current_language, $app_strings){
  20          global $theme;
  21          $util = new VTWorkflowUtils();
  22          $image_path = "themes/$theme/images/";
  23  
  24          $module = new VTWorkflowApplication('edittask');
  25  
  26          $mod = return_module_language($current_language, $module->name);
  27  
  28          if(!$util->checkAdminAccess()){
  29              $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
  30              $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
  31              return;
  32          }
  33  
  34          $smarty = new vtigerCRM_Smarty();
  35          $tm = new VTTaskManager($adb);
  36          $smarty->assign('edit',isset($request["task_id"]));
  37          if(isset($request["task_id"])){
  38              $task = $tm->retrieveTask($request["task_id"]);
  39              $taskClass = get_class($task);
  40              $workflowId=$task->workflowId;
  41          }else{
  42              $workflowId = $request["workflow_id"];
  43              $taskClass = vtlib_purifyForSql($request["task_type"]);
  44              $task = $tm->createTask($taskClass, $workflowId);
  45          }
  46  
  47          if($task==null){
  48              $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_TASK']);
  49              $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_TASK']);
  50              return;
  51          }
  52  
  53          $wm = new VTWorkflowManager($adb);
  54          $workflow = $wm->retrieve($workflowId);
  55          if($workflow==null){
  56              $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
  57              $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
  58              return;
  59          }
  60  
  61  
  62          $smarty->assign("workflow", $workflow);
  63          $smarty->assign("returnUrl", vtlib_purify($request["return_url"]));
  64          $smarty->assign("task", $task);
  65          $smarty->assign("taskType", $taskClass);
  66          $smarty->assign("saveType", vtlib_purify($request['save_type']));
  67  
  68          $taskTypeInstance = VTTaskType::getInstanceFromTaskType($taskClass);
  69          $taskTemplateClass = $tm->retrieveTemplatePath($module->name, $taskTypeInstance);
  70          $smarty->assign("taskTemplate", $taskTemplateClass);
  71  
  72          $et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName);
  73          $smarty->assign("entityType", $et);
  74          $smarty->assign('entityName', $workflow->moduleName);
  75          $smarty->assign("fieldNames", $et->getFieldNames());
  76          $repeat_date = $task->calendar_repeat_limit_date;
  77          if(!empty ($repeat_date)){
  78              $repeat_date = DateTimeField::convertToUserFormat($repeat_date);
  79          }
  80          $smarty->assign('REPEAT_DATE',$repeat_date);
  81          $dateFields = array();
  82          $fieldTypes = $et->getFieldTypes();
  83          $fieldLabels = $et->getFieldLabels();
  84          foreach($fieldTypes as $name => $type){
  85              if($type->type=='Date' || $type->type=='DateTime'){
  86                  $dateFields[$name] = $fieldLabels[$name];
  87              }
  88          }
  89  
  90          $smarty->assign('dateFields', $dateFields);
  91  
  92  
  93          if($task->trigger!=null){
  94              $trigger = $task->trigger;
  95              $days = $trigger['days'];
  96              if ($days < 0){
  97                  $days*=-1;
  98                  $direction = 'before';
  99              }else{
 100                  $direction = 'after';
 101              }
 102              $smarty->assign('trigger', array('days'=>$days, 'direction'=>$direction,
 103                'field'=>$trigger['field']));
 104          }
 105          $metaVariables = $task->getMetaVariables();
 106  
 107          $date = new DateTimeField(null);
 108          $time = substr($date->getDisplayTime(), 0, 5);
 109          $smarty->assign("META_VARIABLES",$metaVariables);
 110          $smarty->assign("SYSTEM_TIMEZONE",$db_timezone);
 111          $smarty->assign("USER_TIME",$task->formatTimeForTimePicker($time));
 112          $smarty->assign("USER_DATE", $date->getDisplayDate());
 113          $smarty->assign("MOD", array_merge(
 114              return_module_language($current_language,'Settings'),
 115              return_module_language($current_language, 'Calendar'),
 116              return_module_language($current_language, $module->name)));
 117          $smarty->assign("APP", $app_strings);
 118          $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 119          $smarty->assign("IMAGE_PATH",$image_path);
 120          $smarty->assign("THEME", $theme);
 121          $smarty->assign("MODULE_NAME", $module->label);
 122          $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']);
 123          $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']);
 124  
 125          $users = $group = array();
 126          $users = get_user_array();
 127          $group = get_group_array();
 128          foreach($group as $id => $name) {
 129              $users[$id] = $name;
 130          }
 131          $smarty->assign('ASSIGNED_TO', $users);
 132          $smarty->assign("module", $module);
 133          $smarty->display("{$module->name}/EditTask.tpl");
 134      }
 135      vtTaskEdit($adb, $_REQUEST, $current_language, $app_strings);
 136  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1