ProcesEditor.php 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('ProcesHelper');
  4. Lib::loadClass('Config');
  5. Lib::loadClass('UI');
  6. Lib::loadClass('User');
  7. Lib::loadClass('Request');
  8. Lib::loadClass('Response');
  9. Lib::loadClass('Api_WfsNs');
  10. class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
  11. public function getProcesListAjaxAction(){
  12. try {
  13. $rows = DB::getPDO()->fetchAll("
  14. SELECT * FROM `CRM_PROCES` WHERE FIND_IN_SET(`ID`, ( SELECT GROUP_CONCAT(Level SEPARATOR ',')
  15. FROM ( SELECT @Ids := ( SELECT GROUP_CONCAT(`ID` SEPARATOR ',') FROM `CRM_PROCES` WHERE FIND_IN_SET(`PARENT_ID`, @Ids)
  16. AND `TYPE` <> 'PROCES_INIT' ) Level FROM `CRM_PROCES` JOIN
  17. (SELECT @Ids := 0) temp1
  18. WHERE FIND_IN_SET(`PARENT_ID`, @Ids) ) temp2 ))
  19. AND `PARENT_ID` >= 0 AND `A_STATUS` <> 'DELETED'
  20. ");
  21. $state = array();
  22. foreach ($rows as $key => $value) {
  23. $id = intval($value["ID"]);
  24. $parent_id = intval($value["PARENT_ID"]);
  25. $state[$id]["ID"] = $value["ID"];
  26. $state[$id]["DESC"] = $value["DESC"];
  27. $state[$id]["OPIS"] = $value["OPIS"];
  28. $state[$id]["TYPE"] = $value["TYPE"];
  29. $state[$id]["IF_TRUE_GOTO"] = intval($value["IF_TRUE_GOTO"]);
  30. $state[$id]["IF_TRUE_GOTO_FLAG"] = $value["IF_TRUE_GOTO_FLAG"];
  31. $state[$id]["PARENT_ID"] = (intval($value["PARENT_ID"]) != 0) ? intval($value["PARENT_ID"]) : "#";
  32. $state[$id]["SORT_PRIO"] = $value["SORT_PRIO"];
  33. if (!isset($state[$id]["childs"])) $state[$id]["childs"] = array();
  34. if (!isset($state[$parent_id]["childs"])) $state[$parent_id]["childs"] = array();
  35. $temp = array();
  36. $temp["ID"] = $id;
  37. array_push($state[$parent_id]["childs"], $temp);
  38. }
  39. Response::sendJsonExit($state);
  40. } catch (Exception $e) {
  41. UI::alert('danger', "Error: " . $e->getMessage());
  42. }
  43. }
  44. public function getPathAjaxAction(){
  45. try {
  46. $video_id = V::get('id', 0, $_GET, 'int');
  47. $rows = DB::getPDO()->fetchAll("
  48. SELECT f.ID, f.DESC
  49. FROM (
  50. SELECT @id AS _id, (SELECT @id := PARENT_ID FROM CRM_PROCES WHERE ID = _id)
  51. FROM (SELECT @id := {$video_id}) tmp1
  52. JOIN CRM_PROCES ON @id <> 0
  53. ) tmp2
  54. JOIN CRM_PROCES f ON tmp2._id = f.ID
  55. ");
  56. $rows = array_reverse($rows);
  57. Response::sendJsonExit($rows);
  58. } catch (Exception $e) {
  59. UI::alert('danger', "Error: " . $e->getMessage());
  60. }
  61. }
  62. private function addWatermark($url){
  63. $watermark_file = "/Library/Server/Web/Data/Sites/Default/SE/stuff/images/play.png"; //to change
  64. $image = new Imagick();
  65. $image->readImage($url);
  66. $watermark = new Imagick();
  67. $watermark->readImage($watermark_file);
  68. $image->resizeImage(500,500,Imagick::FILTER_LANCZOS,1);
  69. $image->compositeImage($watermark, imagick::COMPOSITE_OVER, 0, 0);
  70. $image->writeImage($url);
  71. $image->clear();
  72. $image->destroy();
  73. $watermark->clear();
  74. $watermark->destroy();
  75. }
  76. public function uploadVideoAction() {
  77. if (!User::logged()) return;
  78. $CRM_VIDEO = "/Library/Server/Web/Data/Sites/Default/PLIKI/bartosz_procesy5_pl/CRM_VIDEO/";
  79. $url = $_FILES["files"]["tmp_name"][0];
  80. $size = $_FILES["files"]["size"][0];
  81. $name = $_FILES["files"]["name"][0];
  82. $finfo = new finfo(FILEINFO_MIME_TYPE);
  83. $type = $finfo->file($url);
  84. $ext = pathinfo($name, PATHINFO_EXTENSION);
  85. $imgExtList = array("image/png", "image/jpeg");
  86. $vidExtList = array("video/mp4");
  87. $info = new stdClass();
  88. $statement = DB::getPDO()->prepare("INSERT INTO CRM_IMAGE(NAME, TYPE, REMOTE_TABLE, REMOTE_ID, IMAGE, SIZE)
  89. VALUES(:NAME, :TYPE, :REMOTE_TABLE, :REMOTE_ID, :IMAGE, :SIZE)");
  90. if(in_array($type, $imgExtList)){
  91. // $content = 'data:'.$type.';base64,'.base64_encode(file_get_contents($url));//
  92. $content = file_get_contents($url);
  93. $statement->bindParam(':NAME', $name, PDO::PARAM_STR);
  94. $statement->bindParam(':TYPE', $type, PDO::PARAM_STR);
  95. $imageType = "ADMIN_USERS";
  96. $statement->bindParam(':REMOTE_TABLE', $imageType, PDO::PARAM_STR);
  97. $idUser = User::getID();
  98. $statement->bindParam(':REMOTE_ID', $idUser, PDO::PARAM_INT);
  99. $statement->bindParam(':IMAGE', $content, PDO::PARAM_LOB);
  100. $statement->bindParam(':SIZE', $size, PDO::PARAM_INT);
  101. $statement->execute();
  102. $info->statusCode = 0;
  103. $info->statusText = "Plik załadowany pomyślnie";
  104. }else if(false && in_array($type, $vidExtList)){ //Only image files
  105. $statement_video = DB::getPDO()->prepare("INSERT INTO CRM_VIDEO(NAME, TYPE, REMOTE_TABLE, REMOTE_ID, PARENT_ID, HAS_FILE, EXT, VIDEO_START, VIDEO_END)
  106. VALUES(:NAME, :TYPE, :REMOTE_TABLE, :REMOTE_ID, :PARENT_ID, :HAS_FILE, :EXT, :VIDEO_START, :VIDEO_END)");
  107. $cmd_duration = "/usr/local/bin/ffmpeg -i ".$url." 2>&1 | grep \"Duration\" | cut -d, -f1 | sed 's#Duration\:##' | sed 's# ##' | cut -d. -f1";
  108. $str_time = exec($cmd_duration);
  109. $str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
  110. sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
  111. $time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
  112. $statement_video->execute(array(
  113. ":NAME" => $name,
  114. ":TYPE" => $type,
  115. ":REMOTE_TABLE" => "ADMIN_USERS",
  116. ":PARENT_ID" => 0,
  117. ":REMOTE_ID" => User::getID(),
  118. ":EXT" => $ext,
  119. ":HAS_FILE" => 1,
  120. ":VIDEO_START" => 0,
  121. ":VIDEO_END" => $time_seconds,
  122. ));
  123. $id = DB::getPDO()->lastInsertId();
  124. $temp_file = tempnam(sys_get_temp_dir(), 'thumbnail_');
  125. rename($temp_file, $temp_file .= '.png');
  126. $cmd = '/usr/local/bin/ffmpeg -y -i '.$url.' -ss 00:00:1 -vframes 1 '.$temp_file.' 2>&1';
  127. shell_exec($cmd);
  128. $this->addWatermark($temp_file);
  129. $img_content = 'data:'."image/png".';base64,'.base64_encode(file_get_contents($temp_file));
  130. $img_size = filesize($temp_file);
  131. $statement->execute(array(
  132. ":NAME" => "Miniaturka dla ".$name,
  133. ":TYPE" => "image/png",
  134. ":REMOTE_TABLE" => "CRM_VIDEO",
  135. ":REMOTE_ID" => $id,
  136. ":IMAGE" => $img_content,
  137. ":SIZE" => $img_size
  138. ));
  139. move_uploaded_file ( $url, $CRM_VIDEO.$id.".".$ext );
  140. $info->statusCode = 0;
  141. $info->statusText = "Plik załadowany pomyślnie" ;
  142. }else{
  143. $info->statusCode = 1;
  144. $info->statusText = "Nieobsługiwany format pliku ".$type ;
  145. }
  146. Response::sendJsonExit($info);
  147. }
  148. public function getVideoFileAjaxAction(){
  149. try {
  150. $video_id = V::get('id', 0, $_GET, 'int');
  151. if ($video_id <= 0) throw new Exception("ID is not set.");
  152. $sqlVideoId = DB::getPDO()->quote($video_id, PDO::PARAM_INT);
  153. $rows = DB::getPDO()->fetchAll("
  154. SELECT f.VIDEO_ID
  155. FROM (
  156. SELECT @id AS _id, (SELECT @id := PARENT_ID FROM CRM_VIDEO WHERE VIDEO_ID = _id)
  157. FROM (SELECT @id := {$sqlVideoId}) tmp1
  158. JOIN CRM_VIDEO ON @id <> 0
  159. ) tmp2
  160. JOIN CRM_VIDEO f ON tmp2._id = f.VIDEO_ID
  161. WHERE f.HAS_FILE = 1 and f.TYPE = 'video/mp4'
  162. ");
  163. $rows_time = DB::getPDO()->fetchAll("
  164. SELECT `VIDEO_START`, `VIDEO_END` FROM `CRM_VIDEO` WHERE `VIDEO_ID` = {$sqlVideoId}
  165. ");
  166. $id = $rows[0]["VIDEO_ID"];
  167. $CRM_VIDEO = "/PLIKI/bartosz_procesy5_pl/CRM_VIDEO/";
  168. $result["src"] = $CRM_VIDEO.$id.".mp4";
  169. $result["VIDEO_START"] = $rows_time[0]["VIDEO_START"];
  170. $result["VIDEO_END"] = $rows_time[0]["VIDEO_END"];
  171. Response::sendJsonExit($result);
  172. } catch (Exception $e) {
  173. UI::alert('danger', "Error: " . $e->getMessage());
  174. }
  175. }
  176. public function getThumbnailAjaxAction($video_id = -1){
  177. try {
  178. $doReturn = false;
  179. if($video_id <= 0)
  180. $video_id = V::get('id', 0, $_GET, 'int');
  181. else
  182. $doReturn = true;
  183. if ($video_id <= 0) throw new Exception("ID is not set.");
  184. $sqlVideoId = DB::getPDO()->quote($video_id, PDO::PARAM_INT);
  185. $rows = DB::getPDO()->fetchAll("
  186. SELECT f.VIDEO_ID
  187. FROM (
  188. SELECT @id AS _id, (SELECT @id := PARENT_ID FROM CRM_VIDEO WHERE VIDEO_ID = _id)
  189. FROM (SELECT @id := {$sqlVideoId}) tmp1
  190. JOIN CRM_VIDEO ON @id <> 0
  191. ) tmp2
  192. JOIN CRM_VIDEO f ON tmp2._id = f.VIDEO_ID
  193. WHERE f.PARENT_ID = 0
  194. ");
  195. if(isset($rows[0]["VIDEO_ID"])){
  196. $video_parent_id = $rows[0]["VIDEO_ID"];
  197. $sqlVideoParentId = DB::getPDO()->quote($video_parent_id , PDO::PARAM_INT);
  198. $rows = DB::getPDO()->fetchAll("
  199. SELECT * FROM CRM_IMAGE WHERE REMOTE_TABLE = 'CRM_VIDEO' AND REMOTE_ID = {$sqlVideoParentId}
  200. ");
  201. if($doReturn)
  202. return $rows;
  203. else
  204. Response::sendJsonExit($rows);
  205. }
  206. } catch (Exception $e) {
  207. UI::alert('danger', "Error: " . $e->getMessage());
  208. }
  209. }
  210. public function getVideosClipboardAjaxAction(){
  211. try {
  212. $id = User::getID();
  213. if ($id <= 0) throw new Exception("ID is not set.");
  214. $sqlId = DB::getPDO()->quote($id, PDO::PARAM_INT);
  215. $rows = DB::getPDO()->fetchAll("
  216. SELECT *
  217. FROM CRM_VIDEO
  218. WHERE REMOTE_TABLE = 'ADMIN_USERS' and REMOTE_ID = {$sqlId}
  219. ");
  220. foreach($rows as $key=>$value){
  221. $rows[$key]["THUMBNAIL"] = $this->getThumbnailAjaxAction($value["VIDEO_ID"])[0];
  222. }
  223. Response::sendJsonExit($rows);
  224. } catch (Exception $e) {
  225. UI::alert('danger', "Error: " . $e->getMessage());
  226. }
  227. }
  228. public function getResByParentAjaxAction() {
  229. try {
  230. $idParent = V::get('parent_id', 0, $_GET, 'int');
  231. if ($idParent <= 0) throw new Exception("ID is not set.");
  232. $sqlIdParent = DB::getPDO()->quote($idParent, PDO::PARAM_INT);
  233. $rows = DB::getPDO()->fetchAll("
  234. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  235. from CRM_LISTA_ZASOBOW g
  236. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  237. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  238. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  239. where g.`PARENT_ID` = {$sqlIdParent}
  240. ORDER BY g.SORT_PRIO ASC, g.ID DESC
  241. ");
  242. Response::sendJsonExit($rows);
  243. } catch (Exception $e) {
  244. UI::alert('danger', "Error: " . $e->getMessage());
  245. }
  246. }
  247. public function getResTreeAjaxAction() {
  248. try {
  249. $id = V::get('id', '', $_GET);
  250. $sql = "
  251. select p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  252. from CRM_LISTA_ZASOBOW g
  253. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  254. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  255. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  256. where g.`A_STATUS` not in ('DELETED')
  257. and (p1.ID is null or p1.`A_STATUS` not in ('DELETED'))
  258. and (p2.ID is null or p2.`A_STATUS` not in ('DELETED'))
  259. and (p3.ID is null or p3.`A_STATUS` not in ('DELETED'))
  260. and g.ID = {$id}
  261. limit 1
  262. ";
  263. DBG::_('DBG_SQL', '>1', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__);
  264. $rows = DB::getPDO()->fetchAll($sql);
  265. Response::sendJsonExit($rows);
  266. } catch (Exception $e) {
  267. UI::alert('danger', "Error: " . $e->getMessage());
  268. }
  269. }
  270. public function getResAjaxAction() {
  271. try {
  272. $word = V::get('word', '', $_GET);
  273. $filter = isset($_GET['filter']) ? (int)$_GET['filter'] : 0;
  274. $sqlFilter = "";
  275. if (!empty($word)) {
  276. $sqlWord = DB::getPDO()->quote("%{$word}%", PDO::PARAM_STR);
  277. if (is_numeric($word)) {
  278. $sqlFilter .= "AND (g.`DESC` LIKE {$sqlWord} OR g.`ID` LIKE {$sqlWord})" . "\n";
  279. } else {
  280. $sqlFilter .= "AND g.`DESC` LIKE {$sqlWord}" . "\n";
  281. }
  282. }
  283. switch ($filter) {
  284. case 2: $sqlFilter .= "AND (g.`TYPE` = 'TABELA' OR g.`TYPE` = 'KOMORKA')" . "\n"; break;
  285. case 1: $sqlFilter .= "AND (g.`TYPE` = 'STANOWISKO' OR g.`TYPE` = 'DZIAL' OR g.`TYPE` = 'PODMIOT')" . "\n"; break;
  286. }
  287. $sql = "
  288. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  289. from CRM_LISTA_ZASOBOW g
  290. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  291. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  292. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  293. where g.`A_STATUS` not in ('DELETED')
  294. and (p1.ID is null or p1.`A_STATUS` not in ('DELETED'))
  295. and (p2.ID is null or p2.`A_STATUS` not in ('DELETED'))
  296. and (p3.ID is null or p3.`A_STATUS` not in ('DELETED'))
  297. {$sqlFilter}
  298. limit 100
  299. ";
  300. DBG::_('DBG_SQL', '>1', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__);
  301. $rows = DB::getPDO()->fetchAll($sql);
  302. Response::sendJsonExit($rows);
  303. } catch (Exception $e) {
  304. UI::alert('danger', "Error: " . $e->getMessage());
  305. }
  306. }
  307. public function getSingleResAjaxReponseCallback() {
  308. if (!isset($_POST['data'])) throw new Exception("data is not set.");
  309. $ids = V::get('data', null, $_POST, 'uint_array');
  310. if (empty($ids)) throw new Exception("data is not correct.");
  311. $sqlWhereIdIn = array();
  312. foreach ($ids as $value) {
  313. $sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT);
  314. }
  315. $sqlWhereIdIn = "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")";
  316. $rows = DB::getPDO()->fetchAll("
  317. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  318. from CRM_LISTA_ZASOBOW g
  319. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  320. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  321. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  322. where {$sqlWhereIdIn}
  323. ");
  324. return $rows;
  325. }
  326. public function getSingleResAjaxAction() {
  327. Response::sendTryCatchJson(array($this, 'getSingleResAjaxReponseCallback'));
  328. }
  329. public function handleAuth() {
  330. if (!User::logged()) {
  331. //throw new HttpException('Unauthorized', 401);
  332. User::authByRequest();
  333. }
  334. // zapisać jsona w sesji
  335. }
  336. public function reinstallAction(){
  337. DB::getPDO()->execSql("
  338. CREATE TABLE IF NOT EXISTS `CRM_IMAGE` (
  339. `ID` int(11) NOT NULL,
  340. `NAME` varchar(50) NOT NULL,
  341. `SIZE` int(11) NOT NULL,
  342. `TYPE` varchar(25) NOT NULL,
  343. `IMAGE` mediumblob NOT NULL,
  344. `ICON` tinyblob,
  345. `WIDTH` int(11) NOT NULL,
  346. `HEIGHT` int(11) NOT NULL,
  347. `REMOTE_TABLE` enum('CRM_LISTA_ZASOBOW','CRM_PROCES','CRM_WSKAZNIK','ADMIN_USERS','CRM_VIDEO') NOT NULL,
  348. `REMOTE_ID` int(11) NOT NULL,
  349. `DEST` varchar(16) NOT NULL,
  350. `A_CREATE_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  351. `A_RECORD_CREATE_AUTHOR` varchar(100) NOT NULL,
  352. `SYNC_SQIX_STATUS` varchar(255) NOT NULL,
  353. `A_RECORD_CREATE_DATE` varchar(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
  354. `A_RECORD_UPDATE_DATE` varchar(255) NOT NULL,
  355. `A_RECORD_UPDATE_AUTHOR` varchar(50) NOT NULL
  356. ) ENGINE=MyISAM DEFAULT CHARSET=latin2
  357. ");
  358. try {
  359. DB::getPDO()->execSql("
  360. ALTER table `CRM_IMAGE` CHANGE `REMOTE_TABLE` `REMOTE_TABLE` enum('CRM_LISTA_ZASOBOW','CRM_PROCES','CRM_WSKAZNIK','ADMIN_USERS','CRM_VIDEO') NOT NULL
  361. ");
  362. } catch (Exception $e) {
  363. DBG::log($e);
  364. }
  365. }
  366. public function defaultAction() {
  367. UI::gora();
  368. UI::menu();
  369. try {
  370. $id = V::get('id', 0, $_REQUEST, 'int');
  371. if ($id <= 0) $id = -1;
  372. if($id >= 0)
  373. UI::setTitleJsTag("Edytor Procesu {{$id}}");
  374. else
  375. UI::setTitleJsTag("Tworzenie nowego procesu}");
  376. $this->showEditor($id);
  377. } catch (Exception $e) {
  378. UI::alert('danger', "Error: " . $e->getMessage());
  379. }
  380. UI::dol();
  381. }
  382. public function showEditor($id) {
  383. echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.8.1/css/bootstrap-slider.min.css" crossorigin="anonymous">';
  384. echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
  385. echo '<link rel="stylesheet" href="static/jstree-theme/style.min.css" />';
  386. echo '<script src="static/jstree.min.js"></script>';
  387. $this->showEditorCss();
  388. ?>
  389. <div id="wrapper" class="toggled" style="overflow:hidden">
  390. <div id='sidebar-wrapper'><div id="side"></div></div>
  391. <div id='page-content-wrapper'>
  392. <div id="left">
  393. <button class='lButton btn btn-default' id="btnZasoby" style="top:150px"><p>Zasoby</p></button>
  394. <button class='lButton btn btn-default' style="top:315px" id="btnProcesy"><p>Procesy</p></button>
  395. <button class='lButton btn btn-default' id="btnPhotos" style="top:480px"><p>Media</p></button>
  396. </div>
  397. <div class=col-md-12 >
  398. <div class=col-md-12 ><a id=toggleMenu style=cursor:pointer;>Przełącz menu</a>
  399. </div>
  400. <hr>
  401. <div class="col-md-12 path" style=border-width:1px;text-align:center;>
  402. </div>
  403. </div>
  404. <div id="main" style="margin-left:40px">
  405. <center>Uruchamianie aplikacji.</center>
  406. </div>
  407. </div>
  408. </div>
  409. <script>var USER_ID = '<?= User::getID(); ?>';var BASE_URL = '<?= Request::getPathUri(); ?>';var BASE_WFS_URL = '<?= Api_WfsNs::getBaseWfsUri(); ?>';var mainProces_id = <?= $id; ?>;</script>
  410. <script src="static/sweetalert2.min.js"></script>
  411. <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.8.1/bootstrap-slider.min.js" crossorigin="anonymous"></script>
  412. <script src="static/videoPlayer.js?v=?<?php echo time(); if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
  413. <script src="static/jquery.fileupload.js"></script>
  414. <script src="static/procesEditor.js?<?php echo time(); if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
  415. <?php
  416. }
  417. public function showEditorCss() {
  418. ?>
  419. <style type="text/css">
  420. #p5BModalBack{
  421. width:100%;
  422. position:fixed;
  423. height:100%;
  424. background-color:rgba(0,0,0,0.9);
  425. z-index:2000;
  426. text-align:center;
  427. }
  428. .p5BModalModal{
  429. display: inline-block;
  430. width:800px;
  431. opacity:1;
  432. box-shadow:0 5px 15px rgba(0,0,0,.5);
  433. background-color:white;
  434. -webkit-background-clip: padding-box;
  435. background-clip: padding-box;
  436. border: 1px solid #999;
  437. border: 1px solid rgba(0,0,0,.2);
  438. border-radius: 6px;
  439. outline: 0;
  440. }
  441. .p5BModalContent{
  442. text-align:left;
  443. padding:5px;
  444. }
  445. #pathList{
  446. min-height:400px;
  447. max-height:650px;
  448. overflow-y:scroll;
  449. overflow-x:hidden;
  450. }
  451. .p5BModalHeader{
  452. text-align:left;
  453. font-size: 18px;
  454. margin-bottom: 10px;
  455. font-family: inherit;
  456. font-weight: 500;
  457. cursor:move;
  458. height:30px;
  459. border-bottom:1px solid silver;
  460. font-size:1.5em;
  461. padding-left:10px;
  462. }
  463. .p5BModalHeader span{
  464. display:inline-block;
  465. padding-top:5px;
  466. }
  467. .p5BModalHeader div{
  468. font-family:verdana;
  469. float:right;
  470. padding-top:5px;
  471. cursor:pointer;
  472. border-color:black;
  473. font-weight:bold;
  474. padding-right:10px;
  475. padding-top:6px;
  476. color:gray;
  477. height:100%;
  478. padding-left:7px;
  479. border-top-left-radius:3px;
  480. border-bottom-left-radius:3px;
  481. font-size:0.9em;
  482. }
  483. .p5BModalHeader div:hover{
  484. color:#e74c3c;
  485. }
  486. .hide{
  487. display:none;
  488. }
  489. .p5BModalButton{
  490. float:right;
  491. margin:3px;
  492. }
  493. .pathList{
  494. max-height:700px;
  495. min-height:300px;
  496. overflow-y:scroll;
  497. }
  498. .activeDrop{
  499. background-color:#f1f1f1;
  500. }
  501. .treeInfo{
  502. overflow: hidden;
  503. text-align: right;
  504. display:inline-block;
  505. color:grey;
  506. font-size:0.9em;
  507. white-space: nowrap;
  508. max-width: 90%;
  509. }
  510. .treeInfo div{
  511. float:right;
  512. }
  513. #left{
  514. padding:0px;
  515. }
  516. .sDescAdd, .hDescAdd, .step{
  517. padding-left:10px;
  518. }
  519. #clipboard{
  520. color:black;
  521. }
  522. .no-draggable .dragIcon{
  523. display:none;
  524. }
  525. .no-draggable .imgTitle{
  526. cursor:auto !important;
  527. }
  528. .attImg, .attVid{
  529. position:relative;
  530. display:inline-block;
  531. margin-top:5px;
  532. margin-left:10px;
  533. }
  534. .attImg .img, .attVid .img{
  535. height:100%;
  536. display: flex;
  537. position:relative;
  538. background-color:black;
  539. vertical-align: middle;
  540. }
  541. .attImg img, .attVid img{
  542. align-items: stretch;
  543. max-width:100%;
  544. width: auto;
  545. height: auto;
  546. }
  547. .attImg .imgTitle, .attVid .imgTitle{
  548. background-color:white;
  549. cursor: move;
  550. text-align:left;
  551. }
  552. .remImg{
  553. cursor:pointer;
  554. padding-left:2px;
  555. padding-right:3px;
  556. }
  557. .noRemove .remImg{
  558. display:none;
  559. }
  560. .remImg:hover{
  561. color:red;
  562. }
  563. .attImg div, .attVid div{
  564. font-family:tahoma;
  565. text-align:center;
  566. }
  567. .lButton{
  568. -webkit-transform: translate3d(0,0,0);
  569. position:fixed;
  570. padding:0px;
  571. outline:none;
  572. margin:0px;
  573. width: 40px;
  574. height:160px;
  575. z-index:30;
  576. border-top-left-radius: 0px;
  577. border-bottom-left-radius: 0px;
  578. }
  579. .lButton p
  580. {
  581. margin-bottom:-50px;
  582. -moz-transform:rotate(-90deg);
  583. -ms-transform:rotate(-90deg);
  584. -o-transform:rotate(-90deg);
  585. -webkit-transform:rotate(-90deg);
  586. }
  587. .ico {
  588. margin-top: 3px;
  589. margin-left: 5px;
  590. cursor: pointer;
  591. }
  592. #wrapper {
  593. padding-left: 0;
  594. -webkit-transition: all 0.5s ease;
  595. -moz-transition: all 0.5s ease;
  596. -o-transition: all 0.5s ease;
  597. transition: all 0.5s ease;
  598. }
  599. #wrapper.toggled {
  600. padding-left: 600px;
  601. }
  602. #wrapper #left { width:40px }
  603. #wrapper #left .lButton {
  604. width:40px;
  605. -webkit-transition: all 0.5s ease;
  606. -moz-transition: all 0.5s ease;
  607. -o-transition: all 0.5s ease;
  608. transition: all 0.5s ease;
  609. }
  610. #wrapper.toggled #left .lButton { width:39px }
  611. #side {
  612. padding: 15px;
  613. height: 100%;
  614. border-top-style:solid;
  615. border-top-width:1px;
  616. border-right-style: solid;
  617. border-color: #A61C2E;
  618. border-width: 2px;
  619. }
  620. ul {
  621. list-style: none;
  622. }
  623. #advCon{
  624. width:870px;
  625. min-width:100%;
  626. }
  627. .detailsTable{
  628. color:grey;
  629. float:left;
  630. display:inline;
  631. text-align:center;
  632. margin-left:5px;
  633. height:23px;
  634. }
  635. .tree{
  636. color:grey;
  637. text-overflow:ellipsis;
  638. white-space:nowrap;
  639. overflow:hidden;
  640. display:block;
  641. cursor:pointer;
  642. }
  643. .detailsTable2{
  644. color:grey;
  645. display:block;
  646. font-size:0.8em;
  647. text-align:left;
  648. margin-left:5px;
  649. height:23px;
  650. }
  651. .textTable{
  652. float:left;
  653. width:200px;
  654. text-overflow:ellipsis;
  655. white-space:nowrap;
  656. overflow:hidden;
  657. cursor:pointer;
  658. display:inline-block;
  659. }
  660. #dropPic{
  661. height:250px;
  662. border-radius:5px;
  663. border-style:solid;
  664. border-color:#ededed;
  665. background-color: #fbfbfb;
  666. border-width:1px;
  667. }
  668. .incorrect{
  669. border-style:solid !important;
  670. border-color:#e74c3c !important;
  671. }
  672. .focused{
  673. border-style:solid !important;
  674. border-color:#3498db !important;
  675. }
  676. /* skin.css Style*/
  677. #inp {
  678. height: 100px;
  679. border-width: 2px;
  680. margin-bottom: 0px;
  681. color: #ccc;
  682. border-style: dashed;
  683. border-color: #ccc;
  684. line-height: 100px;
  685. text-align: center;
  686. display:block;
  687. width:100%;
  688. }
  689. .upload-drop-zone.drop {
  690. color: #222;
  691. border-color: #222;
  692. }
  693. .anim-refresh {
  694. -animation: spin .7s infinite linear;
  695. -webkit-animation: spin2 .7s infinite linear;
  696. }
  697. @-webkit-keyframes spin2 {
  698. from { -webkit-transform: rotate(0deg);}
  699. to { -webkit-transform: rotate(360deg);}
  700. }
  701. @keyframes spin {
  702. from { transform: scale(1) rotate(0deg);}
  703. to { transform: scale(1) rotate(360deg);}
  704. }
  705. .list-group-item{
  706. cursor:pointer;
  707. }
  708. .list-group-item:hover{
  709. background-color:#eeeeee;
  710. }
  711. .list-group-item:hover .glyphicon{
  712. opacity:1 !important;
  713. }
  714. .textTable2{
  715. float:left;
  716. width:230px;
  717. text-overflow:ellipsis;
  718. white-space:nowrap;
  719. overflow:hidden;
  720. cursor:pointer;
  721. display:inline-block;
  722. }
  723. .pbody{
  724. padding-left:20px;
  725. padding-right:20px;
  726. text-align:justify;
  727. }
  728. .singleAdv{
  729. float:left;
  730. height:100%;
  731. width:290px;
  732. }
  733. #side #adv{
  734. }
  735. #side #ulcon, #side #ulproc, #side #adv {
  736. background-color: white;
  737. overflow-y: scroll;
  738. height: 70% !important;
  739. border-style:solid;
  740. border-width:1px;
  741. border-color:grey;
  742. margin-top: 10px;
  743. border-radius: 5px;
  744. padding-bottom: 10px;
  745. border-style: solid;
  746. border-width: 1px;
  747. border-color: #e5e5e5;
  748. color: black;
  749. padding-left: 0px;
  750. font-family: tahoma;
  751. font-size: 13px;
  752. }
  753. .selectedAdv{
  754. background-color:#e4e4e4;
  755. }
  756. .selectedAdv:hover{
  757. background-color:#e4e4e4;
  758. }
  759. #side .dragStyle {
  760. padding-left: 8px;
  761. padding-top: 4px;
  762. padding-bottom: 4px;
  763. border-bottom-style: dotted;
  764. border-width: 1px;
  765. cursor: pointer;
  766. border-color: #e5e5e5;
  767. background-color: white;
  768. display: block;
  769. }
  770. #side .showMore {
  771. padding-left: 2px;
  772. padding-top: 4px;
  773. padding-bottom: 4px;
  774. border-width: 1px;
  775. border-color: #e5e5e5;
  776. }
  777. #side .gIco {
  778. padding-left: 2px;
  779. padding-top: 4px;
  780. padding-bottom: 4px;
  781. border-width: 1px;
  782. border-color: #e5e5e5;
  783. cursor: pointer;
  784. }
  785. #side .hov,
  786. #side .grad {
  787. cursor: pointer;
  788. }
  789. .vakata-context {
  790. z-index:3000 !important;
  791. }
  792. #side .click {
  793. float: left;
  794. color: grey;
  795. font-size: 10px;
  796. cursor: pointer;
  797. }
  798. .delRes,
  799. .btnEdit,
  800. .hdesc,
  801. .sdesc {
  802. cursor: pointer;
  803. }
  804. .goto{
  805. padding-left:10px;
  806. }
  807. .imagesDrop{
  808. border-style:dashed;
  809. border-width:1px;
  810. border-color:#bdc3c7;
  811. }
  812. .sdesc{
  813. min-height:20px;
  814. }
  815. #side .tabelaName {
  816. white-space: nowrap;
  817. margin-right: 10px;
  818. overflow: hidden;
  819. width: 350px;
  820. float: left;
  821. text-overflow: ellipsis;
  822. display: block;
  823. cursor: pointer;
  824. }
  825. #side .hov:hover {
  826. background-color: #e5e5e5;
  827. }
  828. #sidebar-wrapper {
  829. position: fixed;
  830. left: 600px;
  831. width: 0;
  832. height: 100%;
  833. color: white;
  834. margin-left: -600px;
  835. overflow-y: auto;
  836. background: #222;
  837. -webkit-transition: all 0.5s ease;
  838. -moz-transition: all 0.5s ease;
  839. -o-transition: all 0.5s ease;
  840. transition: all 0.5s ease;
  841. }
  842. #wrapper.toggled #sidebar-wrapper {
  843. width: 600px;
  844. }
  845. #page-content-wrapper {
  846. width: 100%;
  847. position: absolute;
  848. z-index:0 !important;
  849. padding-top: 15px;
  850. padding-left:0px !important;
  851. }
  852. #wrapper.toggled #page-content-wrapper {
  853. position: absolute;
  854. margin-right: -600px;
  855. }
  856. #wrapper {
  857. padding-left: 600px;
  858. }
  859. #wrapper.toggled {
  860. padding-left: 0 !important;
  861. }
  862. #sidebar-wrapper {
  863. width: 600px;
  864. }
  865. #wrapper.toggled #sidebar-wrapper {
  866. width: 0 !important;
  867. }
  868. #page-content-wrapper {
  869. padding: 20px;
  870. position: relative;
  871. }
  872. #wrapper.toggled #page-content-wrapper {
  873. position: relative;
  874. margin-right: 0;
  875. }
  876. .drop {
  877. margin-top: 10px;
  878. }
  879. .sdesc{
  880. margin-bottom:10px;
  881. }
  882. .hdesc textarea,
  883. .sdesc textarea {
  884. min-width: 100%;
  885. padding: 10px;
  886. }
  887. .step,
  888. .sDescAdd {
  889. margin-top:5px;
  890. color: grey;
  891. cursor: pointer;
  892. display:block;
  893. font-size:10px;
  894. }
  895. .sDescAdd:hover{
  896. color:black;
  897. }
  898. .goto{
  899. }
  900. .editGoto{
  901. cursor:pointer;
  902. }
  903. .sdesc {
  904. display: block;
  905. }
  906. .hDescAdd {
  907. cursor: pointer;
  908. }
  909. #saveBtn {} .changable {
  910. padding-left: 10px;
  911. }
  912. .export{
  913. min-height:200px;
  914. }
  915. .changed {
  916. border-left-style: solid;
  917. border-width: 3px;
  918. border-color: #ffc107;
  919. padding-left: 7px;
  920. }
  921. .del {
  922. }
  923. .liRes:hover{
  924. background-color:#fafafa;
  925. }
  926. span.glyphicon{
  927. opacity:0.6;
  928. cursor:pointer;
  929. margin-left:3px;
  930. }
  931. span.glyphicon:hover{
  932. opacity:1;
  933. }
  934. .delRes:hover{
  935. color:red;
  936. }
  937. .delGoto:hover{
  938. color:red;
  939. cursor:pointer;
  940. }
  941. .del:hover{
  942. color:red;
  943. }
  944. .ids {
  945. color: grey;
  946. font-size: 12px;
  947. }
  948. .more {
  949. margin-left: 15px;
  950. }
  951. .resSelected {
  952. background-color: #d3d3d3;
  953. }
  954. .slider .slider-handle {
  955. background-color: red;
  956. width: 8px;
  957. margin-left: -4px !important;
  958. }
  959. .slider .slider-handle {} .p5VideoPlayer_vid {
  960. background-color: black;
  961. height: 100%;
  962. width: 100%;
  963. }
  964. .p5VideoPlayer {
  965. width:100%;
  966. height:calc(100% - 18px);
  967. }
  968. .p5VideoPlayer .ico {
  969. font-size: 12px;
  970. margin-left: 4px;
  971. margin-right: 4px;
  972. cursor: pointer;
  973. opacity: 0.8;
  974. }
  975. .ico:hover {
  976. opacity: 1;
  977. }
  978. .p5VideoPlayer_video-controls {
  979. background-color: powderblue;
  980. position:relative;
  981. }
  982. .p5VideoPlayer_video-controls:not(.p5VideoPlayer_video-controls-fs) {
  983. top:-25px;
  984. }
  985. .p5VideoPlayer_video-controls .only_fullscreen{
  986. display:none;
  987. }
  988. .p5VideoPlayer_video-controls-fs .only_fullscreen{
  989. display:table-cell;
  990. }
  991. .p5VideoPlayer_video-controls-fs {
  992. opacity: 0;
  993. position: absolute;
  994. bottom: 0;
  995. left: 0;
  996. right: 0;
  997. color: white;
  998. font-size: .8em;
  999. color:black;
  1000. width: 100%;
  1001. height: 20px;
  1002. z-index: 2147483647;
  1003. }
  1004. .p5VideoPlayer:hover .p5VideoPlayer_video-controls-fs {
  1005. opacity: 1;
  1006. }
  1007. .p5VideoPlayer_video-controls td {
  1008. padding: 0px;
  1009. padding-left:5px;
  1010. padding-right:5px;
  1011. }
  1012. .p5VideoPlayer_video-controls .slider {
  1013. width: 100%;
  1014. }
  1015. .przycinanie .slider {
  1016. width: 100%;
  1017. }
  1018. .slider .slider-selection {
  1019. background: #01b7ce;
  1020. }
  1021. video::-webkit-media-controls {
  1022. display: none !important;
  1023. }
  1024. video::-webkit-media-controls-enclosure {
  1025. display: none !important;
  1026. }
  1027. </style>
  1028. <?php
  1029. }
  1030. }