更新到 5.2 正式版后第一次 SVN 提交。
yuchenghu@hawebs.net git-svn-id: https://svn.code.sf.net/p/hawebs/svn@584 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class VTConditionalExpression{
|
||||
public function __construct($expression){
|
||||
$parser = new VTConditionalParser($expression);
|
||||
$this->expTree = $parser->parse();
|
||||
}
|
||||
|
||||
public function evaluate($data){
|
||||
$this->env=$data;
|
||||
return $this->evalGate($this->expTree);
|
||||
}
|
||||
|
||||
private function evalGate($tree){
|
||||
if(in_array($tree[0], array("and", "or"))){
|
||||
switch($tree[0]){
|
||||
case "and":
|
||||
return $this->evalGate($tree[1]) and $this->evalGate($tree[2]);
|
||||
case "or":
|
||||
return $this->evalGate($tree[1]) or $this->evalGate($tree[2]);
|
||||
}
|
||||
}else{
|
||||
return $this->evalCondition($tree);
|
||||
}
|
||||
}
|
||||
|
||||
private function evalCondition($tree){
|
||||
switch($tree[0]){
|
||||
case "=":
|
||||
return (int)$this->getVal($tree[1]) == (int)$this->getVal($tree[2]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getVal($node){
|
||||
list($valueType, $value) = $node;
|
||||
switch($valueType){
|
||||
case "sym":
|
||||
return $this->env[$value];
|
||||
case "num":
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VTParseFailed extends Exception { }
|
||||
|
||||
/**
|
||||
* This is a simple parser for conditional expressions used to trigger workflow actions.
|
||||
*
|
||||
*/
|
||||
class VTConditionalParser{
|
||||
|
||||
|
||||
public function __construct($expr){
|
||||
$this->tokens = $this->getTokens($expr);
|
||||
$this->pos = 0;
|
||||
}
|
||||
|
||||
private function getTokens($expression){
|
||||
preg_match_all('/and|or|\\d+|=|\\w+|\\(|\\)/',$expression, $matches, PREG_SET_ORDER);
|
||||
$tokens=array();
|
||||
foreach($matches as $arr){
|
||||
$tokenVal = $arr[0];
|
||||
if(in_array($tokenVal, array("and", "or", "=", "(", ")"))){
|
||||
$tokenType = "op";
|
||||
}else if(is_numeric($tokenVal)){
|
||||
$tokenType = "num";
|
||||
}else{
|
||||
$tokenType = "sym";
|
||||
}
|
||||
$tokens[]=array($tokenType, $tokenVal);
|
||||
}
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
|
||||
public function parse(){
|
||||
$op = array(
|
||||
"and"=>array("op", "and"),
|
||||
"or"=>array("op", "or"),
|
||||
"="=>array("op", "="),
|
||||
"("=>array("op", "("),
|
||||
")"=>array("op", ")"));
|
||||
|
||||
if($this->peek()==$op['(']){
|
||||
$this->nextToken();
|
||||
$left = $this->parse();
|
||||
if($this->nextToken()!= $op[')']){
|
||||
throw new VTParseFailed();
|
||||
}
|
||||
}else{
|
||||
$left = $this->cond();
|
||||
}
|
||||
if(sizeof($this->tokens)>$this->pos and in_array($this->peek(), array($op["and"], $op["or"]))){
|
||||
$nt = $this->nextToken();
|
||||
return array($nt[1], $left, $this->parse());
|
||||
}else{
|
||||
return $left;
|
||||
}
|
||||
}
|
||||
|
||||
private function cond(){
|
||||
$left = $this->nextToken();
|
||||
$operator = $this->nextToken();
|
||||
$right = $this->nextToken();
|
||||
return array($operator[1], $left, $right);
|
||||
}
|
||||
|
||||
private function peek(){
|
||||
return $this->tokens[$this->pos];
|
||||
}
|
||||
|
||||
private function nextToken(){
|
||||
$this->pos+=1;
|
||||
return $this->tokens[$this->pos - 1];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/*+*******************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
require_once 'modules/com_vtiger_workflow/VTSimpleTemplate.inc';
|
||||
|
||||
/**
|
||||
* Description of VTEmailRecipientsTemplate
|
||||
*
|
||||
* @author MAK
|
||||
*/
|
||||
class VTEmailRecipientsTemplate extends VTSimpleTemplate {
|
||||
|
||||
public function __construct($templateString) {
|
||||
parent::__construct($templateString);
|
||||
}
|
||||
|
||||
protected function useValue($data, $fieldname) {
|
||||
return !empty($data[$fieldname]) && $data['emailoptout'] == 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
class VTWorkflowEntity{
|
||||
function __construct($user, $id){
|
||||
$this->moduleName = null;
|
||||
$this->id = $id;
|
||||
$this->user = $user;
|
||||
$data = vtws_retrieve($id, $user);
|
||||
foreach($data as $key => $value){
|
||||
if(is_string($value)){
|
||||
$data[$key] = html_entity_decode($value, ENT_QUOTES, 'utf-8');
|
||||
}
|
||||
}
|
||||
$this->data = $data;
|
||||
}
|
||||
/**
|
||||
* Get the data from the entity object as an array.
|
||||
*
|
||||
* @return An array representation of the module data.
|
||||
*/
|
||||
function getData(){
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity id.
|
||||
*
|
||||
* @return The entity id.
|
||||
*/
|
||||
function getId(){
|
||||
return $this->data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the module represented by the entity data object.
|
||||
*
|
||||
* @return The module name.
|
||||
*/
|
||||
function getModuleName(){
|
||||
if($this->moduleName==null){
|
||||
global $adb;
|
||||
$wsId = $this->data['id'];
|
||||
$parts = explode('x', $wsId);
|
||||
$result = $adb->pquery('select name from vtiger_ws_entity where id=?',
|
||||
array($parts[0]));
|
||||
$rowData = $adb->raw_query_result_rowdata($result, 0);
|
||||
$this->moduleName = $rowData['name'];
|
||||
}
|
||||
return $this->moduleName;
|
||||
}
|
||||
|
||||
function get($fieldName){
|
||||
return $this->data[$fieldName];
|
||||
}
|
||||
|
||||
function set($fieldName, $value){
|
||||
|
||||
$this->data[$fieldName] = $value;
|
||||
}
|
||||
|
||||
function save(){
|
||||
vtws_update($this->data,$this->user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class VTEntityCache{
|
||||
function __construct($user){
|
||||
$this->user = $user;
|
||||
$this->cache = array();
|
||||
}
|
||||
|
||||
function forId($id){
|
||||
if($this->cache[$id]==null){
|
||||
$data = new VTWorkflowEntity($this->user, $id);
|
||||
$this->cache[$id] = $data;
|
||||
}
|
||||
return $this->cache[$id];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/*+*******************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
******************************************************************************/
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
class VTEntityMethodManager{
|
||||
|
||||
function __construct($adb){
|
||||
$this->adb = $adb;
|
||||
}
|
||||
|
||||
|
||||
function addEntityMethod($moduleName, $methodName, $functionPath, $functionName){
|
||||
$adb = $this->adb;
|
||||
$id = $adb->getUniqueId("com_vtiger_workflowtasks_entitymethod");
|
||||
$adb->pquery("insert into com_vtiger_workflowtasks_entitymethod (workflowtasks_entitymethod_id, module_name, function_path, function_name, method_name) values (?,?,?,?,?)", array($id, $moduleName, $functionPath, $functionName, $methodName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function executeMethod($entityData, $methodName){
|
||||
$adb = $this->adb;
|
||||
$moduleName = $entityData->getModuleName();
|
||||
$result = $adb->pquery("select function_path, function_name from com_vtiger_workflowtasks_entitymethod where module_name=? and method_name=?", array($moduleName, $methodName));
|
||||
if($adb->num_rows($result)!=0){
|
||||
$data = $adb->raw_query_result_rowdata($result, 0);
|
||||
$functionPath = $data['function_path'];
|
||||
$functionName = $data['function_name'];
|
||||
require_once($functionPath);
|
||||
$functionName($entityData);
|
||||
}
|
||||
}
|
||||
|
||||
function methodsForModule($moduleName){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery("select method_name from com_vtiger_workflowtasks_entitymethod where module_name=?", array($moduleName));
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$methodNames = array();
|
||||
foreach($it as $row){
|
||||
$methodNames[] = $row->method_name;
|
||||
}
|
||||
return $methodNames;
|
||||
}
|
||||
/*
|
||||
private function methodExists($object, $methodName){
|
||||
$className = get_class($object);
|
||||
$class = new ReflectionClass($className);
|
||||
$methods = $class->getMethods();
|
||||
foreach($methods as $method){
|
||||
if($method->getName()==$methodName){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
?>
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/events/SqlResultIterator.inc');
|
||||
require_once('VTWorkflowManager.inc');
|
||||
require_once('VTTaskManager.inc');
|
||||
require_once('VTTaskQueue.inc');
|
||||
require_once('VTEntityCache.inc');
|
||||
|
||||
require_once 'include/Webservices/Utils.php';
|
||||
require_once("modules/Users/Users.php");
|
||||
require_once("include/Webservices/VtigerCRMObject.php");
|
||||
require_once("include/Webservices/VtigerCRMObjectMeta.php");
|
||||
require_once("include/Webservices/DataTransform.php");
|
||||
require_once("include/Webservices/WebServiceError.php");
|
||||
require_once 'include/utils/utils.php';
|
||||
require_once 'include/Webservices/ModuleTypes.php';
|
||||
require_once('include/Webservices/Retrieve.php');
|
||||
require_once('include/Webservices/Update.php');
|
||||
require_once 'include/Webservices/WebserviceField.php';
|
||||
require_once 'include/Webservices/EntityMeta.php';
|
||||
require_once 'include/Webservices/VtigerWebserviceObject.php';
|
||||
require_once('VTWorkflowUtils.php');
|
||||
|
||||
/*
|
||||
* VTEventHandler
|
||||
*/
|
||||
class VTWorkflowEventHandler extends VTEventHandler{
|
||||
/**
|
||||
* Push tasks to the task queue if the conditions are true
|
||||
* @param $entityData A VTEntityData object representing the entity.
|
||||
*/
|
||||
function handleEvent($eventName, $entityData){
|
||||
$util = new VTWorkflowUtils();
|
||||
$user = $util->adminUser();
|
||||
global $adb;
|
||||
$isNew = $entityData->isNew();
|
||||
$entityCache = new VTEntityCache($user);
|
||||
$wsModuleName = $util->toWSModuleName($entityData);
|
||||
$wsId = vtws_getWebserviceEntityId($wsModuleName,
|
||||
$entityData->getId());
|
||||
$entityData = $entityCache->forId($wsId);
|
||||
$data = $entityData->getData();
|
||||
$wfs = new VTWorkflowManager($adb);
|
||||
$workflows = $wfs->getWorkflowsForModule($entityData->getModuleName());
|
||||
$tm = new VTTaskManager($adb);
|
||||
$taskQueue = new VTTaskQueue($adb);
|
||||
|
||||
foreach($workflows as $workflow){
|
||||
switch($workflow->executionCondition){
|
||||
case VTWorkflowManager::$ON_FIRST_SAVE:{
|
||||
if($isNew){
|
||||
$doEvaluate = true;
|
||||
}else{
|
||||
$doEvaluate = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VTWorkflowManager::$ONCE:{
|
||||
$entity_id = vtws_getIdComponents($entityData->getId());
|
||||
$entity_id = $entity_id[1];
|
||||
$result = $adb->pquery("SELECT * FROM com_vtiger_workflow_activatedonce
|
||||
WHERE entity_id=? and workflow_id=?", array($entity_id, $workflow->id));
|
||||
|
||||
//Changes
|
||||
$result2=$adb->pquery("SELECT * FROM com_vtiger_workflowtasks
|
||||
INNER JOIN com_vtiger_workflowtask_queue
|
||||
ON com_vtiger_workflowtasks.task_id= com_vtiger_workflowtask_queue.task_id
|
||||
WHERE workflow_id=? AND entity_id=?",
|
||||
array($workflow->id,$entity_id));
|
||||
|
||||
if($adb->num_rows($result)===0 && $adb->num_rows($result2)===0){
|
||||
$doEvaluate = true;
|
||||
}else{
|
||||
$doEvaluate = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VTWorkflowManager::$ON_EVERY_SAVE:{
|
||||
$doEvaluate = true;
|
||||
break;
|
||||
}
|
||||
case VTWorkflowManager::$ON_MODIFY:{
|
||||
$doEvaluate = !($isNew);
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
throw new Exception("Should never come here! Execution Condition:".$workflow->executionCondition);
|
||||
}
|
||||
|
||||
}
|
||||
if($doEvaluate && $workflow->evaluate($entityCache, $entityData->getId())){
|
||||
if(VTWorkflowManager::$ONCE == $workflow->executionCondition) {
|
||||
$entity_id = vtws_getIdComponents($entityData->getId());
|
||||
$entity_id = $entity_id[1];
|
||||
$adb->pquery("INSERT INTO com_vtiger_workflow_activatedonce (entity_id, workflow_id)
|
||||
VALUES (?,?)", array($entity_id, $workflow->id));
|
||||
}
|
||||
|
||||
$tasks = $tm->getTasksForWorkflow($workflow->id);
|
||||
foreach($tasks as $task){
|
||||
if($task->active) {
|
||||
$trigger = $task->trigger;
|
||||
if($trigger != null){
|
||||
$delay = strtotime($data[$trigger['field']])+$trigger['days']*86400;
|
||||
}else{
|
||||
$delay = 0;
|
||||
}
|
||||
if($task->executeImmediately==true){
|
||||
$task->doTask($entityData);
|
||||
}else{
|
||||
$taskQueue->queueTask($task->id,$entityData->getId(), $delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$util->revertUser();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,112 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("include/Zend/Json.php");
|
||||
|
||||
class VTJsonCondition{
|
||||
function __construct(){
|
||||
}
|
||||
|
||||
function evaluate($condition, $entityCache, $id){
|
||||
$expr = Zend_Json::decode($condition);
|
||||
$result=TRUE;
|
||||
$data = $entityCache->forId($id)->getData();
|
||||
|
||||
foreach($expr as $cond){
|
||||
preg_match('/(\w+) : \((\w+)\) (\w+)/', $cond['fieldname'], $matches);
|
||||
if(count($matches)==0){
|
||||
$result = $this->checkCondition($data, $cond);
|
||||
}else{
|
||||
list($full, $referenceField, $referenceModule, $fieldname) = $matches;
|
||||
$referenceFieldId = $data[$referenceField];
|
||||
if($referenceFieldId != 0){
|
||||
$entity = $entityCache->forId($data[$referenceField]);
|
||||
if($entity->getModuleName()==$referenceModule){
|
||||
$entityData = $entity->getData();
|
||||
$cond['fieldname'] = $fieldname;
|
||||
$result = $this->checkCondition($entityData, $cond);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if($result==false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function startsWith($str, $subStr){
|
||||
$sl = strlen($str);
|
||||
$ssl = strlen($subStr);
|
||||
if($sl>=$ssl){
|
||||
return substr_compare($str,$subStr,0, $ssl)==0;
|
||||
}else{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function endsWith($str, $subStr){
|
||||
$sl = strlen($str);
|
||||
$ssl = strlen($subStr);
|
||||
if($sl>=$ssl){
|
||||
return substr_compare($str,$subStr,$sl-$ssl, $ssl)==0;
|
||||
}else{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkCondition($data, $cond){
|
||||
$condition = $cond['operation'];
|
||||
$fieldValue=$data[$cond['fieldname']];
|
||||
$value = html_entity_decode($cond['value']);
|
||||
switch($condition){
|
||||
case "equal to":
|
||||
return $fieldValue == $value;
|
||||
case "less than":
|
||||
return $fieldValue < $value;
|
||||
case "greater than":
|
||||
return $fieldValue > $value;
|
||||
case "does not equal":
|
||||
return $fieldValue != $value;
|
||||
case "less than or equal to":
|
||||
return $fieldValue <= $value;
|
||||
case "greater than or equal to":
|
||||
return $fieldValue >= $value;
|
||||
case "is":
|
||||
if(preg_match('/([^:]+):boolean$/', $value, $match)){
|
||||
$value = $match[1];
|
||||
if($value=='true'){
|
||||
return $fieldValue==='on' || $fieldValue===1 || $fieldValue==='1';
|
||||
}else{
|
||||
return $fieldValue==='off' || $fieldValue===0 || $fieldValue==='0' || $fieldValue==='';
|
||||
}
|
||||
}else{
|
||||
return $fieldValue == $value;
|
||||
}
|
||||
case "contains":
|
||||
return strpos($fieldValue, $value) !== FALSE;
|
||||
case "does not contain":
|
||||
return strpos($fieldValue, $value) === FALSE;
|
||||
case "starts with":
|
||||
return $this->startsWith($fieldValue,$value);
|
||||
case "ends with":
|
||||
return $this->endsWith($fieldValue, $value);
|
||||
case "matches":
|
||||
return preg_match($value, $fieldValue);
|
||||
default:
|
||||
//Unexpected condition
|
||||
throw new Exception("Found an unexpected condition: ".$condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class VTSimpleTemplate{
|
||||
|
||||
function __construct($templateString){
|
||||
$this->template = $templateString;
|
||||
}
|
||||
|
||||
function render($entityCache, $entityId){
|
||||
$this->cache = $entityCache;
|
||||
$this->parent = $this->cache->forId($entityId);
|
||||
return $this->parseTemplate();
|
||||
}
|
||||
|
||||
private function matchHandler($match){
|
||||
preg_match('/\((\w+) : \(([_\w]+)\) (\w+)\)/', $match[1], $matches);
|
||||
if(count($matches)==0){
|
||||
$fieldname = $match[1];
|
||||
$data = $this->parent->getData();
|
||||
if($this->useValue($data, $fieldname)){
|
||||
$result = $data[$fieldname];
|
||||
}else{
|
||||
$result ='';
|
||||
}
|
||||
}else{
|
||||
list($full, $referenceField, $referenceModule, $fieldname) = $matches;
|
||||
if($referenceModule === '__VtigerMeta__'){
|
||||
$result = $this->getMetaValue($fieldname);
|
||||
}else{
|
||||
$referenceId = $this->parent->get($referenceField);
|
||||
if($referenceId==null){
|
||||
$result="";
|
||||
}else{
|
||||
$entity = $this->cache->forId($referenceId);
|
||||
if($referenceModule==="Users" && $entity->getModuleName()=="Groups"){
|
||||
list($groupEntityId, $groupId) = vtws_getIdComponents($referenceId);
|
||||
|
||||
require_once('include/utils/GetGroupUsers.php');
|
||||
$ggu = new GetGroupUsers();
|
||||
$ggu->getAllUsersInGroup($groupId);
|
||||
|
||||
$users = $ggu->group_users;
|
||||
$parts = Array();
|
||||
foreach($users as $userId){
|
||||
$refId = vtws_getWebserviceEntityId("Users", $userId);
|
||||
$entity = $this->cache->forId($refId);
|
||||
$data = $entity->getData();
|
||||
if($this->useValue($data, $fieldname)){
|
||||
$parts[] = $data[$fieldname];
|
||||
}
|
||||
}
|
||||
$result = implode(",", $parts);
|
||||
}if($entity->getModuleName()===$referenceModule){
|
||||
$data = $entity->getData();
|
||||
if($this->useValue($data, $fieldname)){
|
||||
$result = $data[$fieldname];
|
||||
}else{
|
||||
$result = '';
|
||||
}
|
||||
}else{
|
||||
$result = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($result)){
|
||||
$result .= ',';
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
protected function useValue($data, $fieldname) {
|
||||
return !empty($data[$fieldname]);
|
||||
}
|
||||
|
||||
function parseTemplate(){
|
||||
return preg_replace_callback('/\\$(\w+|\((\w+) : \(([_\w]+)\) (\w+)\))\s*,?/', array($this,"matchHandler"), $this->template);
|
||||
}
|
||||
|
||||
function getMetaValue($fieldname){
|
||||
switch($fieldname){
|
||||
case 'date': return getNewDisplayDate();
|
||||
case 'time': return date('h-i-s');
|
||||
default: '';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
/**
|
||||
* Functionality to save and retrieve Tasks from the database.
|
||||
*/
|
||||
class VTTaskManager{
|
||||
function __construct($adb){
|
||||
$this->adb = $adb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the task into the database.
|
||||
*
|
||||
* When a new task is saved for the first time a field is added to it called
|
||||
* id that stores the task id used in the database.
|
||||
*
|
||||
* @param $summary A summary of the task instance.
|
||||
* @param $task The task instance to save.
|
||||
* @return The id of the task
|
||||
*/
|
||||
public function saveTask($task){
|
||||
$adb = $this->adb;
|
||||
if(is_numeric($task->id)){//How do I check whether a member exists in php?
|
||||
$taskId = $task->id;
|
||||
$adb->pquery("update com_vtiger_workflowtasks set summary=?, task=? where task_id=?",
|
||||
array($task->summary, serialize($task), $taskId));
|
||||
return $taskId;
|
||||
}else{
|
||||
$taskId = $adb->getUniqueID("com_vtiger_workflowtasks");
|
||||
$task->id = $taskId;
|
||||
$adb->pquery("insert into com_vtiger_workflowtasks
|
||||
(task_id, workflow_id, summary, task)
|
||||
values (?, ?, ?, ?)",
|
||||
array($taskId, $task->workflowId, $task->summary, serialize($task)));
|
||||
return $taskId;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteTask($taskId){
|
||||
$adb = $this->adb;
|
||||
$adb->pquery("delete from com_vtiger_workflowtasks where task_id=?", array($taskId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new class instance
|
||||
*/
|
||||
public function createTask($taskType, $workflowId){
|
||||
$taskClass = $taskType;
|
||||
$this->requireTask($taskType);
|
||||
$task = new $taskClass();
|
||||
$task->workflowId=$workflowId;
|
||||
$task->summary = "";
|
||||
$task->active=true;
|
||||
return $task;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a task from the database
|
||||
*
|
||||
* @param $taskId The id of the task to retrieve.
|
||||
* @return The retrieved task.
|
||||
*/
|
||||
public function retrieveTask($taskId){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery("select task from com_vtiger_workflowtasks where task_id=?", array($taskId));
|
||||
$data = $adb->raw_query_result_rowdata($result, 0);
|
||||
$task = $data["task"];
|
||||
return $this->unserializeTask($task);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getTasksForWorkflow($workflowId){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery("select task from com_vtiger_workflowtasks
|
||||
where workflow_id=?",
|
||||
array($workflowId));
|
||||
return $this->getTasksForResult($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function unserializeTask($str){
|
||||
$this->requireTask(self::taskName($str));
|
||||
return unserialize($str);
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getTasks(){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->query("select task from com_vtiger_workflowtasks");
|
||||
return $this->getTasksForResult($result);
|
||||
}
|
||||
|
||||
|
||||
function getTaskTypes(){
|
||||
$taskTypes = array("VTEmailTask", "VTEntityMethodTask", "VTCreateTodoTask","VTCreateEventTask");
|
||||
// Make SMSTask available if module is active
|
||||
// TODO Generic way of handling this could be helpful
|
||||
if(getTabid('SMSNotifier') && vtlib_isModuleActive('SMSNotifier')) {
|
||||
$taskTypes [] = 'VTSMSTask';
|
||||
}
|
||||
return $taskTypes;
|
||||
}
|
||||
|
||||
private function getTasksForResult($result){
|
||||
$adb = $this->adb;
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$tasks = array();
|
||||
foreach($it as $row){
|
||||
$text = $row->task;
|
||||
|
||||
$this->requireTask(self::taskName($text));
|
||||
$tasks[] = unserialize($text);
|
||||
}
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
private function taskName($serializedTask){
|
||||
$matches = array();
|
||||
preg_match ('/"([^"]+)"/', $serializedTask, $matches);
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
private function requireTask($taskType){
|
||||
require_once("tasks/".$taskType.".inc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class VTTask{
|
||||
public abstract function doTask($data);
|
||||
public abstract function getFieldNames();
|
||||
}
|
||||
|
||||
//require 'modules/Workflow/tasks/VTEmailTask.inc';
|
||||
?>
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
/**
|
||||
* Time based Queue of tasks ready for execution.
|
||||
*
|
||||
*/
|
||||
class VTTaskQueue{
|
||||
|
||||
public function __construct($adb){
|
||||
$this->adb = $adb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue a task for execution.
|
||||
*
|
||||
* @param $taskId The id of the task to queue
|
||||
* @param $entityId The id of the crm entity the task is assiciated with.
|
||||
* @param $when The time after which the task should be executed. This is
|
||||
* an optional value with a default value of 0.
|
||||
*/
|
||||
public function queueTask($taskId, $entityId, $when=0){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery("select * from com_vtiger_workflowtask_queue
|
||||
where task_id=? and entity_id=?", array($taskId, $entityId));
|
||||
if($adb->num_rows($result)==1){
|
||||
return false;
|
||||
}else{
|
||||
$adb->pquery("insert into com_vtiger_workflowtask_queue (task_id, entity_id, do_after)
|
||||
values (?,?,?)", array($taskId, $entityId, $when));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of taskId/entityId pairs ready for execution.
|
||||
*
|
||||
* The method fetches task id/entity id where the when timestamp
|
||||
* is less than the current time when the method was called.
|
||||
*
|
||||
* @return A list of pairs of the form array(taskId, entityId)
|
||||
*/
|
||||
public function getReadyTasks(){
|
||||
$adb = $this->adb;
|
||||
$time = time();
|
||||
$result = $adb->pquery("select task_id, entity_id from com_vtiger_workflowtask_queue where do_after<?", array($time));
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$arr = array();
|
||||
foreach($it as $row){
|
||||
$arr[]=array($row->task_id, $row->entity_id);
|
||||
}
|
||||
$adb->pquery("delete from com_vtiger_workflowtask_queue where do_after<?", array($time));
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class VTWorkflowApplication{
|
||||
function __construct($action){
|
||||
global $_REQUEST;
|
||||
$this->request;
|
||||
$this->name = "com_vtiger_workflow";
|
||||
$this->label = "Workflow";
|
||||
$this->action = $action;
|
||||
$this->returnUrl = $_SERVER["REQUEST_URI"];
|
||||
}
|
||||
|
||||
function currentUrl(){
|
||||
// $req = $this->request;
|
||||
// $url = "index.php?module={$this->name}&action={$this->action}";
|
||||
// if($this->action=='editworkflow'){
|
||||
// if(isset($req['workflow_id'])){
|
||||
// $url.="&workflow_id=".$req['workflow_id'];
|
||||
// }
|
||||
// }else if($this->action=='edittask'){
|
||||
// if(isset($req['task_id'])){
|
||||
// $url.="&task_id=".$req['task_id'];
|
||||
// }
|
||||
// }
|
||||
return $_SERVER["REQUEST_URI"];
|
||||
}
|
||||
|
||||
function returnUrl(){
|
||||
return $this->returnUrl;
|
||||
}
|
||||
|
||||
function listViewUrl(){
|
||||
return "index.php?module={$this->name}&action=workflowlist";
|
||||
}
|
||||
|
||||
function editWorkflowUrl($id=null){
|
||||
if($id!=null){
|
||||
$idPart="&workflow_id=$id";
|
||||
}
|
||||
return "index.php?module={$this->name}&action=editworkflow$idPart&return_url=".urlencode($this->returnUrl());
|
||||
}
|
||||
|
||||
function deleteWorkflowUrl($id){
|
||||
$idPart="&workflow_id=$id";
|
||||
return "index.php?module={$this->name}&action=deleteworkflow$idPart&return_url=".urlencode($this->returnUrl());
|
||||
}
|
||||
|
||||
function editTaskUrl($id=null){
|
||||
if($id!=null){
|
||||
$idPart="&task_id=$id";
|
||||
}
|
||||
return "index.php?module={$this->name}&action=edittask$idPart&return_url=".urlencode($this->returnUrl());
|
||||
}
|
||||
|
||||
function deleteTaskUrl($id){
|
||||
$idPart="&task_id=$id";
|
||||
return "index.php?module={$this->name}&action=deletetask$idPart&return_url=".urlencode($this->returnUrl());
|
||||
}
|
||||
|
||||
function setReturnUrl($returnUrl){
|
||||
$this->returnUrl = $returnUrl;
|
||||
}
|
||||
|
||||
function errorPageUrl($message){
|
||||
return "index.php?module={$this->name}&action=errormessage&message=".urlencode($message);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("VTJsonCondition.inc");
|
||||
|
||||
class VTWorkflowManager{
|
||||
|
||||
static $ON_FIRST_SAVE = 1;
|
||||
static $ONCE = 2;
|
||||
static $ON_EVERY_SAVE = 3;
|
||||
static $ON_MODIFY = 4;
|
||||
|
||||
|
||||
function __construct($adb){
|
||||
$this->adb = $adb;
|
||||
}
|
||||
|
||||
function save($workflow){
|
||||
$adb=$this->adb;
|
||||
if(isset($workflow->id)){
|
||||
$wf=$workflow;
|
||||
$adb->pquery("update com_vtiger_workflows set
|
||||
module_name=?, summary=?, test=?, execution_condition=?
|
||||
where workflow_id=?",
|
||||
array($wf->moduleName, $wf->description, $wf->test, $wf->executionCondition, $wf->id));
|
||||
}else{
|
||||
$workflowId = $adb->getUniqueID("com_vtiger_workflows");
|
||||
$workflow->id = $workflowId;
|
||||
$wf=$workflow;
|
||||
$adb->pquery("insert into com_vtiger_workflows
|
||||
(workflow_id, module_name, summary, test, execution_condition)
|
||||
values (?,?,?,?,?)",
|
||||
array($workflowId, $wf->moduleName, $wf->description, $wf->test, $wf->executionCondition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getWorkflows(){
|
||||
$adb=$this->adb;
|
||||
|
||||
$result=$adb->getColumnNames("com_vtiger_workflows");
|
||||
if(in_array("defaultworkflow",$result)){
|
||||
$result = $adb->query("select workflow_id, module_name, summary, test, execution_condition,defaultworkflow
|
||||
from com_vtiger_workflows ");
|
||||
}else{
|
||||
|
||||
$result = $adb->query("select workflow_id, module_name, summary, test, execution_condition
|
||||
from com_vtiger_workflows");
|
||||
}
|
||||
return $this->getWorkflowsForResult($result);
|
||||
|
||||
}
|
||||
|
||||
function getWorkflowsForModule($moduleName){
|
||||
$adb=$this->adb;
|
||||
|
||||
|
||||
//my changes
|
||||
$result=$adb->getColumnNames("com_vtiger_workflows");
|
||||
if(in_array(defaultworkflow,$result)){
|
||||
$result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition,defaultworkflow
|
||||
from com_vtiger_workflows where module_name=?",array($moduleName));
|
||||
}
|
||||
else{
|
||||
$result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition
|
||||
from com_vtiger_workflows where module_name=?",array($moduleName));
|
||||
}
|
||||
return $this->getWorkflowsForResult($result);
|
||||
}
|
||||
|
||||
private function getWorkflowsForResult($result){
|
||||
$adb=$this->adb;
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$workflows=array();
|
||||
foreach($it as $row){
|
||||
$workflow=new Workflow();
|
||||
$workflow->id = $row->workflow_id;
|
||||
$workflow->moduleName = $row->module_name;
|
||||
$workflow->description = $row->summary;
|
||||
$workflow->test = $row->test;
|
||||
$workflow->executionCondition = $row->execution_condition;
|
||||
|
||||
if($row->defaultworkflow){
|
||||
$workflow->defaultworkflow=$row->defaultworkflow;
|
||||
}
|
||||
$workflows[]=$workflow;
|
||||
}
|
||||
return $workflows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a workflow from the database
|
||||
*
|
||||
* Returns null if the workflow doesn't exist.
|
||||
*
|
||||
* @param The id of the workflow
|
||||
* @return A workflow object.
|
||||
*/
|
||||
function retrieve($id){
|
||||
$adb=$this->adb;
|
||||
$workflow=new Workflow();
|
||||
$result = $adb->pquery("select workflow_id, module_name, summary, test, execution_condition
|
||||
from com_vtiger_workflows where workflow_id=?",
|
||||
array($id));
|
||||
if($adb->num_rows($result)){
|
||||
$data = $adb->raw_query_result_rowdata($result, 0);
|
||||
$workflow->id = $data["workflow_id"];
|
||||
$workflow->moduleName = $data["module_name"];
|
||||
$workflow->description = $data["summary"];
|
||||
$workflow->test = $data["test"];
|
||||
$workflow->executionCondition = $data['execution_condition'];
|
||||
return $workflow;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id){
|
||||
$adb=$this->adb;
|
||||
$adb->pquery("delete from com_vtiger_workflowtasks where workflow_id=?", array($id));
|
||||
$adb->pquery("delete from com_vtiger_workflows where workflow_id=?", array($id));
|
||||
}
|
||||
|
||||
function newWorkflow($moduleName){
|
||||
$workflow=new Workflow();
|
||||
$workflow->moduleName = $moduleName;
|
||||
$workflow->executionCondition = self::$ON_EVERY_SAVE;
|
||||
return $workflow;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export a workflow as a json encoded string
|
||||
*
|
||||
* @param $workflow The workflow instance to export.
|
||||
*/
|
||||
public function serializeWorkflow($workflow){
|
||||
$exp = array();
|
||||
$exp['moduleName'] = $workflow->moduleName;
|
||||
$exp['description'] = $workflow->description;
|
||||
$exp['test'] = $workflow->test;
|
||||
$exp['executionCondition'] = $workflow->executionCondition;
|
||||
$exp['tasks'] = array();
|
||||
$tm = new VTTaskManager($this->adb);
|
||||
$tasks = $tm->getTasksForWorkflow($workflow->id);
|
||||
foreach($tasks as $task){
|
||||
unset($task->id);
|
||||
unset($task->workflowId);
|
||||
$exp['tasks'][] = serialize($task);
|
||||
}
|
||||
return Zend_Json::encode($exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a json encoded string as a workflow object
|
||||
*
|
||||
* @return The Workflow instance representing the imported workflow.
|
||||
*/
|
||||
public function deserializeWorkflow($str){
|
||||
$data = Zend_Json::decode($str);
|
||||
$workflow = $this->newWorkflow($data['moduleName']);
|
||||
$workflow->description = $data['description'];
|
||||
$workflow->test = $data['test'];
|
||||
$workflow->executionCondition = $data['executionCondition'];
|
||||
$this->save($workflow);
|
||||
$tm = new VTTaskManager($this->adb);
|
||||
$tasks = $data['tasks'];
|
||||
foreach($tasks as $taskStr){
|
||||
$task = $tm->unserializeTask($taskStr);
|
||||
$task->workflowId = $workflow->id;
|
||||
$tm->saveTask($task);
|
||||
}
|
||||
return $workflow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Workflow{
|
||||
function __construct(){
|
||||
$this->conditionStrategy = new VTJsonCondition();
|
||||
}
|
||||
|
||||
function evaluate($entityCache, $id){
|
||||
if($this->test==""){
|
||||
return true;
|
||||
}else{
|
||||
$cs = $this->conditionStrategy;
|
||||
return $cs->evaluate($this->test,
|
||||
$entityCache, $id);
|
||||
}
|
||||
}
|
||||
|
||||
function executionConditionAsLabel($label=null){
|
||||
if($label==null){
|
||||
$arr = array('ON_FIRST_SAVE', 'ONCE', 'ON_EVERY_SAVE','ON_MODIFY');
|
||||
return $arr[$this->executionCondition-1];
|
||||
}else{
|
||||
$arr = array('ON_FIRST_SAVE'=>1, 'ONCE'=>2, 'ON_EVERY_SAVE'=>3, 'ON_MODIFY'=>4);
|
||||
$this->executionCondition = $arr[$label];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
class VTWorkflowTemplateManager{
|
||||
public function __construct($adb){
|
||||
$this->adb = $adb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create anew template instance from a workflow
|
||||
*
|
||||
* This template instance will not be saved. The save
|
||||
* will have to be done explicitly.
|
||||
*
|
||||
* @param $title The title of the template
|
||||
* @param $workflow A workflow instance.
|
||||
*/
|
||||
public function newTemplate($title, $workflow){
|
||||
$adb = $this->adb;
|
||||
$wms = new VTWorkflowManager($adb);
|
||||
$str = $wms->serializeWorkflow($workflow);
|
||||
$template = new VTWorkflowTemplate();
|
||||
$template->title = $title;
|
||||
$template->moduleName = $workflow->moduleName;
|
||||
$template->template = $str;
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a template given it's id
|
||||
*
|
||||
* @param $templateId The id of the template
|
||||
* @return The template object
|
||||
*/
|
||||
public function retrieveTemplate($templateId){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery('select * from com_vtiger_workflowtemplates where template_id=?', array($templateId));
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$data = $it->current();
|
||||
$template = new VTWorkflowTemplate();
|
||||
$template->id = $templateId;
|
||||
$template->title = $data->title;
|
||||
$template->moduleName = $data->module_name;
|
||||
$template->template = $data->template;
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a workflow from a template
|
||||
*
|
||||
* The new workflow will also be added to the database.
|
||||
*
|
||||
* @param $template The template to use
|
||||
* @return A workflow object.
|
||||
*/
|
||||
public function createWorkflow($template){
|
||||
$adb = $this->adb;
|
||||
$wfm = new VTWorkflowManager($adb);
|
||||
return $wfm->deserializeWorkflow($template->template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template objects for a particular module.
|
||||
*
|
||||
* @param $moduleName The name of the module
|
||||
* @return An array containing template objects
|
||||
*/
|
||||
public function getTemplatesForModule($moduleName){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->pquery("select * from com_vtiger_workflowtemplates where module_name=?", array($moduleName));
|
||||
return $this->getTemplatesForResult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all templates
|
||||
*
|
||||
* Get all the templates as an array
|
||||
*
|
||||
* @return An array containing template objects.
|
||||
*/
|
||||
public function getTemplates(){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->query("select * from com_vtiger_workflowtemplates");
|
||||
return $this->getTemplatesForResult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a template
|
||||
*
|
||||
* If the object is a newly created template it
|
||||
* will be added to the database and a field id containing
|
||||
* the new id will be added to the object.
|
||||
*
|
||||
* @param $template The template object to save.
|
||||
*/
|
||||
public function saveTemplate($template){
|
||||
$adb = $this->adb;
|
||||
if(is_numeric($template->id)){//How do I check whether a member exists in php?
|
||||
$templateId = $template->id;
|
||||
$adb->pquery("update com_vtiger_workflowtemplates set title=?,"+
|
||||
" module_name=?, template=? where template_id=?",
|
||||
array($template->title, $template->moduleName,
|
||||
$template->template, $templateId));
|
||||
return $templateId;
|
||||
}else{
|
||||
$templateId = $adb->getUniqueID("com_vtiger_workflowtemplates");
|
||||
$template->id = $templateId;
|
||||
$adb->pquery("insert into com_vtiger_workflowtemplates
|
||||
(template_id, title, module_name, template)
|
||||
values (?, ?, ?, ?)",
|
||||
array($templateId, $template->title,
|
||||
$template->moduleName, $template->template));
|
||||
return $templateId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a template
|
||||
*
|
||||
* $templateId The id of the template to delete.
|
||||
*/
|
||||
public function deleteTemplate($templateId){
|
||||
$adb = $this->adb;
|
||||
$adb->pquery('delete from com_vtiger_workflowtemplates where template_id=?',
|
||||
array($templateId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dump all the templates in vtiger into a string
|
||||
*
|
||||
* This can be used for exporting templates from one
|
||||
* machine to another
|
||||
*
|
||||
* @return The string dump of the templates.
|
||||
*/
|
||||
public function dumpAllTemplates(){
|
||||
$adb = $this->adb;
|
||||
$result = $adb->query("select * from com_vtiger_workflowtemplates");
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$arr = array();
|
||||
foreach($it as $row){
|
||||
$el = array(
|
||||
'moduleName'=>$row->module_name,
|
||||
'title'=>$row->title,
|
||||
'template'=>$row->template
|
||||
);
|
||||
$arr[] = $el;
|
||||
}
|
||||
return Zend_Json::encode($arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load templates form a dumped string
|
||||
*
|
||||
* @param $str The string dump generated from dumpAllTemplates
|
||||
*/
|
||||
public function loadTemplates($str){
|
||||
$arr = Zend_Json::decode($str);
|
||||
foreach($arr as $el){
|
||||
$template = new VTWorkflowTemplate();
|
||||
$template->moduleName = $el['moduleName'];
|
||||
$template->title = $el['title'];
|
||||
$template->template = $el['template'];
|
||||
$this->save($template);
|
||||
$this->createWorkflow($template);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function getTemplatesForResult($result){
|
||||
$adb = $this->adb;
|
||||
$it = new SqlResultIterator($adb, $result);
|
||||
$templates = array();
|
||||
foreach($it as $row){
|
||||
$template = new VTWorkflowTemplate();
|
||||
$template->id = $row->template_id;
|
||||
$template->title = $row->title;
|
||||
$tempalte->moduleName = $row->module_name;
|
||||
$template->template = $row->template;
|
||||
$templates[] = $template;
|
||||
}
|
||||
return $templates;
|
||||
}
|
||||
}
|
||||
|
||||
class VTWorkflowTemplate{
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
//A collection of util functions for the workflow module
|
||||
|
||||
class VTWorkflowUtils{
|
||||
|
||||
function __construct(){
|
||||
global $current_user;
|
||||
$this->userStack = array();
|
||||
}
|
||||
/**
|
||||
* Check whether the given identifier is valid.
|
||||
*/
|
||||
function validIdentifier($identifier){
|
||||
if(is_string($identifier)){
|
||||
return preg_match("/^[a-zA-Z][a-zA-Z_0-9]+$/", $identifier);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Push the admin user on to the user stack
|
||||
* and make it the $current_user
|
||||
*
|
||||
*/
|
||||
function adminUser(){
|
||||
$user = new Users();
|
||||
$user->retrieveCurrentUserInfoFromFile(1);
|
||||
global $current_user;
|
||||
array_push($this->userStack, $current_user);
|
||||
$current_user = $user;
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert to the previous use on the user stack
|
||||
*/
|
||||
function revertUser(){
|
||||
global $current_user;
|
||||
if(count($this->userStack)!=0){
|
||||
$current_user = array_pop($this->userStack);
|
||||
}else{
|
||||
$current_user = null;
|
||||
}
|
||||
return $current_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current user
|
||||
*/
|
||||
function currentUser(){
|
||||
return $current_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* The the webservice entity type of an EntityData object
|
||||
*/
|
||||
function toWSModuleName($entityData){
|
||||
$moduleName = $entityData->getModuleName();
|
||||
if($moduleName == 'Activity'){
|
||||
$arr = array('Task' => 'Calendar', 'Emails' => 'Emails');
|
||||
$moduleName = $arr[getActivityType($entityData->getId())];
|
||||
if($moduleName == null){
|
||||
$moduleName = 'Events';
|
||||
}
|
||||
}
|
||||
return $moduleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert redirection script
|
||||
*/
|
||||
function redirectTo($to, $message){
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$to?>";
|
||||
</script>
|
||||
<a href="<?=$to?>"><?=$message?></a>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user is admin
|
||||
*/
|
||||
function checkAdminAccess(){
|
||||
global $current_user;
|
||||
return strtolower($current_user->is_admin)==='on';
|
||||
}
|
||||
|
||||
/* function to check if the module has workflow
|
||||
* @params :: $modulename - name of the module
|
||||
*/
|
||||
function checkModuleWorkflow($modulename){
|
||||
global $adb;
|
||||
$tabid = getTabid($modulename);
|
||||
$modules_not_supported = array('Documents','Calendar','Emails','Faq','Events','PBXManager','Users');
|
||||
$query = "SELECT name FROM vtiger_tab WHERE name not in (".generateQuestionMarks($modules_not_supported).") AND isentitytype=1 AND presence = 0 AND tabid = ?";
|
||||
$result = $adb->pquery($query,array($modules_not_supported,$tabid));
|
||||
$rows = $adb->num_rows($result);
|
||||
if($rows > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function vtGetModules($adb){
|
||||
$modules_not_supported = array('Documents','Calendar','Emails','Faq','Events','PBXManager','Users');
|
||||
$sql="select distinct vtiger_field.tabid, name
|
||||
from vtiger_field
|
||||
inner join vtiger_tab
|
||||
on vtiger_field.tabid=vtiger_tab.tabid
|
||||
where vtiger_tab.name not in(".generateQuestionMarks($modules_not_supported).") and vtiger_tab.isentitytype=1 and vtiger_tab.presence = 0 ";
|
||||
$it = new SqlResultIterator($adb, $adb->pquery($sql,array($modules_not_supported)));
|
||||
$modules = array();
|
||||
foreach($it as $row){
|
||||
$modules[] = $row->name;
|
||||
}
|
||||
return $modules;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
require_once('include/Ajax/CommonAjax.php');
|
||||
?>
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("include/Zend/Json.php");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTTaskManager.inc");
|
||||
require_once('VTWorkflowUtils.php');
|
||||
|
||||
function vtDeleteWorkflow($adb, $request){
|
||||
$util = new VTWorkflowUtils();
|
||||
$module = new VTWorkflowApplication("deltetask");
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$wm = new VTTaskManager($adb);
|
||||
$wm->deleteTask($request['task_id']);
|
||||
|
||||
if(isset($request["return_url"])){
|
||||
$returnUrl=$request["return_url"];
|
||||
}else{
|
||||
$returnUrl=$module->editWorkflowUrl($wf->id);
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$returnUrl?>";
|
||||
</script>
|
||||
<a href="<?=$returnUrl?>">Return</a>
|
||||
<?php
|
||||
}
|
||||
vtDeleteWorkflow($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("include/Zend/Json.php");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTWorkflowManager.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
function vtDeleteWorkflow($adb, $request){
|
||||
$util = new VTWorkflowUtils();
|
||||
$module = new VTWorkflowApplication("deleteworkflow");
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$wm = new VTWorkflowManager($adb);
|
||||
$wm->delete($request['workflow_id']);
|
||||
|
||||
if(isset($request["return_url"])){
|
||||
$returnUrl=$request["return_url"];
|
||||
}else{
|
||||
$returnUrl=$module->listViewUrl($wf->id);
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$returnUrl?>";
|
||||
</script>
|
||||
<a href="<?=$returnUrl?>">Return</a>
|
||||
<?php
|
||||
}
|
||||
vtDeleteWorkflow($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("include/events/VTWSEntityType.inc");
|
||||
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTTaskManager.inc");
|
||||
require_once("VTWorkflowManager.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
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");
|
||||
}
|
||||
vtTaskEdit($adb, $_REQUEST, $current_language, $app_strings);
|
||||
?>
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/Zend/Json.php");
|
||||
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("include/events/VTWSEntityType.inc");
|
||||
|
||||
require_once("VTWorkflowManager.inc");
|
||||
require_once("VTTaskManager.inc");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once "VTWorkflowTemplateManager.inc";
|
||||
require_once "VTWorkflowUtils.php";
|
||||
|
||||
function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_strings){
|
||||
|
||||
global $theme;
|
||||
$util = new VTWorkflowUtils();
|
||||
|
||||
$image_path = "themes/$theme/images/";
|
||||
|
||||
$module = new VTWorkflowApplication("editworkflow");
|
||||
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$smarty = new vtigerCRM_Smarty();
|
||||
if($request['source']=='from_template'){
|
||||
$tm = new VTWorkflowTemplateManager($adb);
|
||||
$template = $tm->retrieveTemplate($request['template_id']);
|
||||
$workflow = $tm->createWorkflow($template);
|
||||
}else{
|
||||
$wfs = new VTWorkflowManager($adb);
|
||||
if(isset($request["workflow_id"])){
|
||||
$workflow = $wfs->retrieve($request["workflow_id"]);
|
||||
}else{
|
||||
$moduleName=$request["module_name"];
|
||||
$workflow = $wfs->newWorkflow($moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
if($workflow==null){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NO_WORKFLOW']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NO_WORKFLOW']);
|
||||
return;
|
||||
}
|
||||
$workflow->test = addslashes($workflow->test);
|
||||
$tm = new VTTaskManager($adb);
|
||||
$tasks = $tm->getTasksForWorkflow($workflow->id);
|
||||
$smarty->assign("tasks", $tasks);
|
||||
$smarty->assign("taskTypes", $tm->getTaskTypes());
|
||||
$smarty->assign("newTaskReturnUrl", $requestUrl);
|
||||
|
||||
$smarty->assign("returnUrl", $request["return_url"]);
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("MOD", array_merge(
|
||||
return_module_language($current_language,'Settings'),
|
||||
return_module_language($current_language, $module->name)));
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH", $image_path);
|
||||
$smarty->assign("MODULE_NAME", $module->label);
|
||||
$smarty->assign("PAGE_NAME", $mod['LBL_EDIT_WORKFLOW']);
|
||||
$smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_WORKFLOW_TITLE']);
|
||||
|
||||
$smarty->assign("workflow", $workflow);
|
||||
$smarty->assign("saveType", isset($workflow->id)?"edit":"new");
|
||||
$smarty->assign("module", $module);
|
||||
|
||||
$smarty->display("{$module->name}/EditWorkflow.tpl");
|
||||
}
|
||||
vtWorkflowEdit($adb, $_REQUEST, $_SERVER["REQUEST_URI"], $current_language, $app_strings);
|
||||
?>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("include/Zend/Json.php");
|
||||
require_once('modules/com_vtiger_workflow/VTEntityMethodManager.inc');
|
||||
|
||||
function vtEntityMethodJson($adb, $request){
|
||||
$moduleName = $request['module_name'];
|
||||
$emm = new VTEntityMethodManager($adb);
|
||||
$methodNames = $emm->methodsForModule($moduleName);
|
||||
echo Zend_Json::encode($methodNames);
|
||||
}
|
||||
|
||||
vtEntityMethodJson($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
?>
|
||||
<h1>Error</h1>
|
||||
<?=htmlentities($_REQUEST['message'])?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
function displayErrorPage($request){
|
||||
?>
|
||||
<h1>Workflow engine error</h1>
|
||||
<?="It appears that you have entered an invalid value."?>
|
||||
<?php
|
||||
}
|
||||
displayErrorPage($_REQUEST);
|
||||
|
||||
?>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once 'include/events/SqlResultIterator.inc';
|
||||
require 'VTWorkflowManager.inc';
|
||||
require 'VTTaskManager.inc';
|
||||
require 'VTWorkflowTemplateManager.inc';
|
||||
require 'VTTaskQueue.inc';
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once 'include/Webservices/Utils.php';
|
||||
require_once("modules/Users/Users.php");
|
||||
require_once("include/Webservices/VtigerCRMObject.php");
|
||||
require_once("include/Webservices/VtigerCRMObjectMeta.php");
|
||||
require_once("include/Webservices/DataTransform.php");
|
||||
require_once("include/Webservices/WebServiceError.php");
|
||||
require_once 'include/utils/utils.php';
|
||||
require_once 'include/Webservices/ModuleTypes.php';
|
||||
?>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
$mod_strings = array(
|
||||
'VTEmailTask' => 'Send Email',
|
||||
'VTEntityMethodTask' => 'Invoke Custom Function',
|
||||
'VTCreateTodoTask' => 'Create Todo',
|
||||
'VTCreateEventTask' => 'Create Event',
|
||||
'VTSMSTask' => 'SMS Task',
|
||||
'LBL_EDIT_TASK'=>'Edit Task',
|
||||
'LBL_EDIT_TASK_TITLE'=>'Edit an existing task or create a new one',
|
||||
'LBL_EDIT_WORKFLOW'=>'Edit Workflow',
|
||||
'LBL_EDIT_WORKFLOW_TITLE'=>'Edit an existing workflow or create a one',
|
||||
'LBL_FROM_TEMPLATE'=>'From Template',
|
||||
'LBL_NEW_WORKFLOW'=>'New Workflow',
|
||||
'LBL_NEW_TEMPLATE'=>'Save as Template',
|
||||
'LBL_CREATE_WORKFLOW_FOR'=>'Create a workflow for',
|
||||
'LBL_FOR_MODULE'=>'For Module',
|
||||
'LBL_CHOOSE_A_TEMPLATE'=>'Choose a template',
|
||||
'LBL_VALIDATION_MISSING_MANDATORY_FIELDS'=>'There are empty mandatory fields.',
|
||||
'LBL_VALIDATION_INVALID_DATE_RANGE'=>'Start date/time is greater than the end date/time',
|
||||
'LBL_ERROR_NO_WORKFLOW'=>'The workflow you requested does not exist',
|
||||
'LBL_ERROR_NO_TASK'=>'The task you requested does not exist',
|
||||
'LBL_ERROR_NOT_ADMIN'=>'You do not have access to this module as you are not an admin user',
|
||||
'LBL_CREATE_WORKFLOW'=>'Create workflow',
|
||||
'LBL_WORKFLOW_LIST'=>'Workflow List',
|
||||
'LBL_AVAILABLE_WORKLIST_LIST'=>'Available Workflows',
|
||||
'LBL_LOADING'=>'Loading...',
|
||||
'LBL_VALIDATION_ERROR'=>'Validation Error',
|
||||
'LBL_SELECT_OPTION_DOTDOTDOT'=>'Select Option...',
|
||||
'LBL_WORKFLOW_NOTE_CRON_CONFIG'=>'NOTE: You should have Workflow cron script configured.',
|
||||
'LBL_NO_TEMPLATES'=>'No Templates',
|
||||
'LBL_SELECT'=>'Select',
|
||||
'LBL_MESSAGE'=>'Message',
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*Copyright(C)2006-2010 YUCHENG HU
|
||||
*
|
||||
*---------------------------------------------
|
||||
*HAWEBSYSTEMS
|
||||
*http://www.hawebs.net
|
||||
*https://www.hawebs.org/forums/computer/
|
||||
*
|
||||
*CONTACT
|
||||
*huyuchengus@gmail.com/yuchenghu@hawebs.net
|
||||
*
|
||||
*---------------------------------------------
|
||||
*[A]GNUGENERALPUBLICLICENSEGNU/LGPL
|
||||
*[B]ApacheLicense,Version2.0
|
||||
*
|
||||
*---------------------------------------------
|
||||
*NOTE
|
||||
*1.所有的语言配置文件请采用UTF-8编码
|
||||
*
|
||||
*---------------------------------------------
|
||||
*/
|
||||
$mod_strings = array(
|
||||
'VTEmailTask' => '发送邮件',
|
||||
'VTEntityMethodTask' => '自定义函数',
|
||||
'VTCreateTodoTask' => '创建待办事项',
|
||||
'VTCreateEventTask' => '创建活动',
|
||||
'LBL_EDIT_TASK'=>'编辑任务',
|
||||
'LBL_EDIT_TASK_TITLE'=>'编辑现有的任务或者创建新任务',
|
||||
'LBL_EDIT_WORKFLOW'=>'编辑工作流程',
|
||||
'LBL_EDIT_WORKFLOW_TITLE'=>'编辑现有的工作流程或者创建新流程',
|
||||
'LBL_FROM_TEMPLATE'=>'从模板',
|
||||
'LBL_NEW_WORKFLOW'=>'新流程',
|
||||
'LBL_NEW_TEMPLATE'=>'保存为模板',
|
||||
'LBL_CREATE_WORKFLOW_FOR'=>'新的工作流程',
|
||||
'LBL_FOR_MODULE'=>'的模块',
|
||||
'LBL_FROM_TEMPLATE'=>'从模板',
|
||||
'LBL_CHOOSE_A_TEMPLATE'=>'选择模板',
|
||||
'LBL_VALIDATION_MISSING_MANDATORY_FIELDS'=>'有空必填。',
|
||||
'LBL_VALIDATION_INVALID_DATE_RANGE'=>'开始的日期/时间大于结束日期/时间。',
|
||||
'LBL_ERROR_NO_WORKFLOW'=>'你请求的工作流程不存在。 ',
|
||||
'LBL_ERROR_NO_TASK'=>'你请求的任务不存在。',
|
||||
'LBL_ERROR_NOT_ADMIN'=>'您没有访问此模块的权限。',
|
||||
'LBL_CREATE_WORKFLOW'=>'创建工作流',
|
||||
'LBL_WORKFLOW_LIST'=>'工作流列表',
|
||||
'LBL_AVAILABLE_WORKLIST_LIST'=>'有效的工作流',
|
||||
'LBL_LOADING'=>'下载...',
|
||||
'LBL_VALIDATION_ERROR'=>'违例错误',
|
||||
'LBL_SELECT_OPTION_DOTDOTDOT'=>'选择项...',
|
||||
'LBL_WORKFLOW_NOTE_CRON_CONFIG'=>'注意:你必须配置工作流的核心脚本。',
|
||||
'LBL_NO_TEMPLATES'=>'没有模板',
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/utils/utils.php');
|
||||
require_once('include/Zend/Json.php');
|
||||
require_once('include/events/include.inc');
|
||||
require_once('modules/com_vtiger_workflow/include.inc');
|
||||
|
||||
/**
|
||||
* This is a utility function to load a dumped templates files
|
||||
* into vtiger
|
||||
* @param $filename The name of the file to load.
|
||||
*/
|
||||
function loadTemplates($filename){
|
||||
global $adb;
|
||||
$str = file_get_contents('fetchtemplates.out');
|
||||
$tm = new VTWorkflowTemplateManager($adb);
|
||||
$tm->loadTemplates($str);
|
||||
}
|
||||
?>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once "include/Zend/Json.php";
|
||||
require_once("include/events/VTWSEntityType.inc");
|
||||
|
||||
function vtModuleTypeInfoJson($adb, $request){
|
||||
$moduleName = $request['module_name'];
|
||||
$et = VTWSEntityType::usingGlobalCurrentUser($moduleName);
|
||||
echo Zend_Json::encode($et->getFieldLabels());
|
||||
}
|
||||
vtModuleTypeInfoJson($adb, $_REQUEST);
|
||||
?>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 763 B |
@@ -1,106 +0,0 @@
|
||||
function VTCreateTodoTask($){
|
||||
|
||||
var map = fn.map;
|
||||
var dict = fn.dict;
|
||||
var filter = fn.filter;
|
||||
var reduceR = fn.reduceR;
|
||||
var parallelExecuter = fn.parallelExecuter;
|
||||
var contains = fn.contains;
|
||||
var concat = fn.concat;
|
||||
|
||||
|
||||
function parse12HoursTime(timeStr){
|
||||
var hours;
|
||||
|
||||
var match = timeStr.match(/(\d\d):(\d\d)(am|pm)/);
|
||||
if(match[3]=='am'){
|
||||
hours = parseInt(match[1], 10) % 12;
|
||||
}else{
|
||||
hours = parseInt(match[1], 10) % 12 + 12;
|
||||
}
|
||||
return hours*60+parseInt(match[2], 10);
|
||||
}
|
||||
|
||||
function errorDialog(message){
|
||||
alert(message);
|
||||
}
|
||||
|
||||
function index(arr, field){
|
||||
return dict(map(function(e){return [e[field], e];}, arr));
|
||||
}
|
||||
|
||||
function handleError(fn){
|
||||
return function(status, result){
|
||||
if(status){
|
||||
fn(result);
|
||||
}else{
|
||||
errorDialog('Failure:'+result);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fillPicklist(picklistId, fieldInfo, defaultValue){
|
||||
var values = fieldInfo['type']['picklistValues'];
|
||||
var select = $('#'+picklistId);
|
||||
$.each(values, function(i, v){
|
||||
select.append('<option value="'+v['value']+'">'+v['label']+'</option>');
|
||||
});
|
||||
select.attr('value', defaultValue);
|
||||
}
|
||||
|
||||
var validateDateRange = {
|
||||
init: function(){
|
||||
|
||||
},
|
||||
validator: function(){
|
||||
var result;
|
||||
var successResult = [true];
|
||||
var failureResult = [false, 'invalid_date_range_message', []];
|
||||
if(this.fieldValue('startDatefield') == this.fieldValue('endDatefield')){
|
||||
var startTime = this.fieldValue('startTime');
|
||||
var endTime = this.fieldValue('endTime');
|
||||
var startDays = parseInt(this.fieldValue('startDays'), 10);
|
||||
var endDays = parseInt(this.fieldValue('endDays'), 10);
|
||||
var startDirection = this.fieldValue('startDirection')=="After"?1:-1;
|
||||
var endDirection = this.fieldValue('endDirection')=="After"?1:-1;
|
||||
var dd = endDays*endDirection - startDays*startDirection;
|
||||
if(dd<0){
|
||||
result = failureResult;
|
||||
}else if(dd==0){
|
||||
if(parse12HoursTime(startTime)>=parse12HoursTime(startTime)){
|
||||
result = failureResult;
|
||||
}else{
|
||||
result = successResult;
|
||||
}
|
||||
}else{
|
||||
result = successResult;
|
||||
}
|
||||
}else{
|
||||
result = successResult;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
var vtinst = new VtigerWebservices("webservice.php");
|
||||
vtinst.extendSession(handleError(function(result){
|
||||
$(document).ready(function(){
|
||||
//Setup the validator
|
||||
validator.addValidator('validateDateRange', validateDateRange);
|
||||
validator.mandatoryFields.push('eventName');
|
||||
|
||||
vtinst.describeObject('Events', handleError(function(result){
|
||||
var fields = result['fields'];
|
||||
var fieldsMap = index(fields, 'name');
|
||||
fillPicklist('event_status', fieldsMap['eventstatus'], eventStatus);
|
||||
$('#event_status_busyicon').hide();
|
||||
$('#event_status').show();
|
||||
|
||||
fillPicklist('event_type', fieldsMap['activitytype'], eventType);
|
||||
$('#event_type_busyicon').hide();
|
||||
$('#event_type').show();
|
||||
}));
|
||||
});
|
||||
}));
|
||||
}
|
||||
VTCreateTodoTask(jQuery);
|
||||
@@ -1,63 +0,0 @@
|
||||
function VTCreateTodoTask($){
|
||||
|
||||
var map = fn.map;
|
||||
var dict = fn.dict;
|
||||
var filter = fn.filter;
|
||||
var reduceR = fn.reduceR;
|
||||
var parallelExecuter = fn.parallelExecuter;
|
||||
var contains = fn.contains;
|
||||
var concat = fn.concat;
|
||||
|
||||
function errorDialog(message){
|
||||
alert(message);
|
||||
}
|
||||
|
||||
function index(arr, field){
|
||||
return dict(map(function(e){return [e[field], e];}, arr));
|
||||
}
|
||||
|
||||
function handleError(fn){
|
||||
return function(status, result){
|
||||
if(status){
|
||||
fn(result);
|
||||
}else{
|
||||
errorDialog('Failure:'+result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var vtinst = new VtigerWebservices("webservice.php");
|
||||
vtinst.extendSession(handleError(function(result){
|
||||
$(document).ready(function(){
|
||||
//Setup the validator
|
||||
validator.mandatoryFields.push('todo');
|
||||
|
||||
vtinst.describeObject('Calendar', handleError(function(result){
|
||||
var fields = result['fields'];
|
||||
var fieldsMap = index(fields, 'name');
|
||||
var eventStatusType = fieldsMap['taskstatus'];
|
||||
var eventStatusValues = eventStatusType['type']['picklistValues'];
|
||||
|
||||
var taskPriorityType = fieldsMap['taskpriority'];
|
||||
var taskPriorityValues = taskPriorityType['type']['picklistValues'];
|
||||
|
||||
var status = $('#task_status');
|
||||
$.each(eventStatusValues, function(i, v){
|
||||
status.append('<option value="'+v['value']+'">'+v['label']+'</option>');
|
||||
});
|
||||
status.attr('value', taskStatus);
|
||||
$('#task_status_busyicon').hide();
|
||||
$('#task_status').show();
|
||||
|
||||
var priority = $('#task_priority');
|
||||
$.each(taskPriorityValues, function(i, v){
|
||||
priority.append('<option value="'+v['value']+'">'+v['label']+'</option>');
|
||||
});
|
||||
priority.attr('value', taskPriority);
|
||||
$('#task_priority_busyicon').hide();
|
||||
$('#task_priority').show();
|
||||
}));
|
||||
});
|
||||
}));
|
||||
}
|
||||
VTCreateTodoTask(jQuery);
|
||||
@@ -1,51 +0,0 @@
|
||||
function edittaskscript($){
|
||||
|
||||
function NumberBox(element){
|
||||
var elementId = element.attr("id");
|
||||
var boxId = '#'+elementId+'-number-box';
|
||||
var str = "";
|
||||
for(var i = 1; i <= 30; i++){
|
||||
str += '<a href="#'+i+'" class="box_cel">'+(i < 10? ("0"+i) : i)+'</a> ';
|
||||
if(!(i % 5)){
|
||||
str+="<br>";
|
||||
}
|
||||
}
|
||||
element.after('<div id="'+elementId+'-number-box" style="display:none;" class="box">'+str+'</div>');
|
||||
element.focus(function(){
|
||||
var pos = element.position();
|
||||
$(boxId).css('display', 'block');
|
||||
$(boxId).css({
|
||||
position: 'absolute',
|
||||
top: (pos.top+25)+'px'
|
||||
});
|
||||
});
|
||||
|
||||
element.blur(function(){
|
||||
setTimeout(function(){$(boxId).css('display', 'none');},500);
|
||||
});
|
||||
|
||||
$('.box_cel').click(function(){
|
||||
element.attr('value', parseInt($(this).text(), 10));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
validator = new VTFieldValidator($('#new_task_form'));
|
||||
validator.mandatoryFields = ['summary'];
|
||||
$('.time_field').timepicker();
|
||||
NumberBox($('#select_date_days'));
|
||||
//UI to set the date for executing the task.
|
||||
$('#check_select_date').click(function(){
|
||||
if($(this).attr('checked')){
|
||||
$('#select_date').css('display', 'block');
|
||||
}else{
|
||||
$('#select_date').css('display', 'none');
|
||||
}
|
||||
});
|
||||
$('#edittask_cancel_button').click(function(){
|
||||
window.location=returnUrl;
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,499 +0,0 @@
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
function editworkflowscript($, conditions){
|
||||
var vtinst = new VtigerWebservices("webservice.php");
|
||||
var fieldValidator;
|
||||
var desc = null;
|
||||
|
||||
function id(v){
|
||||
return v;
|
||||
}
|
||||
|
||||
function map(fn, list){
|
||||
var out = [];
|
||||
$.each(list, function(i, v){
|
||||
out[out.length]=fn(v);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function field(name){
|
||||
return function(object){
|
||||
if(typeof(object) != 'undefined') {
|
||||
return object[name];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function zip(){
|
||||
var out = [];
|
||||
|
||||
var lengths = map(field('length'), arguments);
|
||||
var min = reduceR(function(a,b){return a<b?a:b;},lengths,lengths[0]);
|
||||
for(var i=0; i<min; i++){
|
||||
out[i]=map(field(i), arguments);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function dict(list){
|
||||
var out = {};
|
||||
$.each(list, function(i, v){
|
||||
out[v[0]] = v[1];
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function filter(pred, list){
|
||||
var out = [];
|
||||
$.each(list, function(i, v){
|
||||
if(pred(v)){
|
||||
out[out.length]=v;
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function diff(reflist, list) {
|
||||
var out = [];
|
||||
$.each(list, function(i, v) {
|
||||
if(contains(reflist, v)) {
|
||||
out.push(v);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
function reduceR(fn, list, start){
|
||||
var acc = start;
|
||||
$.each(list, function(i, v){
|
||||
acc = fn(acc, v);
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
|
||||
function contains(list, value){
|
||||
var ans = false;
|
||||
$.each(list, function(i, v){
|
||||
if(v==value){
|
||||
ans = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return ans;
|
||||
}
|
||||
|
||||
function concat(lista,listb){
|
||||
return lista.concat(listb);
|
||||
}
|
||||
|
||||
function errorDialog(message){
|
||||
alert(message);
|
||||
}
|
||||
|
||||
function handleError(fn){
|
||||
return function(status, result){
|
||||
if(status){
|
||||
fn(result);
|
||||
}else{
|
||||
errorDialog('Failure:'+result);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function implode(sep, arr){
|
||||
var out = "";
|
||||
$.each(arr, function(i, v){
|
||||
out+=v;
|
||||
if(i<arr.length-1){
|
||||
out+=sep;
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function mergeObjects(obj1, obj2){
|
||||
var res = {};
|
||||
for(var k in obj1){
|
||||
res[k] = obj1[k];
|
||||
}
|
||||
for(var k in obj2){
|
||||
res[k] = obj2[k];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function jsonget(operation, params, callback){
|
||||
var obj = {
|
||||
module:'com_vtiger_workflow',
|
||||
action:'com_vtiger_workflowAjax',
|
||||
file:operation, ajax:'true'};
|
||||
$.each(params,function(key, value){
|
||||
obj[key] = value;
|
||||
});
|
||||
$.get('index.php', obj,
|
||||
function(result){
|
||||
var parsed = JSON.parse(result);
|
||||
callback(parsed);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function center(el){
|
||||
el.css({position: 'absolute'});
|
||||
el.width("400px");
|
||||
el.height("125px");
|
||||
placeAtCenter(el.get(0));
|
||||
}
|
||||
|
||||
|
||||
function PageLoadingPopup(){
|
||||
function show(){
|
||||
$('#workflow_loading').css('display', 'block');
|
||||
//center($('#workflow_loading'));
|
||||
}
|
||||
function close(){
|
||||
$('#workflow_loading').css('display', 'none');
|
||||
}
|
||||
return {
|
||||
show:show, close:close
|
||||
};
|
||||
}
|
||||
var pageLoadingPopup = PageLoadingPopup();
|
||||
|
||||
function NewTemplatePopup(){
|
||||
function close(){
|
||||
$('#new_template_popup').css('display', 'none');
|
||||
}
|
||||
|
||||
function show(module){
|
||||
$('#new_template_popup').css('display', 'block');
|
||||
center($('#new_template_popup'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('#new_template_popup_save').click(function(){
|
||||
var messageBoxPopup = MessageBoxPopup();
|
||||
|
||||
if(trim(this.form.title.value) == '') {
|
||||
messageBoxPopup.show();
|
||||
$('#'+ 'empty_fields_message').show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#new_template_popup_close').click(close);
|
||||
$('#new_template_popup_cancel').click(close);
|
||||
return {
|
||||
close:close,show:show
|
||||
};
|
||||
}
|
||||
var newTemplatePopup = NewTemplatePopup();
|
||||
|
||||
function NewTaskPopup(){
|
||||
function close(){
|
||||
$('#new_task_popup').css('display', 'none');
|
||||
}
|
||||
|
||||
function show(module){
|
||||
$('#new_task_popup').css('display', 'block');
|
||||
center($('#new_task_popup'));
|
||||
}
|
||||
|
||||
$('#new_task_popup_close').click(close);
|
||||
$('#new_task_popup_cancel').click(close);
|
||||
return {
|
||||
close:close,show:show
|
||||
};
|
||||
}
|
||||
|
||||
var operations = function(){
|
||||
var op = {
|
||||
string:["is", "contains", "does not contain", "starts with", "ends with"],
|
||||
number:["equal to", "less than", "greater than", "does not equal",
|
||||
"less than or equal to", "greater than or equal to"],
|
||||
value:['is']
|
||||
};
|
||||
var mapping = [
|
||||
['string', ['string', 'text', 'url', 'email', 'phone']],
|
||||
['number', ['integer', 'double']],
|
||||
['value', ['reference', 'picklist', 'multipicklist', 'datetime',
|
||||
'time', 'date', 'boolean']]
|
||||
];
|
||||
|
||||
|
||||
var out = {};
|
||||
$.each(mapping, function(i, v){
|
||||
var opName = v[0];
|
||||
var types = v[1];
|
||||
$.each(types, function(i, v){
|
||||
out[v] = op[opName];
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}();
|
||||
|
||||
function defaultValue(fieldType){
|
||||
|
||||
function forPicklist(opType, condno){
|
||||
var value = $("#save_condition_"+condno+"_value");
|
||||
var options = implode('',
|
||||
map(function (e){return '<option value="'+e.value+'">'+e.label+'</option>';},
|
||||
opType['picklistValues'])
|
||||
);
|
||||
value.replaceWith('<select id="save_condition_'+condno+'_value" class="value">'+
|
||||
options+'</select>');
|
||||
}
|
||||
|
||||
function forInteger(opType, condno){
|
||||
var value = $(format("#save_condition_%s_value", condno));
|
||||
value.replaceWith(format('<input type="text" id="save_condition_%s_value" '+
|
||||
'value="0" class="value">', condno));
|
||||
}
|
||||
var functions = {
|
||||
string:function(opType, condno){
|
||||
var value = $(format("#save_condition_%s_value", condno));
|
||||
value.replaceWith(format('<input type="text" id="save_condition_%s_value" '+
|
||||
'value="" class="value">', condno));
|
||||
},
|
||||
'boolean': function(opType, condno){
|
||||
var value = $("#save_condition_"+condno+"_value");
|
||||
value.replaceWith(
|
||||
'<select id="save_condition_'+condno+'_value" value="true" class="value"> \
|
||||
<option value="true:boolean">True</option>\
|
||||
<option value="false:boolean">False</option>\
|
||||
</select>');
|
||||
},
|
||||
integer: forInteger,
|
||||
picklist:forPicklist,
|
||||
multipicklist:forPicklist
|
||||
};
|
||||
var ret = functions[fieldType];
|
||||
if(ret==null){
|
||||
ret = functions['string'];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
var format = fn.format;
|
||||
|
||||
|
||||
function fillOptions(el,options){
|
||||
el.empty();
|
||||
$.each(options, function(k, v){
|
||||
el.append('<option value="'+k+'">'+v+'</option>');
|
||||
});
|
||||
}
|
||||
|
||||
function resetFields(opType, condno){
|
||||
var ops = $("#save_condition_"+condno+"_operation");
|
||||
var selectedOperations = operations[opType.name];
|
||||
var l = dict(zip(selectedOperations, selectedOperations));
|
||||
fillOptions(ops, l);
|
||||
defaultValue(opType.name)(opType, condno);
|
||||
}
|
||||
|
||||
|
||||
function removeCondition(condno){
|
||||
$(format("#save_condition_%s", condno)).remove();
|
||||
}
|
||||
|
||||
//Convert user type into reference for consistency in describe objects
|
||||
//This is done inplace
|
||||
function referencify(desc){
|
||||
var fields = desc['fields'];
|
||||
for(var i=0; i<fields.length; i++){
|
||||
var field = fields[i];
|
||||
var type = field['type'];
|
||||
if(type['name']=='owner'){
|
||||
type['name']='reference';
|
||||
type['refersTo']=['Users'];
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
function getDescribeObjects(accessibleModules, moduleName, callback){
|
||||
vtinst.describeObject(moduleName, handleError(function(result){
|
||||
var parent = referencify(result);
|
||||
var fields = parent['fields'];
|
||||
var referenceFields = filter(function(e){return e['type']['name']=='reference';}, fields);
|
||||
var referenceFieldModules =
|
||||
map(function(e){ return e['type']['refersTo'];},
|
||||
referenceFields
|
||||
);
|
||||
function union(a, b){
|
||||
var newfields = filter(function(e){return !contains(a, e);}, b);
|
||||
return a.concat(newfields);
|
||||
}
|
||||
var relatedModules = reduceR(union, referenceFieldModules, [parent['name']]);
|
||||
|
||||
// Remove modules that is no longer accessible
|
||||
relatedModules = diff(accessibleModules, relatedModules);
|
||||
|
||||
function executer(parameters){
|
||||
var failures = filter(function(e){return e[0]==false;}, parameters);
|
||||
if(failures.length!=0){
|
||||
var firstFailure = failures[0];
|
||||
callback(false, firstFailure[1]);
|
||||
}else{
|
||||
var moduleDescriptions = map(function(e){return e[1];}, parameters);
|
||||
var modules = dict(map(function(e){return [e['name'], referencify(e)];}, moduleDescriptions));
|
||||
callback(true, modules);
|
||||
}
|
||||
}
|
||||
var p = parallelExecuter(executer, relatedModules.length);
|
||||
$.each(relatedModules, function(i, v){
|
||||
p(function(callback){vtinst.describeObject(v, callback);});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
fieldValidator = new VTFieldValidator($('#edit_workflow_form'));
|
||||
fieldValidator.mandatoryFields = ["description"];
|
||||
pageLoadingPopup.show();
|
||||
vtinst.extendSession(handleError(function(result){
|
||||
vtinst.listTypes(handleError(function(accessibleModules) {
|
||||
getDescribeObjects(accessibleModules, moduleName, handleError(function(modules){
|
||||
var parent = modules[moduleName];
|
||||
function filteredFields(fields){
|
||||
return filter(
|
||||
function(e){return !contains(['autogenerated', 'reference', 'owner', 'multipicklist', 'password'], e.type.name);}, fields
|
||||
);
|
||||
};
|
||||
var parentFields = map(function(e){return[e['name'],e['label']];}, filteredFields(parent['fields']));
|
||||
var referenceFieldTypes = filter(function(e){return (e['type']['name']=='reference')}, parent['fields']);
|
||||
var moduleFieldTypes = {};
|
||||
$.each(modules, function(k, v){
|
||||
moduleFieldTypes[k] = dict(map(function(e){return [e['name'], e['type']];},
|
||||
filteredFields(v['fields'])));
|
||||
});
|
||||
|
||||
function getFieldType(fullFieldName){
|
||||
var group = fullFieldName.match(/(\w+) : \((\w+)\) (\w+)/);
|
||||
if(group==null){
|
||||
var fieldModule = moduleName;
|
||||
var fieldName = fullFieldName;
|
||||
}else{
|
||||
var fieldModule = group[2];
|
||||
var fieldName = group[3];
|
||||
}
|
||||
return moduleFieldTypes[fieldModule][fieldName];
|
||||
}
|
||||
|
||||
function fieldReferenceNames(referenceField){
|
||||
var name = referenceField['name'];
|
||||
var label = referenceField['label'];
|
||||
function forModule(moduleName){
|
||||
// If module is not accessible return no field information
|
||||
if(!contains(accessibleModules, moduleName)) return [];
|
||||
|
||||
return map(function(field){
|
||||
return [name+' : '+'('+moduleName+') '+field['name'], label+' : '+'('+moduleName+') '+field['label']];},
|
||||
filteredFields(modules[moduleName]['fields'])
|
||||
);
|
||||
}
|
||||
return reduceR(concat, map(forModule,referenceField['type']['refersTo']),[]);
|
||||
}
|
||||
|
||||
|
||||
var referenceFields = reduceR(concat, map(fieldReferenceNames, referenceFieldTypes), []);
|
||||
var fieldLabels = dict(parentFields.concat(referenceFields));
|
||||
|
||||
function addCondition(condno){
|
||||
$("#save_conditions").append(
|
||||
'<div id="save_condition_'+condno+'" style=\'margin-bottom: 5px\'> \
|
||||
<select id="save_condition_'+condno+'_fieldname" class="fieldname"></select> \
|
||||
<select id="save_condition_'+condno+'_operation" class="operation"></select> \
|
||||
<input type="text" id="save_condition_'+condno+'_value" class="value"> \
|
||||
<span id="save_condition_'+condno+'_remove" class="link remove-link"> \
|
||||
<img src="modules/com_vtiger_workflow/resources/remove.png"></span> \
|
||||
</div>'
|
||||
);
|
||||
var fe = $("#save_condition_"+condno+"_fieldname");
|
||||
var i = 1;
|
||||
fillOptions(fe, fieldLabels);
|
||||
|
||||
|
||||
var fullFieldName = fe.attr("value");
|
||||
|
||||
resetFields(getFieldType(fullFieldName), condno);
|
||||
|
||||
var re = $("#save_condition_"+condno+"_remove");
|
||||
re.bind("click", function(){
|
||||
removeCondition(condno);
|
||||
});
|
||||
|
||||
fe.bind("change", function(){
|
||||
var select = $(this);
|
||||
var condNo = select.attr("id").match(/save_condition_(\d+)_fieldname/)[1];
|
||||
var fullFieldName = $(this).attr('value');
|
||||
resetFields(getFieldType(fullFieldName), condNo);
|
||||
});
|
||||
}
|
||||
|
||||
var newTaskPopup = NewTaskPopup();
|
||||
$("#new_task").click(function(){
|
||||
newTaskPopup.show();
|
||||
});
|
||||
|
||||
var newTemplatePopup = NewTemplatePopup();
|
||||
$("#new_template").click(function(){
|
||||
newTemplatePopup.show();
|
||||
});
|
||||
|
||||
var condno=0;
|
||||
if(conditions){
|
||||
$.each(conditions, function(i, condition){
|
||||
var fieldname = condition["fieldname"];
|
||||
addCondition(condno);
|
||||
$(format("#save_condition_%s_fieldname", condno)).attr("value", fieldname);
|
||||
resetFields(getFieldType(fieldname), condno);
|
||||
$(format("#save_condition_%s_operation", condno)).attr("value", condition["operation"]);
|
||||
$('#dump').html(condition["value"]);
|
||||
var text = $('#dump').text();
|
||||
$(format("#save_condition_%s_value", condno)).attr("value", text);
|
||||
condno+=1;
|
||||
});
|
||||
}
|
||||
|
||||
$("#save_conditions_add").bind("click", function(){
|
||||
addCondition(condno++);
|
||||
});
|
||||
|
||||
$("#save_submit").bind("click", function(){
|
||||
var conditions = [];
|
||||
$("#save_conditions").children().each(function(i){
|
||||
var fieldname = $(this).children(".fieldname").attr("value");
|
||||
var operation = $(this).children(".operation").attr("value");
|
||||
var value = $(this).children(".value").attr("value");
|
||||
var condition = {fieldname:fieldname, operation:operation, value:value};
|
||||
conditions[i]=condition;
|
||||
});
|
||||
if(conditions.length==0){
|
||||
var out = "";
|
||||
}else{
|
||||
var out = JSON.stringify(conditions);
|
||||
}
|
||||
$("#save_conditions_json").attr("value", out);
|
||||
});
|
||||
pageLoadingPopup.close();
|
||||
$('#save_conditions_add').show();
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
function VTEmailTask($){
|
||||
var vtinst = new VtigerWebservices("webservice.php");
|
||||
var desc = null;
|
||||
var accessibleModulesInfo = null;
|
||||
|
||||
var map = fn.map;
|
||||
var dict = fn.dict;
|
||||
var filter = fn.filter;
|
||||
var reduceR = fn.reduceR;
|
||||
var parallelExecuter = fn.parallelExecuter;
|
||||
var contains = fn.contains;
|
||||
var concat = fn.concat;
|
||||
|
||||
function diff(reflist, list) {
|
||||
var out = [];
|
||||
$.each(list, function(i, v) {
|
||||
if(contains(reflist, v)) {
|
||||
out.push(v);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
//Display an error message.
|
||||
function errorDialog(message){
|
||||
alert(message);
|
||||
}
|
||||
|
||||
//This is a wrapper to handle webservice errors.
|
||||
function handleError(fn){
|
||||
return function(status, result){
|
||||
if(status){
|
||||
fn(result);
|
||||
}else{
|
||||
errorDialog('Failure:'+result);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Insert text at the cursor
|
||||
function insertAtCursor(element, value){
|
||||
//http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript
|
||||
if (document.selection) {
|
||||
element.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = value;
|
||||
element.focus();
|
||||
}else if (element.selectionStart || element.selectionStart == '0') {
|
||||
var startPos = element.selectionStart;
|
||||
var endPos = element.selectionEnd;
|
||||
var scrollTop = element.scrollTop;
|
||||
element.value = element.value.substring(0, startPos)
|
||||
+ value
|
||||
+ element.value.substring(endPos,
|
||||
element.value.length);
|
||||
element.focus();
|
||||
element.selectionStart = startPos + value.length;
|
||||
element.selectionEnd = startPos + value.length;
|
||||
element.scrollTop = scrollTop;
|
||||
} else {
|
||||
element.value += value;
|
||||
element.focus();
|
||||
}
|
||||
}
|
||||
|
||||
//Convert user type into reference for consistency in describe objects
|
||||
//This is done inplace
|
||||
function referencify(desc){
|
||||
var fields = desc['fields'];
|
||||
for(var i=0; i<fields.length; i++){
|
||||
var field = fields[i];
|
||||
var type = field['type'];
|
||||
if(type['name']=='owner'){
|
||||
type['name']='reference';
|
||||
type['refersTo']=['Users'];
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
//Get an array containing the the description of a module and all modules
|
||||
//refered to by it. This is passed to callback.
|
||||
function getDescribeObjects(accessibleModules, moduleName, callback){
|
||||
vtinst.describeObject(moduleName, handleError(function(result){
|
||||
var parent = referencify(result);
|
||||
var fields = parent['fields'];
|
||||
var referenceFields = filter(function(e){
|
||||
return e['type']['name']=='reference';},
|
||||
fields);
|
||||
var referenceFieldModules =
|
||||
map(
|
||||
function(e){
|
||||
return e['type']['refersTo'];
|
||||
},
|
||||
referenceFields
|
||||
);
|
||||
function union(a, b){
|
||||
var newfields = filter(function(e){return !contains(a, e);}, b);
|
||||
return a.concat(newfields);
|
||||
}
|
||||
var relatedModules = reduceR(union, referenceFieldModules, [parent['name']]);
|
||||
|
||||
// Remove modules that is no longer accessible
|
||||
relatedModules = diff(accessibleModules, relatedModules);
|
||||
|
||||
function executer(parameters){
|
||||
var failures = filter(function(e){return e[0]==false;}, parameters);
|
||||
if(failures.length!=0){
|
||||
var firstFailure = failures[0];
|
||||
callback(false, firstFailure[1]);
|
||||
}else{
|
||||
var moduleDescriptions = map(function(e){
|
||||
return referencify(e[1]);},
|
||||
parameters);
|
||||
var modules = dict(map(function(e){
|
||||
return [e['name'], e];},
|
||||
moduleDescriptions));
|
||||
callback(true, modules);
|
||||
}
|
||||
}
|
||||
var p = parallelExecuter(executer, relatedModules.length);
|
||||
$.each(relatedModules, function(i, v){
|
||||
p(function(callback){vtinst.describeObject(v, callback);});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function fillSelectBox(id, modules, parentModule, filterPred){
|
||||
if(filterPred==null){
|
||||
filterPred = function(){
|
||||
return true;
|
||||
};
|
||||
}
|
||||
var parent = modules[parentModule];
|
||||
var fields = parent['fields'];
|
||||
|
||||
function filteredFields(fields){
|
||||
return filter(
|
||||
function(e){
|
||||
var fieldCheck = !contains(['autogenerated', 'reference', 'owner', 'multipicklist', 'password'], e.type.name);
|
||||
var predCheck = filterPred(e);
|
||||
return fieldCheck && predCheck;
|
||||
},
|
||||
fields
|
||||
);
|
||||
}
|
||||
var parentFields = map(function(e){return[e['name'],e['label']];}, filteredFields(parent['fields']));
|
||||
|
||||
var referenceFieldTypes = filter(function(e){
|
||||
return (e['type']['name']=='reference');
|
||||
},parent['fields']
|
||||
);
|
||||
|
||||
var moduleFieldTypes = {};
|
||||
$.each(modules, function(k, v){
|
||||
moduleFieldTypes[k] = dict(map(function(e){return [e['name'], e['type']];},filteredFields(v['fields'])));
|
||||
}
|
||||
);
|
||||
|
||||
function getFieldType(fullFieldName){
|
||||
var group = fullFieldName.match(/(\w+) : \((\w+)\) (\w+)/);
|
||||
if(group==null){
|
||||
var fieldModule = moduleName;
|
||||
var fieldName = fullFieldName;
|
||||
}else{
|
||||
var fieldModule = group[2];
|
||||
var fieldName = group[3];
|
||||
}
|
||||
return moduleFieldTypes[fieldModule][fieldName];
|
||||
}
|
||||
|
||||
function fieldReferenceNames(referenceField){
|
||||
var name = referenceField['name'];
|
||||
var label = referenceField['label'];
|
||||
function forModule(moduleName){
|
||||
// If module is not accessible return no field information
|
||||
if(!contains(accessibleModulesInfo, moduleName)) return [];
|
||||
|
||||
return map(function(field){
|
||||
return ['('+name+' : '+'('+moduleName+') '+field['name']+')',label+' : '+'('+moduleName+') '+field['label']];
|
||||
},
|
||||
filteredFields(modules[moduleName]['fields']));
|
||||
}
|
||||
return reduceR(concat,map(forModule,referenceField['type']['refersTo']),[]);
|
||||
}
|
||||
|
||||
var referenceFields = reduceR(concat,map(fieldReferenceNames,referenceFieldTypes), []);
|
||||
var fieldLabels = dict(parentFields.concat(referenceFields));
|
||||
var select = $('#'+id);
|
||||
var optionClass = id+'_option';
|
||||
$.each(fieldLabels, function(k, v){
|
||||
select.append('<option class="'+optionClass+'" '+ 'value="'+k+'">' + v + '</option>');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
vtinst.extendSession(handleError(function(result){
|
||||
vtinst.listTypes(handleError(function(accessibleModules) {
|
||||
accessibleModulesInfo = accessibleModules;
|
||||
|
||||
getDescribeObjects(accessibleModules, moduleName, handleError(function(modules){
|
||||
fillSelectBox('task-fieldnames', modules, moduleName);
|
||||
$('#task-fieldnames-busyicon').hide();
|
||||
$('#task-fieldnames').show();
|
||||
$('#task-fieldnames').change(function(){
|
||||
var textarea = CKEDITOR.instances.save_content;
|
||||
var value = '$'+jQuery(this).attr('value');
|
||||
textarea.insertHtml(value);
|
||||
});
|
||||
|
||||
fillSelectBox('task-emailfields', modules, moduleName,
|
||||
function(e){return e['type']['name']=='email';});
|
||||
$('#task-emailfields-busyicon').hide();
|
||||
$('#task-emailfields').show();
|
||||
$('#task-emailfields').change(function(){
|
||||
var input = $($('#save_recepient').get());
|
||||
var value = '$'+$(this).attr('value');
|
||||
input.attr("value", input.attr("value")+','+value);
|
||||
});
|
||||
var selptype = document.getElementById('task-emailfields');
|
||||
var selecc = document.getElementById('task-emailfieldscc');
|
||||
for (ops=0;ops<selptype.length;ops++) {
|
||||
selecc.options[ops] = new Option(selptype.options[ops].text, selptype.options[ops].value);
|
||||
}
|
||||
$('#task-emailfieldscc-busyicon').hide();
|
||||
$('#task-emailfieldscc').show();
|
||||
$('#task-emailfieldscc').change(function(){
|
||||
var input = $($('#save_emailcc').get());
|
||||
var value = '$'+$(this).attr('value');
|
||||
input.attr("value", input.attr("value")+','+value);
|
||||
});
|
||||
var selebcc = document.getElementById('task-emailfieldsbcc');
|
||||
for (ops=0;ops<selptype.length;ops++) {
|
||||
selebcc.options[ops] = new Option(selptype.options[ops].text, selptype.options[ops].value);
|
||||
}
|
||||
$('#task-emailfieldsbcc-busyicon').hide();
|
||||
$('#task-emailfieldsbcc').show();
|
||||
$('#task-emailfieldsbcc').change(function(){
|
||||
var input = $($('#save_emailbcc').get());
|
||||
var value = '$'+$(this).attr('value');
|
||||
input.attr("value", input.attr("value")+','+value);
|
||||
});
|
||||
|
||||
//time_changes
|
||||
$('#task_timefields').change(function(){
|
||||
var textarea = CKEDITOR.instances.save_content;
|
||||
var value = '$'+$(this).attr('value');
|
||||
textarea.insertHtml(value);
|
||||
});
|
||||
|
||||
//changes
|
||||
fillSelectBox('task-group_usersnames', modules, moduleName);
|
||||
$('#task-fieldnames-busyicon').hide();
|
||||
$('#task-group_usersnames').show();
|
||||
$('#task-group_usersnames').change(function(){
|
||||
var textarea = $('#save_receipent').get(0);
|
||||
var value = '$'+$(this).attr('value');
|
||||
insertAtCursor(textarea, value);
|
||||
});
|
||||
}));
|
||||
|
||||
}));
|
||||
|
||||
}));
|
||||
//Setup the validator
|
||||
validator.mandatoryFields.push('recepient');
|
||||
validator.mandatoryFields.push('subject');
|
||||
});
|
||||
}
|
||||
vtEmailTask = VTEmailTask(jQuery);
|
||||
@@ -1,88 +0,0 @@
|
||||
function MessageBoxPopup(){
|
||||
function center(el){
|
||||
el.css({position: 'absolute'});
|
||||
el.width("400px");
|
||||
el.height("110px");
|
||||
placeAtCenter(el.get(0));
|
||||
}
|
||||
|
||||
function close(){
|
||||
jQuery('#error_message_box').css('display', 'none');
|
||||
}
|
||||
|
||||
function show(module){
|
||||
if(typeof('VtigerJS_DialogBox') != 'undefined') VtigerJS_DialogBox.unblock();
|
||||
jQuery('#error_message_box').css('display', 'block');
|
||||
center(jQuery('#error_message_box'));
|
||||
}
|
||||
|
||||
jQuery('#error_message_box_close').click(close);
|
||||
jQuery('#error_message_box_cancel').click(close);
|
||||
return {
|
||||
close:close,show:show
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var validateMandatoryFields = {
|
||||
init: function(){
|
||||
this.mandatoryFields = [];
|
||||
},
|
||||
validator: function (){
|
||||
var emptyFields = [];
|
||||
var result;
|
||||
var mandatoryFields = this.mandatoryFields;
|
||||
for(var i = 0; i < mandatoryFields.length; i++){
|
||||
var fieldName = mandatoryFields[i];
|
||||
if(this.fieldValue(fieldName)==""){
|
||||
emptyFields.push(fieldName);
|
||||
}
|
||||
}
|
||||
if(emptyFields.length!=0){
|
||||
result = [false, 'empty_fields_message', emptyFields];
|
||||
}else{
|
||||
result = [true];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
var VTFieldValidatorPrototype = {
|
||||
validate: function(){
|
||||
var isValid = true;
|
||||
var validators = this.validators;
|
||||
for(var i = 0; i < validators.length; i++){
|
||||
var validator = validators[i];
|
||||
var result = validator.call(this);
|
||||
if(result[0]==false){
|
||||
jQuery('#'+result[1]).css('display', 'block');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
if(!isValid){
|
||||
this.messageBoxPopup.show();
|
||||
}
|
||||
return isValid;
|
||||
},
|
||||
addValidator: function(name, validator){
|
||||
validator.init.call(this);
|
||||
this.validators.push(validator.validator);
|
||||
},
|
||||
fieldValue: function(fieldName){
|
||||
return this.form.find('[name='+fieldName+']').val();
|
||||
}
|
||||
};
|
||||
|
||||
function VTFieldValidator(form){
|
||||
var _this = this;
|
||||
_this.form = form;
|
||||
_this.messageBoxPopup = MessageBoxPopup();
|
||||
form.submit(function(){
|
||||
return _this.validate();
|
||||
});
|
||||
_this.validators = [];
|
||||
_this.addValidator('mandatoryFields', validateMandatoryFields);
|
||||
}
|
||||
|
||||
VTFieldValidator.prototype = VTFieldValidatorPrototype;
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
function functional($){
|
||||
return {
|
||||
|
||||
/**
|
||||
* Test:
|
||||
* fn.format("Hello %s", "world") == "Hello world"
|
||||
*/
|
||||
format: function(){
|
||||
var i=1;
|
||||
var fmtStr = arguments[0];
|
||||
var args = arguments;
|
||||
return fmtStr.replace(/%s/g,function(){return args[i++];})
|
||||
},
|
||||
|
||||
addStylesheet: function(url){
|
||||
/*From: http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS*/
|
||||
var headID = document.getElementsByTagName("head")[0];
|
||||
var cssNode = document.createElement('link');
|
||||
cssNode.type = 'text/css';
|
||||
cssNode.rel = 'stylesheet';
|
||||
cssNode.href = url;
|
||||
cssNode.media = 'screen';
|
||||
headID.appendChild(cssNode);
|
||||
},
|
||||
|
||||
id: function(v){
|
||||
return v;
|
||||
},
|
||||
|
||||
map: function(fn, list){
|
||||
var out = [];
|
||||
$.each(list, function(i, v){
|
||||
out[out.length]=fn(v);
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
field: function(name){
|
||||
return function(object){
|
||||
return object[name];
|
||||
}
|
||||
},
|
||||
|
||||
zip: function(){
|
||||
var out = [];
|
||||
|
||||
var lengths = map(field('length'), arguments);
|
||||
var min = reduceR(function(a,b){return a<b?a:b},lengths,lengths[0]);
|
||||
for(var i=0; i<min; i++){
|
||||
out[i]=map(field(i), arguments);
|
||||
}
|
||||
return out;
|
||||
},
|
||||
|
||||
dict: function(list){
|
||||
var out = {};
|
||||
$.each(list, function(i, v){
|
||||
out[v[0]] = v[1];
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
filter: function(pred, list){
|
||||
var out = [];
|
||||
$.each(list, function(i, v){
|
||||
if(pred(v)){
|
||||
out[out.length]=v;
|
||||
}
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
reduceR: function(fn, list, start){
|
||||
var acc = start;
|
||||
$.each(list, function(i, v){
|
||||
acc = fn(acc, v);
|
||||
});
|
||||
return acc;
|
||||
},
|
||||
|
||||
contains: function(list, value){
|
||||
var ans = false;
|
||||
$.each(list, function(i, v){
|
||||
if(v==value){
|
||||
ans = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return ans;
|
||||
},
|
||||
|
||||
concat: function(lista,listb){
|
||||
return lista.concat(listb);
|
||||
},
|
||||
|
||||
|
||||
mergeObjects: function(obj1, obj2){
|
||||
var res = {};
|
||||
for(var k in obj1){
|
||||
res[k] = obj1[k];
|
||||
}
|
||||
for(var k in obj2){
|
||||
res[k] = obj2[k];
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
parallelExecuter: function(executer, operationCount){
|
||||
var parameters = [];
|
||||
var n = 0;
|
||||
var ctr = 0;
|
||||
function makeParallel(operation){
|
||||
var id = n;
|
||||
n++;
|
||||
function cookie(){
|
||||
parameters[id] = arguments;
|
||||
ctr++;
|
||||
if(ctr == operationCount){
|
||||
executer(parameters);
|
||||
}
|
||||
}
|
||||
operation(cookie);
|
||||
}
|
||||
return makeParallel;
|
||||
},
|
||||
/*
|
||||
*Convert the last parameter into a list argument
|
||||
*/
|
||||
larg: function (fn){
|
||||
var arity = fn.arity;
|
||||
var nparams = arity-1;
|
||||
return function(){
|
||||
if(nparams>arguments.length){
|
||||
nparams = arguments.length;
|
||||
}
|
||||
|
||||
var args = [];
|
||||
for(var i=0;i<nparams;i++){
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
var largs = [];
|
||||
alert(arguments.length-nparams);
|
||||
for(var i=0, n=arguments.length-nparams;i<n;i++){
|
||||
largs[i]=arguments[nparams+i];
|
||||
}
|
||||
args[args.length]=largs;
|
||||
return fn.apply(this, args);
|
||||
}
|
||||
},
|
||||
|
||||
htmlentities: function(s){
|
||||
var out = "";
|
||||
for(var i = 0; i<s.length;i++){
|
||||
out+="&#"+s.charCodeAt(i)+";"
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn = functional(jQuery);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
File diff suppressed because it is too large
Load Diff
@@ -1,119 +0,0 @@
|
||||
/* jQuery timepicker
|
||||
* replaces a single text input with a set of pulldowns to select hour, minute, and am/pm
|
||||
*
|
||||
* Copyright (c) 2007 Jason Huck/Core Five Creative (http://www.corefive.com/)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*
|
||||
* Version 1.0
|
||||
*/
|
||||
|
||||
(function($){
|
||||
jQuery.fn.timepicker = function(){
|
||||
this.each(function(){
|
||||
// get the ID and value of the current element
|
||||
var i = this.id;
|
||||
var v = $(this).val();
|
||||
|
||||
// the options we need to generate
|
||||
var hrs = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
|
||||
var mins = new Array('00','15','30','45');
|
||||
var ap = new Array('am','pm');
|
||||
|
||||
// default to the current time
|
||||
var d = new Date;
|
||||
var h = d.getHours();
|
||||
var m = d.getMinutes();
|
||||
var p = (h >= 12 ? 'pm' : 'am');
|
||||
|
||||
// adjust hour to 12-hour format
|
||||
if(h > 12) h = h - 12;
|
||||
|
||||
// round minutes to nearest quarter hour
|
||||
$.each(mins, function(mn){
|
||||
if(m <= parseInt(mins[mn], 10)){
|
||||
m = parseInt(mins[mn], 10);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// increment hour if we push minutes to next 00
|
||||
if(m > 45){
|
||||
m = 0;
|
||||
|
||||
switch(h){
|
||||
case(11):
|
||||
h += 1;
|
||||
p = (p == 'am' ? 'pm' : 'am');
|
||||
break;
|
||||
|
||||
case(12):
|
||||
h = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
h += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// override with current values if applicable
|
||||
if(v.length == 7){
|
||||
h = parseInt(v.substr(0,2), 10);
|
||||
m = parseInt(v.substr(3,2), 10);
|
||||
p = v.substr(5);
|
||||
}
|
||||
|
||||
// build the new DOM objects
|
||||
var output = '';
|
||||
|
||||
output += '<select id="h_' + i + '" class="h timepicker">';
|
||||
$.each(hrs, function(hr){
|
||||
output += '<option value="' + hrs[hr] + '"';
|
||||
if(parseInt(hrs[hr], 10) == h) output += ' selected';
|
||||
output += '>' + hrs[hr] + '</option>';
|
||||
});
|
||||
output += '</select>';
|
||||
|
||||
output += '<select id="m_' + i + '" class="m timepicker">';
|
||||
$.each(mins, function(mn){
|
||||
output += '<option value="' + mins[mn] + '"';
|
||||
if(parseInt(mins[mn], 10) == m) output += ' selected';
|
||||
output += '>' + mins[mn] + '</option>';
|
||||
});
|
||||
output += '</select>';
|
||||
|
||||
output += '<select id="p_' + i + '" class="p timepicker">';
|
||||
$.each(ap, function(pp){
|
||||
output += '<option value="' + ap[pp] + '"';
|
||||
if(ap[pp] == p) output += ' selected';
|
||||
output += '>' + ap[pp] + '</option>';
|
||||
});
|
||||
output += '</select>';
|
||||
|
||||
// hide original input and append new replacement inputs
|
||||
//$(this).attr('type','hidden').after(output);
|
||||
$(this).after(output);
|
||||
|
||||
// Initialize the default value
|
||||
if(v == '') {
|
||||
$(this).val( h + ':' + m + p );
|
||||
}
|
||||
});
|
||||
|
||||
$('select.timepicker').change(function(){
|
||||
var i = this.id.substr(2);
|
||||
var h = $('#h_' + i).val();
|
||||
var m = $('#m_' + i).val();
|
||||
var p = $('#p_' + i).val();
|
||||
var v = h + ':' + m + p;
|
||||
$('#' + i).val(v);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
|
||||
/* SVN: $Id: jquery.timepicker.js 456 2007-07-16 19:09:57Z Jason Huck $ */
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
json2.js
|
||||
2007-11-06
|
||||
|
||||
Public Domain
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
This file creates a global JSON object containing two methods:
|
||||
|
||||
JSON.stringify(value, whitelist)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
whitelist an optional that determines how object values are
|
||||
stringified.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
There are three possible ways to stringify an object, depending
|
||||
on the optional whitelist parameter.
|
||||
|
||||
If an object has a toJSON method, then the toJSON() method will be
|
||||
called. The value returned from the toJSON method will be
|
||||
stringified.
|
||||
|
||||
Otherwise, if the optional whitelist parameter is an array, then
|
||||
the elements of the array will be used to select members of the
|
||||
object for stringification.
|
||||
|
||||
Otherwise, if there is no whitelist parameter, then all of the
|
||||
members of the object will be stringified.
|
||||
|
||||
Values that do not have JSON representaions, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped, in arrays will be replaced with null. JSON.stringify()
|
||||
returns undefined. Dates will be stringified as quoted ISO dates.
|
||||
|
||||
Example:
|
||||
|
||||
var text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
JSON.parse(text, filter)
|
||||
This method parses a JSON text to produce an object or
|
||||
array. It can throw a SyntaxError exception.
|
||||
|
||||
The optional filter parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values, and
|
||||
its return value is used instead of the original value. If it
|
||||
returns what it received, then structure is not modified. If it
|
||||
returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. If a key contains the string 'date' then
|
||||
// convert the value to a date.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
return key.indexOf('date') >= 0 ? new Date(value) : value;
|
||||
});
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
|
||||
Use your own copy. It is extremely unwise to load third party
|
||||
code into your pages.
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
/*extern JSON */
|
||||
|
||||
if (!this.JSON) {
|
||||
|
||||
JSON = function () {
|
||||
|
||||
function f(n) { // Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
Date.prototype.toJSON = function () {
|
||||
|
||||
// Eventually, this method will be based on the date.toISOString method.
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
|
||||
var m = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
|
||||
function stringify(value, whitelist) {
|
||||
var a, // The array holding the partial texts.
|
||||
i, // The loop counter.
|
||||
k, // The member key.
|
||||
l, // Length.
|
||||
r = /["\\\x00-\x1f\x7f-\x9f]/g,
|
||||
v; // The member value.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe sequences.
|
||||
|
||||
return r.test(value) ?
|
||||
'"' + value.replace(r, function (a) {
|
||||
var c = m[a];
|
||||
if (c) {
|
||||
return c;
|
||||
}
|
||||
c = a.charCodeAt();
|
||||
return '\\u00' + Math.floor(c / 16).toString(16) +
|
||||
(c % 16).toString(16);
|
||||
}) + '"' :
|
||||
'"' + value + '"';
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
return String(value);
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript,
|
||||
// typeof null is 'object', so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// If the object has a toJSON method, call it, and stringify the result.
|
||||
|
||||
if (typeof value.toJSON === 'function') {
|
||||
return stringify(value.toJSON());
|
||||
}
|
||||
a = [];
|
||||
if (typeof value.length === 'number' &&
|
||||
!(value.propertyIsEnumerable('length'))) {
|
||||
|
||||
// The object is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
l = value.length;
|
||||
for (i = 0; i < l; i += 1) {
|
||||
a.push(stringify(value[i], whitelist) || 'null');
|
||||
}
|
||||
|
||||
// Join all of the elements together and wrap them in brackets.
|
||||
|
||||
return '[' + a.join(',') + ']';
|
||||
}
|
||||
if (whitelist) {
|
||||
|
||||
// If a whitelist (array of keys) is provided, use it to select the components
|
||||
// of the object.
|
||||
|
||||
l = whitelist.length;
|
||||
for (i = 0; i < l; i += 1) {
|
||||
k = whitelist[i];
|
||||
if (typeof k === 'string') {
|
||||
v = stringify(value[k], whitelist);
|
||||
if (v) {
|
||||
a.push(stringify(k) + ':' + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (typeof k === 'string') {
|
||||
v = stringify(value[k], whitelist);
|
||||
if (v) {
|
||||
a.push(stringify(k) + ':' + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together and wrap them in braces.
|
||||
|
||||
return '{' + a.join(',') + '}';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
stringify: stringify,
|
||||
parse: function (text, filter) {
|
||||
var j;
|
||||
|
||||
function walk(k, v) {
|
||||
var i, n;
|
||||
if (v && typeof v === 'object') {
|
||||
for (i in v) {
|
||||
if (Object.prototype.hasOwnProperty.apply(v, [i])) {
|
||||
n = walk(i, v[i]);
|
||||
if (n !== undefined) {
|
||||
v[i] = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return filter(k, v);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in three stages. In the first stage, we run the text against
|
||||
// regular expressions that look for non-JSON patterns. We are especially
|
||||
// concerned with '()' and 'new' because they can cause invocation, and '='
|
||||
// because it can cause mutation. But just to be safe, we want to reject all
|
||||
// unexpected forms.
|
||||
|
||||
// We split the first stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace all backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').
|
||||
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g, ']').
|
||||
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the second stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional third stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a filter function for possible transformation.
|
||||
|
||||
return typeof filter === 'function' ? walk('', j) : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('parseJSON');
|
||||
}
|
||||
};
|
||||
}();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
function parallelExecuter(executer, operationCount){
|
||||
var parameters = [];
|
||||
var n = 0;
|
||||
var ctr = 0;
|
||||
function makeParallel(operation){
|
||||
var id = n;
|
||||
n++;
|
||||
function cookie(){
|
||||
parameters[id] = arguments;
|
||||
ctr++;
|
||||
if(ctr == operationCount){
|
||||
executer(parameters);
|
||||
}
|
||||
}
|
||||
operation(cookie);
|
||||
}
|
||||
return makeParallel;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 198 B |
@@ -1,80 +0,0 @@
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
|
||||
.popup_content{
|
||||
padding: 0.5em;
|
||||
margin:0.5em;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* From http://www.quirksmode.org/css/forms.html*/
|
||||
.form_label .form_input{
|
||||
display: block;
|
||||
/*width: 150px;*/
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.form_input{
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.form_label {
|
||||
text-align: right;
|
||||
width: 75px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.form_br {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
.value{
|
||||
display: inline-block;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.operation{
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.link{
|
||||
text-decoration: underline
|
||||
}
|
||||
.link:hover{
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
#select_date_days{
|
||||
width:50px;
|
||||
}
|
||||
|
||||
.box{
|
||||
background-color: white;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.box_cel{
|
||||
display: inline-block;
|
||||
width: 2em;
|
||||
height:2em;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.row_selected{
|
||||
color:white;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
/* similar to .small class defined themes/softed/style.css */
|
||||
.fieldname, .operation, .value, .form_input, .time_field, .timepicker {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
color: #000000;
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
function vtigerwebservicesproto(){
|
||||
var $ = jQuery;
|
||||
function md5(str){
|
||||
return hex_md5(str);
|
||||
}
|
||||
|
||||
function mergeObjects(obj1, obj2){
|
||||
var res = {};
|
||||
for(var k in obj1){
|
||||
res[k] = obj1[k];
|
||||
}
|
||||
for(var k in obj2){
|
||||
res[k] = obj2[k];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function doGet(params, callback){
|
||||
$.get(this.serviceUrl, params, function(result){
|
||||
var parsed = JSON.parse(result);
|
||||
callback(parsed);
|
||||
});
|
||||
}
|
||||
|
||||
function doPost(params, callback){
|
||||
$.post(this.serviceUrl, params, function(result){
|
||||
var parsed = JSON.parse(result);
|
||||
callback(parsed);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function get(operation, parameters, callback){
|
||||
response = this.doGet(mergeObjects(parameters,
|
||||
{'operation':operation, 'sessionName':this.sessionId}), function(response){
|
||||
if(response['success']==true){
|
||||
callback(true,response['result']);
|
||||
}else{
|
||||
callback(false,response['error']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function post(operation, parameters, callback){
|
||||
response = this.doPost(mergeObjects(parameters,
|
||||
{'operation':operation, 'sessionName':this.sessionId}), function(response){
|
||||
if(response['success']==true){
|
||||
callback(true,response['result']);
|
||||
}else{
|
||||
callback(false,response['error']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function login(callback){
|
||||
var self = this;
|
||||
response = this.doGet({operation:'getchallenge', username:this.username}, function(response){
|
||||
if(response['success']==true){
|
||||
var token = response['result']['token'];
|
||||
var encodedKey = md5(token+self.accessKey);
|
||||
self.doPost({operation:'login', username: self.username, accessKey: encodedKey}, function (response){
|
||||
if(response['success']==true){
|
||||
self.sessionId = response['result']['sessionName'];
|
||||
self.userId = response['result']['userId'];
|
||||
callback(true);
|
||||
}else{
|
||||
callback(false,response['error']);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
callback(false,response['error']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function logout(callback){
|
||||
this.post('logout', {}, callback);
|
||||
}
|
||||
|
||||
function listTypes(callback){
|
||||
this.get('listtypes', {}, function (status, result){
|
||||
if(status){
|
||||
callback(true, result['types']);
|
||||
}else{
|
||||
callback(false, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function describeObject(name, callback){
|
||||
this.get('describe', {'elementType':name}, callback);
|
||||
}
|
||||
|
||||
function create(object, objectType, callback){
|
||||
if(object['assigned_user_id']==null){
|
||||
object['assigned_user_id'] = this.userId;
|
||||
}
|
||||
objectJson = JSON.encode(object);
|
||||
this.post('create', {'elementType':objectType,
|
||||
'element':objectJson}, callback);
|
||||
}
|
||||
|
||||
function retrieve(id, callback){
|
||||
this.get('retrieve', {'id':id}, callback);
|
||||
}
|
||||
|
||||
function update(object, callback){
|
||||
objectJson = JSON.encode(object);
|
||||
this.post('update', {'element':objectJson}, callback);
|
||||
}
|
||||
|
||||
|
||||
function deleteObject(id, callback){
|
||||
this.post('delete', {'id':id}, callback);
|
||||
}
|
||||
|
||||
function query(query, callback){
|
||||
this.get('query', {'query':query}, callback);
|
||||
}
|
||||
|
||||
function extendSession(callback){
|
||||
var self = this;
|
||||
this.doPost({operation: 'extendsession'}, function(response){
|
||||
var status = response['success'];
|
||||
var result = response['result'];
|
||||
if(status==true){
|
||||
self.sessionId = result['sessionName'];
|
||||
self.userId = result['userId'];
|
||||
callback(true, result);
|
||||
}else{
|
||||
callback(false, result);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
doPost:doPost, doGet:doGet,
|
||||
get:get, post:post,
|
||||
login:login, logout:logout,
|
||||
listTypes:listTypes, describeObject:describeObject,
|
||||
create:create, retrieve:retrieve, update:update, deleteObject:deleteObject,
|
||||
query:query, extendSession: extendSession
|
||||
}
|
||||
}
|
||||
|
||||
function VtigerWebservices(serviceUrl, username, accessKey){
|
||||
this.serviceUrl = serviceUrl;
|
||||
this.username = username;
|
||||
this.accessKey = accessKey;
|
||||
}
|
||||
VtigerWebservices.prototype = vtigerwebservicesproto();
|
||||
|
||||
vtInst = new VtigerWebservices("http://localhost/504/webservice.php", "admin", "u1p8CDnxtCFwBRMZ");
|
||||
@@ -1,131 +0,0 @@
|
||||
/*+********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
********************************************************************************/
|
||||
|
||||
jQuery.noConflict();
|
||||
function workflowlistscript($){
|
||||
|
||||
|
||||
function jsonget(operation, params, callback){
|
||||
var obj = {
|
||||
module:'com_vtiger_workflow',
|
||||
action:'com_vtiger_workflowAjax',
|
||||
file:operation, ajax:'true'};
|
||||
$.each(params,function(key, value){
|
||||
obj[key] = value;
|
||||
});
|
||||
$.get('index.php', obj,
|
||||
function(result){
|
||||
var parsed = JSON.parse(result);
|
||||
callback(parsed);
|
||||
});
|
||||
}
|
||||
|
||||
function center(el){
|
||||
el.css({position: 'absolute'});
|
||||
el.width("400px");
|
||||
el.height("175px");
|
||||
placeAtCenter(el.get(0));
|
||||
}
|
||||
|
||||
function NewWorkflowPopup(){
|
||||
function close(){
|
||||
$('#new_workflow_popup').css('display', 'none');
|
||||
}
|
||||
|
||||
function show(module){
|
||||
$('#new_workflow_popup').css('display', 'block');
|
||||
center($('#new_workflow_popup'));
|
||||
}
|
||||
|
||||
$('#new_workflow_popup_close').click(close);
|
||||
$('#new_workflow_popup_cancel').click(close);
|
||||
return {
|
||||
close:close,show:show
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var workflowCreationMode='from_module';
|
||||
var templatesForModule = {};
|
||||
function updateTemplateList(){
|
||||
var moduleSelect = $('#module_list');
|
||||
var currentModule = moduleSelect.attr('value');
|
||||
|
||||
$('#template_list').hide();
|
||||
$('#template_list_foundnone').hide();
|
||||
$('#template_list_busyicon').show();
|
||||
|
||||
function fillTemplateList(templates){
|
||||
var templateSelect = $('#template_list');
|
||||
templateSelect.empty();
|
||||
|
||||
$.each(templates, function(i, v){
|
||||
templateSelect.append('<option value="'+v['id']+'">'+
|
||||
v['title']+'</option>');
|
||||
});
|
||||
if(templateSelect.children().length > 0) { templateSelect.show(); }
|
||||
else { $('#template_list_foundnone').show(); }
|
||||
$('#template_list_busyicon').hide();
|
||||
|
||||
}
|
||||
if(templatesForModule[currentModule]==null){
|
||||
|
||||
jsonget('templatesformodulejson',{module_name:currentModule},
|
||||
function(templates){
|
||||
templatesForModule[currentModule] = templates;
|
||||
fillTemplateList(templatesForModule[currentModule]);
|
||||
});
|
||||
}else{
|
||||
fillTemplateList(templatesForModule[currentModule]);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var newWorkflowPopup = NewWorkflowPopup();
|
||||
$("#new_workflow").click(newWorkflowPopup.show);
|
||||
$("#pick_module").change(function(){
|
||||
VtigerJS_DialogBox.block();
|
||||
$("#filter_modules").submit();
|
||||
});
|
||||
|
||||
|
||||
$('.workflow_creation_mode').click(function(){
|
||||
var el = $(this);
|
||||
workflowCreationMode = el.attr('value');
|
||||
if(workflowCreationMode=='from_template'){
|
||||
updateTemplateList();
|
||||
$('#template_select_field').show();
|
||||
}else{
|
||||
$('#template_select_field').hide();
|
||||
}
|
||||
|
||||
});
|
||||
$('#module_list').change(function(){
|
||||
if(workflowCreationMode=='from_template'){
|
||||
updateTemplateList();
|
||||
}
|
||||
});
|
||||
|
||||
var filterModule = $('#pick_module').attr('value');
|
||||
if(filterModule!='All'){
|
||||
$('#module_list').attr('value', filterModule);
|
||||
$('#module_list').change();
|
||||
}
|
||||
|
||||
$('#new_workflow_popup_save').click(function() {
|
||||
if(workflowCreationMode == 'from_template') {
|
||||
// No templates selected?
|
||||
if($('#template_list').attr('value') == '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
workflowlistscript(jQuery);
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
ini_set('include_path',ini_get('include_path').':../..');
|
||||
|
||||
require_once("config.inc.php");
|
||||
require_once("include/HTTP_Session/Session.php");
|
||||
require_once 'include/Webservices/Utils.php';
|
||||
require_once("modules/Users/Users.php");
|
||||
require_once("include/Webservices/State.php");
|
||||
require_once("include/Webservices/OperationManager.php");
|
||||
require_once("include/Webservices/SessionManager.php");
|
||||
require_once("include/Zend/Json.php");
|
||||
require_once 'include/Webservices/WebserviceField.php';
|
||||
require_once 'include/Webservices/EntityMeta.php';
|
||||
require_once 'include/Webservices/VtigerWebserviceObject.php';
|
||||
require_once("include/Webservices/VtigerCRMObject.php");
|
||||
require_once("include/Webservices/VtigerCRMObjectMeta.php");
|
||||
require_once("include/Webservices/DataTransform.php");
|
||||
require_once("include/Webservices/WebServiceError.php");
|
||||
require_once 'include/utils/CommonUtils.php';
|
||||
require_once 'include/utils/utils.php';
|
||||
require_once 'include/utils/UserInfoUtil.php';
|
||||
require_once 'include/Webservices/ModuleTypes.php';
|
||||
require_once 'include/utils/VtlibUtils.php';
|
||||
require_once('include/logging.php');
|
||||
require_once 'include/Webservices/WebserviceEntityOperation.php';
|
||||
require_once "include/language/$default_language.lang.php";
|
||||
require_once 'include/Webservices/Retrieve.php';
|
||||
require_once('modules/Emails/mail.php');
|
||||
require_once 'modules/Users/Users.php';
|
||||
require_once('VTSimpleTemplate.inc');
|
||||
require_once 'VTEntityCache.inc';
|
||||
require_once('VTWorkflowUtils.php');
|
||||
|
||||
require 'include.inc';
|
||||
|
||||
function vtRunTaskJob($adb){
|
||||
$util = new VTWorkflowUtils();
|
||||
$adminUser = $util->adminUser();
|
||||
$tq = new VTTaskQueue($adb);
|
||||
$readyTasks = $tq->getReadyTasks();
|
||||
$tm = new VTTaskManager($adb);
|
||||
foreach($readyTasks as $pair){
|
||||
list($taskId, $entityId) = $pair;
|
||||
$task = $tm->retrieveTask($taskId);
|
||||
$entity = new VTWorkflowEntity($adminUser, $entityId);
|
||||
$task->doTask($entity);
|
||||
}
|
||||
}
|
||||
vtRunTaskJob($adb);
|
||||
?>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("VTTaskManager.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
|
||||
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 = $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;
|
||||
}
|
||||
|
||||
$fieldNames = $task->getFieldNames();
|
||||
foreach($fieldNames as $fieldName){
|
||||
$task->$fieldName = $request[$fieldName];
|
||||
if ($fieldName == 'calendar_repeat_limit_date') {
|
||||
$task->$fieldName = getDBInsertDateValue($request[$fieldName]);
|
||||
}
|
||||
}
|
||||
$tm->saveTask($task);
|
||||
|
||||
if(isset($request["return_url"])){
|
||||
$returnUrl=$request["return_url"];
|
||||
}else{
|
||||
$returnUrl=$module->editTaskUrl($task->id);
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$returnUrl?>";
|
||||
</script>
|
||||
<a href="<?=$returnUrl?>">Return</a>
|
||||
<?php
|
||||
}
|
||||
vtSaveTask($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once "include/utils/CommonUtils.php";
|
||||
require_once "include/events/SqlResultIterator.inc";
|
||||
require_once "include/Zend/Json.php";
|
||||
require_once "VTWorkflowApplication.inc";
|
||||
require_once "VTWorkflowManager.inc";
|
||||
require_once "VTWorkflowTemplateManager.inc";
|
||||
require_once "VTTaskManager.inc";
|
||||
require_once "VTWorkflowUtils.php";
|
||||
|
||||
function vtSaveWorkflowTemplate($adb, $request){
|
||||
$util = new VTWorkflowUtils();
|
||||
$module = new VTWorkflowApplication("savetemplate");
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $request['title'];
|
||||
$workflowId = $request['workflow_id'];
|
||||
$wfs = new VTworkflowManager($adb);
|
||||
$workflow = $wfs->retrieve($workflowId);
|
||||
$tm = new VTWorkflowTemplateManager($adb);
|
||||
$tpl = $tm->newTemplate($title, $workflow);
|
||||
$tm->saveTemplate($tpl);
|
||||
$returnUrl = $request['return_url'];
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$returnUrl?>";
|
||||
</script>
|
||||
<a href="<?=$returnUrl?>">Return</a>
|
||||
<?php
|
||||
}
|
||||
vtSaveWorkflowTemplate($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
require_once("include/Zend/Json.php");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTWorkflowManager.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
|
||||
function vtWorkflowSave($adb, $request){
|
||||
$util = new VTWorkflowUtils();
|
||||
$module = new VTWorkflowApplication("saveworkflow");
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$description = $request["description"];
|
||||
$moduleName = $request["module_name"];
|
||||
$conditions = $request["conditions"];
|
||||
$taskId = $request["task_id"];
|
||||
$saveType=$request["save_type"];
|
||||
$executionCondition = $request['execution_condition'];
|
||||
$wm = new VTWorkflowManager($adb);
|
||||
if($saveType=='new'){
|
||||
$wf = $wm->newWorkflow($moduleName);
|
||||
$wf->description = $description;
|
||||
$wf->test = $conditions;
|
||||
$wf->taskId = $taskId;
|
||||
$wf->executionConditionAsLabel($executionCondition);
|
||||
$wm->save($wf);
|
||||
}else if($saveType=='edit'){
|
||||
$wf = $wm->retrieve($request["workflow_id"]);
|
||||
$wf->description = $description;
|
||||
$wf->test = $conditions;
|
||||
$wf->taskId = $taskId;
|
||||
$wf->executionConditionAsLabel($executionCondition);
|
||||
$wm->save($wf);
|
||||
}else{
|
||||
throw new Exception();
|
||||
}
|
||||
if(isset($request["return_url"])){
|
||||
$returnUrl=$request["return_url"];
|
||||
}else{
|
||||
$returnUrl=$module->editWorkflowUrl($wf->id);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.location="<?=$returnUrl?>";
|
||||
</script>
|
||||
<a href="<?=$returnUrl?>">Return</a>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
vtWorkflowSave($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
function vtSortFieldsJson($request){
|
||||
$moduleName = $request['module_name'];
|
||||
require_once("modules/$moduleName/$moduleName.php");
|
||||
$focus = new $moduleName();
|
||||
echo Zend_Json::encode($focus->sortby_fields);
|
||||
}
|
||||
vtSortFieldsJson($_REQUEST);
|
||||
?>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
|
||||
require_once("VTTaskManager.inc");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
|
||||
|
||||
function vtDisplayTaskList($adb, $requestUrl, $current_language){
|
||||
global $theme, $app_strings;
|
||||
$image_path = "themes/$theme/images/";
|
||||
|
||||
$util = new VTWorkflowUtils();
|
||||
$module = new VTWorkflowApplication("tasklist");
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$smarty = new vtigerCRM_Smarty();
|
||||
$tm = new VTTaskManager($adb);
|
||||
$smarty->assign("tasks", $tm->getTasks());
|
||||
$smarty->assign("moduleNames", array("Contacts", "Applications"));
|
||||
$smarty->assign("taskTypes", array("VTEmailTask", "VTDummyTask"));
|
||||
$smarty->assign("returnUrl", $requestUrl);
|
||||
|
||||
$smarty->assign("MOD", return_module_language($current_language,'Settings'));
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("MODULE_NAME", $module->label);
|
||||
$smarty->assign("PAGE_NAME", 'Task List');
|
||||
$smarty->assign("PAGE_TITLE", 'List available tasks');
|
||||
$smarty->assign("moduleName", $moduleName);
|
||||
$smarty->display("{$module->name}/ListTasks.tpl");
|
||||
}
|
||||
vtDisplayTaskList($adb, $_SERVER["REQUEST_URI"], $current_language);
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class VTCreateEntityTask extends VTTask{
|
||||
|
||||
public function getFieldNames(){
|
||||
return array("fieldExpressions");
|
||||
}
|
||||
public function doTask($module, $data){
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/Webservices/Utils.php');
|
||||
require_once("include/Webservices/VtigerCRMObject.php");
|
||||
require_once("include/Webservices/VtigerCRMObjectMeta.php");
|
||||
require_once("include/Webservices/DataTransform.php");
|
||||
require_once("include/Webservices/WebServiceError.php");
|
||||
require_once 'include/Webservices/ModuleTypes.php';
|
||||
require_once('include/Webservices/Create.php');
|
||||
require_once 'include/Webservices/DescribeObject.php';
|
||||
require_once 'include/Webservices/WebserviceField.php';
|
||||
require_once 'include/Webservices/EntityMeta.php';
|
||||
require_once 'include/Webservices/VtigerWebserviceObject.php';
|
||||
|
||||
require_once("modules/Users/Users.php");
|
||||
|
||||
class VTCreateEventTask extends VTTask{
|
||||
public $executeImmediately = true;
|
||||
|
||||
public function getFieldNames(){
|
||||
return array('eventType', 'eventName', 'description', 'sendNotification',
|
||||
'startTime', 'startDays', 'startDirection', 'startDatefield',
|
||||
'endTime','endDays', 'endDirection', 'endDatefield',
|
||||
'status', 'priority','recurringcheck','repeat_frequency',
|
||||
'recurringtype','calendar_repeat_limit_date',
|
||||
'mon_flag','tue_flag','wed_flag','thu_flag','fri_flag','sat_flag','sun_flag',
|
||||
'repeatMonth','repeatMonth_date','repeatMonth_daytype','repeatMonth_day');
|
||||
}
|
||||
|
||||
function getAdmin(){
|
||||
$user = new Users();
|
||||
$user->retrieveCurrentUserInfoFromFile(1);
|
||||
global $current_user;
|
||||
$this->originalUser = $current_user;
|
||||
$current_user = $user;
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function doTask($entityData){
|
||||
global $adb, $current_user;
|
||||
$userId = $entityData->get('assigned_user_id');
|
||||
if($userId===null){
|
||||
$userId = vtws_getWebserviceEntityId('Users', 1);;
|
||||
}
|
||||
|
||||
$startDate = $this->calculateDate($entityData, $this->startDays,
|
||||
$this->startDirection, $this->startDatefield);
|
||||
$endDate = $this->calculateDate($entityData, $this->endDays,
|
||||
$this->endDirection, $this->endDatefield);
|
||||
|
||||
$fields = array(
|
||||
'activitytype'=>$this->eventType,
|
||||
'description'=>$this->description,
|
||||
'subject'=>$this->eventName,
|
||||
'taskpriority'=>$this->priority,
|
||||
'eventstatus'=>$this->status,
|
||||
'assigned_user_id'=>$userId,
|
||||
'time_start'=>self::conv12to24hour($this->startTime),
|
||||
'date_start'=>$startDate,
|
||||
'time_end'=>self::conv12to24hour($this->endTime),
|
||||
'due_date'=>$endDate,
|
||||
'visibility'=>'all',
|
||||
'taskstatus'=>'',
|
||||
'duration_hours'=>'0'
|
||||
);
|
||||
|
||||
$_REQUEST['date_start'] = getDisplayDate($startDate);
|
||||
$_REQUEST['due_date'] = getDisplayDate($endDate);
|
||||
$_REQUEST['recurringcheck']=$this->recurringcheck;
|
||||
$_REQUEST['repeat_frequency']=$this->repeat_frequency;
|
||||
$_REQUEST['recurringtype']=$this->recurringtype;
|
||||
$_REQUEST['calendar_repeat_limit_date']=getDisplayDate($this->calendar_repeat_limit_date);
|
||||
$_REQUEST['mon_flag']=$this->mon_flag;
|
||||
$_REQUEST['tue_flag']=$this->tue_flag;
|
||||
$_REQUEST['wed_flag']=$this->wed_flag;
|
||||
$_REQUEST['thu_flag']=$this->thu_flag;
|
||||
$_REQUEST['fri_flag']=$this->fri_flag;
|
||||
$_REQUEST['sat_flag']=$this->sat_flag;
|
||||
$_REQUEST['sun_flag']=$this->sun_flag;
|
||||
$_REQUEST['repeatMonth']=$this->repeatMonth;
|
||||
$_REQUEST['repeatMonth_date']=$this->repeatMonth_date;
|
||||
$_REQUEST['repeatMonth_daytype']=$this->repeatMonth_daytype;
|
||||
$_REQUEST['repeatMonth_day']=$this->repeatMonth_day;
|
||||
|
||||
$moduleName = $entityData->getModuleName();
|
||||
$adminUser = $this->getAdmin();
|
||||
$id = $entityData->getId();
|
||||
if($moduleName=='Contacts'){
|
||||
$fields['contact_id'] = $id;
|
||||
}else{
|
||||
$data = vtws_describe('Calendar', $adminUser);
|
||||
$fieldInfo = $data['fields'];
|
||||
foreach($fieldInfo as $field){
|
||||
if($field['name']=='parent_id'){
|
||||
$parentIdField = $field;
|
||||
}
|
||||
}
|
||||
$refersTo = $parentIdField['type']['refersTo'];
|
||||
|
||||
if(in_array($moduleName, $refersTo)){
|
||||
$fields['parent_id'] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$event = vtws_create('Events', $fields, $adminUser);
|
||||
list($typeId, $id) = vtws_getIdComponents($event['id']);
|
||||
$event = CRMEntity::getInstance('Events');
|
||||
$event->id = $id;
|
||||
$startDate = $entityData->get($this->startDatefield);
|
||||
if($this->recurringcheck && !empty($startDate) &&
|
||||
($this->calendar_repeat_limit_date)) {
|
||||
include_once 'modules/Calendar/RepeatEvents.php';
|
||||
Calendar_RepeatEvents::repeat($event);
|
||||
}
|
||||
global $current_user;
|
||||
$current_user = $this->originalUser;
|
||||
}
|
||||
|
||||
private function calculateDate($entityData, $days, $direction, $datefield){
|
||||
$baseDate = $entityData->get($datefield);
|
||||
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDate, $match);
|
||||
$baseDate = strtotime($match[0]);
|
||||
$date = strftime('%Y-%m-%d', $baseDate+$days*24*60*60*
|
||||
($direction=='Before'?-1:1));
|
||||
return $date;
|
||||
}
|
||||
|
||||
static function conv12to24hour($timeStr){
|
||||
$arr = array();
|
||||
preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);
|
||||
if($arr[3]=='am'){
|
||||
$hours = ((int)$arr[1]) % 12;
|
||||
}else{
|
||||
$hours = ((int)$arr[1]) % 12 + 12;
|
||||
}
|
||||
return str_pad($hours, 2, '0', STR_PAD_LEFT).':'.str_pad($arr[2], 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('include/Webservices/Utils.php');
|
||||
require_once("include/Webservices/VtigerCRMObject.php");
|
||||
require_once("include/Webservices/VtigerCRMObjectMeta.php");
|
||||
require_once("include/Webservices/DataTransform.php");
|
||||
require_once("include/Webservices/WebServiceError.php");
|
||||
require_once 'include/Webservices/ModuleTypes.php';
|
||||
require_once('include/Webservices/Create.php');
|
||||
require_once 'include/Webservices/DescribeObject.php';
|
||||
require_once 'include/Webservices/WebserviceField.php';
|
||||
require_once 'include/Webservices/EntityMeta.php';
|
||||
require_once 'include/Webservices/VtigerWebserviceObject.php';
|
||||
|
||||
require_once("modules/Users/Users.php");
|
||||
|
||||
class VTCreateTodoTask extends VTTask{
|
||||
public $executeImmediately = true;
|
||||
|
||||
public function getFieldNames(){return array('todo', 'description', 'sendNotification', 'time', 'date', 'status', 'priority', 'days', 'direction', 'datefield', 'sendNotification');}
|
||||
|
||||
function getAdmin(){
|
||||
$user = new Users();
|
||||
$user->retrieveCurrentUserInfoFromFile(1);
|
||||
global $current_user;
|
||||
$this->originalUser = $current_user;
|
||||
$current_user = $user;
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function doTask($entityData){
|
||||
global $adb, $current_user;
|
||||
$userId = $entityData->get('assigned_user_id');
|
||||
if($userId===null){
|
||||
$userId = vtws_getWebserviceEntityId('Users', 1);;
|
||||
}
|
||||
|
||||
$baseDate = $entityData->get($this->datefield);
|
||||
$time = explode(' ',$baseDate);
|
||||
if(count($time) < 2) {
|
||||
$time[] = date('H:i');
|
||||
}
|
||||
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDate, $match);
|
||||
$baseDate = strtotime($match[0]);
|
||||
$date = strftime('%Y-%m-%d', $baseDate+$this->days*24*60*60*($this->directions=='Before'?-1:1));
|
||||
$fields = array(
|
||||
'activitytype'=>'Task',
|
||||
'description'=>$this->description,
|
||||
'subject'=>$this->todo,
|
||||
'taskpriority'=>$this->priority,
|
||||
'taskstatus'=>$this->status,
|
||||
'assigned_user_id'=>$userId,
|
||||
'time_start'=>$time[1],
|
||||
'sendnotification'=>$this->sendNotification!=''?1:0,
|
||||
'date_start'=>$date,
|
||||
'due_date'=>$date,
|
||||
'visibility'=>'all',
|
||||
'eventstatus'=>''
|
||||
);
|
||||
$moduleName = $entityData->getModuleName();
|
||||
$adminUser = $this->getAdmin();
|
||||
$id = $entityData->getId();
|
||||
if($moduleName=='Contacts'){
|
||||
$fields['contact_id'] = $id;
|
||||
}else{
|
||||
$data = vtws_describe('Calendar', $adminUser);
|
||||
$fieldInfo = $data['fields'];
|
||||
foreach($fieldInfo as $field){
|
||||
if($field['name']=='parent_id'){
|
||||
$parentIdField = $field;
|
||||
}
|
||||
}
|
||||
$refersTo = $parentIdField['type']['refersTo'];
|
||||
|
||||
if(in_array($moduleName, $refersTo)){
|
||||
$fields['parent_id'] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
vtws_create('Calendar', $fields, $adminUser);
|
||||
global $current_user;
|
||||
$current_user = $this->originalUser;
|
||||
}
|
||||
|
||||
static function conv12to24hour($timeStr){
|
||||
$arr = array();
|
||||
preg_match('/(\d{1,2}):(\d{1,2})(am|pm)/', $timeStr, $arr);
|
||||
if($arr[3]=='am'){
|
||||
$hours = ((int)$arr[1]) % 12;
|
||||
}else{
|
||||
$hours = ((int)$arr[1]) % 12 + 12;
|
||||
}
|
||||
return str_pad($hours, 2, '0', STR_PAD_LEFT).':'.str_pad($arr[2], 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
class VTDummyTask extends VTTask{
|
||||
public $executeImmediately = true;
|
||||
|
||||
public function getFieldNames(){return array();}
|
||||
public function doTask($entity){
|
||||
$statement=$this->statement;
|
||||
echo "This is a dummy workflow task with $statement";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('modules/com_vtiger_workflow/VTEntityCache.inc');
|
||||
require_once('modules/com_vtiger_workflow/VTWorkflowUtils.php');
|
||||
require_once('modules/com_vtiger_workflow/VTEmailRecipientsTemplate.inc');
|
||||
require_once('modules/Emails/mail.php');
|
||||
class VTEmailTask extends VTTask{
|
||||
// Sending email takes more time, this should be handled via queue all the time.
|
||||
public $executeImmediately = false;
|
||||
|
||||
public function getFieldNames(){
|
||||
return array("subject", "content", "recepient", 'emailcc', 'emailbcc');
|
||||
}
|
||||
public function doTask($entity){
|
||||
global $adb, $current_user;
|
||||
$util = new VTWorkflowUtils();
|
||||
|
||||
$result = $adb->query("select user_name, email1, email2 from vtiger_users where id=1");
|
||||
$from_email = $adb->query_result($result,0,'email1');
|
||||
$from_name = $adb->query_result($result,0,'user_name');
|
||||
|
||||
$admin = $util->adminUser();
|
||||
$module = $entity->getModuleName();
|
||||
|
||||
$entityCache = new VTEntityCache($admin);
|
||||
|
||||
$et = new VTEmailRecipientsTemplate($this->recepient);
|
||||
$to_email = $et->render($entityCache, $entity->getId());
|
||||
$ecct = new VTEmailRecipientsTemplate($this->emailcc);
|
||||
$cc = $ecct->render($entityCache, $entity->getId());
|
||||
$ebcct = new VTEmailRecipientsTemplate($this->emailbcc);
|
||||
$bcc = $ebcct->render($entityCache, $entity->getId());
|
||||
if(strlen(trim($to_email, " \t\n,")) == 0 && strlen(trim($cc, " \t\n,")) == 0 &&
|
||||
strlen(trim($bcc, " \t\n,")) == 0) {
|
||||
return ;
|
||||
}
|
||||
|
||||
$st = new VTSimpleTemplate($this->subject);
|
||||
$subject = $st->render($entityCache, $entity->getId());
|
||||
$ct = new VTSimpleTemplate($this->content);
|
||||
$content = $ct->render($entityCache, $entity->getId());
|
||||
send_mail($module,$to_email,$from_name,$from_email,$subject,$content, $cc, $bcc);
|
||||
|
||||
$util->revertUser();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('modules/com_vtiger_workflow/VTEntityMethodManager.inc');
|
||||
class VTEntityMethodTask extends VTTask{
|
||||
|
||||
public $executeImmediately = true;
|
||||
|
||||
public function getFieldNames(){return array('methodName');}
|
||||
public function doTask($entityData){
|
||||
global $adb;
|
||||
$emm = new VTEntityMethodManager($adb);
|
||||
$emm->executeMethod($entityData, $this->methodName);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once('modules/SMSNotifier/workflow/VTSMSTask.php');
|
||||
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once 'include/Zend/Json.php';
|
||||
require_once 'VTWorkflowTemplateManager.inc';
|
||||
function vtTemplatesForModuleJson($adb, $request){
|
||||
$moduleName = $request['module_name'];
|
||||
$tm = new VTWorkflowTemplateManager($adb);
|
||||
$templates = $tm->getTemplatesForModule($moduleName);
|
||||
$arr = array();
|
||||
foreach($templates as $template){
|
||||
$arr[] = array("title"=>$template->title, 'id'=>$template->id);
|
||||
}
|
||||
echo Zend_Json::encode($arr);
|
||||
}
|
||||
vtTemplatesForModuleJson($adb, $_REQUEST);
|
||||
?>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/*+**********************************************************************************
|
||||
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
|
||||
* ("License"); You may not use this file except in compliance with the License
|
||||
* The Original Code is: vtiger CRM Open Source
|
||||
* The Initial Developer of the Original Code is vtiger.
|
||||
* Portions created by vtiger are Copyright (C) vtiger.
|
||||
* All Rights Reserved.
|
||||
************************************************************************************/
|
||||
require_once("Smarty_setup.php");
|
||||
require_once("include/utils/CommonUtils.php");
|
||||
|
||||
require_once("include/events/SqlResultIterator.inc");
|
||||
|
||||
require_once("VTWorkflowManager.inc");
|
||||
require_once("VTWorkflowApplication.inc");
|
||||
require_once("VTWorkflowUtils.php");
|
||||
|
||||
function vtGetModules($adb){
|
||||
$modules_not_supported = array('Documents','Calendar','Emails','Faq','Events','PBXManager','Users');
|
||||
$sql="select distinct vtiger_field.tabid, name
|
||||
from vtiger_field
|
||||
inner join vtiger_tab
|
||||
on vtiger_field.tabid=vtiger_tab.tabid
|
||||
where vtiger_tab.name not in(".generateQuestionMarks($modules_not_supported).") and vtiger_tab.isentitytype=1 and vtiger_tab.presence = 0 ";
|
||||
$it = new SqlResultIterator($adb, $adb->pquery($sql,array($modules_not_supported)));
|
||||
$modules = array();
|
||||
foreach($it as $row){
|
||||
$modules[] = $row->name;
|
||||
}
|
||||
return $modules;
|
||||
}
|
||||
|
||||
function vtDisplayWorkflowList($adb, $request, $requestUrl, $app_strings, $current_language){
|
||||
global $theme;
|
||||
$image_path = "themes/$theme/images/";
|
||||
|
||||
$module = new VTWorkflowApplication("workflowlist");
|
||||
$util = new VTWorkflowUtils();
|
||||
$mod = return_module_language($current_language, $module->name);
|
||||
|
||||
if(!$util->checkAdminAccess()){
|
||||
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
|
||||
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
|
||||
return;
|
||||
}
|
||||
|
||||
$smarty = new vtigerCRM_Smarty();
|
||||
$wfs = new VTWorkflowManager($adb);
|
||||
$smarty->assign("moduleNames", $util->vtGetModules($adb));
|
||||
$smarty->assign("returnUrl", $requestUrl);
|
||||
|
||||
$listModule =$request['list_module'];
|
||||
$smarty->assign("listModule", $listModule);
|
||||
if($listModule==null || strtolower($listModule)=="all"){
|
||||
$smarty->assign("workflows", $wfs->getWorkflows());
|
||||
}else{
|
||||
$smarty->assign("workflows", $wfs->getWorkflowsForModule($listModule));
|
||||
}
|
||||
|
||||
$smarty->assign("MOD",array_merge(
|
||||
return_module_language($current_language,'Settings'),
|
||||
return_module_language($current_language, $module->name)));
|
||||
$smarty->assign("APP", $app_strings);
|
||||
$smarty->assign("THEME", $theme);
|
||||
$smarty->assign("IMAGE_PATH",$image_path);
|
||||
$smarty->assign("MODULE_NAME", $module->label);
|
||||
$smarty->assign("PAGE_NAME", $mod['LBL_WORKFLOW_LIST']);
|
||||
$smarty->assign("PAGE_TITLE", $mod['LBL_AVAILABLE_WORKLIST_LIST']);
|
||||
$smarty->assign("module", $module);
|
||||
$smarty->display("{$module->name}/ListWorkflows.tpl");
|
||||
}
|
||||
vtDisplayWorkflowList($adb, $_REQUEST, $_SERVER["REQUEST_URI"], $app_strings, $current_language);
|
||||
?>
|
||||
Reference in New Issue
Block a user