procesy5.php 110 KB

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