procesy5.php 115 KB

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