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 
}
 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();
 }
 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();
 }
Exemple #4
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");
}
Exemple #5
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);
}
$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;");
/* To store the field to module relationship for uitype 10 */
Exemple #7
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);
	}
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));
}
/* Delete broken worflows and tasks */
$brokenWorkflowsResult = $adb->pquery("SELECT workflow_id FROM com_vtiger_workflows WHERE (module_name=? AND summary IN(?,?)) OR (module_name=? AND summary IN(?,?))", array('Calendar', 'Автоматические обработчики для задач Календаря при выбранной опции Отправить уведомление', 'Workflow for Calendar Todos when Send Notification is True', 'Events', 'Автоматические обработчики для событий при выбранной опции Отправить уведомление', 'Workflow for Events when Send Notification is True'));
while ($brokenWorkflowRow = $adb->fetchByAssoc($brokenWorkflowsResult)) {
    $adb->pquery('DELETE FROM com_vtiger_workflows WHERE workflow_id=?', array($brokenWorkflowRow['workflow_id']));
    $adb->pquery('DELETE FROM com_vtiger_workflowtasks WHERE workflow_id=?', array($brokenWorkflowRow['workflow_id']));
}
/* Recreate normal */
$workflowManager = new VTWorkflowManager($adb);
$taskManager = new VTTaskManager($adb);
$eventsWorkflow = $workflowManager->newWorkFlow("Events");
$eventsWorkflow->test = '[{"fieldname":"sendnotification","operation":"is","value":"true:boolean"}]';
$eventsWorkflow->description = "Автоматические обработчики для событий при выбранной опции Отправить уведомление";
$eventsWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
$eventsWorkflow->defaultworkflow = 1;
$workflowManager->save($eventsWorkflow);
$task = $taskManager->createTask('VTEmailTask', $eventsWorkflow->id);
$task->active = true;
$task->summary = 'Отправляет письмо с уведомлением приглашенным пользователям';
$task->recepient = "\$(assigned_user_id : (Users) email1)";
$task->subject = "Событие :  \$subject";
$task->content = '$(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) ,<br/>' . '<b>Детали события:</b><br/>' . 'Название события       : $subject<br/>' . 'Дата и Время Начала    : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Дата и Время Окончания : $due_date  $time_end ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Статус                 : $eventstatus <br/>' . 'Приоритет              : $taskpriority <br/>' . 'Относится к            : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id            : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Контакты               : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Место проведения       : $location <br/>' . 'Описание               : $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 = "Автоматические обработчики для задач Календаря при выбранной опции Отправить уведомление";
$calendarWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
$calendarWorkflow->defaultworkflow = 1;
$workflowManager->save($calendarWorkflow);
$task = $taskManager->createTask('VTEmailTask', $calendarWorkflow->id);
$task->active = true;
Exemple #10
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);
 }
Exemple #11
0
$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"}]';
$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";
 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();
 }
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);
}
 /**
  * Function adds default system workflows
  * @param <PearDatabase> $adb
  */
 static function populateDefaultWorkflows($adb)
 {
     vimport("~~modules/com_vtiger_workflow/include.inc");
     vimport("~~modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc");
     vimport("~~modules/com_vtiger_workflow/VTEntityMethodManager.inc");
     vimport("~~modules/com_vtiger_workflow/VTTaskManager.inc");
     // register the workflow tasks
     $taskTypes = array();
     $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 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"}]';
     // SalesPlatform.ru begin
     $accWorkFlow->description = "Отправить Email пользователю, если указано Уведомлять ответственного";
     //$accWorkFlow->description = "Send Email to user when Notifyowner is True";
     // SalesPlatform.ru end
     $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)";
     // SalesPlatform.ru begin
     $task->subject = "Уведомление о назначении Контрагента";
     $task->content = "В системе vtigerCRM Вам был назначен контрагент<br>Информация о контрагенте :<br><br>" . "Контрагент №:" . '<b>$account_no</b><br>' . "Контрагент:" . '<b>$accountname</b><br>' . "Рейтинг:" . '<b>$rating</b><br>' . "Отрасль:" . '<b>$industry</b><br>' . "Тип:" . '<b>$accounttype</b><br>' . "Описание:" . '<b>$description</b><br><br><br>' . "Спасибо,<br>Admin";
     $task->summary = "Создан Контрагент ";
     //$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 ";
     // SalesPlatform.ru end
     $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");
     // SalesPlatform.ru begin
     $conWorkFlow->summary = "Создан Контакт ";
     //$conWorkFlow->summary="A contact has been created ";
     // SalesPlatform.ru end
     $conWorkFlow->executionCondition = 2;
     $conWorkFlow->test = '[{"fieldname":"notify_owner","operation":"is","value":"true:boolean"}]';
     // SalesPlatform.ru begin
     $conWorkFlow->description = "Отправить Email пользователю, если указано Уведомлять ответственного";
     //$conWorkFlow->description = "Send Email to user when Notifyowner is True";
     // SalesPlatform.ru end
     $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)";
     // SalesPlatform.ru begin
     $task->subject = "Уведомление о назначении Контакта";
     $task->content = "В системе vtigerCRM Вам был назначен контакт<br>Информация о контакте :<br><br>" . "Контакт №:" . '<b>$contact_no</b><br>' . "Фамилия:" . '<b>$lastname</b><br>' . "Имя:" . '<b>$firstname</b><br>' . "Источник:" . '<b>$leadsource</b><br>' . "Отдел:" . '<b>$department</b><br>' . "Описание:" . '<b>$description</b><br><br><br>' . "Спасибо,<br>Admin";
     $task->summary = "Создан Контакт ";
     //$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 ";
     // SalesPlatform.ru end
     $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"}]';
     // SalesPlatform.ru begin
     $conpuWorkFlow->description = "Отправить Email пользователю, если контакт стал пользователем портала";
     //$conpuWorkFlow->description = "Send Email to user when Portal User is True";
     // SalesPlatform.ru end
     $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)";
     // SalesPlatform.ru begin
     $task->subject = "Уведомление о назначении Контакта";
     $task->content = "В системе vtigerCRM Вам был назначен контакт<br>Информация о контакте :<br><br>" . "Контакт №:" . '<b>$contact_no</b><br>' . "Фамилия:" . '<b>$lastname</b><br>' . "Имя:" . '<b>$firstname</b><br>' . "Источник:" . '<b>$leadsource</b><br>' . "Отдел:" . '<b>$department</b><br>' . "Описание:" . '<b>$description</b><br><br><br>' . "А также <b>детали логина на CustomerPortal</b> были отправлены " . "Email :-" . '$email<br>' . "<br>Спасибо,<br>Admin";
     $task->summary = "Создан Контакт ";
     //$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 ";
     // SalesPlatform.ru end
     $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");
     // SalesPlatform.ru begin
     $potentialWorkFlow->description = "Отправить Email пользователю при создании Сделки";
     //$potentialWorkFlow->description = "Send Email to users on Potential creation";
     // SalesPlatform.ru end
     $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)";
     // SalesPlatform.ru begin
     $task->subject = "Уведомление о назначении Сделки";
     $task->content = "В системе vtigerCRM Вам была назначена сделка<br>Информация о сделке :<br><br>" . "Сделка №:" . '<b>$potential_no</b><br>' . "Название Сделки:" . '<b>$potentialname</b><br>' . "Сумма (руб):" . '<b>$amount</b><br>' . "Ожидаемая Дата Закрытия:" . '<b>$closingdate</b><br>' . "Тип:" . '<b>$opportunity_type</b><br><br><br>' . "Описание:" . '$description<br>' . "<br>Спасибо,<br>Admin";
     $task->summary = "Создана сделка ";
     //$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 ";
     // SalesPlatform.ru end
     $tm->saveTask($task);
     $workflowManager = new VTWorkflowManager($adb);
     $taskManager = new VTTaskManager($adb);
     // Contact workflow on creation/modification
     $contactWorkFlow = $workflowManager->newWorkFlow("Contacts");
     $contactWorkFlow->test = '';
     //SalesPlatform.ru begin
     $contactWorkFlow->description = "Автоматические обработчики для создания и модификации контактов";
     //$contactWorkFlow->description = "Workflow for Contact Creation or Modification";
     //SalesPlatform.ru end
     $contactWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
     $contactWorkFlow->defaultworkflow = 1;
     $workflowManager->save($contactWorkFlow);
     $task = $taskManager->createTask('VTEntityMethodTask', $contactWorkFlow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Сообщение с регистрационными данными клиентского портала';
     //$task->summary = 'Email Customer Portal Login Details';
     //SalesPlatform.ru end
     $task->methodName = "SendPortalLoginDetails";
     $taskManager->saveTask($task);
     $task->active = true;
     $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));
     // Trouble Tickets workflow on creation from Customer Portal
     $helpDeskWorkflow = $workflowManager->newWorkFlow("HelpDesk");
     $helpDeskWorkflow->test = '[{"fieldname":"from_portal","operation":"is","value":"true:boolean"}]';
     //SalesPlatform.ru begin
     $helpDeskWorkflow->description = "Автоматический обработчик для создаваемой заявки из портала";
     //$helpDeskWorkflow->description = "Workflow for Ticket Created from Portal";
     //SalesPlatform.ru end
     $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_FIRST_SAVE;
     $helpDeskWorkflow->defaultworkflow = 1;
     $workflowManager->save($helpDeskWorkflow);
     $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Уведомляет ответственного за заявку и связанный контакт при создании заявки из портала';
     //$task->summary = 'Notify Record Owner and the Related Contact when Ticket is created from Portal';
     //SalesPlatform.ru end
     $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"}]';
     //SalesPlatform.ru begin
     $helpDeskWorkflow->description = "Автоматические обработчики для обновляемых заявок из портала";
     //$helpDeskWorkflow->description = "Workflow for Ticket Updated from Portal";
     //SalesPlatform.ru end
     $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_MODIFY;
     $helpDeskWorkflow->defaultworkflow = 1;
     $workflowManager->save($helpDeskWorkflow);
     $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Уведомляет ответственного за заявку при добавлении комментариев к заявке через Клиентский портал';
     //$task->summary = 'Notify Record Owner when Comment is added to a Ticket from Customer Portal';
     //SalesPlatform.ru end
     $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"}]';
     //SalesPlatform.ru begin
     $helpDeskWorkflow->description = "Обработчик для изменяемых заявок, не из портала";
     //$helpDeskWorkflow->description = "Workflow for Ticket Change, not from the Portal";
     //SalesPlatform.ru end
     $helpDeskWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
     $helpDeskWorkflow->defaultworkflow = 1;
     $workflowManager->save($helpDeskWorkflow);
     $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Уведомляет ответственного за заявку, созданную не из портала, при ее изменении';
     //$task->summary = 'Notify Record Owner on Ticket Change, which is not done from Portal';
     //SalesPlatform.ru end
     $task->methodName = "NotifyOwnerOnTicketChange";
     $taskManager->saveTask($task);
     $task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Уведомляет связанного клиента при изменении заявки, которая создана не из портала';
     //$task->summary = 'Notify Related Customer on Ticket Change, which is not done from Portal';
     //SalesPlatform.ru end
     $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"}]';
     //SalesPlatform.ru begin
     $eventsWorkflow->description = "Автоматические обработчики для событий при выбранной опции Отправить уведомление";
     //$eventsWorkflow->description = "Workflow for Events when Send Notification is True";
     //SalesPlatform.ru end
     $eventsWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
     $eventsWorkflow->defaultworkflow = 1;
     $workflowManager->save($eventsWorkflow);
     $task = $taskManager->createTask('VTEmailTask', $eventsWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Отправляет письмо с уведомлением приглашенным пользователям';
     //$task->summary = 'Send Notification Email to Record Owner';
     //SalesPlatform.ru end
     $task->recepient = "\$(assigned_user_id : (Users) email1)";
     //SalesPlatform.ru begin
     $task->subject = "Событие :  \$subject";
     $task->content = '$(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) ,<br/>' . '<b>Детали события:</b><br/>' . 'Название события       : $subject<br/>' . 'Дата и Время Начала    : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Дата и Время Окончания : $due_date  $time_end ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Статус                 : $eventstatus <br/>' . 'Приоритет              : $taskpriority <br/>' . 'Относится к            : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id            : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Контакты               : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Место проведения       : $location <br/>' . 'Описание               : $description';
     //vtiger commented code
     /*
     		$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';
     */
     //SalesPlatform.ru end
     $taskManager->saveTask($task);
     // Calendar workflow when Send Notification is checked
     $calendarWorkflow = $workflowManager->newWorkFlow("Calendar");
     $calendarWorkflow->test = '[{"fieldname":"sendnotification","operation":"is","value":"true:boolean"}]';
     //SalesPlatform.ru begin
     $calendarWorkflow->description = "Автоматические обработчики для задач Календаря при выбранной опции Отправить уведомление";
     //$calendarWorkflow->description = "Workflow for Calendar Todos when Send Notification is True";
     //SalesPlatform.ru end
     $calendarWorkflow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE;
     $calendarWorkflow->defaultworkflow = 1;
     $workflowManager->save($calendarWorkflow);
     $task = $taskManager->createTask('VTEmailTask', $calendarWorkflow->id);
     $task->active = true;
     //SalesPlatform.ru begin
     $task->summary = 'Отправляет письмо с уведомлением ответственному за задачу';
     //$task->summary = 'Send Notification Email to Record Owner';
     //SalesPlatform.ru end
     $task->recepient = "\$(assigned_user_id : (Users) email1)";
     //SalesPlatform.ru begin
     $task->subject = "Задача :  \$subject";
     $task->content = '$(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) ,<br/>' . '<b>Детали задачи:</b><br/>' . 'Название задачи        : $subject<br/>' . 'Дата и Время Начала    : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Дата и Время Окончания : $due_date ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Статус                 : $taskstatus <br/>' . 'Приоритет              : $taskpriority <br/>' . 'Относится к            : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Контакты               : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Место проведения       : $location <br/>' . 'Описание               : $description';
     //vtiger commented code
     /*
     		$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';
     */
     //SalesPlatform.ru end
     $taskManager->saveTask($task);
 }
Exemple #15
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");
}
Exemple #16
0
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';
$task->methodName = "NotifyOnPortalTicketCreation";
$taskManager->saveTask($task);
putMsg('Workflow "' . $helpDeskWorkflow->description . '" created!');
// 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';
 /**
  * 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);
                         }
                     }
                 }
             }
         }
     }
 }
// Ends
require_once 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';
$emm = new VTEntityMethodManager($adb);
$emm->addEntityMethod("ModComments", "CustomerCommentFromPortal", "modules/ModComments/ModCommentsHandler.php", "CustomerCommentFromPortal");
$emm->addEntityMethod("ModComments", "TicketOwnerComments", "modules/ModComments/ModCommentsHandler.php", "TicketOwnerComments");
require_once 'modules/com_vtiger_workflow/VTWorkflowManager.inc';
require_once 'modules/com_vtiger_workflow/VTTaskManager.inc';
$workflowManager = new VTWorkflowManager($adb);
$taskManager = new VTTaskManager($adb);
$commentsWorkflow = $workflowManager->newWorkFlow("ModComments");
$commentsWorkflow->test = '[{"fieldname":"related_to : (HelpDesk) ticket_title","operation":"is not empty","value":""}]';
$commentsWorkflow->description = "Workflow for comments on Tickets";
$commentsWorkflow->executionCondition = VTWorkflowManager::$ON_FIRST_SAVE;
$commentsWorkflow->defaultworkflow = 1;
$workflowManager->save($commentsWorkflow);
$task = $taskManager->createTask('VTEntityMethodTask', $commentsWorkflow->id);
$task->active = true;
$task->summary = 'Customer commented from Portal';
$task->methodName = "CustomerCommentFromPortal";
$taskManager->saveTask($task);
$task1 = $taskManager->createTask('VTEntityMethodTask', $commentsWorkflow->id);
$task1->active = true;
$task1->summary = 'Notify Customer when commenting on a Ticket';
$task1->methodName = "TicketOwnerComments";
$taskManager->saveTask($task1);
// Ends
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column linktype VARCHAR(50)', array());
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column linklabel VARCHAR(50)', array());
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column handler_class VARCHAR(50)', array());
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column handler VARCHAR(50)', array());
//--
 /**
  * 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.
                         }
                     }
                 }
             }
         }
     }
 }
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);
    // 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";
    // JFV - add Japanese localization to email notification
    $task->subject = "顧客企業が作成されました / " . $task->subject;
    // JFV END
    $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";
    // JFV - add Japanese localization to email notification
    $task->content = "vtigerCRM にて顧客企業があなたに割り当てられました。<br>顧客企業の詳細は次のとおりです:<br><br>" . "顧客企業 No:" . '<b>$account_no</b><br>' . "顧客企業名:" . '<b>$accountname</b><br>' . "各付け:" . '<b>$rating</b><br>' . "業界:" . '<b>$industry</b><br>' . "タイプ:" . '<b>$accounttype</b><br>' . "詳細:" . '<b>$description</b><br><br><br>' . "宜しくお願いします<br>管理者" . "<br><br>---------------<br>" . $task->content;
    // JFV END
    $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";
    $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";
    // JFV - add Japanese localization to email notification
    $task->subject = "顧客担当者が作成されました / " . $task->subject;
    // JFV END
    $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";
    // JFV - add Japanese localization to email notification
    $task->content = "vtigerCRM にて顧客担当者があなたに割り当てられました。<br>詳細は次のとおりです:<br><br>" . "顧客担当者 ID:" . '<b>$contact_no</b><br>' . "姓:" . '<b>$lastname</b><br>' . "名:" . '<b>$firstname</b><br>' . "紹介元:" . '<b>$leadsource</b><br>' . "部門:" . '<b>$department</b><br>' . "詳細:" . '<b>$description</b><br><br><br>' . "宜しくお願いします<br>管理者" . "<br><br>---------------<br>" . $task->content;
    // JFV END
    $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";
    // JFV - add Japanese localization to email notification
    $task->subject = "顧客担当者が割り当てられました / " . $task->subject;
    // JFV END
    $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";
    // JFV - add Japanese localization to email notification
    $task->content = "vtigerCRM にて顧客担当者があなたに割り当てられました。<br>詳細は次のとおりです<br><br>" . "顧客担当者 ID:" . '<b>$contact_no</b><br>' . "姓:" . '<b>$lastname</b><br>' . "名:" . '<b>$firstname</b><br>' . "紹介元:" . '<b>$leadsource</b><br>' . "部門:" . '<b>$department</b><br>' . "詳細:" . '<b>$description</b><br><br><br>' . "また、<b>顧客ポータルのログインの詳細は</b>、次に送信しました:" . "電子メール :-" . '$email<br>' . "<br>宜しくお願いします<br>管理者" . "<br><br>---------------<br>" . $task->content;
    // JFV END
    $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;
    $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";
    // JFV - add Japanese localization to email notification
    $task->subject = "案件が割り当てられました / " . $task->subject;
    // JFV END
    $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";
    // JFV - add Japanese localization to email notification
    $task->content = "vtigerCRM にて案件があなたに割り当てられました。<br>詳細は次のとおりです:<br><br>" . "案件 No:" . '<b>$potential_no</b><br>' . "案件名:" . '<b>$potentialname</b><br>' . "金額:" . '<b>$amount</b><br>' . "完了予定日:" . '<b>$closingdate</b><br>' . "タイプ:" . '<b>$opportunity_type</b><br><br><br>' . "詳細 :" . '$description<br>' . "<br>宜しくお願いします<br>管理者" . "<br><br>---------------<br>" . $task->content;
    // JFV END
    $task->summary = "An Potential has been created ";
    $tm->saveTask($task);
    $adb->pquery("update com_vtiger_workflows set defaultworkflow=? where workflow_id=?", array(1, $id1));
}