Squashed 'public/legacy/' content from commit 817a12dc0

git-subtree-dir: public/legacy
git-subtree-split: 817a12dc0c30c189f56d5cb1f7dc37a9631bdbe3
This commit is contained in:
Dillon-Brown 2021-03-31 15:37:32 +01:00
commit 8e4cc94994
9769 changed files with 1617695 additions and 0 deletions

View file

@ -0,0 +1,981 @@
<?php
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
class AOW_WorkFlow extends Basic
{
public $new_schema = true;
public $module_dir = 'AOW_WorkFlow';
public $object_name = 'AOW_WorkFlow';
public $table_name = 'aow_workflow';
public $importable = false;
public $disable_row_level_security = true;
public $id;
public $name;
public $date_entered;
public $date_modified;
public $modified_user_id;
public $modified_by_name;
public $created_by;
public $created_by_name;
public $description;
public $deleted;
public $created_by_link;
public $modified_user_link;
public $assigned_user_id;
public $assigned_user_name;
public $assigned_user_link;
public $flow_module;
public $status;
public $run_when;
public $flow_run_on;
public $multiple_runs;
/**
* return an SQL operator
* @param $key name of SQL operator
* @return mixed SQL operator or false if $key not found
*/
private function getSQLOperator($key)
{
$sqlOperatorList['Equal_To'] = '=';
$sqlOperatorList['Not_Equal_To'] = '!=';
$sqlOperatorList['Greater_Than'] = '>';
$sqlOperatorList['Less_Than'] = '<';
$sqlOperatorList['Greater_Than_or_Equal_To'] = '>=';
$sqlOperatorList['Less_Than_or_Equal_To'] = '<=';
$sqlOperatorList['Contains'] = 'LIKE';
$sqlOperatorList['Starts_With'] = 'LIKE';
$sqlOperatorList['Ends_With'] = 'LIKE';
$sqlOperatorList['is_null'] = 'IS NULL';
if (!isset($sqlOperatorList[$key])) {
return false;
}
return $sqlOperatorList[$key];
}
/**
* check an SQL operator is exists
* @param $key name of SQL operator
* @return bool true if operator exists otherwise false
*/
private function isSQLOperator($key)
{
return $this->getSQLOperator($key) ? true : false;
}
/**
* AOW_WorkFlow constructor.
* @param bool $init
*/
public function __construct($init = true)
{
parent::__construct();
if ($init) {
$this->load_flow_beans();
require_once('modules/AOW_WorkFlow/aow_utils.php');
}
}
/**
* @param $interface
* @return bool
*/
public function bean_implements($interface)
{
switch ($interface) {
case 'ACL':
return true;
}
return false;
}
public function save($check_notify = false)
{
if (empty($this->id) || (isset($_POST['duplicateSave']) && $_POST['duplicateSave'] == 'true')) {
unset($_POST['aow_conditions_id']);
unset($_POST['aow_actions_id']);
}
$return_id = parent::save($check_notify);
require_once('modules/AOW_Conditions/AOW_Condition.php');
$condition = BeanFactory::newBean('AOW_Conditions');
$condition->save_lines($_POST, $this, 'aow_conditions_');
require_once('modules/AOW_Actions/AOW_Action.php');
$action = BeanFactory::newBean('AOW_Actions');
$action->save_lines($_POST, $this, 'aow_actions_');
return $return_id;
}
public function mark_deleted($id)
{
// These are owned by the workflow, so delete them instead of just removing the link
$beans = $this->get_linked_beans('aow_conditions');
$beans = array_merge($beans, $this->get_linked_beans('aow_actions'));
$beans = array_merge($beans, $this->get_linked_beans('aow_processed'));
foreach ($beans as $bean) {
$bean->mark_deleted($bean->id);
}
parent::mark_deleted($id);
}
public function load_flow_beans()
{
global $beanList, $app_list_strings;
if (!empty($app_list_strings['moduleList'])) {
$app_list_strings['aow_moduleList'] = $app_list_strings['moduleList'];
foreach ($app_list_strings['aow_moduleList'] as $mkey => $mvalue) {
if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOW_')) {
unset($app_list_strings['aow_moduleList'][$mkey]);
}
}
}
$app_list_strings['aow_moduleList'] = array_merge((array)array(''=>''), (array)$app_list_strings['aow_moduleList']);
asort($app_list_strings['aow_moduleList']);
}
/**
* Select and run all active flows
* @return bool
*/
public function run_flows()
{
$flows = AOW_WorkFlow::get_full_list('', " aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'In_Scheduler' OR aow_workflow.run_when = 'Create') ");
if (empty($flows)) {
LoggerManager::getLogger()->warn('There is no any workflow to run');
}
foreach ((array)$flows as $flow) {
$flow->run_flow();
}
return true;
}
/**
* Retrieve the beans to actioned and run the actions
*/
public function run_flow()
{
$beans = $this->get_flow_beans();
if (!empty($beans)) {
foreach ($beans as $bean) {
$bean->retrieve($bean->id);
$this->run_actions($bean);
}
}
}
/**
* Select and run all active flows for the specified bean
*/
public function run_bean_flows(SugarBean $bean)
{
if (!defined('SUGARCRM_IS_INSTALLING') && (!isset($_REQUEST['module']) || $_REQUEST['module'] != 'Import')) {
$query = "SELECT id FROM aow_workflow WHERE aow_workflow.flow_module = '" . $bean->module_dir . "' AND aow_workflow.status = 'Active' AND (aow_workflow.run_when = 'Always' OR aow_workflow.run_when = 'On_Save' OR aow_workflow.run_when = 'Create') AND aow_workflow.deleted = 0 ";
$result = $this->db->query($query, false);
$flow = BeanFactory::newBean('AOW_WorkFlow');
while (($row = $bean->db->fetchByAssoc($result)) != null) {
$flow->retrieve($row['id']);
if ($flow->check_valid_bean($bean)) {
$flow->run_actions($bean, true);
}
}
}
return true;
}
/**
* Use the condition statements and processed table to build query to retrieve beans to be actioned
*/
public function get_flow_beans()
{
global $beanList;
$flowModule = null;
if (isset($beanList[$this->flow_module])) {
$flowModule = $beanList[$this->flow_module];
} else {
LoggerManager::getLogger()->warn('Undefined flow module in bean list: ' . $this->flow_module);
}
if ($flowModule) {
$module = new $beanList[$this->flow_module]();
$query = '';
$query_array = array();
$query_array['select'][] = $module->table_name.".id AS id";
$query_array = $this->build_flow_query_where($query_array);
if (!empty($query_array)) {
foreach ($query_array['select'] as $select) {
$query .= ($query == '' ? 'SELECT ' : ', ').$select;
}
$query .= ' FROM '.$module->table_name.' ';
if (isset($query_array['join'])) {
foreach ($query_array['join'] as $join) {
$query .= $join;
}
}
if (isset($query_array['where'])) {
$query_where = '';
foreach ($query_array['where'] as $where) {
$query_where .= ($query_where == '' ? 'WHERE ' : ' AND ').$where;
}
$query .= ' '.$query_where;
}
return $module->process_full_list_query($query);
}
}
return null;
}
public function build_flow_custom_query_join(
$name,
$custom_name,
SugarBean $module,
$query = array()
) {
if (!isset($query['join'][$custom_name])) {
$query['join'][$custom_name] = 'LEFT JOIN '.$module->get_custom_table_name()
.' '.$custom_name.' ON '.$name.'.id = '. $custom_name.'.id_c ';
}
return $query;
}
public function build_flow_relationship_query_join(
$name,
SugarBean $module,
$query = array()
) {
if (!isset($query['join'][$name])) {
if ($module->load_relationship($name)) {
$params['join_type'] = 'LEFT JOIN';
$params['join_table_alias'] = $name;
$join = $module->$name->getJoin($params, true);
$query['join'][$name] = $join['join'];
$query['select'][] = $join['select']." AS '".$name."_id'";
}
}
return $query;
}
public function build_flow_query_where($query = array())
{
global $beanList;
$flowModule = null;
if (isset($beanList[$this->flow_module])) {
$flowModule = $beanList[$this->flow_module];
} else {
LoggerManager::getLogger()->warn('Undefined flow module in bean list: ' . $this->flow_module);
}
if ($flowModule) {
$module = new $beanList[$this->flow_module]();
$sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC";
$result = $this->db->query($sql);
while ($row = $this->db->fetchByAssoc($result)) {
$condition = BeanFactory::newBean('AOW_Conditions');
$condition->retrieve($row['id']);
$query = $this->build_query_where($condition, $module, $query);
if (empty($query)) {
return $query;
}
}
if ($this->flow_run_on) {
switch ($this->flow_run_on) {
case'New_Records':
if ($module->table_name === 'campaign_log') {
$query['where'][] = $module->table_name . '.' . 'activity_date' . ' > ' . "'" . $this->activity_date . "'";
} else {
$query['where'][] = $module->table_name . '.' . 'date_entered' . ' > ' . "'" . $this->date_entered . "'";
}
break;
case'Modified_Records':
if ($module->table_name === 'campaign_log') {
$query['where'][] = $module->table_name . '.' . 'date_modified' . ' > ' . "'" . $this->activity_date . "'" . ' AND ' . $module->table_name . '.' . 'activity_date' . ' <> ' . $module->table_name . '.' . 'date_modified';
} else {
$query['where'][] = $module->table_name . '.' . 'date_modified' . ' > ' . "'" . $this->date_entered . "'" . ' AND ' . $module->table_name . '.' . 'date_entered' . ' <> ' . $module->table_name . '.' . 'date_modified';
}
break;
}
}
if (!$this->multiple_runs) {
if (!isset($query['where'])) {
LoggerManager::getLogger()->warn('Undefined index: where');
$query['where'] = [];
}
$query['where'][] .= "NOT EXISTS (SELECT * FROM aow_processed WHERE aow_processed.aow_workflow_id='".$this->id."' AND aow_processed.parent_id=".$module->table_name.".id AND aow_processed.status = 'Complete' AND aow_processed.deleted = 0)";
}
$query['where'][] = $module->table_name.".deleted = 0 ";
}
return $query;
}
public function build_query_where(AOW_Condition $condition, $module, $query = array())
{
global $beanList, $app_list_strings, $sugar_config, $timedate;
$path = unserialize(base64_decode($condition->module_path));
$condition_module = $module;
$table_alias = $condition_module->table_name;
if (isset($path[0]) && $path[0] != $module->module_dir) {
foreach ($path as $rel) {
$query = $this->build_flow_relationship_query_join(
$rel,
$condition_module,
$query
);
$condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)];
$table_alias = $rel;
}
}
if ($this->isSQLOperator($condition->operator)) {
$where_set = false;
$data = $condition_module->field_defs[$condition->field];
if ($data['type'] == 'relate' && isset($data['id_name'])) {
$condition->field = $data['id_name'];
}
if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
$field = $table_alias.'_cstm.'.$condition->field;
$query = $this->build_flow_custom_query_join(
$table_alias,
$table_alias.'_cstm',
$condition_module,
$query
);
} else {
$field = $table_alias.'.'.$condition->field;
}
if ($condition->operator == 'is_null') {
$query['where'][] = '('.$field.' '.$this->getSQLOperator($condition->operator).' OR '.$field.' '.$this->getSQLOperator('Equal_To')." '')";
return $query;
}
switch ($condition->value_type) {
case 'Field':
$data = null;
if (isset($module->field_defs[$condition->value])) {
$data = $module->field_defs[$condition->value];
} else {
LoggerManager::getLogger()->warn('Undefined field def for condition value in module: ' . get_class($module) . '::field_defs[' . $condition->value . ']');
}
if ($data['type'] == 'relate' && isset($data['id_name'])) {
$condition->value = $data['id_name'];
}
if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
$value = $module->table_name.'_cstm.'.$condition->value;
$query = $this->build_flow_custom_query_join(
$module->table_name,
$module->table_name.'_cstm',
$module,
$query
);
} else {
$value = $module->table_name.'.'.$condition->value;
}
break;
case 'Any_Change':
//can't detect in scheduler so return
return array();
case 'Date':
$params = @unserialize(base64_decode($condition->value));
if ($params === false) {
LoggerManager::getLogger()->error('Unserializable data given');
$params = [null];
}
if ($params[0] == 'now') {
if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
$value = 'GetUTCDate()';
} else {
$value = 'UTC_TIMESTAMP()';
}
} elseif (isset($params[0]) && $params[0] == 'today') {
if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
//$field =
$value = 'CAST(GETDATE() AS DATE)';
} else {
$field = 'DATE('.$field.')';
$value = 'Curdate()';
}
} else {
if (isset($params[0]) && $params[0] == 'today') {
if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
//$field =
$value = 'CAST(GETDATE() AS DATE)';
} else {
$field = 'DATE('.$field.')';
$value = 'Curdate()';
}
} else {
$data = null;
if (isset($module->field_defs[$params[0]])) {
$data = $module->field_defs[$params[0]];
} else {
LoggerManager::getLogger()->warn('Filed def data is missing: ' . get_class($module) . '::$field_defs[' . $params[0] . ']');
}
if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
$value = $module->table_name.'_cstm.'.$params[0];
$query = $this->build_flow_custom_query_join(
$module->table_name,
$module->table_name.'_cstm',
$module,
$query
);
} else {
$value = $module->table_name.'.'.$params[0];
}
}
}
if ($params[1] != 'now') {
switch ($params[3]) {
case 'business_hours':
if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php') && $params[0] == 'now') {
require_once('modules/AOBH_BusinessHours/AOBH_BusinessHours.php');
$businessHours = BeanFactory::newBean('AOBH_BusinessHours');
$amount = $params[2];
if ($params[1] != "plus") {
$amount = 0-$amount;
}
$value = $businessHours->addBusinessHours($amount);
$value = "'".$timedate->asDb($value)."'";
break;
}
//No business hours module found - fall through.
$params[3] = 'hour';
// no break
default:
if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
$value = "DATEADD(".$params[3].", ".$app_list_strings['aow_date_operator'][$params[1]]." $params[2], $value)";
} else {
if (!isset($params)) {
LoggerManager::getLogger()->warn('Undefined variable: param');
$params = [null, null, null, null];
}
$params1 = $params[1];
$params2 = $params[2];
$params3 = $params[3];
$dateOp = null;
if (isset($app_list_strings['aow_date_operator'][$params1])) {
$dateOp = $app_list_strings['aow_date_operator'][$params1];
} else {
LoggerManager::getLogger()->warn('Date operator is not set in app_list_string[' . $params1 . ']');
}
$field = 'DATE_FORMAT('.$field.", '%Y-%m-%d %H:%i')";
$value = "DATE_FORMAT(DATE_ADD($value, INTERVAL ".$dateOp." $params2 ".$params3."), '%Y-%m-%d %H:%i')";
}
break;
}
}
break;
case 'Multi':
$sep = ' AND ';
if ($condition->operator == 'Equal_To') {
$sep = ' OR ';
}
$multi_values = unencodeMultienum($condition->value);
if (!empty($multi_values)) {
$value = '(';
if ($data['type'] == 'multienum') {
$multi_operator = $condition->operator == 'Equal_To' ? 'LIKE' : 'NOT LIKE';
foreach ($multi_values as $multi_value) {
if ($value != '(') {
$value .= $sep;
}
$value .= $field." $multi_operator '%^".$multi_value."^%'";
}
} else {
foreach ($multi_values as $multi_value) {
if ($value != '(') {
$value .= $sep;
}
$value .= $field.' '.$this->getSQLOperator($condition->operator)." '".$multi_value."'";
}
}
$value .= ')';
$query['where'][] = $value;
}
$where_set = true;
break;
case 'SecurityGroup':
$sgModule = $condition_module->module_dir;
if (isset($data['module']) && $data['module'] !== '') {
$sgModule = $data['module'];
}
$sql = 'EXISTS (SELECT 1 FROM securitygroups_records WHERE record_id = ' . $field . " AND module = '" . $sgModule . "' AND securitygroup_id = '" . $condition->value . "' AND deleted=0)";
if ($sgModule === 'Users') {
$sql = 'EXISTS (SELECT 1 FROM securitygroups_users WHERE user_id = ' . $field . " AND securitygroup_id = '" . $condition->value . "' AND deleted=0)";
}
$query['where'][] = $sql;
$where_set = true;
break;
case 'Value':
default:
$value = "'".$condition->value."'";
break;
}
//handle like conditions
switch ($condition->operator) {
case 'Contains':
$value = "CONCAT('%', ".$value." ,'%')";
break;
case 'Starts_With':
$value = "CONCAT(".$value." ,'%')";
break;
case 'Ends_With':
$value = "CONCAT('%', ".$value.")";
break;
}
if (!$where_set) {
$query['where'][] = $field.' '.$this->getSQLOperator($condition->operator).' '.$value;
}
}
return $query;
}
/**
* @param SugarBean $bean
* @return bool
*/
public function check_valid_bean(SugarBean $bean)
{
global $app_list_strings, $timedate;
if (!$this->multiple_runs) {
$processed = BeanFactory::getBean('AOW_Processed');
$processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id, 'parent_id' => $bean->id));
if ($processed->status === 'Complete') {
//has already run so return false
return false;
}
}
if (!isset($bean->date_entered) && $bean->fetched_row !== false) {
$bean->date_entered = $bean->fetched_row['date_entered'];
}
if ($this->flow_run_on) {
$dateEntered = $timedate->fromUserType($this->date_entered, 'datetime')
?: $timedate->fromDbType($this->date_entered, 'datetime');
$beanDateEntered = $timedate->fromUserType($bean->date_entered, 'datetime')
?: $timedate->fromDbType($bean->date_entered, 'datetime');
$beanDateModified = $timedate->fromUserType($bean->date_modified, 'datetime')
?: $timedate->fromDbType($bean->date_modified, 'datetime');
switch ($this->flow_run_on) {
case'New_Records':
if (!empty($bean->fetched_row) || $beanDateEntered < $dateEntered) {
return false;
}
break;
case'Modified_Records':
if (empty($bean->fetched_row) ||
($beanDateModified < $dateEntered && $beanDateModified !== $beanDateEntered)) {
return false;
}
break;
}
}
$sql = "SELECT id FROM aow_conditions WHERE aow_workflow_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC";
$result = $this->db->query($sql);
$query_array = array();
while ($row = $this->db->fetchByAssoc($result)) {
$condition = BeanFactory::newBean('AOW_Conditions');
$condition->retrieve($row['id']);
$path = unserialize(base64_decode($condition->module_path));
$condition_bean = $bean;
if (isset($path[0]) && $path[0] != $bean->module_dir) {
$query_array = $this->build_query_where($condition, $condition_bean, $query_array);
continue;
}
$field = $condition->field;
$value = $condition->value;
$dateFields = array('date','datetime', 'datetimecombo');
if ($this->isSQLOperator($condition->operator)) {
$data = $condition_bean->field_defs[$field];
if ($data['type'] === 'relate' && isset($data['id_name'])) {
$field = $data['id_name'];
$condition->field = $data['id_name'];
}
$field = $condition_bean->$field;
if (in_array($data['type'], $dateFields)) {
$field = strtotime($field);
}
switch ($condition->value_type) {
case 'Field':
$data = $condition_bean->field_defs[$value];
if ($data['type'] === 'relate' && isset($data['id_name'])) {
$value = $data['id_name'];
}
$value = $condition_bean->$value;
if (in_array($data['type'], $dateFields)) {
$value = strtotime($value);
}
break;
case 'Any_Change':
if ($data['type'] === 'relate' && isset($data['name'])
&& isset($condition_bean->rel_fields_before_value[$condition->field])) {
$value = $condition_bean->rel_fields_before_value[$condition->field];
} else {
$value = from_html($condition_bean->fetched_row[$condition->field]);
// Bug - on delete bean action CRM load bean in a different way and bean can contain html characters
$field = from_html($field);
}
if (in_array($data['type'], $dateFields)) {
$value = strtotime($value);
}
switch ($condition->operator) {
case 'Not_Equal_To':
$condition->operator = 'Equal_To';
break;
case 'Equal_To':
default:
$condition->operator = 'Not_Equal_To';
break;
}
break;
case 'Date':
$params = unserialize(base64_decode($value));
$dateType = 'datetime';
if ($params[0] == 'now') {
$value = date('Y-m-d H:i:s');
} elseif ($params[0] == 'today') {
$dateType = 'date';
$value = date('Y-m-d');
$field = strtotime(date('Y-m-d', $field));
} else {
if ($params[0] == 'today') {
$dateType = 'date';
$value = date('Y-m-d');
$field = strtotime(date('Y-m-d', $field));
} else {
$fieldName = $params[0];
$value = $condition_bean->$fieldName;
}
}
if ($params[1] != 'now') {
switch ($params[3]) {
case 'business_hours':
if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) {
require_once('modules/AOBH_BusinessHours/AOBH_BusinessHours.php');
$businessHours = BeanFactory::newBean('AOBH_BusinessHours');
$amount = $params[2];
if ($params[1] != "plus") {
$amount = 0-$amount;
}
$value = $businessHours->addBusinessHours($amount, $timedate->fromDb($value));
$value = strtotime($timedate->asDbType($value, $dateType));
break;
}
//No business hours module found - fall through.
$params[3] = 'hours';
// no break
default:
$value = strtotime($value.' '.$app_list_strings['aow_date_operator'][$params[1]]." $params[2] ".$params[3]);
if ($dateType == 'date') {
$value = strtotime(date('Y-m-d', $value));
}
break;
}
} else {
$value = strtotime($value);
}
break;
case 'Multi':
$value = unencodeMultienum($value);
if ($data['type'] == 'multienum') {
$field = unencodeMultienum($field);
}
switch ($condition->operator) {
case 'Not_Equal_To':
$condition->operator = 'Not_One_of';
break;
case 'Equal_To':
default:
$condition->operator = 'One_of';
break;
}
break;
case 'SecurityGroup':
if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
$sg_module = $condition_bean->module_dir;
if (isset($data['module']) && $data['module'] != '') {
$sg_module = $data['module'];
}
$value = $this->check_in_group($field, $sg_module, $value);
$field = true;
break;
}
// no break
case 'Value':
default:
if (in_array($data['type'], $dateFields) && trim($value) != '') {
$value = strtotime($value);
} elseif ($data['type'] == 'bool' && (!(bool)$value || strtolower($value) == 'false')) {
$value = 0;
}
break;
}
if (!($this->compare_condition($field, $value, $condition->operator))) {
return false;
}
}
}
if (isset($query_array['where'])) {
$query = 'SELECT '.$bean->table_name.'.id AS id FROM '.$bean->table_name.' ';
if (isset($query_array['join'])) {
foreach ($query_array['join'] as $join) {
$query .= $join;
}
}
$query_where = '';
$query_array['where'][] = $bean->table_name.'.id = '."'".$bean->id."'";
foreach ($query_array['where'] as $where) {
$query_where .= ($query_where == '' ? 'WHERE ' : ' AND ').$where;
}
$query .= ' '.$query_where;
$rel_check = $bean->db->getOne($query);
if ($rel_check == '') {
return false;
}
}
return true;
}
public function compare_condition($var1, $var2, $operator = 'Equal_To')
{
switch ($operator) {
case "Not_Equal_To": return $var1 != $var2;
case "Greater_Than": return $var1 > $var2;
case "Less_Than": return $var1 < $var2;
case "Greater_Than_or_Equal_To": return $var1 >= $var2;
case "Less_Than_or_Equal_To": return $var1 <= $var2;
case "Contains": return strpos($var1, $var2);
case "Starts_With": return strrpos($var1, $var2, -strlen($var1));
case "Ends_With": return strpos($var1, $var2, strlen($var1) - strlen($var2));
case "is_null": return $var1 == '';
case "One_of":
if (is_array($var1)) {
foreach ($var1 as $var) {
if (in_array($var, $var2)) {
return true;
}
}
return false;
}
return in_array($var1, $var2);
case "Not_One_of":
if (is_array($var1)) {
foreach ($var1 as $var) {
if (in_array($var, $var2)) {
return false;
}
}
return true;
}
return !in_array($var1, $var2);
case "Equal_To":
default: return $var1 == $var2;
}
}
public function check_in_group($bean_id, $module, $group)
{
$sql = "SELECT id FROM securitygroups_records WHERE record_id = '".$bean_id."' AND module = '".$module."' AND securitygroup_id = '".$group."' AND deleted=0";
if ($module == 'Users') {
$sql = "SELECT id FROM securitygroups_users WHERE user_id = '".$bean_id."' AND securitygroup_id = '".$group."' AND deleted=0";
}
$id = $this->db->getOne($sql);
if ($id != '') {
return true;
}
return false;
}
/**
* Run the actions against the passed $bean
*/
public function run_actions(SugarBean &$bean, $in_save = false)
{
require_once('modules/AOW_Processed/AOW_Processed.php');
$processed = BeanFactory::newBean('AOW_Processed');
if (!$this->multiple_runs) {
$processed->retrieve_by_string_fields(array('aow_workflow_id' => $this->id,'parent_id' => $bean->id));
if ($processed->status == 'Complete') {
//should not have gotten this far, so return
return true;
}
}
$processed->aow_workflow_id = $this->id;
$processed->parent_id = $bean->id;
$processed->parent_type = $bean->module_dir;
$processed->status = 'Running';
$processed->save(false);
$processed->load_relationship('aow_actions');
$pass = true;
$sql = "SELECT id FROM aow_actions WHERE aow_workflow_id = '".$this->id."' AND deleted = 0 ORDER BY action_order ASC";
$result = $this->db->query($sql);
while ($row = $this->db->fetchByAssoc($result)) {
$action = BeanFactory::newBean('AOW_Actions');
$action->retrieve($row['id']);
if ($this->multiple_runs || !$processed->db->getOne("select id from aow_processed_aow_actions where aow_processed_id = '".$processed->id."' AND aow_action_id = '".$action->id."' AND status = 'Complete'")) {
$action_name = 'action'.$action->action;
if (file_exists('custom/modules/AOW_Actions/actions/'.$action_name.'.php')) {
require_once('custom/modules/AOW_Actions/actions/'.$action_name.'.php');
} elseif (file_exists('modules/AOW_Actions/actions/'.$action_name.'.php')) {
require_once('modules/AOW_Actions/actions/'.$action_name.'.php');
} else {
if (file_exists('modules/AOW_Actions/actions/'.$action_name.'.php')) {
require_once('modules/AOW_Actions/actions/'.$action_name.'.php');
} else {
return false;
}
}
$custom_action_name = "custom" . $action_name;
if (class_exists($custom_action_name)) {
$action_name = $custom_action_name;
}
$flow_action = new $action_name($action->id);
if (!$flow_action->run_action($bean, unserialize(base64_decode($action->parameters)), $in_save)) {
$pass = false;
$processed->aow_actions->add($action->id, array('status' => 'Failed'));
} else {
$processed->aow_actions->add($action->id, array('status' => 'Complete'));
}
}
}
if ($pass) {
$processed->status = 'Complete';
} else {
$processed->status = 'Failed';
}
$processed->save(false);
return $pass;
}
}

View file

@ -0,0 +1,35 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
global $app_strings;
$dashletMeta['AOW_WorkFlowDashlet'] = array('module' => 'AOW_WorkFlow',
'title' => translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow'),
'description' => 'A customizable view into WorkFlow',
'icon' => 'icon_AOW_WorkFlow_32.gif',
'category' => 'Module Views');

View file

@ -0,0 +1,52 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
require_once('include/Dashlets/DashletGeneric.php');
require_once('modules/AOW_WorkFlow/AOW_WorkFlow.php');
class AOW_WorkFlowDashlet extends DashletGeneric
{
public function __construct($id, $def = null)
{
global $current_user, $app_strings;
require('modules/AOW_WorkFlow/metadata/dashletviewdefs.php');
parent::__construct($id, $def);
if (empty($def['title'])) {
$this->title = translate('LBL_HOMEPAGE_TITLE', 'AOW_WorkFlow');
}
$this->searchFields = $dashletData['AOW_WorkFlowDashlet']['searchFields'];
$this->columns = $dashletData['AOW_WorkFlowDashlet']['columns'];
$this->seedBean = BeanFactory::newBean('AOW_WorkFlow');
}
}

39
modules/AOW_WorkFlow/Menu.php Executable file
View file

@ -0,0 +1,39 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
global $mod_strings, $app_strings, $sugar_config;
if (ACLController::checkAccess('AOW_WorkFlow', 'edit', true)) {
$module_menu[]=array("index.php?module=AOW_WorkFlow&action=EditView&return_module=AOW_WorkFlow&return_action=DetailView", $mod_strings['LNK_NEW_RECORD'],"Create", 'AOW_WorkFlow');
}
if (ACLController::checkAccess('AOW_WorkFlow', 'list', true)) {
$module_menu[]=array("index.php?module=AOW_WorkFlow&action=index&return_module=AOW_WorkFlow&return_action=DetailView", $mod_strings['LNK_LIST'],"List", 'AOW_WorkFlow');
}
if (ACLController::checkAccess('AOW_Processed', 'list', true)) {
$module_menu[]=array("index.php?module=AOW_Processed&action=index&return_module=AOW_Processed&return_action=DetailView", $mod_strings['LNK_PROCESSED_LIST'],"View_Process_Audit", 'AOW_Processed');
}

1020
modules/AOW_WorkFlow/aow_utils.php Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,620 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
require_once("modules/AOW_WorkFlow/aow_utils.php");
class AOW_WorkFlowController extends SugarController
{
protected function action_getModuleFields()
{
if (!empty($_REQUEST['aow_module']) && $_REQUEST['aow_module'] != '') {
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$module = $_REQUEST['aow_module'];
}
$override = array();
if (isset($_REQUEST['override']) && is_array($_REQUEST['override'])) {
$override = $_REQUEST['override'];
}
$view = isset($_REQUEST['view']) ? $_REQUEST['view'] : 'EditView';
$value = isset($_REQUEST['aow_value']) ? $_REQUEST['aow_value'] : '';
echo getModuleFields($module, $view, $value, array(), $override);
}
die;
}
protected function action_getRelatedModule()
{
if (!empty($_REQUEST['aow_module']) && $_REQUEST['aow_module'] != '') {
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$module = $_REQUEST['aow_module'];
}
echo htmlspecialchars($module);
}
die;
}
protected function action_getModuleRelationships()
{
if (!empty($_REQUEST['aow_module']) && $_REQUEST['aow_module'] != '') {
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$module = $_REQUEST['aow_module'];
}
echo getModuleRelationships($module);
}
die;
}
protected function action_getModuleOperatorField()
{
global $app_list_strings, $beanFiles, $beanList;
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$module = $_REQUEST['aow_module'];
}
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
require_once($beanFiles[$beanList[$module]]);
$focus = new $beanList[$module];
$vardef = $focus->getFieldDefinition($fieldname);
if ($vardef) {
switch ($vardef['type']) {
case 'double':
case 'decimal':
case 'float':
case 'currency':
$valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To','is_null');
break;
case 'uint':
case 'ulong':
case 'long':
case 'short':
case 'tinyint':
case 'int':
$valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To','is_null');
break;
case 'date':
case 'datetime':
case 'datetimecombo':
$valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To','is_null');
break;
case 'enum':
case 'multienum':
$valid_opp = array('Equal_To','Not_Equal_To','is_null');
break;
default:
$valid_opp = array('Equal_To','Not_Equal_To','Contains', 'Starts_With', 'Ends_With','is_null');
break;
}
foreach ($app_list_strings['aow_operator_list'] as $key => $keyValue) {
if (!in_array($key, $valid_opp)) {
unset($app_list_strings['aow_operator_list'][$key]);
}
}
$app_list_strings['aow_operator_list'];
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_operator_list'], $value) ."</select>";
} else {
echo $app_list_strings['aow_operator_list'][$value];
}
}
die;
}
protected function action_getFieldTypeOptions()
{
global $app_list_strings, $beanFiles, $beanList;
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$module = $_REQUEST['aow_module'];
}
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
require_once($beanFiles[$beanList[$module]]);
$focus = new $beanList[$module];
$vardef = $focus->getFieldDefinition($fieldname);
switch ($vardef['type']) {
case 'double':
case 'decimal':
case 'float':
case 'currency':
$valid_opp = array('Value','Field','Any_Change');
break;
case 'uint':
case 'ulong':
case 'long':
case 'short':
case 'tinyint':
case 'int':
$valid_opp = array('Value','Field','Any_Change');
break;
case 'date':
case 'datetime':
case 'datetimecombo':
$valid_opp = array('Value','Field','Any_Change','Date');
break;
case 'enum':
case 'dynamicenum':
case 'multienum':
$valid_opp = array('Value','Field','Any_Change', 'Multi');
break;
case 'relate':
case 'id':
$valid_opp = array('Value','Field','Any_Change', 'SecurityGroup');
break;
default:
$valid_opp = array('Value','Field','Any_Change');
break;
}
if (!file_exists('modules/SecurityGroups/SecurityGroup.php')) {
unset($app_list_strings['aow_condition_type_list']['SecurityGroup']);
}
foreach ($app_list_strings['aow_condition_type_list'] as $key => $keyValue) {
if (!in_array($key, $valid_opp)) {
unset($app_list_strings['aow_condition_type_list'][$key]);
}
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_condition_type_list'], $value) ."</select>";
} else {
echo $app_list_strings['aow_condition_type_list'][$value];
}
die;
}
protected function action_getActionFieldTypeOptions()
{
global $app_list_strings, $beanFiles, $beanList;
$module = $_REQUEST['aow_module'];
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
require_once($beanFiles[$beanList[$module]]);
$focus = new $beanList[$module];
$vardef = $focus->getFieldDefinition($fieldname);
switch ($vardef['type']) {
case 'double':
case 'decimal':
case 'float':
case 'currency':
$valid_opp = array('Value','Field');
break;
case 'uint':
case 'ulong':
case 'long':
case 'short':
case 'tinyint':
case 'int':
$valid_opp = array('Value','Field');
break;
case 'date':
case 'datetime':
case 'datetimecombo':
$valid_opp = array('Value','Field', 'Date');
break;
case 'enum':
case 'multienum':
$valid_opp = array('Value','Field');
break;
case 'relate':
$valid_opp = array('Value','Field');
if ($vardef['module'] == 'Users') {
$valid_opp = array('Value','Field','Round_Robin','Least_Busy','Random');
}
break;
default:
$valid_opp = array('Value','Field');
break;
}
foreach ($app_list_strings['aow_action_type_list'] as $key => $keyValue) {
if (!in_array($key, $valid_opp)) {
unset($app_list_strings['aow_action_type_list'][$key]);
}
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_action_type_list'], $value) ."</select>";
} else {
echo $app_list_strings['aow_action_type_list'][$value];
}
die;
}
protected function action_getModuleFieldType()
{
if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
$rel_module = getRelatedModule($_REQUEST['aow_module'], $_REQUEST['rel_field']);
} else {
$rel_module = $_REQUEST['aow_module'];
}
$module = $_REQUEST['aow_module'];
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
switch ($_REQUEST['aow_type']) {
case 'Field':
if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
$module = $_REQUEST['alt_module'];
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field ' title='' tabindex='116'>". getModuleFields($module, $view, $value, getValidFieldsTypes($module, $fieldname)) ."</select>";
} else {
echo getModuleFields($module, $view, $value);
}
break;
case 'Any_Change':
echo '';
break;
case 'Date':
echo getDateField($module, $aow_field, $view, $value, false);
break;
case 'Multi':
echo getModuleField($rel_module, $fieldname, $aow_field, $view, $value, 'multienum');
break;
case 'SecurityGroup':
$module = 'Accounts';
$fieldname = 'SecurityGroups';
// no break
case 'Value':
default:
echo getModuleField($rel_module, $fieldname, $aow_field, $view, $value);
break;
}
die;
}
protected function action_getModuleFieldTypeSet()
{
$module = $_REQUEST['aow_module'];
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
switch ($_REQUEST['aow_type']) {
case 'Field':
$valid_fields = getValidFieldsTypes($module, $fieldname);
if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
$module = $_REQUEST['alt_module'];
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field ' title='' tabindex='116'>". getModuleFields($module, $view, $value, $valid_fields) ."</select>";
} else {
echo getModuleFields($module, $view, $value);
}
break;
case 'Date':
if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
$module = $_REQUEST['alt_module'];
}
echo getDateField($module, $aow_field, $view, $value);
break;
case 'Round_Robin':
case 'Least_Busy':
case 'Random':
echo getAssignField($aow_field, $view, $value);
break;
case 'Value':
default:
echo getModuleField($module, $fieldname, $aow_field, $view, $value);
break;
}
die;
}
protected function action_getModuleField()
{
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
echo getModuleField($_REQUEST['aow_module'], $_REQUEST['aow_fieldname'], $_REQUEST['aow_newfieldname'], $view, $value);
die;
}
protected function action_getRelFieldTypeSet()
{
$module = $_REQUEST['aow_module'];
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
switch ($_REQUEST['aow_type']) {
case 'Field':
if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
$module = $_REQUEST['alt_module'];
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field ' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
} else {
echo getModuleFields($module, $view, $value);
}
break;
case 'Value':
default:
echo getModuleField($module, $fieldname, $aow_field, $view, $value);
break;
}
die;
}
protected function action_getRelActionFieldTypeOptions()
{
global $app_list_strings, $beanFiles, $beanList;
$module = $_REQUEST['aow_module'];
$alt_module = $_REQUEST['alt_module'];
$fieldname = $_REQUEST['aow_fieldname'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
require_once($beanFiles[$beanList[$module]]);
$focus = new $beanList[$module];
$vardef = $focus->getFieldDefinition($fieldname);
/*if($vardef['module'] == $alt_module){
$valid_opp = array('Value','Field');
}
else{
$valid_opp = array('Value');
}*/
$valid_opp = array('Value','Field');
foreach ($app_list_strings['aow_rel_action_type_list'] as $key => $keyValue) {
if (!in_array($key, $valid_opp)) {
unset($app_list_strings['aow_rel_action_type_list'][$key]);
}
}
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_rel_action_type_list'], $value) ."</select>";
} else {
echo $app_list_strings['aow_rel_action_type_list'][$value];
}
die;
}
protected function action_getAction()
{
global $beanList, $beanFiles;
$action_name = 'action'.$_REQUEST['aow_action'];
$line = $_REQUEST['line'];
if ($_REQUEST['aow_module'] == '' || !isset($beanList[$_REQUEST['aow_module']])) {
echo '';
die;
}
if (file_exists('custom/modules/AOW_Actions/actions/'.$action_name.'.php')) {
require_once('custom/modules/AOW_Actions/actions/'.$action_name.'.php');
} else {
if (file_exists('modules/AOW_Actions/actions/'.$action_name.'.php')) {
require_once('modules/AOW_Actions/actions/'.$action_name.'.php');
} else {
echo '';
die;
}
}
$custom_action_name = "custom" . $action_name;
if (class_exists($custom_action_name)) {
$action_name = $custom_action_name;
}
$id = '';
$params = array();
if (isset($_REQUEST['id'])) {
require_once('modules/AOW_Actions/AOW_Action.php');
$aow_action = BeanFactory::newBean('AOW_Actions');
$aow_action->retrieve($_REQUEST['id']);
$id = $aow_action->id;
$params = unserialize(base64_decode($aow_action->parameters));
}
$action = new $action_name($id);
require_once($beanFiles[$beanList[$_REQUEST['aow_module']]]);
$bean = new $beanList[$_REQUEST['aow_module']];
echo $action->edit_display($line, $bean, $params);
die;
}
protected function action_getEmailField()
{
$module = $_REQUEST['aow_module'];
$aow_field = $_REQUEST['aow_newfieldname'];
if (isset($_REQUEST['view'])) {
$view = $_REQUEST['view'];
} else {
$view= 'EditView';
}
if (isset($_REQUEST['aow_value'])) {
$value = $_REQUEST['aow_value'];
} else {
$value = '';
}
switch ($_REQUEST['aow_type']) {
case 'Record Email':
echo '';
break;
case 'Related Field':
$rel_field_list = getRelatedEmailableFields($module);
if ($view == 'EditView') {
echo "<select type='text' name='$aow_field' id='$aow_field' title='' tabindex='116'>". get_select_options_with_id($rel_field_list, $value) ."</select>";
} else {
echo $rel_field_list[$value];
}
break;
case 'Specify User':
echo getModuleField('Accounts', 'assigned_user_name', $aow_field, $view, $value);
break;
case 'Users':
echo getAssignField($aow_field, $view, $value);
break;
case 'Email Address':
default:
if ($view == 'EditView') {
echo "<input type='text' name='$aow_field' id='$aow_field' size='25' title='' tabindex='116' value='$value'>";
} else {
echo $value;
}
break;
}
die;
}
protected function action_testFlow()
{
echo 'Started<br />';
require_once('modules/AOW_WorkFlow/AOW_WorkFlow.php');
$workflow = BeanFactory::newBean('AOW_WorkFlow');
if ($workflow->run_flows()) {
echo 'PASSED';
}
}
}

View file

@ -0,0 +1,80 @@
<?php
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2019 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
$mod_strings = array(
'LBL_ASSIGNED_TO_ID' => 'Assigned User Id',
'LBL_ASSIGNED_TO_NAME' => 'Assigned to',
'LBL_ID' => 'ID',
'LBL_DATE_ENTERED' => 'Date Created',
'LBL_DATE_MODIFIED' => 'Date Modified',
'LBL_MODIFIED' => 'Modified By',
'LBL_MODIFIED_NAME' => 'Modified By Name',
'LBL_CREATED' => 'Created By',
'LBL_DESCRIPTION' => 'Description',
'LBL_DELETED' => 'Deleted',
'LBL_NAME' => 'Name',
'LBL_CREATED_USER' => 'Created by User',
'LBL_MODIFIED_USER' => 'Modified by User',
'LBL_LIST_NAME' => 'Name',
'LBL_LIST_FORM_TITLE' => 'WorkFlow List',
'LBL_MODULE_NAME' => 'WorkFlow',
'LBL_MODULE_TITLE' => 'WorkFlow',
'LBL_HOMEPAGE_TITLE' => 'My Work Flow',
'LNK_NEW_RECORD' => 'Create WorkFlow',
'LNK_LIST' => 'View WorkFlow',
'LNK_PROCESSED_LIST' => 'View Process Audit',
'LBL_SEARCH_FORM_TITLE' => 'Search WorkFlow',
'LBL_HISTORY_SUBPANEL_TITLE' => 'View History',
'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities',
'LBL_NEW_FORM_TITLE' => 'New WorkFlow',
'LBL_FLOW_MODULE' => 'WorkFlow Module',
'LBL_STATUS' => 'Status',
'LBL_FLOW_RUN_ON' => 'Run On',
'LBL_CONDITION_LINES' => 'Conditions',
'LBL_ADD_CONDITION' => 'Add Condition',
'LBL_ACTION_LINES' => 'Actions',
'LBL_ADD_ACTION' => 'Add Action',
'LBL_MULTIPLE_RUNS' => 'Repeated Runs',
'LBL_RUN_WHEN' => 'Run'
);

View file

@ -0,0 +1,43 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$searchFields['AOW_WorkFlow'] =
array(
'name' => array( 'query_type'=>'default'),
'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
'assigned_user_id'=> array('query_type'=>'default'),
//Range Search Support
'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
//Range Search Support
);

View file

@ -0,0 +1,51 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
global $current_user;
$dashletData['AOW_WorkFlowDashlet']['searchFields'] = array('date_entered' => array('default' => ''),
'date_modified' => array('default' => ''),
'assigned_user_id' => array('type' => 'assigned_user_name',
'default' => $current_user->name));
$dashletData['AOW_WorkFlowDashlet']['columns'] = array( 'name' => array('width' => '40',
'label' => 'LBL_LIST_NAME',
'link' => true,
'default' => true),
'date_entered' => array('width' => '15',
'label' => 'LBL_DATE_ENTERED',
'default' => true),
'date_modified' => array('width' => '15',
'label' => 'LBL_DATE_MODIFIED'),
'created_by' => array('width' => '8',
'label' => 'LBL_CREATED'),
'assigned_user_name' => array('width' => '8',
'label' => 'LBL_LIST_ASSIGNED_USER'),
);

View file

@ -0,0 +1,157 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$viewdefs ['AOW_WorkFlow'] =
array(
'DetailView' =>
array(
'templateMeta' =>
array(
'form' =>
array(
'buttons' =>
array(
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
),
),
'maxColumns' => '2',
'widths' =>
array(
0 =>
array(
'label' => '10',
'field' => '30',
),
1 =>
array(
'label' => '10',
'field' => '30',
),
),
'useTabs' => false,
'tabDefs' =>
array(
'DEFAULT' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
'CONDITIONS' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
'ACTIONS' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
),
),
'panels' =>
array(
'default' =>
array(
0 =>
array(
0 => 'name',
1 => 'assigned_user_name',
),
1 =>
array(
0 =>
array(
'name' => 'flow_module',
'studio' => 'visible',
'label' => 'LBL_FLOW_MODULE',
),
1 =>
array(
'name' => 'status',
'studio' => 'visible',
'label' => 'LBL_STATUS',
),
),
2 =>
array(
0 =>
array(
'name' => 'run_when',
'label' => 'LBL_RUN_WHEN',
),
1 =>
array(
'name' => 'flow_run_on',
'studio' => 'visible',
'label' => 'LBL_FLOW_RUN_ON',
),
),
3 =>
array(
0 =>
array(
'name' => 'multiple_runs',
'label' => 'LBL_MULTIPLE_RUNS',
),
),
4 =>
array(
0 => 'description',
),
5 =>
array(
0 =>
array(
'name' => 'date_entered',
'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}',
'label' => 'LBL_DATE_ENTERED',
),
1 =>
array(
'name' => 'date_modified',
'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}',
'label' => 'LBL_DATE_MODIFIED',
),
),
),
'LBL_CONDITION_LINES' =>
array(
0 =>
array(
0 => 'condition_lines',
),
),
'LBL_ACTION_LINES' =>
array(
0 =>
array(
0 => 'action_lines',
),
),
),
),
);

View file

@ -0,0 +1,133 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$viewdefs ['AOW_WorkFlow'] =
array(
'EditView' =>
array(
'templateMeta' =>
array(
'maxColumns' => '2',
'widths' =>
array(
0 =>
array(
'label' => '10',
'field' => '30',
),
1 =>
array(
'label' => '10',
'field' => '30',
),
),
'useTabs' => false,
'tabDefs' =>
array(
'DEFAULT' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
'CONDITIONS' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
'ACTIONS' =>
array(
'newTab' => false,
'panelDefault' => 'expanded',
),
),
'syncDetailEditViews' => false,
),
'panels' =>
array(
'default' =>
array(
0 =>
array(
0 => 'name',
1 => 'assigned_user_name',
),
1 =>
array(
0 =>
array(
'name' => 'flow_module',
'studio' => 'visible',
'label' => 'LBL_FLOW_MODULE',
),
1 =>
array(
'name' => 'status',
'studio' => 'visible',
'label' => 'LBL_STATUS',
),
),
2 =>
array(
0 =>
array(
'name' => 'run_when',
'label' => 'LBL_RUN_WHEN',
),
1 =>
array(
'name' => 'flow_run_on',
'studio' => 'visible',
'label' => 'LBL_FLOW_RUN_ON',
),
),
3 =>
array(
0 =>
array(
'name' => 'multiple_runs',
'label' => 'LBL_MULTIPLE_RUNS',
),
),
4 =>
array(
0 => 'description',
),
),
'LBL_CONDITION_LINES' =>
array(
0 =>
array(
0 => 'condition_lines',
),
),
'LBL_ACTION_LINES' =>
array(
0 =>
array(
0 => 'action_lines',
),
),
),
),
);

View file

@ -0,0 +1,72 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$listViewDefs ['AOW_WorkFlow'] =
array(
'NAME' =>
array(
'width' => '15%',
'label' => 'LBL_NAME',
'default' => true,
'link' => true,
),
'FLOW_MODULE' =>
array(
'type' => 'enum',
'default' => true,
'studio' => 'visible',
'label' => 'LBL_FLOW_MODULE',
'width' => '15%',
),
'STATUS' =>
array(
'type' => 'enum',
'default' => true,
'studio' => 'visible',
'label' => 'LBL_STATUS',
'width' => '15%',
),
'ASSIGNED_USER_NAME' =>
array(
'width' => '15%',
'label' => 'LBL_ASSIGNED_TO_NAME',
'module' => 'Employees',
'id' => 'ASSIGNED_USER_ID',
'default' => true,
),
'DATE_ENTERED' =>
array(
'type' => 'datetime',
'label' => 'LBL_DATE_ENTERED',
'width' => '15%',
'default' => true,
),
'DATE_MODIFIED' =>
array(
'type' => 'datetime',
'label' => 'LBL_DATE_MODIFIED',
'width' => '10%',
'default' => true,
),
);

View file

@ -0,0 +1,33 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$metafiles['AOW_WorkFlow'] = array(
'detailviewdefs' => 'modules/AOW_WorkFlow/metadata/detailviewdefs.php',
'editviewdefs' => 'modules/AOW_WorkFlow/metadata/editviewdefs.php',
'listviewdefs' => 'modules/AOW_WorkFlow/metadata/listviewdefs.php',
'searchdefs' => 'modules/AOW_WorkFlow/metadata/searchdefs.php',
'popupdefs' => 'modules/AOW_WorkFlow/metadata/popupdefs.php',
'searchfields' => 'modules/AOW_WorkFlow/metadata/SearchFields.php',
);

View file

@ -0,0 +1,37 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$popupMeta = array('moduleMain' => 'AOW_WorkFlow',
'varName' => 'AOW_WorkFlow',
'orderBy' => 'aow_workflow.name',
'whereClauses' =>
array('name' => 'aow_workflow.name',
),
'searchInputs'=> array('aow_workflow_number', 'name', 'priority','status'),
);

View file

@ -0,0 +1,47 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$viewdefs['AOW_WorkFlow']['QuickCreate'] = array(
'templateMeta' => array('maxColumns' => '2',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30')
),
),
'panels' =>array(
'default' =>
array(
array(
'name',
'assigned_user_name',
),
),
),
);

View file

@ -0,0 +1,44 @@
<?php
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$module_name = 'AOW_WorkFlow';
$searchdefs['AOW_WorkFlow'] = array(
'templateMeta' => array(
'maxColumns' => '3',
'maxColumnsBasic' => '4',
'widths' => array('label' => '10', 'field' => '30'),
),
'layout' => array(
'basic_search' => array(
'name',
array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
),
'advanced_search' => array(
'name',
'status',
'flow_module',
array('name' => 'assigned_user_id', 'label' => 'LBL_ASSIGNED_TO', 'type' => 'enum', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
),
),
);

View file

@ -0,0 +1,42 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
* Advanced OpenWorkflow, Automating SugarCRM.
* @package Advanced OpenWorkflow for SugarCRM
* @copyright SalesAgility Ltd http://www.salesagility.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with this program; if not, see http://www.gnu.org/licenses
* or write to the Free Software Foundation,Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA
*
* @author SalesAgility <info@salesagility.com>
*/
$layout_defs['AOW_WorkFlow'] = array(
'subpanel_setup' => array(
'aow_processed' =>
array(
'order' => 100,
'module' => 'AOW_Processed',
'subpanel_name' => 'default',
'sort_order' => 'desc',
'sort_by' => 'date_entered',
'title_key' => 'AOW_Processed',
'get_subpanel_data' => 'aow_processed',
),
),
);

View file

@ -0,0 +1,73 @@
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
$subpanel_layout = array(
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'AOW_WorkFlow'),
),
'where' => '',
'list_fields' => array(
'name'=>array(
'vname' => 'LBL_NAME',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '45%',
),
'date_modified'=>array(
'vname' => 'LBL_DATE_MODIFIED',
'width' => '45%',
),
'edit_button'=>array(
'widget_class' => 'SubPanelEditButton',
'module' => 'AOW_WorkFlow',
'width' => '4%',
),
'remove_button'=>array(
'widget_class' => 'SubPanelRemoveButton',
'module' => 'AOW_WorkFlow',
'width' => '5%',
),
),
);

262
modules/AOW_WorkFlow/vardefs.php Executable file
View file

@ -0,0 +1,262 @@
<?php
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
$dictionary['AOW_WorkFlow'] = array(
'table' => 'aow_workflow',
'audited' => true,
'duplicate_merge' => true,
'fields' => array(
'flow_module' =>
array(
'required' => true,
'name' => 'flow_module',
'vname' => 'LBL_FLOW_MODULE',
'type' => 'enum',
'massupdate' => 0,
'default' => '',
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'len' => 100,
'size' => '20',
'options' => 'aow_moduleList',
'studio' => 'visible',
'dependency' => false,
),
'flow_run_on' =>
array(
'required' => true,
'name' => 'flow_run_on',
'vname' => 'LBL_RUN_ON',
'type' => 'enum',
'massupdate' => 0,
'default' => '0',
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'len' => 100,
'size' => '20',
'options' => 'aow_run_on_list',
'studio' => 'visible',
'dependency' => false,
),
'status' =>
array(
'required' => false,
'name' => 'status',
'vname' => 'LBL_STATUS',
'type' => 'enum',
'massupdate' => 1,
'default' => 'Active',
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'len' => 100,
'size' => '20',
'options' => 'aow_status_list',
'studio' => 'visible',
'dependency' => false,
),
'run_when' =>
array(
'required' => false,
'name' => 'run_when',
'vname' => 'LBL_RUN_WHEN',
'type' => 'enum',
'massupdate' => 0,
'default' => 'Always',
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'len' => 100,
'size' => '20',
'options' => 'aow_run_when_list',
'studio' => 'visible',
'dependency' => false,
),
'multiple_runs' =>
array(
'name' => 'multiple_runs',
'vname' => 'LBL_MULTIPLE_RUNS',
'type' => 'bool',
'default' => '0',
'reportable' => false,
),
'condition_lines' =>
array(
'required' => false,
'name' => 'condition_lines',
'vname' => 'LBL_CONDITION_LINES',
'type' => 'function',
'source' => 'non-db',
'massupdate' => 0,
'importable' => 'false',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => 0,
'audited' => false,
'reportable' => false,
'inline_edit' => false,
'function' =>
array(
'name' => 'display_condition_lines',
'returns' => 'html',
'include' => 'modules/AOW_Conditions/conditionLines.php'
),
),
'action_lines' =>
array(
'required' => false,
'name' => 'action_lines',
'vname' => 'LBL_ACTION_LINES',
'type' => 'function',
'source' => 'non-db',
'massupdate' => 0,
'importable' => 'false',
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => 0,
'audited' => false,
'reportable' => false,
'inline_edit' => false,
'function' =>
array(
'name' => 'display_action_lines',
'returns' => 'html',
'include' => 'modules/AOW_Actions/actionLines.php'
),
),
'aow_conditions' =>
array(
'name' => 'aow_conditions',
'type' => 'link',
'relationship' => 'aow_workflow_aow_conditions',
'module' => 'AOW_Conditions',
'bean_name' => 'AOW_Condition',
'source' => 'non-db',
),
'aow_actions' =>
array(
'name' => 'aow_actions',
'type' => 'link',
'relationship' => 'aow_workflow_aow_actions',
'module' => 'AOW_Actions',
'bean_name' => 'AOW_Action',
'source' => 'non-db',
),
'aow_processed' =>
array(
'name' => 'aow_processed',
'type' => 'link',
'relationship' => 'aow_workflow_aow_processed',
'module' => 'AOW_Processed',
'bean_name' => 'AOW_Processed',
'source' => 'non-db',
),
),
'relationships' => array(
'aow_workflow_aow_conditions' =>
array(
'lhs_module' => 'AOW_WorkFlow',
'lhs_table' => 'aow_workflow',
'lhs_key' => 'id',
'rhs_module' => 'AOW_Conditions',
'rhs_table' => 'aow_conditions',
'rhs_key' => 'aow_workflow_id',
'relationship_type' => 'one-to-many',
),
'aow_workflow_aow_actions' =>
array(
'lhs_module' => 'AOW_WorkFlow',
'lhs_table' => 'aow_workflow',
'lhs_key' => 'id',
'rhs_module' => 'AOW_Actions',
'rhs_table' => 'aow_actions',
'rhs_key' => 'aow_workflow_id',
'relationship_type' => 'one-to-many',
),
'aow_workflow_aow_processed' =>
array(
'lhs_module' => 'AOW_WorkFlow',
'lhs_table' => 'aow_workflow',
'lhs_key' => 'id',
'rhs_module' => 'AOW_Processed',
'rhs_table' => 'aow_processed',
'rhs_key' => 'aow_workflow_id',
'relationship_type' => 'one-to-many',
),
),
'indices' => array(
array(
'name' => 'aow_workflow_index_status',
'type' => 'index',
'fields' => array('status'),
),
),
'optimistic_locking' => true,
'unified_search' => true,
);
if (!class_exists('VardefManager')) {
require_once('include/SugarObjects/VardefManager.php');
}
VardefManager::createVardef('AOW_WorkFlow', 'AOW_WorkFlow', array('basic', 'assignable', 'security_groups'));