HOR-1421
This commit is contained in:
@@ -376,7 +376,7 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true, $filter = '', $appUid = false)
|
||||
public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true, $filter = '', $appUid = false, $search = '')
|
||||
{
|
||||
$addTab = new AdditionalTables();
|
||||
$aData = $addTab->load($sUID, true);
|
||||
@@ -443,7 +443,48 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
}
|
||||
$stringOr = $stringOr . '$oCriteria->add($a);';
|
||||
eval($stringOr);
|
||||
|
||||
}
|
||||
if ($search !== '' && is_string($search)) {
|
||||
try {
|
||||
$object = G::json_decode($search);
|
||||
if (isset($object->where)) {
|
||||
$stringAnd = "";
|
||||
$closure = "";
|
||||
$fields = $object->where;
|
||||
foreach ($fields as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$stringAnd = $stringAnd . '$a = $oCriteria->getNewCriterion(' . $sClassPeerName . '::' . G::toUpper($key) . ', "' . $value . '", Criteria::EQUAL)' . $closure . ';';
|
||||
$closure = '->addAnd($a)';
|
||||
}
|
||||
if (is_object($value)) {
|
||||
$defined = defined("Base" . $sClassPeerName . "::" . G::toUpper($key));
|
||||
if ($defined === false) {
|
||||
throw new Exception(G::loadTranslation("ID_FIELD_NOT_FOUND") . ": " . $key . "");
|
||||
}
|
||||
if (isset($value->neq) && $defined) {
|
||||
$stringAnd = $stringAnd . '$a = $oCriteria->getNewCriterion(' . $sClassPeerName . '::' . G::toUpper($key) . ', "' . $value->neq . '", Criteria::NOT_EQUAL)' . $closure . ';';
|
||||
$closure = '->addAnd($a)';
|
||||
}
|
||||
if (isset($value->like) && $defined) {
|
||||
$stringAnd = $stringAnd . '$a = $oCriteria->getNewCriterion(' . $sClassPeerName . '::' . G::toUpper($key) . ', "' . $value->like . '", Criteria::LIKE)' . $closure . ';';
|
||||
$closure = '->addAnd($a)';
|
||||
}
|
||||
if (isset($value->nlike) && $defined) {
|
||||
$stringAnd = $stringAnd . '$a = $oCriteria->getNewCriterion(' . $sClassPeerName . '::' . G::toUpper($key) . ', "' . $value->nlike . '", Criteria::NOT_LIKE)' . $closure . ';';
|
||||
$closure = '->addAnd($a)';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($stringAnd)) {
|
||||
$stringAnd = $stringAnd . '$oCriteria->add($a);';
|
||||
eval($stringAnd);
|
||||
}
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
if ($filter != '' && is_string($filter) || $search !== '' && is_string($search)) {
|
||||
$oCriteriaCount = clone $oCriteria;
|
||||
eval('$count = ' . $sClassPeerName . '::doCount($oCriteria);');
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class Table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTableData($tab_uid, $pro_uid = '', $filter = null, $reportFlag = false)
|
||||
public function getTableData($tab_uid, $pro_uid = '', $filter = null, $reportFlag = false, $search = '')
|
||||
{
|
||||
//Validation
|
||||
$inputFilter = new \InputFilter();
|
||||
@@ -164,7 +164,7 @@ class Table
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($tab_uid, true);
|
||||
$result = $additionalTables->getAllData($tab_uid, null, null, null, $filter);
|
||||
$result = $additionalTables->getAllData($tab_uid, null, null, null, $filter, false, $search);
|
||||
$primaryKeys = $additionalTables->getPrimaryKeys();
|
||||
if (is_array($result['rows'])) {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
|
||||
@@ -72,6 +72,8 @@ class Pmtable extends Api
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $filter
|
||||
* @param string $q
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -79,11 +81,11 @@ class Pmtable extends Api
|
||||
*
|
||||
* @url GET /:pmt_uid/data
|
||||
*/
|
||||
public function doGetPmTableData($pmt_uid, $filter = null)
|
||||
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$response = $oPmTable->getTableData($pmt_uid, null, $filter);
|
||||
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
|
||||
Reference in New Issue
Block a user