procesy5.php 110 KB

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