Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -227,10 +227,10 @@ class Group
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
||||
|
||||
if (isset($arrayData["GRP_TITLE"])) {
|
||||
@@ -475,7 +475,7 @@ class Group
|
||||
$criteria = $this->getGroupCriteria();
|
||||
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
$criteria->add(\ContentPeer::CON_VALUE, "%" . trim($arrayFilterData["filter"]) . "%", \Criteria::LIKE);
|
||||
$criteria->add(\ContentPeer::CON_VALUE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE);
|
||||
}
|
||||
|
||||
//Number records total
|
||||
@@ -616,12 +616,10 @@ class Group
|
||||
}
|
||||
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
$filter = trim($arrayFilterData["filter"]);
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%" . $filter . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%" . $filter . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%" . $filter . "%", \Criteria::LIKE)))
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_USERNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_LASTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -673,10 +671,10 @@ class Group
|
||||
$arrayUser = array();
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process = new \BusinessModel\Process();
|
||||
|
||||
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||
|
||||
//Get data
|
||||
|
||||
206
workflow/engine/src/BusinessModel/Group/User.php
Normal file
206
workflow/engine/src/BusinessModel/Group/User.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
namespace BusinessModel\Group;
|
||||
|
||||
class User
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"GRP_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "groupUid"),
|
||||
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
|
||||
private $arrayFieldNameForException = array();
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
try {
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exception messages for fields
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException($arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the field according to the format
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the User in Group
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the User in Group
|
||||
*/
|
||||
public function throwExceptionIfNotExistsGroupUser($groupUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \GroupUserPeer::retrieveByPK($groupUid, $userUid);
|
||||
|
||||
if (!(is_object($obj) && get_class($obj) == "GroupUser")) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $userUid), "The user with {0}: {1}, is not assigned to the group");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the User in Group
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if exists the User in Group
|
||||
*/
|
||||
public function throwExceptionIfExistsGroupUser($groupUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \GroupUserPeer::retrieveByPK($groupUid, $userUid);
|
||||
|
||||
if (is_object($obj) && get_class($obj) == "GroupUser") {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $userUid), "The user with {0}: {1}, is already assigned to the group");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign User to Group
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the User assigned to Group
|
||||
*/
|
||||
public function create($groupUid, $arrayData)
|
||||
{
|
||||
try {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
unset($arrayData["GRP_UID"]);
|
||||
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
$group = new \BusinessModel\Group();
|
||||
|
||||
$group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||
|
||||
$process->throwExceptionIfNoExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
$this->throwExceptionIfExistsGroupUser($groupUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
//Create
|
||||
$group = new \Groups();
|
||||
|
||||
$group->addUserToGroup($groupUid, $arrayData["USR_UID"]);
|
||||
|
||||
//Return
|
||||
$arrayData = array_merge(array("GRP_UID" => $groupUid), $arrayData);
|
||||
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unassign User of the Group
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function delete($groupUid, $userUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \BusinessModel\Process();
|
||||
$group = new \BusinessModel\Group();
|
||||
|
||||
$group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
|
||||
|
||||
$process->throwExceptionIfNoExistsUser($userUid, $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
$this->throwExceptionIfNotExistsGroupUser($groupUid, $userUid, $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
//Delete
|
||||
$group = new \Groups();
|
||||
|
||||
$group->removeUserOfGroup($groupUid, $userUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,25 @@ use \G;
|
||||
use \AdditionalTables;
|
||||
use \Fields;
|
||||
|
||||
class ReportTable
|
||||
class Table
|
||||
{
|
||||
/**
|
||||
* List of ReportTables in process
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* List of Tables in process
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReportTables($pro_uid)
|
||||
public function getTables($pro_uid = '', $reportFlag = false)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($reportFlag) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
}
|
||||
|
||||
$reportTables = array();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(\AdditionalTablesPeer::ADD_TAB_UID);
|
||||
@@ -26,16 +32,17 @@ class ReportTable
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$reportTables[] = $this->getReportTable($pro_uid, $row['ADD_TAB_UID'], false);
|
||||
$reportTables[] = $this->getTable($row['ADD_TAB_UID'], $pro_uid, $reportFlag, false);
|
||||
}
|
||||
|
||||
return $reportTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for ReportTable
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_uid. Uid for Report Table
|
||||
* Get data for Table
|
||||
* @var string $tab_uid. Uid for table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
* @var string $validate. Flag for validate
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -43,64 +50,117 @@ class ReportTable
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getReportTable($pro_uid, $rep_uid, $validate = true)
|
||||
public function getTable($tab_uid, $pro_uid = '', $reportFlag = false, $validate = true)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
$repData['PRO_UID'] = $pro_uid;
|
||||
if ($reportFlag) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$tabData['PRO_UID'] = $pro_uid;
|
||||
}
|
||||
$tab_uid = $this->validateTabUid($tab_uid, $reportFlag);
|
||||
}
|
||||
|
||||
$repData = array();
|
||||
$tabData = array();
|
||||
$additionalTables = new AdditionalTables();
|
||||
|
||||
// REPORT TABLE PROPERTIES
|
||||
$table = $additionalTables->load( $rep_uid, true );
|
||||
// TABLE PROPERTIES
|
||||
$table = $additionalTables->load( $tab_uid, true );
|
||||
$table['DBS_UID'] = $table['DBS_UID'] == null || $table['DBS_UID'] == '' ? 'workflow' : $table['DBS_UID'];
|
||||
$repData['REP_UID'] = $rep_uid;
|
||||
$repData['REP_TAB_NAME'] = $table['ADD_TAB_NAME'];
|
||||
$repData['REP_TAB_DESCRIPTION'] = $table['ADD_TAB_DESCRIPTION'];
|
||||
$repData['REP_TAB_CLASS_NAME'] = $table['ADD_TAB_CLASS_NAME'];
|
||||
$repData['REP_TAB_CONNECTION'] = $table['DBS_UID'];
|
||||
$repData['REP_TAB_TYPE'] = $table['ADD_TAB_TYPE'];
|
||||
$repData['REP_TAB_GRID'] = $table['ADD_TAB_GRID'];
|
||||
|
||||
// REPORT TABLE NUM ROWS DATA
|
||||
$tableData = $additionalTables->getAllData( $rep_uid, 0, 2 );
|
||||
$repData['REP_NUM_ROWS'] = $tableData['count'];
|
||||
// TABLE NUM ROWS DATA
|
||||
$tableData = $additionalTables->getAllData( $tab_uid, 0, 2 );
|
||||
|
||||
// REPORT TABLE FIELDS
|
||||
if ($reportFlag) {
|
||||
$tabData['REP_UID'] = $tab_uid;
|
||||
$tabData['REP_TAB_NAME'] = $table['ADD_TAB_NAME'];
|
||||
$tabData['REP_TAB_DESCRIPTION'] = $table['ADD_TAB_DESCRIPTION'];
|
||||
$tabData['REP_TAB_CLASS_NAME'] = $table['ADD_TAB_CLASS_NAME'];
|
||||
$tabData['REP_TAB_CONNECTION'] = $table['DBS_UID'];
|
||||
$tabData['REP_TAB_TYPE'] = $table['ADD_TAB_TYPE'];
|
||||
$tabData['REP_TAB_GRID'] = $table['ADD_TAB_GRID'];
|
||||
$tabData['REP_NUM_ROWS'] = $tableData['count'];
|
||||
} else {
|
||||
$tabData['PMT_UID'] = $tab_uid;
|
||||
$tabData['PMT_TAB_NAME'] = $table['ADD_TAB_NAME'];
|
||||
$tabData['PMT_TAB_DESCRIPTION'] = $table['ADD_TAB_DESCRIPTION'];
|
||||
$tabData['PMT_TAB_CLASS_NAME'] = $table['ADD_TAB_CLASS_NAME'];
|
||||
$tabData['PMT_NUM_ROWS'] = $tableData['count'];
|
||||
}
|
||||
|
||||
// TABLE FIELDS
|
||||
$hiddenFields = array(
|
||||
'fld_foreign_key', 'fld_foreign_key_table',
|
||||
'fld_dyn_name', 'fld_dyn_uid', 'fld_filter'
|
||||
);
|
||||
foreach ($table['FIELDS'] as $valField) {
|
||||
$fieldTemp = array();
|
||||
$fieldTemp = array_change_key_case($valField, CASE_LOWER);
|
||||
$repData['FIELDS'][] = $fieldTemp;
|
||||
foreach ($fieldTemp as $key => $value) {
|
||||
if (in_array($key, $hiddenFields)) {
|
||||
unset($fieldTemp[$key]);
|
||||
}
|
||||
}
|
||||
$tabData['FIELDS'][] = $fieldTemp;
|
||||
}
|
||||
|
||||
$repData = array_change_key_case($repData, CASE_LOWER);
|
||||
return $repData;
|
||||
$tabData = array_change_key_case($tabData, CASE_LOWER);
|
||||
return $tabData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for ReportTable
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_uid. Uid for Report Table
|
||||
* Generate Data for Report Table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $rep_uid. Uid for report table
|
||||
* @var string $validate. Flag for validate
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generateDataReport($pro_uid, $rep_uid, $validate = true)
|
||||
{
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateTabUid($rep_uid);
|
||||
G::loadClass('pmTable');
|
||||
}
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($rep_uid);
|
||||
$additionalTables->populateReportTable(
|
||||
$table['ADD_TAB_NAME'],
|
||||
\pmTable::resolveDbSource( $table['DBS_UID'] ),
|
||||
$table['ADD_TAB_TYPE'],
|
||||
$table['PRO_UID'],
|
||||
$table['ADD_TAB_GRID'],
|
||||
$table['ADD_TAB_UID']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for Table
|
||||
* @var string $tab_uid. Uid for table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDataReportTableData($pro_uid, $rep_uid)
|
||||
public function getTableData($tab_uid, $pro_uid = '', $reportFlag = false)
|
||||
{
|
||||
//VALIDATION
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
if ($reportFlag) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
}
|
||||
$tab_uid = $this->validateTabUid($tab_uid, $reportFlag);
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($rep_uid, true);
|
||||
$result = $additionalTables->getAllData($rep_uid);
|
||||
$table = $additionalTables->load($tab_uid, true);
|
||||
$result = $additionalTables->getAllData($tab_uid);
|
||||
$primaryKeys = $additionalTables->getPrimaryKeys();
|
||||
if (is_array($result['rows'])) {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
@@ -119,40 +179,54 @@ class ReportTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Data for Report Table
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_data. Data for Report Table
|
||||
* @var string $createRep. Flag for create Report Table
|
||||
* Save Data for Table
|
||||
* @var string $tab_data. Data for table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
* @var string $createRep. Flag for create table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function saveReportTable($pro_uid, $rep_data, $createRep = true)
|
||||
public function saveTable($tab_data, $pro_uid = '', $reportFlag = false, $createRep = true)
|
||||
{
|
||||
// CHANGE CASE UPPER REPORT TABLE
|
||||
$dataValidate = array();
|
||||
$dataValidate = array_change_key_case($rep_data, CASE_UPPER);
|
||||
// CHANGE CASE UPPER TABLE
|
||||
$fieldsValidate = array();
|
||||
$tableName = '';
|
||||
$tableCon = 'workflow';
|
||||
$dataValidate = array_change_key_case($tab_data, CASE_UPPER);
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
|
||||
// VALIDATION REPORT TABLE DATA
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$dataValidate['PRO_UID'] = $pro_uid;
|
||||
$dataValidate['REP_TAB_NAME'] = $this->validateRepName($dataValidate['REP_TAB_NAME']);
|
||||
$tempRepTabName = $dataValidate['REP_TAB_CONNECTION'];
|
||||
$dataValidate['REP_TAB_CONNECTION'] = $this->validateRepConnection($tempRepTabName, $pro_uid);
|
||||
if ($dataValidate['REP_TAB_TYPE'] == 'GRID') {
|
||||
$dataValidate['REP_TAB_GRID'] = $this->validateRepGrid($dataValidate['REP_TAB_GRID'], $pro_uid);
|
||||
// VALIDATION TABLE DATA
|
||||
if ($reportFlag) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$dataValidate['TAB_UID'] = (isset($dataValidate['REP_UID'])) ? $dataValidate['REP_UID'] : '';
|
||||
$dataValidate['PRO_UID'] = $pro_uid;
|
||||
$dataValidate['REP_TAB_NAME'] = $this->validateTabName($dataValidate['REP_TAB_NAME']);
|
||||
$tempRepTabName = $dataValidate['REP_TAB_CONNECTION'];
|
||||
$dataValidate['REP_TAB_CONNECTION'] = $this->validateRepConnection($tempRepTabName, $pro_uid);
|
||||
if ($dataValidate['REP_TAB_TYPE'] == 'GRID') {
|
||||
$dataValidate['REP_TAB_GRID'] = $this->validateRepGrid($dataValidate['REP_TAB_GRID'], $pro_uid);
|
||||
}
|
||||
$fieldsValidate = $this->getDynafields($pro_uid, $dataValidate['REP_TAB_TYPE'], $dataValidate['REP_TAB_GRID']);
|
||||
$repTabClassName = $oAdditionalTables->getPHPName($dataValidate['REP_TAB_NAME']);
|
||||
$tableName = $dataValidate['REP_TAB_NAME'];
|
||||
$tableCon = $dataValidate['REP_TAB_CONNECTION'];
|
||||
} else {
|
||||
$dataValidate['TAB_UID'] = (isset($dataValidate['PMT_UID'])) ? $dataValidate['PMT_UID'] : '';
|
||||
$dataValidate['PMT_TAB_NAME'] = $this->validateTabName($dataValidate['PMT_TAB_NAME']);
|
||||
$dataValidate['PMT_TAB_CONNECTION'] = 'workflow';
|
||||
$repTabClassName = $oAdditionalTables->getPHPName($dataValidate['PMT_TAB_NAME']);
|
||||
$tableName = $dataValidate['PMT_TAB_NAME'];
|
||||
$tableCon = $dataValidate['PMT_TAB_CONNECTION'];
|
||||
}
|
||||
|
||||
// VERIFY COLUMNS REPORT TABLE
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
// VERIFY COLUMNS TABLE
|
||||
$oFields = new Fields();
|
||||
|
||||
$repTabClassName = $oAdditionalTables->getPHPName($dataValidate['REP_TAB_NAME']);
|
||||
$columns = $dataValidate['FIELDS'];
|
||||
|
||||
|
||||
// Reserved Words Table, Field, Sql
|
||||
$reservedWords = array ('ALTER','CLOSE','COMMIT','CREATE','DECLARE','DELETE',
|
||||
'DROP','FETCH','FUNCTION','GRANT','INDEX','INSERT','OPEN','REVOKE','ROLLBACK',
|
||||
@@ -164,28 +238,34 @@ class ReportTable
|
||||
'or','throw','protected','public','static','switch','xor','try','use','var','while');
|
||||
$reservedWordsSql = G::reservedWordsSql();
|
||||
|
||||
$defaultColumns = $this->getReportTableDefaultColumns($data['REP_TAB_TYPE']);
|
||||
$columns = array_merge( $defaultColumns, $columns );
|
||||
if ($reportFlag) {
|
||||
$defaultColumns = $this->getReportTableDefaultColumns($data['REP_TAB_TYPE']);
|
||||
$columns = array_merge( $defaultColumns, $columns );
|
||||
}
|
||||
|
||||
// validations
|
||||
if (is_array( $oAdditionalTables->loadByName( $data['REP_TAB_NAME'] ) )) {
|
||||
throw new \Exception(G::loadTranslation('ID_PMTABLE_ALREADY_EXISTS', array($data['REP_TAB_NAME'])));
|
||||
if ($createRep) {
|
||||
if (is_array( $oAdditionalTables->loadByName( $tableName ) )) {
|
||||
throw new \Exception(G::loadTranslation('ID_PMTABLE_ALREADY_EXISTS', array($tableName)));
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array( strtoupper( $data["REP_TAB_NAME"] ), $reservedWords ) ||
|
||||
in_array( strtoupper( $data["REP_TAB_NAME"] ), $reservedWordsSql )) {
|
||||
throw (new \Exception(G::LoadTranslation("ID_PMTABLE_INVALID_NAME", array($data["REP_TAB_NAME"]))));
|
||||
if (in_array( strtoupper( $tableName ), $reservedWords ) ||
|
||||
in_array( strtoupper( $tableName ), $reservedWordsSql )) {
|
||||
throw (new \Exception(G::LoadTranslation("ID_PMTABLE_INVALID_NAME", array($tableName))));
|
||||
}
|
||||
|
||||
|
||||
//backward compatility
|
||||
$flagKey = false;
|
||||
$columnsStd = array();
|
||||
$fieldsValidate = $this->getDynafields($pro_uid, $dataValidate['REP_TAB_TYPE'], $dataValidate['REP_TAB_GRID']);
|
||||
foreach ($columns as $i => $column) {
|
||||
if (isset($columns[$i]['fld_dyn'])) {
|
||||
$columns[$i]['field_dyn'] = $columns[$i]['fld_dyn'];
|
||||
unset($columns[$i]['fld_dyn']);
|
||||
} else {
|
||||
$columns[$i]['fld_dyn'] = '';
|
||||
}
|
||||
$columns[$i]['fld_dyn'] = ($reportFlag) ? $columns[$i]['fld_dyn'] : '';
|
||||
|
||||
if (isset($columns[$i]['fld_name'])) {
|
||||
$columns[$i]['field_name'] = $columns[$i]['fld_name'];
|
||||
}
|
||||
@@ -201,15 +281,27 @@ class ReportTable
|
||||
$columns[$i]['field_size'] = $columns[$i]['fld_size'];
|
||||
unset($columns[$i]['fld_size']);
|
||||
}
|
||||
if (isset($columns[$i]['fld_key'])) {
|
||||
$columns[$i]['field_key'] = $columns[$i]['fld_key'];
|
||||
unset($columns[$i]['fld_key']);
|
||||
}
|
||||
if (isset($columns[$i]['fld_null'])) {
|
||||
$columns[$i]['field_null'] = $columns[$i]['fld_null'];
|
||||
unset($columns[$i]['fld_null']);
|
||||
}
|
||||
if (isset($columns[$i]['fld_autoincrement'])) {
|
||||
$columns[$i]['field_autoincrement'] = $columns[$i]['fld_autoincrement'];
|
||||
unset($columns[$i]['fld_autoincrement']);
|
||||
}
|
||||
|
||||
if (in_array(strtoupper($columns[$i]['field_name']), $reservedWordsSql) ||
|
||||
if (in_array(strtoupper($columns[$i]['field_name']), $reservedWordsSql) ||
|
||||
in_array( strtolower( $columns[$i]['field_name']), $reservedWordsPhp )) {
|
||||
throw (new \Exception(G::LoadTranslation("ID_PMTABLE_INVALID_FIELD_NAME", array($columns[$i]['field_name']))));
|
||||
}
|
||||
|
||||
// VALIDATIONS
|
||||
$columns[$i]['field_type'] = $this->validateFldType($columns[$i]['field_type']);
|
||||
if ($columns[$i]['field_autoincrement']) {
|
||||
if (isset($columns[$i]['field_autoincrement']) && $columns[$i]['field_autoincrement']) {
|
||||
$typeCol = $columns[$i]['field_type'];
|
||||
if (! ($typeCol === 'INTEGER' || $typeCol === 'TINYINT' || $typeCol === 'SMALLINT' || $typeCol === 'BIGINT')) {
|
||||
$columns[$i]['field_autoincrement'] = false;
|
||||
@@ -217,7 +309,7 @@ class ReportTable
|
||||
}
|
||||
|
||||
if (isset($columns[$i]['fld_name'])) {
|
||||
if ($columns[$i]['field_dyn'] != '') {
|
||||
if (isset($columns[$i]['field_dyn']) && $columns[$i]['field_dyn'] != '') {
|
||||
$res = array_search($columns[$i]['field_dyn'], $fieldsValidate['NAMES']);
|
||||
if ($res === false) {
|
||||
throw (new \Exception("The property 'fields' in key '$i' in property fld_dyn: '".$columns[$i]['field_dyn']."', is incorrect."));
|
||||
@@ -243,31 +335,57 @@ class ReportTable
|
||||
$temp->field_dyn = (isset($temp->field_dyn)) ? $temp->field_dyn : '';
|
||||
$temp->field_filter = (isset($temp->field_filter)) ? $temp->field_filter : 0;
|
||||
$temp->field_autoincrement = (isset($temp->field_autoincrement)) ? $temp->field_autoincrement : 0;
|
||||
|
||||
if (!$reportFlag) {
|
||||
unset($temp->_index);
|
||||
unset($temp->field_filter);
|
||||
}
|
||||
if ($temp->field_key == 1 || $temp->field_key == true) {
|
||||
$flagKey = true;
|
||||
}
|
||||
$columnsStd[$i] = $temp;
|
||||
}
|
||||
if (!$flagKey) {
|
||||
throw (new \Exception("The fields must have a key 'fld_key'"));
|
||||
}
|
||||
|
||||
G::LoadClass("pmTable");
|
||||
$pmTable = new \pmTable($dataValidate['REP_TAB_NAME']);
|
||||
$pmTable->setDataSource($dataValidate['REP_TAB_CONNECTION']);
|
||||
$pmTable = new \pmTable($tableName);
|
||||
$pmTable->setDataSource($tableCon);
|
||||
$pmTable->setColumns($columnsStd);
|
||||
$pmTable->setAlterTable(true);
|
||||
if (!$createRep) {
|
||||
$pmTable->setKeepData(true);
|
||||
}
|
||||
$pmTable->build();
|
||||
$buildResult = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// Updating additional table struture information
|
||||
$dataValidate['REP_TAB_UID'] = (isset($dataValidate['REP_TAB_UID'])) ? $dataValidate['REP_TAB_UID'] : '';
|
||||
$addTabData = array(
|
||||
'ADD_TAB_UID' => $dataValidate['REP_TAB_UID'],
|
||||
'ADD_TAB_NAME' => $dataValidate['REP_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['REP_TAB_DSC'],
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['REP_TAB_CONNECTION'] ? $dataValidate['REP_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => $dataValidate['PRO_UID'],
|
||||
'ADD_TAB_TYPE' => $dataValidate['REP_TAB_TYPE'],
|
||||
'ADD_TAB_GRID' => $dataValidate['REP_TAB_GRID']
|
||||
);
|
||||
if ($reportFlag) {
|
||||
$addTabData = array(
|
||||
'ADD_TAB_UID' => $dataValidate['TAB_UID'],
|
||||
'ADD_TAB_NAME' => $dataValidate['REP_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['REP_TAB_DSC'],
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['REP_TAB_CONNECTION'] ? $dataValidate['REP_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => $dataValidate['PRO_UID'],
|
||||
'ADD_TAB_TYPE' => $dataValidate['REP_TAB_TYPE'],
|
||||
'ADD_TAB_GRID' => $dataValidate['REP_TAB_GRID']
|
||||
);
|
||||
} else {
|
||||
$addTabData = array(
|
||||
'ADD_TAB_UID' => $dataValidate['TAB_UID'],
|
||||
'ADD_TAB_NAME' => $dataValidate['PMT_TAB_NAME'],
|
||||
'ADD_TAB_CLASS_NAME' => $repTabClassName,
|
||||
'ADD_TAB_DESCRIPTION' => $dataValidate['PMT_TAB_DSC'],
|
||||
'ADD_TAB_PLG_UID' => '',
|
||||
'DBS_UID' => ($dataValidate['PMT_TAB_CONNECTION'] ? $dataValidate['PMT_TAB_CONNECTION'] : 'workflow'),
|
||||
'PRO_UID' => '',
|
||||
'ADD_TAB_TYPE' => '',
|
||||
'ADD_TAB_GRID' => ''
|
||||
);
|
||||
}
|
||||
if ($createRep) {
|
||||
//new report table
|
||||
//create record
|
||||
@@ -275,16 +393,15 @@ class ReportTable
|
||||
} else {
|
||||
//editing report table
|
||||
//updating record
|
||||
$addTabUid = $dataValidate['REP_TAB_UID'];
|
||||
$addTabUid = $dataValidate['TAB_UID'];
|
||||
$oAdditionalTables->update( $addTabData );
|
||||
|
||||
//removing old data fields references
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->add( \FieldsPeer::ADD_TAB_UID, $dataValidate['REP_TAB_UID'] );
|
||||
$oCriteria->add( \FieldsPeer::ADD_TAB_UID, $dataValidate['TAB_UID'] );
|
||||
\FieldsPeer::doDelete( $oCriteria );
|
||||
}
|
||||
|
||||
$rep_uid = $addTabUid;
|
||||
// Updating pmtable fields
|
||||
foreach ($columnsStd as $i => $column) {
|
||||
$column = (array)$column;
|
||||
@@ -307,105 +424,98 @@ class ReportTable
|
||||
);
|
||||
$oFields->create( $field );
|
||||
}
|
||||
$this->generateDataReport($pro_uid, $rep_uid, false);
|
||||
if ($reportFlag) {
|
||||
$rep_uid = $addTabUid;
|
||||
$this->generateDataReport($pro_uid, $rep_uid, false);
|
||||
}
|
||||
if ($createRep) {
|
||||
return $this->getReportTable($pro_uid, $rep_uid, false);
|
||||
$tab_uid = $addTabUid;
|
||||
return $this->getTable($tab_uid, $pro_uid, $reportFlag, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Data for ReportTable
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_data. Data for ReportTable
|
||||
* Update Data for Table
|
||||
* @var string $tab_data. Data for table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateReportTable($pro_uid, $rep_data)
|
||||
public function updateTable($tab_data, $pro_uid = '', $reportFlag = false)
|
||||
{
|
||||
$rep_uid = $rep_data['rep_uid'];
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
if ($reportFlag) {
|
||||
$tab_uid = $tab_data['rep_uid'];
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
} else {
|
||||
$tab_uid = $tab_data['pmt_uid'];
|
||||
}
|
||||
$tab_uid = $this->validateTabUid($tab_uid, $reportFlag);
|
||||
|
||||
$dataValidate = array();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
$oCriteria->add(\AdditionalTablesPeer::ADD_TAB_UID, $rep_uid, \Criteria::EQUAL);
|
||||
$oCriteria->add(\AdditionalTablesPeer::ADD_TAB_UID, $tab_uid, \Criteria::EQUAL);
|
||||
$oDataset = \AdditionalTablesPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$dataValidate['rep_tab_uid'] = $rep_uid;
|
||||
$dataValidate['rep_tab_name'] = $row['ADD_TAB_NAME'];
|
||||
$dataValidate['rep_tab_dsc'] = $rep_data['rep_tab_dsc'];
|
||||
$dataValidate['rep_tab_connection'] = $row['DBS_UID'];
|
||||
$dataValidate['rep_tab_type'] = $row['ADD_TAB_TYPE'];
|
||||
$dataValidate['rep_tab_grid'] = $row['ADD_TAB_GRID'];
|
||||
$dataValidate['fields'] = $rep_data['fields'];
|
||||
if ($reportFlag) {
|
||||
$dataValidate['rep_uid'] = $tab_uid;
|
||||
$dataValidate['rep_tab_name'] = $row['ADD_TAB_NAME'];
|
||||
$dataValidate['rep_tab_dsc'] = $tab_data['rep_tab_dsc'];
|
||||
$dataValidate['rep_tab_connection'] = $row['DBS_UID'];
|
||||
$dataValidate['rep_tab_type'] = $row['ADD_TAB_TYPE'];
|
||||
$dataValidate['rep_tab_grid'] = $row['ADD_TAB_GRID'];
|
||||
} else {
|
||||
$dataValidate['pmt_uid'] = $tab_uid;
|
||||
$dataValidate['pmt_tab_name'] = $row['ADD_TAB_NAME'];
|
||||
$dataValidate['pmt_tab_dsc'] = $tab_data['pmt_tab_dsc'];
|
||||
}
|
||||
$dataValidate['fields'] = $tab_data['fields'];
|
||||
} else {
|
||||
throw (new \Exception("The property rep_uid: '$rep_uid', is incorrect."));
|
||||
if ($reportFlag) {
|
||||
throw (new \Exception("The property rep_uid: '$tab_uid', is incorrect."));
|
||||
} else {
|
||||
throw (new \Exception("The property pmt_uid: '$tab_uid', is incorrect."));
|
||||
}
|
||||
}
|
||||
$this->saveReportTable($pro_uid, $dataValidate, false);
|
||||
$this->saveTable($dataValidate, $pro_uid, $reportFlag, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete ReportTable
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_uid. Uid for Report Table
|
||||
* Delete Table
|
||||
* @var string $tab_uid. Uid for table
|
||||
* @var string $pro_uid. Uid for process
|
||||
* @var string $reportFlag. If is report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteReportTable($pro_uid, $rep_uid)
|
||||
public function deleteTable($tab_uid, $pro_uid = '', $reportFlag = false)
|
||||
{
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
if ($reportFlag) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
}
|
||||
$tab_uid = $this->validateTabUid($tab_uid, $reportFlag);
|
||||
|
||||
$at = new AdditionalTables();
|
||||
$table = $at->load( $rep_uid );
|
||||
$table = $at->load( $tab_uid );
|
||||
|
||||
if (! isset( $table )) {
|
||||
require_once 'classes/model/ReportTable.php';
|
||||
$rtOld = new ReportTable();
|
||||
$existReportTableOld = $rtOld->load($rep_uid);
|
||||
$existReportTableOld = $rtOld->load($tab_uid);
|
||||
if (count($existReportTableOld) == 0) {
|
||||
throw new Exception(G::LoadTranslation('ID_TABLE_NOT_EXIST_SKIPPED'));
|
||||
}
|
||||
}
|
||||
$at->deleteAll($rep_uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Data for Report Table
|
||||
* @var string $pro_uid. Uid for Process
|
||||
* @var string $rep_uid. Uid for Report Table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generateDataReport($pro_uid, $rep_uid, $validate = true) {
|
||||
if ($validate) {
|
||||
$pro_uid = $this->validateProUid($pro_uid);
|
||||
$rep_uid = $this->validateRepUid($rep_uid);
|
||||
G::loadClass('pmTable');
|
||||
}
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($rep_uid);
|
||||
$additionalTables->populateReportTable(
|
||||
$table['ADD_TAB_NAME'],
|
||||
\pmTable::resolveDbSource( $table['DBS_UID'] ),
|
||||
$table['ADD_TAB_TYPE'],
|
||||
$table['PRO_UID'],
|
||||
$table['ADD_TAB_GRID'],
|
||||
$table['ADD_TAB_UID']
|
||||
);
|
||||
$at->deleteAll($tab_uid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,7 +660,7 @@ class ReportTable
|
||||
'field_filter' => false,
|
||||
'field_autoincrement' => false
|
||||
); //APPLICATION KEY
|
||||
|
||||
|
||||
array_push( $defaultColumns, $application );
|
||||
|
||||
$application = array(
|
||||
@@ -584,7 +694,7 @@ class ReportTable
|
||||
'field_filter' => false,
|
||||
'field_autoincrement' => false
|
||||
); //APP_STATUS
|
||||
|
||||
|
||||
array_push( $defaultColumns, $application );
|
||||
|
||||
//if it is a grid report table
|
||||
@@ -619,7 +729,8 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateProUid ($pro_uid) {
|
||||
public function validateProUid ($pro_uid)
|
||||
{
|
||||
$pro_uid = trim($pro_uid);
|
||||
if ($pro_uid == '') {
|
||||
throw (new \Exception("The project with prj_uid: '', does not exist."));
|
||||
@@ -632,28 +743,34 @@ class ReportTable
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Report Table Uid
|
||||
* @var string $rep_uid. Uid for report table
|
||||
* Validate Table Uid
|
||||
* @var string $tab_uid. Uid for table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateRepUid ($rep_uid) {
|
||||
$rep_uid = trim($rep_uid);
|
||||
if ($rep_uid == '') {
|
||||
throw (new \Exception("The report table with rep_uid: '', does not exist."));
|
||||
public function validateTabUid ($tab_uid, $reportFlag = true)
|
||||
{
|
||||
if ($reportFlag) {
|
||||
$label = 'The report table with rep_uid:';
|
||||
} else {
|
||||
$label = 'The pm table with pmt_uid:';
|
||||
}
|
||||
$tab_uid = trim($tab_uid);
|
||||
if ($tab_uid == '') {
|
||||
throw (new \Exception($label . "'', does not exist."));
|
||||
}
|
||||
$oAdditionalTables = new \AdditionalTables();
|
||||
if (!($oAdditionalTables->exists($rep_uid))) {
|
||||
throw (new \Exception("The report table with rep_uid: '$rep_uid', does not exist."));
|
||||
if (!($oAdditionalTables->exists($tab_uid))) {
|
||||
throw (new \Exception($label . "'$tab_uid', does not exist."));
|
||||
}
|
||||
return $rep_uid;
|
||||
return $tab_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Report Table Name
|
||||
* Validate Table Name
|
||||
* @var string $rep_tab_name. Name for report table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -661,7 +778,8 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateRepName ($rep_tab_name) {
|
||||
public function validateTabName ($rep_tab_name)
|
||||
{
|
||||
$rep_tab_name = trim($rep_tab_name);
|
||||
if ((strpos($rep_tab_name, ' ')) || (strlen($rep_tab_name) < 4)) {
|
||||
throw (new \Exception("The property rep_tab_name: '$rep_tab_name', is incorrect."));
|
||||
@@ -683,7 +801,8 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateRepConnection ($rep_tab_connection, $pro_uid) {
|
||||
public function validateRepConnection ($rep_tab_connection, $pro_uid)
|
||||
{
|
||||
$rep_tab_connection = trim($rep_tab_connection);
|
||||
if ($rep_tab_connection == '') {
|
||||
throw (new \Exception("The property rep_tab_connection: '$rep_tab_connection', is incorrect."));
|
||||
@@ -716,7 +835,8 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateRepGrid ($rep_tab_grid, $pro_uid) {
|
||||
public function validateRepGrid ($rep_tab_grid, $pro_uid)
|
||||
{
|
||||
$rep_tab_grid = trim($rep_tab_grid);
|
||||
if ($rep_tab_grid == '') {
|
||||
throw (new \Exception("The property rep_tab_grid: '$rep_tab_grid', is incorrect."));
|
||||
@@ -764,8 +884,8 @@ class ReportTable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function validateFldType ($fld_type) {
|
||||
|
||||
public function validateFldType ($fld_type)
|
||||
{
|
||||
$fld_type = trim($fld_type);
|
||||
if ($fld_type == '') {
|
||||
throw (new \Exception("The property fld_type: '$fld_type', is incorrect."));
|
||||
52
workflow/engine/src/Services/Api/ProcessMaker/Group/User.php
Normal file
52
workflow/engine/src/Services/Api/ProcessMaker/Group/User.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Group;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Group\User Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class User extends Api
|
||||
{
|
||||
/**
|
||||
* @url POST /:grp_uid/user
|
||||
*
|
||||
* @param string $grp_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostUser($grp_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$groupUser = new \BusinessModel\Group\User();
|
||||
$groupUser->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayData = $groupUser->create($grp_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:grp_uid/user/:usr_uid
|
||||
*
|
||||
* @param string $grp_uid {@min 32}{@max 32}
|
||||
* @param string $usr_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteUser($grp_uid, $usr_uid)
|
||||
{
|
||||
try {
|
||||
$groupUser = new \BusinessModel\Group\User();
|
||||
$groupUser->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$groupUser->delete($grp_uid, $usr_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
148
workflow/engine/src/Services/Api/ProcessMaker/Pmtable.php
Normal file
148
workflow/engine/src/Services/Api/ProcessMaker/Pmtable.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Pmtable Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class Pmtable extends Api
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET
|
||||
*/
|
||||
public function doGetPmTables()
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \BusinessModel\Table();
|
||||
$response = $oPmTable->getTables();
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:pmt_uid
|
||||
*/
|
||||
public function doGetPmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \BusinessModel\Table();
|
||||
$response = $oPmTable->getTable($pmt_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /:pmt_uid/data
|
||||
*/
|
||||
public function doGetPmTableData($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \BusinessModel\Table();
|
||||
$response = $oPmTable->getTableData($pmt_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $request_data
|
||||
* @param string $pmt_tab_name {@from body}
|
||||
* @param string $pmt_tab_dsc {@from body}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url POST
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostPmTable(
|
||||
$request_data,
|
||||
$pmt_tab_name,
|
||||
$pmt_tab_dsc = ''
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->saveTable($request_data);
|
||||
if (isset($response['pro_uid'])) {
|
||||
unset($response['pro_uid']);
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $pmt_tab_dsc {@from body}
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url PUT /:pmt_uid
|
||||
*/
|
||||
public function doPutPmTable(
|
||||
$pmt_uid,
|
||||
$request_data,
|
||||
$pmt_tab_dsc = ''
|
||||
) {
|
||||
try {
|
||||
$request_data['pmt_uid'] = $pmt_uid;
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->updateTable($request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url DELETE /:pmt_uid
|
||||
*/
|
||||
public function doDeletePmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->deleteTable($pmt_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class ReportTable extends Api
|
||||
public function doGetReportTables($prj_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->getReportTables($prj_uid);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->getTables($prj_uid, true);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
@@ -46,8 +46,8 @@ class ReportTable extends Api
|
||||
public function doGetReportTable($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->getReportTable($prj_uid, $rep_uid);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->getTable($rep_uid, $prj_uid, true);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
@@ -66,7 +66,7 @@ class ReportTable extends Api
|
||||
public function doGetPopulateReportTable($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->generateDataReport($prj_uid, $rep_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
@@ -86,8 +86,8 @@ class ReportTable extends Api
|
||||
public function doGetReportTableData($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->getDataReportTableData($prj_uid, $rep_uid);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->getTableData($rep_uid, $prj_uid, true);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
@@ -121,8 +121,8 @@ class ReportTable extends Api
|
||||
$rep_tab_grid = ''
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->saveReportTable($prj_uid, $request_data);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->saveTable($request_data, $prj_uid, true);
|
||||
if (isset($response['pro_uid'])) {
|
||||
unset($response['pro_uid']);
|
||||
}
|
||||
@@ -153,8 +153,8 @@ class ReportTable extends Api
|
||||
) {
|
||||
try {
|
||||
$request_data['rep_uid'] = $rep_uid;
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->updateReportTable($prj_uid, $request_data);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->updateTable($request_data, $prj_uid, true);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
@@ -173,10 +173,11 @@ class ReportTable extends Api
|
||||
public function doDeleteReportTable($prj_uid, $rep_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \BusinessModel\ReportTable();
|
||||
$response = $oReportTable->deleteReportTable($prj_uid, $rep_uid);
|
||||
$oReportTable = new \BusinessModel\Table();
|
||||
$response = $oReportTable->deleteTable($rep_uid, $prj_uid, true);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user