procesy5.php 112 KB

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