PMC-155-B
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Method defined and copied from processmaker/workflow/engine/classes/class.configuration.php
|
||||
* Get default configuration for Cases List.
|
||||
*
|
||||
* @param string $action
|
||||
* @param int $translation
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function casesListDefaultFieldsAndConfig($action, $translation = 1)
|
||||
{
|
||||
@@ -322,6 +329,16 @@ function casesListDefaultFieldsAndConfig($action, $translation = 1)
|
||||
return array("caseColumns" => $caseColumns, "caseReaderFields" => $caseReaderFields, "rowsperpage" => 20, "dateformat" => "M d, Y");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default configuration and verify if casesListDefaultFieldsAndConfig method exist.
|
||||
*
|
||||
* @param string $action
|
||||
* @param int $translation
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function getDefaultConfig($action, $translation)
|
||||
{
|
||||
$config = new Configurations();
|
||||
@@ -335,6 +352,16 @@ function getDefaultConfig($action, $translation)
|
||||
return $arrayConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default fields configuration.
|
||||
*
|
||||
* @param string $action
|
||||
* @param int $translation
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function getDefaultFields($action, $translation)
|
||||
{
|
||||
$config = new Configurations();
|
||||
@@ -405,6 +432,16 @@ function getDefaultFields($action, $translation)
|
||||
return $arrayField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set available fields.
|
||||
*
|
||||
* @param array $arrayAvailableField
|
||||
* @param array $arrayField
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function setAvailableFields($arrayAvailableField, $arrayField)
|
||||
{
|
||||
$i = 0;
|
||||
@@ -427,6 +464,16 @@ function setAvailableFields($arrayAvailableField, $arrayField)
|
||||
return $arrayFieldResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Cases List fields.
|
||||
*
|
||||
* @param array $arrayCasesListField
|
||||
* @param array $arrayField
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function setCasesListFields($arrayCasesListField, $arrayField)
|
||||
{
|
||||
$i = 0;
|
||||
@@ -468,6 +515,7 @@ function setCasesListFields($arrayCasesListField, $arrayField)
|
||||
* @global string $action
|
||||
* @global array $confCasesList
|
||||
* @global string $tabUid
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
@@ -477,21 +525,21 @@ function fieldSet()
|
||||
global $confCasesList;
|
||||
global $tabUid;
|
||||
|
||||
$arrayField = getDefaultFields($action, 0);
|
||||
$arrayConfig = getDefaultConfig($action, 0);
|
||||
$result = genericJsonResponse($tabUid, [], $arrayField, $arrayConfig["rowsperpage"], $arrayConfig["dateformat"]);
|
||||
$result['first']['data'] = getFieldsByTabUid($tabUid);
|
||||
|
||||
$confCasesList = (array) $confCasesList;
|
||||
|
||||
$result = [];
|
||||
$sw1 = !empty($confCasesList);
|
||||
$sw2 = $tabUid === "" || (!empty($tabUid) && !empty($confCasesList['PMTable']) && $confCasesList['PMTable'] === $tabUid);
|
||||
|
||||
if ($sw1 && $sw2) {
|
||||
$result = $confCasesList;
|
||||
} else {
|
||||
$fields = getFieldsByTabUid($tabUid);
|
||||
$arrayField = getDefaultFields($action, 0);
|
||||
$arrayConfig = getDefaultConfig($action, 0);
|
||||
$generic = genericJsonResponse($tabUid, [], $arrayField, $arrayConfig["rowsperpage"], $arrayConfig["dateformat"]);
|
||||
$result = $generic;
|
||||
$result['first']['data'] = $fields;
|
||||
if (!empty($confCasesList)) {
|
||||
if (!empty($tabUid) && empty($confCasesList['PMTable'])) {
|
||||
$confCasesList['PMTable'] = $tabUid;
|
||||
$confCasesList['first']['data'] = getFieldsByTabUid($tabUid);
|
||||
}
|
||||
if (!empty($confCasesList['PMTable']) && empty($tabUid)) {
|
||||
$result = $confCasesList;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($result) && isset($result['second']['data'])) {
|
||||
@@ -502,6 +550,15 @@ function fieldSet()
|
||||
echo G::json_encode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset fields configuration.
|
||||
*
|
||||
* @global string $action
|
||||
* @param int $translation
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function fieldReset($translation)
|
||||
{
|
||||
global $action;
|
||||
@@ -514,6 +571,15 @@ function fieldReset($translation)
|
||||
echo G::json_encode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a field.
|
||||
*
|
||||
* @global string $action
|
||||
* @param int $translation
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function fieldComplete($translation)
|
||||
{
|
||||
|
||||
@@ -579,6 +645,15 @@ function fieldComplete($translation)
|
||||
echo G::json_encode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset field label.
|
||||
*
|
||||
* @global string $action
|
||||
* @param int $translation
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function fieldLabelReset($translation)
|
||||
{
|
||||
|
||||
@@ -618,6 +693,15 @@ function fieldLabelReset($translation)
|
||||
echo G::json_encode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a field.
|
||||
*
|
||||
* @global object $conf
|
||||
* @global string $action
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function fieldSave()
|
||||
{
|
||||
|
||||
@@ -731,14 +815,20 @@ try {
|
||||
G::outRes( G::json_encode( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* set the generic Json Response, using two array for the grid stores and a string for the pmtable name
|
||||
* @param string $pmtable
|
||||
* @param array $first
|
||||
* @param array $second
|
||||
* @return $response a json string
|
||||
*/
|
||||
function genericJsonResponse($pmtable, $first, $second, $rowsperpage, $dateFormat)
|
||||
/**
|
||||
* Set the generic Json Response, using two array for the grid stores and a string for the pmtable name.
|
||||
*
|
||||
* @param string $pmtable
|
||||
* @param array $first
|
||||
* @param array $second
|
||||
* @param array $rowsPerPage
|
||||
* @param string $dateFormat
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function genericJsonResponse($pmtable, $first, $second, $rowsPerPage, $dateFormat)
|
||||
{
|
||||
$firstGrid['totalCount'] = count($first);
|
||||
$firstGrid['data'] = $first;
|
||||
@@ -748,7 +838,7 @@ function genericJsonResponse($pmtable, $first, $second, $rowsperpage, $dateForma
|
||||
$result['first'] = $firstGrid;
|
||||
$result['second'] = $secondGrid;
|
||||
$result['PMTable'] = isset($pmtable) ? $pmtable : '';
|
||||
$result['rowsperpage'] = isset($rowsperpage) ? $rowsperpage : 20;
|
||||
$result['rowsperpage'] = isset($rowsPerPage) ? $rowsPerPage : 20;
|
||||
$result['dateformat'] = isset($dateFormat) && $dateFormat != '' ? $dateFormat : 'M d, Y';
|
||||
return $result;
|
||||
}
|
||||
@@ -757,6 +847,9 @@ function genericJsonResponse($pmtable, $first, $second, $rowsperpage, $dateForma
|
||||
* Get row from PM Table.
|
||||
*
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function xgetFieldsFromPMTable($tabUid)
|
||||
{
|
||||
@@ -770,6 +863,9 @@ function xgetFieldsFromPMTable($tabUid)
|
||||
*
|
||||
* @param string $tabUid
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function getFieldsByTabUid($tabUid)
|
||||
{
|
||||
@@ -800,11 +896,14 @@ function getFieldsByTabUid($tabUid)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Array $fields
|
||||
* @return Array
|
||||
*
|
||||
*/
|
||||
* Calculate Grid index.
|
||||
*
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*
|
||||
* @see workflow/engine/methods/cases/proxyPMTablesFieldList.php
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
function calculateGridIndex($fields)
|
||||
{
|
||||
for ($i=0; $i<count( $fields ); $i++) {
|
||||
|
||||
@@ -329,6 +329,11 @@ class ReportTable
|
||||
*
|
||||
* @param array $arrayData
|
||||
* @param bool $flagAlterTable
|
||||
*
|
||||
* @see pmTablesProxy->save()
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->createStructureOfTables()
|
||||
* @see Table->validateTableBeforeUpdate()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
@@ -561,6 +566,7 @@ class ReportTable
|
||||
//Delete Report Table
|
||||
$resultDeleteReportTable = $pmTablesProxy->delete($obj);
|
||||
}
|
||||
$this->updateConfigurationCaseList($additionalTableUid, $columns);
|
||||
} catch (Exception $e) {
|
||||
$buildResult = ob_get_contents();
|
||||
|
||||
@@ -579,7 +585,6 @@ class ReportTable
|
||||
|
||||
$result->trace = $e->getTraceAsString();
|
||||
}
|
||||
$this->updateCaseListFieldsConfiguration($columns);
|
||||
//Return
|
||||
return $result;
|
||||
}
|
||||
@@ -588,8 +593,12 @@ class ReportTable
|
||||
* Update the Custom Case List fields configuration.
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function updateCaseListFieldsConfiguration($columns)
|
||||
public function updateConfigurationCaseList($addTabUid, $columns)
|
||||
{
|
||||
$actions = [
|
||||
"todo", "draft", "sent", "unassigned", "paused", "completed", "cancelled"
|
||||
@@ -597,21 +606,84 @@ class ReportTable
|
||||
$conf = new Configurations();
|
||||
foreach ($actions as $action) {
|
||||
$confCasesList = $conf->loadObject("casesList", $action, "", "", "");
|
||||
if (is_array($confCasesList) && !empty($confCasesList)) {
|
||||
$this->removeNonExistentElementsCustomCaseList($confCasesList['first']['data'], $columns);
|
||||
$this->removeNonExistentElementsCustomCaseList($confCasesList['second']['data'], $columns);
|
||||
$sw = is_array($confCasesList) && !empty($confCasesList) && !empty($confCasesList['PMTable']) && $confCasesList['PMTable'] === $addTabUid;
|
||||
if ($sw) {
|
||||
$this->addFieldsToCustomCaseList($confCasesList['first']['data'], $confCasesList['second']['data'], $columns);
|
||||
$this->removeFieldsFromCustomCaseList($confCasesList['first']['data'], $columns);
|
||||
$this->removeFieldsFromCustomCaseList($confCasesList['second']['data'], $columns);
|
||||
$conf->saveObject($confCasesList, "casesList", $action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fields to Custom Case List.
|
||||
* @param array $data1
|
||||
* @param array $data2
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function addFieldsToCustomCaseList(&$data1, $data2, $columns)
|
||||
{
|
||||
$all = [];
|
||||
$type = 'PM Table';
|
||||
$this->loadFieldTypeValues($data1, $all, $type);
|
||||
$this->loadFieldTypeValues($data2, $all, $type);
|
||||
foreach ($all as $value) {
|
||||
foreach ($columns as $index => $column) {
|
||||
if ($value['name'] === $column->field_name) {
|
||||
unset($columns[$index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$defaults = ["APP_UID", "APP_NUMBER", "APP_STATUS"];
|
||||
foreach ($defaults as $value) {
|
||||
foreach ($columns as $index => $column) {
|
||||
if ($value === $column->field_name) {
|
||||
unset($columns[$index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($columns as $value) {
|
||||
$data1[] = [
|
||||
"name" => $column->field_name,
|
||||
"fieldType" => $type
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load field type values.
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $all
|
||||
* @param string $type
|
||||
*/
|
||||
private function loadFieldTypeValues($fields, array &$all, $type)
|
||||
{
|
||||
foreach ($fields as $value) {
|
||||
if ($value['fieldType'] === $type) {
|
||||
$all[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove non existent elements in Custom Case List.
|
||||
* Remove fields from Custom Cases List.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function removeNonExistentElementsCustomCaseList(&$data, $columns)
|
||||
public function removeFieldsFromCustomCaseList(&$data, $columns)
|
||||
{
|
||||
$n = count($data);
|
||||
for ($key = 0; $key < $n; $key++) {
|
||||
|
||||
@@ -153,21 +153,23 @@ Ext.onReady(function () {
|
||||
{name: 'align', mapping : 'align'}
|
||||
];
|
||||
|
||||
//Dropdown to select the PMTable
|
||||
var PmTableStore = new Ext.data.JsonStore({
|
||||
root : 'data',
|
||||
url : 'proxyPMTablesList',
|
||||
totalProperty : 'totalCount',
|
||||
idProperty : 'gridIndex',
|
||||
remoteSort : false, //true,
|
||||
autoLoad : false,
|
||||
fields : [
|
||||
'ADD_TAB_UID', 'ADD_TAB_NAME'
|
||||
],
|
||||
listeners : {load: function() {
|
||||
tabs.setActiveTab(tabIndex);
|
||||
}}
|
||||
});
|
||||
//Dropdown to select the PMTable
|
||||
var PmTableStore = new Ext.data.JsonStore({
|
||||
root: 'data',
|
||||
url: 'proxyPMTablesList',
|
||||
totalProperty: 'totalCount',
|
||||
idProperty: 'gridIndex',
|
||||
remoteSort: false, //true,
|
||||
autoLoad: false,
|
||||
fields: [
|
||||
'ADD_TAB_UID', 'ADD_TAB_NAME'
|
||||
],
|
||||
listeners: {
|
||||
load: function () {
|
||||
tabs.setActiveTab(tabIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// create the Data Store to list PMTables in the dropdown
|
||||
var pmTablesDropdown = new Ext.form.ComboBox({
|
||||
@@ -179,6 +181,9 @@ Ext.onReady(function () {
|
||||
triggerAction: 'all',
|
||||
store: PmTableStore,
|
||||
listeners: {
|
||||
focus: function(){
|
||||
PmTableStore.load();
|
||||
},
|
||||
'select': function () {
|
||||
var tableUid = this.value;
|
||||
Ext.Ajax.request({
|
||||
@@ -479,6 +484,20 @@ Ext.onReady(function () {
|
||||
height : screen.height-245,
|
||||
layout : 'hbox',
|
||||
layoutConfig : {align : 'stretch'},
|
||||
listeners: {
|
||||
render: function (target) {
|
||||
var el;
|
||||
if (target.container && target.container.dom) {
|
||||
el = target.container.dom;
|
||||
el.style.cssText = 'overflow:hidden;position:absolute;top:28px;bottom:0px;left:0px;right:0px;';
|
||||
target.setHeight(el.clientHeight);
|
||||
Ext.EventManager.onWindowResize(function () {
|
||||
mainPanel.setHeight(el.clientHeight);
|
||||
mainPanel.doLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
tbar : new Ext.Toolbar({
|
||||
items: [
|
||||
_("ID_PM_TABLE"),
|
||||
|
||||
Reference in New Issue
Block a user