procesy5.php 110 KB

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