From 5a870ea7e0a77fef24857d5ee66c406c71f2f631 Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Sun, 16 Aug 2026 20:50:56 +0300 Subject: [PATCH] Workaround for No Track problem --- lib/controller/doPlatformOperations.php | 6 +- lib/controller/getAddModuleWindow.php | 178 +++++++++++++++++++++++- 2 files changed, 180 insertions(+), 4 deletions(-) diff --git a/lib/controller/doPlatformOperations.php b/lib/controller/doPlatformOperations.php index 3fd2b4f..81d7235 100644 --- a/lib/controller/doPlatformOperations.php +++ b/lib/controller/doPlatformOperations.php @@ -31,7 +31,7 @@ $PID = $DATABASE->getLastInsertID(); if( $PID ){ if( $LAY == 'A' || $LAY == 'B' ){ - $QS = "INSERT INTO `metro_tracks`(`platform_id`,`name`,`short`) VALUES({$PID},{$UP_TRN},{$UP_TRA})"; + $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')"; $DATABASE->Query( $QS ); } else { $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')"; @@ -39,8 +39,8 @@ $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'B','{$BT_TRN}','{$BT_TRA}')"; $DATABASE->Query( $QS ); }; - $QS="INSERT INTO `modbus_modules` SET `platform_id`={$PID}"; - $DATABASE->Query( $QS ); + //$QS="INSERT INTO `modbus_modules` SET `platform_id`={$PID}"; + //$DATABASE->Query( $QS ); $Data['success'] = true; $LOG->reg_op( $_POST ); }; diff --git a/lib/controller/getAddModuleWindow.php b/lib/controller/getAddModuleWindow.php index 8bb4f59..eef6ba9 100644 --- a/lib/controller/getAddModuleWindow.php +++ b/lib/controller/getAddModuleWindow.php @@ -164,7 +164,183 @@ DATA_BOUNDARY; }; echo $WTPL; } else { - echo '{ xtype: \'panel\', html: \'No Tracks On Platform!\'}'; + $QS = "SELECT * FROM `metro_platforms` WHERE `id`={$PID}"; + $RR = $DATABASE->Query( $QS, false ); + $UP_TRN = "Platform_{$PID}_UTR"; + $BT_TRN = "Platform_{$PID}_BTR"; + $UP_TRA = "{$PID}_UTR"; + $BT_TRA = "{$PID}_BTR"; + if( $RR[0]['layout'] == 'A' || $LAY == 'B' ){ + $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')"; + $DATABASE->Query( $QS ); + } else { + $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'U','{$UP_TRN}','{$UP_TRA}')"; + $DATABASE->Query( $QS ); + $QS = "INSERT INTO `metro_tracks`(`platform_id`,`side`,`name`,`short`) VALUES({$PID},'B','{$BT_TRN}','{$BT_TRA}')"; + $DATABASE->Query( $QS ); + }; + $QS = "SELECT * FROM `metro_tracks` WHERE `platform_id`={$PID}"; + $RR = $DATABASE->Query( $QS, false ); + if( count( $RR ) ){ + $MODS = array(); + $ATN = ''; + $ATS = ''; + $BTN = ''; + $BTS = ''; + foreach( $RR as $CT ){ + if( $CT['side'] == 'U' ){ + $FID = intval( $CT['far_module_id'] ); + $NID = intval( $CT['near_module_id'] ); + if( !$FID ) $MODS['UL']=$CT['id']; + if( !$NID ) $MODS['UR']=$CT['id']; + $ATN = $CT['name']; + $ATS = $CT['short']; + } else { + $FID = intval( $CT['far_module_id'] ); + $NID = intval( $CT['near_module_id'] ); + if( !$FID ) $MODS['BR']=$CT['id']; + if( !$NID ) $MODS['BL']=$CT['id']; + $BTN = $CT['name']; + $BTS = $CT['short']; + }; + }; + //If no mods = all are defined + if( count( $MODS ) ){ + $PAPA = array(); + $LOCK = count( $MODS ); + $CVAL = ''; + foreach( $MODS as $KEY=>$VALUE ){ + $PAPA[] = "['".$KEY . "','" .$Labels->GetLabel( 'MOD_LOC_'.$KEY ) . "','" .'/style/assets/ms_'.strtolower( $KEY ).".png']"; + if( $CVAL == '' ) $CVAL = $KEY; + }; + $CDATA = implode(',', $PAPA ); + $WTPL =<<GetLabel( '_ADD_MODULE_' )}", + modal: true, + resizable: false, + width: 450, + height: 290, + items:[{ + xtype: 'form', + labelWidth: 150, + labelAlign: 'right', + items: [{ + xtype: 'textfield', + fieldLabel: "{$Labels->GetLabel( 'MOD_NAME' )}", + id: 'mod_name', + width: 200, + },{ + xtype: 'textfield', + fieldLabel: "{$Labels->GetLabel( 'MOD_IP' )}", + id: 'mod_ip', + width: 200, + },{ + xtype: 'textfield', + fieldLabel: "{$Labels->GetLabel( 'MOD_IDENT' )}", + id: 'mod_id', + width: 200, + },{ + xtype: 'combo', + fieldLabel: "{$Labels->GetLabel( 'MOD_LOCATION' )}", + id: 'mod_loc', + width: 200, + lazyRender: true, + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + readOnly: ({$LOCK}==1), + disableKeyFilter: true, + tpl:'
 {name}
', + store: new Ext.data.ArrayStore({ + fields: ['abbr','name','icon'], + data: [{$CDATA}] + }), + valueField: 'abbr', + displayField: 'name', + value: '{$CVAL}', + listeners:{ + select: function( t, r, i ){ + t.getEl().setStyle({ + 'background-image': 'url(' + r.data.icon + ')', + 'background-repeat': 'no-repeat', + 'background-position': '3px center', + 'background-size': '16px 16px', + 'padding-left': '25px' + }); + }, + afterrender: function( t ){ + t.getEl().setStyle({ + 'background-image': 'url(' + t.store.data.items[t.store.findExact( 'abbr', t.value )].data.icon + ')', + 'background-repeat': 'no-repeat', + 'background-position': '3px center', + 'background-size': '16px 16px', + 'padding-left': '25px' + }); + } + } + },{ + xtype: 'panel', + id: 'infopan', + html: '
{$ATN}[{$ATS}]
{$BTN}[{$BTS}]
' + }] + }], + bbar:[{ + text: '{$Labels->GetLabel( '_CANCEL_' )}', + handler: function(){ + var tt = Ext.getCmp('huba_buba'); + tt.close(); + } + },{ + text: '{$Labels->GetLabel( '_ADD_' )}', + handler: function(){ + var name = Ext.getCmp('mod_name').getValue(); + var addr = Ext.getCmp('mod_ip').getValue(); + var iden = Ext.getCmp('mod_id').getValue(); + var loca = Ext.getCmp('mod_loc').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/doModuleOperations.php', + params: { + OPID: 300, + NAM: name, + I4P: addr, + PID: {$PID}, + IDT: iden, + LOC: loca, + UID: {$UserID}, + SID: '{$Session}' + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + if( data.status == 'ok' ){ + addModuleWindow.close(); + loadModules(); + } else { + Ext.Msg.show({ + title: "{$Labels->GetLabel("_INFO_MSG_")}", + msg: data.msg, + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + //SettingsLidar3D.hide(); + }, + icon: Ext.MessageBox.INFO //QUESTION + }); + } + }, + failure: failureAJAXFunction + }); + } + }] +} +DATA_BOUNDARY; + }; + echo $WTPL; + } else { + echo '{ xtype: \'panel\', html: \'Error Creating Tracks On Platform (to fix)!\'}'; + }; }; } else { header('location: /');