Пример #1
0
function vtDisplayWorkflowList($adb, $request, $requestUrl, $app_strings, $current_language)
{
    global $theme;
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication("workflowlist");
    $util = new VTWorkflowUtils();
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $wfs = new VTWorkflowManager($adb);
    $smarty->assign("moduleNames", $util->vtGetModules($adb));
    $smarty->assign("returnUrl", $requestUrl);
    $listModule = $request['list_module'];
    $smarty->assign("listModule", $listModule);
    if ($listModule == null || strtolower($listModule) == "all") {
        $smarty->assign("workflows", $wfs->getWorkflows());
    } else {
        $smarty->assign("workflows", $wfs->getWorkflowsForModule($listModule));
    }
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, $module->name)));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_WORKFLOW_LIST']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_AVAILABLE_WORKLIST_LIST']);
    $smarty->assign("module", $module);
    $smarty->assign('MODULE', $module->name);
    $smarty->assign("CRON_TASK", Vtiger_Cron::getInstance('Workflow'));
    $smarty->display("{$module->name}/ListWorkflows.tpl");
}
Пример #2
0
 public function doTask($entity)
 {
     if (SMSNotifier::checkServer()) {
         global $adb, $current_user, $log;
         $util = new VTWorkflowUtils();
         $admin = $util->adminUser();
         $ws_id = $entity->getId();
         $entityCache = new VTEntityCache($admin);
         $et = new VTSimpleTemplate($this->sms_recepient);
         $recepient = $et->render($entityCache, $ws_id);
         $recepients = explode(',', $recepient);
         $ct = new VTSimpleTemplate($this->content);
         $content = $ct->render($entityCache, $ws_id);
         $relatedCRMid = substr($ws_id, stripos($ws_id, 'x') + 1);
         $relatedModule = $entity->getModuleName();
         /** Pickup only non-empty numbers */
         $tonumbers = array();
         foreach ($recepients as $tonumber) {
             if (!empty($tonumber)) {
                 $tonumbers[] = $tonumber;
             }
         }
         SMSNotifier::sendsms($content, $tonumbers, $current_user->id, $relatedCRMid, $relatedModule);
     }
 }
Пример #3
0
function vtDeleteWorkflow($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("deltetask");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $wm = new VTTaskManager($adb);
    $wm->deleteTask($request['task_id']);
    if (isset($request["return_url"])) {
        $returnUrl = vtlib_purify($request["return_url"]);
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Пример #4
0
function vtDisplayTaskList($adb, $requestUrl, $current_language)
{
    global $theme, $app_strings;
    $image_path = "themes/{$theme}/images/";
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("tasklist");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $tm = new VTTaskManager($adb);
    $smarty->assign("tasks", $tm->getTasks());
    $smarty->assign("moduleNames", array("Contacts", "Applications"));
    $smarty->assign("taskTypes", array("VTEmailTask", "VTDummyTask"));
    $smarty->assign("returnUrl", $requestUrl);
    $smarty->assign("MOD", return_module_language($current_language, 'Settings'));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", 'Task List');
    $smarty->assign("PAGE_TITLE", 'List available tasks');
    $smarty->assign("moduleName", $moduleName);
    $smarty->display("{$module->name}/ListTasks.tpl");
}
Пример #5
0
function vtSaveWorkflowTemplate($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("savetemplate");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $title = vtlib_purifyForSql($request['title']);
    $workflowId = $request['workflow_id'];
    $wfs = new VTworkflowManager($adb);
    $workflow = $wfs->retrieve($workflowId);
    $tm = new VTWorkflowTemplateManager($adb);
    $tpl = $tm->newTemplate($title, $workflow);
    $tm->saveTemplate($tpl);
    $returnUrl = vtlib_purify($request['return_url']);
    ?>
		<script type="text/javascript" charset="utf-8">
			 window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
	<?php 
}
 function handleEvent($eventName, $data)
 {
     if ($eventName == 'vtiger.entity.beforesave') {
         // Entity is about to be saved, take required action
     }
     if ($eventName == 'vtiger.entity.aftersave') {
         $db = PearDatabase::getInstance();
         $relatedToId = $data->get('related_to');
         if ($relatedToId) {
             $moduleName = getSalesEntityType($relatedToId);
             $focus = CRMEntity::getInstance($moduleName);
             $focus->retrieve_entity_info($relatedToId, $moduleName);
             $focus->id = $relatedToId;
             $fromPortal = $data->get('from_portal');
             if ($fromPortal) {
                 $focus->column_fields['from_portal'] = $fromPortal;
             }
             $entityData = VTEntityData::fromCRMEntity($focus);
             $wfs = new VTWorkflowManager($db);
             $relatedToEventHandler = new VTWorkflowEventHandler();
             $relatedToEventHandler->workflows = $wfs->getWorkflowsForModuleSupportingComments($entityData->getModuleName());
             $wsId = vtws_getWebserviceEntityId($entityData->getModuleName(), $entityData->getId());
             $fromPortal = $entityData->get('from_portal');
             $util = new VTWorkflowUtils();
             $entityCache = new VTEntityCache($util->adminUser());
             $entityCacheData = $entityCache->forId($wsId);
             $entityCacheData->set('from_portal', $fromPortal);
             $entityCache->cache[$wsId] = $entityCacheData;
             $relatedToEventHandler->handleEvent($eventName, $entityData, $entityCache);
             $util->revertUser();
         }
     }
 }
Пример #7
0
 public function __construct($adb)
 {
     $util = new VTWorkflowUtils();
     $adminUser = $util->adminUser();
     $this->user = $adminUser;
     $this->db = $adb;
 }
Пример #8
0
function vtSaveTask($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("savetask");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $tm = new VTTaskManager($adb);
    if (isset($request["task_id"])) {
        $task = $tm->retrieveTask($request["task_id"]);
    } else {
        $taskType = vtlib_purifyForSql($request["task_type"]);
        $workflowId = $request["workflow_id"];
        $task = $tm->createTask($taskType, $workflowId);
    }
    $task->summary = $request["summary"];
    if ($request["active"] == "true") {
        $task->active = true;
    } else {
        if ($request["active"] == "false") {
            $task->active = false;
        }
    }
    if (isset($request['check_select_date'])) {
        $trigger = array('days' => ($request['select_date_direction'] == 'after' ? 1 : -1) * (int) $request['select_date_days'], 'field' => $request['select_date_field']);
        $task->trigger = $trigger;
    } else {
        $task->trigger = null;
    }
    $fieldNames = $task->getFieldNames();
    foreach ($fieldNames as $fieldName) {
        $task->{$fieldName} = $request[$fieldName];
        if ($fieldName == 'calendar_repeat_limit_date') {
            $task->{$fieldName} = DateTimeField::convertToDBFormat($request[$fieldName]);
        }
    }
    $tm->saveTask($task);
    if (isset(vtlib_purify($request["return_url"]))) {
        $returnUrl = vtlib_purify($request["return_url"]);
    } else {
        $returnUrl = $module->editTaskUrl($task->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Пример #9
0
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    $request = vtlib_purify($request);
    // this cleans all values of the array
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = $request["module_name"];
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = $request["save_type"];
    $executionCondition = $request['execution_condition'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset($request["return_url"])) {
        $returnUrl = $request["return_url"];
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Пример #10
0
function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_strings)
{
    global $theme;
    $util = new VTWorkflowUtils();
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication("editworkflow");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    if ($request['source'] == 'from_template') {
        $tm = new VTWorkflowTemplateManager($adb);
        $template = $tm->retrieveTemplate($request['template_id']);
        $workflow = $tm->createWorkflow($template);
    } else {
        $wfs = new VTWorkflowManager($adb);
        if (isset($request["workflow_id"])) {
            $workflow = $wfs->retrieve($request["workflow_id"]);
        } else {
            $moduleName = $request["module_name"];
            $workflow = $wfs->newWorkflow($moduleName);
        }
    }
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $workflow->test = addslashes($workflow->test);
    $tm = new VTTaskManager($adb);
    $tasks = $tm->getTasksForWorkflow($workflow->id);
    $smarty->assign("tasks", $tasks);
    $taskTypes = $tm->getTaskTypes($workflow->moduleName);
    $smarty->assign("taskTypes", $taskTypes);
    $smarty->assign("newTaskReturnUrl", vtlib_purify($requestUrl));
    $smarty->assign("returnUrl", vtlib_purify($request["return_url"]));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, $module->name)));
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_WORKFLOW']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_WORKFLOW_TITLE']);
    $smarty->assign("workflow", $workflow);
    $smarty->assign("saveType", isset($workflow->id) ? "edit" : "new");
    $smarty->assign("module", $module);
    $smarty->assign("WORKFLOW_TRIGGER_TYPES_HELP_LINK", WORKFLOW_TRIGGER_TYPES);
    $smarty->display("{$module->name}/EditWorkflow.tpl");
}
Пример #11
0
function vtRunTaskJob($adb)
{
    $util = new VTWorkflowUtils();
    $adminUser = $util->adminUser();
    $tq = new VTTaskQueue($adb);
    $readyTasks = $tq->getReadyTasks();
    $tm = new VTTaskManager($adb);
    foreach ($readyTasks as $pair) {
        list($taskId, $entityId) = $pair;
        $task = $tm->retrieveTask($taskId);
        $entity = new VTWorkflowEntity($adminUser, $entityId);
        $task->doTask($entity);
    }
}
Пример #12
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     return $settingsLinks;
 }
Пример #13
0
function evalwfEmailTask($entityid, $task)
{
    global $entityCache, $HELPDESK_SUPPORT_EMAIL_ID;
    $util = new VTWorkflowUtils();
    $admin = $util->adminUser();
    $from_name = $from_email = '';
    if (!empty($task->fromname)) {
        $fnt = new VTEmailRecipientsTemplate($task->fromname);
        $from_name = $fnt->render($entityCache, $entityid);
    }
    $fromname = $from_name;
    if (!empty($task->fromemail)) {
        $fet = new VTEmailRecipientsTemplate($task->fromemail);
        $from_email = $fet->render($entityCache, $entityid);
    }
    $fromemail = $from_email;
    if (empty($from_name) and !empty($from_email)) {
        $fromname = 'first and last name of user with email: ' . $from_email;
    }
    if (!empty($from_name) and empty($from_email)) {
        $fromname = 'first and last name of user with user_name: ' . $from_name;
        $fromemail = 'email of user with user_name: ' . $from_name;
    }
    if (empty($from_name) and empty($from_email)) {
        $fromemail = $HELPDESK_SUPPORT_EMAIL_ID;
        $fromname = 'first and last name of user with user_name: ' . $HELPDESK_SUPPORT_EMAIL_ID;
    }
    $et = new VTEmailRecipientsTemplate($task->recepient);
    $to_email = $et->render($entityCache, $entityid);
    $ecct = new VTEmailRecipientsTemplate($task->emailcc);
    $cc = $ecct->render($entityCache, $entityid);
    $ebcct = new VTEmailRecipientsTemplate($task->emailbcc);
    $bcc = $ebcct->render($entityCache, $entityid);
    $to_email = preg_replace('/,,+/', ',', $to_email);
    $cc = preg_replace('/,,+/', ',', $cc);
    $bcc = preg_replace('/,,+/', ',', $bcc);
    $st = new VTSimpleTemplate($task->subject);
    $subject = $st->render($entityCache, $entityid);
    $ct = new VTSimpleTemplate($task->content);
    $content = $ct->render($entityCache, $entityid);
    $util->revertUser();
    return array('from_name' => $fromname, 'from_email' => $fromemail, 'to_email' => $to_email, 'cc' => $cc, 'bcc' => $bcc, 'subject' => $subject, 'content' => $content);
}
Пример #14
0
 /**
  * Push the admin user on to the user stack
  * and make it the $current_user
  *
  */
 function adminUser()
 {
     $user = Users::getActiveAdminUser();
     global $current_user;
     if (empty(self::$userStack) || count(self::$userStack) == 0) {
         self::$loggedInUser = $current_user;
     }
     array_push(self::$userStack, $current_user);
     $current_user = $user;
     return $user;
 }
Пример #15
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     if (!$this->isEntityModule()) {
         return array();
     }
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTINGS', 'linklabel' => 'LBL_SERVER_CONFIGURATION', 'linkurl' => 'index.php?parent=Settings&module=PBXManager&view=Index', 'linkicon' => '');
     return $settingsLinks;
 }
Пример #16
0
 public function getSettingLinks()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_FIELDS', 'linkurl' => 'index.php?parent=Settings&module=LayoutEditor&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflow&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_PICKLIST_VALUES', 'linkurl' => 'index.php?parent=Settings&module=Picklist&source_module=' . $this->getName(), 'linkicon' => '');
     if ($this->hasSequenceNumberField()) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_MODULE_SEQUENCE_NUMBERING', 'linkurl' => 'index.php?parent=Settings&module=Vtiger&view=CustomRecordNumbering&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     return $settingsLinks;
 }
Пример #17
0
function vtTaskEdit($adb, $request, $current_language, $app_strings)
{
    global $theme;
    $util = new VTWorkflowUtils();
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication('edittask');
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $tm = new VTTaskManager($adb);
    $smarty->assign('edit', isset($request["task_id"]));
    if (isset($request["task_id"])) {
        $task = $tm->retrieveTask($request["task_id"]);
        $workflowId = $task->workflowId;
    } else {
        $workflowId = $request["workflow_id"];
        $taskClass = $request["task_type"];
        $task = $tm->createTask($taskClass, $workflowId);
    }
    if ($task == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_TASK']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_TASK']);
        return;
    }
    $wm = new VTWorkflowManager($adb);
    $workflow = $wm->retrieve($workflowId);
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $smarty->assign("workflow", $workflow);
    $smarty->assign("returnUrl", $request["return_url"]);
    $smarty->assign("task", $task);
    $smarty->assign("taskType", $taskClass);
    $smarty->assign("saveType", $request['save_type']);
    $taskClass = get_class($task);
    $smarty->assign("taskTemplate", "{$module->name}/taskforms/{$taskClass}.tpl");
    $et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName);
    $smarty->assign("entityType", $et);
    $smarty->assign('entityName', $workflow->moduleName);
    $smarty->assign("fieldNames", $et->getFieldNames());
    $dateFields = array();
    $fieldTypes = $et->getFieldTypes();
    $fieldLabels = $et->getFieldLabels();
    foreach ($fieldTypes as $name => $type) {
        if ($type->type == 'Date' || $type->type == 'DateTime') {
            $dateFields[$name] = $fieldLabels[$name];
        }
    }
    $smarty->assign('dateFields', $dateFields);
    if ($task->trigger != null) {
        $trigger = $task->trigger;
        $days = $trigger['days'];
        if ($days < 0) {
            $days *= -1;
            $direction = 'before';
        } else {
            $direction = 'after';
        }
        $smarty->assign('trigger', array('days' => $days, 'direction' => $direction, 'field' => $trigger['field']));
    }
    $curr_date = "(general : (__VtigerMeta__) date)";
    $curr_time = '(general : (__VtigerMeta__) time)';
    $smarty->assign("DATE", $curr_date);
    $smarty->assign("TIME", $curr_time);
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, 'Calendar'), return_module_language($current_language, $module->name)));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("THEME", $theme);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']);
    $smarty->assign("module", $module);
    $smarty->display("{$module->name}/EditTask.tpl");
}
Пример #18
0
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = vtlib_purify($request["module_name"]);
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = vtlib_purify($request["save_type"]);
    //OnDemand Specific Starts
    $schtypeid = $request["schtypeid"];
    $schtime = $request["s_time"];
    if (!preg_match('/^[0-2]\\d(:[0-5]\\d){1,2}$/', $schtime) or substr($schtime, 0, 2) > 23) {
        // invalid time format
        $schtime = '00:00';
    }
    $schdayofmonth = $request["s_dayofmonth"];
    $schdayofweek = $request["s_dayofweek"];
    $schmonth = $request["s_month"];
    //OnDemand Specific Ends
    $executionCondition = $request['execution_condition'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wf->filtersavedinnew = 5;
        //OnDemand Specific Starts
        $wf->schtypeid = $schtypeid;
        $wf->schtime = $schtime;
        $wf->schdayofmonth = $schdayofmonth;
        $wf->schdayofweek = $schdayofweek;
        $wf->schmonth = $schmonth;
        //OnDemand Specific Ends
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wf->filtersavedinnew = 5;
            //OnDemand Specific Starts
            $wf->schtypeid = $schtypeid;
            $wf->schtime = $schtime;
            $wf->schdayofmonth = $schdayofmonth;
            $wf->schdayofweek = $schdayofweek;
            $wf->schmonth = $schmonth;
            //OnDemand Specific Ends
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset(vtlib_purify($request["return_url"]))) {
        $returnUrl = vtlib_purify($request["return_url"]);
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Пример #19
0
function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_strings)
{
    global $theme, $current_user;
    $util = new VTWorkflowUtils();
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication("editworkflow");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    if ($request['source'] == 'from_template') {
        $tm = new VTWorkflowTemplateManager($adb);
        $template = $tm->retrieveTemplate($request['template_id']);
        $workflow = $tm->createWorkflow($template);
    } else {
        $wfs = new VTWorkflowManager($adb);
        if (isset($request["workflow_id"])) {
            $workflow = $wfs->retrieve($request["workflow_id"]);
        } else {
            $moduleName = $request["module_name"];
            $workflow = $wfs->newWorkflow($moduleName);
        }
        $smarty->assign('ScheduledWorkflowsCount', $wfs->getScheduledWorkflowsCount());
        $smarty->assign('MaxAllowedScheduledWorkflows', $wfs->getMaxAllowedScheduledWorkflows());
        $smarty->assign('schdtime_12h', date('h:ia', strtotime(substr($workflow->schtime, 0, strrpos($workflow->schtime, ':')))));
        $schannualdates = json_decode($workflow->schannualdates);
        if (count($schannualdates) > 0) {
            $schannualdates = DateTimeField::convertToUserFormat($schannualdates[0]);
        } else {
            $schannualdates = '';
        }
        $smarty->assign('schdate', $schannualdates);
        $smarty->assign('selected_days1_31', json_decode($workflow->schdayofmonth));
        $smarty->assign('dayOfWeek', json_decode($workflow->schdayofweek));
    }
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $workflow->test = addslashes($workflow->test);
    $tm = new VTTaskManager($adb);
    $tasks = $tm->getTasksForWorkflow($workflow->id);
    $smarty->assign("tasks", $tasks);
    $taskTypes = $tm->getTaskTypes($workflow->moduleName);
    $smarty->assign("taskTypes", $taskTypes);
    $smarty->assign("newTaskReturnUrl", vtlib_purify($requestUrl));
    $dayrange = array();
    for ($d = 1; $d <= 31; $d++) {
        $dayrange[$d] = $d;
    }
    $smarty->assign('days1_31', $dayrange);
    $smarty->assign('wfnexttrigger_time', DateTimeField::convertToUserFormat($workflow->nexttrigger_time));
    $smarty->assign("dateFormat", parse_calendardate($current_user->date_format));
    $smarty->assign("returnUrl", vtlib_purify($request["return_url"]));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, $module->name)));
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_WORKFLOW']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_WORKFLOW_TITLE']);
    $smarty->assign("workflow", $workflow);
    $smarty->assign("saveType", isset($workflow->id) ? "edit" : "new");
    $smarty->assign("module", $module);
    $smarty->assign("WORKFLOW_TRIGGER_TYPES_HELP_LINK", WORKFLOW_TRIGGER_TYPES);
    $smarty->display("{$module->name}/EditWorkflow.tpl");
}
Пример #20
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     if (!$this->isEntityModule()) {
         return array();
     }
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_FIELDS', 'linkurl' => 'index.php?parent=Settings&module=LayoutEditor&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_ARRANGE_RELATED_TABS', 'linkurl' => 'index.php?parent=Settings&module=LayoutEditor&mode=showRelatedListLayout&block=2&fieldid=41&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_QUICK_CREATE_EDITOR', 'linkurl' => 'index.php?parent=Settings&module=QuickCreateEditor&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_TREES_MANAGER', 'linkurl' => 'index.php?parent=Settings&module=TreesManager&view=List&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_WIDGETS_MANAGMENT', 'linkurl' => 'index.php?parent=Settings&module=Widgets&view=Index&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_PICKLIST_VALUES', 'linkurl' => 'index.php?parent=Settings&module=Picklist&view=Index&source_module=' . $this->getName(), 'linkicon' => '');
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_PICKLIST_DEPENDENCY', 'linkurl' => 'index.php?parent=Settings&module=PickListDependency&view=List&formodule=' . $this->getName(), 'linkicon' => '');
     if ($this->hasSequenceNumberField()) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_MODULE_SEQUENCE_NUMBERING', 'linkurl' => 'index.php?parent=Settings&module=Vtiger&view=CustomRecordNumbering&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     $webformSupportedModule = Settings_Webforms_Module_Model::getSupportedModulesList();
     if (array_key_exists($this->getName(), $webformSupportedModule)) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_SETUP_WEBFORMS', 'linkurl' => 'index.php?module=Webforms&parent=Settings&view=Edit&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     return $settingsLinks;
 }
Пример #21
0
function vtTaskEdit($adb, $request, $current_language, $app_strings)
{
    global $theme;
    $util = new VTWorkflowUtils();
    $request = vtlib_purify($request);
    // this cleans all values of the array
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication('edittask');
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $tm = new VTTaskManager($adb);
    $smarty->assign('edit', isset($request["task_id"]));
    if (isset($request["task_id"])) {
        $task = $tm->retrieveTask($request["task_id"]);
        $taskClass = get_class($task);
        $workflowId = $task->workflowId;
    } else {
        $workflowId = $request["workflow_id"];
        $taskClass = vtlib_purifyForSql($request["task_type"]);
        $task = $tm->createTask($taskClass, $workflowId);
    }
    if ($task == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_TASK']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_TASK']);
        return;
    }
    $wm = new VTWorkflowManager($adb);
    $workflow = $wm->retrieve($workflowId);
    if ($workflow == null) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
        return;
    }
    $smarty->assign("workflow", $workflow);
    $smarty->assign("returnUrl", $request["return_url"]);
    $smarty->assign("task", $task);
    $smarty->assign("taskType", $taskClass);
    $smarty->assign("saveType", $request['save_type']);
    $taskTypeInstance = VTTaskType::getInstanceFromTaskType($taskClass);
    $taskTemplateClass = $tm->retrieveTemplatePath($module->name, $taskTypeInstance);
    $smarty->assign("taskTemplate", $taskTemplateClass);
    $et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName);
    $smarty->assign("entityType", $et);
    $smarty->assign('entityName', $workflow->moduleName);
    $smarty->assign("fieldNames", $et->getFieldNames());
    $repeat_date = $task->calendar_repeat_limit_date;
    if (!empty($repeat_date)) {
        $repeat_date = DateTimeField::convertToUserFormat($repeat_date);
    }
    $smarty->assign('REPEAT_DATE', $repeat_date);
    $dateFields = array();
    $fieldTypes = $et->getFieldTypes();
    $fieldLabels = $et->getFieldLabels();
    foreach ($fieldTypes as $name => $type) {
        if ($type->type == 'Date' || $type->type == 'DateTime') {
            $dateFields[$name] = $fieldLabels[$name];
        }
    }
    $smarty->assign('dateFields', $dateFields);
    if ($task->trigger != null) {
        $trigger = $task->trigger;
        $days = $trigger['days'];
        if ($days < 0) {
            $days *= -1;
            $direction = 'before';
        } else {
            $direction = 'after';
        }
        $smarty->assign('trigger', array('days' => $days, 'direction' => $direction, 'field' => $trigger['field']));
    }
    $metaVariables = $task->getMetaVariables();
    $date = new DateTimeField(null);
    $time = substr($date->getDisplayTime(), 0, 5);
    $smarty->assign("META_VARIABLES", $metaVariables);
    $smarty->assign("SYSTEM_TIMEZONE", $db_timezone);
    $smarty->assign("USER_TIME", $task->formatTimeForTimePicker($time));
    $smarty->assign("USER_DATE", $date->getDisplayDate());
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, 'Calendar'), return_module_language($current_language, $module->name)));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("dateFormat", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("THEME", $theme);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']);
    $users = $group = array();
    $users['user'] = get_user_array();
    $users['group'] = get_group_array();
    $smarty->assign('ASSIGNED_TO', $users);
    $smarty->assign("module", $module);
    $smarty->display("{$module->name}/EditTask.tpl");
}
Пример #22
0
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    $request = vtlib_purify($request);
    // this cleans all values of the array
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = $request["module_name"];
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = $request["save_type"];
    $executionCondition = $request['execution_condition'];
    $schdayofweek = array();
    if (isset($request['sun_flag']) && $_REQUEST['sun_flag'] != null) {
        $schdayofweek[] = 1;
    }
    if (isset($request['mon_flag']) && $_REQUEST['mon_flag'] != null) {
        $schdayofweek[] = 2;
    }
    if (isset($request['tue_flag']) && $_REQUEST['tue_flag'] != null) {
        $schdayofweek[] = 3;
    }
    if (isset($request['wed_flag']) && $_REQUEST['wed_flag'] != null) {
        $schdayofweek[] = 4;
    }
    if (isset($request['thu_flag']) && $_REQUEST['thu_flag'] != null) {
        $schdayofweek[] = 5;
    }
    if (isset($request['fri_flag']) && $_REQUEST['fri_flag'] != null) {
        $schdayofweek[] = 6;
    }
    if (isset($request['sat_flag']) && $_REQUEST['sat_flag'] != null) {
        $schdayofweek[] = 7;
    }
    // internally the code is prepared to launch the same workflow on many dates
    // but the interface only sends one in
    // TODO: change interface to send in many dates for annual scheduling
    $schannualdates = DateTimeField::convertToDBFormat($request['schdate']);
    $schannualdates = json_encode(array($schannualdates));
    $schminuteinterval = $request['schminuteinterval'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wf->schtypeid = $request['schtypeid'];
        $wf->schtime = VTCreateEventTask::conv12to24hour($request['schtime']);
        $wf->schdayofmonth = json_encode($request['schdayofmonth']);
        $wf->schdayofweek = json_encode($schdayofweek);
        $wf->schannualdates = $schannualdates;
        $wf->schminuteinterval = $schminuteinterval;
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wf->schtypeid = $request['schtypeid'];
            $wf->schtime = VTCreateEventTask::conv12to24hour($request['schtime']);
            $wf->schdayofmonth = json_encode($request['schdayofmonth']);
            $wf->schdayofweek = json_encode($schdayofweek);
            $wf->schannualdates = $schannualdates;
            $wf->schminuteinterval = $schminuteinterval;
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset($request["return_url"])) {
        $returnUrl = $request["return_url"];
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Пример #23
0
             $menu_array['FieldFormulas']['image_src'] = $adb->query_result($sql_result, 0, 'iconpath');
             $menu_array['FieldFormulas']['desc'] = getTranslatedString($adb->query_result($sql_result, 0, 'description'), 'FieldFormulas');
             $menu_array['FieldFormulas']['label'] = getTranslatedString($adb->query_result($sql_result, 0, 'name'), 'FieldFormulas');
         }
     }
 }
 if (vtlib_isModuleActive('Tooltip')) {
     $sql_result = $adb->pquery("select * from vtiger_settings_field where name = ? and active=0", array('LBL_TOOLTIP_MANAGEMENT'));
     if ($adb->num_rows($sql_result) > 0) {
         $menu_array['Tooltip']['location'] = $adb->query_result($sql_result, 0, 'linkto') . '&formodule=' . $module;
         $menu_array['Tooltip']['image_src'] = vtiger_imageurl($adb->query_result($sql_result, 0, 'iconpath'), $theme);
         $menu_array['Tooltip']['desc'] = getTranslatedString($adb->query_result($sql_result, 0, 'description'), 'Tooltip');
         $menu_array['Tooltip']['label'] = getTranslatedString($adb->query_result($sql_result, 0, 'name'), 'Tooltip');
     }
 }
 if (VTWorkflowUtils::checkModuleWorkflow($module)) {
     $sql_result = $adb->pquery("SELECT * FROM vtiger_settings_field WHERE name = ? AND active=0", array('LBL_WORKFLOW_LIST'));
     if ($adb->num_rows($sql_result) > 0) {
         $menu_array['Workflow']['location'] = $adb->query_result($sql_result, 0, 'linkto') . '&list_module=' . $module;
         $menu_array['Workflow']['image_src'] = vtiger_imageurl($adb->query_result($sql_result, 0, 'iconpath'), $theme);
         $menu_array['Workflow']['desc'] = getTranslatedString($adb->query_result($sql_result, 0, 'description'), 'com_vtiger_workflow');
         $menu_array['Workflow']['label'] = getTranslatedString($adb->query_result($sql_result, 0, 'name'), 'com_vtiger_workflow');
     }
 }
 $menu_array['CYP_SERVER_CONFIGURATION']['location'] = 'index.php?module=CobroPago&action=CobroPagoConfigServer&parenttab=Settings&formodule=CobroPago';
 $menu_array['CYP_SERVER_CONFIGURATION']['image_src'] = 'modules/CobroPago/settings.png';
 $menu_array['CYP_SERVER_CONFIGURATION']['desc'] = getTranslatedString('SERVER_CONFIGURATION_DESCRIPTION', $module);
 $menu_array['CYP_SERVER_CONFIGURATION']['label'] = getTranslatedString('SERVER_CONFIGURATION', $module);
 //add blanks for 3-column layout
 $count = count($menu_array) % 3;
 if ($count > 0) {
Пример #24
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     if (!$this->isEntityModule()) {
         return array();
     }
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_FIELDS', 'linkurl' => 'index.php?parent=Settings&module=LayoutEditor&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_PICKLIST_VALUES', 'linkurl' => 'index.php?parent=Settings&module=Picklist&view=Index&source_module=' . $this->getName(), 'linkicon' => '');
     if ($this->hasSequenceNumberField()) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_MODULE_SEQUENCE_NUMBERING', 'linkurl' => 'index.php?parent=Settings&module=Vtiger&view=CustomRecordNumbering&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     $webformSupportedModule = Settings_Webforms_Module_Model::getSupportedModulesList();
     if (array_key_exists($this->getName(), $webformSupportedModule)) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_SETUP_WEBFORMS', 'linkurl' => 'index.php?module=Webforms&parent=Settings&view=Edit&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     return $settingsLinks;
 }
Пример #25
0
 public static function runScheduledReports($adb)
 {
     require_once 'modules/com_vtiger_workflow/VTWorkflowUtils.php';
     $util = new VTWorkflowUtils();
     $adminUser = $util->adminUser();
     $scheduledReports = self::getScheduledReports($adminUser);
     $util->revertUser();
     foreach ($scheduledReports as $scheduledReport) {
         $ReportOwnerUser = ITS4YouReports::getReports4YouOwnerUser($scheduledReport->reportinformations["owner"]);
         //echo "<pre>";print_r($);echo "</pre>";exit;
         $scheduledReport->sendEmail($ReportOwnerUser);
         $scheduledReport->updateNextTriggerTime();
         $ReportOwnerUser = ITS4YouReports::revertSchedulerUser();
     }
 }
Пример #26
0
}
list($wsmod, $crmid) = explode('x', $crm_record_to_evaluate);
$wsrs = $adb->pquery('select name FROM vtiger_ws_entity where id=?', array($wsmod));
if (!$wsrs or $adb->num_rows($wsrs) == 0) {
    echo "<h2>Incorrect crmid:</h2>";
    echo "<b>crmid</b> could not be evaluated as a valid webservice enhanced ID<br>";
    die;
}
$currentModule = $adb->query_result($wsrs, 0, 0);
$semod = getSalesEntityType($crmid);
if ($semod != $currentModule and ($semod != 'Calendar' and $currentModule != 'Events')) {
    echo "<h2>Incorrect crmid:</h2>";
    echo "<b>crmid</b> could not be evaluated as a valid record ID<br>";
    die;
}
$util = new VTWorkflowUtils();
$adminUser = $util->adminUser();
$entityCache = new VTEntityCache($adminUser);
$wfs = new VTWorkflowManager($adb);
$result = $adb->pquery('select workflow_id, module_name, summary, test, execution_condition, type
			from com_vtiger_workflows where workflow_id=?', array($workflowid_to_evaluate));
if (!$result or $adb->num_rows($result) == 0) {
    echo "<h2>Incorrect workflowid:</h2>";
    echo "<b>workflowid</b> could not be found as a valid workflow<br>";
    die;
}
$workflows = $wfs->getWorkflowsForResult($result);
$workflow = $workflows[$workflowid_to_evaluate];
$entityData = $entityCache->forId($crm_record_to_evaluate);
if ($workflows[$workflowid_to_evaluate]->executionCondition == VTWorkflowManager::$ON_SCHEDULE) {
    echo "<h2>Scheduled: SQL for affected records:</h2>";
Пример #27
0
 public static function runScheduledReports($adb)
 {
     require_once 'modules/com_vtiger_workflow/VTWorkflowUtils.php';
     $util = new VTWorkflowUtils();
     $adminUser = $util->adminUser();
     $currentModule = vglobal('currentModule');
     $current_language = vglobal('current_language');
     if (empty($currentModule)) {
         $currentModule = 'Reports';
     }
     if (empty($current_language)) {
         vglobal('current_language', 'en_us');
     }
     $scheduledReports = self::getScheduledReports($adb, $adminUser);
     foreach ($scheduledReports as $scheduledReport) {
         $scheduledReport->sendEmail();
         $scheduledReport->updateNextTriggerTime();
     }
     $util->revertUser();
 }
Пример #28
0
 public static function runScheduledReports()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $util = new VTWorkflowUtils();
     $util->adminUser();
     $currentModule = vglobal('currentModule');
     $current_language = vglobal('current_language');
     if (empty($currentModule)) {
         $currentModule = 'Reports';
     }
     if (empty($current_language)) {
         vglobal('current_language', 'en_us');
     }
     $scheduledReports = self::getScheduledReports();
     foreach ($scheduledReports as $scheduledReport) {
         $status = $scheduledReport->sendEmail();
         Vtiger_Utils::ModuleLog('ScheduleReprot Send Mail Status ', $status);
         if ($status) {
             $scheduledReport->updateNextTriggerTime();
         }
     }
     $util->revertUser();
     return $status;
 }
Пример #29
0
 /**
  * Function to get contents of this task
  * @param <Object> $entity
  * @return <Array> contents
  */
 public function getContents($entity, $entityCache = false)
 {
     if (!$this->contents) {
         global $adb, $current_user;
         $taskContents = array();
         $entityId = $entity->getId();
         $utils = new VTWorkflowUtils();
         $adminUser = $utils->adminUser();
         if (!$entityCache) {
             $entityCache = new VTEntityCache($adminUser);
         }
         $fromUserId = Users::getActiveAdminId();
         $entityOwnerId = $entity->get('assigned_user_id');
         if ($entityOwnerId) {
             list($moduleId, $fromUserId) = explode('x', $entityOwnerId);
         }
         $ownerEntity = $entityCache->forId($entityOwnerId);
         if ($ownerEntity->getModuleName() === 'Groups') {
             list($moduleId, $recordId) = vtws_getIdComponents($entityId);
             $fromUserId = Vtiger_Util_Helper::getCreator($recordId);
         }
         if ($this->fromEmail && !($ownerEntity->getModuleName() === 'Groups' && strpos($this->fromEmail, 'assigned_user_id : (Users) ') !== false)) {
             $et = new VTEmailRecipientsTemplate($this->fromEmail);
             $fromEmailDetails = $et->render($entityCache, $entityId);
             $con1 = strpos($fromEmailDetails, '&lt;');
             $con2 = strpos($fromEmailDetails, '&gt;');
             if ($con1 && $con2) {
                 list($fromName, $fromEmail) = explode('&lt;', $fromEmailDetails);
                 list($fromEmail, $rest) = explode('&gt;', $fromEmail);
             } else {
                 $fromName = "";
                 $fromEmail = $fromEmailDetails;
             }
         } else {
             $userObj = CRMEntity::getInstance('Users');
             $userObj->retrieveCurrentUserInfoFromFile($fromUserId);
             if ($userObj) {
                 $fromEmail = $userObj->email1;
                 $fromName = $userObj->user_name;
             } else {
                 $result = $adb->pquery('SELECT user_name, email1 FROM vtiger_users WHERE id = ?', array($fromUserId));
                 $fromEmail = $adb->query_result($result, 0, 'email1');
                 $fromName = $adb->query_result($result, 0, 'user_name');
             }
         }
         if (!$fromEmail) {
             $utils->revertUser();
             return false;
         }
         $taskContents['fromEmail'] = $fromEmail;
         $taskContents['fromName'] = $fromName;
         if ($entity->getModuleName() === 'Events') {
             $contactId = $entity->get('contact_id');
             if ($contactId) {
                 $contactIds = '';
                 list($wsId, $recordId) = explode('x', $entityId);
                 $webserviceObject = VtigerWebserviceObject::fromName($adb, 'Contacts');
                 $result = $adb->pquery('SELECT contactid FROM vtiger_cntactivityrel WHERE activityid = ?', array($recordId));
                 $numOfRows = $adb->num_rows($result);
                 for ($i = 0; $i < $numOfRows; $i++) {
                     $contactIds .= vtws_getId($webserviceObject->getEntityId(), $adb->query_result($result, $i, 'contactid')) . ',';
                 }
             }
             $entity->set('contact_id', trim($contactIds, ','));
             $entityCache->cache[$entityId] = $entity;
         }
         $et = new VTEmailRecipientsTemplate($this->recepient);
         $toEmail = $et->render($entityCache, $entityId);
         $ecct = new VTEmailRecipientsTemplate($this->emailcc);
         $ccEmail = $ecct->render($entityCache, $entityId);
         $ebcct = new VTEmailRecipientsTemplate($this->emailbcc);
         $bccEmail = $ebcct->render($entityCache, $entityId);
         if (strlen(trim($toEmail, " \t\n,")) == 0 && strlen(trim($ccEmail, " \t\n,")) == 0 && strlen(trim($bccEmail, " \t\n,")) == 0) {
             $utils->revertUser();
             return false;
         }
         $taskContents['toEmail'] = $toEmail;
         $taskContents['ccEmail'] = $ccEmail;
         $taskContents['bccEmail'] = $bccEmail;
         $st = new VTSimpleTemplate($this->subject);
         $taskContents['subject'] = $st->render($entityCache, $entityId);
         $ct = new VTSimpleTemplate($this->content);
         $taskContents['content'] = $ct->render($entityCache, $entityId);
         $this->contents = $taskContents;
         $utils->revertUser();
     }
     if (is_array($this->contents)) {
         $this->contents = Zend_Json::encode($this->contents);
     }
     return $this->contents;
 }