Ejemplo n.º 1
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");
}
Ejemplo n.º 2
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 
}
Ejemplo n.º 3
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 
}
Ejemplo n.º 4
0
 public function queueScheduledWorkflowTasks()
 {
     global $default_timezone;
     $adb = $this->db;
     $vtWorflowManager = new VTWorkflowManager($adb);
     $taskQueue = new VTTaskQueue($adb);
     $entityCache = new VTEntityCache($this->user);
     // set the time zone to the admin's time zone, this is needed so that the scheduled workflow will be triggered
     // at admin's time zone rather than the systems time zone. This is specially needed for Hourly and Daily scheduled workflows
     $admin = Users::getActiveAdminUser();
     $adminTimeZone = $admin->time_zone;
     @date_default_timezone_set($adminTimeZone);
     $currentTimestamp = date("Y-m-d H:i:s");
     @date_default_timezone_set($default_timezone);
     $scheduledWorkflows = $vtWorflowManager->getScheduledWorkflows($currentTimestamp);
     $noOfScheduledWorkflows = count($scheduledWorkflows);
     foreach ($scheduledWorkflows as $workflow) {
         $tm = new VTTaskManager($adb);
         $tasks = $tm->getTasksForWorkflow($workflow->id);
         if ($tasks) {
             $records = $this->getEligibleWorkflowRecords($workflow);
             $noOfRecords = count($records);
             for ($j = 0; $j < $noOfRecords; ++$j) {
                 $recordId = $records[$j];
                 // We need to pass proper module name to get the webservice
                 if ($workflow->moduleName == 'Calendar') {
                     $moduleName = vtws_getCalendarEntityType($recordId);
                 } else {
                     $moduleName = $workflow->moduleName;
                 }
                 $wsEntityId = vtws_getWebserviceEntityId($moduleName, $recordId);
                 $entityData = $entityCache->forId($wsEntityId);
                 $data = $entityData->getData();
                 foreach ($tasks as $task) {
                     if ($task->active) {
                         $trigger = $task->trigger;
                         if ($trigger != null) {
                             $delay = strtotime($data[$trigger['field']]) + $trigger['days'] * 86400;
                         } else {
                             $delay = 0;
                         }
                         if ($task->executeImmediately == true) {
                             if (empty($task->test) or $task->evaluate($entityCache, $entityData->getId())) {
                                 $task->doTask($entityData);
                             }
                         } else {
                             $taskQueue->queueTask($task->id, $entityData->getId(), $delay);
                         }
                     }
                 }
             }
         }
         $vtWorflowManager->updateNexTriggerTime($workflow);
     }
     $scheduledWorkflows = null;
 }
 function applyChange()
 {
     global $adb;
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $chktbl = $adb->query('select 1 from com_vtiger_workflow_tasktypes limit 1');
         if ($chktbl) {
             $moduleInstance = Vtiger_Module::getInstance('Potentials');
             $block = Vtiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $moduleInstance);
             $field = Vtiger_Field::getInstance('forecast_amount', $moduleInstance);
             if ($field) {
                 $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
             } else {
                 $forecast_field = new Vtiger_Field();
                 $forecast_field->name = 'forecast_amount';
                 $forecast_field->label = 'Forecast Amount';
                 $forecast_field->table = 'vtiger_potential';
                 $forecast_field->column = 'forecast_amount';
                 $forecast_field->columntype = 'decimal(25,4)';
                 $forecast_field->typeofdata = 'N~O';
                 $forecast_field->uitype = '71';
                 $forecast_field->masseditable = '0';
                 $block->addField($forecast_field);
             }
             $wfrs = $adb->query("SELECT workflow_id FROM com_vtiger_workflows WHERE summary='Calculate or Update forecast amount'");
             if ($wfrs and $adb->num_rows($wfrs) == 1) {
                 $this->sendMsg('Workfolw already exists!');
             } else {
                 $workflowManager = new VTWorkflowManager($adb);
                 $taskManager = new VTTaskManager($adb);
                 $potentailsWorkFlow = $workflowManager->newWorkFlow("Potentials");
                 $potentailsWorkFlow->test = '';
                 $potentailsWorkFlow->description = "Calculate or Update forecast amount";
                 $potentailsWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
                 $potentailsWorkFlow->defaultworkflow = 1;
                 $workflowManager->save($potentailsWorkFlow);
                 $task = $taskManager->createTask('VTUpdateFieldsTask', $potentailsWorkFlow->id);
                 $task->active = true;
                 $task->summary = 'update forecast amount';
                 $task->field_value_mapping = '[{"fieldname":"forecast_amount","valuetype":"expression","value":"amount * probability / 100"}]';
                 $taskManager->saveTask($task);
             }
             $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
             $this->markApplied();
         } else {
             $this->sendMsgError('This changeset could not be applied because it depends on create_workflow_tasktype which probably has not been applied yet. Apply that changeset and try this one again.');
         }
     }
     $this->finishExecution();
 }
Ejemplo n.º 6
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");
}
Ejemplo n.º 7
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);
    }
}
Ejemplo n.º 8
0
 public function queueScheduledWorkflowTasks()
 {
     global $default_timezone;
     $adb = $this->db;
     $vtWorflowManager = new VTWorkflowManager($adb);
     $entityCache = new VTEntityCache($this->user);
     // set the time zone to the admin's time zone, this is needed so that the scheduled workflow will be triggered
     // at admin's time zone rather than the systems time zone. This is specially needed for Hourly and Daily scheduled workflows
     $admin = Users::getActiveAdminUser();
     $adminTimeZone = $admin->time_zone;
     @date_default_timezone_set($adminTimeZone);
     $currentTimestamp = date("Y-m-d H:i:s");
     @date_default_timezone_set($default_timezone);
     $scheduledWorkflows = $vtWorflowManager->getScheduledWorkflows($currentTimestamp);
     $noOfScheduledWorkflows = count($scheduledWorkflows);
     for ($i = 0; $i < $noOfScheduledWorkflows; ++$i) {
         $workflow = $scheduledWorkflows[$i];
         if ($workflow->active != 1) {
             continue;
         }
         $tm = new VTTaskManager($adb);
         $tasks = $tm->getTasksForWorkflow($workflow->id);
         if ($tasks) {
             $records = $this->getEligibleWorkflowRecords($workflow);
             $noOfRecords = count($records);
             for ($j = 0; $j < $noOfRecords; ++$j) {
                 $recordId = $records[$j];
                 // We need to pass proper module name to get the webservice
                 if ($workflow->moduleName == 'Calendar') {
                     $moduleName = vtws_getCalendarEntityType($recordId);
                 } else {
                     $moduleName = $workflow->moduleName;
                 }
                 $wsEntityId = vtws_getWebserviceEntityId($moduleName, $recordId);
                 $entityData = $entityCache->forId($wsEntityId);
                 $tm->performTasks($entityData, false);
             }
         }
         $vtWorflowManager->updateNexTriggerTime($workflow);
     }
     $scheduledWorkflows = null;
 }
 function applyChange()
 {
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $emm = new VTEntityMethodManager($adb);
         // Adding EntityMethod for Updating Products data after updating PurchaseOrder
         $emm->addEntityMethod("PurchaseOrder", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel");
         // Creating Workflow for Updating Inventory Stock on PO
         $vtWorkFlow = new VTWorkflowManager($adb);
         $invWorkFlow = $vtWorkFlow->newWorkFlow("PurchaseOrder");
         $invWorkFlow->test = '[{"fieldname":"subject","operation":"does not contain","value":"`!`"}]';
         $invWorkFlow->description = "UpdateInventoryProducts On Every Save";
         $invWorkFlow->defaultworkflow = 1;
         $vtWorkFlow->save($invWorkFlow);
         $tm = new VTTaskManager($adb);
         $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
         $task->active = true;
         $task->methodName = "UpdateInventory";
         $task->summary = "Update product stock";
         $tm->saveTask($task);
         // add Cancel status to Invoice and SO for stock control
         $moduleInstance = Vtiger_Module::getInstance('Invoice');
         $field = Vtiger_Field::getInstance('invoicestatus', $moduleInstance);
         if ($field) {
             $field->setPicklistValues(array('Cancel'));
         }
         $this->sendMsg('Changeset ' . get_class($this) . ' applied! Add Workflow Custom Function complete!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
function populateDefaultWorkflows($adb)
{
    require_once "modules/com_vtiger_workflow/include.inc";
    require_once "modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc";
    require_once "modules/com_vtiger_workflow/VTEntityMethodManager.inc";
    // Creating Workflow for Updating Inventory Stock for Invoice
    $vtWorkFlow = new VTWorkflowManager($adb);
    $invWorkFlow = $vtWorkFlow->newWorkFlow("Invoice");
    $invWorkFlow->test = '[{"fieldname":"subject","operation":"does not contain","value":"`!`"}]';
    $invWorkFlow->description = "UpdateInventoryProducts On Every Save";
    $vtWorkFlow->save($invWorkFlow);
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
    $task->active = true;
    $task->methodName = "UpdateInventory";
    $tm->saveTask($task);
}
Ejemplo n.º 11
0
        }
        foreach ($dateTimeFieldsList as $moduleName => $fieldNamesList) {
            foreach ($fieldNamesList as $fieldName) {
                $propertyValue = str_replace("({$moduleName}) {$fieldName}) {$timeZone}", "({$moduleName}) {$fieldName})", $propertyValue);
            }
        }
        $emailTask->{$propertyName} = $propertyValue;
    }
    $tm->saveTask($emailTask);
}
$result = $adb->pquery('SELECT task_id FROM com_vtiger_workflowtasks WHERE workflow_id IN
                        (SELECT workflow_id FROM com_vtiger_workflows WHERE module_name IN (?, ?))
                        AND task LIKE ?', array('Calendar', 'Events', '%VTSendNotificationTask%'));
$numOfRowas = $adb->num_rows($result);
for ($i = 0; $i < $numOfRows; $i++) {
    $tm = new VTTaskManager($adb);
    $task = $tm->retrieveTask($adb->query_result($result, $i, 'task_id'));
    $emailTask = new VTEmailTask();
    $properties = get_object_vars($task);
    foreach ($properties as $propertyName => $propertyValue) {
        $propertyValue = str_replace('$date_start  $time_start ( $(general : (__VtigerMeta__) usertimezone) ) ', '$date_start', $propertyValue);
        $propertyValue = str_replace('$due_date  $time_end ( $(general : (__VtigerMeta__) usertimezone) )', '$due_date', $propertyValue);
        $propertyValue = str_replace('$due_date ( $(general : (__VtigerMeta__) usertimezone) )', '$due_date', $propertyValue);
        $propertyValue = str_replace('$(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname)', '$contact_id', $propertyValue);
        $emailTask->{$propertyName} = $propertyValue;
    }
    $tm->saveTask($emailTask);
}
// $maxActionIdResult = $adb->pquery('SELECT MAX(actionid) AS maxid FROM vtiger_actionmapping', array());
// $maxActionId = $adb->query_result($maxActionIdResult, 0, 'maxid');
// Migration_Index_View::ExecuteQuery('INSERT INTO vtiger_actionmapping(actionid, actionname, securitycheck) VALUES(?,?,?)', array($maxActionId+1 ,'Print', '0'));
Ejemplo n.º 12
0
 /**
  * Function to get the count of active workflows
  * @return <Integer> count of acive workflows
  */
 public static function getActiveCount()
 {
     $db = PearDatabase::getInstance();
     vimport('~~/modules/com_vtiger_workflow/VTTaskManager.inc');
     $taskManager = new VTTaskManager($db);
     $taskList = $taskManager->getTasks();
     $examinedIdList = array();
     foreach ($taskList as $taskDetails) {
         $workFlowId = $taskDetails->workflowId;
         if (in_array($workFlowId, $examinedIdList)) {
             continue;
         }
         if ($taskDetails->active) {
             array_push($examinedIdList, $workFlowId);
         }
     }
     return count($examinedIdList);
 }
Ejemplo n.º 13
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");
}
Ejemplo n.º 14
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");
}
Ejemplo n.º 15
0
}
$dateTimeFields = array();
foreach ($dateTimeFieldsList as $moduleName => $fieldNamesList) {
    $dateTimeFields = array_merge($dateTimeFields, $fieldNamesList);
}
$taskIdsList = array();
$result = $adb->pquery('SELECT task_id, module_name FROM com_vtiger_workflowtasks
                        INNER JOIN com_vtiger_workflows ON com_vtiger_workflows.workflow_id = com_vtiger_workflowtasks.workflow_id
                        WHERE task LIKE ?', array('%VTEmailTask%'));
while ($rowData = $adb->fetch_array($result)) {
    $taskIdsList[$rowData['task_id']] = $rowData['module_name'];
}
$dateFormat = '($_DATE_FORMAT_)';
$timeZone = '($(general : (__VtigerMeta__) usertimezone))';
foreach ($taskIdsList as $taskId => $taskModuleName) {
    $tm = new VTTaskManager($adb);
    $task = $tm->retrieveTask($taskId);
    $emailTask = new VTEmailTask();
    $properties = get_object_vars($task);
    foreach ($properties as $propertyName => $propertyValue) {
        $propertyValue = str_replace('$(general : (__VtigerMeta__) date)', "(general : (__VtigerMeta__) date) {$dateFormat}", $propertyValue);
        foreach ($dateFields as $fieldName) {
            if ($taskModuleName === 'Events' && $fieldName === 'due_date') {
                continue;
            }
            $propertyValue = str_replace("\${$fieldName}", "\${$fieldName} {$dateFormat}", $propertyValue);
        }
        foreach ($dateTimeFields as $fieldName) {
            if ($taskModuleName === 'Calendar' && $fieldName === 'due_date') {
                continue;
            }
Ejemplo n.º 16
0
require_once 'include/Webservices/WebserviceEntityOperation.php';
require_once "include/language/{$default_language}.lang.php";
require_once 'include/Webservices/Retrieve.php';
require_once 'modules/Emails/mail.php';
require_once 'modules/Users/Users.php';
require_once 'modules/com_vtiger_workflow/VTSimpleTemplate.inc';
require_once 'modules/com_vtiger_workflow/VTEntityCache.inc';
require_once 'modules/com_vtiger_workflow/VTWorkflowUtils.php';
require_once 'modules/com_vtiger_workflow/include.inc';
global $current_user, $adb;
$util = new VTWorkflowUtils();
$adminUser = $util->adminUser();
$current_user = $adminUser;
$tq = new VTTaskQueue($adb);
$readyTasks = $tq->getReadyTasks();
$tm = new VTTaskManager($adb);
$taskId = 41;
$entityId = '12x136';
$task = $tm->retrieveTask($taskId);
if (!empty($task)) {
    list($moduleId, $crmId) = explode('x', $entityId);
    $query = "select deleted from vtiger_crmentity where crmid={$crmId}";
    $res = $adb->query($query);
    if ($adb->num_rows($res) == 0 || $adb->query_result($res, 0, 0)) {
        echo "Deleted Record\n";
    } else {
        //error_reporting(E_ALL);ini_set('display_errors','on');
        $entity = new VTWorkflowEntity($adminUser, $entityId);
        $task->doTask($entity);
    }
} else {
Ejemplo n.º 17
0
ExecuteQuery("ALTER TABLE vtiger_inventoryproductrel ADD COLUMN incrementondel int(11) not null default '0'");
$invoiceids = $adb->pquery("SELECT invoiceid from vtiger_invoice", array());
$noOfRows = $adb->num_rows($invoiceids);
for ($i = 0; $i < $noOfRows; $i++) {
    $adb->pquery("UPDATE vtiger_inventoryproductrel SET incrementondel = 1 WHERE id=?", array($adb->query_result($invoiceids, $i, "invoiceid")));
}
$emm->addEntityMethod("SalesOrder", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel");
//Adding EntityMethod for Updating Products data after creating SalesOrder
$emm->addEntityMethod("Invoice", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel");
//Adding EntityMethod for Updating Products data after creating Invoice
$vtWorkFlow = new VTWorkflowManager($adb);
$invWorkFlow = $vtWorkFlow->newWorkFlow("Invoice");
$invWorkFlow->test = '[{"fieldname":"subject","operation":"does not contain","value":"`!`"}]';
$invWorkFlow->description = "UpdateInventoryProducts On Every Save";
$vtWorkFlow->save($invWorkFlow);
$tm = new VTTaskManager($adb);
$task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
$task->active = true;
$task->methodName = "UpdateInventory";
$tm->saveTask($task);
/* Support to track if a module is of CrmEntity type or not */
ExecuteQuery("ALTER TABLE vtiger_tab ADD COLUMN isentitytype INT NOT NULL DEFAULT 1");
ExecuteQuery("UPDATE vtiger_tab SET isentitytype=0 WHERE name IN ('Home','Dashboard','Rss','Reports','Portal','Users','Recyclebin')");
/* Support for different languages to be stored in database instead of config file - Vtlib */
ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_language(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), " . "prefix VARCHAR(10), label VARCHAR(30), lastupdated DATETIME, sequence INT, isdefault INT(1), active INT(1)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
/* Register default language English. This will automatically register all the other langauges from config file */
require_once 'vtlib/Vtiger/Language.php';
$vtlanguage = new Vtiger_Language();
$vtlanguage->register('en_us', 'US English', 'English', true, true, true);
/* To store relationship between the modules in a common table */
ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_crmentityrel (crmid int(11) NOT NULL, module varchar(100) NOT NULL, relcrmid int(11) NOT NULL, relmodule varchar(100) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
Ejemplo n.º 18
0
    public function databaseData()
    {
        global $log, $adb;
        $log->debug("Entering YetiForceUpdate::databaseData() method ...");
        $this->addFields();
        $adb->query("UPDATE vtiger_eventhandlers_seq SET `id` = (SELECT MAX(eventhandler_id) FROM `vtiger_eventhandlers`);");
        $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", array('vtiger.entity.link.after', 'HelpDeskHandler'));
        if ($adb->num_rows($result) == 0) {
            $addHandler = array();
            $addHandler[] = array('vtiger.entity.link.after', 'modules/HelpDesk/handlers/HelpDeskHandler.php', 'HelpDeskHandler', '', '1', '[]');
            $em = new VTEventsManager($adb);
            foreach ($addHandler as $handler) {
                $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]);
            }
        }
        $template[] = array('Notify Owner On Ticket Change', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Account On Ticket Change', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Contact On Ticket Closed', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Account On Ticket Closed', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Contact On Ticket Create', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Account On Ticket Create', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Contact On Ticket Change', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Owner On Ticket Closed', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Notify Owner On Ticket Create', 'HelpDesk', 'PLL_RECORD');
        $template[] = array('Customer Portal Login Details', 'Contacts', 'PLL_RECORD');
        $template[] = array('Send invitations', 'Events', 'PLL_RECORD');
        $template[] = array('Send Notification Email to Record Owner', 'Calendar', 'PLL_RECORD');
        $template[] = array('Activity Reminder Notification', 'Calendar', 'PLL_RECORD');
        $template[] = array('Activity Reminder Notification', 'Events', 'PLL_RECORD');
        $template[] = array('Test mail about the mail server configuration.', 'Users', 'PLL_RECORD');
        $template[] = array('ForgotPassword', 'Users', 'PLL_RECORD');
        $template[] = array('Customer Portal - ForgotPassword', 'Contacts', 'PLL_RECORD');
        $template[] = array('New comment added to ticket from portal', 'ModComments', 'PLL_RECORD');
        $template[] = array('New comment added to ticket', 'ModComments', 'PLL_RECORD');
        $template[] = array('Security risk has been detected - Brute Force', 'Contacts', 'PLL_MODULE');
        $template[] = array('Backup has been made', 'Contacts', 'PLL_MODULE');
        $result = $adb->query("SHOW COLUMNS FROM `vtiger_ossmailtemplates` LIKE 'ossmailtemplates_type';");
        if ($adb->num_rows($result) == 1) {
            foreach ($template as $temp) {
                $adb->pquery("UPDATE `vtiger_ossmailtemplates` set ossmailtemplates_type = ? WHERE `name` = ? AND oss_module_list = ? ", array($temp[2], $temp[0], $temp[1]));
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('OSSMailTemplates'), getTabid('Documents'), 'get_attachments', 'Documents'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Documents');
            $target_Module = Vtiger_Module::getInstance('OSSMailTemplates');
            $target_Module->setRelatedList($moduleInstance, 'Documents', array('add,select'), 'get_attachments');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('HelpDesk'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('HelpDesk');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('SELECT'), 'get_related_list');
        }
        $adb->pquery("UPDATE `vtiger_field` set displaytype = ? WHERE `columnname` = ?;", array(2, 'was_read'));
        $adb->pquery("UPDATE `vtiger_field` set uitype = ? WHERE `columnname` = ? AND tablename = ?;", array(15, 'industry', 'vtiger_leaddetails'));
        $adb->pquery("UPDATE `vtiger_calendar_default_activitytypes` set active = ? ;", array(1));
        $adb->pquery("UPDATE `com_vtiger_workflows` SET `type` = ? WHERE `summary` = ? AND module_name = ? ;", array('[]', 'Ticket Creation: Send Email to Record Contact', 'HelpDesk'));
        $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Send Customer Login Details', 'Contacts'));
        if ($adb->num_rows($result) == 1) {
            $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id');
            $workflowTaskAdd = array(128, 53, 'Mark portal users password as sent.', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"53";s:7:"summary";s:35:"Mark portal users password as sent.";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:16:"MarkPasswordSent";s:2:"id";i:128;}');
            $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id));
            if ($adb->num_rows($result) == 0) {
                $taskManager = new VTTaskManager($adb);
                $task = $taskManager->unserializeTask($workflowTaskAdd[3]);
                $task->id = '';
                $task->workflowId = $workflow_id;
                $taskManager->saveTask($task);
            }
        }
        $adb->pquery('UPDATE com_vtiger_workflows SET defaultworkflow = "0" WHERE `summary` = ? AND module_name = ?;', array('Ticket Creation: Send Email to Record Contact', 'HelpDesk'));
        $result = $adb->pquery('SELECT * FROM com_vtiger_workflows WHERE `summary` = ? AND module_name = ?;', array('Ticket Creation: Send Email to Record Contact', 'HelpDesk'));
        for ($i = 0; $i < $adb->num_rows($result); $i++) {
            $recordId = $adb->query_result($result, $i, 'workflow_id');
            $adb->pquery("DELETE FROM com_vtiger_workflowtasks WHERE workflow_id IN\n\t\t\t\t\t\t\t(SELECT workflow_id FROM com_vtiger_workflows WHERE workflow_id=? AND (defaultworkflow IS NULL OR defaultworkflow != 1))", array($recordId));
            $adb->pquery("DELETE FROM com_vtiger_workflows WHERE workflow_id=? AND (defaultworkflow IS NULL OR defaultworkflow != 1)", array($recordId));
        }
        $result = $adb->pquery('SELECT * FROM com_vtiger_workflowtasks WHERE `summary` IN (?,?);', array('Notify Contact On Ticket Closed', 'Notify Contact On Ticket Change'));
        for ($i = 0; $i < $adb->num_rows($result); $i++) {
            $recordId = $adb->query_result($result, $i, 'task_id');
            $adb->pquery("delete from com_vtiger_workflowtasks where task_id=?", array($recordId));
        }
        $task_entity_method[] = array('HelpDesk', 'HeldDeskChangeNotifyContacts', 'modules/HelpDesk/workflows/HelpDeskWorkflow.php', 'HeldDeskChangeNotifyContacts');
        $task_entity_method[] = array('HelpDesk', 'HeldDeskClosedNotifyContacts', 'modules/HelpDesk/workflows/HelpDeskWorkflow.php', 'HeldDeskClosedNotifyContacts');
        $emm = new VTEntityMethodManager($adb);
        foreach ($task_entity_method as $method) {
            $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks_entitymethod` WHERE method_name = ? ", array($method[1]));
            if ($adb->num_rows($result) == 0) {
                $emm->addEntityMethod($method[0], $method[1], $method[2], $method[3]);
            }
        }
        $adb->pquery('UPDATE com_vtiger_workflows SET test = ? WHERE `summary` = ? AND module_name = ?;', array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is","value":"Closed","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket Closed: Send Email to Record Contact', 'HelpDesk'));
        $adb->pquery('UPDATE com_vtiger_workflows SET test = ? WHERE `summary` = ? AND module_name = ?;', array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is not","value":"Closed","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket change: Send Email to Record Contact', 'HelpDesk'));
        $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Ticket change: Send Email to Record Contact', 'HelpDesk'));
        if ($adb->num_rows($result) == 1) {
            $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id');
            $workflowTaskAdd = array(133, 26, 'Notify Contact On Ticket Change', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"26";s:7:"summary";s:31:"Notify Contact On Ticket Change";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:28:"HeldDeskChangeNotifyContacts";s:2:"id";i:133;}');
            $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id));
            if ($adb->num_rows($result) == 0) {
                $taskManager = new VTTaskManager($adb);
                $task = $taskManager->unserializeTask($workflowTaskAdd[3]);
                $task->id = '';
                $task->workflowId = $workflow_id;
                $taskManager->saveTask($task);
            }
        }
        $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Ticket Closed: Send Email to Record Contact', 'HelpDesk'));
        if ($adb->num_rows($result) == 1) {
            $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id');
            $workflowTaskAdd = array(134, 29, 'Notify contacts about closing of ticket.', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"29";s:7:"summary";s:40:"Notify contacts about closing of ticket.";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:28:"HeldDeskClosedNotifyContacts";s:2:"id";i:134;}');
            $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id));
            if ($adb->num_rows($result) == 0) {
                $taskManager = new VTTaskManager($adb);
                $task = $taskManager->unserializeTask($workflowTaskAdd[3]);
                $task->id = '';
                $task->workflowId = $workflow_id;
                $taskManager->saveTask($task);
            }
        }
        $this->settingsReplace();
        $this->picklists();
        $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showMailAccounts'));
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showMailAccounts','false');");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showNumberUnreadEmails'));
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showNumberUnreadEmails','false');");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showMailIcon'));
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showMailIcon','true');");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('timeCheckingMail'));
        if ($adb->num_rows($result) == 0) {
            $result = $adb->pquery("SELECT * FROM `vtiger_ossmailscanner_config` WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'time_checking_mail'));
            $value = $adb->query_result($result, 0, 'value');
            if (!$value) {
                $value = 30;
            }
            $adb->pquery("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','timeCheckingMail',?);", array($value));
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('autologinActive'));
        if ($adb->num_rows($result) == 0) {
            $result = $adb->pquery("SELECT * FROM `vtiger_ossmailscanner_config` WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'autologon'));
            $value = $adb->query_result($result, 0, 'value');
            if (!$value) {
                $value = 'false';
            }
            $adb->pquery("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('autologin','autologinActive',?);", array('false'));
        }
        $result = $adb->pquery('SELECT * FROM `yetiforce_mail_config` WHERE type = ? AND name = ?;', array('signature', 'signature'));
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('signature','signature','');");
        }
        $result = $adb->pquery('SELECT * FROM `yetiforce_mail_config` WHERE type = ? AND name = ?;', array('signature', 'addSignature'));
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_mail_config`(`type`,`name`,`value`) values ('signature','addSignature','false');");
        }
        $adb->pquery("DELETE FROM vtiger_ossmailscanner_config WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'autologon'));
        $adb->pquery("DELETE FROM vtiger_ossmailscanner_config WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'time_checking_mail'));
        $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `summary` = ? ;", array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is not","value":"Closed","valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"(assigned_user_id : (Users) emailoptout)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket change: Send Email to Record Owner'));
        $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `summary` = ? ;", array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is","value":"Closed","valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"(assigned_user_id : (Users) emailoptout)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket Closed: Send Email to Record Owner'));
        $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? ", array('Update Closed Time'));
        if ($adb->num_rows($result) == 1) {
            $task_id = $adb->query_result($result, 0, 'task_id');
            $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($task_id);
            $taskObject = $taskRecordModel->getTaskObject();
            $taskObject->active = false;
            $taskRecordModel->save();
        }
        $adb->pquery('UPDATE `vtiger_field` SET uitype = ? WHERE tabid = ? AND columnname = ? ;', array(19, getTabid('Emails'), 'description'));
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?  AND tabid =?;', [3, 'vtiger_activity', 'date_start', getTabid('Calendar')]);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?  AND tabid =?;', [10, 'vtiger_activity', 'date_start', getTabid('Events')]);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [4, 'vtiger_activity', 'due_date', getTabid('Calendar')]);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [11, 'vtiger_activity', 'due_date', getTabid('Events')]);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_contactdetails', 'firstname']);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_contactdetails', 'parentid']);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_contactdetails', 'email']);
        $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_contactdetails', 'smownerid']);
        $result = $adb->pquery("SELECT * FROM `vtiger_support_processes`;");
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `vtiger_support_processes`(`id`,`ticket_status_indicate_closing`) values (1,'');");
        }
        $result = $adb->pquery('SELECT quickcreatesequence FROM `vtiger_field` WHERE tablename = ? AND columnname = ? AND tabid =?;', array('vtiger_seactivityrel', 'crmid', getTabid('Calendar')));
        $result2 = $adb->pquery('SELECT quickcreatesequence FROM `vtiger_field` WHERE tablename = ? AND columnname = ? AND tabid =?;', array('vtiger_seactivityrel', 'crmid', getTabid('Events')));
        if ($adb->num_rows($result) == 1) {
            $quickcreatesequence = $adb->query_result($result, 0, 'quickcreatesequence');
            $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=? WHERE tablename = ? AND columnname = ? ;', ['process', 'vtiger_activity', 'process', 'Process', '1', 'vtiger_seactivityrel', 'crmid']);
            $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=?, uitype=?, quickcreatesequence=?, summaryfield=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['link', 'vtiger_activity', 'link', 'Relation', '2', '67', $quickcreatesequence, '1', 'vtiger_cntactivityrel', 'contactid', getTabid('Calendar')]);
            $quickcreatesequence = $adb->query_result($result2, 0, 'quickcreatesequence');
            $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=?, uitype=?, quickcreatesequence=?, summaryfield=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['link', 'vtiger_activity', 'link', 'Relation', '2', '67', $quickcreatesequence, '1', 'vtiger_cntactivityrel', 'contactid', getTabid('Events')]);
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_realization_process`;");
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("INSERT INTO vtiger_realization_process(module_id, status_indicate_closing) VALUES(?,?)", array(getTabid('Project'), ''));
        }
        $adb->pquery("DELETE FROM vtiger_settings_field WHERE name = ?;", array('LBL_CONVERSION_TO_ACCOUNT'));
        $adb->pquery('UPDATE `vtiger_settings_field` SET `name` = ?, `description` = ?, `linkto` = ? WHERE `name` = ? AND `description` = ? ;', ['LBL_MENU_BUILDER', 'LBL_MENU_BUILDER_DESCRIPTION', 'index.php?module=Menu&view=Index&parent=Settings', 'Menu Manager', 'LBL_MENU_DESC']);
        $result = $adb->query("SELECT * FROM `yetiforce_auth`;");
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','active','false');");
            $adb->query("insert  into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','server','testlab.local');");
            $adb->query("insert  into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','port','389');");
            $adb->pquery("insert  into `yetiforce_auth`(`type`,`param`,`value`) values (?,?,?);", ['ldap', 'users', NULL]);
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_auth` WHERE `param` = ?;", ['domain']);
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `yetiforce_auth`(`type`,`param`,`value`) values (?,?,?);", ['ldap', 'domain', NULL]);
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_menu`;");
        if ($adb->num_rows($result) == 0) {
            $menu[] = array(44, 0, 0, 2, 1, NULL, 'MEN_VIRTUAL_DESK', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(45, 0, 44, 0, 0, getTabid('Home'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(46, 0, 44, 0, 1, getTabid('Calendar'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(47, 0, 0, 2, 2, NULL, 'MEN_LEADS', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(48, 0, 47, 0, 0, getTabid('Leads'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(49, 0, 47, 0, 1, getTabid('Contacts'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(50, 0, 47, 0, 2, getTabid('Vendors'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(51, 0, 47, 0, 3, getTabid('Accounts'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(52, 0, 0, 2, 3, NULL, 'MEN_SALES', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(54, 0, 52, 0, 0, getTabid('Campaigns'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(55, 0, 52, 0, 1, getTabid('Potentials'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(56, 0, 52, 0, 2, getTabid('QuotesEnquires'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(57, 0, 52, 0, 3, getTabid('RequirementCards'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(58, 0, 52, 0, 4, getTabid('Calculations'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(59, 0, 52, 0, 5, getTabid('Quotes'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(60, 0, 52, 0, 6, getTabid('SalesOrder'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(61, 0, 52, 0, 7, getTabid('PurchaseOrder'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(62, 0, 52, 0, 8, getTabid('PriceBooks'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(63, 0, 0, 2, 5, NULL, 'MEN_SUPPORT', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(64, 0, 63, 0, 0, getTabid('HelpDesk'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(65, 0, 63, 0, 1, getTabid('ServiceContracts'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(66, 0, 63, 0, 2, getTabid('Faq'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(67, 0, 0, 2, 4, NULL, 'MEN_PROJECTS', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(68, 0, 67, 0, 0, getTabid('Project'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(69, 0, 67, 0, 1, getTabid('ProjectMilestone'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(70, 0, 67, 0, 2, getTabid('ProjectTask'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(71, 0, 0, 2, 6, NULL, 'MEN_BOOKKEEPING', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(72, 0, 71, 0, 3, getTabid('PaymentsIn'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(73, 0, 71, 0, 2, getTabid('PaymentsOut'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(74, 0, 71, 0, 1, getTabid('Invoice'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(75, 0, 71, 0, 0, getTabid('OSSCosts'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(76, 0, 0, 2, 7, NULL, 'MEN_HUMAN_RESOURCES', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(77, 0, 76, 0, 0, getTabid('OSSEmployees'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(78, 0, 76, 0, 1, getTabid('OSSTimeControl'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(79, 0, 76, 0, 2, getTabid('HolidaysEntitlement'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(80, 0, 0, 2, 8, NULL, 'MEN_SECRETARY', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(81, 0, 80, 0, 0, getTabid('LettersIn'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(82, 0, 80, 0, 1, getTabid('LettersOut'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(83, 0, 80, 0, 2, getTabid('Reservations'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(84, 0, 0, 2, 9, NULL, 'MEN_DATABESES', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(85, 0, 84, 2, 0, NULL, 'MEN_PRODUCTBASE', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(86, 0, 84, 0, 1, getTabid('Products'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(87, 0, 84, 0, 2, getTabid('OutsourcedProducts'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(88, 0, 84, 0, 3, getTabid('Assets'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(89, 0, 84, 3, 4, NULL, NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(90, 0, 84, 2, 5, NULL, 'MEN_SERVICESBASE', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(91, 0, 84, 0, 6, getTabid('Services'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(92, 0, 84, 0, 7, getTabid('OSSOutsourcedServices'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(93, 0, 84, 0, 8, getTabid('OSSSoldServices'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(94, 0, 84, 3, 9, NULL, NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(95, 0, 84, 2, 10, NULL, 'MEN_LISTS', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(96, 0, 84, 0, 11, getTabid('OSSMailView'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(97, 0, 84, 0, 12, getTabid('SMSNotifier'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(98, 0, 84, 0, 13, getTabid('PBXManager'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(99, 0, 84, 0, 14, getTabid('OSSMailTemplates'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(100, 0, 84, 0, 15, getTabid('Documents'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(102, 0, 84, 0, 16, getTabid('OSSPdf'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(106, 0, 84, 0, 18, getTabid('CallHistory'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(107, 0, 84, 3, 19, NULL, NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(108, 0, 84, 0, 21, getTabid('NewOrders'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(109, 0, 84, 0, 17, getTabid('OSSPasswords'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(110, 0, 0, 2, 10, NULL, 'MEN_TEAMWORK', 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(111, 0, 110, 0, 0, getTabid('Ideas'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(112, 0, 0, 6, 0, getTabid('Home'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(113, 0, 44, 0, 2, getTabid('OSSMail'), NULL, 0, NULL, 0, NULL, NULL, "");
            $menu[] = array(114, 0, 84, 0, 20, getTabid('Reports'), NULL, 0, NULL, 0, NULL, NULL, "");
            foreach ($menu as $m) {
                $adb->pquery("insert  into `yetiforce_menu`(`id`,`role`,`parentid`,`type`,`sequence`,`module`,`label`,`newwindow`,`dataurl`,`showicon`,`icon`,`sizeicon`,`hotkey`) values (" . generateQuestionMarks($m) . ");", array($m));
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'Calendar', getTabid('Home')]);
        if ($adb->num_rows($result) == 0) {
            $instanceModule = Vtiger_Module::getInstance('Home');
            $instanceModule->addLink('DASHBOARDWIDGET', 'Calendar', 'index.php?module=Home&view=ShowWidget&name=Calendar');
        }
        $adb->query('DROP TABLE IF EXISTS vtiger_converttoaccount_settings;');
        $adb->query('DROP TABLE IF EXISTS vtiger_marketing_processes;');
        $adb->query('DROP TABLE IF EXISTS vtiger_proc_marketing;');
        $adb->query('DROP TABLE IF EXISTS vtiger_salesprocesses_settings;');
        $adb->pquery('DELETE FROM vtiger_settings_field WHERE name = ?;', array('LBL_MDULES_COLOR_EDITOR'));
        $adb->query("CREATE TABLE IF NOT EXISTS `yetiforce_proc_marketing` (\n  `type` varchar(30) DEFAULT NULL,\n  `param` varchar(30) DEFAULT NULL,\n  `value` varchar(200) DEFAULT NULL,\n  KEY `type` (`type`,`param`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
        $adb->query("CREATE TABLE IF NOT EXISTS `yetiforce_proc_sales` (\n  `type` varchar(30) DEFAULT NULL,\n  `param` varchar(30) DEFAULT NULL,\n  `value` varchar(200) DEFAULT NULL,\n  KEY `type` (`type`,`param`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE type = ? AND param = ?;", ['conversion', 'change_owner']);
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('conversion','change_owner','false');");
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','groups','');");
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','status','');");
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','currentuser_status','false');");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_sales` WHERE type = ? AND param = ?;", ['popup', 'limit_product_service']);
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('popup','limit_product_service','false');");
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('popup','update_shared_permissions','false');");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_sales` WHERE type = ? AND param = ?;", ['calculation', 'calculationsstatus']);
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('calculation','calculationsstatus','');");
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('potential','salesstage','');");
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('asset','assetstatus','');");
            $adb->query("insert  into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('potential','add_potential','false');");
        }
        $adb->pquery('UPDATE `vtiger_settings_field` SET linkto = ? WHERE name = ?;', ['index.php?module=SalesProcesses&view=Index&parent=Settings', 'LBL_SALES_PROCESSES']);
        $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", ['vtiger.entity.link.after', 'Vtiger_SharingPrivileges_Handler']);
        if ($adb->num_rows($result) == 0) {
            $em = new VTEventsManager($adb);
            $em->registerHandler('vtiger.entity.link.after', 'modules/Vtiger/handlers/SharingPrivileges.php', 'Vtiger_SharingPrivileges_Handler');
        }
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_projecttask', 'projectid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_projecttask', 'startdate']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [6, getTabid('ProjectTask'), 'smownerid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_projecttask', 'projecttaskstatus']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_projecttask', 'projectmilestoneid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_projecttask', 'targetenddate']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_requirementcards', 'subject']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_requirementcards', 'requirementcards_status']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_requirementcards', 'potentialid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('RequirementCards'), 'smownerid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_requirementcards', 'quotesenquiresid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [9, 'vtiger_leadaddress', 'phone']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_leaddetails', 'lastname']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_leaddetails', 'company']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_leaddetails', 'email']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_leaddetails', 'leadstatus']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('Leads'), 'smownerid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_leaddetails', 'vat_id']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_leaddetails', 'leads_relation']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_leaddetails', 'legal_form']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_reservations', 'reservations_status']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [4, getTabid('Reservations'), 'smownerid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_reservations', 'date_start']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_reservations', 'time_start']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_reservations', 'time_end']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_reservations', 'due_date']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_reservations', 'type']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [9, getTabid('Reservations'), 'description']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_osspdf', 'title']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('OSSPdf'), 'smownerid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [10, 'vtiger_osspdf', 'osspdf_pdf_format']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [11, 'vtiger_osspdf', 'osspdf_pdf_orientation']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_osspdf', 'osspdf_enable_footer']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_osspdf', 'osspdf_enable_header']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_osspdf', 'height_header']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [9, 'vtiger_osspdf', 'height_footer']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_osspdf', 'selected']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_osspdf', 'osspdf_view']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_osspdf', 'moduleid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [6, getTabid('Contacts'), 'smownerid']);
        $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE handler_class = ?;", array('ProjectTaskHandler'));
        if ($adb->num_rows($result) == 0) {
            $em = new VTEventsManager($adb);
            $em->registerHandler('vtiger.entity.aftersave.final', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler');
            $em->registerHandler('vtiger.entity.afterdelete', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler');
            $em->registerHandler('vtiger.entity.afterrestore', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler');
        }
        $adb->pquery('UPDATE vtiger_relatedlists SET label = ? WHERE label = ?;', ['Activities', 'Upcoming Activities']);
        $adb->pquery('DELETE FROM vtiger_relatedlists WHERE `tabid` IN (?,?,?,?,?,?,?,?) AND `label` = ?;', [getTabid('Accounts'), getTabid('Leads'), getTabid('Contacts'), getTabid('Potentials'), getTabid('HelpDesk'), getTabid('Campaigns'), getTabid('ServiceContracts'), getTabid('Project'), 'Activity History']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_potential', 'related_to']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_potential', 'closingdate']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_potential', 'sales_stage']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', 2]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_osssoldservices', 'ssservicesstatus']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [9, 'vtiger_osssoldservices', 'pscategory']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_osssoldservices', 'datesold']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('OSSSoldServices')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_osssoldservices', 'invoiceid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_osssoldservices', 'parent_id']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_osssoldservices', 'serviceid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_paymentsin', 'paymentsname']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('PaymentsIn')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_paymentsin', 'paymentsin_status']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_paymentsin', 'relatedid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_paymentsin', 'salesid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_paymentsin', 'paymentsvalue']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_paymentsin', 'paymentstitle']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_paymentsin', 'bank_account']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_lettersin', 'title']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('LettersIn')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_lettersout', 'title']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('LettersOut')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_quotesenquires', 'subject']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_quotesenquires', 'potentialid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('QuotesEnquires')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_quotesenquires', 'quotesenquires_stage']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_account', 'phone']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_account', 'website']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('Accounts')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_vendor', 'phone']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_vendor', 'email']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('Vendors')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_osstimecontrol', 'osstimecontrol_status']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_osstimecontrol', 'date_start']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_osstimecontrol', 'time_start']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_osstimecontrol', 'time_end']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_osstimecontrol', 'due_date']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_osstimecontrol', 'timecontrol_type']);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_ossemployees', 'private_phone']);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_ossemployees', 'business_mail']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'description', getTabid('OSSTimeControl')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_holidaysentitlement', 'holidaysentitlement_year']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ?, masseditable = ? WHERE tablename = ? AND columnname = ?;', [3, 2, 2, 'vtiger_holidaysentitlement', 'days']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_holidaysentitlement', 'ossemployeesid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_crmentity', 'smownerid', getTabid('HolidaysEntitlement')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_account', 'legal_form']);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_leaddetails', 'industry']);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_leaddetails', 'subindustry']);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'was_read', getTabid('Leads')]);
        $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [10, 'vtiger_leaddetails', 'leads_relation']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_crmentity', 'smownerid', getTabid('Calendar')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_activity', 'due_date', getTabid('Calendar')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 2, 'vtiger_activity', 'process', getTabid('Calendar')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_activity', 'link', getTabid('Calendar')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_activity', 'subject', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'smownerid', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_activity', 'date_start', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_activity', 'due_date', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 2, 'vtiger_activity', 'process', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_activity', 'eventstatus', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_activity', 'activitytype', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_activity', 'link', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_activity', 'allday', getTabid('Events')]);
        $adb->pquery('UPDATE vtiger_homestuff SET `visible` = ? WHERE `stufftype` = ? ;', [1, 'Tag Cloud']);
        $adb->pquery('UPDATE vtiger_field SET typeofdata = ? WHERE tablename = ? AND columnname = ?;', ['D~M', 'vtiger_projectmilestone', 'projectmilestonedate']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_notes', 'filename', getTabid('Documents')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_crmentity', 'smownerid', getTabid('Documents')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_notes', 'filelocationtype', getTabid('Documents')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_notes', 'folderid', getTabid('Documents')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_modcomments', 'commentcontent', getTabid('ModComments')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('ModComments')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_modcomments', 'related_to', getTabid('ModComments')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_projecttask', 'projectid', getTabid('ProjectTask')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_crmentity', 'smownerid', getTabid('ProjectTask')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_projecttask', 'startdate', getTabid('ProjectTask')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_projecttask', 'projecttaskstatus', getTabid('ProjectTask')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_osspasswords', 'passwordname', getTabid('OSSPasswords')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_osspasswords', 'username', getTabid('OSSPasswords')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_osspasswords', 'password', getTabid('OSSPasswords')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_osspasswords', 'link_adres', getTabid('OSSPasswords')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_crmentity', 'smownerid', getTabid('OSSPasswords')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_ossemployees', 'employee_status', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_crmentity', 'smownerid', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_ossemployees', 'last_name', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [17, 'vtiger_ossemployees', 'pesel', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [18, 'vtiger_ossemployees', 'id_card', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_ossemployees', 'employee_education', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 'vtiger_ossemployees', 'birth_date', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [19, 'vtiger_ossemployees', 'business_phone', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [16, 'vtiger_ossemployees', 'private_phone', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [21, 'vtiger_ossemployees', 'business_mail', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [20, 'vtiger_ossemployees', 'private_mail', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [22, 'vtiger_ossemployees', 'street', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [13, 'vtiger_ossemployees', 'code', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_ossemployees', 'city', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_ossemployees', 'state', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [10, 'vtiger_ossemployees', 'country', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [11, 'vtiger_ossemployees', 'ship_street', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [15, 'vtiger_ossemployees', 'ship_code', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [12, 'vtiger_ossemployees', 'ship_city', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [14, 'vtiger_ossemployees', 'ship_state', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_ossemployees', 'ship_country', getTabid('OSSEmployees')]);
        $adb->pquery('UPDATE vtiger_field SET defaultvalue = ?, summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['PLL_WAITING_FOR_VERIFICATION', 1, 'vtiger_calculations', 'calculationsstatus']);
        $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'name']);
        $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'relatedid']);
        $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'potentialid']);
        $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'requirementcardsid']);
        $adb->pquery('UPDATE vtiger_field SET summaryfield = ?, displaytype = ? WHERE tablename = ? AND columnname = ?;', ['1', 1, 'vtiger_calculations', 'quotesenquiresid']);
        $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_projecttask', 'estimated_work_time']);
        $widgets[] = array(53, 'Calculations', 'Summary', NULL, 1, 0, NULL, '[]');
        $widgets[] = array(54, 'Calculations', 'RelatedModule', '', 2, 1, NULL, '{"limit":"5","relatedmodule":"8","columns":"3","action":"1","filter":"-"}');
        foreach ($widgets as $widget) {
            if (self::checkModuleExists($widget[1])) {
                $result = $adb->pquery('SELECT * FROM vtiger_widgets WHERE tabid = ? AND `type` = ?', array(getTabid($widget[1]), $widget[2]));
                if (!$adb->num_rows($result)) {
                    $sql = "INSERT INTO vtiger_widgets (tabid, type, label, wcol, sequence, nomargin, data) VALUES (?, ?, ?, ?, ?, ?, ?);";
                    $adb->pquery($sql, array(getTabid($widget[1]), $widget[2], $widget[3], $widget[4], $widget[5], $widget[6], $widget[7]));
                }
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'Calculations', getTabid('Home')]);
        if ($adb->num_rows($result) == 0) {
            $instanceModule = Vtiger_Module::getInstance('Home');
            $instanceModule->addLink('DASHBOARDWIDGET', 'Calculations', 'index.php?module=Calculations&view=ShowWidget&name=Calculations');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'PotentialsList', getTabid('Home')]);
        if ($adb->num_rows($result) == 0) {
            $instanceModule = Vtiger_Module::getInstance('Home');
            $instanceModule->addLink('DASHBOARDWIDGET', 'PotentialsList', 'index.php?module=Potentials&view=ShowWidget&name=PotentialsList');
        }
        // copy values from_portal in HelpDesk
        $result = $adb->query("SHOW COLUMNS FROM `vtiger_troubletickets` LIKE 'from_portal';");
        if ($adb->num_rows($result) == 0) {
            $adb->query("ALTER TABLE `vtiger_troubletickets` ADD COLUMN `from_portal` varchar(3) NULL after `ordertime` ;");
            $adb->query('UPDATE vtiger_troubletickets LEFT JOIN vtiger_ticketcf ON vtiger_troubletickets.ticketid = vtiger_ticketcf.ticketid SET vtiger_troubletickets.from_portal=vtiger_ticketcf.from_portal;');
            $adb->pquery('UPDATE `vtiger_field` SET tablename=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['vtiger_troubletickets', 'vtiger_ticketcf', 'from_portal', getTabid('HelpDesk')]);
            $adb->pquery('alter table vtiger_ticketcf drop column from_portal');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE `type` = ? AND `name` = ? ;", ['info', 'notworkingdays']);
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('info','notworkingdays ','LBL_NOTWORKING_DAYS',NULL);");
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linklabel = ? AND linkicon = ? ; ", array('LBL_SHOW_ACCOUNT_HIERARCHY', 'icon-align-justify'));
        if ($adb->num_rows($result) == 0) {
            //$mods = Vtiger_Module::getInstance( "Accounts" );
            // $mods->deleteLink('DETAILVIEWBASIC', 'LBL_SHOW_ACCOUNT_HIERARCHY', 'index.php?module=Accounts&action=AccountHierarchy&accountid=$RECORD$');
            $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = ? WHERE `linklabel`= ? ;", array('icon-align-justify', 'LBL_SHOW_ACCOUNT_HIERARCHY'));
            $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = ? WHERE `linklabel`= ? ;", array('icon-file', 'LBL_ADD_NOTE'));
            $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-file'  WHERE `linklabel` = ?;", array('Add Note'));
            $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-tasks' WHERE `linklabel` = ?;", array('Add Project Task'));
            $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-user' WHERE `linklabel` = ?;", array('LBL_SHOW_EMPLOYEES_HIERARCHY'));
        }
        $result = $adb->query("SELECT * FROM `vtiger_backup_settings`;");
        if ($adb->num_rows($result) == 0) {
            $adb->query("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values ('folder','storage_folder','false');");
            $adb->query("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values ('folder','storage_folder','false');");
        }
        // change related list
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Accounts'), 'change' => array('name' => 'get_accounts_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Contacts'), 'change' => array('name' => 'get_contacts_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Leads'), 'change' => array('name' => 'get_leads_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Potentials'), 'change' => array('name' => 'get_potentials_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('HelpDesk'), 'change' => array('name' => 'get_helpdesk_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Project'), 'change' => array('name' => 'get_project_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('ServiceContracts'), 'change' => array('name' => 'get_servicecontracts_mail'));
        $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Campaigns'), 'change' => array('name' => 'get_campaigns_mail'));
        $update[] = array('tabid' => getTabid('Contacts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails'));
        $update[] = array('tabid' => getTabid('Leads'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails'));
        $update[] = array('tabid' => getTabid('Accounts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails'));
        $update[] = array('tabid' => getTabid('Vendors'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails'));
        $update[] = array('tabid' => getTabid('ServiceContracts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => ''));
        $update[] = array('tabid' => getTabid('HelpDesk'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => ''));
        $update[] = array('tabid' => getTabid('Potentials'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => ''));
        $update[] = array('tabid' => getTabid('Campaigns'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => ''));
        $update[] = array('tabid' => getTabid('Project'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => ''));
        foreach ($update as $presents) {
            $sql1 = 'UPDATE `vtiger_relatedlists` SET ';
            foreach ($presents['change'] as $column => $value) {
                $sql = $sql1 . $column . ' = ? ';
                $sql .= 'WHERE `tabid` = ? AND `related_tabid` = ? ;';
                $adb->pquery($sql, array($value, $presents['tabid'], $presents['related_tabid']), true);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('OSSMailView'), getTabid('Vendors'), 'get_vendor_mail', 'Vendors'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Vendors');
            $target_Module = Vtiger_Module::getInstance('OSSMailView');
            $target_Module->setRelatedList($moduleInstance, 'Vendors', array('ADD,SELECT'), 'get_vendor_mail');
        }
        //mailview relation
        $module = 'OSSMailView';
        $sql = 'SELECT * FROM vtiger_crmentityrel WHERE module = ? OR relmodule = ?';
        $result1 = $adb->pquery($sql, [$module, $module]);
        for ($i = 0; $i < $adb->num_rows($result1); $i++) {
            $row = $adb->raw_query_result_rowdata($result1, $i);
            $id = $row['module'] == $module ? $row['relcrmid'] : $row['crmid'];
            $mailID = $row['module'] != $module ? $row['relcrmid'] : $row['crmid'];
            $sql = 'SELECT createdtime FROM vtiger_crmentity WHERE crmid = ?';
            $result2 = $adb->pquery($sql, [$mailID]);
            if ($adb->num_rows($result2) > 0) {
                $createdtime = $adb->query_result($result2, 0, 'createdtime');
                $adb->pquery('INSERT INTO vtiger_ossmailview_relation VALUES(?,?,?,?)', [$mailID, $id, $createdtime, 0]);
                $adb->pquery('DELETE FROM vtiger_crmentityrel WHERE crmid = ? AND relcrmid = ?; ', [$row['crmid'], $row['relcrmid']]);
            }
        }
        $adb->pquery('UPDATE `vtiger_ossmailview` LEFT JOIN `vtiger_crmentity` ON `vtiger_ossmailview`.`ossmailviewid` = `vtiger_crmentity`.`crmid`
		SET `vtiger_ossmailview`.`date` = vtiger_crmentity.`modifiedtime` WHERE `vtiger_ossmailview`.`date` IS NULL OR `vtiger_ossmailview`.`date` = ?', ['0000-00-00 00:00:00']);
        $result = $adb->pquery('SELECT * FROM `roundcube_system` WHERE name = ?;', array('roundcube-version'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery('UPDATE `roundcube_system` SET `value` = ? WHERE `name` = ?;', ['2015030800', 'roundcube-version']);
        } else {
            $adb->pquery('INSERT INTO `roundcube_system`(`name`,`value`) values (?,?);', ['2015030800', 'roundcube-version']);
        }
        //
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Project'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('Project');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Project'), 'get_related_list', 'Project'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Project');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'Project', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Quotes'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('Quotes');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Quotes'), 'get_related_list', 'Quotes'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Quotes');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'Quotes', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Calculations'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('Calculations');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Calculations'), 'get_related_list', 'Calculations'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Calculations');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'Calculations', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('QuotesEnquires'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('QuotesEnquires');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('QuotesEnquires'), 'get_related_list', 'QuotesEnquires'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('QuotesEnquires');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'QuotesEnquires', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('SalesOrder'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('SalesOrder');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('SalesOrder'), 'get_related_list', 'SalesOrder'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('SalesOrder');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'SalesOrder', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('PurchaseOrder'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('PurchaseOrder');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('PurchaseOrder'), 'get_related_list', 'PurchaseOrder'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('PurchaseOrder');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'PurchaseOrder', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Invoice'), getTabid('Contacts'), 'get_related_list', 'Contacts'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Contacts');
            $target_Module = Vtiger_Module::getInstance('Invoice');
            $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list');
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Invoice'), 'get_related_list', 'Invoice'));
        if ($adb->num_rows($result) == 0) {
            $moduleInstance = Vtiger_Module::getInstance('Invoice');
            $target_Module = Vtiger_Module::getInstance('Contacts');
            $target_Module->setRelatedList($moduleInstance, 'Invoice', array('ADD,SELECT'), 'get_related_list');
        }
        $adb->pquery('UPDATE vtiger_field SET typeofdata = ? WHERE tablename = ? AND columnname = ?;', ['D~M', 'vtiger_calculations', 'date']);
        $result = $adb->pquery("SELECT * FROM `vtiger_dataaccess` WHERE module_name = ? AND `summary` = ?;", ['Events', 'Adding time period to status change']);
        if ($adb->num_rows($result) == 0) {
            $adb->pquery('insert  into `vtiger_dataaccess`(`module_name`,`summary`,`data`) values (?,?,?)', ['Events', 'Adding time period to status change', 'a:1:{i:0;a:3:{s:2:"an";s:25:"Vtiger!!show_quick_create";s:7:"modules";s:14:"OSSTimeControl";s:2:"cf";b:1;}}']);
            $recordId = $adb->getLastInsertID();
            $adb->pquery('insert  into `vtiger_dataaccess_cnd`(`dataaccessid`,`fieldname`,`comparator`,`val`,`required`,`field_type`) values (?,?,?,?,?,?);', [$recordId, 'eventstatus', 'has changed', 'Held', 1, 'picklist']);
        }
        $adb->pquery('UPDATE vtiger_links SET linkurl = ? WHERE linklabel = ?;', ['index.php?module=OSSTimeControl&view=ShowWidget&name=TimeControl', 'Employees Time Control']);
        $adb->pquery('DELETE FROM `vtiger_ws_entity` WHERE `name` = ? LIMIT 1;', ['OSSDocumentControl']);
        $adb->pquery("UPDATE vtiger_widgets SET data = ?  WHERE type = 'RelatedModule' AND label = 'ProjectTask';", ['{"limit":"5","relatedmodule":"' . getTabid('ProjectTask') . '","columns":"3","action":"1","filter":"-","checkbox_selected":"","checkbox":"-"}']);
        $adb->pquery("UPDATE vtiger_widgets SET data = ? WHERE type = 'RelatedModule' AND label = 'ProjectMilestone';", ['{"limit":"5","relatedmodule":"' . getTabid('ProjectMilestone') . '","columns":"3","action":"1","filter":"-","checkbox_selected":"","checkbox":"-"}']);
        $adb->query("UPDATE vtiger_widgets SET label = 'Documents' WHERE type = 'RelatedModule' AND tabid = '" . getTabid('Calculations') . "';");
        $log->debug("Exiting YetiForceUpdate::databaseData() method ...");
    }
Ejemplo n.º 19
0
 private function addWorkflow($moduleName)
 {
     vimport('~~modules/com_vtiger_workflow/include.inc');
     vimport('~~modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc');
     vimport('~~modules/com_vtiger_workflow/VTEntityMethodManager.inc');
     $db = PearDatabase::getInstance();
     $functionName = 'UpdateBalance';
     $emm = new VTEntityMethodManager($db);
     $emm->addEntityMethod($moduleName, $functionName, "modules/PaymentsIn/workflow/UpdateBalance.php", $functionName);
     $workflowManager = new VTWorkflowManager($db);
     $taskManager = new VTTaskManager($db);
     $newWorkflow = $workflowManager->newWorkFlow($moduleName);
     $newWorkflow->test = '[]';
     $newWorkflow->defaultworkflow = 0;
     $newWorkflow->description = "{$moduleName} - UpdateBalance";
     $newWorkflow->executionCondition = 3;
     $workflowManager->save($newWorkflow);
     $task = $taskManager->createTask('VTEntityMethodTask', $newWorkflow->id);
     $task->active = true;
     $task->summary = 'UpdateBalance';
     $task->methodName = $functionName;
     $taskManager->saveTask($task);
 }
Ejemplo n.º 20
0
}
$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>";
    $workflowScheduler = new WorkFlowScheduler($adb);
    $query = $workflowScheduler->getWorkflowQuery($workflow);
    echo "<span style='font-size: large;'>{$query}</span>";
} else {
    echo "<h2>Launch Conditions:</h2>";
    $eval = $workflow->evaluate($entityCache, $crm_record_to_evaluate);
    echo "<span style='font-size: large;'>";
    var_dump($eval);
    echo '</span>';
    $tm = new VTTaskManager($adb);
    $taskQueue = new VTTaskQueue($adb);
    $tasks = $tm->getTasksForWorkflow($workflow->id);
    foreach ($tasks as $task) {
        if (is_object($task) and $task->active and get_class($task) == 'VTEmailTask') {
            $email = evalwfEmailTask($crm_record_to_evaluate, $task);
            foreach ($email as $key => $value) {
                echo "<h2>{$key}</h2>{$value} <br><hr>";
            }
        }
    }
}
?>
</table>
</body>
</html>
Ejemplo n.º 21
0
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=ConfigEditor&action=index', description='Update configuration file of the application' where name = 'Configuration Editor' or name = 'LBL_CONFIG_EDITOR'");
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=ModTracker&action=BasicSettings&parenttab=Settings&formodule=ModTracker' where name = 'ModTracker'");
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=CustomerPortal&action=index&parenttab=Settings' where name = 'LBL_CUSTOMER_PORTAL'");
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Webforms&action=index&parenttab=Settings', description='Allows you to manage Webforms' where name = 'Webforms'");
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=CronTasks&action=ListCronJobs&parenttab=Settings', description='Allows you to Configure Cron Task' where name = 'Scheduler'");
ExecuteQuery("UPDATE `vtiger_settings_field` set `linkto` = 'index.php?module=Tooltip&action=QuickView&parenttab=Settings' where name = 'LBL_TOOLTIP_MANAGEMENT'");
//Delete new Blocks in Calendar
ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_DESCRIPTION_INFORMATION' AND tabid = '9'");
ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_DESCRIPTION_INFORMATION' AND tabid = '16'");
ExecuteQuery("UPDATE vtiger_blocks SET blocklabel = '' WHERE blocklabel = 'LBL_REMINDER_INFORMATION' AND tabid = 16");
ExecuteQuery("UPDATE vtiger_field SET block = '41' WHERE tabid = '16' and fieldname NOT IN('reminder_time','contact_id')");
ExecuteQuery("UPDATE vtiger_field SET block = '19' WHERE tabid = '16' and fieldname = 'contact_id'");
// Change HelpDesk Workflows
global $adb;
$workflowManager = new VTWorkflowManager($adb);
$taskManager = new VTTaskManager($adb);
$wfrs = $adb->query("SELECT workflow_id,summary FROM com_vtiger_workflows WHERE module_name='HelpDesk'");
while ($wfid = $adb->fetch_array($wfrs)) {
    deleteWorkflow($wfid['workflow_id']);
    putMsg('Workflow "' . $wfid['summary'] . '" deleted!');
}
// Trouble Tickets workflow on creation from Customer Portal
$helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
$helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]';
$helpDeskWorkflow->description = "Workflow for Ticket Created from Portal";
$helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_FIRST_SAVE;
$helpDeskWorkflow->defaultworkflow = 1;
$workflowManager->save($helpDeskWorkflow);
$task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
$task->active = true;
$task->summary = 'Notify Record Owner and the Related Contact when Ticket is created from Portal';
Ejemplo n.º 22
0
$defaultModules = array('include' => array(), 'exclude' => array());
$createToDoModules = array('include' => array("Leads", "Accounts", "Potentials", "Contacts", "HelpDesk", "Campaigns", "Quotes", "PurchaseOrder", "SalesOrder", "Invoice"), 'exclude' => array("Calendar", "FAQ", "Events"));
$createEventModules = array('include' => array("Leads", "Accounts", "Potentials", "Contacts", "HelpDesk", "Campaigns"), 'exclude' => array("Calendar", "FAQ", "Events"));
$taskTypes[] = array("name" => "VTEmailTask", "label" => "Send Mail", "classname" => "VTEmailTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTEmailTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTEmailTask.tpl", "modules" => $defaultModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTEntityMethodTask", "label" => "Invoke Custom Function", "classname" => "VTEntityMethodTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTEntityMethodTask.tpl", "modules" => $defaultModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTCreateTodoTask", "label" => "Create Todo", "classname" => "VTCreateTodoTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTCreateTodoTask.tpl", "modules" => $createToDoModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTCreateEventTask", "label" => "Create Event", "classname" => "VTCreateEventTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTCreateEventTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTCreateEventTask.tpl", "modules" => $createEventModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTUpdateFieldsTask", "label" => "Update Fields", "classname" => "VTUpdateFieldsTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTUpdateFieldsTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTUpdateFieldsTask.tpl", "modules" => $defaultModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTCreateEntityTask", "label" => "Create Entity", "classname" => "VTCreateEntityTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTCreateEntityTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTCreateEntityTask.tpl", "modules" => $defaultModules, "sourcemodule" => '');
$taskTypes[] = array("name" => "VTSMSTask", "label" => "SMS Task", "classname" => "VTSMSTask", "classpath" => "modules/com_vtiger_workflow/tasks/VTSMSTask.inc", "templatepath" => "com_vtiger_workflow/taskforms/VTSMSTask.tpl", "modules" => $defaultModules, "sourcemodule" => 'SMSNotifier');
foreach ($taskTypes as $taskType) {
    VTTaskType::registerTaskType($taskType);
}
// Creating Default workflows
$workflowManager = new VTWorkflowManager($adb);
$taskManager = new VTTaskManager($adb);
// Contact workflow on creation/modification
$contactWorkFlow = $workflowManager->newWorkFlow("Contacts");
$contactWorkFlow->test = '';
$contactWorkFlow->description = "Workflow for Contact Creation or Modification";
$contactWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
$contactWorkFlow->defaultworkflow = 1;
$workflowManager->save($contactWorkFlow);
$task = $taskManager->createTask('VTEntityMethodTask', $contactWorkFlow->id);
$task->active = true;
$task->summary = 'Email Customer Portal Login Details';
$task->methodName = "SendPortalLoginDetails";
$taskManager->saveTask($task);
// Trouble Tickets workflow on creation from Customer Portal
$helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
$helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]';
Ejemplo n.º 23
0
 public function addWorkflow()
 {
     global $log, $adb;
     $workflow = array();
     $result = $adb->query("SELECT * FROM `com_vtiger_workflows` WHERE summary = 'Update Closed Time';");
     if ($adb->num_rows($result) == 0) {
         $workflow[] = array(54, 'HelpDesk', 'Update Closed Time', '[{"fieldname":"ticketstatus","operation":"is","value":"Rejected","valuetype":"rawtext","joincondition":"or","groupjoin":null,"groupid":"1"},{"fieldname":"ticketstatus","operation":"is","value":"Closed","valuetype":"rawtext","joincondition":"","groupjoin":null,"groupid":"1"}]', 2, NULL, 'basic', 6, NULL, NULL, NULL, NULL, NULL, NULL);
     }
     $result = $adb->query("SELECT * FROM `com_vtiger_workflows` WHERE summary = 'Generate mail address book';");
     if ($adb->num_rows($result) == 0) {
         $workflow[] = array(55, 'Contacts', 'Generate mail address book', '[]', 3, NULL, 'basic', 6, NULL, NULL, NULL, NULL, NULL, NULL);
     }
     $workflowTask = array();
     $workflowTask[] = array(121, 54, 'Update Closed Time', 'O:18:"VTUpdateClosedTime":6:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"54";s:7:"summary";s:18:"Update Closed Time";s:6:"active";b:1;s:7:"trigger";N;s:2:"id";i:121;}');
     $workflowTask[] = array(123, 55, 'Generate mail address book', 'O:17:"VTAddressBookTask":7:{s:18:"executeImmediately";b:0;s:10:"workflowId";s:2:"55";s:7:"summary";s:26:"Generate mail address book";s:6:"active";b:1;s:7:"trigger";N;s:4:"test";s:0:"";s:2:"id";i:123;}');
     require_once 'modules/com_vtiger_workflow/include.inc';
     require_once 'modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc';
     require_once 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';
     $workflowManager = new VTWorkflowManager($adb);
     $taskManager = new VTTaskManager($adb);
     foreach ($workflow as $record) {
         $newWorkflow = $workflowManager->newWorkFlow($record[1]);
         $newWorkflow->description = $record[2];
         $newWorkflow->test = $record[3];
         $newWorkflow->executionCondition = $record[4];
         $newWorkflow->defaultworkflow = $record[5];
         $newWorkflow->type = $record[6];
         $newWorkflow->filtersavedinnew = $record[7];
         $workflowManager->save($newWorkflow);
         foreach ($workflowTask as $indexTask) {
             if ($indexTask[1] == $record[0]) {
                 $task = $taskManager->unserializeTask($indexTask[3]);
                 $task->id = '';
                 $task->workflowId = $newWorkflow->id;
                 $taskManager->saveTask($task);
             }
         }
     }
 }
Ejemplo n.º 24
0
function populateDefaultWorkflows($adb)
{
    require_once "modules/com_vtiger_workflow/include.inc";
    require_once "modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc";
    require_once "modules/com_vtiger_workflow/VTEntityMethodManager.inc";
    // Creating Workflow for Updating Inventory Stock for Invoice
    $vtWorkFlow = new VTWorkflowManager($adb);
    $invWorkFlow = $vtWorkFlow->newWorkFlow("Invoice");
    $invWorkFlow->test = '[{"fieldname":"subject","operation":"does not contain","value":"`!`"}]';
    $invWorkFlow->description = "UpdateInventoryProducts On Every Save";
    $invWorkFlow->defaultworkflow = 1;
    $vtWorkFlow->save($invWorkFlow);
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
    $task->active = true;
    $task->methodName = "UpdateInventory";
    $tm->saveTask($task);
    // Creating Workflow for Accounts when Notifyowner is true
    $vtaWorkFlow = new VTWorkflowManager($adb);
    $accWorkFlow = $vtaWorkFlow->newWorkFlow("Accounts");
    $accWorkFlow->test = '[{"fieldname":"notify_owner","operation":"is","value":"true:boolean"}]';
    $accWorkFlow->description = "Send Email to user when Notifyowner is True";
    $accWorkFlow->executionCondition = 2;
    $accWorkFlow->defaultworkflow = 1;
    $vtaWorkFlow->save($accWorkFlow);
    $id1 = $accWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $accWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Account Creation";
    $task->content = "An Account has been assigned to you on vtigerCRM<br>Details of account are :<br><br>" . "AccountId:" . '<b>$account_no</b><br>' . "AccountName:" . '<b>$accountname</b><br>' . "Rating:" . '<b>$rating</b><br>' . "Industry:" . '<b>$industry</b><br>' . "AccountType:" . '<b>$accounttype</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "Thank You<br>Admin";
    $task->summary = "An account has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Contacts when Notifyowner is true
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $conWorkFlow = $vtcWorkFlow->newWorkFlow("Contacts");
    $conWorkFlow->summary = "A contact has been created ";
    $conWorkFlow->executionCondition = 2;
    $conWorkFlow->test = '[{"fieldname":"notify_owner","operation":"is","value":"true:boolean"}]';
    $conWorkFlow->description = "Send Email to user when Notifyowner is True";
    $conWorkFlow->defaultworkflow = 1;
    $vtcWorkFlow->save($conWorkFlow);
    $id1 = $conWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $conWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Contact Creation";
    $task->content = "An Contact has been assigned to you on vtigerCRM<br>Details of Contact are :<br><br>" . "Contact Id:" . '<b>$contact_no</b><br>' . "LastName:" . '<b>$lastname</b><br>' . "FirstName:" . '<b>$firstname</b><br>' . "Lead Source:" . '<b>$leadsource</b><br>' . "Department:" . '<b>$department</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "Thank You<br>Admin";
    $task->summary = "An contact has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Contacts when PortalUser is true
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $conpuWorkFlow = $vtcWorkFlow->newWorkFlow("Contacts");
    $conpuWorkFlow->test = '[{"fieldname":"portal","operation":"is","value":"true:boolean"}]';
    $conpuWorkFlow->description = "Send Email to user when Portal User is True";
    $conpuWorkFlow->executionCondition = 2;
    $conpuWorkFlow->defaultworkflow = 1;
    $vtcWorkFlow->save($conpuWorkFlow);
    $id1 = $conpuWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $conpuWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Contact Assignment";
    $task->content = "An Contact has been assigned to you on vtigerCRM<br>Details of Contact are :<br><br>" . "Contact Id:" . '<b>$contact_no</b><br>' . "LastName:" . '<b>$lastname</b><br>' . "FirstName:" . '<b>$firstname</b><br>' . "Lead Source:" . '<b>$leadsource</b><br>' . "Department:" . '<b>$department</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "And <b>CustomerPortal Login Details</b> is sent to the " . "EmailID :-" . '$email<br>' . "<br>Thank You<br>Admin";
    $task->summary = "An contact has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Potentials
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $potentialWorkFlow = $vtcWorkFlow->newWorkFlow("Potentials");
    $potentialWorkFlow->description = "Send Email to users on Potential creation";
    $potentialWorkFlow->executionCondition = 1;
    $potentialWorkFlow->defaultworkflow = 1;
    $vtcWorkFlow->save($potentialWorkFlow);
    $id1 = $potentialWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $potentialWorkFlow->id);
    $task->active = true;
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Potential Assignment";
    $task->content = "An Potential has been assigned to you on vtigerCRM<br>Details of Potential are :<br><br>" . "Potential No:" . '<b>$potential_no</b><br>' . "Potential Name:" . '<b>$potentialname</b><br>' . "Amount:" . '<b>$amount</b><br>' . "Expected Close Date:" . '<b>$closingdate</b><br>' . "Type:" . '<b>$opportunity_type</b><br><br><br>' . "Description :" . '$description<br>' . "<br>Thank You<br>Admin";
    $task->summary = "An Potential has been created ";
    $tm->saveTask($task);
    $workflowManager = new VTWorkflowManager($adb);
    $taskManager = new VTTaskManager($adb);
    // Contact workflow on creation/modification
    $contactWorkFlow = $workflowManager->newWorkFlow("Contacts");
    $contactWorkFlow->test = '';
    $contactWorkFlow->description = "Workflow for Contact Creation or Modification";
    $contactWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
    $contactWorkFlow->defaultworkflow = 1;
    $workflowManager->save($contactWorkFlow);
    $task = $taskManager->createTask('VTEntityMethodTask', $contactWorkFlow->id);
    $task->active = true;
    $task->summary = 'Email Customer Portal Login Details';
    $task->methodName = "SendPortalLoginDetails";
    $taskManager->saveTask($task);
    // Trouble Tickets workflow on creation from Customer Portal
    $helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
    $helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]';
    $helpDeskWorkflow->description = "Workflow for Ticket Created from Portal";
    $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_FIRST_SAVE;
    $helpDeskWorkflow->defaultworkflow = 1;
    $workflowManager->save($helpDeskWorkflow);
    $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
    $task->active = true;
    $task->summary = 'Notify Record Owner and the Related Contact when Ticket is created from Portal';
    $task->methodName = "NotifyOnPortalTicketCreation";
    $taskManager->saveTask($task);
    // Trouble Tickets workflow on ticket update from Customer Portal
    $helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
    $helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]';
    $helpDeskWorkflow->description = "Workflow for Ticket Updated from Portal";
    $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_MODIFY;
    $helpDeskWorkflow->defaultworkflow = 1;
    $workflowManager->save($helpDeskWorkflow);
    $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
    $task->active = true;
    $task->summary = 'Notify Record Owner when Comment is added to a Ticket from Customer Portal';
    $task->methodName = "NotifyOnPortalTicketComment";
    $taskManager->saveTask($task);
    // Trouble Tickets workflow on ticket change, which is not from Customer Portal - Both Record Owner and Related Customer
    $helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
    $helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"false:boolean"}]';
    $helpDeskWorkflow->description = "Workflow for Ticket Change, not from the Portal";
    $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
    $helpDeskWorkflow->defaultworkflow = 1;
    $workflowManager->save($helpDeskWorkflow);
    $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
    $task->active = true;
    $task->summary = 'Notify Record Owner on Ticket Change, which is not done from Portal';
    $task->methodName = "NotifyOwnerOnTicketChange";
    $taskManager->saveTask($task);
    $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
    $task->active = true;
    $task->summary = 'Notify Related Customer on Ticket Change, which is not done from Portal';
    $task->methodName = "NotifyParentOnTicketChange";
    $taskManager->saveTask($task);
    // Events workflow when Send Notification is checked
    $eventsWorkflow = $workflowManager->newWorkFlow("Events");
    $eventsWorkflow->test = '[{"fieldname":"sendnotification","operation":"is","value":"true:boolean"}]';
    $eventsWorkflow->description = "Workflow for Events when Send Notification is True";
    $eventsWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
    $eventsWorkflow->defaultworkflow = 1;
    $workflowManager->save($eventsWorkflow);
    $task = $taskManager->createTask('VTEmailTask', $eventsWorkflow->id);
    $task->active = true;
    $task->summary = 'Send Notification Email to Record Owner';
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Event :  \$subject";
    $task->content = '$(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) ,<br/>' . '<b>Activity Notification Details:</b><br/>' . 'Subject             : $subject<br/>' . 'Start date and time : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'End date and time   : $due_date  $time_end ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Status              : $eventstatus <br/>' . 'Priority            : $taskpriority <br/>' . 'Related To          : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Contacts List       : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Location            : $location <br/>' . 'Description         : $description';
    $taskManager->saveTask($task);
    // Calendar workflow when Send Notification is checked
    $calendarWorkflow = $workflowManager->newWorkFlow("Calendar");
    $calendarWorkflow->test = '[{"fieldname":"sendnotification","operation":"is","value":"true:boolean"}]';
    $calendarWorkflow->description = "Workflow for Calendar Todos when Send Notification is True";
    $calendarWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
    $calendarWorkflow->defaultworkflow = 1;
    $workflowManager->save($calendarWorkflow);
    $task = $taskManager->createTask('VTEmailTask', $calendarWorkflow->id);
    $task->active = true;
    $task->summary = 'Send Notification Email to Record Owner';
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Task :  \$subject";
    $task->content = '$(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) ,<br/>' . '<b>Task Notification Details:</b><br/>' . 'Subject : $subject<br/>' . 'Start date and time : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'End date and time   : $due_date ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Status              : $taskstatus <br/>' . 'Priority            : $taskpriority <br/>' . 'Related To          : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id         : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Contacts List       : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Location            : $location <br/>' . 'Description         : $description';
    $taskManager->saveTask($task);
}
Ejemplo n.º 25
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");
}
Ejemplo n.º 26
0
 function applyChange()
 {
     global $adb;
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $modname = 'CobroPago';
         $module = Vtiger_Module::getInstance($modname);
         $block = Vtiger_Block::getInstance('LBL_COBROPAGO_INFORMATION', $module);
         $fld_ref = Vtiger_Field::getInstance('reference', $module);
         $this->ExecuteQuery("UPDATE vtiger_field SET typeofdata='V~O' WHERE fieldid={$fld_ref->id}");
         $this->ExecuteQuery("UPDATE vtiger_field SET sequence=sequence+1 WHERE block={$block->id} AND sequence>1");
         $field = Vtiger_Field::getInstance('cyp_no', $module);
         if (!$field) {
             $field1 = new Vtiger_Field();
             $field1->name = 'cyp_no';
             $field1->label = 'CyP No';
             $field1->column = 'cyp_no';
             $field1->columntype = 'VARCHAR(50)';
             $field1->sequence = 2;
             $field1->uitype = 4;
             $field1->typeofdata = 'V~M';
             $field1->displaytype = 1;
             $field1->presence = 0;
             $block->addField($field1);
         }
         $fld_due = Vtiger_Field::getInstance('duedate', $module);
         $qry = "SELECT sequence FROM vtiger_field WHERE fieldid={$fld_due->id}";
         $res = $adb->query($qry);
         $seq = $adb->query_result($res, 0, 'sequence');
         $this->ExecuteQuery("UPDATE vtiger_field SET sequence=sequence+1 WHERE block={$block->id} AND sequence>{$seq}");
         $field = Vtiger_Field::getInstance('paymentdate', $module);
         if (!$field) {
             $field1 = new Vtiger_Field();
             $field1->name = 'paymentdate';
             $field1->label = 'PaymentDate';
             $field1->column = 'paymentdate';
             $field1->columntype = 'DATE';
             $field1->sequence = $seq + 1;
             $field1->uitype = 5;
             $field1->typeofdata = 'D~O';
             $field1->displaytype = 1;
             $field1->presence = 0;
             $block->addField($field1);
         }
         $res_ui4 = $adb->pquery("SELECT * FROM vtiger_field WHERE tabid=? AND uitype=? AND fieldname<>?", array($module->id, '4', 'cyp_no'));
         if ($adb->num_rows($res_ui4) != 0) {
             $fld_ui4_id = $adb->query_result($res_ui4, 0, 'fieldid');
             $fld_ui4_name = $adb->query_result($res_ui4, 0, 'fieldname');
             $fld_ui4_colname = $adb->query_result($res_ui4, 0, 'columnname');
             $this->ExecuteQuery("UPDATE vtiger_field SET uitype=? WHERE fieldid=?", array('1', $fld_ui4_id));
         }
         $res = $adb->query("SELECT * FROM vtiger_modentity_num WHERE semodule='CobroPago'");
         if ($adb->num_rows($res) == 0) {
             $focus = CRMEntity::getInstance($modname);
             $focus->setModuleSeqNumber('configure', $modname, 'PAY-', '0000001');
             $focus->updateMissingSeqNumber($modname);
         } elseif (!is_null($fld_ui4_colname)) {
             $this->ExecuteQuery("UPDATE vtiger_cobropago SET cyp_no={$fld_ui4_colname}");
             //Workflow, copy CyP No to Reference
             $vtWorkFlow = new VTWorkflowManager($adb);
             $invWorkFlow = $vtWorkFlow->newWorkFlow('CobroPago');
             $invWorkFlow->description = "Number to Reference";
             $invWorkFlow->executionCondition = 3;
             $invWorkFlow->defaultworkflow = 1;
             $vtWorkFlow->save($invWorkFlow);
             $tm = new VTTaskManager($adb);
             $task = $tm->createTask('VTUpdateFieldsTask', $invWorkFlow->id);
             $task->active = true;
             $task->summary = "Number to Reference";
             $task->field_value_mapping = '[{"fieldname":"' . $fld_ui4_name . '","valuetype":"fieldname","value":"cyp_no "}]';
             $tm->saveTask($task);
         }
         $this->ExecuteQuery("UPDATE vtiger_entityname SET fieldname=CONCAT(fieldname,',cyp_no') WHERE tabid={$module->id}");
         $this->ExecuteQuery("UPDATE vtiger_cobropago SET paymentdate=duedate");
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
Ejemplo n.º 27
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
  */
 function vtlib_handler($modulename, $event_type)
 {
     global $adb;
     require_once 'include/events/include.inc';
     include_once 'vtlib/Vtiger/Module.php';
     if ($event_type == 'module.postinstall') {
         // TODO Handle post installation actions
         $modAccounts = Vtiger_Module::getInstance('Accounts');
         $modContacts = Vtiger_Module::getInstance('Contacts');
         $modInvD = Vtiger_Module::getInstance('InventoryDetails');
         $modIss = Vtiger_Module::getInstance('Issuecards');
         if ($modAccounts) {
             $modAccounts->setRelatedList($modIss, 'Issuecards', array('ADD'), 'get_dependents_list');
         }
         if ($modContacts) {
             $modContacts->setRelatedList($modIss, 'Issuecards', array('ADD'), 'get_dependents_list');
         }
         if ($modInvD) {
             $field = Vtiger_Field::getInstance('related_to', $modInvD);
             $field->setRelatedModules(array('Issuecards'));
             $modIss->setRelatedList($modInvD, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         //Add Gendoc to Issuecards
         if (vtlib_isModuleActive("evvtgendoc")) {
             $modIss->addLink('LISTVIEWBASIC', 'Generate Document', "javascript:showgendoctemplates('\$MODULE\$');");
             $modIss->addLink('DETAILVIEWWIDGET', 'Generate Document', "module=evvtgendoc&action=evvtgendocAjax&file=DetailViewWidget&formodule=\$MODULE\$&forrecord=\$RECORD\$", 'modules/evvtgendoc/evvtgendoc.gif');
         }
         $emm = new VTEntityMethodManager($adb);
         // Adding EntityMethod for Updating Products data after updating PurchaseOrder
         $emm->addEntityMethod("Issuecards", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel");
         // Creating Workflow for Updating Inventory Stock on Issuecards
         $vtWorkFlow = new VTWorkflowManager($adb);
         $invWorkFlow = $vtWorkFlow->newWorkFlow("Issuecards");
         $invWorkFlow->test = '[{"fieldname":"pslip_no","operation":"does not contain","value":"`!`"}]';
         $invWorkFlow->description = "UpdateInventoryProducts On Every Save";
         $invWorkFlow->defaultworkflow = 1;
         $vtWorkFlow->save($invWorkFlow);
         $tm = new VTTaskManager($adb);
         $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
         $task->active = true;
         $task->methodName = "UpdateInventory";
         $task->summary = "Update product stock";
         $tm->saveTask($task);
         $this->setModuleSeqNumber('configure', $modulename, 'pslip-', '0000001');
     } else {
         if ($event_type == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($event_type == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($event_type == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($event_type == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($event_type == 'module.postupdate') {
                             // TODO Handle actions after this module is updated.
                             $modInvD = Vtiger_Module::getInstance('InventoryDetails');
                             $modIss = Vtiger_Module::getInstance('Issuecards');
                             //Add subject field to can import and export
                             $block = Vtiger_Block::getInstance('LBL_ISSUECARDS_INFO', $modIss);
                             $field = Vtiger_Field::getInstance('subject', $modIss);
                             if (!$field) {
                                 $field1 = new Vtiger_Field();
                                 $field1->name = 'subject';
                                 $field1->label = 'subject';
                                 $field1->table = 'vtiger_issuecards';
                                 $field1->column = 'subject';
                                 $field1->columntype = 'VARCHAR(100)';
                                 $field1->sequence = 3;
                                 $field1->uitype = 1;
                                 $field1->typeofdata = 'V~O';
                                 $field1->displaytype = 1;
                                 $field1->presence = 0;
                                 $block->addField($field1);
                             }
                             if ($modInvD) {
                                 $field = Vtiger_Field::getInstance('related_to', $modInvD);
                                 $field->setRelatedModules(array('Issuecards'));
                                 $modIss->setRelatedList($modInvD, 'InventoryDetails', array(''), 'get_dependents_list');
                             }
                             //Add Gendoc to Issuecards
                             if (vtlib_isModuleActive("evvtgendoc")) {
                                 $modIss->addLink('LISTVIEWBASIC', 'Generate Document', "javascript:showgendoctemplates('\$MODULE\$');");
                                 $modIss->addLink('DETAILVIEWWIDGET', 'Generate Document', "module=evvtgendoc&action=evvtgendocAjax&file=DetailViewWidget&formodule=\$MODULE\$&forrecord=\$RECORD\$", 'modules/evvtgendoc/evvtgendoc.gif');
                             }
                             $emm = new VTEntityMethodManager($adb);
                             // Adding EntityMethod for Updating Products data after updating Issuecards
                             $emm->addEntityMethod("Issuecards", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel");
                             // Creating Workflow for Updating Inventory Stock on Issuecards
                             $vtWorkFlow = new VTWorkflowManager($adb);
                             $invWorkFlow = $vtWorkFlow->newWorkFlow("Issuecards");
                             $invWorkFlow->test = '[{"fieldname":"pslip_no","operation":"does not contain","value":"`!`"}]';
                             $invWorkFlow->description = "UpdateInventoryProducts On Every Save";
                             $invWorkFlow->defaultworkflow = 1;
                             $vtWorkFlow->save($invWorkFlow);
                             $tm = new VTTaskManager($adb);
                             $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
                             $task->active = true;
                             $task->methodName = "UpdateInventory";
                             $task->summary = "Update product stock";
                             $tm->saveTask($task);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
function populateDefaultWorkflows($adb)
{
    require_once "modules/com_vtiger_workflow/include.inc";
    require_once "modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc";
    require_once "modules/com_vtiger_workflow/VTEntityMethodManager.inc";
    //added column defaultworkflow
    //For default workflows it sets column defaultworkflow=true
    $column_name = "defaultworkflow";
    $adb->pquery("alter table com_vtiger_workflows add column {$column_name} int(1)", array());
    // Creating Workflow for Accounts when Notifyowner is true
    $vtaWorkFlow = new VTWorkflowManager($adb);
    $accWorkFlow = $vtaWorkFlow->newWorkFlow("Accounts");
    $accWorkFlow->test = '[{"fieldname":"notify_owner","operation":"is","value":"true:boolean"}]';
    $accWorkFlow->description = "Send Email to user when Notifyowner is True";
    $accWorkFlow->executionCondition = 2;
    $vtaWorkFlow->save($accWorkFlow);
    $id1 = $accWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $accWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Account Creation";
    $task->content = "An Account has been assigned to you on vtigerCRM<br>Details of account are :<br><br>" . "AccountId:" . '<b>$account_no</b><br>' . "AccountName:" . '<b>$accountname</b><br>' . "Rating:" . '<b>$rating</b><br>' . "Industry:" . '<b>$industry</b><br>' . "AccountType:" . '<b>$accounttype</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "Thank You<br>Admin";
    $task->summary = "An account has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Contacts when Notifyowner is true
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $conWorkFlow = $vtcWorkFlow->newWorkFlow("Contacts");
    $conWorkFlow->summary = "Test accounut";
    $conWorkFlow->executionCondition = 2;
    $conWorkFlow->test = '[{"fieldname":"notify_owner","operation":"is","value":"true:boolean"}]';
    $conWorkFlow->description = "Send Email to user when Notifyowner is True";
    $vtcWorkFlow->save($conWorkFlow);
    $id1 = $conWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $conWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Contact Creation";
    $task->content = "An Contact has been assigned to you on vtigerCRM<br>Details of Contact are :<br><br>" . "Contact Id:" . '<b>$contact_no</b><br>' . "LastName:" . '<b>$lastname</b><br>' . "FirstName:" . '<b>$firstname</b><br>' . "Lead Source:" . '<b>$leadsource</b><br>' . "Department:" . '<b>$department</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "Thank You<br>Admin";
    $task->summary = "An contact has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Contacts when PortalUser is true
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $conpuWorkFlow = $vtcWorkFlow->newWorkFlow("Contacts");
    $conpuWorkFlow->test = '[{"fieldname":"portal","operation":"is","value":"true:boolean"}]';
    $conpuWorkFlow->description = "Send Email to user when Portal User is True";
    $conpuWorkFlow->executionCondition = 2;
    $vtcWorkFlow->save($conpuWorkFlow);
    $id1 = $conpuWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $conpuWorkFlow->id);
    $task->active = true;
    $task->methodName = "NotifyOwner";
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Contact Assignment";
    $task->content = "An Contact has been assigned to you on vtigerCRM<br>Details of Contact are :<br><br>" . "Contact Id:" . '<b>$contact_no</b><br>' . "LastName:" . '<b>$lastname</b><br>' . "FirstName:" . '<b>$firstname</b><br>' . "Lead Source:" . '<b>$leadsource</b><br>' . "Department:" . '<b>$department</b><br>' . "Description:" . '<b>$description</b><br><br><br>' . "And <b>CustomerPortal Login Details</b> is sent to the " . "EmailID :-" . '$email<br>' . "<br>Thank You<br>Admin";
    $task->summary = "An contact has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
    // Creating Workflow for Potentials
    $vtcWorkFlow = new VTWorkflowManager($adb);
    $potentialWorkFlow = $vtcWorkFlow->newWorkFlow("Potentials");
    $potentialWorkFlow->description = "Send Email to user on Potential creation";
    $potentialWorkFlow->executionCondition = 1;
    $vtcWorkFlow->save($potentialWorkFlow);
    $id1 = $potentialWorkFlow->id;
    $tm = new VTTaskManager($adb);
    $task = $tm->createTask('VTEmailTask', $potentialWorkFlow->id);
    $task->active = true;
    $task->recepient = "\$(assigned_user_id : (Users) email1)";
    $task->subject = "Regarding Potential Assignment";
    $task->content = "An Potential has been assigned to you on vtigerCRM<br>Details of Potential are :<br><br>" . "Potential No:" . '<b>$potential_no</b><br>' . "Potential Name:" . '<b>$potentialname</b><br>' . "Amount:" . '<b>$amount</b><br>' . "Expected Close Date:" . '<b>$closingdate</b><br>' . "Type:" . '<b>$opportunity_type</b><br><br><br>' . "Description :" . '$description<br>' . "<br>Thank You<br>Admin";
    $task->summary = "An Potential has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
}
Ejemplo n.º 29
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
  */
 function vtlib_handler($modulename, $event_type)
 {
     if ($event_type == 'module.postinstall') {
         //Handle post installation actions
         require_once "modules/com_vtiger_workflow/include.inc";
         require_once "modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc";
         require_once "modules/com_vtiger_workflow/VTEntityMethodManager.inc";
         global $adb;
         $mod = Vtiger_Module::getInstance('InventoryDetails');
         $this->setModuleSeqNumber('configure', $modulename, '', '000000001');
         $modAccounts = Vtiger_Module::getInstance('Accounts');
         $modContacts = Vtiger_Module::getInstance('Contacts');
         $modVnd = Vtiger_Module::getInstance('Vendors');
         $modInvoice = Vtiger_Module::getInstance('Invoice');
         $modSO = Vtiger_Module::getInstance('SalesOrder');
         $modPO = Vtiger_Module::getInstance('PurchaseOrder');
         $modQt = Vtiger_Module::getInstance('Quotes');
         $modPrd = Vtiger_Module::getInstance('Products');
         $modSrv = Vtiger_Module::getInstance('Services');
         if ($modAccounts) {
             $modAccounts->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modContacts) {
             $modContacts->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modVnd) {
             $modVnd->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modInvoice) {
             $modInvoice->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modSO) {
             $modSO->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modPO) {
             $modPO->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modQt) {
             $modQt->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modPrd) {
             $modPrd->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         if ($modSrv) {
             $modSrv->setRelatedList($mod, 'InventoryDetails', array(''), 'get_dependents_list');
         }
         $wfrs = $adb->query("SELECT workflow_id FROM com_vtiger_workflows WHERE summary='Line Completed'");
         if ($wfrs and $adb->num_rows($wfrs) == 1) {
             echo 'Workfolw already exists!';
         } else {
             $workflowManager = new VTWorkflowManager($adb);
             $taskManager = new VTTaskManager($adb);
             $InvDtWorkFlow = $workflowManager->newWorkFlow("InventoryDetails");
             $InvDtWorkFlow->test = '[{"fieldname":"units_delivered_received","operation":"equal to","value":"quantity","valuetype":"fieldname","joincondition":"and","groupid":"0"}]';
             $InvDtWorkFlow->description = "Line Completed";
             $InvDtWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
             $InvDtWorkFlow->defaultworkflow = 1;
             $workflowManager->save($InvDtWorkFlow);
             $task = $taskManager->createTask('VTUpdateFieldsTask', $InvDtWorkFlow->id);
             $task->active = true;
             $task->summary = 'Mark as Line Completed';
             $task->field_value_mapping = '[{"fieldname":"line_completed","valuetype":"rawtext","value":"true:boolean"}]';
             $taskManager->saveTask($task);
         }
     } else {
         if ($event_type == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
         } else {
             if ($event_type == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($event_type == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                 } else {
                     if ($event_type == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($event_type == 'module.postupdate') {
                             // TODO Handle actions after this module is updated.
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 30
0
	public static function getCleanInstance($workflowModel, $taskName) {
		$db = PearDatabase::getInstance();
		$tm = new VTTaskManager($db);
		$task = $tm->createTask($taskName, $workflowModel->getId());
		return self::getInstanceFromTaskObject($task, $workflowModel, $tm);
	}