|
|
@@ -56,7 +56,24 @@ function zaliczkaFetchData(query, fieldType, resultCallback) {
|
|
|
}
|
|
|
switch (fieldType['@namespace']) {
|
|
|
case 'default_db/IN7_DZIENNIK_KORESP': {
|
|
|
-
|
|
|
+ superagent
|
|
|
+ .post('<?= Request::getPathUri(); ?>/index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=fetchDataAjax')
|
|
|
+ .type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
|
|
|
+ .send({
|
|
|
+ schema: fieldType,
|
|
|
+ query: query
|
|
|
+ })
|
|
|
+ .set('Accept', 'application/json')
|
|
|
+ .end(function(err, res) {
|
|
|
+ var payload;
|
|
|
+ if (err || !res.ok || 'application/json' !== res.type) {
|
|
|
+ payload = {type: 'warning', msg: res.body.msg || 'Request error', body: res.body};
|
|
|
+ } else {
|
|
|
+ payload = {type: 'success', msg: res.body.msg || '', body: res.body};
|
|
|
+ }
|
|
|
+ jQuery(document).trigger('DBG:notify', payload);
|
|
|
+ resultCallback(payload.body.options);
|
|
|
+ });
|
|
|
console.warn("TODO: fetch by ajax default_db:IN7_DZIENNIK_KORESP");
|
|
|
var options = [
|
|
|
{ id: 65432, title: 'testowa koresp 1', kategoriaKosztu: 'KOSZT1' },
|
|
|
@@ -111,6 +128,16 @@ function syncZaliczkaState(state, updates, stateSyncSyccessCallback, stateSyncEr
|
|
|
UI::tag('script', ['src'=>'static/zaliczka/main.js' . (V::get('DBG', '', $_GET) ? '?_ts=' . time() : ''), 'type'=>'text/javascript']);
|
|
|
}
|
|
|
|
|
|
+ public function fetchDataAjaxAction() {
|
|
|
+ $reqBody = Request::getRequestBody();
|
|
|
+ // var_dump($reqBody);
|
|
|
+ die(json_encode([
|
|
|
+ [ 'id' => 100, 'nrBudowy' => 'Budowa 100/2016' ],
|
|
|
+ [ 'id' => 101, 'nrBudowy' => 'Budowa 101/2016' ],
|
|
|
+ [ 'id' => 102, 'nrBudowy' => 'Budowa 102/2016' ],
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
public function fetchDataBySchema($schema, $idUser, $primaryKey = null) {// if $primaryKey is null then search for last row
|
|
|
return [// TODO: fetch data from DB
|
|
|
'id' => 123,
|