2014-02-11 17:10:11 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api;
|
2014-02-11 17:10:11 -04:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @url GET
|
|
|
|
|
*/
|
|
|
|
|
public function doGetPmTables()
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-11 17:10:11 -04:00
|
|
|
$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
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @url GET /:pmt_uid
|
|
|
|
|
*/
|
|
|
|
|
public function doGetPmTable($pmt_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-11 17:10:11 -04:00
|
|
|
$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}
|
2016-07-20 11:59:03 -04:00
|
|
|
* @param string $filter
|
|
|
|
|
* @param string $q
|
2014-02-11 17:10:11 -04:00
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @url GET /:pmt_uid/data
|
|
|
|
|
*/
|
2016-07-20 11:59:03 -04:00
|
|
|
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
|
2014-02-11 17:10:11 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
2016-07-20 11:59:03 -04:00
|
|
|
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
|
2014-02-11 17:10:11 -04:00
|
|
|
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
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @url POST
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
|
|
|
|
public function doPostPmTable(
|
|
|
|
|
$request_data,
|
|
|
|
|
$pmt_tab_name,
|
|
|
|
|
$pmt_tab_dsc = ''
|
|
|
|
|
) {
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-11 17:10:11 -04:00
|
|
|
$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()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-13 16:28:38 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $pmt_uid {@min 1} {@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-13 16:28:38 -04:00
|
|
|
* @url POST /:pmt_uid/data
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
|
|
|
|
public function doPostPmTableData(
|
|
|
|
|
$pmt_uid,
|
2014-04-28 12:15:48 -04:00
|
|
|
$request_data
|
2014-02-13 16:28:38 -04:00
|
|
|
) {
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-13 16:28:38 -04:00
|
|
|
$response = $oReportTable->saveTableData($pmt_uid, $request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-11 17:10:11 -04:00
|
|
|
/**
|
2017-10-13 10:59:18 -04:00
|
|
|
* Update pm-table.
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:pmt_uid
|
2014-02-11 17:10:11 -04:00
|
|
|
*
|
2017-10-13 10:59:18 -04:00
|
|
|
* @param string $pmt_uid {@min 1} {@max 32}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @param array $request_data
|
|
|
|
|
*
|
2017-10-13 10:59:18 -04:00
|
|
|
* @return void
|
2017-10-19 15:54:11 -04:00
|
|
|
* @throw RestException
|
2014-02-11 17:10:11 -04:00
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
2017-10-11 11:19:53 -04:00
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
*/
|
|
|
|
|
public function doPutPmTable(
|
|
|
|
|
$pmt_uid,
|
2014-04-28 12:15:48 -04:00
|
|
|
$request_data
|
2014-02-11 17:10:11 -04:00
|
|
|
) {
|
|
|
|
|
try {
|
|
|
|
|
$request_data['pmt_uid'] = $pmt_uid;
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-11 17:10:11 -04:00
|
|
|
$response = $oReportTable->updateTable($request_data);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-13 16:28:38 -04:00
|
|
|
/**
|
2017-10-13 10:59:18 -04:00
|
|
|
* Update pm-table data.
|
|
|
|
|
*
|
|
|
|
|
* @url PUT /:pmt_uid/data
|
|
|
|
|
*
|
2014-02-13 16:28:38 -04:00
|
|
|
* @param string $pmt_uid {@min 1} {@max 32}
|
|
|
|
|
* @param array $request_data
|
2017-10-13 10:59:18 -04:00
|
|
|
*
|
2014-02-13 16:28:38 -04:00
|
|
|
* @return array
|
2017-10-13 10:59:18 -04:00
|
|
|
* @throws RestException
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
2017-10-11 11:19:53 -04:00
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-13 16:28:38 -04:00
|
|
|
*/
|
|
|
|
|
public function doPutPmTableData(
|
|
|
|
|
$pmt_uid,
|
2014-04-28 12:15:48 -04:00
|
|
|
$request_data
|
2014-02-13 16:28:38 -04:00
|
|
|
) {
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-13 16:28:38 -04:00
|
|
|
$response = $oReportTable->updateTableData($pmt_uid, $request_data);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-11 17:10:11 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $pmt_uid {@min 1} {@max 32}
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-11 17:10:11 -04:00
|
|
|
* @url DELETE /:pmt_uid
|
|
|
|
|
*/
|
|
|
|
|
public function doDeletePmTable($pmt_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-11 17:10:11 -04:00
|
|
|
$response = $oReportTable->deleteTable($pmt_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-13 16:28:38 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $pmt_uid {@min 1} {@max 32}
|
|
|
|
|
* @param string $key1 {@min 1}
|
|
|
|
|
* @param string $value1 {@min 1}
|
|
|
|
|
* @param string $key2
|
|
|
|
|
* @param string $value2
|
|
|
|
|
* @param string $key3
|
|
|
|
|
* @param string $value3
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
2016-07-21 09:52:33 -04:00
|
|
|
* @access protected
|
|
|
|
|
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
2014-02-13 16:28:38 -04:00
|
|
|
* @url DELETE /:pmt_uid/data/:key1/:value1
|
|
|
|
|
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
|
|
|
|
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
|
|
|
|
*/
|
|
|
|
|
public function doDeletePmTableData($pmt_uid, $key1, $value1, $key2 = '', $value2 = '', $key3 = '', $value3 = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$rows = array($key1 => $value1);
|
|
|
|
|
if ($key2 != '') {
|
|
|
|
|
$rows[$key2] = $value2;
|
|
|
|
|
}
|
|
|
|
|
if ($key3 != '') {
|
|
|
|
|
$rows[$key3] = $value3;
|
|
|
|
|
}
|
2014-04-02 17:02:02 -04:00
|
|
|
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
2014-02-13 16:28:38 -04:00
|
|
|
$response = $oReportTable->deleteTableData($pmt_uid, $rows);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-11 17:10:11 -04:00
|
|
|
}
|
|
|
|
|
|