|
|
@@ -1064,6 +1064,64 @@ class Route_ViewTableAjax extends RouteBase {
|
|
|
return $jsonData;
|
|
|
}
|
|
|
|
|
|
+ public function typespecialAction() { Response::sendTryCatchJson(array($this, 'typespecial'), $args = $_REQUEST); }
|
|
|
+ public function typespecial($args) { // @required idField, @optional: q (query), selected (selected value), idRecord (fetch value for given record)
|
|
|
+ $idField = V::get('idField', 0, $args, 'int');
|
|
|
+ if (!$idField) throw new HttpException("Bad Request - missing idField", 400);
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ DBG::log("\$query({$query})");
|
|
|
+
|
|
|
+ $cellInfo = DB::getPDO()->fetchFirst("
|
|
|
+ select *
|
|
|
+ from CRM_PROCES_idx_TABLES_INFO_VIEW
|
|
|
+ where ID_CELL = :id
|
|
|
+ ", [ ':id' => $idField ]);
|
|
|
+ DBG::log($cellInfo, 'array', "cell info");
|
|
|
+ if (!$cellInfo) throw new HttpException("Bad Request - wrong idField", 400);
|
|
|
+ // 'ID_CELL' => '24310',
|
|
|
+ // 'CELL_NAME' => 'L_APPOITMENT_USER',
|
|
|
+ // 'CELL_LABEL' => 'Osoba odpowiedzialna',
|
|
|
+ // 'CELL_DESCRIPTION' => '',
|
|
|
+ // 'CELL_SORT_PRIO' => '3',
|
|
|
+ // 'ID_TABLE' => '13051',
|
|
|
+ // 'TABLE_NAME' => 'TEST_PERMS',
|
|
|
+ // 'TABLE_LABEL' => 'Test permy',
|
|
|
+ // 'TABLE_DESCRIPTION' => '',
|
|
|
+ // 'ID_DATABASE' => '36',
|
|
|
+ $namespace = (false !== strpos($cellInfo['TABLE_NAME'], '/')) ? $cellInfo['TABLE_NAME'] : "default_db/{$cellInfo['TABLE_NAME']}";
|
|
|
+ if (!$namespace) throw new HttpException("Bad Request - wrong idField, cannot find namespace", 400);
|
|
|
+
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace($namespace);
|
|
|
+ $fieldName = $cellInfo['CELL_NAME'];
|
|
|
+
|
|
|
+ $jsonData = array();
|
|
|
+ $typeSpecial = Typespecial::getInstance($idField, $fieldName);
|
|
|
+ if ($typeSpecial) {
|
|
|
+
|
|
|
+ // if (idRecord or selected) { // TODO
|
|
|
+ // $jsonData->data = $typeSpecial->getReturnData($acl->getID(), $id, $fieldName, '');
|
|
|
+ // $jsonData->namespace = 'default_db/' . V::get('tbl_name', '', $jsonData->data);
|
|
|
+
|
|
|
+ $rawRows = null;
|
|
|
+ $rows = $typeSpecial->getValuesWithExports($query);
|
|
|
+ DBG::log($rows, 'array', "\$rows({$query})");
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
+ }
|
|
|
+ if (!empty($vItem->{'$order'})) {
|
|
|
+ $itemJson->{'$order'} = $vItem->{'$order'};
|
|
|
+ }
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $jsonData;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param $_GET['namespace'] = AclNamespace
|
|
|
* @param $_GET['format'] = 'csv' | 'html'
|