procesy5.php 112 KB

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