|
|
@@ -8,6 +8,14 @@ Lib::loadClass('Response');
|
|
|
Lib::loadClass('ProcesHelper');
|
|
|
Lib::loadClass('Route_UrlAction');
|
|
|
Lib::loadClass('UI');
|
|
|
+Lib::loadClass('Core_AclHelper');
|
|
|
+
|
|
|
+// TODO: zaliczkaListaView:
|
|
|
+// TODO: btn "Dodaj Zaliczkę" $acl->addItem($item); // @require only 'worker' => [ 'id', 'login', 'name' ]
|
|
|
+// TODO: lista 10 najnowszych + btn "load more ..."
|
|
|
+// TODO: Rozlicz / Podgląd - tylko najnowsza Zaliczka
|
|
|
+// TODO: Rozlicz / Podgląd - edytowć może tylko właściciel / grupa / user connected by REF ?
|
|
|
+// TODO: create view for printZaliczka to view older rows
|
|
|
|
|
|
class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
|
|
|
|
|
|
@@ -23,25 +31,253 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
|
|
|
if (1 != V::get('_print', '', $_GET)) UI::menu();
|
|
|
try {
|
|
|
$data = array();
|
|
|
- $data['id_user'] = V::get('ID_PROJECT', User::getID(), $_REQUEST, 'int');
|
|
|
+ $data['idUser'] = V::get('idUser', User::getID(), $_REQUEST, 'int');
|
|
|
+ $data['idZaliczka'] = V::get('idZaliczka', 0, $_REQUEST, 'int');// TODO: idZaliczka is always MAX(z.ID);
|
|
|
|
|
|
- $this->zaliczkaFormView($data);
|
|
|
+ if (!$data['idZaliczka']) {
|
|
|
+ $this->zaliczkaListaView($data);
|
|
|
+ } else {
|
|
|
+ $this->zaliczkaFormView($data);
|
|
|
+ }
|
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
}
|
|
|
if (1 != V::get('_print', '', $_GET)) UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function syncStataAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'syncStataAjaxReponseCallback'), $args = 'JSON_FROM_REQUEST_BODY');// try to read json from request body
|
|
|
+ }
|
|
|
+ public function syncStataAjaxReponseCallback($args) {
|
|
|
+ if (empty($args) || !array_key_exists('updates', $args)) throw new HttpException("Error Parsing Request - missing args", 400);
|
|
|
+ $args['idUser'] = V::get('idUser', 0, $_REQUEST, 'int');// (int)$args['idUser'];
|
|
|
+ if ($args['idUser'] <= 0) throw new HttpException("Error Parsing Request - missing idUser", 400);
|
|
|
+ $args['idZaliczka'] = V::get('idZaliczka', 0, $_REQUEST, 'int');// (int)$args['idZaliczka'];
|
|
|
+ if ($args['idZaliczka'] <= 0) throw new HttpException("Error Parsing Request - missing idZaliczka", 400);
|
|
|
+
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
|
|
|
+ $schema = $acl->getSimpleSchemaTree();
|
|
|
+ if (!empty($args['updates'])) {
|
|
|
+ throw new Exception("TODO: F." . __FUNCTION__ . " L." . __LINE__);
|
|
|
+ }
|
|
|
+
|
|
|
+ $zaliczkaData = $this->fetchDataBySchema($schema, $args['idUser']);
|
|
|
+ return [
|
|
|
+ 'nierozliczonaKwota' => V::get('nierozliczona_kwota', 0, $zaliczkaData),
|
|
|
+ 'schema' => [
|
|
|
+ 'zaliczka' => $schema,
|
|
|
+ ],
|
|
|
+ 'zaliczka' => $zaliczkaData,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetchDataAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'fetchDataAjaxReponseCallback'), $args = 'JSON_FROM_REQUEST_BODY');// try to read json from request body
|
|
|
+ }
|
|
|
+ public function fetchDataAjaxReponseCallback($args) {
|
|
|
+ if (empty($args) || empty($args['schema']['@namespace']) || empty($args['schema']['@namespace'])) throw new HttpException("Error Parsing Request - missing @namespace", 400);
|
|
|
+ $nsUri = $args['schema']['@namespace'];
|
|
|
+ if ('default_db/IN7_DZIENNIK_KORESP' == $nsUri) {
|
|
|
+ return [
|
|
|
+ 'options' => [
|
|
|
+ [ 'id' => "65432", 'title' => "testowa koresp 1", 'kategoriaKosztu' => "KOSZT1" ],
|
|
|
+ [ 'id' => "10008", 'title' => "testowa koresp 8", 'kategoriaKosztu' => "KOSZT8" ],
|
|
|
+ [ 'id' => "10009", 'title' => "testowa koresp 9", 'kategoriaKosztu' => "KOSZT9" ],
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if ('default_db/IN7_MK_BAZA_DYSTRYBUCJI' == $nsUri) {
|
|
|
+ return [
|
|
|
+ 'options' => [
|
|
|
+ [ 'id' => 100, 'nrBudowy' => 'Budowa 100/2016' ],
|
|
|
+ [ 'id' => 101, 'nrBudowy' => 'Budowa 101/2016' ],
|
|
|
+ [ 'id' => 102, 'nrBudowy' => 'Budowa 102/2016' ],
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return null;// msg?
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetchDataBySchema($schema, $idUser, $primaryKey = null) {// if $primaryKey is null then search for last row
|
|
|
+ return [// TODO: fetch data from DB
|
|
|
+ 'id' => 123,
|
|
|
+ 'created' => '2016-11-22', // data wydania zaliczki - data utworzenia rekordu
|
|
|
+ 'worker' => [
|
|
|
+ 'id' => 666,
|
|
|
+ 'name' => 'Kowalski', // 'TODO' => get name from admin_users - imię i nazwisko pracownika pobierającego zaliczkę
|
|
|
+ 'login' => 'kowalski'
|
|
|
+ ],
|
|
|
+ 'kwota' => 555.55, // kwota wypłaconej zaliczki
|
|
|
+ 'nierozliczona_kwota' => 123.56,
|
|
|
+ 'pozycja' => [
|
|
|
+ [ 'id' => 1,
|
|
|
+ 'kwota' => 100.22,
|
|
|
+ 'korespondencja' => [ 'id' => 65432, 'title' => 'testowa koresp 1', 'kategoriaKosztu' => 'KOSZT1' ],
|
|
|
+ 'projekt' => [ 'nrBudowy' => 'Budowa/1' ]
|
|
|
+ ],
|
|
|
+ [ 'id' => 2,
|
|
|
+ 'kwota' => 200.55,
|
|
|
+ 'korespondencja' => [ 'id' => 76543, 'title' => 'testowa koresp 2', 'kategoriaKosztu' => 'KOSZT2' ],
|
|
|
+ 'projekt' => [ 'id' => 123, 'nrBudowy' => 'Budowa/2' ]
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function zaliczkaListaView($data) {
|
|
|
+ $idUser = V::get('idUser', User::getID(), $data);
|
|
|
+
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
|
|
|
+ $schema = $acl->getSimpleSchemaTree();
|
|
|
+ $zaliczkaData = $this->fetchDataBySchema($schema, $idUser);
|
|
|
+
|
|
|
+ UI::startContainer();
|
|
|
+ UI::setTitle("Zaliczka");
|
|
|
+
|
|
|
+ UI::startTag('form', ['action'=>'', 'method'=>'POST']);
|
|
|
+ UI::emptyTag('input', ['type'=>"hidden", 'name'=>'_route', 'value'=>"UrlAction_UserProNetMediaZaliczka"]);
|
|
|
+ UI::emptyTag('input', ['type'=>"hidden", 'name'=>'_task', 'value'=>"add"]);
|
|
|
+ UI::emptyTag('input', ['type'=>"hidden", 'name'=>'idUser', 'value'=>$idUser]);
|
|
|
+ UI::emptyTag('input', ['type'=>"submit", 'value'=>"Dodaj nową zaliczkę", 'class'=>'btn btn-primary']);
|
|
|
+ UI::endTag('form');
|
|
|
+
|
|
|
+ UI::alert('danger', "TODO: lista zaliczek");
|
|
|
+ UI::alert('danger', "TODO: pierwsza na liście - aktualna - btn(Rozlicz)");// -> Edycja zaliczki
|
|
|
+
|
|
|
+ UI::endContainer();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addAction() {
|
|
|
+ $idUser = V::get('idUser', User::getID(), $_REQUEST);
|
|
|
+ try {
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
|
|
|
+ $id = $acl->addItem([
|
|
|
+ 'worker' => [
|
|
|
+ 'id' => $idUser
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ if (!$id) throw new Exception("Nie udało się utworzyć zaliczki");
|
|
|
+
|
|
|
+ } catch (Exception $e) {
|
|
|
+ UI::gora();
|
|
|
+ // UI::menu();// TODO: show menu
|
|
|
+ UI::startContainer();
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ UI::endContainer();
|
|
|
+ UI::dol();
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $redirectUrl = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&idUser={$idUser}&idZaliczka={$id}";
|
|
|
+ if (!headers_sent()) {
|
|
|
+ header("Location: {$redirectUrl}");
|
|
|
+ } else {
|
|
|
+ echo'<script type="text/javascript">'."
|
|
|
+window.location.href='{$redirectUrl}';
|
|
|
+ ".'</script>';
|
|
|
+ echo "\n".'<noscript>';
|
|
|
+ echo "\n".'<meta http-equiv="refresh" content="0;url='.$redirectUrl.'" />';
|
|
|
+ echo "\n".'</noscript>';
|
|
|
+ echo'<p>'.'<a href="'.$redirectUrl.'">'."dalej".'</a>'.'</p>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reinstallAction() {
|
|
|
+ UI::gora();
|
|
|
+ try {
|
|
|
+ Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka")->reinstall();
|
|
|
+ UI::startContainer();
|
|
|
+ UI::alert('success', "Structure for 'default_db/ZALICZKA/Zaliczka' created in a database");
|
|
|
+ $backUrl = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka";
|
|
|
+ UI::tag('a', ['href'=>$backUrl, 'class'=>"btn btn-primary"], "wróć");
|
|
|
+
|
|
|
+ UI::table([
|
|
|
+ 'caption' => "Zaliczka",
|
|
|
+ 'rows' => DB::getPDO()->fetchAll("
|
|
|
+ select t.TABLE_NAME, t.COLUMN_NAME, t.DATA_TYPE, t.COLUMN_TYPE
|
|
|
+ from `information_schema`.`COLUMNS` t
|
|
|
+ where t.TABLE_SCHEMA = 'SES_USERS2'
|
|
|
+ and (t.TABLE_NAME like 'ZALICZKA'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA\_\_%'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_HIST'
|
|
|
+ or t.TABLE_NAME like 'Zaliczka\_\_%'
|
|
|
+ )
|
|
|
+ order by t.TABLE_NAME asc, t.COLUMN_NAME asc
|
|
|
+ ")
|
|
|
+ ]);
|
|
|
+
|
|
|
+ UI::table([
|
|
|
+ 'caption' => "Zaliczka Pozycja",
|
|
|
+ 'rows' => DB::getPDO()->fetchAll("
|
|
|
+ select t.TABLE_NAME, t.COLUMN_NAME, t.DATA_TYPE, t.COLUMN_TYPE
|
|
|
+ from `information_schema`.`COLUMNS` t
|
|
|
+ where t.TABLE_SCHEMA = 'SES_USERS2'
|
|
|
+ and (t.TABLE_NAME like 'ZALICZKA_POZYCJA'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_POZYCJA\_\_%'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_POZYCJA_HIST'
|
|
|
+ or t.TABLE_NAME like 'ZaliczkaPozycja\_\_%'
|
|
|
+ )
|
|
|
+ order by t.TABLE_NAME asc, t.COLUMN_NAME asc
|
|
|
+ ")
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $tableList = DB::getPDO()->fetchAll("
|
|
|
+ select t.TABLE_NAME
|
|
|
+ from `information_schema`.`COLUMNS` t
|
|
|
+ where t.TABLE_SCHEMA = 'SES_USERS2'
|
|
|
+ and (t.TABLE_NAME like 'ZALICZKA'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA\_\_%'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_HIST'
|
|
|
+ or t.TABLE_NAME like 'Zaliczka\_\_%'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_POZYCJA'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_POZYCJA\_\_%'
|
|
|
+ or t.TABLE_NAME like 'ZALICZKA_POZYCJA_HIST'
|
|
|
+ or t.TABLE_NAME like 'ZaliczkaPozycja\_\_%'
|
|
|
+ )
|
|
|
+ group by t.TABLE_NAME
|
|
|
+ ");
|
|
|
+ foreach ($tableList as $table) {
|
|
|
+ $tableName = $table['TABLE_NAME'];
|
|
|
+ UI::startTag('div', ['style'=>"margin:10px 0; max-width:100%; overflow:scroll; border:1px solid #ccc"]);
|
|
|
+ UI::table([
|
|
|
+ 'caption' => "Tabela '{$tableName}'",
|
|
|
+ 'rows' => DB::getPDO()->fetchAll("
|
|
|
+ select t.*
|
|
|
+ from `{$tableName}` t
|
|
|
+ ")
|
|
|
+ ]);
|
|
|
+ UI::endTag('div');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ('1' == V::get('_clear', '', $_GET)) {
|
|
|
+ foreach ($tableList as $table) {
|
|
|
+ $tableName = $table['TABLE_NAME'];
|
|
|
+ DB::getPDO()->exec("TRUNCATE `{$tableName}`");
|
|
|
+ }
|
|
|
+ UI::tag('a', ['class'=>"btn btn-primary", 'href'=>"index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=reinstall"], "Dane usunięte - odśwież stronę");
|
|
|
+ } else {
|
|
|
+ UI::tag('a', ['class'=>"btn btn-danger", 'href'=>"index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=reinstall&_clear=1"], "Wyczyść tabele");
|
|
|
+ }
|
|
|
+ UI::endContainer();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ UI::dol();
|
|
|
+ }
|
|
|
+
|
|
|
public function zaliczkaFormView($data) {
|
|
|
- $idUser = V::get('id_user', User::getID(), $data);
|
|
|
+ $idUser = V::get('idUser', User::getID(), $data);
|
|
|
+ $idZaliczka = V::get('idZaliczka', 0, $data);
|
|
|
|
|
|
UI::tag('div', ['id'=>"zaliczka-app", 'data-dbg'=>V::get('DBG', '', $_GET), 'data-sync-js-function'=>"syncZaliczkaState", 'data-fetch-data-js-function'=>"zaliczkaFetchData"]);
|
|
|
UI::emptyTag('br');
|
|
|
|
|
|
- $acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");//User::getAcl()->getObjectAcl();
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
|
|
|
$schema = $acl->getSimpleSchemaTree();
|
|
|
$zaliczkaData = $this->fetchDataBySchema($schema, $idUser);
|
|
|
|
|
|
+ DBG::nicePrint($zaliczkaData, '$zaliczkaData');// TODO: DBG
|
|
|
+
|
|
|
?>
|
|
|
<script>
|
|
|
function zaliczkaFetchData(query, fieldType, resultCallback) {
|
|
|
@@ -55,9 +291,11 @@ function zaliczkaFetchData(query, fieldType, resultCallback) {
|
|
|
return;
|
|
|
}
|
|
|
switch (fieldType['@namespace']) {
|
|
|
- case 'default_db/IN7_DZIENNIK_KORESP': {
|
|
|
+ case 'default_db/IN7_MK_BAZA_DYSTRYBUCJI':
|
|
|
+ case 'default_db/IN7_DZIENNIK_KORESP':
|
|
|
+ {
|
|
|
superagent
|
|
|
- .post('<?= Request::getPathUri(); ?>/index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=fetchDataAjax')
|
|
|
+ .post('<?= Request::getPathUri(); ?>/index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=fetchDataAjax&idUser=<?= $idUser; ?>&idZaliczka=<?= $idZaliczka; ?>')
|
|
|
.type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
|
|
|
.send({
|
|
|
schema: fieldType,
|
|
|
@@ -65,32 +303,17 @@ function zaliczkaFetchData(query, fieldType, resultCallback) {
|
|
|
})
|
|
|
.set('Accept', 'application/json')
|
|
|
.end(function(err, res) {
|
|
|
- var payload;
|
|
|
- if (err || !res.ok || 'application/json' !== res.type) {
|
|
|
- payload = {type: 'warning', msg: (res.body && res.body.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);
|
|
|
+ var payload = (err || !res.ok || 'application/json' !== res.type)
|
|
|
+ ? {type: 'warning', msg: (res.body && res.body.msg) ? res.body.msg : 'Request error', body: res.body}
|
|
|
+ : {type: 'success', msg: res.body.msg || '', body: res.body}
|
|
|
+ jQuery(document).trigger('DBG:notify', payload)
|
|
|
+ console.log('F.fetchDataAjax res.body', res.body)
|
|
|
+ console.log('F.fetchDataAjax payload', payload)
|
|
|
+ jQuery.notify(payload.msg, payload.type)
|
|
|
+ resultCallback(payload.body)
|
|
|
});
|
|
|
- console.warn("TODO: fetch by ajax default_db:IN7_DZIENNIK_KORESP");
|
|
|
- var options = [
|
|
|
- { id: 65432, title: 'testowa koresp 1', kategoriaKosztu: 'KOSZT1' },
|
|
|
- { id: 10008, title: 'testowa koresp 8', kategoriaKosztu: 'KOSZT8' },
|
|
|
- { id: 10009, title: 'testowa koresp 9', kategoriaKosztu: 'KOSZT9' },
|
|
|
- ]
|
|
|
- resultCallback(options);
|
|
|
- } break;
|
|
|
- case 'default_db/IN7_MK_BAZA_DYSTRYBUCJI': {
|
|
|
- console.warn("TODO: fetch by ajax default_db:IN7_MK_BAZA_DYSTRYBUCJI");
|
|
|
- var options = [
|
|
|
- { id: 100, nrBudowy: 'Budowa 100/2016' },
|
|
|
- { id: 101, nrBudowy: 'Budowa 101/2016' },
|
|
|
- { id: 102, nrBudowy: 'Budowa 102/2016' },
|
|
|
- ]
|
|
|
- resultCallback(options);
|
|
|
- } break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
default: {
|
|
|
console.log("BUG: Unsupported type namespace '" + fieldType['@baseTypeName'] + "'");
|
|
|
}
|
|
|
@@ -105,94 +328,31 @@ function syncZaliczkaState(state, updates, stateSyncSyccessCallback, stateSyncEr
|
|
|
// TODO: if ajax success then stateSyncSyccessCallback(Response.data)
|
|
|
// TODO: if ajax fail then stateSyncErrorCallback(Response.data)
|
|
|
console.log('====== TODO: syncZaliczkaState updates:', updates, 'state:', state);
|
|
|
- if (null === updates) {
|
|
|
- var data = {
|
|
|
- nierozliczonaKwota: 300,
|
|
|
- schema: {
|
|
|
- zaliczka: <?= json_encode($schema); ?>
|
|
|
- },
|
|
|
- zaliczka: <?= json_encode($zaliczkaData); ?>
|
|
|
- }
|
|
|
- setTimeout(function() {
|
|
|
- stateSyncSyccessCallback({data: data});// TODO: app state + updates from api Response
|
|
|
- }, 1000);
|
|
|
- } else {
|
|
|
- setTimeout(function() {
|
|
|
- stateSyncSyccessCallback({data: state});// TODO: app state + updates from api Response
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
+ superagent
|
|
|
+ .post('<?= Request::getPathUri(); ?>/index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=syncStataAjax&idUser=<?= $idUser; ?>&idZaliczka=<?= $idZaliczka; ?>') // TODO: add idUser & idZaliczka
|
|
|
+ .type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
|
|
|
+ .send({
|
|
|
+ updates: updates,
|
|
|
+ })
|
|
|
+ .set('Accept', 'application/json')
|
|
|
+ .end(function(err, res) {
|
|
|
+ var payload = (err || !res.ok || 'application/json' !== res.type)
|
|
|
+ ? {type: 'warning', msg: (res.body && res.body.msg) ? res.body.msg : 'Request error', body: res.body}
|
|
|
+ : {type: 'success', msg: res.body.msg || '', body: res.body}
|
|
|
+ jQuery(document).trigger('DBG:notify', payload)
|
|
|
+ console.log('F.syncZaliczkaState res.body', res.body)
|
|
|
+ console.log('F.syncZaliczkaState payload', payload)
|
|
|
+ jQuery.notify(payload.msg, payload.type)
|
|
|
+ stateSyncSyccessCallback({data: payload.body})
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
<?php
|
|
|
+ UI::tag('script', ['src'=>'static/vendor.js' . (V::get('DBG', '', $_GET) ? '?_ts=' . time() : ''), 'type'=>'text/javascript']);
|
|
|
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,
|
|
|
- 'created' => '2016-11-22', // data wydania zaliczki - data utworzenia rekordu
|
|
|
- 'worker' => [
|
|
|
- 'id' => 666,
|
|
|
- 'name' => 'Kowalski', // 'TODO' => get name from admin_users - imię i nazwisko pracownika pobierającego zaliczkę
|
|
|
- 'login' => 'kowalski'
|
|
|
- ],
|
|
|
- 'kwota' => 555.55, // kwota wypłaconej zaliczki
|
|
|
- 'pozycja' => [
|
|
|
- [ 'id' => 1,
|
|
|
- 'kwota' => 100.22,
|
|
|
- 'korespondencja' => [ 'id' => 65432, 'title' => 'testowa koresp 1', 'kategoriaKosztu' => 'KOSZT1' ],
|
|
|
- 'projekt' => [ 'nrBudowy' => 'Budowa/1' ]
|
|
|
- ],
|
|
|
- [ 'id' => 2,
|
|
|
- 'kwota' => 200.55,
|
|
|
- 'korespondencja' => [ 'id' => 76543, 'title' => 'testowa koresp 2', 'kategoriaKosztu' => 'KOSZT2' ],
|
|
|
- 'projekt' => [ 'nrBudowy' => 'Budowa/2' ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- public function getSchema() {
|
|
|
- return [// var zaliczkaFlatSchema
|
|
|
- '__baseTypeName' => 'default_db:ZALICZKA',
|
|
|
- 'id' => 'xsd:integer',
|
|
|
- 'created' => 'xsd:date',
|
|
|
- 'worker' => [// 'ref:worker',
|
|
|
- '__baseTypeName' => 'default_db:ADMIN_USERS',
|
|
|
- 'name' => 'xsd:string',
|
|
|
- 'login' => 'xsd:string'
|
|
|
- ],
|
|
|
- 'kwota' => 'xsd:decimal',
|
|
|
- 'pozycja' => [// 'ref:pozycja'
|
|
|
- '__baseTypeName' => 'default_db:ZALICZKA_POZYCJA',
|
|
|
- 'id' => 'xsd:integer',
|
|
|
- 'kwota' => 'xsd:decimal',
|
|
|
- 'korespondencja' => [// 'ref:korespondencja'
|
|
|
- '__baseTypeName' => 'default_db:IN7_DZIENNIK_KORESP',
|
|
|
- 'id' => 'xsd:integer',
|
|
|
- 'title' => 'xsd:string',
|
|
|
- 'kategoriaKosztu' => 'xsd:string'
|
|
|
- ],
|
|
|
- 'projekt' => [// 'ref:projekt'
|
|
|
- '__baseTypeName' => 'default_db:IN7_MK_BAZA_DYSTRYBUCJI',
|
|
|
- 'id' => 'xsd:integer',
|
|
|
- 'nrBudowy' => 'xsd:string'
|
|
|
- ]
|
|
|
- ]
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/* Akcje
|
|
|
@@ -207,42 +367,4 @@ $data = [ id => 123, pozycja => [ [ kwota => 200.00, korespondencja => [ ... ],
|
|
|
update `ZALICZKA__#REF__POZYCJA` set `A_STATUS` = 'DELETED' where `PRIMARY_KEY` = 123;
|
|
|
|
|
|
|
|
|
-*/
|
|
|
-/* -- Struktura
|
|
|
-
|
|
|
-CREATE TABLE IF NOT EXISTS `ZALICZKA__#REF__POZYCJA` ( `PRIMARY_KEY` int(11), `REMOTE_PRIMARY_KEY` int(11), );
|
|
|
-
|
|
|
-CREATE TABLE IF NOT EXISTS `ZALICZKA` (
|
|
|
- `ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
|
- `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
|
|
|
- `A_RECORD_CREATE_AUTHOR` varchar(20) DEFAULT NULL,
|
|
|
- `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL,
|
|
|
- `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
|
|
|
- `A_STATUS` enum('WAITING','NORMAL','MONITOR','WARNING','OFF_SOFT','OFF_HARD','DELETED') DEFAULT NULL,
|
|
|
- `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT '',
|
|
|
- `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT '',
|
|
|
- `L_APPOITMENT_USER` varchar(100) NOT NULL DEFAULT '',
|
|
|
- `KWOTA` decimal(16,2) NOT NULL DEFAULT 0,
|
|
|
- `NIEROZLICZONA_KWOTA` decimal(16,2) NOT NULL DEFAULT 0,
|
|
|
- PRIMARY KEY (`ID`)
|
|
|
- KEY `ID_PROJECT` (`ID_PROJECT`)
|
|
|
-) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
-
|
|
|
-CREATE TABLE IF NOT EXISTS `ZALICZKA_HIST` (
|
|
|
- `ID` int(11) NOT NULL AUTO_INCREMENT,
|
|
|
- `ID_USERS2` int(11) NOT NULL,
|
|
|
- `A_RECORD_CREATE_DATE` varchar(20) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_RECORD_UPDATE_DATE` varchar(20) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_STATUS` varchar(20) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT 'N/S;',
|
|
|
- `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT 'N/S;',
|
|
|
- `L_APPOITMENT_USER` varchar(100) NOT NULL DEFAULT 'N/S;',
|
|
|
- `KWOTA` varchar(16) NOT NULL DEFAULT 'N/S;',
|
|
|
- `NIEROZLICZONA_KWOTA` varchar(16) NOT NULL DEFAULT 'N/S;',
|
|
|
- PRIMARY KEY (`ID`),
|
|
|
- KEY `ID_USERS2` (`ID_USERS2`)
|
|
|
-) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
-
|
|
|
*/
|