Przypomnij.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. <?php
  2. class Przypomnij {
  3. private $_data;
  4. private $_fltrs;
  5. private $_deepRecurseLimit;
  6. private $_dSource = array();
  7. private $_tblIdCache = array();
  8. private $_tblAclCache = array();
  9. public function __construct() {
  10. $this->_data = array();// [type][id] = {id, _title, _type, _l_app, _l_app_date}
  11. $this->_data['projekt'] = array();
  12. $this->_data['koresp'] = array();
  13. $this->_data['proces'] = array();
  14. $this->_fltrs = array();// type => selected value
  15. $this->_fltrs['user'] = '';// L_APPOITMENT_USER
  16. $this->_fltrs['date_from'] = '';
  17. $this->_fltrs['date_to'] = '';
  18. $this->_deepRecurseLimit = 3;
  19. }
  20. public function setRecurseLimit($deepRecurseLimit) {
  21. $this->_deepRecurseLimit = $deepRecurseLimit;
  22. }
  23. public function getRawData() {
  24. return $this->_data;
  25. }
  26. public function fetchData() {
  27. $db = DB::getDB();
  28. $userLogin = User::getLogin();
  29. $usrAclGroups = User::getLdapGroupsNames();
  30. //$usrAclGroups[] = '';// TODO: empty group not allowed to view for everyone?
  31. $sqlUsrAclGroups = "'" . implode("','", $usrAclGroups) . "'";
  32. $sqlFltr_TODO = "
  33. t.`A_ADM_COMPANY` in({$sqlUsrAclGroups})
  34. and t.`A_CLASSIFIED` in({$sqlUsrAclGroups})
  35. ";
  36. $sqlAclFltrKoresp = "
  37. and (kor.`A_ADM_COMPANY` in({$sqlUsrAclGroups})
  38. or kor.`A_CLASSIFIED` in({$sqlUsrAclGroups})
  39. or kor.`L_APPOITMENT_USER`='{$userLogin}'
  40. )
  41. ";
  42. $sql = "select kor.ID
  43. , kor.ID_PROJECT
  44. , kor.A_STATUS
  45. , kor.L_APPOITMENT_USER
  46. , kor.L_APPOITMENT_DATE
  47. , kor.L_APPOITMENT_INFO
  48. , kor.A_RECORD_CREATE_DATE
  49. , kor.A_RECORD_CREATE_AUTHOR
  50. , kor.K_TYP_KORESP, kor.K_TYP_RODZAJ
  51. -- ? , kor.K_TYP_RODZAJ_OPIS
  52. , kor.K_OD_KOGO
  53. , kor.OD_KOGO_ADRES
  54. , kor.K_ZAWARTOS
  55. -- TODO: , proj.M_DIST_DESC
  56. , kor.K_LOKALIZACJA
  57. , kor.K_LOKALIZACJA_OPIS
  58. from `IN7_DZIENNIK_KORESP` as kor
  59. where kor.`A_STATUS` not in ('OFF_HARD','DELETED')
  60. {$sqlAclFltrKoresp}
  61. ";
  62. $res = $db->query($sql);
  63. while ($r = $db->fetch($res)) {
  64. $r->_task_type = 'koresp';
  65. $r->_show = false;
  66. $r->_acl_proj_id = (int)$r->ID_PROJECT;
  67. $r->_title = "<strong>{$r->K_OD_KOGO}</strong><br><em>{$r->OD_KOGO_ADRES}</em><br>{$r->K_ZAWARTOS}";
  68. $r->_type = "{$r->K_TYP_KORESP}-{$r->K_TYP_RODZAJ}";
  69. $r->_l_app = $r->L_APPOITMENT_USER;
  70. $r->_l_app_date = $r->L_APPOITMENT_DATE;
  71. $this->_data['koresp'][$r->ID] = $r;
  72. }
  73. $sqlAclFltrProj = "
  74. and (proj.`A_ADM_COMPANY` in({$sqlUsrAclGroups})
  75. or proj.`A_CLASSIFIED` in({$sqlUsrAclGroups})
  76. or proj.`L_APPOITMENT_USER`='{$userLogin}'
  77. )
  78. ";
  79. $sql = "select proj.ID
  80. , proj.P_ID
  81. , proj.A_STATUS
  82. , proj.M_DIST_DESC
  83. , proj.M_DIST_TYPE
  84. , proj.L_APPOITMENT_DATE
  85. , proj.L_APPOITMENT_USER
  86. , proj.L_APPOITMENT_INFO
  87. , proj.A_RECORD_CREATE_DATE
  88. , proj.A_RECORD_CREATE_AUTHOR
  89. , proj.M_DISTRIBUTOR
  90. -- ? , proj.M_DIST_DATE
  91. -- ? , proj.A_RECORD_CREATE_AUTHOR, proj.A_RECORD_UPDATE_AUTHOR, proj.A_RECORD_UPDATE_DATE
  92. -- ? , proj.A_PROBLEM, proj.A_PROBLEM_DATE, proj.A_PROBLEM_DESC
  93. from `IN7_MK_BAZA_DYSTRYBUCJI` as proj
  94. where proj.`A_STATUS` NOT IN ('OFF_HARD','DELETED')
  95. {$sqlAclFltrProj}
  96. ";
  97. $res = $db->query($sql);
  98. while ($r = $db->fetch($res)) {
  99. $r->M_DIST_DESC = htmlspecialchars($r->M_DIST_DESC);// TODO: fix bug in html a href inside M_DIST_DESC
  100. $r->_task_type = 'projekt';
  101. $r->_show = false;
  102. $r->_acl_proj_id = (int)$r->P_ID;
  103. $r->_title = $r->M_DIST_DESC;
  104. $r->_type = $r->M_DIST_TYPE;
  105. $r->_l_app = $r->L_APPOITMENT_USER;
  106. $r->_l_app_date = $r->L_APPOITMENT_DATE;
  107. $this->_data['projekt'][$r->ID] = $r;
  108. }
  109. $sqlAclFltrProces = "
  110. and (p.`A_ADM_COMPANY` in({$sqlUsrAclGroups})
  111. or p.`A_CLASSIFIED` in({$sqlUsrAclGroups})
  112. or p.`L_APPOITMENT_USER`='{$userLogin}'
  113. )
  114. ";
  115. $sql = "select p.ID
  116. , p.`DESC`
  117. , p.`A_STATUS`
  118. , p.`TYPE`
  119. , p.`L_APPOITMENT_DATE`
  120. , p.`L_APPOITMENT_USER`
  121. , p.`L_APPOITMENT_INFO`
  122. from `CRM_PROCES` as p
  123. where p.`A_STATUS` in('NORMAL', 'WAITING')
  124. and p.`TYPE`='PROCES_INIT'
  125. and p.`L_APPOITMENT_DATE`!=''
  126. and p.`L_APPOITMENT_USER`!=''
  127. {$sqlAclFltrProces}
  128. ";
  129. $res = $db->query($sql);
  130. while ($r = $db->fetch($res)) {
  131. $r->_task_type = 'proces';
  132. $r->_show = false;
  133. $r->_title = $r->DESC;
  134. $r->_type = $r->TYPE;
  135. $r->_l_app = $r->L_APPOITMENT_USER;
  136. $r->_l_app_date = $r->L_APPOITMENT_DATE;
  137. $this->_data['proces'][$r->ID] = $r;
  138. }
  139. $sqlAclFltrProblems = "
  140. and (probl.`A_ADM_COMPANY` in({$sqlUsrAclGroups})
  141. or probl.`A_CLASSIFIED` in({$sqlUsrAclGroups})
  142. or probl.`L_APPOITMENT_USER`='{$userLogin}'
  143. )
  144. ";
  145. $sql = "select probl.ID
  146. , probl.PARENT_ID
  147. , probl.A_STATUS
  148. , probl.L_APPOITMENT_DATE
  149. , probl.L_APPOITMENT_USER
  150. , probl.L_APPOITMENT_INFO
  151. , probl.A_RECORD_CREATE_DATE
  152. , probl.A_RECORD_CREATE_AUTHOR
  153. , probl.A_PROBLEM
  154. , probl.A_PROBLEM_DESC
  155. from `PROBLEMS` as probl
  156. where probl.`A_STATUS` NOT IN ('OFF_HARD','DELETED')
  157. and probl.`L_APPOITMENT_DATE`!=''
  158. and probl.`L_APPOITMENT_USER`!=''
  159. {$sqlAclFltrProblems}
  160. ";
  161. $res = $db->query($sql);
  162. while ($r = $db->fetch($res)) {
  163. $r->A_PROBLEM_DESC = htmlspecialchars($r->A_PROBLEM_DESC);
  164. $r->_task_type = 'task';
  165. $r->_show = false;
  166. $r->_title = $r->A_PROBLEM_DESC;
  167. $r->_type = $r->M_DIST_TYPE;
  168. $r->_l_app = $r->L_APPOITMENT_USER;
  169. $r->_l_app_date = $r->L_APPOITMENT_DATE;
  170. $this->_data['task'][$r->ID] = $r;
  171. }
  172. $this->_fetchLAppUsers();
  173. }
  174. public function setFltrUser($userName) {
  175. foreach ($this->_data as $kType => $vTasks) {
  176. foreach ($vTasks as $kId => $vTask) {
  177. if (!$userName) {
  178. $this->_data[$kType][$kId]->_show = true;
  179. } else {
  180. if ($vTask->_l_app == $userName) {
  181. $this->_data[$kType][$kId]->_show = true;
  182. } else {
  183. $this->_data[$kType][$kId]->_show = false;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. private function _fetchLAppUsers() {
  190. $this->_createCacheTable();
  191. $this->_updateCacheTable();
  192. $projTodo = array();
  193. foreach ($this->_data['projekt'] as $kID => $vProj) {
  194. if (empty($vProj->_l_app)) {
  195. if ($vProj->_acl_proj_id > 0) {
  196. $projTodo[$vProj->_acl_proj_id][$vProj->ID] = 'projekt';
  197. }
  198. }
  199. }
  200. foreach ($this->_data['koresp'] as $kID => $vKoresp) {
  201. if (empty($vKoresp->_l_app)) {
  202. if ($vKoresp->_acl_proj_id > 0) {
  203. $projTodo[$vKoresp->_acl_proj_id][$vKoresp->ID] = 'koresp';
  204. }
  205. }
  206. }
  207. if (empty($projTodo)) {
  208. return;
  209. }
  210. $db = DB::getDB();
  211. $projIds = array_keys($projTodo);
  212. $sql = "select c.`ID`, c.`ID_PROJECT`, c.`L_APPOITMENT_USER`, c.`L_APPOITMENT_DATE`
  213. from `_PRZYPOMNIJ_CACHE` as c
  214. where c.`ID_PROJECT` in(" . implode(",", $projIds) . ")
  215. ";
  216. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
  217. $res = $db->query($sql);
  218. if (!$res) {
  219. if ($db->has_errors()) {
  220. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">DB Errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($db->get_errors());echo'</pre>';
  221. }
  222. }
  223. while ($r = $db->fetch($res)) {
  224. foreach ($projTodo[$r->ID_PROJECT] as $kRowId => $vType) {
  225. if ($vType == 'projekt') {
  226. if (isset($this->_data['projekt'][$kRowId])) {
  227. if (!empty($r->L_APPOITMENT_USER)) {
  228. $this->_data['projekt'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  229. }
  230. } else {
  231. //echo '<p style="color:red">'."Error not set \$this->_data['projekt'][$kRowId]".'</p>';
  232. }
  233. }
  234. else if ($vType == 'koresp') {
  235. if (!empty($r->L_APPOITMENT_USER)) {
  236. $this->_data['koresp'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  237. if (!empty($r->L_APPOITMENT_DATE) && empty($this->_data['koresp'][$kRowId]->_l_app_date)) {
  238. //$this->_data['koresp'][$kRowId]->_l_app_date = $r->L_APPOITMENT_DATE;
  239. $this->_data['koresp'][$kRowId]->_l_app_date = '0000-00-00';
  240. }
  241. }
  242. }
  243. }
  244. }
  245. }
  246. private function _fetchLAppUsersRec() {
  247. $projTodo = array();
  248. $db = DB::getDB();
  249. $loopLimit = $this->_deepRecurseLimit;
  250. $firstLoop = true;
  251. do {
  252. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') start projTodo (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($projTodo);echo'</pre>';}
  253. foreach ($this->_data['projekt'] as $kID => $vProj) {
  254. if (empty($vProj->_l_app)) {
  255. if ($vProj->_acl_proj_id > 0) {
  256. if (isset($this->_data['projekt'][$vProj->_acl_proj_id])) {// already fetched from DB
  257. if (!empty($this->_data['projekt'][$vProj->_acl_proj_id]->_l_app)) {
  258. $this->_data['projekt'][$vProj->ID]->_l_app = $this->_data['projekt'][$vProj->_acl_proj_id]->_l_app;
  259. } else {
  260. $this->_data['projekt'][$vProj->ID]->_acl_proj_id = $this->_data['projekt'][$vProj->_acl_proj_id]->_acl_proj_id;
  261. }
  262. } else {
  263. $projTodo[$vProj->_acl_proj_id][$vProj->ID] = 'projekt';
  264. }
  265. } else if (!$vProj->_acl_proj_id) {
  266. //if ($firstLoop) echo '<p>'."Error: Projekt {$vProj->ID} nie ma P_ID ani L_APPOITMENT_USER! Autor: {$vProj->A_RECORD_CREATE_AUTHOR} / {$vProj->A_RECORD_CREATE_DATE}".'</p>';
  267. $this->_data['projekt'][$kID]->_acl_proj_id = -1;// set error
  268. } else if ($vProj->_acl_proj_id < 0) {
  269. //if ($firstLoop) echo '<p>'."Error: Projekt {$vProj->ID} ma P_ID = -1, brak L_APPOITMENT_USER! Autor: {$vProj->A_RECORD_CREATE_AUTHOR} / {$vProj->A_RECORD_CREATE_DATE}".'</p>';
  270. $this->_data['projekt'][$kID]->_acl_proj_id = -1;// set error
  271. }
  272. }
  273. }
  274. foreach ($this->_data['koresp'] as $kID => $vKoresp) {
  275. if (empty($vKoresp->_l_app)) {
  276. if ($vKoresp->_acl_proj_id > 0) {
  277. if (!empty($this->_data['projekt'][$vKoresp->_acl_proj_id]->_l_app)) {
  278. $this->_data['koresp'][$vKoresp->ID]->_l_app = $this->_data['projekt'][$vKoresp->_acl_proj_id]->_l_app;
  279. } else {
  280. $this->_data['koresp'][$vKoresp->ID]->_acl_proj_id = $this->_data['projekt'][$vKoresp->_acl_proj_id]->_acl_proj_id;
  281. if ($vKoresp->_acl_proj_id > 0) {
  282. $projTodo[$vKoresp->_acl_proj_id][$vKoresp->ID] = 'koresp';
  283. } else {
  284. //echo '<p style="color:red">'."Error: brak l_app w projektach dla Koresp {$vKoresp->ID}".'</p>';
  285. }
  286. }
  287. } else {
  288. //if ($firstLoop) echo '<p>'."Error: Korespondencja {$vKoresp->ID} ma ID_PROJECT = {$vKoresp->_acl_proj_id}, brak L_APPOITMENT_USER! Autor: {$vKoresp->A_RECORD_CREATE_AUTHOR} / {$vKoresp->A_RECORD_CREATE_DATE}".'</p>';
  289. $this->_data['koresp'][$kID]->_acl_proj_id = -1;// set error
  290. }
  291. }
  292. }
  293. if ($firstLoop) $firstLoop = false;
  294. if (empty($projTodo)) {
  295. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("break loop " . ($this->_deepRecurseLimit - $loopLimit));echo'</pre>';}
  296. break;
  297. }
  298. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') $projTodo (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($projTodo);echo'</pre>';}
  299. $projIds = array_keys($projTodo);
  300. $sql = "select `ID`, `P_ID`, `L_APPOITMENT_USER`, `L_APPOITMENT_USER`
  301. from `IN7_MK_BAZA_DYSTRYBUCJI`
  302. where `ID` in(" . implode(",", $projIds) . ")
  303. ";
  304. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
  305. $res = $db->query($sql);
  306. if (!$res) {
  307. if ($db->has_errors()) {
  308. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">DB Errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($db->get_errors());echo'</pre>';
  309. }
  310. }
  311. while ($r = $db->fetch($res)) {
  312. //if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') r [isset($projTodo[$r->ID]) = '.isset($projTodo[$r->ID]).'] (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($r);echo'</pre>';}
  313. foreach ($projTodo[$r->ID] as $kRowId => $vType) {
  314. if ($vType == 'projekt') {
  315. if (isset($this->_data['projekt'][$kRowId])) {
  316. $this->_data['projekt'][$kRowId]->_acl_proj_id = (int)$r->P_ID;
  317. if (!empty($r->L_APPOITMENT_USER)) {
  318. $this->_data['projekt'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  319. //if (!empty($r->L_APPOINTMENT_DATE)) {
  320. // $this->_data['projekt'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  321. //}
  322. }
  323. } else {
  324. echo '<p style="color:red">'."Error not set \$this->_data['projekt'][$kRowId]".'</p>';
  325. }
  326. } else if ($vType == 'koresp') {
  327. $this->_data['koresp'][$kRowId]->_acl_proj_id = (int)$r->P_ID;
  328. if (!empty($r->L_APPOITMENT_USER)) {
  329. $this->_data['koresp'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  330. //if (!empty($r->L_APPOINTMENT_DATE)) {
  331. // $this->_data['projekt'][$kRowId]->_l_app = $r->L_APPOITMENT_USER;
  332. //}
  333. }
  334. }
  335. }
  336. unset($projTodo[$r->ID]);
  337. }
  338. if(V::get('DBG_P', '', $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">loop(' . ($this->_deepRecurseLimit - $loopLimit) . ') this->_data (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_data);echo'</pre>';}
  339. } while (--$loopLimit);
  340. }
  341. public function getAllowedUsersList() {
  342. $allowedUsers = array();
  343. $db = DB::getDB();
  344. $userLogin = User::getLogin();
  345. $usrAclGroups = User::getLdapGroupsNames();
  346. //$usrAclGroups[] = '';// TODO: allow empty for everyone?
  347. $sqlUsrAclGroups = "'" . implode("','", $usrAclGroups) . "'";
  348. DBG::_('DBG_P', '>2', 'sqlUsrAclGroups', $sqlUsrAclGroups, __CLASS__, __FUNCTION__, __LINE__);
  349. $tblsToSearch = array();
  350. $tblsToSearch[] = 'IN7_MK_BAZA_DYSTRYBUCJI';
  351. $tblsToSearch[] = 'IN7_DZIENNIK_KORESP';
  352. $tblsToSearch[] = 'CRM_PROCES';
  353. $tblsToSearch[] = 'CRM_LISTA_ZASOBOW';
  354. $tblsToSearch[] = 'PROBLEMS';
  355. $userAcl = User::getAcl();
  356. foreach ($tblsToSearch as $tblName) {
  357. $tblZasobId = ProcesHelper::getZasobTableID($tblName);
  358. if ($userAcl->hasTableAcl($tblZasobId)) {
  359. $tblAcl = $userAcl->getTableAcl($tblZasobId);
  360. if ($tblAcl->hasFieldPerm($tblAcl->getFieldIdByName('ID'), 'R')) {
  361. $ds = $tblAcl->getDataSource();
  362. $sqlAclFltr = '';
  363. if ($ds->hasAclGroupFields()) {
  364. $fldGroupWrite = $ds->getFieldGroupWrite();
  365. $fldGroupRead = $ds->getFieldGroupRead();
  366. $fldOwner = $ds->getFieldOwner();
  367. $sqlFltr = "
  368. t.`{$fldGroupWrite}` in({$sqlUsrAclGroups})
  369. and t.`{$fldGroupRead}` in({$sqlUsrAclGroups})
  370. ";
  371. if ($fldOwner) {
  372. $sqlFltr = "( ({$sqlFltr}) or t.`{$fldOwner}`='{$userLogin}' )";
  373. }
  374. $sqlAclFltr = " and {$sqlFltr}";
  375. }
  376. $sql = "select distinct t.`L_APPOITMENT_USER`
  377. from `{$tblName}` t
  378. where t.`L_APPOITMENT_USER`!=''
  379. and t.`A_STATUS` not in ('OFF_HARD','DELETED')
  380. {$sqlAclFltr}
  381. ";
  382. $res = $db->query($sql) or die("blad zapytania do bazy {$sql}");
  383. while ($r = $db->fetch($res)) {
  384. $allowedUsers[$r->L_APPOITMENT_USER] = true;
  385. }
  386. DBG::_('DBG_P', '>2', 'allowedUsers after '.$tblName.'', implode(',', array_keys($allowedUsers)), __CLASS__, __FUNCTION__, __LINE__);
  387. }
  388. }
  389. }
  390. if (!empty($allowedUsers)) {
  391. $allowedUsersFiltered = array();
  392. $tblName = 'ADMIN_USERS';
  393. $tblZasobId = ProcesHelper::getZasobTableID($tblName);
  394. if (!$userAcl->hasTableAcl($tblZasobId)) {
  395. DBG::_('DBG_P', '>2', '!hasTableAcl', null, __CLASS__, __FUNCTION__, __LINE__);
  396. return null;
  397. }
  398. $tblAcl = $userAcl->getTableAcl($tblZasobId);
  399. if (!$tblAcl->hasFieldPerm($tblAcl->getFieldIdByName('ID'), 'R')) {
  400. DBG::_('DBG_P', '>2', '!$tblAcl->hasFieldPerm(ID, R)', $tblAcl, __CLASS__, __FUNCTION__, __LINE__);
  401. return null;
  402. }
  403. $ds = $tblAcl->getDataSource();
  404. $sqlAclFltr = '';
  405. if ($ds->hasAclGroupFields()) {
  406. $fldGroupWrite = $ds->getFieldGroupWrite();
  407. $fldGroupRead = $ds->getFieldGroupRead();
  408. $sqlFltr = "
  409. t.`{$fldGroupWrite}` in({$sqlUsrAclGroups})
  410. and t.`{$fldGroupRead}` in({$sqlUsrAclGroups})
  411. ";
  412. $sqlAclFltr = " and {$sqlFltr}";
  413. }
  414. else {
  415. DBG::_('DBG_P', '>0', '!hasAclGroupFields tblAcl', $tblAcl, __CLASS__, __FUNCTION__, __LINE__);
  416. }
  417. $sqlFoundUsers = array_keys($allowedUsers);
  418. $sqlFoundUsers = "'" . implode("','", $sqlFoundUsers) . "'";
  419. $sql = "select t.`ADM_ACCOUNT`
  420. from `{$tblName}` t
  421. where t.`ADM_ACCOUNT` in({$sqlFoundUsers})
  422. {$sqlAclFltr}
  423. ";
  424. DBG::_('DBG_P', '>2', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__);
  425. $res = $db->query($sql) or die("blad zapytania do bazy {$sql}");
  426. while ($r = $db->fetch($res)) {
  427. $allowedUsersFiltered[$r->ADM_ACCOUNT] = true;
  428. }
  429. $allowedUsers = $allowedUsersFiltered;
  430. }
  431. DBG::_('DBG_P', '>2', 'allowedUsersFiltered', $allowedUsersFiltered, __CLASS__, __FUNCTION__, __LINE__);
  432. ksort($allowedUsers);
  433. return $allowedUsers;
  434. }
  435. private function _createCacheTable() {
  436. $db = DB::getDB();
  437. $sql = "CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_CACHE` (
  438. `ID` int(11) NOT NULL AUTO_INCREMENT,
  439. `ID_PROJECT` int(11) NOT NULL,
  440. `_l_app_user` varchar(40) NOT NULL DEFAULT '',
  441. `P_ID` varchar(20) NOT NULL DEFAULT '0',
  442. `A_RECORD_CREATE_DATE` datetime NOT NULL,
  443. `A_RECORD_CREATE_AUTHOR` varchar(40) NOT NULL DEFAULT '',
  444. `A_RECORD_UPDATE_DATE` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  445. `A_RECORD_UPDATE_AUTHOR` varchar(40) NOT NULL DEFAULT '',
  446. `L_APPOITMENT_DATE` varchar(30) NOT NULL DEFAULT '',
  447. `L_APPOITMENT_USER` varchar(40) NOT NULL DEFAULT '',
  448. `L_APPOITMENT_INFO` varchar(200) NOT NULL DEFAULT '',
  449. `L_CALENDAR` enum('NO','YES') NOT NULL DEFAULT 'NO',
  450. `A_STATUS` enum('WAITING','NORMAL','MONITOR','WARNING','OFF_SOFT','OFF_HARD','DELETED') NOT NULL DEFAULT 'WAITING',
  451. `M_DIST_DATE` date NOT NULL DEFAULT '0000-00-00',
  452. `M_DIST_TYPE` varchar(64) NOT NULL DEFAULT 'INNE',
  453. `M_DIST_DESC` varchar(255) NOT NULL DEFAULT '',
  454. `M_DISTRIBUTOR` varchar(200) NOT NULL DEFAULT '',
  455. PRIMARY KEY (`ID`),
  456. KEY `P_ID` (`P_ID`),
  457. KEY `ID_PROJECT` (`ID_PROJECT`)
  458. ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
  459. ";
  460. if(V::get('DBG_P', '', $_GET) > 3){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
  461. $db->query($sql);
  462. }
  463. private function _updateCacheTable() {
  464. $db = DB::getDB();
  465. $sql = "truncate table `_PRZYPOMNIJ_CACHE`; ";
  466. $db->query($sql);
  467. $sql = "insert into `_PRZYPOMNIJ_CACHE` (`ID_PROJECT`,`P_ID`,`_l_app_user`,`L_APPOITMENT_USER`,`L_APPOITMENT_DATE`)
  468. select `ID`,`P_ID`,`L_APPOITMENT_USER`,`L_APPOITMENT_USER`,`L_APPOITMENT_DATE`
  469. from `IN7_MK_BAZA_DYSTRYBUCJI`
  470. where 1=1
  471. ";
  472. $db->query($sql);
  473. // test recurse update l_app
  474. $sql = "select c._l_app_user
  475. , p.L_APPOITMENT_USER
  476. , p1.L_APPOITMENT_USER
  477. , p2.L_APPOITMENT_USER
  478. , p3.L_APPOITMENT_USER
  479. , p4.L_APPOITMENT_USER
  480. , p5.L_APPOITMENT_USER
  481. , p.ID
  482. , p1.ID
  483. , p2.ID
  484. , p3.ID
  485. , p4.ID
  486. , p5.ID
  487. from `_PRZYPOMNIJ_CACHE` as c
  488. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p on (p.ID=c.ID_PROJECT)
  489. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p1 on (p1.ID=p.P_ID)
  490. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p2 on (p2.ID=p1.P_ID)
  491. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p3 on (p3.ID=p2.P_ID)
  492. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p4 on (p4.ID=p3.P_ID)
  493. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p5 on (p5.ID=p4.P_ID)
  494. where c.`_l_app_user`=''
  495. ";
  496. // for i to recurse limit
  497. $sql = "update `_PRZYPOMNIJ_CACHE` as c
  498. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p on (p.ID=c.ID_PROJECT)
  499. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p1 on (p1.ID=p.P_ID)
  500. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p2 on (p2.ID=p1.P_ID)
  501. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p3 on (p3.ID=p2.P_ID)
  502. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p4 on (p4.ID=p3.P_ID)
  503. left join `IN7_MK_BAZA_DYSTRYBUCJI` as p5 on (p5.ID=p4.P_ID)
  504. set
  505. c.`_l_app_user`=IF(p.`L_APPOITMENT_USER`!='', p.`L_APPOITMENT_USER`
  506. , IF(p1.`L_APPOITMENT_USER`!='', p1.`L_APPOITMENT_USER`
  507. , IF(p2.`L_APPOITMENT_USER`!='', p2.`L_APPOITMENT_USER`
  508. , IF(p3.`L_APPOITMENT_USER`!='', p3.`L_APPOITMENT_USER`
  509. , IF(p4.`L_APPOITMENT_USER`!='', p4.`L_APPOITMENT_USER`
  510. , IF(p5.`L_APPOITMENT_USER`!='', p5.`L_APPOITMENT_USER`
  511. , ''
  512. )
  513. )
  514. )
  515. )
  516. )
  517. )
  518. where c.`_l_app_user`=''
  519. ";
  520. $db->query($sql);
  521. }
  522. public function orderByDateAsc($t1, $t2) {
  523. return $this->orderByDate($t1, $t2, true);
  524. }
  525. public function orderByDateDesc($t1, $t2) {
  526. return $this->orderByDate($t1, $t2, false);
  527. }
  528. public function orderByDate($t1, $t2, $asc = true) {
  529. $a = $t1->_l_app_date;
  530. $b = $t2->_l_app_date;
  531. if ($a == $b) {
  532. return 0;
  533. }
  534. if ($asc) {
  535. return ($a > $b)? 1 : -1;
  536. } else {
  537. return ($a < $b)? 1 : -1;
  538. }
  539. }
  540. public function getTasksByDate($asc = true) {
  541. $tasks = array();
  542. foreach ($this->_data as $kType => $vTasks) {
  543. foreach ($vTasks as $kId => $vTask) {
  544. $tasks[] = $vTask;
  545. }
  546. }
  547. if ($asc) {
  548. usort($tasks, array($this, 'orderByDateAsc'));
  549. } else {
  550. usort($tasks, array($this, 'orderByDateDesc'));
  551. }
  552. return $tasks;
  553. }
  554. public function getZasobIdByType($type) {
  555. if (!isset($this->_tblIdCache[$type])) {
  556. $this->_tblIdCache[$type] = null;
  557. $allowedTypes = array('projekt', 'proces', 'koresp', 'task');
  558. if (empty($type) || !in_array($type, $allowedTypes)) {
  559. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu" . '</div>';
  560. return null;
  561. }
  562. Lib::loadClass('ProcesHelper');
  563. switch ($type) {
  564. case 'projekt':
  565. $this->_tblIdCache[$type] = ProcesHelper::getZasobTableID('IN7_MK_BAZA_DYSTRYBUCJI');
  566. break;
  567. case 'koresp':
  568. $this->_tblIdCache[$type] = ProcesHelper::getZasobTableID('IN7_DZIENNIK_KORESP');
  569. break;
  570. case 'proces':
  571. $this->_tblIdCache[$type] = ProcesHelper::getZasobTableID('CRM_PROCES');
  572. break;
  573. case 'task':
  574. $this->_tblIdCache[$type] = ProcesHelper::getZasobTableID('PROBLEMS');
  575. break;
  576. default:
  577. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu" . '</div>';
  578. return null;
  579. }
  580. }
  581. return $this->_tblIdCache[$type];
  582. }
  583. private function getTblAclByType($type) {
  584. if (!isset($this->_tblAclCache[$type])) {
  585. $this->_tblAclCache[$type] = null;
  586. $zasobID = $this->getZasobIdByType($type);
  587. if (!$zasobID) {
  588. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu" . '</div>';
  589. return null;
  590. }
  591. Lib::loadClass('ProcesHelper');
  592. $zasobObj = ProcesHelper::getZasobTableInfo($zasobID);
  593. if (!$zasobObj) {
  594. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Zasob TABELA ID={$zasobID} nie istnieje" . '</div>';
  595. return null;
  596. }
  597. $userAcl = User::getAcl();
  598. $userAcl->fetchGroups();
  599. if (!$userAcl->hasTableAcl($zasobObj->ID)) {
  600. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak uprawnień do tabeli ID={$zasobObj->ID}" . '</div>';
  601. return null;
  602. }
  603. $tblAcl = $userAcl->getTableAcl($zasobObj->ID);
  604. $this->_tblAclCache[$type] = $tblAcl;
  605. }
  606. return $this->_tblAclCache[$type];
  607. }
  608. private function getDataSource($tblAcl) {
  609. $tblName = $tblAcl->getName();
  610. if (!isset($this->_dSource[$tblName])) {
  611. $this->_dSource[$tblName] = $tblAcl->getDataSource();
  612. }
  613. return $this->_dSource[$tblName];
  614. }
  615. private function getEditAppDateFields() {
  616. $fields = array();
  617. $fields[] = 'L_APPOITMENT_DATE';
  618. $fields[] = 'L_APPOITMENT_USER';
  619. $fields[] = 'L_APPOITMENT_INFO';
  620. return $fields;
  621. }
  622. public function sendAjaxEditAppDateInline() {
  623. // $_GET [rowid] => 2286, [type] => proces, [fldId] => date
  624. $rowID = V::get('rowid', 0, $_GET, 'int');
  625. $type = V::get('type', '', $_GET);
  626. $fields = $this->getEditAppDateFields();
  627. $DBG = ('1' == V::get('DBG', '', $_REQUEST));
  628. header("Content-type: text/plain");
  629. if ($rowID <= 0) {
  630. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu" . '</div>';
  631. exit;
  632. }
  633. $tblAcl = $this->getTblAclByType($type);
  634. if (!$tblAcl) {
  635. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu (acl)" . '</div>';
  636. exit;
  637. }
  638. $tblAcl->init();
  639. $dataSource = $this->getDataSource($tblAcl);
  640. if (!$dataSource) {
  641. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak danych" . '</div>';
  642. exit;
  643. }
  644. $row = $dataSource->getItem($rowID);
  645. if (!$row) {
  646. echo "404: No item ID({$rowID})";
  647. exit;
  648. }
  649. ?>
  650. <blockquote>Rekord <strong><?php echo $row->ID; ?></strong> typu <?php echo $type; ?></blockquote>
  651. <?php
  652. foreach ($fields as $fieldName) {
  653. $fieldID = $tblAcl->getFieldIdByName($fieldName);
  654. if (!$fieldID) {
  655. if ($DBG) echo "404: No field by name ({$fieldName})";
  656. continue;
  657. }
  658. if ($DBG) echo "fieldID: {$fieldID}\n";
  659. if (!$tblAcl->isAllowed($fieldID, 'R', $row)) {
  660. if ($DBG) echo " R not allowed\n";
  661. } else {
  662. if ($DBG) echo " R allowed\n";
  663. }
  664. if (!$tblAcl->isAllowed($fieldID, 'W', $row)) {
  665. if ($DBG) echo " W not allowed\n";
  666. } else {
  667. if ($DBG) echo " W allowed\n";
  668. }
  669. $fieldVal = '';
  670. if ($tblAcl->isAllowed($fieldID, 'R', $row)) {
  671. $fieldVal = V::get($fieldName, $fieldVal, $row);
  672. }
  673. $fieldVal = V::get("f{$fieldID}", $fieldVal, $_POST);
  674. $vCol = $tblAcl->getField($fieldID);
  675. $vCol['label'] = (!empty($vCol['label']))? $vCol['label'] : $vCol['name'];
  676. $tsValues = array();
  677. Lib::loadClass('Typespecial');
  678. $typeSpecial = Typespecial::getInstance($fieldID, $vCol['name']);
  679. if ($typeSpecial) {
  680. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Typespecial('.$fieldID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($typeSpecial);echo'</pre>';}
  681. $specialValues = $typeSpecial->getEditSelectedValuesByIds($zasobID, $row->ID, $fieldName, V::get($fieldName, $fieldVal, $row));
  682. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Typespecial('.$fieldID.') specialValues (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($specialValues);echo'</pre>';}
  683. if (!empty($specialValues)) {
  684. $tsValues[$row->ID] = implode('<br>', $specialValues);
  685. }
  686. }
  687. ?>
  688. <label for="<?php echo "f{$fieldID}"; ?>" class="AjaxTableEdit-label">
  689. <strong title="<?php echo "[{$fieldID}] {$fieldName}"; ?>"><?php echo "{$vCol['label']}"; ?></strong>
  690. <?php if (!empty($vCol['opis'])) : ?>
  691. <em><?php echo $vCol['opis']; ?></em>
  692. <?php endif; ?>
  693. </label>
  694. <?php
  695. $fieldParams = array('widthClass'=>'inside-modal', 'maxGrid'=>6);
  696. if (!empty($tsValues[$row->ID])) {
  697. $fieldParams['typespecialValue'] = $tsValues[$row->ID];
  698. }
  699. $vDefault = $dataSource->getColDefault($fieldName);
  700. if (!empty($vDefault)) {
  701. $fieldParams['default'] = $vDefault;
  702. }
  703. echo $tblAcl->showFormItem('W', $fieldID, "f{$fieldID}", $fieldVal, $fieldParams, $row);
  704. }
  705. echo '<p style="padding:100px 0;"></p>';
  706. exit;
  707. }
  708. public function _getDateFltrTypes() {
  709. $fltrDate = array();
  710. $fltrDate[] = 'BRAK';
  711. $fltrDate[] = 'PO_TERMINIE';
  712. $fltrDate[] = 'DZISIAJ';
  713. $fltrDate[] = 'W_CIAGU_7_DNI';
  714. $fltrDate[] = 'PO_7_DNIACH';
  715. return $fltrDate;
  716. }
  717. public function getDateHideFltrTypes() {
  718. $fltrDate = $this->_getDateFltrTypes();
  719. foreach ($fltrDate as $i => $fltr) {
  720. $fltrDate[$i] = "fltr-hide_{$fltr}";
  721. }
  722. return $fltrDate;
  723. }
  724. public function getDateFltrTypes() {
  725. $fltrDate = $this->_getDateFltrTypes();
  726. foreach ($fltrDate as $i => $fltr) {
  727. $fltrDate[$i] = "date-{$fltr}";
  728. }
  729. return $fltrDate;
  730. }
  731. public function getTaskDateFltrType($taskDate) {
  732. $nowDay = date("Y-m-d");
  733. $nowDayPlus7 = date("Y-m-d", mktime(0,0,0, date("m"), date("d") + 7, date("Y")));
  734. $clsData = '';
  735. $appDay = substr($taskDate, 0, 10);
  736. if (empty($taskDate)) {
  737. $clsData = 'date-BRAK';
  738. } else if ($appDay < $nowDay) {
  739. $clsData = 'date-PO_TERMINIE';
  740. } else if ($appDay == $nowDay) {
  741. $clsData = 'date-DZISIAJ';
  742. } else if ($appDay > $nowDay && $appDay <= $nowDayPlus7) {
  743. $clsData = 'date-W_CIAGU_7_DNI';
  744. } else {
  745. $clsData = 'date-PO_7_DNIACH';
  746. }
  747. return $clsData;
  748. }
  749. public function sendAjaxEditAppDateInlineSave() {
  750. $DBG = ('1' == V::get('DBG', '', $_REQUEST));
  751. sleep(1);// TODO: RMME DBG loading
  752. $rowID = V::get('rowid', 0, $_POST, 'int');
  753. $type = V::get('type', '', $_POST);
  754. $fields = $this->getEditAppDateFields();
  755. if ($rowID <= 0) {
  756. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu" . '</div>';
  757. exit;
  758. }
  759. $tblAcl = $this->getTblAclByType($type);
  760. if (!$tblAcl) {
  761. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak dostępu (acl)" . '</div>';
  762. exit;
  763. }
  764. $tblAcl->init();
  765. $dataSource = $this->getDataSource($tblAcl);
  766. if (!$dataSource) {
  767. echo '<div class="alert alert-danger cls-line-' . __LINE__ . '">' . "Brak danych" . '</div>';
  768. exit;
  769. }
  770. $row = $dataSource->getItem($rowID);
  771. if (!$row) {
  772. echo "404: No item ID({$rowID})";
  773. exit;
  774. }
  775. $sqlObj = new stdClass();
  776. $allData = new stdClass();
  777. foreach ($fields as $fieldName) {
  778. $fieldID = $tblAcl->getFieldIdByName($fieldName);
  779. if (!$fieldID) {
  780. if ($DBG) echo "404: No field by name ({$fieldName})";
  781. continue;
  782. }
  783. if ($DBG) echo "fieldID: {$fieldID}\n";
  784. if (!$tblAcl->isAllowed($fieldID, 'W', $row)) {
  785. if ($DBG) echo " W not allowed\n";
  786. continue;
  787. } else {
  788. if ($DBG) echo " W allowed\n";
  789. }
  790. $fieldVal = V::get($fieldName, '', $row);
  791. $sqlObj->{$fieldName} = V::get("f{$fieldID}", $fieldVal, $_POST);
  792. if (empty($_POST["f{$fieldID}"]) && strlen($_POST["f{$fieldID}"]) == 0) {// fix bug in input type date and value="0000-00-00"
  793. $sqlObj->{$fieldName} = $tblAcl->fixEmptyValueFromUser($fieldID);
  794. }
  795. }
  796. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TODO: save type ('.$type.') ID(' . $rowid . ') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'</pre>';}
  797. $sqlObj->ID = $row->ID;
  798. $dbID = $tblAcl->getDB();
  799. $db = DB::getDB($dbID);
  800. if (!$db) {
  801. header('HTTP/1.0 406 Not Acceptable');
  802. exit;
  803. }
  804. $tblName = $tblAcl->getName();
  805. $sqlObj->ID = $rowID;
  806. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TODO: Save ('.$tblName.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'</pre>';}
  807. $allData = array();
  808. $allData['L_APPOITMENT_DATE'] = $sqlObj->L_APPOITMENT_DATE;
  809. $allData['L_APPOITMENT_USER'] = $sqlObj->L_APPOITMENT_USER;
  810. $allData['L_APPOITMENT_INFO'] = $sqlObj->L_APPOITMENT_INFO;
  811. $ret = $db->UPDATE_OBJ($tblName, $sqlObj);
  812. if ($ret > 0) {
  813. echo '<div class="alert alert-success">';
  814. echo "Rekord zapisany pomyślnie";//"Record saved successfully";
  815. echo '</div>';
  816. echo '<div class="EditAppDateInlineSave" style="display:none">';
  817. echo '<span class="l_app_date">' . $allData['L_APPOITMENT_DATE'] . '</span>';
  818. echo '<span class="l_app_user">' . $allData['L_APPOITMENT_USER'] . '</span>';
  819. echo '<span class="l_app_info">' . $allData['L_APPOITMENT_INFO'] . '</span>';
  820. echo '<span class="date_fltr_type">' . $this->getTaskDateFltrType($allData['L_APPOITMENT_DATE']) . '</span>';
  821. echo '</div>';
  822. } else if ($ret == 0) {
  823. echo '<div class="alert alert-info">';
  824. echo "Nie wprowadzono żadnych zmian";
  825. if ($db->has_errors()) {
  826. $errors = $db->get_errors();
  827. echo implode('<br>', $errors);
  828. }
  829. echo '</div>';
  830. } else {
  831. echo '<div class="alert alert-danger">';
  832. echo '<h4>' . "Wystąpiły błędy!" . '</h4>';
  833. if ($db->has_errors()) {
  834. $errors = $db->get_errors();
  835. echo implode('<br>', $errors);
  836. }
  837. echo '</div>';
  838. }
  839. exit;
  840. }
  841. }