procesy5.php 113 KB

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