procesy5.php 113 KB

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