procesy5.php 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921
  1. <?php
  2. //version 2010-06-01 - addding limits and searches
  3. //version 2010-06-13 - by plabudda login by AUTH MODULE (.config.php $AUTH_API)
  4. //version 2010-09-22 - by abinder, drobne poprawki z wyszukiwaniem i pokazywaniem tabeli
  5. //version 2010-09-30 - by abinder, drobne poprawki z wyszukiwanie w PROCESACH do edycji...
  6. //version 2011-09-12 - by pl, TODO: Obowiazki - menu
  7. require_once dirname(__FILE__) . '/se-lib/bootstrap.php';
  8. error_reporting(E_ALL & ~E_NOTICE);
  9. //session_save_path("../session") ;
  10. session_start();
  11. date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
  12. if (file_exists(".config.php")) include(".config.php");
  13. SEF('DEBUG_S');
  14. SEF('ZAP_SQL');
  15. SEF('ZAP_SQL_UPDATE');
  16. SEF('USERS_COLUMN_INIT');
  17. SEF('GETFORMITEM');
  18. SEF('T_WORKPOINTS_USER_SELECT');
  19. Lib::loadClass('App');
  20. Lib::loadClass('ProcesHelper');
  21. Lib::loadClass('Tree');
  22. Lib::loadClass('TreeHelper');
  23. Lib::loadClass('DB_Image');
  24. Lib::loadClass('TreeSortChildren');
  25. Lib::loadClass('UI');
  26. // ========== Task functions ==============
  27. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'legacy.php';
  28. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'proces.php';
  29. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'zasob.php';
  30. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'testy.php';// CRM_TESTY_WYNIKI
  31. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'proces_log.php';
  32. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'user.php';
  33. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'ext_ids.php';
  34. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'search.php';// CRM_SEARCH
  35. // TODO: if (App::is_ajax_request())
  36. require_once APP_PATH_ROOT . DS . 'procesy' . DS . 'ajax.php';
  37. require_once APP_PATH_ROOT . DS . 'se-lib' . DS . 'SE_Layout.php';// CRM_SEARCH
  38. // ========== SESSION set default session values ==============
  39. S::init();
  40. if (!isset($_SESSION['HIDE_ZASOBY'])) $_SESSION['HIDE_ZASOBY'] = true;
  41. if (!isset($_SESSION['HIDE_PROCESY'])) $_SESSION['HIDE_PROCESY'] = true;
  42. if (!isset($_SESSION['ZWIN_DRZEWO'])) $_SESSION['ZWIN_DRZEWO'] = false;
  43. if (!isset($_SESSION['TREE_OPEN_ARRAY'])) $_SESSION['TREE_OPEN_ARRAY'] = array();
  44. if (!isset($_SESSION['TREE_SHOW_P_ID2'])) $_SESSION['TREE_SHOW_P_ID2'] = false;
  45. if (!isset($_SESSION['TREE_SHOW_P_ID3'])) $_SESSION['TREE_SHOW_P_ID3'] = false;
  46. if (!isset($_SESSION['ROZWIN'])) $_SESSION['ROZWIN'] = false;
  47. if (!isset($_SESSION['ROZWIN_OPIS'])) $_SESSION['ROZWIN_OPIS'] = false;
  48. if (!isset($_SESSION['ROZWIN_ZASOBY'])) $_SESSION['ROZWIN_ZASOBY'] = false;
  49. if (!isset($_SESSION['TREE-ZASOBY'])) $_SESSION['TREE-ZASOBY'] = array();
  50. if (!isset($_SESSION['TREE-PROCESY'])) $_SESSION['TREE-PROCESY'] = array();
  51. if (!isset($_SESSION['USER_PARAMS'])) $_SESSION['USER_PARAMS'] = array();
  52. // ========== SESSION set values from request ==============
  53. if(isset($_GET['HIDE_ZASOBY']) && $_GET['HIDE_ZASOBY']) $_SESSION['HIDE_ZASOBY'] = true;
  54. if(isset($_GET['UNHIDE_ZASOBY']) && $_GET['UNHIDE_ZASOBY']) $_SESSION['HIDE_ZASOBY'] = false;
  55. if(isset($_GET['HIDE_PROCESY']) && $_GET['HIDE_PROCESY']) $_SESSION['HIDE_PROCESY'] = true;
  56. if(isset($_GET['UNHIDE_PROCESY']) && $_GET['UNHIDE_PROCESY']) $_SESSION['HIDE_PROCESY'] = false;
  57. if(isset($_GET['ZWIN_DRZEWO']) && $_GET['ZWIN_DRZEWO']) $_SESSION['ZWIN_DRZEWO'] = true;
  58. if(isset($_GET['ROZWIN_DRZEWO']) && $_GET['ROZWIN_DRZEWO']) $_SESSION['ZWIN_DRZEWO'] = false;
  59. if(isset($_GET['TREE_OPEN']) && $_GET['TREE_OPEN']) $_SESSION['TREE_OPEN_ARRAY'][$_GET['TREE_OPEN']] = true;
  60. if(isset($_GET['TREE_CLOSE']) && $_GET['TREE_CLOSE']) $_SESSION['TREE_OPEN_ARRAY'][$_GET['TREE_CLOSE']] = false;
  61. if(isset($_GET['TREE_SHOW_P_ID2']) && $_GET['TREE_SHOW_P_ID2']) $_SESSION['TREE_SHOW_P_ID2'] = true;
  62. if(isset($_GET['TREE_HIDE_P_ID2']) && $_GET['TREE_HIDE_P_ID2']) $_SESSION['TREE_SHOW_P_ID2'] = false;
  63. if(isset($_GET['TREE_SHOW_P_ID3']) && $_GET['TREE_SHOW_P_ID3']) $_SESSION['TREE_SHOW_P_ID3'] = true;
  64. if(isset($_GET['TREE_HIDE_P_ID3']) && $_GET['TREE_HIDE_P_ID3']) $_SESSION['TREE_SHOW_P_ID3'] = false;
  65. if(isset($_GET['TREE_ROZWIN']) && $_GET['TREE_ROZWIN']) $_SESSION['ROZWIN'] = true;
  66. if(isset($_GET['TREE_ZWIN']) && $_GET['TREE_ZWIN']) $_SESSION['ROZWIN'] = false;
  67. if(isset($_GET['TREE_OPISY_ROZWIN']) && $_GET['TREE_OPISY_ROZWIN']) $_SESSION['ROZWIN_OPIS'] = true;
  68. if(isset($_GET['TREE_OPISY_ZWIN']) && $_GET['TREE_OPISY_ZWIN']) $_SESSION['ROZWIN_OPIS'] = false;
  69. if(isset($_GET['TREE_ZASOBY_ROZWIN']) && $_GET['TREE_ZASOBY_ROZWIN']) $_SESSION['ROZWIN_ZASOBY'] = true;
  70. if(isset($_GET['TREE_ZASOBY_ZWIN']) && $_GET['TREE_ZASOBY_ZWIN']) $_SESSION['ROZWIN_ZASOBY'] = false;
  71. // ========== SESSION timeout ==============
  72. S::timeout_update();
  73. // ========== App state ==============
  74. App::set_default_task('CRM_PROCES');
  75. // ========== DB connection ==============
  76. //$conn = DB::connect();// TODO: needed?
  77. // ========== App auth ==============
  78. User::auth();// die if not logged in
  79. // ========== FUNCTION_INIT ==============
  80. // ?_ajax_request=FUNCTION
  81. // TODO: if (App::is_ajax_request())
  82. App::exec_ajax_request();
  83. // ?function_init=FUNCTION
  84. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">';var_dump( headers_sent() );echo'</pre>';
  85. App::exec_function_init();
  86. // column init
  87. Lib::loadClass('Column');
  88. Column::init('CRM_PROCES');
  89. Column::init('CRM_LISTA_ZASOBOW');
  90. //Column::init('CRM_TESTY');
  91. /**
  92. * Perm/access function.
  93. *
  94. * admin - kierownik, $_SESSION['ADM_ADMIN_LEVEL'] in (0,1)
  95. */
  96. function User_is_admin() {
  97. return User::hasAccess('procesy_admin');
  98. }
  99. function User_procesy5_check_access() {
  100. if (!User::hasAccess('procesy')) {
  101. ?>
  102. <div class="container">
  103. <div class="alert alert-danger">
  104. Brak dostępu!
  105. </div>
  106. </div>
  107. <br>.
  108. <?php
  109. lay_procesy_dol();
  110. die();
  111. }
  112. }
  113. function lay_procesy_gora() {
  114. $title = SE_Layout::getTitle().' procesy';
  115. if (($id_proces = V::get('id_proces', 0, $_GET, 'int')) > 0) {
  116. $title = "Proces {{$id_proces}}";
  117. }
  118. ?><!DOCTYPE html>
  119. <html>
  120. <head>
  121. <meta charset="utf-8" />
  122. <title><?php echo $title; ?></title>
  123. <link rel="shortcut icon" type="image/x-icon" href="./favicon.png?v=0.1">
  124. <meta name="author" content="Piotr Labudda <piotrl86@gmail.com>" />
  125. <link rel="stylesheet" href="stuff/bootstrap/css/bootstrap.min.css" type="text/css" />
  126. <link rel="stylesheet" href="stuff/jquery-ui-smoothness/jquery-ui-1.10.4.custom.min.css" type="text/css">
  127. <link rel="stylesheet" href="stuff/main.css" type="text/css" />
  128. <style type="text/css">
  129. body { <?php echo UI::fixFooterPosition('body_style'); ?> }
  130. </style>
  131. <style type="text/css">
  132. .popover-with-html .popover-heading {display:none;}
  133. .popover-with-html .popover-body {display:none;}
  134. </style>
  135. <script src="stuff/jquery-2.1.0.min.js"></script>
  136. <script src="stuff/jquery-plugins.js"></script>
  137. <script src="stuff/bootstrap/js/bootstrap.min.js"></script>
  138. <script src="stuff/jquery-ui-1.10.4.custom.min.js"></script>
  139. <script>
  140. jQuery(document).ready(function(){
  141. jQuery(".popover-with-html").popover({
  142. html: true,
  143. trigger: 'hover',
  144. animation: false,
  145. container: 'body',
  146. placement: 'top',
  147. content: function() {
  148. return jQuery(this).children(".popover-body").html();
  149. },
  150. title: function() {
  151. return jQuery(this).children(".popover-heading").html();
  152. }
  153. });
  154. });
  155. </script>
  156. <link rel="stylesheet" href="stuff/jquery.selectize/css/selectize.bootstrap3.css" type="text/css" />
  157. <script src="stuff/jquery.selectize/js/standalone/selectize.min.js"></script>
  158. <style type="text/css">
  159. .typepsecial .selectize-input { width:366px; padding:4px 6px; }
  160. .typepsecial .selectize-control::before {
  161. -moz-transition: opacity 0.2s;
  162. -webkit-transition: opacity 0.2s;
  163. transition: opacity 0.2s;
  164. content: ' ';
  165. z-index: 2;
  166. position: absolute;
  167. display: block;
  168. top: 12px;
  169. right: 34px;
  170. width: 16px;
  171. height: 16px;
  172. background: url(stuff/i/loading.gif);
  173. background-size: 16px 16px;
  174. opacity: 0;
  175. }
  176. .typepsecial .selectize-control.loading::before {
  177. opacity: 0.4;
  178. }
  179. .typepsecial .selectize-control.single .selectize-input {
  180. color: #333;
  181. text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
  182. background-color: #fff;
  183. background-image: none;
  184. background-repeat: none;
  185. border-color: #ccc;
  186. filter: none;
  187. -webkit-box-shadow: none;
  188. -moz-box-shadow: none;
  189. box-shadow: none;
  190. }
  191. </style>
  192. <?php
  193. lay_procesy_css();
  194. App::show_head_css();
  195. App::show_head_js();
  196. S::timeout_update_js();
  197. echo'</head>'."\n";
  198. echo'<body>'."\n";
  199. }
  200. if ('YES' != V::get('HEADER_NOT_INIT', '', $_REQUEST))
  201. lay_procesy_gora();
  202. function ECHOO($VAR) {
  203. echo "$VAR";
  204. }
  205. //INICJALIZACJA_KOLUMN
  206. if (!isset($_SESSION['CRM_LISTA_ZASOBOW_COLUMN'])) {
  207. $COLUMN="CRM_LISTA_ZASOBOW";
  208. $res = DB::query("show fields from $COLUMN");
  209. $KEY=0;
  210. while ($h = DB::fetch_row( $res )) {
  211. $_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"] = $h[0];
  212. $_SESSION[$COLUMN."_COLUMN"]['TYPE'][$_SESSION[$COLUMN."_COLUMN"]['DESC']["$KEY"]] = $h[1];
  213. if(!isset($_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]])) $_SESSION[$COLUMN."_COLUMN"]['PERMEDIT'][$h[0]] = "RW" ;
  214. $_SESSION[$COLUMN."_COLUMN"]['DESC_TO_KEY'][$h[0]] = $KEY;
  215. $_SESSION[$COLUMN."_COLUMN"]['ID']["$KEY"]=$KEY;
  216. if($_SESSION['USER_PROFILE'][$COLUMN."_COLUMN"]["$KEY"] == "HIDE") {
  217. $_SESSION[$COLUMN."_COLUMN"]['HIDE']["$KEY"]='HIDE';
  218. }
  219. $KEY++;
  220. }
  221. // echo "<br>Zainicjalizowano kolumne $COLUMN<br>";
  222. }
  223. //EOF INICJALIZACJA KOLUMN
  224. // ========== MENU ==============
  225. lay_procesy_user_panel();
  226. // ========== TASK ==============
  227. App::exec_task();
  228. // ========== function_init - funkcje ==============
  229. function SESSION_DEBUG() {
  230. if (isset($_GET['arg1_val'])) {
  231. $_SESSION['DEBUG'] = intval($_GET['arg1_val']);
  232. }
  233. }
  234. function SESSION_USER_PARAMS() {
  235. $allowed_user_params = array();
  236. $allowed_user_params['SHOW_PANEL']= 'int';
  237. $allowed_user_params['PROCESY_TREE_TYPE_HTML']= 'int';
  238. $allowed_user_params['ZASOBY_TREE_TYPE_HTML']= 'int';
  239. if (!isset($_GET['arg1']) || !isset($_GET['arg1_val'])) {
  240. return;
  241. } else if (array_key_exists($_GET['arg1'], $allowed_user_params)) {
  242. $_SESSION['USER_PARAMS'][ $_GET['arg1'] ] = intval($_GET['arg1_val']);
  243. }
  244. }
  245. function SORT_PRIO_ZASOB() {
  246. $id = V::get('arg1', '', $_GET, 'int');
  247. $sort_prio_dir = V::get('arg1_val', '', $_GET);
  248. TreeSortChildren::sortPrio($id, 'CRM_LISTA_ZASOBOW', 'PARENT_ID', $sort_prio_dir);
  249. }
  250. function SORT_PRIO_WSKAZNIK() {
  251. $id = V::get('arg1', '', $_GET, 'int');
  252. $sort_prio_dir = V::get('arg1_val', '', $_GET);
  253. TreeSortChildren::sortPrio($id, 'CRM_WSKAZNIK', 'ID_PROCES', $sort_prio_dir);
  254. }
  255. function SORT_PRIO_PROCES() {
  256. $id = V::get('arg1', '', $_GET, 'int');
  257. //$_GET['arg1_val'] = ($_GET['arg1_val'] == 'up')? 'dw' : 'up';// procesy w odwrotnej kolejnosci, w SQL order by SORT_PRIO DESC
  258. $sort_prio_dir = V::get('arg1_val', '', $_GET);
  259. TreeSortChildren::sortPrio($id, 'CRM_PROCES', 'PARENT_ID', $sort_prio_dir);
  260. }
  261. // ========== TASK - funkcje ==============
  262. function task_CRM_ADD_CRM_WSKAZNIK() {
  263. User_procesy5_check_access();
  264. // submit form - add wskaznik
  265. if (V::get('ADD_ID_CRM_PRZYPADEK', '', $_POST)) {
  266. $sql_obj = new stdClass();
  267. $sql_obj->ID_PROCES = V::get('ADD_ID_PROCES', '', $_POST);
  268. $sql_obj->ID_ZASOB = V::get('ADD_ID_ZASOB', '', $_POST);
  269. $sql_obj->TYP = V::get('ADD_CRM_WSKAZNIK_TYP', '', $_POST);
  270. $sql_obj->ID_PRZYPADEK = V::get('ADD_ID_CRM_PRZYPADEK', '', $_POST);
  271. $sql_obj->OPIS_ZASOB = V::get('ADD_CRM_WSKAZNIK_OPIS_ZASOB', '', $_POST);
  272. $sql_obj->SORT_PRIO = 0;
  273. // nowy wskaznik na koniec listy pod procesem
  274. $sql = "select max(cw.`SORT_PRIO`) as MAX_SORT_PRIO
  275. from `CRM_WSKAZNIK` as cw
  276. where
  277. cw.`ID_PROCES`='".$sql_obj->ID_PROCES."'
  278. ";
  279. $res = DB::query( $sql );
  280. while ($r = DB::fetch( $res )) {
  281. $sql_obj->SORT_PRIO = $r->MAX_SORT_PRIO + 1;
  282. }
  283. //TODO: POST_VERIFY
  284. $new_id = DB::ADD_NEW_OBJ('CRM_WSKAZNIK', $sql_obj);
  285. if (V::get('DEBUG', '', $_SESSION)) echo"PASSED(1) NEW RECORD ID($new_id)<hr>";
  286. if ($new_id > 0) {
  287. echo '<p class="sql-msg box box-green">'."Dodano nowy rekord";
  288. } else {
  289. echo '<p class="sql-msg box box-red">'."Error przy dodawaniu rekordu";
  290. }
  291. echo'<br />'."Wroc do ".App::link("procesow", "?task=CRM_PROCES");
  292. echo'<br />'."lub ".App::link("dodaj kolejny zasob do procesu ".$sql_obj->ID_PROCES, "?task=ADD_PROCES_ID&id=".$sql_obj->ID_PROCES);
  293. echo'</p>';// .box
  294. }
  295. // show form - add wskaznik
  296. if (V::get('ADD_ID_ZASOB', '', $_GET)) {
  297. $id_proces = V::get('ADD_ID_PROCES', 0, $_REQUEST, 'int');
  298. $id_zasob = V::get('ADD_ID_ZASOB', 0, $_REQUEST, 'int');
  299. if ($id_proces <= 0) {
  300. echo'<p class="err">'."Wrong id!".'</p>';
  301. return;
  302. }
  303. if ($id_zasob <= 0) {
  304. echo'<p class="err">'."Wrong zasob id!".'</p>';
  305. return;
  306. }
  307. $proces = DB::get_by_id( 'CRM_PROCES', $id_proces );
  308. if (!$proces) {
  309. echo'<div class="box box-red">';
  310. echo "Proces [".$id_proces."] not exists.";
  311. echo'</div>';
  312. return;
  313. }
  314. $zasob = DB::get_by_id( 'CRM_LISTA_ZASOBOW', $id_zasob );
  315. if (!$zasob) {
  316. echo'<div class="box box-red">';
  317. echo "Proces [".$id_zasob."] not exists.";
  318. echo'</div>';
  319. return;
  320. }
  321. {// pathway
  322. echo'<h1>';
  323. echo App::link("Procesy", array('task'=>"CRM_PROCES"));
  324. if ($id_proces > 0) {
  325. echo ' &raquo; '.App::link("Dodaj zasob do procesu [".$id_proces."]", array('task'=>'ADD_PROCES_ID', 'id'=>$id_proces));
  326. if ($id_zasob > 0) {
  327. echo ' &raquo; '.App::link("Dodaj zasob [".$id_zasob."]", array('task'=>'CRM_ADD_CRM_WSKAZNIK', 'ADD_ID_PROCES'=>$id_proces, 'ADD_ID_ZASOB'=>$id_zasob));
  328. }
  329. }
  330. echo'</h1>';
  331. }// pathway
  332. Lib::loadClass('ProcesHelper');
  333. {// proces info
  334. $wsk = ProcesHelper::get_wskazniki( $proces->ID );
  335. echo'<div class="tree-wrap">';
  336. echo'<ul>';
  337. echo'<li class="tree-last">';
  338. echo'<dl>';
  339. echo'<dt>';
  340. if (!empty($wsk)) echo'<div class="has_wsk">';
  341. echo'<b class="item_id btn-box">'.$proces->ID.'</b>';
  342. echo'<span class="desc"><b>'.$proces->DESC.'</b>';
  343. echo'<span class="more-desc"> '.$proces->OPIS.' </span>';
  344. echo'</span>';
  345. if (!empty($wsk)) echo'</div>';
  346. echo'</dt>';
  347. if (!empty($wsk)) {
  348. $zasoby_id = array();
  349. echo'<dd>';
  350. echo'<ul>';
  351. $wsk_cnt = count( $wsk );
  352. foreach ($wsk as $w) {
  353. $w_parents_out = '';
  354. $w_title_parents_out = '';
  355. echo'<li'.((--$wsk_cnt)? '' : ' class="tree-last"').'>';
  356. echo'<p>';
  357. echo ' <span class="btn-box btn-box-silver">'.$w->CW_ID.'</span>';
  358. echo'<span class="green"'.$w_title_parents_out.'>['.$w->ID.']</span>';
  359. echo' <i title="'.$w->CP_PYTANIE.' '.$w->CP_OPIS.'">'.$w->CP_FORM_TREAT.'</i>';
  360. echo'';
  361. echo ' '.$w->TYPE.'';
  362. echo ' <b>'.$w->DESC.'</b> ';
  363. //if ($tree->get_param('rozwin_opis'))
  364. echo ' <span class="green">'.$w->OPIS.'</span>';// opis zasobu
  365. //if ($tree->get_param('rozwin_opis'))
  366. echo ' <span style="color:#000;">'.$w->OPIS_ZASOB.'</span>';// komentarz wskaznika
  367. echo'</p>';
  368. echo'</li>';
  369. }
  370. echo'</ul>';
  371. }
  372. echo'</dl>';
  373. echo'</li>';
  374. echo'</ul>';
  375. echo'</div>';// .tree-wrap
  376. }// proces info
  377. // echo '<h3>Wybierz okolicznosci procesu <b style="color:red">'.V::get('ADD_ID_PROCES', '', $_GET).'</b> do zasobu <b style="color:green">'.V::get('ADD_ID_ZASOB', '', $_GET).'</b></h3>';
  378. echo'<h3>'."Wybierz okolicznosci powiazania zasobu ".'<b style="color:green">'.$zasob->ID.'</b>'." do procesu ".'<b style="color:red">'.$proces->ID.'</b>'.'</h3>';
  379. echo'<div class="tree-wrap">';
  380. echo'<p> <span class="btn-box btn-box-silver"></span>';
  381. echo' <span class="green">['.$zasob->ID.']</span>';
  382. echo' '.$zasob->TYPE.' <b>'.$zasob->DESC.'</b> <span class="green">'.$zasob->OPIS.'</span>';
  383. echo'</p>';
  384. echo'</div>';
  385. $ZAP_SQL = "select * from CRM_PRZYPADEK ";
  386. $res = DB::query( $ZAP_SQL );
  387. echo'<form action="'."?task=CRM_ADD_CRM_WSKAZNIK&ADD_ID_ZASOB=".$_GET['ADD_ID_ZASOB']."&ADD_ID_PROCES=".$_GET['ADD_ID_PROCES'].'" method="POST">';
  388. echo'<input type="hidden" name="ADD_ID_ZASOB" value="'.V::get('ADD_ID_ZASOB', '', $_GET).'">';
  389. echo'<input type="hidden" name="ADD_ID_PROCES" value="'.V::get('ADD_ID_PROCES', '', $_GET).'">';
  390. echo'Rodzaj : <select name="ADD_CRM_WSKAZNIK_TYP"><option value="R">RZECZOWNIK</option><option value="C">CZASOWNIK</option></select><br>Przypadki rzeczownika:';
  391. echo'<select name="ADD_ID_CRM_PRZYPADEK">';
  392. while ($DWA = DB::fetch( $res )) {
  393. echo'<option value="'.$DWA->ID.'">'.$DWA->FORM_TREAT.' | '.$DWA->NAZWA.' | '.$DWA->PYTANIE.' | '.$DWA->OPIS.'</option>'."\n";
  394. }
  395. echo'</select>';
  396. //echo'<br />Komentarz: <input type="text" name="ADD_CRM_WSKAZNIK_OPIS_ZASOB" value="'.$_GET['ADD_CRM_WSKAZNIK_OPIS_ZASOB'].'" size=50>';
  397. echo'<br />Komentarz:';
  398. echo'<br /><textarea name="ADD_CRM_WSKAZNIK_OPIS_ZASOB" cols="80" rows="6">'.V::get('ADD_CRM_WSKAZNIK_OPIS_ZASOB', '', $_GET).'</textarea>';
  399. echo'<br><input type="SUBMIT" value="DODAJ"></form>';
  400. echo'<hr>';
  401. }
  402. }
  403. /**
  404. * @param $_GET['ID'] - ID rekordu do edycji
  405. */
  406. function task_CRM_EDIT_CRM_WSKAZNIK() {
  407. global $error;
  408. User_procesy5_check_access();
  409. $id = V::get('ID', '', $_GET, 'int');
  410. if ($id <= 0) {
  411. echo'<p class="err">'."Wrong ID".'</p>';
  412. return;
  413. }
  414. $R = null;
  415. $sql = "select * from `CRM_WSKAZNIK` where `ID`='".$id."' limit 1; ";// TODO: use DB::get_by_id
  416. $res = DB::query($sql);
  417. if (!$res) die("sql query error $sql");
  418. $R = DB::fetch($res);
  419. if (!$R) {
  420. echo'<p class="err">'."Wrong ID - not exists".'</p>';
  421. return;
  422. }
  423. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">';print_r($R);echo'</pre>';
  424. // form submit
  425. if (V::get('EDIT_SUBMIT', '', $_POST)) {
  426. $sql_obj = new stdClass();
  427. $sql_obj->ID = $R->ID;
  428. //$sql_obj->PARENT_ID = V::get('EDIT_PARENT_ID', '', $_POST);
  429. $sql_obj->TYP = V::get('EDIT_TYP', '', $_POST);
  430. $sql_obj->ID_PRZYPADEK = V::get('EDIT_ID_PRZYPADEK', '', $_POST);
  431. $sql_obj->OPIS_ZASOB = V::get('EDIT_OPIS_ZASOB', '', $_POST);
  432. $sql_obj->ID_PROCES = V::get('EDIT_ID_PROCES', '', $_POST, 'int');
  433. $sql_obj->ID_ZASOB = V::get('EDIT_ID_ZASOB', '', $_POST, 'int');
  434. $sql_obj->PARENT_ID = V::get('PARENT_ID', '', $_POST);//todo trzeba sprawdzic czy jest taki wskaznik uzyty w tym procesie
  435. $sql_obj->EXPORT_WSKAZNIK = V::get('EXPORT_WSKAZNIK', '', $_POST, 'int');//todo musi byc weryfikacja czy jest taki wskaznik w odwolujacej sie funkcji
  436. //TODO: POST_VERIFY
  437. $affected = DB::UPDATE_OBJ( 'CRM_WSKAZNIK', $sql_obj );
  438. if (V::get('DEBUG', '', $_SESSION)) echo"PASSED($affected)<hr>";
  439. if ($affected == 2) {
  440. echo '<p class="green box box-green">'."Zmienio rekord";
  441. } else if ($affected == 1) {
  442. echo '<p class="err box box-red">'."Zmieniono rekord (Error: nie zapisano hostorii)";
  443. } else if ($affected < 0) {
  444. echo '<p class="err box box-red">'."Blad podczas edytowania rekordu - nic nie zmieniono";
  445. }
  446. echo'<br />'."Wroc do ".App::link("procesow", "?task=CRM_PROCES");
  447. echo'</p>';// .box
  448. }
  449. // show form - edit wskaznik
  450. if (V::get('EDIT', '', $_GET)) {
  451. // overwrite data from POST
  452. if ($_POST) {
  453. if (isset($_POST['EDIT_ID_PROCES'])) $R->ID_PROCES = $_POST['EDIT_ID_PROCES'];
  454. if (isset($_POST['EDIT_ID_ZASOB'])) $R->ID_ZASOB = $_POST['EDIT_ID_ZASOB'];
  455. if (isset($_POST['EDIT_TYP'])) $R->TYP = $_POST['EDIT_TYP'];
  456. if (isset($_POST['EDIT_ID_PRZYPADEK'])) $R->ID_PRZYPADEK = $_POST['EDIT_ID_PRZYPADEK'];
  457. if (isset($_POST['EDIT_OPIS_ZASOB'])) $R->OPIS_ZASOB = $_POST['EDIT_OPIS_ZASOB'];
  458. if (isset($_POST['PARENT_ID'])) $R->PARENT_ID = $_POST['PARENT_ID'];
  459. if (isset($_POST['EXPORT_WSKAZNIK'])) $R->EXPORT_WSKAZNIK = $_POST['EXPORT_WSKAZNIK'];
  460. }
  461. echo '<h3>Edytuj wskaznik procesu <b style="color:red">'.$R->ID_PROCES.'</b> do zasobu <b style="color:green">'.$R->ID_ZASOB.'</b></h3>';
  462. $frm_edit_action = "?task=CRM_EDIT_CRM_WSKAZNIK&EDIT=".$R->ID."&ID=".$R->ID;
  463. echo "<h6>Dane bieżącego rekordu: Stworzono: {$R->A_RECORD_CREATE_DATE}, Stworzył: {$R->A_RECORD_CREATE_AUTHOR} , Aktualizował: {$R->A_RECORD_UPDATE_DATE}, data:{$R->A_RECORD_UPDATE_DATE} </h6>";
  464. echo '<form action="'.$frm_edit_action.'" method="POST">';
  465. echo'<input type="hidden" name="EDIT_SUBMIT" value="1">';
  466. echo '<br />'."Proces ID: ";
  467. echo'<input type="text" name="EDIT_ID_PROCES" value="'.$R->ID_PROCES.'">';
  468. echo '<br />'."Zasob ID: ";
  469. echo'<input type="text" name="EDIT_ID_ZASOB" value="'.$R->ID_ZASOB.'">';
  470. // TODO: rodzaj array selected - typespecial
  471. echo'<br />'."Rodzaj: ";
  472. echo'<select name="EDIT_TYP"><option value="R">RZECZOWNIK</option><option value="C">CZASOWNIK</option></select>';
  473. echo'<br>Przypadki rzeczownika:';
  474. echo'<select name="EDIT_ID_PRZYPADEK">';
  475. $ZAP_SQL = "select * from CRM_PRZYPADEK ";
  476. $res = DB::query( $ZAP_SQL );
  477. while ($DWA = DB::fetch( $res )) {
  478. $sel = ($R->ID_PRZYPADEK == $DWA->ID)? ' selected="selected"' : '';
  479. echo'<option value="'.$DWA->ID.'"'.$sel.'>'.$DWA->FORM_TREAT.' | '.$DWA->NAZWA.' | '.$DWA->PYTANIE.' | '.$DWA->OPIS.'</option>'."\n";
  480. }
  481. echo'</select>';
  482. //echo'<br />Komentarz: <input type="text" name="EDIT_OPIS_ZASOB" value="'.$R->OPIS_ZASOB.'" size=50>';
  483. echo'<br />Komentarz:';
  484. echo'<br /><textarea name="EDIT_OPIS_ZASOB" cols="80" rows="6">'.$R->OPIS_ZASOB.'</textarea>';
  485. echo'<br><input type="SUBMIT" value="'."ZAPISZ".'">';
  486. echo'</form>';
  487. echo'<hr>';
  488. }
  489. }
  490. function task_CRM_DEL_CRM_WSKAZNIK() {
  491. User_procesy5_check_access();
  492. $sql_obj = new stdClass();
  493. $sql_obj->ID = V::get('ID', '', $_GET, 'int');
  494. $sql_obj->A_STATUS = 'DELETED';
  495. //TODO: POST_VERIFY
  496. if ($sql_obj->ID <= 0) {
  497. echo'<p class="err">'."Wrong ID".'</p>';
  498. return;
  499. }
  500. $db = DB::getDB();
  501. $affected = $db->UPDATE_OBJ('CRM_WSKAZNIK', $sql_obj);
  502. if ($affected == 2) {
  503. echo '<p class="green box box-green">'."Usunieto wskaznik";
  504. } else if ($affected == 1) {
  505. echo '<p class="err box box-red">'."Usunieto wskaznik (Error: nie zapisano hostorii)";
  506. } else if ($affected < 0) {
  507. if ($db->has_errors()) {
  508. try {
  509. $dsErrors = array();
  510. $errorsSql = $db->get_errors();
  511. foreach ($errorsSql as $vErr) {
  512. if ('SQL QUERY FAILED: ' == substr($vErr, 0, 18)) {
  513. $vErr = substr($vErr, 18);
  514. }
  515. $dsErrors[] = $vErr;
  516. }
  517. if (!empty($dsErrors)) {
  518. Lib::loadClass('StorageException');
  519. throw new StorageException($dsErrors);
  520. }
  521. } catch (Exception $e) {
  522. ?><div class="alert alert-danger">
  523. Wystąpiły błędy: <?php echo $e->getMessage(); ?>
  524. </div><?php
  525. }
  526. } else {
  527. echo '<p class="err box box-red">'."Blad podczas usuwaniu wskaznika - nic nie zmieniono";
  528. }
  529. }
  530. echo'<br />'."Wroc do ".App::link("procesow", "?task=CRM_PROCES");
  531. echo'</p>';// .box
  532. }
  533. /**
  534. * @param $tree_callback - tree item show function callback
  535. * @param $tree_params - array of tree params
  536. */
  537. function action_VIEW_SUBTREE( $tbl, $proces_id, $tree_callback, $tree_params ) {
  538. $tree = new Tree( $tbl );
  539. $tree->set_param('show_item_callback', $tree_callback);
  540. foreach ($tree_params as $key => $val) {
  541. $tree->set_param($key, $val);
  542. }
  543. $tree->showSubTree( $proces_id );
  544. }
  545. function task_VIEW_PROCES_MAP() {
  546. User_procesy5_check_access();
  547. $procesMap = new stdClass();
  548. $procesMap->procesInitAll = array();
  549. $procesMap->gotoAll = array();
  550. $procesMap->treeFlat = array();
  551. $db = DB::getDB();
  552. $sql = "select p.`ID`, p.`PARENT_ID`
  553. -- , p.`OPIS`
  554. , p.`TYPE`, p.`IF_TRUE_GOTO`, p.`IF_TRUE_GOTO_FLAG`
  555. from `CRM_PROCES` as p
  556. where
  557. p.`A_STATUS` in('WAITING', 'NORMAL')
  558. -- and (p.`TYPE`='PROCES_INIT' or p.`IF_TRUE_GOTO`>0)
  559. ";
  560. $res = $db->query($sql);
  561. while ($r = $db->fetch($res)) {
  562. if ($r->IF_TRUE_GOTO > 0) {
  563. $procesMap->gotoAll[$r->ID] = $r;
  564. }
  565. if ($r->TYPE == 'PROCES_INIT') {
  566. $procesMap->procesInitAll[$r->ID] = $r;
  567. }
  568. $procesMap->treeFlat[$r->PARENT_ID][] = $r->ID;
  569. }
  570. // validate goto - goto only to PROCES_INIT
  571. $procesMap->gotoErrors = array();
  572. foreach ($procesMap->gotoAll as $kId => $vStep) {
  573. if (!array_key_exists($vStep->IF_TRUE_GOTO, $procesMap->procesInitAll)) {
  574. $procesMap->gotoErrors[$kId] = $vStep;
  575. }
  576. }
  577. foreach ($procesMap->gotoErrors as $kId => $vStep) {
  578. unset($procesMap->gotoAll[$kId]);
  579. }
  580. foreach ($procesMap->procesInitAll as $kId => $vProces) {
  581. $vProces->gotoLinks = array();
  582. $vProces->sub = array();
  583. if (array_key_exists($kId, $procesMap->treeFlat)) {
  584. foreach ($procesMap->treeFlat[$kId] as $childId) {
  585. $vProces->sub[$childId] = true;
  586. }
  587. }
  588. //$procesMap->procesInitAll[$kId] = $vProces;
  589. }
  590. if(V::get('DBG', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">procesMap (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($procesMap);echo'</pre>';}
  591. $loopLimit = 50;// max ilość zagłębień w procesie
  592. for ($i = 0; $i < $loopLimit; $i++) {
  593. $breakLoop = true;
  594. foreach ($procesMap->procesInitAll as $kId => $vProces) {
  595. if (!empty($vProces->sub)) {
  596. $breakLoop = false;
  597. $childrens = array_keys($vProces->sub);
  598. $vProces->sub = array();
  599. foreach ($childrens as $childId) {
  600. if (array_key_exists($childId, $procesMap->treeFlat)) {
  601. foreach ($procesMap->treeFlat[$childId] as $vId) {
  602. $vProces->sub[$vId] = true;
  603. }
  604. }
  605. if (array_key_exists($childId, $procesMap->gotoAll)) {
  606. $gotoId = $procesMap->gotoAll[$childId]->IF_TRUE_GOTO;
  607. $vProces->gotoLinks[$gotoId] = $procesMap->procesInitAll[$gotoId];
  608. $procesMap->gotoFrom[$gotoId][$vProces->ID] = $vProces->ID;
  609. }
  610. }
  611. }
  612. }
  613. if ($breakLoop) {
  614. if(V::get('DBG', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">breakLoop (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("end by {$i} loops");echo'</pre>';}
  615. break;
  616. }
  617. }
  618. // fetch DESC i OPIS laters
  619. $sqlIds = array_keys($procesMap->procesInitAll);
  620. if (!empty($sqlIds)) {
  621. $sqlIds = implode(",", $sqlIds);
  622. $sql = "select p.`ID`, p.`DESC`, p.`OPIS`
  623. from `CRM_PROCES` as p
  624. where
  625. p.`A_STATUS` in('WAITING', 'NORMAL')
  626. and p.`ID` in({$sqlIds})
  627. ";
  628. $res = $db->query($sql);
  629. while ($r = $db->fetch($res)) {
  630. $procesMap->procesInitAll[$r->ID]->DESC = $r->DESC;
  631. $procesMap->procesInitAll[$r->ID]->OPIS = $r->OPIS;
  632. }
  633. }
  634. if(V::get('DBG', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">procesMap (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($procesMap);echo'</pre>';}
  635. ?>
  636. <style type="text/css">
  637. .procesMapItem { padding:20px 6px; border-bottom:1px solid #eee; color:rgba(51, 51, 51, 0.6); }
  638. .procesMapItem:hover { color:#333; }
  639. .procesMapItem li { width:100%; overflow:hidden; clear:left; text-align:left; text-overflow:ellipsis; white-space:nowrap; }
  640. @media print {
  641. .procesMapItem { color:rgb(51, 51, 51); }
  642. }
  643. </style>
  644. <div class="container">
  645. <?php if (!empty($procesMap->gotoErrors) && !V::get('HIDE_PANEL', 0, $_GET, 'int')) : ?>
  646. <div class="alert alert-danger">
  647. <button type="button" class="close" data-dismiss="alert">×</button>
  648. <strong>Uwaga błędy w GOTO!</strong> GOTO może wywołać jedynie PROCES_INIT. <?php echo count($procesMap->gotoErrors); ?> błędów.
  649. <ul>
  650. <?php foreach ($procesMap->gotoErrors as $vStep) : ?>
  651. <li>Krok <?php echo $vStep->ID; ?> <?php echo $vStep->IF_TRUE_GOTO_FLAG; ?> {<?php echo $vStep->IF_TRUE_GOTO; ?>}</li>
  652. <?php endforeach; ?>
  653. </ul>
  654. </div>
  655. <?php endif; ?>
  656. <h1>Mapa procesów
  657. <?php
  658. if (!V::get('HIDE_PANEL', 0, $_GET, 'int')) {
  659. echo App::link("drukuj", array('task'=>'VIEW_PROCES_MAP', 'HIDE_PANEL'=>1), array('target'=>'_blank', 'ico_after_text'=>'print', 'style'=>'font-size:small;'));
  660. }
  661. ?>
  662. </h1>
  663. <?php foreach ($procesMap->procesInitAll as $kId => $vProces) : ?>
  664. <div class="procesMapItem">
  665. <h4 id="procesMapId-<?php echo $vProces->ID; ?>">{<?php echo $vProces->ID; ?>} <?php echo $vProces->DESC; ?></h4>
  666. <p><?php echo strip_tags($vProces->OPIS); ?></p>
  667. <?php if ($vProces->gotoLinks) : ?>
  668. <dl>
  669. <dt>Może wywołać:</dt>
  670. <dd>
  671. <ul>
  672. <?php foreach ($vProces->gotoLinks as $kGotoProcesId => $gotoProces) : ?>
  673. <li><a href="#procesMapId-<?php echo $gotoProces->ID; ?>">{<?php echo $gotoProces->ID; ?>}</a> <?php echo $gotoProces->DESC; ?></li>
  674. <?php endforeach; ?>
  675. </ul>
  676. </dd>
  677. </dl>
  678. <?php endif; ?>
  679. <?php if (!empty($procesMap->gotoFrom[$vProces->ID])) : ?>
  680. <dl>
  681. <dt>Może zostać wywołany przez:</dt>
  682. <dd>
  683. <ul>
  684. <?php foreach ($procesMap->gotoFrom[$vProces->ID] as $kGotoProcesId) : $gotoProces = $procesMap->procesInitAll[$kGotoProcesId]; ?>
  685. <li><a href="#procesMapId-<?php echo $gotoProces->ID; ?>">{<?php echo $gotoProces->ID; ?>}</a> <?php echo $gotoProces->DESC; ?></li>
  686. <?php endforeach; ?>
  687. </ul>
  688. </dd>
  689. </dl>
  690. <?php endif; ?>
  691. </div>
  692. <?php endforeach; ?>
  693. </div>
  694. <?php
  695. if (V::get('HIDE_PANEL', 0, $_GET, 'int') == 1) {
  696. ?>
  697. <script>jQuery(document).ready(function(){
  698. window.print();
  699. });
  700. </script>
  701. <?php
  702. }
  703. }
  704. function task_PROCES_VIEW_LIST() {
  705. $tbl = 'CRM_PROCES';
  706. $id_proces = V::get('id_proces', '', $_REQUEST, 'int');
  707. if ($id_proces <= 0) {
  708. echo '<div class="alert alert-danger">' . "Wrong ID" . '</div>';
  709. return;
  710. }
  711. $p = DB::get_by_id('CRM_PROCES', $id_proces);
  712. if (!$p) {
  713. echo '<div class="alert alert-danger">' . "Proces {$id_proces} nie istnieje" . '</div>';
  714. return;
  715. }
  716. $userAcl = User::getAcl();
  717. if (!$userAcl->canViewProces($id_proces)) {
  718. echo '<div class="alert alert-danger">' . "Brak uprawnień do procesu" . '</div>';
  719. return;
  720. }
  721. if (!V::get('HIDE_PANEL', 0, $_GET, 'int')) {
  722. // pathway
  723. echo'<h1>'.App::link("Menu", "?task=CRM_MENU");
  724. echo' - ';
  725. echo "Przegladaj proces <b>".$id_proces."</b>";
  726. echo ' ';
  727. echo App::link("drukuj", array('task'=>'PROCES_VIEW_LIST', 'id_proces'=>$id_proces, 'HIDE_PANEL'=>1), array('target'=>'_blank', 'ico_after_text'=>'print', 'style'=>'font-size:small;'));
  728. echo'</h1>';
  729. }
  730. Lib::loadClass('TreeList');
  731. $treeList = new TreeList('CRM_PROCES', $id_proces, 'PARENT_ID');
  732. $treeList->fetchTreeFlat();
  733. $listFlat = $treeList->generateListFlat();
  734. $treeList->fetchData();
  735. $ids = $treeList->getListIds();
  736. $wskazniki = ProcesHelper::getWskaznikiByIds($ids, array('group_stanowiska' => 1));
  737. if(V::get('DBG_TF', '', $_GET) > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$wskazniki (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($wskazniki);echo'</pre>';}
  738. $gotoLinks = array();
  739. $gotoIds = array();
  740. foreach ($listFlat as $vItem) {
  741. $item = $treeList->getData($vItem->ID);
  742. if ($item->IF_TRUE_GOTO > 0) {
  743. $gotoIds[] = $item->IF_TRUE_GOTO;
  744. }
  745. }
  746. if (!empty($gotoIds)) {
  747. $db = DB::getDB();
  748. $sqlIds = implode(",", $gotoIds);
  749. $sql = "select p.`ID`, p.`DESC`, p.`OPIS`
  750. from `CRM_PROCES` as p
  751. where
  752. p.`A_STATUS` in('WAITING', 'NORMAL')
  753. and p.`ID` in({$sqlIds})
  754. ";
  755. $res = $db->query($sql);
  756. while ($r = $db->fetch($res)) {
  757. $gotoLinks[$r->ID] = $r->DESC;
  758. }
  759. }
  760. foreach ($listFlat as $vItem) {
  761. $item = $treeList->getData($vItem->ID);
  762. if(V::get('DBG_TF', '', $_GET) > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">wskazniki['.$item->ID.'] (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($wskazniki[$item->ID]);echo'</pre>';}
  763. $vItem->gotoOut = '';
  764. if ($item->IF_TRUE_GOTO > 0) {
  765. $gotoLink = "{{$item->IF_TRUE_GOTO}}";
  766. if (!V::get('HIDE_PANEL', 0, $_GET, 'int')) {
  767. $gotoLink = App::link($gotoLink, array('task'=>'PROCES_VIEW_LIST', 'id_proces'=>$item->IF_TRUE_GOTO));
  768. }
  769. if ($item->IF_TRUE_GOTO_FLAG == 'GOTO') {
  770. $vItem->gotoOut .= " {$gotoLink}"; //usunąłem Przejdz do Procesu, bo w instrukcji/umowie nie jest to potrzebne
  771. } else if ($item->IF_TRUE_GOTO_FLAG == 'GOTO_AND_RETURN') {
  772. $vItem->gotoOut .= "Przejdź do procesu {$gotoLink} i wróć po jego zakończeniu";
  773. } else if ($item->IF_TRUE_GOTO_FLAG == 'FORK') {
  774. $vItem->gotoOut .= "Uruchom propces {$gotoLink}";
  775. }
  776. if (!empty($vItem->gotoOut) && !empty($gotoLinks[$item->IF_TRUE_GOTO])) {
  777. $vItem->gotoOut .= ": {$gotoLinks[$item->IF_TRUE_GOTO]}";
  778. }
  779. $vItem->gotoOut .= ".";
  780. }
  781. }
  782. $imgSize = (V::get('show_big_img', '', $_GET))? '600x600' : '200x200';
  783. ?>
  784. <style type="text/css">
  785. .proces-list-item-view { clear:both; }
  786. .proces-list-view-image { float:right; padding:0 0 8px 8px; clear:right; }
  787. </style>
  788. <div class="container">
  789. <?php foreach ($listFlat as $vItem) {
  790. $item = $treeList->getData($vItem->ID);
  791. ?>
  792. <div class="proces-list-item-view">
  793. <h4><?php
  794. if($item->TYPE=='PROCES_INIT') echo "{".$item->ID."}";
  795. else if(in_array($item->TYPE,array('TEXT_BREAK'))) echo "&nbsp;&nbsp;&nbsp;";
  796. else if(strstr($item->TYPE,'PROCES_GROUP')) echo "<font size=+2>§".$vItem->listNrNUM."";
  797. else
  798. echo $vItem->listNrNUM."."; ?> <?php echo $item->DESC; ?> <span class="muted"><font size=-2 color=grey><i><?php if(!in_array($item->TYPE,array('TEXT_BREAK','PROCES_INIT'))) echo "{".$item->ID."}"; ?></i></font></span></h4>
  799. <?php if($item->TYPE=='PROCES_INIT')
  800. if(!empty($item->A_RECORD_UPDATE_DATE))
  801. echo "<font size=-5>akt. {$item->A_RECORD_UPDATE_DATE} przez {$item->A_RECORD_UPDATE_AUTHOR}</font>"; //TODO nalezy zabrac informacje o procesie z klasy
  802. else
  803. echo "<font size=-5>utw. {$item->A_RECORD_CREATE_DATE} przez {$item->A_RECORD_CREATE_AUTHOR}</font>"; //TODO nalezy zabrac informacje o procesie z klasy
  804. ?>
  805. <p style="overflow:hidden">
  806. <?php if ($item->A_HAS_IMAGE > 0) : ?>
  807. <?php $tbl = 'CRM_PROCES'; ?>
  808. <?php for ($i = 0; $i < $item->A_HAS_IMAGE; $i++) : ?>
  809. <a href="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $item->ID; ?>&number=<?php echo $i; ?>" target="_blank" class="proces-list-view-image lightbox">
  810. <img src="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $item->ID; ?>&number=<?php echo $i; ?>&resize=<?php echo $imgSize; ?>" />
  811. </a>
  812. <?php endfor; ?>
  813. <?php endif; ?>
  814. <?php echo $item->OPIS; ?>
  815. </p>
  816. <?php
  817. if(strstr($item->TYPE,'PROCES_GROUP')) echo "</font>";
  818. ?></p>
  819. <?php if (array_key_exists($item->ID, $wskazniki)) : ?>
  820. <dl class="dl-horizontal">
  821. <?php if (!empty($wskazniki[$item->ID]['stanowiska'])) : ?>
  822. <dt>Stanowiska:</dt>
  823. <dd>
  824. <ul>
  825. <?php foreach ($wskazniki[$item->ID]['stanowiska'] as $vWsk) : ?>
  826. <li><?php echo $vWsk->DESC; ?> <span class="muted">[<?php echo $vWsk->ID; ?>]</span></li>
  827. <?php endforeach; ?>
  828. </ul>
  829. </dd>
  830. <?php endif; ?>
  831. <?php if (!empty($wskazniki[$item->ID]['inne'])) : ?>
  832. <dt>Użyte zasoby:</dt>
  833. <dd>
  834. <ul>
  835. <?php foreach ($wskazniki[$item->ID]['inne'] as $vWsk) : ?>
  836. <li style="clear:both;">
  837. <?php if ($vWsk->A_HAS_IMAGE > 0) : ?>
  838. <?php $tbl = 'CRM_LISTA_ZASOBOW'; ?>
  839. <?php for ($i = 0; $i < $vWsk->A_HAS_IMAGE; $i++) : ?>
  840. <a href="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $vWsk->ID; ?>&number=<?php echo $i; ?>" target="_blank" class="proces-list-view-image lightbox">
  841. <img src="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $vWsk->ID; ?>&number=<?php echo $i; ?>&resize=<?php echo $imgSize; ?>" />
  842. </a>
  843. <?php endfor; ?>
  844. <?php endif; ?>
  845. <?php if ($vWsk->CW_A_HAS_IMAGE > 0) : ?>
  846. <?php $tbl = 'CRM_WSKAZNIK'; ?>
  847. <?php for ($i = 0; $i < $vWsk->CW_A_HAS_IMAGE; $i++) : ?>
  848. <a href="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $vWsk->CW_ID; ?>&number=<?php echo $i; ?>" target="_blank" class="proces-list-view-image lightbox">
  849. <img src="procesy5.php?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=<?php echo $tbl; ?>&id=<?php echo $vWsk->CW_ID; ?>&number=<?php echo $i; ?>&resize=<?php echo $imgSize; ?>" />
  850. </a>
  851. <?php endfor; ?>
  852. <?php endif; ?>
  853. <strong><?php echo (!empty($vWsk->DESC_PL))? $vWsk->DESC_PL : $vWsk->DESC; ?></strong>
  854. <?php echo (!empty($vWsk->OPIS))? " <em>({$vWsk->OPIS})</em>." : ''; ?>
  855. <?php echo (!empty($vWsk->OPIS_ZASOB))? "<br>{$vWsk->OPIS_ZASOB}" : ''; ?>
  856. <span class="muted">[<?php echo $vWsk->ID; ?>]</span>
  857. </li>
  858. <?php endforeach; ?>
  859. </ul>
  860. </dd>
  861. <?php endif; ?>
  862. </dl>
  863. <?php endif; ?>
  864. <?php if ($vItem->gotoOut) : ?>
  865. <blockquote>
  866. <small>
  867. <?php echo $vItem->gotoOut; ?>
  868. </small>
  869. </blockquote>
  870. <?php endif; ?>
  871. </div>
  872. <?php
  873. }
  874. echo '</div>';// .container
  875. }
  876. function task_PROCES_VIEW() {
  877. User_procesy5_check_access();
  878. $id_proces = V::get('id_proces', '', $_REQUEST, 'int');
  879. if ($id_proces <= 0) {
  880. echo'<p class="err box box-red">'."Wrong ID".'</p>';
  881. return;
  882. }
  883. if (1 != V::get('HIDE_PANEL', 0, $_GET, 'int')) {
  884. // pathway
  885. echo'<h1>'.App::link("Menu", "?task=CRM_MENU");
  886. echo' - ';
  887. echo "Przegladaj proces <b>".$id_proces."</b>";
  888. echo ' ';
  889. echo App::link("drukuj", array('task'=>'PROCES_VIEW', 'id_proces'=>$id_proces, 'HIDE_PANEL'=>1), array('target'=>'_blank', 'ico_after_text'=>'print', 'style'=>'font-size:small;'));
  890. echo ' ';
  891. echo App::link("drukuj większe zdjęcia", array('task'=>'PROCES_VIEW', 'id_proces'=>$id_proces, 'HIDE_PANEL'=>1, 'show_big_img'=>1, 'group_stanowiska'=>1), array('target'=>'_blank', 'ico_after_text'=>'print', 'style'=>'font-size:small;'));
  892. echo ' ';
  893. echo App::link("widok listy", array('task'=>'PROCES_VIEW_LIST', 'id_proces'=>$id_proces), array('style'=>'font-size:small;'));
  894. echo ' ';
  895. echo "<font size=-1><a href=index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&id_proces={$id_proces} target=blank>Widok mapy</a></font>";
  896. echo'</h1>';
  897. }
  898. $p = DB::get_by_id( 'CRM_PROCES', $id_proces );
  899. if (!$p) {
  900. echo'<p class="err box box-red">'."Process ".$id_proces." not exists".'</p>';
  901. return;
  902. }
  903. $tbl = 'CRM_PROCES';
  904. $clbk = 'tree_callback__show_item_from_'.$tbl;
  905. $tree_params = array();
  906. $tree_params['rozwin'] = true;
  907. $tree_params['editable'] = false;
  908. $tree_params['rozwin_proces'] = true;
  909. $tree_params['filtr_img'] = true;
  910. $tree_params['rozwin_zasoby'] = true;
  911. $tree_params['rozwin_opis'] = true;
  912. $tree_params['style'] = 'NOWY';
  913. action_VIEW_SUBTREE($tbl, $p->ID, $clbk, $tree_params);
  914. }
  915. function task_CRM_WYSWIETL_OBOWIAZKI() {
  916. User_procesy5_check_access();
  917. $_GET['TYPE'] = V::get('TYPE', "%", $_REQUEST);
  918. $_GET['DESC'] = V::get('DESC', "%", $_REQUEST);
  919. $_GET['OPIS'] = V::get('OPIS', "%", $_REQUEST);
  920. $_GET['ADM_AREA'] = V::get('ADM_AREA', "BN%", $_REQUEST);
  921. $_GET['CLZ_ID'] = V::get('CLZ_ID', '', $_REQUEST);
  922. if (!$_GET['CLZ_ID']) {
  923. //echo'<p class="err">'."Brak ID".'</p>';
  924. task_CRM_MENU();
  925. //TEST:// echo App::link_ajax_load_on_ready('user menu', 'task_CRM_MENU');
  926. return;
  927. }
  928. $zasob = DB::get_by_id('CRM_LISTA_ZASOBOW', $_GET['CLZ_ID']);
  929. if (!$zasob) {
  930. echo'<p class="err">'."Brak danych - zasob ".$_GET['CLZ_ID']." nie istnieje.".'</p>';
  931. return;
  932. }
  933. echo'<p>';
  934. echo "Procesy powiazane z zasobem: ";
  935. echo'<b>['.$zasob->ID.']</b>';
  936. echo'<br />';
  937. echo ' <b>'.$zasob->TYPE.'</b>';
  938. echo ' <span>'.$zasob->DESC.'</span>';
  939. echo '<br /><span>'.$zasob->OPIS.'</span>';
  940. echo '<br> <a href=index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_zasob='.$zasob->ID.'&RESOURCES=1><span>Wyświetl mapę </span>';
  941. echo'</p>';
  942. $db = DB::getDB();
  943. $sql = "select
  944. w.`ID_PROCES` as w__ID_PROCES
  945. , w.`OPIS_ZASOB` as w__OPIS_ZASOB
  946. , p.`ID` as p__ID
  947. , p.`DESC` as p__DESC
  948. , p.`OPIS` as p__OPIS
  949. , p_root.`ID` as p_root__ID
  950. , p_root.`DESC` as p_root__DESC
  951. , p_root.`OPIS` as p_root__OPIS
  952. from `CRM_WSKAZNIK` as w
  953. left join `CRM_PROCES` as p on (p.`ID`=w.`ID_PROCES`)
  954. left join `CRM_PROCES` as p_root on (p_root.`ID`=p.`PARENT_ID`)
  955. where
  956. w.`ID_ZASOB`=".$_GET['CLZ_ID']."
  957. and w.`A_STATUS` in('WAITING','NORMAL')
  958. and p.`A_STATUS` in('WAITING','NORMAL')
  959. order by p.SORT_PRIO
  960. ";
  961. $res = $db->query($sql);
  962. while ($r = $db->fetch($res)) {
  963. $arr [$r->w__ID_PROCES][] = $r;
  964. }
  965. echo'<table border="1" cellspacing="0" cellpadding="0" class="tbl-view">';
  966. echo'<thead>';
  967. echo'<tr>';
  968. echo'<th>'."PROCES ID".'</th>';
  969. echo'<th style="text-align:left">'."NAZWA / OPIS".'</th>';
  970. echo'</tr>';
  971. echo'</thead>';
  972. echo'<tbody>';
  973. $t = 0;
  974. foreach ($arr as $k_id => $v_arr) {
  975. echo'<tr class="row-'.($t = 1 - $t).'">';
  976. echo'<td>';
  977. echo App::link($k_id, array('task'=>"CRM_PROCES", 'filtr_id'=>$k_id));
  978. echo'</td>';
  979. echo'<td>';
  980. foreach ($v_arr as $r) {
  981. echo'<p>';
  982. echo' <b>'.$r->p__DESC.'</b>';
  983. echo'<br />';
  984. echo'<em>'.$r->p__OPIS.'</em>';
  985. if ($r->w__OPIS_ZASOB) echo'<span class="silver">'.$r->w__OPIS_ZASOB.'</span>';
  986. echo'</p>';
  987. }
  988. echo'</td>';
  989. echo'</tr>';
  990. }
  991. echo'</tbody>';
  992. echo'</table>';
  993. }
  994. function task_ADD_PROCES_ID() {
  995. User_procesy5_check_access();
  996. $id_proces = (isset($_REQUEST['id']))? intval($_REQUEST['id']) : 0;
  997. //$id_zasob = 0;//(isset($_REQUEST['id']))? intval($_REQUEST['id']) : 0;
  998. if ($id_proces <= 0) {
  999. echo'<p class="err">'."Wrong id!".'</p>';
  1000. return;
  1001. }
  1002. $proces = DB::get_by_id( 'CRM_PROCES', $id_proces );
  1003. if (!$proces) {
  1004. echo'<div class="box box-red">';
  1005. echo "Proces [".$id_proces."] not exists.";
  1006. echo'</div>';
  1007. return;
  1008. }
  1009. {// pathway
  1010. echo'<h1>';
  1011. echo App::link("Procesy", array('task'=>"CRM_PROCES"));
  1012. if ($id_proces > 0) {
  1013. echo ' &raquo; '.App::link("Dodaj zasob do procesu [".$id_proces."]", array('task'=>'ADD_PROCES_ID', 'id'=>$id_proces));
  1014. //if ($id_zasob > 0) {
  1015. // echo ' &raquo; '.App::link("Dodaj zasob [".$id_zasob."]", array('task'=>'CRM_ADD_CRM_WSKAZNIK', 'ADD_ID_PROCES'=>$id_proces, 'ADD_ID_ZASOB'=>$id_zasob));
  1016. //}
  1017. }
  1018. echo'</h1>';
  1019. }// pathway
  1020. Lib::loadClass('ProcesHelper');
  1021. {// proces info
  1022. $wsk = ProcesHelper::get_wskazniki( $proces->ID );
  1023. echo'<div class="tree-wrap">';
  1024. echo'<ul>';
  1025. echo'<li class="tree-last">';
  1026. echo'<dl>';
  1027. echo'<dt>';
  1028. if (!empty($wsk)) echo'<div class="has_wsk">';
  1029. echo'<b class="item_id btn-box">'.$proces->ID.'</b>';
  1030. echo'<span class="desc"><b>'.$proces->DESC.'</b>';
  1031. echo'<span class="more-desc"> '.$proces->OPIS.' </span>';
  1032. echo'</span>';
  1033. if (!empty($wsk)) echo'</div>';
  1034. echo'</dt>';
  1035. if (!empty($wsk)) {
  1036. $zasoby_id = array();
  1037. echo'<dd>';
  1038. echo'<ul>';
  1039. $wsk_cnt = count( $wsk );
  1040. foreach ($wsk as $w) {
  1041. $w_parents_out = '';
  1042. $w_title_parents_out = '';
  1043. echo'<li'.((--$wsk_cnt)? '' : ' class="tree-last"').'>';
  1044. echo'<p>';
  1045. echo ' <span class="btn-box btn-box-silver">'.$w->CW_ID.'</span>';
  1046. echo'<span class="green"'.$w_title_parents_out.'>['.$w->ID.']</span>';
  1047. echo' <i title="'.$w->CP_PYTANIE.' '.$w->CP_OPIS.'">'.$w->CP_FORM_TREAT.'</i>';
  1048. echo'';
  1049. echo ' '.$w->TYPE.'';
  1050. echo ' <b>'.$w->DESC.'</b> ';
  1051. //if ($tree->get_param('rozwin_opis'))
  1052. echo ' <span class="green">'.$w->OPIS.'</span>';// opis zasobu
  1053. //if ($tree->get_param('rozwin_opis'))
  1054. echo ' <span style="color:#000;">'.$w->OPIS_ZASOB.'</span>';// komentarz wskaznika
  1055. echo'</p>';
  1056. echo'</li>';
  1057. }
  1058. echo'</ul>';
  1059. }
  1060. echo'</dl>';
  1061. echo'</li>';
  1062. echo'</ul>';
  1063. echo'</div>';// .tree-wrap
  1064. }// proces info
  1065. echo'<form action="" method="GET">';
  1066. echo'<input type="hidden" name="'."task".'" value="'."CRM_ADD_CRM_WSKAZNIK".'" />';
  1067. echo'<input type="hidden" name="'."ADD_ID_PROCES".'" value="'.$proces->ID.'" />';
  1068. echo'<p>'."Podaj numer zasobu: ";
  1069. echo'<input type="text" name="'."ADD_ID_ZASOB".'" value="'."".'" />';
  1070. echo'<input type="submit" value="'."OK".'" />';
  1071. echo '<br />'." lub wyszukaj ponizej:";
  1072. echo'</p>';
  1073. echo'</form>';
  1074. echo'<pre id="tree">';
  1075. echo "DRZEWO ";
  1076. if ($_SESSION['ZWIN_DRZEWO']) {
  1077. echo App::link("ROZWIN", "?ROZWIN_DRZEWO=1&id={$id_proces}#tree");
  1078. } else {
  1079. echo App::link("ZWIN", "?ZWIN_DRZEWO=1&id={$id_proces}#tree");
  1080. }
  1081. echo " / ";
  1082. $js = "window.location.href='#TREE'+this.form.id.value;return false;";
  1083. echo '<form style="display:inline" action="#" method="GET">';
  1084. echo "Zasob ID: ";
  1085. echo'<input type="text" name="id" value="" />';
  1086. echo'<button onclick="'.$js.'">'."Wyszukaj ID".'</button>';
  1087. echo'</form>'."\n";
  1088. tree_listuj_zasoby(0,0,0);
  1089. echo'</pre>';
  1090. }
  1091. function fun_SHOW_EXTERNAL_IMAGE() {
  1092. $remote_table = V::get('tbl', '', $_REQUEST);
  1093. $remote_id = V::get('id', '', $_REQUEST, 'int');
  1094. $number = V::get('number', '', $_REQUEST, 'int');
  1095. $imageResize = V::get('resize', '', $_REQUEST);
  1096. $DBG = (V::get('DBG', 0, $_REQUEST, 'int') > 0);
  1097. if ($remote_id <= 0) {
  1098. header('HTTP/1.1 400: Bad Request');
  1099. header('Warning: wrong ID L.' . __LINE__);
  1100. exit;
  1101. }
  1102. if (!DB_Image::tableIsAllowed($remote_table)) {
  1103. header('HTTP/1.1 400: Bad Request');
  1104. header('Warning: table not allowed L.' . __LINE__);
  1105. exit;
  1106. }
  1107. $image_row = DB_Image::getImage($remote_table, $remote_id, $number);
  1108. if (!$image_row) {
  1109. header('HTTP/1.1 400: Bad Request');
  1110. header('Warning: image not found in db L.' . __LINE__);
  1111. exit;
  1112. }
  1113. $etag = md5($image_row->ID . $image_row->A_CREATE_DATE_TS);
  1114. if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $image_row->A_CREATE_DATE_TS
  1115. || trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
  1116. //header("HTTP/1.1 304 Not Modified");
  1117. //exit;
  1118. }
  1119. $expire_date = mktime(0, 0, 0, date('m') + 3, date('d'), date('Y'));
  1120. $maxWidth = 0;
  1121. $maxHeight = 0;
  1122. if ($imageResize) {
  1123. list($maxWidth, $maxHeight) = explode('x', $imageResize, 2);
  1124. $maxWidth = intval($maxWidth);
  1125. $maxHeight = intval($maxHeight);
  1126. if ($maxWidth <= 0 || $maxHeight <= 0) {
  1127. header('HTTP/1.1 400: Bad Request');
  1128. echo'ERROR wrong param resize (WxH)';
  1129. exit;
  1130. }
  1131. }
  1132. if (!$DBG) {
  1133. header("Content-type: {$image_row->TYPE}");
  1134. header("Cache-control: public");
  1135. header("Pragma: public");// default 'no-cache'
  1136. header("Etag: {$etag}");
  1137. if (!$imageResize) {
  1138. header("Content-length: {$image_row->SIZE}");
  1139. }
  1140. header("Expires: " . gmdate("D, d M Y H:i:s", $expire_date) . " GMT");
  1141. header("Last-Modified: " . gmdate("D, d M Y H:i:s", $image_row->A_CREATE_DATE_TS) . " GMT");
  1142. }
  1143. if ($imageResize) {
  1144. print DB_Image::resizeImageFromBlob($image_row->IMAGE, $image_row->TYPE, $maxWidth, $maxHeight);
  1145. } else {
  1146. print $image_row->IMAGE;
  1147. }
  1148. exit;
  1149. }
  1150. function fun_SHOW_IMAGE() {
  1151. $image_id = V::get('image_id', 0, $_REQUEST, 'int');
  1152. if ($image_id <= 0) {
  1153. header('HTTP/1.1 400: Bad Request');
  1154. header('Warning: wrong id ' . __LINE__);
  1155. exit;
  1156. }
  1157. $image_row = DB_Image::getImageById($image_id);
  1158. if (!$image_row) {
  1159. header('HTTP/1.1 400: Bad Request');
  1160. header('Warning: image not found in db L.' . __LINE__);
  1161. exit;
  1162. }
  1163. header("Content-type: ".$image_row->TYPE);
  1164. header("Content-length: ".$image_row->SIZE);
  1165. print $image_row->IMAGE;
  1166. exit;
  1167. }
  1168. function fun_IMAGE_ADD() {
  1169. $remote_table = V::get('tbl', '', $_REQUEST);
  1170. $remote_id = V::get('id', 0, $_REQUEST, 'int');
  1171. $task = V::get('task', '', $_REQUEST);
  1172. $thiss = new stdClass();
  1173. $thiss->DETECT_TABLE_NAME = $remote_table;
  1174. $errors = array();
  1175. $msgs = array();
  1176. // check remote id
  1177. if ($remote_id <= 0) {
  1178. echo'<p>';
  1179. echo "Error wrong ID";
  1180. echo'<br />';
  1181. //echo App::link();// TODO: link do ???
  1182. echo'</p>';
  1183. return;
  1184. }
  1185. // check remote table
  1186. if (!DB_Image::tableIsAllowed($remote_table)) {
  1187. $errors[] = "Error table not allowed to add image";
  1188. }
  1189. // task
  1190. $task = V::get('task', '', $_REQUEST);
  1191. if ($task == 'REMOVE') {// TODO: przerobic na funkcje, zwrocic msg, pokazac w body
  1192. $req = array();
  1193. $req['ID'] = V::get('ID', '', $_REQUEST, 'int');
  1194. $req['REMOTE_ID'] = V::get('REMOTE_ID', '', $_REQUEST, 'int');
  1195. $req['REMOTE_TABLE'] = V::get('REMOTE_TABLE', '', $_REQUEST);
  1196. // validate
  1197. if ($req['ID'] <= 0) {
  1198. $errors[] = 'error ID';
  1199. }
  1200. if ($req['REMOTE_ID'] <= 0) {
  1201. $errors[] = 'error REMOTE_ID';
  1202. }
  1203. if ($req['REMOTE_TABLE'] != $remote_table) {
  1204. $errors[] = 'error REMOTE_TABLE';
  1205. }
  1206. if (empty($errors)) {
  1207. $affected = DB_Image::deleteImage($req['ID'], $req['REMOTE_TABLE'], $req['REMOTE_ID']);
  1208. if ($affected == 1) {
  1209. $msgs[] = '<p>'."Usunieto zdjecie ID=".$req['ID'].'</p>';
  1210. } else {
  1211. $erros[] = '<p>'."Wystapil blad podczas usuwania zdjecia ID=".$req['ID'].'</p>';
  1212. }
  1213. }
  1214. }
  1215. // check if a file was submitted
  1216. if (!isset($_FILES['userfile'])) {
  1217. //echo '<p>Please select a file</p>';
  1218. }
  1219. else {
  1220. $errors = DB_Image::uploadImage($remote_table, $remote_id, $_FILES['userfile']);
  1221. // give praise and thanks to the php gods
  1222. if (empty($errors)) {
  1223. $msgs[] = '<p>Thank you for submitting</p>';
  1224. } else {
  1225. $msgs[] = '<p style="border:1px solid red;">' . "Sorry, could not upload file:" . '<br />' . implode('<br />', $errors) .'</p>';
  1226. }
  1227. }
  1228. $title = 'Dodaj plik do rekordu ID='.$remote_id.' z tabeli '.$remote_table;
  1229. lay_procesy_gora();
  1230. echo'<h3>'.$title.'</h3>';
  1231. // show masgs
  1232. if (!empty($msgs)) {
  1233. echo'<div class="box box-green">';
  1234. echo implode('<br />', $msgs);
  1235. echo'</div>';
  1236. }
  1237. // show errors
  1238. if (!empty($errors)) {
  1239. echo'<div class="box box-red">';
  1240. echo implode('<br />', $errors);
  1241. echo'</div>';
  1242. echo'<br /><br />'.'<a href="javascript:window.close()">'."Zamknij to okno".'</a>';
  1243. return;
  1244. }
  1245. echo'<div class="box box-silver">';
  1246. echo'<form enctype="multipart/form-data" action="" method="post">';
  1247. echo'<input type="hidden" name="function_init" value="'. __FUNCTION__ .'" />';
  1248. echo'<input type="hidden" name="REMOTE_ID" value="'.$remote_id.'" />';
  1249. echo'<input type="hidden" name="REMOTE_TABLE" value="'.$remote_table.'" />';
  1250. //echo'<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />';
  1251. echo"Rodzaj obrazka: ";
  1252. echo'<input type="text" name="'."DEST".'" value="'."".'" />';
  1253. $select_arr = array();
  1254. $select_arr = DB_Image::conf_get_options($thiss->DETECT_TABLE_NAME);
  1255. if (!empty($select_arr)) {
  1256. echo' ';
  1257. $js = "if(this.selectedIndex>0){this.form.DEST.value=this.value}";
  1258. echo'<select onchange="'.$js.'">';
  1259. echo'<option value="">'."Wybierz".'</option>';
  1260. foreach ($select_arr as $key => $val) {
  1261. echo'<option value="'.$key.'">'.$val.'</option>';
  1262. }
  1263. echo'</select>';
  1264. }
  1265. echo'<br />';
  1266. echo'<input name="userfile" type="file" />';
  1267. echo'<br />';
  1268. echo'<input type="submit" value="'."Dodaj obrazek".'" />';
  1269. echo'</form>';
  1270. echo'</div>';// .box-silver
  1271. // TODO: show images, mv to function {
  1272. $images = DB_Image::getImages($thiss->DETECT_TABLE_NAME, $remote_id);
  1273. echo'<div class="box box-blue" style="overflow:hidden">';
  1274. if (empty($images)) {
  1275. echo'<p class="err">'."Brak obrazkow".'</p>';
  1276. } else {
  1277. echo'<h3>'."Wgrane pliki:".'</h3>';
  1278. foreach ($images as $r) {
  1279. $link_src = '?function_init=fun_SHOW_IMAGE&image_id='.$r->ID.'&HEADER_NOT_INIT=YES';
  1280. $st = array();
  1281. if ($r->WIDTH > 100 || $r->HEIGHT > 100) {
  1282. if ($r->WIDTH > $r->HEIGHT) {
  1283. $st[] = 'width:100px';
  1284. } else {
  1285. $st[] = 'height:100px';
  1286. }
  1287. }
  1288. $st = (empty($st))? '' : ' style="'.implode(';', $st).'"';
  1289. echo'<table style="float:left;border:1px solid silver;">';
  1290. echo'<tr>';
  1291. echo'<td>';
  1292. echo''.$r->NAME.'<br />';
  1293. echo''.$r->DEST.'<br />';
  1294. echo''.$r->A_CREATE_DATE.'<br />';
  1295. echo''.DB_Image::showSize($r->SIZE).' '.$r->WIDTH.'x'.$r->HEIGHT.'<br />';
  1296. echo'<img src="'.$link_src.'" '.$st.'/>';
  1297. echo'</td>';
  1298. echo'</tr>';
  1299. echo'<tr>';
  1300. echo'<td style="text-align:center;">';
  1301. echo'<form action="" method="post" style="display:inline">';
  1302. echo'<input type="hidden" name="task" value="'."REMOVE".'" />';
  1303. echo'<input type="hidden" name="ID" value="'.$r->ID.'" />';
  1304. echo'<input type="hidden" name="REMOTE_ID" value="'.$remote_id.'" />';
  1305. echo'<input type="hidden" name="REMOTE_TABLE" value="'.$remote_table.'" />';
  1306. $js = "if(!confirm('Czy na pewno chcesz usunac obrazek?')) return false;";
  1307. echo'<input type="submit" value="Usun" onclick="'.$js.'" />';
  1308. echo'</form>';
  1309. if (0) {// TODO: edytuj
  1310. echo'<form action="" method="post" style="display:inline">';
  1311. echo'<input type="hidden" name="task" value="'."EDIT".'" />';
  1312. echo'<input type="hidden" name="ID" value="'.$r->ID.'" />';
  1313. echo'<input type="hidden" name="REMOTE_ID" value="'.$remote_id.'" />';
  1314. echo'<input type="hidden" name="REMOTE_TABLE" value="'.$remote_table.'" />';
  1315. echo'<input type="submit" value="Edytuj" />';
  1316. echo'</form>';
  1317. }
  1318. echo'</td>';
  1319. echo'</tr>';
  1320. echo'</table>';
  1321. }
  1322. }
  1323. echo'</div>';// .box-blue
  1324. // } function show images
  1325. echo'<br /><br />'.'<a href="javascript:window.close()">'."Zamknij to okno".'</a>';
  1326. die("\n".'<!-- EOF L.' . __LINE__ . ' -->');
  1327. }
  1328. // http://se.dev.webone.pl/se-dev/procesy5.php?function_init=fun_SHOW_VIDEO&id=2314&task=CRM_PROCES
  1329. function fun_SHOW_VIDEO() {
  1330. $zasob_id = V::get('id', '', $_GET);
  1331. $zasob = DB::get_by_id('CRM_LISTA_ZASOBOW', $zasob_id);
  1332. if ($zasob->TYPE != 'PLIK') {
  1333. die('Wrong type!');
  1334. }
  1335. $movie_ext = array('avi', 'mov', 'm4v');
  1336. if (!in_array(end(explode('.', $zasob->DESC)), $movie_ext)) {
  1337. die('Wrong file name!');
  1338. }
  1339. $zasob_parent = DB::get_by_id('CRM_LISTA_ZASOBOW', $zasob->PARENT_ID);
  1340. if (!$zasob_parent) {
  1341. die('Parent not exists!');
  1342. }
  1343. $zasob_parent2 = DB::get_by_id('CRM_LISTA_ZASOBOW', $zasob_parent->PARENT_ID);
  1344. if (!$zasob_parent2) {
  1345. die('Parent2 not exists!');
  1346. }
  1347. echo'<p>'."[".$zasob->ID."] ".'<i>'.$zasob->TYPE.'</i> '.$zasob->DESC.'</p>';
  1348. echo'<p>'."[".$zasob_parent->ID."] ".'<i>'.$zasob_parent->TYPE.'</i> '.$zasob_parent->DESC.'</p>';
  1349. echo'<p>'."[".$zasob_parent2->ID."] ".'<i>'.$zasob_parent2->TYPE.'</i> '.$zasob_parent2->DESC.'</p>';
  1350. exit;
  1351. }
  1352. // ======== TREE =========
  1353. DEBUG_S(5,'SES.USER_PARAMS', $_SESSION['USER_PARAMS'], __FILE__, __FUNCTION__, __LINE__);
  1354. DEBUG_S(6,'SES', $_SESSION, __FILE__, __FUNCTION__, __LINE__);
  1355. DEBUG_S(6,'SRV', $_SERVER, __FILE__, __FUNCTION__, __LINE__);
  1356. echo'<br>.';
  1357. lay_procesy_dol();
  1358. function lay_procesy_dol() {
  1359. if (1 == V::get('HIDE_PANEL', 0, $_REQUEST, 'int')) {
  1360. return;
  1361. }
  1362. SE_Layout::dol();
  1363. }
  1364. function lay_procesy_user_panel() {
  1365. //echo 'ST-"'.ini_get('session.gc_maxlifetime').'", req_time="'.date('H:i:s').'", end_time="'.date('H:i:s', time() + ini_get('session.gc_maxlifetime')).'", ID="'.session_id().'"<br />'."\n";
  1366. if (!V::get('SHOW_PANEL', '', $_SESSION['USER_PARAMS'])) {
  1367. // return;
  1368. }
  1369. if (1 == V::get('HIDE_PANEL', 0, $_REQUEST, 'int')) {
  1370. return;
  1371. }
  1372. Lib::loadClass('SE_Layout');
  1373. SE_Layout::menu();
  1374. return;
  1375. echo "\n".'<div id="GORA">'."\n";
  1376. echo'<table cellspacing="0" cellpadding="0" style="width:100%"><tbody>';
  1377. echo'<tr>';
  1378. echo '<th class="logo" style="width:5%; white-space:nowrap;">';
  1379. echo '<a href="index.php">SE</a>';
  1380. echo ' / ';
  1381. echo App::link("ODSWIEZ", '');
  1382. echo'</th>';
  1383. echo'<td class="main-menu">';// center
  1384. $menu = array();
  1385. /*
  1386. * ADM_ADMIN_LEVEL = 6;
  1387. * A_STATUS = 'WAITING';
  1388. * ADM_ACCOUNT = 'Kandydat';
  1389. * ADM_AREA = 'KANDYDAT';
  1390. * ADM_ADMIN_DESC = 'Kandydat';
  1391. */
  1392. if (User::get('ADM_ADMIN_LEVEL') == 6) {
  1393. $menu ['CRM_TESTY'] = array("TESTY", "?task=CRM_TESTY", array('title'=>'Wyswietlenie testów'));
  1394. } else {
  1395. $menu ['CRM_PROCES'] = array("PROCESY", array('task'=>'CRM_PROCES'), array('title'=>'Wyswietlenie procesow'));
  1396. $menu ['CRM_LISTA_ZASOBOW'] = array("ZASOBY", "?task=CRM_LISTA_ZASOBOW", array('title'=>'Wyswietlenie zasobow'));
  1397. $menu ['CRM_WYSWIETL_OBOWIAZKI'] = array("OBOWIAZKI", "?task=CRM_WYSWIETL_OBOWIAZKI", array('title'=>'Wyswietlenie OBOWIAZKOW'));
  1398. $menu ['CRM_TESTY'] = array("TESTY", "?task=CRM_TESTY", array('title'=>'Wyswietlenie testów'));
  1399. if (User::hasAccess('testy_wyniki_read')) {
  1400. $menu ['CRM_TESTY_WYNIKI'] = array("WYNIKI", "?task=CRM_TESTY_WYNIKI", array('title'=>'Wyswietlenie wyników testów'));
  1401. }
  1402. $menu ['USERS'] = array("KONTAKTY", "?task=USERS", array('title'=>'Kontakty'));
  1403. }
  1404. foreach ($menu as $k_task => $v_menu) {
  1405. if ($k_task == App::get_task()) $v_menu[2] ['class'] = 'current';
  1406. echo App::link($v_menu[0], $v_menu[1], $v_menu[2]);
  1407. }
  1408. echo'</td>'."\n";
  1409. echo'<td class="user" style="text-align:right">'."\n";
  1410. {
  1411. $q = V::get('q', '', $_REQUEST);
  1412. echo '<form action="' . "?task=CRM_SEARCH" . '" method="post" class="panel-search">';
  1413. //echo '<input type="hidden" name="task" value="CRM_SEARCH" />';
  1414. echo '<input type="text" name="q" value="' . htmlspecialchars($q) . '" class="q" />';
  1415. echo '<input type="image" src="icon/search.png" class="s" />';
  1416. echo '</form>';
  1417. echo' | ';
  1418. }
  1419. S::show_session_timer();
  1420. //echo'<a href="?function_init=SCREEN">Ekran</a> | ';
  1421. if (V::get('DEBUG', '', $_SESSION)) {
  1422. echo'<b title="'.$_SESSION['DEBUG'].'">DBG('.$_SESSION['DEBUG'].')</b>';
  1423. $js = "if(jQuery(document.body).hasClass('show-DEBUG_S')){jQuery(document.body).removeClass('show-DEBUG_S');this.innerHTML='+';}else{jQuery(document.body).addClass('show-DEBUG_S');this.innerHTML='-'};return false;";
  1424. echo ' <a href="#" onclick="' . $js . '">' . "+" . '</a>';
  1425. echo' | ';
  1426. }
  1427. echo App::link($_SESSION['AUTHORIZE_USER'], array('task'=>"USER"), array('title'=>$_SESSION['ADM_ACCOUNT']));
  1428. echo' | '.User::get('ADM_ADMIN_LEVEL').'';
  1429. echo' | ';
  1430. echo App::link("Wyloguj", "?LOGIN=LOGOUT");
  1431. echo'</td>';
  1432. echo'</tr></tbody></table>';
  1433. echo "\n".'</div>'."\n";// #GORA
  1434. }
  1435. function lay_procesy_css() {
  1436. echo'<style type="text/css">';
  1437. echo"
  1438. body { margin:0; font-size:small; }
  1439. #body_content { padding:10px; }
  1440. #body_content h1{ margin:13px 0;color:#000; }
  1441. #body_content h1 a{ color:#C53000; }
  1442. .err{color:#f00;}
  1443. p {margin:6px 0;}
  1444. li p {margin:3px 0;}
  1445. .panel-search {display:inline; margin:0; padding:0;}
  1446. .panel-search .q {margin:0 2px; padding:0 5px; border:0; background:#eee;}
  1447. .panel-search .s {margin:0 2px; padding:0; border:0; vertical-align:bottom;}
  1448. .tbl-view th,
  1449. .tbl-view td {font-size:small;border-color:#eee;padding:0 1px;}
  1450. .tbl-view thead th,
  1451. .tbl-view thead td {background:#f3f3f3;}
  1452. .tbl-view tbody tr:hover td {background:#E6FFE6;}
  1453. .tbl-view tbody tr.row-0 {background:#f3f3f3;}
  1454. .tbl-view tbody tr.row-1 {background:#fff;}
  1455. .tbl-view tbody th {text-align:center;}
  1456. .tbl-view tbody td {padding:0 2px;}
  1457. .tbl-view form {margin:0;padding:0;}
  1458. .tbl-view .find th,
  1459. .tbl-view .find td,
  1460. .tbl-view tfoot th,
  1461. .tbl-view tfoot td {background:#E3E3E3;}
  1462. .tbl-view .i {margin:0;padding:0;border:1px solid #999;}
  1463. .tbl-view .add td .i,
  1464. .tbl-view .find td .i {width:100%;}
  1465. .tbl-view .find td.selected {border-bottom:2px solid #FF0000;}
  1466. .tbl-wsk-view{border-collapse:separate;border:1px solid #fff;}
  1467. .tbl-wsk-view th,
  1468. .tbl-wsk-view td{padding:0px;border-spacing:1px;background:#E6FFE6;font-size:small;border:1px solid #008000;}
  1469. .tree-wrap dd .tbl-wsk-view{margin:0 0 0 10px;}
  1470. .tree-wrap .tbl-wsk-view .btn-box{margin:0;}
  1471. .tree-wrap .wsk-cell{background:#fff;padding:2px;}
  1472. #GORA {margin:0;padding:0;background:#000;color:#fff;border-bottom:2px solid #969696;overflow:hidden;}
  1473. /*
  1474. #GORA {position:fixed;top:0;left:0;width:100%;}
  1475. */
  1476. #GORA a {margin:0;padding:0px;color:#fff;text-decoration:none;font-size:12px;}
  1477. #GORA a:hover {text-decoration:underline;}
  1478. #GORA th, #GORA td {color:#fff;font-size:12px;}
  1479. #GORA th.logo {padding:2px 3px;background:#C53000;}
  1480. #GORA td.user {padding:2px 3px;}
  1481. #GORA .main-menu {}
  1482. #GORA .main-menu {margin:0;padding:0;list-style:none;}
  1483. #GORA .main-menu li {margin:0;padding:0;display:inline;}
  1484. #GORA .main-menu a {display:block;float:left;margin:0;padding:4px;text-decoration:none;border-top:3px solid #000;font-size:12px;font-weight:bold;font-family:arial;}
  1485. #GORA .main-menu a:hover {border-color:#C53000;text-decoration:none;background:#555;}
  1486. #GORA .main-menu a.current {border-color:#C53000;}
  1487. #GORA .main-menu a.last {border-top:2px solid #C53000;}
  1488. fieldset.main { border:1px solid #000; }
  1489. fieldset.main, fieldset.main legend { background-color:#eee; }
  1490. fieldset.main legend { padding:0 5px; border:1px solid #000; }
  1491. p.sql-msg { color:green; }
  1492. p.sql-msg-err { color:red; }
  1493. tr.add { background-color:#eee; }
  1494. tr.edit { background-color:#ffa; }
  1495. a.external {padding:0 13px 0 0;background: url(icon/external.png) center right no-repeat;}
  1496. a.btn-p5 {background:#eee;color:#000;text-decoration:none;font-weight:bold;padding:0 3px;border:1px solid #666;white-space:nowrap;}
  1497. a.btn-p5:hover {background:#eee;color:#00f;}
  1498. a.btn-clean {background:#fff;color:#00f;text-decoration:none;font-weight:bold;padding:0;border:none;}
  1499. a.btn-clean:hover {background:#fff;color:#f00;}
  1500. a.btn-sm {font-size:x-small;}
  1501. .P_ID {color:#f00;}
  1502. .P_ID_ACCESS {color:#0E7E0E;}
  1503. .P_ID_MAP {color:#A020F0;}
  1504. .ALIAS_ID {color:#FF6900;}
  1505. .red{color:#f00;}
  1506. .green{color:#008000;}
  1507. .blue{color:#00f;}
  1508. .silver{color:#666;}
  1509. .box{border:1px solid #999;padding:5px;margin:5px;}
  1510. .box-center{border:1px solid #999;padding:5px;margin:5px auto;}
  1511. .box-silver{border-color:#999;}
  1512. .box-red{border-color:#f00;}
  1513. .box-blue{border-color:#00f;}
  1514. .box-green{border-color:#008000;}
  1515. .box-hover-active{background:#fff;border-color:#999;}
  1516. .box-hover-active:hover{background:#eee;border-color:#000;}
  1517. .cmnt {color:#eee;}
  1518. .cmnt-small {font-size:small;color:#eee;}
  1519. #body_content .pathway{margin:0 0 10px 0;padding:3px 8px;border:1px solid #aaa;font-size:medium;font-weight:bold;background-color:#efefef;}
  1520. #body_content .pathway a{text-decoration:none;}
  1521. #body_content .pathway a:hover{text-decoration:underline;}
  1522. .flexigrid{font-size:small;}
  1523. .flexigrid td,
  1524. .flexigrid th{font-size:small;}
  1525. .flexigrid .tDiv .add { background:url(stuff/i/add.png) no-repeat center left; }
  1526. .flexigrid .tDiv .delete { background:url(stuff/i/del.png) no-repeat center left; }
  1527. .flexigrid .tDiv .edit { background:url(stuff/i/edit.gif) no-repeat center left; }
  1528. .filters{margin:0;padding:2px;background:#F0F0F0 url(./stuff/flexigrid/css/images/bg.gif) repeat-x top;border:1px solid #ccc;border-style:solid solid none solid;clear:both;overflow:hidden;}
  1529. .filters {font-size:13px; line-height:16px;}
  1530. .filters input {font-size:13px; line-height:16px;}
  1531. .filters .btnseparator{float:left;height:22px;border-left:1px solid #CCC;border-right:1px solid #fff;margin:1px;}
  1532. .filters form{margin:0;padding:0;}
  1533. .filters nobr{display:block;float:left;margin:0;padding:2px;font-weight:normal;font-size:13px;}
  1534. .filters nobr:hover{text-decoration:underline;}
  1535. .filters nobr.active{color:#f00;font-weight:normal;}
  1536. .filters nobr input,
  1537. .filters nobr select,
  1538. .filters nobr button{margin:0 1px;padding:0 2px;font-size:13px;}
  1539. .btn-box{margin:0 2px 0 0;padding:0 3px;background:#bbb;color:#fff;text-decoration:none;border:0;font-weight:bold;}
  1540. .btn-box-blue{background:#3A3AFF;color:#fff;}
  1541. .btn-box-green{background:#008A00;color:#fff;}
  1542. .btn-box-lgreen{background:#97CF97;color:#fff;}
  1543. .btn-box-red{background:#FF4646;color:#fff;}
  1544. .btn-box-group1{background-color:#9F9FCB;color:#fff;}
  1545. .btn-box-group2{background-color:#B8B879;color:#fff;}
  1546. /*.tree-wrap .btn-p5{border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;}*/
  1547. /*.btn-box{border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;}*/
  1548. .user-menu-tree {color:#666;font-weight:normal;}
  1549. .user-menu-PROCES_INIT {color:#f00;font-weight:bold;}
  1550. ";
  1551. echo'</style>' . "\n";
  1552. }
  1553. function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
  1554. // $dbg=debug_backtrace();
  1555. // DEBUG_S(-3,'backtrace',$dbg);
  1556. $db = DB::getDB();
  1557. $wsk = array();
  1558. Lib::loadClass('ProcesHelper');
  1559. $tree->log('show item - start');
  1560. if ($tree->get_param('rozwin_proces')) {
  1561. $wsk = ProcesHelper::get_wskazniki($r->ID);
  1562. $tree->log('show item -> get_wskazniki', array('get_wskazniki'));
  1563. foreach ($wsk as $idx => $w) $wsk[$idx]->ACL_TYPE = in_array($w->TYPE, ['STANOWISKO', 'DZIAL', 'PODMIOT']) ? 'GROUP' : '';
  1564. // UI::table([ 'rows' => array_map(function ($w) {
  1565. // unset($w->path);
  1566. // unset($w->OPIS);
  1567. // return (array)$w;
  1568. // }, $wsk) ]);
  1569. $fixedWskList = array();
  1570. foreach ($wsk as $w) {
  1571. if ('GROUP' == $w->ACL_TYPE) $fixedWskList[] = $w;
  1572. }
  1573. if ('PROCES_INIT' == $r->TYPE) {// fetch INHERIT acl groups
  1574. $idGroups = array_reduce($wsk, function ($carry, $w) {
  1575. if ('GROUP' != $w->ACL_TYPE) return $carry;
  1576. return (!empty($carry)) ? "{$carry},{$w->ID}" : $w->ID;
  1577. }, "");
  1578. $sqlFilterIdGroups = (!empty($idGroups)) ? " and gp.ID_GROUP not in({$idGroups})" : "";
  1579. foreach (DB::getPDO()->fetchAll("select z.ID
  1580. , z.PARENT_ID
  1581. , z.`TYPE`
  1582. , z.`DESC`
  1583. , 'INHERIT' as ACL_TYPE
  1584. from CRM_PROCES_idx_GROUP_to_PROCES gp
  1585. join CRM_LISTA_ZASOBOW z on(z.ID = gp.ID_GROUP)
  1586. where gp.ID_PROCES = {$r->ID}
  1587. {$sqlFilterIdGroups}
  1588. ") as $aclW) {
  1589. $fixedWskList[] = (object)$aclW;
  1590. }
  1591. }
  1592. foreach ($wsk as $w) {
  1593. if ('GROUP' != $w->ACL_TYPE) $fixedWskList[] = $w;
  1594. }
  1595. $wsk = $fixedWskList;
  1596. $tree->log('show item -> get_wskazniki inherit', array('get_wskazniki'));
  1597. }
  1598. $pytania = array();
  1599. $tblPytaniaId = $tree->get_param('PytaniaTblId');
  1600. if ($tree->get_param('editable') && $tree->get_param('HasAclPytaniaTbl')) {
  1601. $userAcl = User::getAcl();
  1602. $tblAcl = $userAcl->getTableAcl($tblPytaniaId);
  1603. $dataSource = $tblAcl->getDataSource();
  1604. $params = array();
  1605. $params['f_ID_PROCES'] = $r->ID;
  1606. $pytania = $dataSource->getItems($params);
  1607. $tree->log('show item -> fetch-pytania', array('fetch-pytania'));
  1608. }
  1609. $show_form = ($tree->get_param('show_form_at_item') == $r->ID);
  1610. $show_form = ($tree->get_param('show_form_at_item') > 0);// TODO: RMME
  1611. $cls = array();
  1612. if (($search_id = $tree->get_param('search_id')) > 0 && $search_id == $r->ID) {
  1613. $cls[] = 'search_id';
  1614. }
  1615. $cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : '';
  1616. echo '<dl'.$cls.'>';
  1617. echo '<dt>';
  1618. if (!empty($wsk)) echo'<div class="has_wsk">';
  1619. $out_id = ($r->ID < 10)? '&nbsp;'.$r->ID.'' : $r->ID;
  1620. $proces_type_css_class = null;
  1621. if ($r->TYPE == 'PROCES_INIT') {
  1622. $proces_type_css_class = 'red';
  1623. } else if ($r->TYPE == 'PROCES_GROUP_1') {
  1624. $proces_type_css_class = 'group1';
  1625. } else if ($r->TYPE == 'PROCES_GROUP_2') {
  1626. $proces_type_css_class = 'group2';
  1627. }
  1628. $cls = array();
  1629. $cls[] = 'item_id';
  1630. $cls[] = 'btn-box';
  1631. if ($proces_type_css_class) $cls[] = 'btn-box-'.$proces_type_css_class;
  1632. echo App::link($out_id, array('task'=>"CRM_PROCES", 'filtr_id'=>$r->ID, '#'=>'TREE'.$r->ID), array('class'=>implode(' ', $cls)));
  1633. //if($r->TYPE == 'PROCES_INIT') {
  1634. $tree->log('show item -> fetch-IF_TRUE_GOTO start');
  1635. $gotoList = ProcesHelper::getGoToProces($r->ID);
  1636. foreach ($gotoList as $gotoId => $gotoFlag) {
  1637. $popupIcon = 'glyphicon glyphicon-chevron-left';
  1638. $popupLink = "procesy5.php?task=PROCES_VIEW&id_proces={$gotoId}";
  1639. $popupTitle = "GOTO";
  1640. $popupContent = "{$gotoId} {$gotoFlag} {$r->ID}";
  1641. $linkStyle = '';
  1642. if ('popover' == $linkStyle) {
  1643. ?>
  1644. <a href="<?php echo $popupLink; ?>"><i class="<?php echo $popupIcon; ?> wsk-help popover-with-html">
  1645. <span class="popover-heading"><?php echo $popupTitle; ?></span>
  1646. <span class="popover-body"><?php echo $popupContent; ?></span>
  1647. </i><?php echo $gotoId; ?></a>
  1648. <?php
  1649. } else {
  1650. echo ' ';
  1651. echo App::link("&lt;{$gotoId}", array('task'=>'PROCES_VIEW', 'id_proces'=>$gotoId), array('title'=>$popupContent));
  1652. echo ' ';
  1653. }
  1654. }
  1655. $tree->log('show item -> fetch-IF_TRUE_GOTO', array('fetch-IF_TRUE_GOTO'));
  1656. //}
  1657. //echo App::link("&#9873;", array('task'=>"CRM_PROCES", 'filtr_id'=>$r->ID, '#'=>'TREE'.$r->ID), array('class'=>''));
  1658. //echo App::link("&#9872;", array('task'=>"CRM_PROCES", 'filtr_id'=>$r->ID, '#'=>'TREE'.$r->ID), array('class'=>''));
  1659. if ($tree->get_param('editable')) {
  1660. //echo'('.$r->SORT_PRIO.')';//TODO: DBG
  1661. echo App::link("<b>^</b>", array('task'=>'CRM_PROCES', 'function_init'=>'SORT_PRIO_PROCES', 'arg1'=>$r->ID, 'arg1_val'=>'upup','#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore o 5 pol"));
  1662. echo App::link("^", array('task'=>'CRM_PROCES', 'function_init'=>'SORT_PRIO_PROCES', 'arg1'=>$r->ID, 'arg1_val'=>'up','#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore"));
  1663. echo App::link("v", array('task'=>'CRM_PROCES', 'function_init'=>'SORT_PRIO_PROCES', 'arg1'=>$r->ID, 'arg1_val'=>'dw','#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w dol"));
  1664. echo App::link("V", array('task'=>'CRM_PROCES', 'function_init'=>'SORT_PRIO_PROCES', 'arg1'=>$r->ID, 'arg1_val'=>'downdown','#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w dol o 5 pol"));
  1665. echo' ';
  1666. if ($tree->get_param('ProcesTblId') > 0) {
  1667. // rem@2016-08 sqix link do nowy edytor:
  1668. if($r->TYPE == 'PROCES_INIT') {
  1669. echo App::link("E", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('ProcesTblId')."#EDIT/".$r->ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1670. echo App::link("e", "index.php?_route=UrlAction_ProcesEditor&id=".$r->ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1671. } else {
  1672. echo App::link("E", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('ProcesTblId')."#EDIT/".$r->ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1673. }
  1674. }
  1675. else {
  1676. echo App::link("E", array('task'=>"CRM_PROCES", 'EDIT'=>$r->ID), array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1677. }
  1678. if ($tree->get_param('ProcesTblId') > 0) {
  1679. echo App::link("F", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('ProcesTblId')."#FILES/".$r->ID, array('title'=>'Pliki', 'class'=>'btn-p5'));
  1680. }
  1681. if (!in_array($r->TYPE, array('PROCES_GROUP_1', 'PROCES_GROUP_2'))) {
  1682. if (!$r->TEST_PYTANIE) {
  1683. echo App::link("P+", array('task'=>"CRM_TESTY_ADD_PYTANIA", 'id_proces'=>$r->ID), array('title'=>'Dodaj pytanie do testow', 'class'=>'btn-p5 btn-red'));
  1684. } else {
  1685. echo App::link("P+", array('task'=>"CRM_TESTY_ADD_PYTANIA", 'id_proces'=>$r->ID), array('title'=>'Dodaj pytanie do testow', 'class'=>'btn-p5'));
  1686. if (!empty($pytania)) {
  1687. foreach ($pytania as $pytanie) {
  1688. if ($tree->get_param('rozwin_proces') && $pytanie->ID_WSKAZNIK != 0) {
  1689. continue;
  1690. }
  1691. $odpowiedzi = array();
  1692. for ($i = 0; $i < 5; $i++) {
  1693. $fldTxt = "ODP_{$i}";
  1694. $fldOdp = "ODP_{$i}_ODP";
  1695. if (!empty($pytanie->{$fldTxt})) {
  1696. if ($pytanie->{$fldOdp} == 'TAK') {
  1697. $odpowiedzi[] = '<span class="text-success">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
  1698. } else {
  1699. $odpowiedzi[] = '<span class="text-error">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
  1700. }
  1701. }
  1702. }
  1703. $popupIcon = ($pytanie->TEST_TYPE=='TEORETYCZNY')? 'glyphicon glyphicon-question-sign' : 'glyphicon glyphicon-exclamation-sign';
  1704. $popupLink = "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$tblPytaniaId}&task=CRM_PROCES#EDIT/{$pytanie->ID}";// TODO: add rand _hash?
  1705. $popupTitle = "#{$pytanie->ID} " . htmlspecialchars($pytanie->PYTANIE);
  1706. $popupContent = implode('<hr style="margin:0.5em 0;">', $odpowiedzi);
  1707. ?>
  1708. <a target="_blank" href="<?php echo $popupLink; ?>"><i class="<?php echo $popupIcon; ?> wsk-help popover-with-html">
  1709. <span class="popover-heading"><?php echo $popupTitle; ?></span>
  1710. <span class="popover-body"><?php echo $popupContent; ?></span>
  1711. </i></a>
  1712. <?php
  1713. }
  1714. }
  1715. }
  1716. }
  1717. }
  1718. $bold = false;
  1719. if ((!empty($_GET['arg1']) && $_GET['arg1'] == $r->ID)
  1720. || (!empty($_GET['EDIT']) && $_GET['EDIT'] == $r->ID)
  1721. ) {
  1722. $bold = true;
  1723. }
  1724. //if ($bold) echo "***";
  1725. if ($r->IF_TRUE_GOTO > 0) {
  1726. $tree->log('show item -> fetch-proces_flag - start');
  1727. $link_out = ProcesHelper::proces_flag($r->ID, $r->IF_TRUE_GOTO, $r->IF_TRUE_GOTO_FLAG);
  1728. $tree->log('show item -> fetch-proces_flag', array('fetch-proces_flag'));
  1729. echo App::link($link_out, "#TREE".$r->IF_TRUE_GOTO, array('onclick'=>"return scrollToProces('".$r->IF_TRUE_GOTO."');", 'title'=>$r->IF_TRUE_GOTO_FLAG." ".$r->IF_TRUE_GOTO, 'class'=>'btn-p5'));
  1730. echo "<a href=procesy5.php?task=PROCES_VIEW&id_proces=".$r->IF_TRUE_GOTO.">&gt;&gt;</a>";
  1731. if (empty($r->DESC)) {
  1732. $sql = "select `DESC`,`OPIS` from CRM_PROCES where ID='".$r->IF_TRUE_GOTO."' limit 1";
  1733. $rs = DB::query($sql);
  1734. while ($h = DB::fetch($rs)) {
  1735. echo "<font color=grey><b>".$h->DESC."</b>";
  1736. if ($tree->get_param('rozwin_opis') && $h->OPIS) echo ' '.$h->OPIS;
  1737. echo "</font>";
  1738. }
  1739. }
  1740. }
  1741. if ($r->has_childrens) {
  1742. if (!$tree->get_param('rozwin')) {
  1743. $js = "return " . $tree->js_tree_open_rec_fun . "(this," . $r->ID . ");";
  1744. //echo'<a class="open-rec" href="#" onclick="'.$js.'">'."L".'</a>';
  1745. echo App::link("L", '#', array('title'=>'Rozwin wszystko', 'class'=>'btn-p5 open-rec', 'onclick'=>$js));
  1746. }
  1747. }
  1748. echo'<span class="desc">';
  1749. $cls = ($proces_type_css_class)? ' class="desc-'.$proces_type_css_class.'"' : '';
  1750. echo'<b'.$cls.'>'.$r->DESC.'</b>';
  1751. {// status ico
  1752. if ($r->TYPE == 'PROCES_INIT') {
  1753. $status_ico = ($r->A_STATUS == 'NORMAL')? "icon/status-ok.gif" : "icon/status-notok.gif";
  1754. echo'<img src="'.$status_ico.'" alt="'.$r->A_STATUS.'" width="16" title="'."Status: ".$r->A_STATUS." ".$r->L_APPOITMENT_DATE.'" style="vertical-align:middle;cursor:help" />';
  1755. echo "<a href=?task=PROCES_VIEW&id_proces=".$r->ID."&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1>P</a>";
  1756. echo "<a href=?task=PROCES_VIEW_LIST&id_proces=".$r->ID."&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1>L</a>";
  1757. echo "<a href=index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&id_proces={$r->ID} target=blank>M</a>";
  1758. } else {
  1759. if ( strstr($r->TYPE,'PROCES_GROUP')) {
  1760. echo "&nbsp;<a href=?task=PROCES_VIEW_LIST&id_proces=".$r->ID."&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1>L</a>";
  1761. echo " <a href=index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&id_proces={$r->ID}&PROCES_INIT_SCAN=1 target=blank>M</a>";
  1762. }
  1763. }
  1764. }
  1765. //if ($bold) echo "***";
  1766. if ($tree->get_param('editable')) { echo App::link("Z+", "index.php?MENU_INIT=PROCES_ADD_ZASOB&procesID=".$r->ID, array('title'=>'Dodaj', 'class'=>'btn-p5'));
  1767. echo App::link("↵+", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('ProcesTblId')."&ff_PARENT_ID=".$r->ID."#CREATE", array('class'=>'btn-p5', 'title'=>'Dodaj dziecko', 'onclick'=>null));
  1768. }
  1769. $opis_before = ''; $opis_after = '';
  1770. $tbl = 'CRM_PROCES';
  1771. if ($tree->get_param('filtr_img')) {
  1772. if ($r->A_HAS_IMAGE) {
  1773. echo'<br />';
  1774. $imgSize = (V::get('show_big_img', '', $_GET))? '600x600' : '200x200';
  1775. for ($i = 0; $i < $r->A_HAS_IMAGE; $i++) {
  1776. $opis_before .= '<a href="'."?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=".$tbl."&id=".$r->ID."&number=".$i.'" target="_blank" class="lightbox">';
  1777. $opis_before .= '<img src="'."?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=".$tbl."&id=".$r->ID."&number=".$i."&resize={$imgSize}".'" style="float:left" />';
  1778. $opis_before .= '</a>';
  1779. }
  1780. }
  1781. if ($opis_before != '') $opis_after = '<br style="clear:both"/>';
  1782. }
  1783. echo' <span class="more-desc">';
  1784. echo $opis_before;
  1785. if ($tree->get_param('rozwin_opis') && $r->OPIS) {
  1786. echo ' '.$r->OPIS;
  1787. }
  1788. else if (!empty($r->OPIS)) {
  1789. ?>
  1790. <i class="glyphicon glyphicon-info-sign wsk-help popover-with-html">
  1791. <span class="popover-heading"><?php echo "[{$r->ID}] " . $r->DESC; ?></span>
  1792. <span class="popover-body"><?php echo $r->OPIS; ?></span>
  1793. </i>
  1794. <?php
  1795. }
  1796. echo $opis_after;
  1797. echo '</span>';
  1798. echo'</span>';
  1799. $tbl = 'CRM_PROCES';
  1800. if ($tree->get_param('filtr_img')) {
  1801. if ($r->A_HAS_IMAGE || $tree->get_param('editable')) {
  1802. echo' <span class="external-ids">{';
  1803. for ($i = 0; $i < $r->A_HAS_IMAGE; $i++) {
  1804. echo App::link("I", array('function_init'=>'fun_SHOW_EXTERNAL_IMAGE', 'tbl'=>$tbl,'id'=>$r->ID, 'number'=>$i), array('target'=>'_blank', 'title'=>"Zdjecie ".($i+1), 'iconBootstrap'=>'glyphicon glyphicon-camera', 'class'=>'lightbox'));
  1805. //echo'<img src="'."?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=".$tbl."&id=".$r->ID."&number=".$i."&resize=200x200".'" />';
  1806. }
  1807. if ($tree->get_param('editable')) echo App::link("+", "?function_init=fun_IMAGE_ADD&tbl=".$tbl."&id=".$r->ID, array('target'=>'_blank', 'title'=>"Dodaj zdjecia", 'iconBootstrap'=>'glyphicon glyphicon-plus'));
  1808. echo'}</span>';
  1809. }
  1810. }
  1811. if (!empty($wsk)) echo'</div>';// .has_wsk
  1812. echo'</dt>'."\n";
  1813. if (!empty($wsk)) {
  1814. $zasoby_id = array();
  1815. echo'<dd>';
  1816. echo'<ul>';
  1817. if (V::get('group_stanowiska', '', $_GET)) {
  1818. $wsk_stanowiska = array();
  1819. $wsk_inne = array();
  1820. foreach ($wsk as $w) {
  1821. if ($w->TYPE == 'STANOWISKO') {
  1822. $wsk_stanowiska[] = $w;
  1823. } else {
  1824. $wsk_inne[] = $w;
  1825. }
  1826. }
  1827. $wsk = array();
  1828. if (!empty($wsk_stanowiska)) {
  1829. $wsk[] = $wsk_stanowiska;
  1830. }
  1831. if (!empty($wsk_inne)) {
  1832. foreach ($wsk_inne as $w) {
  1833. $wsk[] = $w;
  1834. }
  1835. }
  1836. }
  1837. $wsk_cnt = count( $wsk );
  1838. foreach ($wsk as $w) {
  1839. if (is_array($w)) {// if $_GET['group_stanowiska']
  1840. $stanowiska = array();
  1841. foreach ($w as $vStanowisko) {
  1842. $stanowiska[] = "[{$vStanowisko->ID}] {$vStanowisko->DESC}";
  1843. }
  1844. echo '<li'.((--$wsk_cnt)? '' : ' class="tree-last"').'>';
  1845. echo '<p>';
  1846. echo ' <span class="btn-box btn-box-silver">'."STANOWISKA:".'</span>';
  1847. echo ' <b>' . implode(', ', $stanowiska) . '</b> ';
  1848. echo '</p>';
  1849. echo '</li>';
  1850. continue;
  1851. }
  1852. $w_parents_out = '';
  1853. $w_title_parents_out = '';
  1854. if ($tree->get_param('rozwin_zasoby')) {
  1855. $tree->log('show item -> fetch-get_all_parents - start');
  1856. $w->_parents = TreeHelper::get_all_parents( 'CRM_LISTA_ZASOBOW', $w->PARENT_ID );
  1857. $tree->log('show item -> fetch-get_all_parents', array('fetch-get_all_parents'));
  1858. $w_parents_out = array();
  1859. foreach ($w->_parents as $w_p_id => $w_p) {
  1860. $w_parents_out[] = '[<b>'.$w_p->ID.'</b> '.$w_p->TYPE.' '.$w_p->DESC.']';
  1861. $w_title_parents_out[] = ''.$w_p->ID.' '.$w_p->TYPE.' '.$w_p->DESC.'';
  1862. }
  1863. $w_parents_out = ' <span class="wsk_parents">'.implode(' / ', $w_parents_out).'</span>';
  1864. $w_title_parents_out = (!empty($w_title_parents_out))? implode(' / ', $w_title_parents_out) : '';
  1865. }
  1866. echo'<li'.((--$wsk_cnt)? '' : ' class="tree-last"').'>';
  1867. if ('INHERIT' == $w->ACL_TYPE) {
  1868. UI::startTag('p', ['style' => "color:#aaa", 'title' => "Stanowiska dziedziczone z procesu/ów wywołujących (GOTO)"]);
  1869. UI::tag('span', ['title' => $w_title_parents_out], "[{$w->ID}]");
  1870. echo " {$w->TYPE} ";
  1871. UI::tag('span', [], $w->DESC);
  1872. UI::endTag('p');
  1873. continue;
  1874. } else {
  1875. }
  1876. echo'<p>';
  1877. // echo ' <span class="btn-box btn-box-silver">'.$w->CW_ID.'</span>';
  1878. ('GROUP' == $w->ACL_TYPE)
  1879. ? UI::startTag('p', ['style' => "color:#daa520"])
  1880. : UI::startTag('p', []);
  1881. ('GROUP' == $w->ACL_TYPE)
  1882. ? UI::tag('span', ['style' => "color:#daa520", 'title' => $w_title_parents_out], "[{$w->ID}]")
  1883. : UI::tag('span', ['class' => "green", 'title' => $w_title_parents_out], "[{$w->ID}]");
  1884. if ($tree->get_param('editable')) {
  1885. echo App::link("<b>^</b>", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=>$w->CW_ID, 'arg1_val'=>'upup','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore o 5 pol"));
  1886. echo App::link("^", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=>$w->CW_ID, 'arg1_val'=>'up','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore"));
  1887. echo App::link("v", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=> $w->CW_ID, 'arg1_val'=>'dw','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w dol"));
  1888. echo App::link("V", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=> $w->CW_ID, 'arg1_val'=>'downdown','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w dol o 5 pol"));
  1889. echo' ';
  1890. if ($tree->get_param('WskaznikTblId')) {
  1891. echo App::link("E", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('WskaznikTblId')."#EDIT/".$w->CW_ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1892. } else {
  1893. echo App::link("E", "?task=CRM_EDIT_CRM_WSKAZNIK&EDIT=".$w->CW_ID."&ID=".$w->CW_ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  1894. }
  1895. if ($tree->get_param('ZasobTblId') > 0) {
  1896. echo App::link("F", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('ZasobTblId')."#FILES/".$w->ID, array('title'=>'Pliki', 'class'=>'btn-p5'));
  1897. }
  1898. }
  1899. if (!empty($pytania)) {
  1900. foreach ($pytania as $pytanie) {
  1901. if ($pytanie->ID_WSKAZNIK != $w->CW_ID) {
  1902. continue;
  1903. }
  1904. $odpowiedzi = array();
  1905. for ($i = 0; $i < 5; $i++) {
  1906. $fldTxt = "ODP_{$i}";
  1907. $fldOdp = "ODP_{$i}_ODP";
  1908. if (!empty($pytanie->{$fldTxt})) {
  1909. if ($pytanie->{$fldOdp} == 'TAK') {
  1910. $odpowiedzi[] = '<span class="text-success">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
  1911. } else {
  1912. $odpowiedzi[] = '<span class="text-error">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
  1913. }
  1914. }
  1915. }
  1916. $popupIcon = ($pytanie->TEST_TYPE=='TEORETYCZNY')? 'glyphicon glyphicon-question-sign' : 'glyphicon glyphicon-exclamation-sign';
  1917. $popupLink = "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$tblPytaniaId}&task=CRM_PROCES#EDIT/{$pytanie->ID}";// TODO: add rand _hash?
  1918. $popupTitle = "#{$pytanie->ID} " . htmlspecialchars($pytanie->PYTANIE);
  1919. $popupContent = implode('<hr style="margin:0.5em 0">', $odpowiedzi);
  1920. ?>
  1921. <a target="_blank" href="<?php echo $popupLink; ?>"><i class="<?php echo $popupIcon; ?> wsk-help popover-with-html">
  1922. <span class="popover-heading"><?php echo $popupTitle; ?></span>
  1923. <span class="popover-body"><?php echo $popupContent; ?></span>
  1924. </i></a>
  1925. <?php
  1926. }
  1927. }
  1928. if (!empty($w->CP_FORM_TREAT)) echo' <span title="'.$w->CP_PYTANIE.' '.$w->CP_OPIS.'" style="color:#999">'.str_replace(',', '', $w->CP_FORM_TREAT).'</span>';
  1929. echo ' '.$w->TYPE.'';
  1930. echo ' <b>'.$w->DESC.'</b> ';
  1931. if ($tree->get_param('editable')) {
  1932. $js_onclick = "if(!confirm('Czy na pewno usunac wskaznik ".$w->CW_ID." do zasobu ".$w->ID." w procesie ".$r->ID."?')){return false;}";
  1933. echo App::link("Z-", "?task=CRM_DEL_CRM_WSKAZNIK&ID=".$w->CW_ID, array('title'=>'Usun', 'class'=>'btn-p5', 'onclick'=>$js_onclick));
  1934. }
  1935. if ($tree->get_param('filtr_img')) {
  1936. // wskaznik images
  1937. $tbl = 'CRM_WSKAZNIK';
  1938. if ($w->CW_A_HAS_IMAGE > 0 || $tree->get_param('editable')) {
  1939. for ($i = 0; $i < $w->CW_A_HAS_IMAGE; $i++) {
  1940. echo App::link("I", array('function_init'=>'fun_SHOW_EXTERNAL_IMAGE', 'tbl'=>$tbl,'id'=>$w->CW_ID, 'number'=>$i), array('target'=>'_blank', 'title'=>"Zdjecie ".($i+1), 'iconBootstrap'=>'glyphicon glyphicon-camera', 'class'=>'lightbox'));
  1941. }
  1942. if ($tree->get_param('editable')) echo App::link("+", "?function_init=fun_IMAGE_ADD&tbl=".$tbl."&id=".$w->CW_ID, array('target'=>'_blank', 'title'=>"Dodaj zdjecia", 'iconBootstrap'=>'glyphicon glyphicon-plus'));
  1943. }
  1944. // zasob images
  1945. $tbl = 'CRM_LISTA_ZASOBOW';
  1946. if ($w->A_HAS_IMAGE) {
  1947. for ($i = 0; $i < $w->A_HAS_IMAGE; $i++) {
  1948. echo App::link("I", array('function_init'=>'fun_SHOW_EXTERNAL_IMAGE', 'tbl'=>$tbl,'id'=>$w->ID, 'number'=>$i), array('target'=>'_blank', 'title'=>"Zdjecie ".($i+1), 'iconBootstrap'=>'glyphicon glyphicon-camera', 'class'=>'lightbox'));
  1949. }
  1950. }
  1951. // show video link if file is movie type
  1952. if ($w->TYPE == 'PLIK') {
  1953. $movieExtAllowed = array('avi', 'mov', 'm4v');
  1954. $movieExt = explode('.', $w->DESC);
  1955. $movieExt = end($movieExt);
  1956. if (in_array($movie_ext, $movieExtAllowed)) {
  1957. //echo App::link("V", array('function_init'=>'fun_SHOW_VIDEO','id'=>$w->ID), array('target'=>'_blank', 'title'=>"Film", 'ico'=>'video', 'class'=>''));//lightbox video
  1958. }
  1959. }
  1960. }
  1961. if ($tree->get_param('rozwin_opis')) {
  1962. if ($w->TYPE == 'STANOWISKO') {
  1963. if (!empty($w->OPIS)) {
  1964. if (strlen($w->OPIS) > 300) {
  1965. ?>
  1966. <!-- Button to trigger modal -->
  1967. <a href="#wsk-<?php echo $w->CW_ID; ?>-Modal" class="wsk-long-desc" data-toggle="modal">
  1968. <i class="glyphicon glyphicon-info-sign" title="Opis stanowiska"></i>
  1969. </a>
  1970. <!-- Modal -->
  1971. <div id="wsk-<?php echo $w->CW_ID; ?>-Modal" class="wsk-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="wsk-<?php echo $w->CW_ID; ?>-ModalLabel" aria-hidden="true">
  1972. <div class="modal-dialog">
  1973. <div class="modal-content">
  1974. <div class="modal-header">
  1975. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  1976. <h3 id="wsk-<?php echo $w->CW_ID; ?>-ModalLabel"><?php echo "[{$w->CW_ID}] {$w->DESC}"; ?></h3>
  1977. </div>
  1978. <div class="modal-body">
  1979. <?php echo $w->OPIS; ?>
  1980. </div>
  1981. <div class="modal-footer">
  1982. <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Zamknij</button>
  1983. </div>
  1984. </div>
  1985. </div>
  1986. </div>
  1987. <?php
  1988. } else {
  1989. ?>
  1990. <i class="glyphicon glyphicon-info-sign wsk-help popover-with-html">
  1991. <span class="popover-heading"><?php echo "[{$w->CW_ID}] " . $w->OPIS; ?></span>
  1992. <span class="popover-body"><?php echo $w->OPIS_ZASOB; ?></span>
  1993. </i>
  1994. <?php
  1995. }
  1996. }
  1997. } else {
  1998. echo ' <span class="green">'.$w->OPIS.'</span>';// opis zasobu
  1999. }
  2000. }
  2001. if ($tree->get_param('rozwin_opis')) {
  2002. echo ' <span style="color:#000;">'.$w->OPIS_ZASOB.'</span>';// komentarz wskaznika
  2003. }
  2004. else if (!empty($w->OPIS_ZASOB)) {
  2005. ?>
  2006. <i class="glyphicon glyphicon-info-sign wsk-help popover-with-html">
  2007. <span class="popover-heading"><?php echo "[" . $w->CW_ID . "] " . $w->OPIS; ?></span>
  2008. <span class="popover-body"><?php echo "[{$w->ID}]" . $w->OPIS_ZASOB; ?></span>
  2009. </i>
  2010. <?php
  2011. }
  2012. if ($show_form) $zasoby_id[$w->TYPE][$w->ID] = $w->CW_ID;
  2013. if ($tree->get_param('rozwin_zasoby')) {
  2014. echo $w_parents_out;
  2015. }
  2016. echo'</p>';
  2017. echo'</li>';
  2018. }
  2019. echo'</ul>';
  2020. if(0) {// TODO: grupuj zasoby
  2021. echo'<hr />';
  2022. $zasoby_id = array();
  2023. $wsk_cnt = count( $wsk );
  2024. echo'<pre style="max-height:100px;overflow:auto;border:1px solid red;">wsk = ';print_r($wsk);echo'</pre>';
  2025. // TEST parents
  2026. $wsk_parents = array();
  2027. $max_deep = 0;// max parents deep
  2028. foreach ($wsk as $k_wsk_id => $w) {
  2029. $wsk_parents_cur = array_reverse(array_keys($w->_parents));
  2030. $wsk_parents_cur[] = $w->ID;
  2031. if (count($wsk_parents_cur) > $max_deep) $max_deep = count($wsk_parents_cur);
  2032. $wsk_parents_cur ['wsk_id'] = $k_wsk_id;
  2033. $wsk_parents[] = $wsk_parents_cur;
  2034. echo'parents ['.implode(',', $wsk_parents_cur).']<br />';
  2035. }
  2036. $wsk_parents_cnt = count($wsk_parents);
  2037. echo'<pre style="max-height:100px;overflow:auto;border:1px solid red;">parents('.$wsk_parents_cnt.'); max_deep('.$max_deep.'); wsk_parents = ';print_r($wsk_parents);echo'</pre>';
  2038. $zasoby_id = array();
  2039. foreach ($wsk as $k_wsk_id => $w) {
  2040. $zasoby_id [$w->ID] =& $wsk[$k_wsk_id];
  2041. foreach ($w->_parents as $k_z_id => $z) {
  2042. $zasoby_id [$k_z_id] =& $wsk[$k_wsk_id]->_parents[$k_z_id];
  2043. }
  2044. }
  2045. $wsk_parents_map = array();// table td: rowspan, colspan, wsk_id
  2046. /*
  2047. for ($x = 0, $last_x = 0, $last_y = 0; $x < $max_deep; $x++, $last_x = $x) {
  2048. for ($y = 0; $y < $wsk_parents_cnt; $y++) {
  2049. $z_id = 'x';
  2050. if (isset($wsk_parents[$y][$x])) {
  2051. $z_id = $wsk_parents[$y][$x];
  2052. }
  2053. $wsk_parents_map[$y][$x] = array('rowspan'=>1, 'colspan'=>1, 'z_id'=>$z_id);// default content is 'x'
  2054. }
  2055. }
  2056. */
  2057. for ($y = 0, $last_y = 0, $last_x = 0; $y < $wsk_parents_cnt; $y++, $last_y = $y) {
  2058. for ($x = 0; $x < $max_deep; $x++) {
  2059. $z_id = 'x';
  2060. $wsk_parents_map[$y][$x] = array('rowspan'=>1, 'colspan'=>1, 'z_id'=>$z_id);// default content is 'x'
  2061. if (isset($wsk_parents[$y][$x])) {
  2062. $wsk_parents_map[$y][$x]['z_id'] = $wsk_parents[$y][$x];
  2063. } else if ($x > 0 && $wsk_parents_map[$y][$x - 1]['z_id'] != 'x') {
  2064. //$wsk_parents_map[$y][$x - 1]['z_id'] = 'x';
  2065. $wsk_parents_map[$y][$x - 1]['wsk_id'] = $wsk_parents[$y]['wsk_id'];
  2066. }
  2067. }
  2068. // dodaj wsk_id do ostatniego elementu
  2069. $x = $max_deep - 1;
  2070. if ($wsk_parents_map[$y][$x]['z_id'] != 'x') {
  2071. $wsk_parents_map[$y][$x]['wsk_id'] = $wsk_parents[$y]['wsk_id'];
  2072. }
  2073. }
  2074. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">1:wsk_parents_map = ';print_r($wsk_parents_map);echo'</pre>';
  2075. // set rowspan
  2076. for ($x = 0, $last_x = 0; $x < $max_deep; $x++, $last_x = $x) {
  2077. for ($y = 1, $last_y = 0; $y < $wsk_parents_cnt; $y++) {
  2078. $last_cell_map =& $wsk_parents_map[$last_y][$x];
  2079. $curr_cell_map =& $wsk_parents_map[$y][$x];
  2080. if ($last_cell_map['z_id'] != $curr_cell_map['z_id']) {
  2081. $last_y = $y;
  2082. } else if (isset($last_cell_map['wsk_id'])) {
  2083. $last_y = $y;
  2084. } else {
  2085. $curr_cell_map['z_id'] = 'x';
  2086. $last_cell_map['rowspan'] += 1;
  2087. }
  2088. }
  2089. }
  2090. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">2:wsk_parents_map = ';print_r($wsk_parents_map);echo'</pre>';
  2091. // set colspan
  2092. for ($y = 0, $last_y = 0; $y < $wsk_parents_cnt; $y++, $last_y = $y) {
  2093. for ($x = 1, $last_x = 0; $x < $max_deep; $x++) {
  2094. $last_cell_map =& $wsk_parents_map[$y][$last_x];
  2095. $curr_cell_map =& $wsk_parents_map[$y][$x];
  2096. if ($curr_cell_map['z_id'] == 'x') {
  2097. $curr_cell_map['z_id'] = 'x';
  2098. $last_cell_map['colspan'] += 1;
  2099. } else {
  2100. $last_x = $x;
  2101. }
  2102. }
  2103. }
  2104. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">wsk_parents_map = ';print_r($wsk_parents_map);echo'</pre>';
  2105. /*
  2106. foreach ($wsk_parents as $k_i => $v_map) {
  2107. $last_p_id = 0; $last_map_ind = -1;
  2108. foreach ($v_map as $wsk_i => $parent_id) {
  2109. if ($last_map_ind == -1) {
  2110. $last_map_ind = 0;
  2111. $wsk_parents_map[$k_i][$last_map_ind] = array('p_id'=>$parent_id, 'rowspan'=>1);
  2112. } else if ($last_p_id != $parent_id) {
  2113. $last_map_ind++;
  2114. $wsk_parents_map[$k_i][$last_map_ind] = array('p_id'=>$parent_id, 'rowspan'=>1);
  2115. } else {
  2116. $wsk_parents_map[$k_i][$last_map_ind]['rowspan'] += 1;
  2117. }
  2118. $last_p_id = $parent_id;
  2119. }
  2120. }
  2121. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">wsk_parents_map = ';print_r($wsk_parents_map);echo'</pre>';
  2122. */
  2123. /*
  2124. parents [27,35,57,79 ]
  2125. parents [27,35,57,79 ]
  2126. parents [27,14,31,355,1070,2365]
  2127. parents [27,35,57,79 ]
  2128. wsk_parents_map = Array(
  2129. [0] => Array(
  2130. [0] => Array(
  2131. [p_id] => 27
  2132. [rowspan] => 3
  2133. <table>
  2134. <tr>
  2135. <td rowspan=4> 27 </td>
  2136. <td rowspan=2> 35 </td>
  2137. <td rowspan=2> 57 </td>
  2138. <td rowspan=2> 79 </td>
  2139. </tr>
  2140. <tr>
  2141. <td> 14 </td>
  2142. <td> 31 </td>
  2143. <td> 355 </td>
  2144. </tr>
  2145. <tr>
  2146. <td> 27 </td>
  2147. <td> 35 </td>
  2148. <td> 57 </td>
  2149. </tr>
  2150. </table>
  2151. */
  2152. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">zasoby_id: ';print_r($zasoby_id);echo'</pre>';
  2153. echo'<table class="tbl-wsk-view" border="1">';
  2154. echo'<tbody>';
  2155. foreach ($wsk_parents_map as $k_map_y => $v_map_line) {
  2156. $out_row = '';
  2157. foreach ($v_map_line as $k_map_x => $v_map) {
  2158. if ($v_map['z_id'] == 'x') {
  2159. continue;
  2160. }
  2161. $cls = '';
  2162. $out_zasob = '';
  2163. $out_rowspan = ($v_map['rowspan'] > 1)? ' rowspan="'.$v_map['rowspan'].'"' : '';
  2164. $out_colspan = ($v_map['colspan'] > 1)? ' colspan="'.$v_map['colspan'].'"' : '';
  2165. {// get zasob info
  2166. //[TYPE] => NARZEDZIE
  2167. //[DESC] => SUPEREDIT-WWW
  2168. //[OPIS] => http://se.dev.webone.pl/
  2169. $curr_z = V::get($v_map['z_id'], null, $zasoby_id);
  2170. if (!$curr_z) {
  2171. $out_zasob .= 'error brak zasobu {'.$v_map['z_id'].'}';
  2172. } else {
  2173. $out_zasob_title = array();
  2174. $out_zasob_title[] = V::get('DESC', '', $curr_z);
  2175. $out_zasob_title[] = V::get('OPIS', '', $curr_z);
  2176. $out_zasob_title = ''.implode(' ', $out_zasob_title).'';
  2177. $out_zasob .= '<b class="btn-box btn-box-green" title="'.$out_zasob_title.'">'.$v_map['z_id'].'</b>';
  2178. }
  2179. }
  2180. if (isset($v_map['wsk_id'])) {
  2181. $curr_wsk = V::get($v_map['wsk_id'], null, $wsk);
  2182. if (!$curr_wsk) {
  2183. $out_zasob .= 'error brak wskaznika {'.$v_map['wsk_id'].'}';
  2184. } else {
  2185. $out_zasob_opis = V::get('OPIS_ZASOB', '', $curr_wsk);
  2186. $out_zasob .= ' <b class="btn-box" title="'."Wskaznik [".$v_map['wsk_id']."]".'">'.$v_map['wsk_id'].'</b>';
  2187. // TODO: if edit, etc.
  2188. $out_zasob .= ' '.$out_zasob_opis;
  2189. }
  2190. //$out_row .= '<td'.$out_rowspan.''.$out_colspan.'>'.$out_zasob.'</td>';
  2191. $cls = ' class="wsk-cell"';
  2192. }
  2193. $out_row .= '<td'.$cls.''.$out_rowspan.''.$out_colspan.'>'.$out_zasob.'</td>';
  2194. }
  2195. if ($out_row) {
  2196. echo'<tr>';
  2197. echo $out_row;
  2198. echo'</tr>';
  2199. }
  2200. }
  2201. echo'</tbody>';
  2202. echo'</table>';
  2203. }// grupuj zasoby
  2204. if ($show_form) {
  2205. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">zasoby_id = ';print_r($zasoby_id);echo'</pre>';
  2206. if (!empty($zasoby_id['KOMORKA'])) {
  2207. $komorki = array();
  2208. foreach ($zasoby_id['KOMORKA'] as $z_id => $w_id) {
  2209. $komorki[] = $wsk[ $w_id ];
  2210. }
  2211. DEBUG_S(4,'komorki',$komorki, __FILE__, __FUNCTION__, __LINE__);
  2212. // zasoby pobierz info o komorkach: tabela, baza danych; host,login,passwd z configa
  2213. // BAZA_DANYCH -> TABELA -> KOMORKA
  2214. $zasoby_tabele = array();
  2215. $zasoby_db_conf = array();
  2216. $sql = "select
  2217. z.ID as KOMORKA_ID
  2218. , z.DESC as KOMORKA_DESC
  2219. , z.OPIS as KOMORKA_OPIS
  2220. , z2.ID as TABELA_ID
  2221. , z2.DESC as TABELA_DESC
  2222. , z2.OPIS as TABELA_OPIS
  2223. , z3.ID as DB_ID
  2224. , z3.DESC as DB_DESC
  2225. , z3.OPIS as DB_OPIS
  2226. from `CRM_LISTA_ZASOBOW` as z
  2227. left join `CRM_LISTA_ZASOBOW` as z2 on(z2.`ID`=z.`PARENT_ID`)
  2228. left join `CRM_LISTA_ZASOBOW` as z3 on(z3.`ID`=z2.`PARENT_ID`)
  2229. where
  2230. z.`ID` in (".implode(',', array_keys($zasoby_id['KOMORKA'])).")
  2231. and z2.`TYPE`='TABELA'
  2232. -- and z3.`TYPE`='BAZA_DANYCH' -- lub DATABASE_MYSQL, DATABASE_MSSQL
  2233. ";
  2234. DEBUG_S(5,'sql', $sql, __FILE__, __FUNCTION__, __LINE__);
  2235. $res = DB::query( $sql );
  2236. while ($z = DB::fetch( $res )) {
  2237. $zasoby_db_conf [$z->DB_ID][] = array($z->KOMORKA_ID, $z->DB_ID, $z->DB_DESC, $z->DB_OPIS);
  2238. $zasoby_tabele [$z->TABELA_ID][] = array($z->KOMORKA_ID, $z->TABELA_ID, $z->TABELA_DESC, $z->TABELA_OPIS);
  2239. }
  2240. DEBUG_S(4,'zasoby_db_conf ['.implode(',',array_keys($zasoby_db_conf)).']', $zasoby_db_conf, __FILE__, __FUNCTION__, __LINE__);
  2241. DEBUG_S(4,'zasoby_tabele ['.implode(',',array_keys($zasoby_tabele)).']', $zasoby_tabele, __FILE__, __FUNCTION__, __LINE__);
  2242. // pogrupuj komorki wg tabel
  2243. // permy z $zasob->CW_TYP
  2244. }
  2245. }
  2246. echo'</dd>';
  2247. }
  2248. echo'</dl>'."\n";
  2249. $tree->log('show item -> end');
  2250. }
  2251. function tree_callback__show_item_from_CRM_LISTA_ZASOBOW( &$r, &$tree ) {
  2252. // TODO: btn-box zasob type from PARENT_ID
  2253. $cls = array();
  2254. if (($search_id = $tree->get_param('search_id')) > 0 && $search_id == $r->ID) {
  2255. $cls[] = 'search_id';
  2256. }
  2257. if ($tree->_table == 'CRM_LISTA_ZASOBOW') {
  2258. $cls[] = 'type-'.(($r->ALIAS_ID > 0)? 'ALIAS_ID' : $r->PARENT_TYPE);// TODO: Undefined property: stdClass::$PARENT_TYPE przy Filtr ID
  2259. }
  2260. $cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : '';
  2261. echo'<dl'.$cls.'>';
  2262. echo'<dt>';
  2263. $out_id = ($r->ID < 10)? '&nbsp;'.$r->ID.'' : $r->ID;
  2264. echo App::link($out_id, array('task'=>"CRM_LISTA_ZASOBOW", 'filtr_id'=>$r->ID, '#'=>'TREE'.$r->ID), array('class'=>'item_id btn-box'));
  2265. if ($tree->get_param('editable')) {
  2266. //echo'('.$r->SORT_PRIO.')';// TODO: DBG
  2267. echo App::link("<b>^</b>", array('task'=>'CRM_LISTA_ZASOBOW', 'function_init'=>'SORT_PRIO_ZASOB', 'arg1'=>$r->ID, 'arg1_val'=>'upup'), array('class'=>"btn-clean", 'title'=>"w gore szybko"));
  2268. echo App::link("^", array('task'=>'CRM_LISTA_ZASOBOW', 'function_init'=>'SORT_PRIO_ZASOB', 'arg1'=>$r->ID, 'arg1_val'=>'up'), array('class'=>"btn-clean", 'title'=>"w gore"));
  2269. echo App::link("v", array('task'=>'CRM_LISTA_ZASOBOW', 'function_init'=>'SORT_PRIO_ZASOB', 'arg1'=>$r->ID, 'arg1_val'=>'dw'), array('class'=>"btn-clean", 'title'=>"w dol"));
  2270. echo App::link("V", array('task'=>'CRM_LISTA_ZASOBOW', 'function_init'=>'SORT_PRIO_ZASOB', 'arg1'=>$r->ID, 'arg1_val'=>'downdown'), array('class'=>"btn-clean", 'title'=>"w dol szybko"));
  2271. echo '('.$r->SORT_PRIO.')';
  2272. }
  2273. if ($tree->get_param('editable')) {
  2274. if($tree->get_param('hasFieldPerm__ID'))
  2275. echo App::link("E", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('getZasobTableID')."#EDIT/".$r->ID, array('title'=>'Pliki', 'class'=>'btn-p5'));
  2276. else echo App::link("E", "?task=CRM_LISTA_ZASOBOW&EDIT=".$r->ID."#".$r->ID, array('title'=>'Edytuj', 'class'=>'btn-p5'));
  2277. }
  2278. if ($tree->get_param('hasFieldPerm__ID')) echo App::link("F", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('getZasobTableID')."#FILES/".$r->ID, array('title'=>'Pliki', 'class'=>'btn-p5'));
  2279. // TODO: dodaj obrazek w okienku/ajax
  2280. //if ($tree->get_param('editable')) echo App::link_ajax("+IMG", 'ajax_add_image', array('tbl'=>"CRM_LISTA_ZASOBOW", 'id'=>$r->ID), array('js_result_type'=>'popup', 'class'=>'btn-p5', 'title'=>'Dodaj zdjecie'));
  2281. if ($r->has_childrens) {
  2282. if (!$tree->get_param('rozwin')) {
  2283. $js = "return " . $tree->js_tree_open_rec_fun . "(this," . $r->ID . ");";
  2284. //echo'<a class="open-rec" href="#" onclick="'.$js.'">'."L".'</a>';
  2285. echo App::link("L", '#', array('title'=>'Rozwin wszystko', 'class'=>'btn-p5 open-rec', 'onclick'=>$js));
  2286. }
  2287. }
  2288. if(($r->minOccurs!=1)or ($r->maxOccurs!=1)) echo '('.$r->minOccurs."/".$r->maxOccurs.")";
  2289. else echo "(1)";
  2290. echo'<span class="desc">';
  2291. {
  2292. $outAliasStyle = 'color:#999';
  2293. $outAliasTitle = 'ALIAS INFO';
  2294. $outAliasLink .= '<i class="glyphicon glyphicon-share-alt"></i>';
  2295. if ($r->ALIAS_ID > 0) {
  2296. $outAliasLink .= "{$r->ALIAS_ID}";
  2297. // '<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</a>'
  2298. // '<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</a>'
  2299. if ('VIRTUAL' == $r->ALIAS_MODE) {
  2300. $outAliasStyle = 'color:#CA06E2';
  2301. $outAliasTitle = "ALIAS WIRTUALNY DO {$r->ALIAS_ID}";
  2302. } else {
  2303. $outAliasStyle = 'color:#FF6900';
  2304. $outAliasTitle = "ALIAS DO {$r->ALIAS_ID}";
  2305. }
  2306. }
  2307. echo '<span style="' . $outAliasStyle . '">
  2308. <a href="#"
  2309. style="' . $outAliasStyle . '"
  2310. title="' . $outAliasTitle . '"
  2311. data-id="' . $r->ID . '"
  2312. onclick="return showZasobAliasTooltip(this);"
  2313. >' . "{$outAliasLink}" . '</a>'
  2314. . ' <span class="alias-description"></span>'
  2315. . '</span>'
  2316. ;
  2317. }
  2318. echo '<b>'.$r->TYPE.'</b>';
  2319. $bold=false;
  2320. if ((!empty($_GET['arg1']) && $_GET['arg1'] == $r->ID)
  2321. || (!empty($_GET['EDIT']) && $_GET['EDIT']==$r->ID)
  2322. ) {
  2323. $bold = true;
  2324. }
  2325. if ($bold) echo "<b>";
  2326. echo ' '.$r->DESC;
  2327. if ($bold) echo "</b>";
  2328. echo '<font size=-3 color=grey> '.$r->DESC_PL.'</font>';
  2329. $opis_before = ''; $opis_after = '';
  2330. $tbl = 'CRM_LISTA_ZASOBOW';
  2331. if ($tree->get_param('filtr_img')) {
  2332. if ($r->A_HAS_IMAGE) {
  2333. echo'<br />';
  2334. for ($i = 0; $i < $r->A_HAS_IMAGE; $i++) {
  2335. $opis_before .= '<a href="'."?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=".$tbl."&id=".$r->ID."&number=".$i.'" target="_blank" class="lightbox">';
  2336. $opis_before .= '<img src="'."?function_init=fun_SHOW_EXTERNAL_IMAGE&tbl=".$tbl."&id=".$r->ID."&number=".$i."&resize=200x200".'" style="float:left" />';
  2337. $opis_before .= '</a>';
  2338. }
  2339. }
  2340. if ($opis_before != '') $opis_after = '<br style="clear:both"/>';
  2341. }
  2342. echo' <span class="more-desc">';
  2343. echo $opis_before;
  2344. if ($tree->get_param('rozwin_opis') && $r->OPIS) echo ' '.$r->OPIS;
  2345. echo $opis_after;
  2346. echo '</span>';
  2347. echo'</span>';
  2348. $tbl = 'CRM_LISTA_ZASOBOW';
  2349. if ($tree->get_param('filtr_img')) {
  2350. if ($r->A_HAS_IMAGE || $tree->get_param('editable')) {
  2351. echo' <span class="external-ids">{';
  2352. //echo App::link("IMG", array('function_init'=>'ajax_show_images', 'tbl'=>'CRM_LISTA_ZASOBOW','id'=>$r->ID), array('target'=>'_blank', 'title'=>"Zdjecia (".$r->A_HAS_IMAGE.")"));
  2353. //echo App::link_ajax("IMG", 'ajax_show_images', array('tbl'=>'CRM_LISTA_ZASOBOW','id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>'', 'title'=>"Zdjecia (".$r->A_HAS_IMAGE.")"));
  2354. // TODO: A_HAS_IMAGE - count images, show img icons to show image in new window
  2355. for ($i = 0; $i < $r->A_HAS_IMAGE; $i++) {
  2356. echo App::link("I", array('function_init'=>'fun_SHOW_EXTERNAL_IMAGE', 'tbl'=>$tbl,'id'=>$r->ID, 'number'=>$i), array('target'=>'_blank', 'title'=>"Zdjecie ".($i+1), 'iconBootstrap'=>'glyphicon glyphicon-camera', 'class'=>'lightbox'));
  2357. }
  2358. if ($tree->get_param('editable')) echo App::link("+", "?function_init=fun_IMAGE_ADD&tbl=".$tbl."&id=".$r->ID, array('target'=>'_blank', 'title'=>"Dodaj zdjecia", 'iconBootstrap'=>'glyphicon glyphicon-plus'));
  2359. echo'}</span>';
  2360. }
  2361. }
  2362. if ($tree->get_param('editable')) {
  2363. // TODO: check table
  2364. $allowed_check_database = array();
  2365. $allowed_check_database[] = 'BAZA_DANYCH';
  2366. $allowed_check_database[] = 'DATABASE_MYSQL';
  2367. $allowed_check_database[] = 'DATABASE_MSSQL';
  2368. if ($r->TYPE == 'TABELA') {
  2369. //echo'{';
  2370. //echo App::link_ajax("check", "ajax_zasob_check_table", array('zasob_id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>''));
  2371. //echo'}';
  2372. }
  2373. else if (in_array($r->TYPE, $allowed_check_database)) {
  2374. //echo'{';
  2375. //echo App::link_ajax("check", "ajax_zasob_check_db", array('zasob_id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>''));
  2376. //echo'}';
  2377. }
  2378. }
  2379. // obowiazki
  2380. if ($tree->get_param('filtr_ob')) {
  2381. echo' <span class="external-ids">{';
  2382. echo App::link_ajax("OB", "ajax_zasob_get_obowiazki", array('zasob_id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>'', 'title'=>"Obowiazki"));
  2383. echo'}</span>';
  2384. }
  2385. // get external ids
  2386. if ($tree->get_param('filtr_ids')) {
  2387. if (in_array($r->TYPE, array('STANOWISKO', 'DZIAL', 'PODMIOT'))) {
  2388. echo '<span class="external-ids">' . "{";
  2389. echo App::link_ajax("kontakty", "ajax_zasob_stanowisko_search_kontakty", array('zasob_id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>''));
  2390. echo "}" . '</span>';
  2391. } else {
  2392. $external_ids_allowed_type = array();
  2393. $external_ids_allowed_type[] = 'NARZEDZIE';
  2394. $external_ids_allowed_type[] = 'TELBOX';
  2395. $external_ids_allowed_type[] = 'URZADZENIE';
  2396. $external_ids_allowed_type[] = 'SERWER';
  2397. $external_ids_allowed_type[] = 'SEGREGATOR';
  2398. $external_ids_allowed_type[] = 'MAGAZYN';
  2399. $external_ids_allowed_type[] = 'POMIESZCZENIE';
  2400. $external_ids_allowed_type[] = 'ALARM-SATEL';
  2401. $external_ids_allowed_type[] = 'DOSTEP-ZAMEK';
  2402. $external_ids_allowed_type[] = 'DOSTEP-KLUCZ';
  2403. $external_ids_allowed_type[] = 'SZAFA';
  2404. $external_ids_allowed_type[] = 'PIECZATKA';
  2405. $external_ids_allowed_type[] = 'MATERIAL_REKLAMOWY';
  2406. $external_ids_allowed_type[] = 'INNE';
  2407. $external_ids_allowed_type[] = 'DANE';
  2408. $external_ids_allowed_type[] = 'SIP_ACCOUNT';
  2409. $external_ids_allowed_type[] = 'PODMIOT';
  2410. $external_ids_allowed_type[] = 'URZADZENIA_I_OZNACZENIA_BHP';
  2411. $external_ids_allowed_type[] = 'SOFTWARE';
  2412. $external_ids_allowed_type[] = 'WYPOSAZENIE_LOKALU';
  2413. $external_ids_allowed_type[] = 'KUWETA';
  2414. $external_ids_allowed_type[] = 'DOSTEP-UPRAWNIENIA';
  2415. $external_ids_allowed_type[] = 'APLIKACJA';
  2416. $external_ids_allowed_type[] = 'LOKALIZACJA';
  2417. $external_ids_allowed_type[] = 'KOMPUTER';
  2418. $external_ids_allowed_type[] = 'MATERIAL_EKSPLOATACYJNY';
  2419. $external_ids_allowed_type[] = 'SOFTWARE';
  2420. $external_ids_allowed_type[] = 'OBSZAR';
  2421. $external_ids_allowed_type[] = 'REWIR';
  2422. $external_ids_allowed_type[] = 'DOKUMENTY';
  2423. $external_ids_allowed_type[] = 'SEJF';
  2424. $external_ids_allowed_type[] = 'DOSTEP-UPRAWNIENIA';
  2425. $external_ids_allowed_type[] = 'PLYTA_CD';
  2426. $external_ids_allowed_type[] = 'PROJEKT';
  2427. $external_ids_allowed_type[] = 'SPRAWA';
  2428. $external_ids_allowed_type[] = 'DOSTEP-KARTA';
  2429. $external_ids_allowed_type[] = 'OZNACZENIE_LOKALIZACJI';
  2430. $external_ids_allowed_type[] = 'DOSTEP-ZAMEK-ELEKTRONICZNY';
  2431. $external_ids_allowed_type[] = 'POLKA';
  2432. $external_ids_allowed_type[] = 'LOKALIZACJA_USLUGI';
  2433. $external_ids_allowed_type[] = 'SERVICE_POINT';
  2434. $external_ids_allowed_type[] = 'OFFER_GROUP';
  2435. $external_ids_allowed_type[] = 'OFFER';
  2436. $external_ids_allowed_type[] = 'OFFER_COSTS_GROUP';
  2437. $external_ids_allowed_type[] = 'OFFER_COST';
  2438. if (in_array($r->TYPE, $external_ids_allowed_type)) {
  2439. echo '<span class="external-ids">' . "{";
  2440. echo App::link_ajax("get IDS", "ajax_zasob_search_external_ids", array('zasob_id'=>$r->ID), array('js_result_type'=>'override', 'js_result'=>''));
  2441. echo "}" . '</span>';
  2442. }
  2443. }
  2444. }
  2445. if($tree->get_param('editable'))
  2446. echo App::link("↵+", "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$tree->get_param('getZasobTableID')."&ff_PARENT_ID=".$r->ID."#CREATE", array('class'=>'btn-p5', 'title'=>'Dodaj dziecko', 'onclick'=>null));
  2447. echo'</dt>';
  2448. echo'</dl>'."\n";
  2449. }
  2450. // ========== typespecial functions
  2451. // function typespecial_{$FUN}( $field_name, $cmd, $value, $attrs = array() ) {
  2452. // switch ($cmd) {
  2453. // case 'show': {// show field in form
  2454. // $out = '';
  2455. // return $out;
  2456. // }
  2457. // break;
  2458. // case 'update': {// return field value
  2459. // return $value;
  2460. // }
  2461. // break;
  2462. // default:
  2463. //
  2464. // }
  2465. // }
  2466. function typespecial_L_APPOITMENT_USER($field_name, $cmd, $user_value, $attrs = array()) {
  2467. static $_users_list;
  2468. if (!$_users_list) {
  2469. $_users_list = array();
  2470. $sql = "select u.*
  2471. from `ADMIN_USERS` as u
  2472. where
  2473. u.`A_STATUS`='NORMAL'
  2474. and u.`ADM_TECH_WORKER`!='NO'
  2475. -- and u.`ADM_COMPANY` like '" . $_SESSION['ADM_COMPANY'] . "'
  2476. order by u.`ADM_NAME`
  2477. ";
  2478. $res = DB::query( $sql );
  2479. while ($r = DB::fetch( $res )) {
  2480. $_users_list [$r->ADM_ACCOUNT] = "" . $r->ADM_NAME . " (" . $r->ADM_ACCOUNT . ")";
  2481. }
  2482. }
  2483. $out = '';
  2484. switch ($cmd) {
  2485. case 'show': {
  2486. $out .= '<select name="' . $field_name . '">';
  2487. $out .= ' <option value="">' . " " . '</option>';
  2488. foreach ($_users_list as $key => $val) {
  2489. $sel = ($user_value == $key)? ' selected="selected"' : '';
  2490. $out .= '<option value="' . $key . '"' . $sel . '>' . $val . '</option>';
  2491. }
  2492. $out .= '</select>';
  2493. }
  2494. break;
  2495. case 'search': {
  2496. $out .= '<select name="' . $field_name . '">';
  2497. $out .= ' <option value="'."%".'">' . " % " . '</option>';
  2498. foreach ($_users_list as $key => $val) {
  2499. $sel = ($user_value == $key)? ' selected="selected"' : '';
  2500. $out .= '<option value="' . $key . '"' . $sel . '>' . $val . '</option>';
  2501. }
  2502. $out .= '</select>';
  2503. }
  2504. break;
  2505. case 'update': {
  2506. echo 'TODO: ' . __FUNCTION__ . '(update, '.$field_name.')';
  2507. return $value;
  2508. }
  2509. break;
  2510. default:
  2511. }
  2512. return $out;
  2513. }
  2514. function typespecial_CRM_TESTY__ID_ORGANIZER( $field_name, $cmd, $user_value, $attrs = array() ) {
  2515. static $_users_list;
  2516. if (!$_users_list) {
  2517. $_users_list = array();
  2518. Lib::loadClass('UsersHelper');
  2519. $params = array();
  2520. $params['ADM_ADMIN_LEVEL'] = 0;
  2521. $organizer_list = UsersHelper::get_users_list( $params, 100, 0, 'ADM_NAME', 'ASC' );
  2522. foreach ($organizer_list as $k => $v_organizer) {
  2523. $_users_list [$v_organizer->ID] = "" . $v_organizer->ADM_NAME . " (" . $v_organizer->ID . ")";
  2524. }
  2525. }
  2526. $out = '';
  2527. switch ($cmd) {
  2528. case 'show': {
  2529. $out .= '<select name="' . $field_name . '">';
  2530. $out .= ' <option value="">' . " " . '</option>';
  2531. foreach ($_users_list as $key => $val) {
  2532. $sel = ($user_value == $key)? ' selected="selected"' : '';
  2533. $out .= '<option value="' . $key . '"' . $sel . '>' . $val . '</option>';
  2534. }
  2535. $out .= '</select>';
  2536. }
  2537. break;
  2538. case 'search': {
  2539. $out .= '<select name="' . $field_name . '">';
  2540. $out .= ' <option value="'."%".'">' . " % " . '</option>';
  2541. foreach ($_users_list as $key => $val) {
  2542. $sel = ($user_value == $key)? ' selected="selected"' : '';
  2543. $out .= '<option value="' . $key . '"' . $sel . '>' . $val . '</option>';
  2544. }
  2545. $out .= '</select>';
  2546. }
  2547. break;
  2548. case 'update': {
  2549. echo 'TODO: ' . __FUNCTION__ . '(update, '.$field_name.')';
  2550. return $value;
  2551. }
  2552. break;
  2553. default:
  2554. }
  2555. return $out;
  2556. }
  2557. //2007-04-28 KOMENTARZ arek@tx.pl
  2558. //
  2559. // PROCES(X,Y)
  2560. // KROK_1 <-(CRM_WSKAZNIK)-----ZASOB(1)
  2561. // KROK_1 <-(CRM_WSKAZNIK)-----CZYNNOSC(1)
  2562. // KROK_2 <-(CRM_WSKAZNIK)-----ZASOB(2)
  2563. // KROK_2 <-(CRM_WSKAZNIK)--ZASOB(3)
  2564. // KROK_2 <-(CRM_WSKAZNIK)--CZYNNOSC(2)
  2565. // KROK_2 <-(CRM_WSKAZNIK)--ZASOB(4)
  2566. //
  2567. //
  2568. // dodatkowo ZASOBY i CZYNNOSCI maja miec strukture drzewa ID/PARENT_ID
  2569. // i przy rysowaniu procesu ma sie wyswietlac pelne drzewo
  2570. //
  2571. //
  2572. // czyli jest SERWER/DANE/arkusz_zalegllosci, uzyty do procesu windykacji, z flaga UZYWANIE
  2573. // a inny proces jest typu zasob=SERWER , ale uzyta jest flaga SERWIS
  2574. //
  2575. // czyli widac, ze jest serwer serwisowany, oraz kto go uzywa itp...
  2576. //
  2577. // trzeba bedzie dobrac odpowiednie flagi oraz odpowiednie elementy,
  2578. // i na tej podstawie opisac wszystkie zdarzenia w firmie i do nich wyrysowac procesy
  2579. // zobaczymy jak to sie ulozy organizacyjnie, bo w zasadzie moga wyjsc z tego niezle procedury
  2580. // w tym i do prowadzenia inwestycji i wszystkiego.
  2581. //Pozdro 600 , zrob do tego ladniejszy interfejs, zeby dalo sie ustalac strukture zasobow, czynnosci oraz procesow