You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
9.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. require_once('../php/argus/server.php');
  4. if( $CUser->Data['id'] > 1 ){
  5. $PID = intval( $_POST['PID'] );
  6. $QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$PID}";
  7. $RR = $DATABASE->Query( $QS, false );
  8. if( count( $RR ) ){
  9. $MODS = array();
  10. $ATN = '';
  11. $ATS = '';
  12. $BTN = '';
  13. $BTS = '';
  14. foreach( $RR as $CT ){
  15. if( $CT['side'] == 'U' ){
  16. $FID = intval( $CT['far_module_id'] );
  17. $NID = intval( $CT['near_module_id'] );
  18. if( !$FID ) $MODS['UL']=$CT['id'];
  19. if( !$NID ) $MODS['UR']=$CT['id'];
  20. $ATN = $CT['name'];
  21. $ATS = $CT['short'];
  22. } else {
  23. $FID = intval( $CT['far_module_id'] );
  24. $NID = intval( $CT['near_module_id'] );
  25. if( !$FID ) $MODS['BR']=$CT['id'];
  26. if( !$NID ) $MODS['BL']=$CT['id'];
  27. $BTN = $CT['name'];
  28. $BTS = $CT['short'];
  29. };
  30. };
  31. //If no mods = all are defined
  32. if( count( $MODS ) ){
  33. $PAPA = array();
  34. $LOCK = count( $MODS );
  35. $CVAL = '';
  36. foreach( $MODS as $KEY=>$VALUE ){
  37. $PAPA[] = "['".$KEY . "','" .$Labels->GetLabel( 'MOD_LOC_'.$KEY ) . "','" .'/style/assets/ms_'.strtolower( $KEY ).".png']";
  38. if( $CVAL == '' ) $CVAL = $KEY;
  39. };
  40. $CDATA = implode(',', $PAPA );
  41. $WTPL =<<<DATA_BOUNDARY
  42. {
  43. id: 'huba_buba',
  44. title: "{$Labels->GetLabel( '_ADD_MODULE_' )}",
  45. modal: true,
  46. resizable: false,
  47. width: 450,
  48. height: 290,
  49. items:[{
  50. xtype: 'form',
  51. labelWidth: 150,
  52. labelAlign: 'right',
  53. items: [{
  54. xtype: 'textfield',
  55. fieldLabel: "{$Labels->GetLabel( 'MOD_NAME' )}",
  56. id: 'mod_name',
  57. width: 200,
  58. },{
  59. xtype: 'textfield',
  60. fieldLabel: "{$Labels->GetLabel( 'MOD_IP' )}",
  61. id: 'mod_ip',
  62. width: 200,
  63. },{
  64. xtype: 'textfield',
  65. fieldLabel: "{$Labels->GetLabel( 'MOD_IDENT' )}",
  66. id: 'mod_id',
  67. width: 200,
  68. },{
  69. xtype: 'combo',
  70. fieldLabel: "{$Labels->GetLabel( 'MOD_LOCATION' )}",
  71. id: 'mod_loc',
  72. width: 200,
  73. lazyRender: true,
  74. mode: 'local',
  75. forceSelection: true,
  76. triggerAction: 'all',
  77. editable: false,
  78. readOnly: ({$LOCK}==1),
  79. disableKeyFilter: true,
  80. tpl:'<tpl for="."><div class="x-combo-list-item"><img width="16px" src="{icon}"/>&nbsp;{name}</div></tpl>',
  81. store: new Ext.data.ArrayStore({
  82. fields: ['abbr','name','icon'],
  83. data: [{$CDATA}]
  84. }),
  85. valueField: 'abbr',
  86. displayField: 'name',
  87. value: '{$CVAL}',
  88. listeners:{
  89. select: function( t, r, i ){
  90. t.getEl().setStyle({
  91. 'background-image': 'url(' + r.data.icon + ')',
  92. 'background-repeat': 'no-repeat',
  93. 'background-position': '3px center',
  94. 'background-size': '16px 16px',
  95. 'padding-left': '25px'
  96. });
  97. },
  98. afterrender: function( t ){
  99. t.getEl().setStyle({
  100. 'background-image': 'url(' + t.store.data.items[t.store.findExact( 'abbr', t.value )].data.icon + ')',
  101. 'background-repeat': 'no-repeat',
  102. 'background-position': '3px center',
  103. 'background-size': '16px 16px',
  104. 'padding-left': '25px'
  105. });
  106. }
  107. }
  108. },{
  109. xtype: 'panel',
  110. id: 'infopan',
  111. html: '<table width="100%" border=1><tr><td class="mod_sch_ucell">{$ATN}[{$ATS}]</td></tr><tr><td class="mod_sch_bcell">{$BTN}[{$BTS}]</td></tr></table>'
  112. }]
  113. }],
  114. bbar:[{
  115. text: '{$Labels->GetLabel( '_CANCEL_' )}',
  116. handler: function(){
  117. var tt = Ext.getCmp('huba_buba');
  118. tt.close();
  119. }
  120. },{
  121. text: '{$Labels->GetLabel( '_ADD_' )}',
  122. handler: function(){
  123. var name = Ext.getCmp('mod_name').getValue();
  124. var addr = Ext.getCmp('mod_ip').getValue();
  125. var iden = Ext.getCmp('mod_id').getValue();
  126. var loca = Ext.getCmp('mod_loc').getValue();
  127. Ext.Ajax.request({
  128. url: '/lib/controller/doModuleOperations.php',
  129. params: {
  130. OPID: 300,
  131. NAM: name,
  132. I4P: addr,
  133. PID: {$PID},
  134. IDT: iden,
  135. LOC: loca,
  136. UID: {$UserID},
  137. SID: '{$Session}'
  138. },
  139. success: function( response, opts ){
  140. // If the response is JSON, you have to decode it
  141. var data = Ext.decode(response.responseText);
  142. if( data.status == 'ok' ){
  143. addModuleWindow.close();
  144. loadModules();
  145. } else {
  146. Ext.Msg.show({
  147. title: "{$Labels->GetLabel("_INFO_MSG_")}",
  148. msg: data.msg,
  149. buttons: Ext.Msg.OK,//YESNOCANCEL,
  150. fn: function(){
  151. //SettingsLidar3D.hide();
  152. },
  153. icon: Ext.MessageBox.INFO //QUESTION
  154. });
  155. }
  156. },
  157. failure: failureAJAXFunction
  158. });
  159. }
  160. }]
  161. }
  162. DATA_BOUNDARY;
  163. };
  164. echo $WTPL;
  165. } else {
  166. $QS = "SELECT * FROM `metro_platforms` WHERE `id`={$PID}";
  167. $RR = $DATABASE->Query( $QS, false );
  168. $UP_TRN = "Platform_{$PID}_UTR";
  169. $BT_TRN = "Platform_{$PID}_BTR";
  170. $UP_TRA = "{$PID}_UTR";
  171. $BT_TRA = "{$PID}_BTR";
  172. if( $RR[0]['layout'] == 'A' || $LAY == 'B' ){
  173. $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')";
  174. $DATABASE->Query( $QS );
  175. } else {
  176. $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')";
  177. $DATABASE->Query( $QS );
  178. $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'B','{$BT_TRN}','{$BT_TRA}')";
  179. $DATABASE->Query( $QS );
  180. };
  181. $QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$PID}";
  182. $RR = $DATABASE->Query( $QS, false );
  183. if( count( $RR ) ){
  184. $MODS = array();
  185. $ATN = '';
  186. $ATS = '';
  187. $BTN = '';
  188. $BTS = '';
  189. foreach( $RR as $CT ){
  190. if( $CT['side'] == 'U' ){
  191. $FID = intval( $CT['far_module_id'] );
  192. $NID = intval( $CT['near_module_id'] );
  193. if( !$FID ) $MODS['UL']=$CT['id'];
  194. if( !$NID ) $MODS['UR']=$CT['id'];
  195. $ATN = $CT['name'];
  196. $ATS = $CT['short'];
  197. } else {
  198. $FID = intval( $CT['far_module_id'] );
  199. $NID = intval( $CT['near_module_id'] );
  200. if( !$FID ) $MODS['BR']=$CT['id'];
  201. if( !$NID ) $MODS['BL']=$CT['id'];
  202. $BTN = $CT['name'];
  203. $BTS = $CT['short'];
  204. };
  205. };
  206. //If no mods = all are defined
  207. if( count( $MODS ) ){
  208. $PAPA = array();
  209. $LOCK = count( $MODS );
  210. $CVAL = '';
  211. foreach( $MODS as $KEY=>$VALUE ){
  212. $PAPA[] = "['".$KEY . "','" .$Labels->GetLabel( 'MOD_LOC_'.$KEY ) . "','" .'/style/assets/ms_'.strtolower( $KEY ).".png']";
  213. if( $CVAL == '' ) $CVAL = $KEY;
  214. };
  215. $CDATA = implode(',', $PAPA );
  216. $WTPL =<<<DATA_BOUNDARY
  217. {
  218. id: 'huba_buba',
  219. title: "{$Labels->GetLabel( '_ADD_MODULE_' )}",
  220. modal: true,
  221. resizable: false,
  222. width: 450,
  223. height: 290,
  224. items:[{
  225. xtype: 'form',
  226. labelWidth: 150,
  227. labelAlign: 'right',
  228. items: [{
  229. xtype: 'textfield',
  230. fieldLabel: "{$Labels->GetLabel( 'MOD_NAME' )}",
  231. id: 'mod_name',
  232. width: 200,
  233. },{
  234. xtype: 'textfield',
  235. fieldLabel: "{$Labels->GetLabel( 'MOD_IP' )}",
  236. id: 'mod_ip',
  237. width: 200,
  238. },{
  239. xtype: 'textfield',
  240. fieldLabel: "{$Labels->GetLabel( 'MOD_IDENT' )}",
  241. id: 'mod_id',
  242. width: 200,
  243. },{
  244. xtype: 'combo',
  245. fieldLabel: "{$Labels->GetLabel( 'MOD_LOCATION' )}",
  246. id: 'mod_loc',
  247. width: 200,
  248. lazyRender: true,
  249. mode: 'local',
  250. forceSelection: true,
  251. triggerAction: 'all',
  252. editable: false,
  253. readOnly: ({$LOCK}==1),
  254. disableKeyFilter: true,
  255. tpl:'<tpl for="."><div class="x-combo-list-item"><img width="16px" src="{icon}"/>&nbsp;{name}</div></tpl>',
  256. store: new Ext.data.ArrayStore({
  257. fields: ['abbr','name','icon'],
  258. data: [{$CDATA}]
  259. }),
  260. valueField: 'abbr',
  261. displayField: 'name',
  262. value: '{$CVAL}',
  263. listeners:{
  264. select: function( t, r, i ){
  265. t.getEl().setStyle({
  266. 'background-image': 'url(' + r.data.icon + ')',
  267. 'background-repeat': 'no-repeat',
  268. 'background-position': '3px center',
  269. 'background-size': '16px 16px',
  270. 'padding-left': '25px'
  271. });
  272. },
  273. afterrender: function( t ){
  274. t.getEl().setStyle({
  275. 'background-image': 'url(' + t.store.data.items[t.store.findExact( 'abbr', t.value )].data.icon + ')',
  276. 'background-repeat': 'no-repeat',
  277. 'background-position': '3px center',
  278. 'background-size': '16px 16px',
  279. 'padding-left': '25px'
  280. });
  281. }
  282. }
  283. },{
  284. xtype: 'panel',
  285. id: 'infopan',
  286. html: '<table width="100%" border=1><tr><td class="mod_sch_ucell">{$ATN}[{$ATS}]</td></tr><tr><td class="mod_sch_bcell">{$BTN}[{$BTS}]</td></tr></table>'
  287. }]
  288. }],
  289. bbar:[{
  290. text: '{$Labels->GetLabel( '_CANCEL_' )}',
  291. handler: function(){
  292. var tt = Ext.getCmp('huba_buba');
  293. tt.close();
  294. }
  295. },{
  296. text: '{$Labels->GetLabel( '_ADD_' )}',
  297. handler: function(){
  298. var name = Ext.getCmp('mod_name').getValue();
  299. var addr = Ext.getCmp('mod_ip').getValue();
  300. var iden = Ext.getCmp('mod_id').getValue();
  301. var loca = Ext.getCmp('mod_loc').getValue();
  302. Ext.Ajax.request({
  303. url: '/lib/controller/doModuleOperations.php',
  304. params: {
  305. OPID: 300,
  306. NAM: name,
  307. I4P: addr,
  308. PID: {$PID},
  309. IDT: iden,
  310. LOC: loca,
  311. UID: {$UserID},
  312. SID: '{$Session}'
  313. },
  314. success: function( response, opts ){
  315. // If the response is JSON, you have to decode it
  316. var data = Ext.decode(response.responseText);
  317. if( data.status == 'ok' ){
  318. addModuleWindow.close();
  319. loadModules();
  320. } else {
  321. Ext.Msg.show({
  322. title: "{$Labels->GetLabel("_INFO_MSG_")}",
  323. msg: data.msg,
  324. buttons: Ext.Msg.OK,//YESNOCANCEL,
  325. fn: function(){
  326. //SettingsLidar3D.hide();
  327. },
  328. icon: Ext.MessageBox.INFO //QUESTION
  329. });
  330. }
  331. },
  332. failure: failureAJAXFunction
  333. });
  334. }
  335. }]
  336. }
  337. DATA_BOUNDARY;
  338. };
  339. echo $WTPL;
  340. } else {
  341. echo '{ xtype: \'panel\', html: \'Error Creating Tracks On Platform (to fix)!\'}';
  342. };
  343. };
  344. } else {
  345. header('location: /');
  346. };
  347. ?>