set_backend.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. ini_set('error_reporting', E_ALL | E_STRICT);
  3. $tag_header = 'set';
  4. include 'head.php';
  5. $obj = json_decode(trim($output[3]));//var_dump($obj);
  6. $system = json_decode(trim($output[0]));
  7. $ModelName = $system->{'ModelName'};
  8. $OcppConnStatus='';
  9. switch ($obj->{'OcppConnStatus'}){
  10. case 0:
  11. $OcppConnStatus='disconnected';
  12. break;
  13. case 1:
  14. $OcppConnStatus='connected';
  15. break;
  16. }
  17. $MaintainServerConnStatus='';
  18. switch ($obj->{'MaintainServerConnStatus'}){
  19. case 0:
  20. $MaintainServerConnStatus='disconnected';
  21. break;
  22. case 1:
  23. $MaintainServerConnStatus='connected';
  24. break;
  25. }
  26. ?>
  27. <style>
  28. img {
  29. display: block;
  30. margin-left: auto;
  31. margin-right: auto;
  32. }
  33. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  34. /* Colors: Default (blue) */
  35. .toggle-switchy {color:#fff;}
  36. .toggle-switchy > input + .toggle:before {content:'Yes';}
  37. .toggle-switchy > input + .toggle:after {content:'No';}
  38. .toggle-switchy > input + .toggle > .switch {background:#fff;}
  39. .toggle-switchy > input + .toggle + .label {color:#000;}
  40. .toggle-switchy > input:checked + .toggle {background:#3498db;}
  41. .toggle-switchy > input:not(:checked) + .toggle {background:#ccc;}
  42. .toggle-switchy > input:checked + .toggle > .switch {border:3px solid #3498db;}
  43. .toggle-switchy > input:not(:checked) + .toggle > .switch {border:3px solid #ccc;}
  44. .toggle-switchy > input:focus + .toggle,
  45. .toggle-switchy > input:active + .toggle {box-shadow:0 0 5px 3px rgba(0, 119, 200, 0.50);}
  46. /* Rounded switch corners */
  47. .toggle-switchy > input + .toggle {border-radius:4px;}
  48. .toggle-switchy > input + .toggle .switch {border-radius:6px;}
  49. /* //////////////////////////
  50. CORE STYLES BELOW - NO TOUCHY
  51. ////////////////////////// */
  52. .toggle-switchy {display:inline-flex; align-items:center; user-select:none; position:relative;}
  53. .toggle-switchy:hover {cursor:pointer;}
  54. .toggle-switchy > input {position:absolute; opacity:0;}
  55. .toggle-switchy > input + .toggle {align-items:center; position:relative;}
  56. .toggle-switchy > input + .toggle {overflow:hidden; position:relative; flex-shrink:0;}
  57. .toggle-switchy > input[disabled] + .toggle {opacity:0.5;}
  58. .toggle-switchy > input[disabled] + .toggle:hover {cursor:not-allowed;}
  59. .toggle-switchy > input + .toggle {width:100%; height:100%; margin:0; cursor:pointer;}
  60. .toggle-switchy > input + .toggle > .switch {display:block; height:100%; position:absolute; right:0; z-index:3;}
  61. /* Labels */
  62. .toggle-switchy > input + .toggle:before,
  63. .toggle-switchy > input + .toggle:after {display:flex; align-items:center; position:absolute; z-index:2; height:100%;}
  64. .toggle-switchy > input + .toggle:before {right:55%;}
  65. .toggle-switchy > input + .toggle:after {left:50%;}
  66. .toggle-switchy > input + .toggle + .label {margin-left:10px;}
  67. .toggle-switchy[data-label='left'] > input + .toggle {order:2;}
  68. .toggle-switchy[data-label='left'] > input + .toggle + .label {order:1; margin-left:0; margin-right:10px;}
  69. /* Show / Hide */
  70. .toggle-switchy > input + .toggle:before {opacity:0;}
  71. .toggle-switchy > input:checked + .toggle:before {opacity:1;}
  72. .toggle-switchy > input:checked + .toggle:after {opacity:0;}
  73. /* Transitions */
  74. .toggle-switchy > input + .toggle {transition:background 200ms linear, box-shadow 200ms linear;}
  75. .toggle-switchy > input + .toggle:before,
  76. .toggle-switchy > input + .toggle:after {transition:all 200ms linear;}
  77. .toggle-switchy > input + .toggle > .switch {transition:right 200ms linear, border-color 200ms linear;}
  78. /* //////////////////////////
  79. CORE STYLES ABOVE - NO TOUCHY
  80. ////////////////////////// */
  81. /* Size: Extra Large */
  82. .toggle-switchy[data-size='xl'] > input + .toggle {width:85px; height:40px;}
  83. .toggle-switchy[data-size='xl'] > input + .toggle > .switch {width:40px;}
  84. .toggle-switchy[data-size='xl'] > input + .toggle:before,
  85. .toggle-switchy[data-size='xl'] > input + .toggle:after {font-size:1.2rem;}
  86. .toggle-switchy[data-size='xl'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 40px);}
  87. /* Size: Large */
  88. .toggle-switchy[data-size='lg'] > input + .toggle {width:75px; height:35px;}
  89. .toggle-switchy[data-size='lg'] > input + .toggle > .switch {width:35px;}
  90. .toggle-switchy[data-size='lg'] > input + .toggle:before,
  91. .toggle-switchy[data-size='lg'] > input + .toggle:after {font-size:1rem;}
  92. .toggle-switchy[data-size='lg'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 35px);}
  93. /* Size: Default (Medium) */
  94. .toggle-switchy > input + .toggle {width:100px; height:30px;}
  95. .toggle-switchy > input + .toggle > .switch {width:30px;}
  96. .toggle-switchy > input + .toggle:before,
  97. .toggle-switchy > input + .toggle:after {font-size:0.8rem;}
  98. .toggle-switchy > input:not(:checked) + .toggle > .switch {right:calc(100% - 30px);}
  99. /* Size: Small */
  100. .toggle-switchy[data-size='sm'] > input + .toggle {width:55px; height:25px;}
  101. .toggle-switchy[data-size='sm'] > input + .toggle > .switch {width:25px;}
  102. .toggle-switchy[data-size='sm'] > input + .toggle:before,
  103. .toggle-switchy[data-size='sm'] > input + .toggle:after {font-size:0.7rem;}
  104. .toggle-switchy[data-size='sm'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 25px);}
  105. /* Size: Extra Small */
  106. .toggle-switchy[data-size='xs'] > input + .toggle {width:45px; height:20px;}
  107. .toggle-switchy[data-size='xs'] > input + .toggle > .switch {width:20px;}
  108. .toggle-switchy[data-size='xs'] > input + .toggle:before,
  109. .toggle-switchy[data-size='xs'] > input + .toggle:after {font-size:0.5rem;}
  110. .toggle-switchy[data-size='xs'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 20px);}
  111. /* Style: Rounded */
  112. .toggle-switchy[data-style='rounded'] > input + .toggle,
  113. .toggle-switchy[data-style='rounded'] > input + .toggle > .switch {border-radius:50px;}
  114. .toggle-switchy[data-style='rounded'] > input + .toggle:before {right:30%;}
  115. .toggle-switchy[data-style='rounded'] > input + .toggle:after {left:40%;}
  116. /* Style: Square */
  117. .toggle-switchy[data-style='square'] > input + .toggle {border-radius:0;}
  118. .toggle-switchy[data-style='square'] > input + .toggle .switch {border-radius:0;}
  119. /* Text: Off */
  120. .toggle-switchy[data-text='false'] > input + .toggle:before,
  121. .toggle-switchy[data-text='false'] > input + .toggle:after {content:'';}
  122. .toggle-switchy[data-text='false'][data-size='xl'] > input + .toggle {width:80px;}
  123. .toggle-switchy[data-text='false'][data-size='lg'] > input + .toggle {width:70px;}
  124. .toggle-switchy[data-text='false'] > input + .toggle {width:60px;}
  125. .toggle-switchy[data-text='false'][data-size='sm'] > input + .toggle {width:50px;}
  126. .toggle-switchy[data-text='false'][data-size='xs'] > input + .toggle {width:40px;}
  127. /* Color: Red */
  128. .toggle-switchy[data-color='red'] > input:checked + .toggle {background:#e74c3c;}
  129. .toggle-switchy[data-color='red'] > input:checked + .toggle > .switch {border-color:#e74c3c;}
  130. /* Color: Orange */
  131. .toggle-switchy[data-color='orange'] > input:checked + .toggle {background:#e67e22;}
  132. .toggle-switchy[data-color='orange'] > input:checked + .toggle > .switch {border-color:#e67e22;}
  133. /* Color: Yellow */
  134. .toggle-switchy[data-color='yellow'] > input:checked + .toggle {background:#f1c40f;}
  135. .toggle-switchy[data-color='yellow'] > input:checked + .toggle > .switch {border-color:#f1c40f;}
  136. /* Color: Green */
  137. .toggle-switchy[data-color='green'] > input:checked + .toggle {background:#2ecc71;}
  138. .toggle-switchy[data-color='green'] > input:checked + .toggle > .switch {border-color:#2ecc71;}
  139. /* Color: Blue */
  140. .toggle-switchy[data-color='blue'] > input:checked + .toggle {background:#3498db;}
  141. .toggle-switchy[data-color='blue'] > input:checked + .toggle > .switch {border-color:#3498db;}
  142. /* Color: Purple */
  143. .toggle-switchy[data-color='purple'] > input:checked + .toggle {background:#9b59b6;}
  144. .toggle-switchy[data-color='purple'] > input:checked + .toggle > .switch {border-color:#9b59b6;}
  145. /* Color: Gray */
  146. .toggle-switchy[data-color='gray'] > input:checked + .toggle {background:#555;}
  147. .toggle-switchy[data-color='gray'] > input:checked + .toggle > .switch {border-color:#555;}
  148. <?php } ?>
  149. </style>
  150. <div class="envor-content">
  151. <!--
  152. Page Title start
  153. //-->
  154. <section class="envor-page-title-1" data-stellar-background-ratio="0.5">
  155. <div class="container">
  156. <div class="row">
  157. <div class="col-lg-9 col-md-9 col-sm-9">
  158. <h1><?php echo $lang->showWord("backend"); ?></h1>
  159. </div>
  160. </div>
  161. </div>
  162. <!--
  163. Page Title end
  164. //-->
  165. </section>
  166. <!--
  167. Main Content start
  168. //-->
  169. <a id="loadinghref"><div id="loading" style="display:none;"><img src="img/giphy.gif"/></div></a>
  170. <section class="envor-section">
  171. <div class="container">
  172. <div class="row">
  173. <div class="col-lg-12">
  174. <div class="envor-sorting" id="faq-sorting">
  175. <div class="envor-toggle">
  176. <!--Common Information-->
  177. <article class="envor-sorting-item css">
  178. <header><?php echo $lang->showWord("common_information"); ?><i class="fa fa-plus"></i></header>
  179. <section>
  180. <div class="form-group" style="display:<?php echo $am101;?>">
  181. <label>Backend Connection Timeout</label>
  182. <input type="text" name="BackendConnTimeout" id="BackendConnTimeout" class="form-control" value="<?php echo $obj->{'BackendConnTimeout'};?>">
  183. <small class="form-text text-muted-red">seconds</small>
  184. </div>
  185. <div class="form-group" style="display:<?php echo $am101;?>">
  186. <label>Offline Policy</label>
  187. <select class="form-control" id="OfflinePolicy" name="OfflinePolicy">
  188. <option value="0" <?php echo $obj->{'OfflinePolicy'}=="0"?"selected":""?>>local list</option>
  189. <?php /* <option value="1" <?php echo $obj->{'OfflinePolicy'}=="1"?"selected":""?>>Phihong RFID tag</option>*/?>
  190. <option value="2" <?php echo $obj->{'OfflinePolicy'}=="2"?"selected":""?>>free charging</option>
  191. <option value="3" <?php echo $obj->{'OfflinePolicy'}=="3"?"selected":""?>>no charging</option>
  192. </select>
  193. </div>
  194. <div class="form-group" style="display:<?php echo $am101;?>">
  195. <label>Offline Max Charge Energy</label>
  196. <small class="form-text text-muted-red">kWh</small>
  197. <input type="text" name="OfflineMaxChargeEnergy" id="OfflineMaxChargeEnergy" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeEnergy'};?>">
  198. </div>
  199. <div class="form-group" style="display:<?php echo $am101;?>">
  200. <label>Offline Max Charge Duration</label>
  201. <small class="form-text text-muted-red">minutes</small>
  202. <input type="text" name="OfflineMaxChargeDuration" id="OfflineMaxChargeDuration" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeDuration'};?>">
  203. </div>
  204. </section>
  205. </article>
  206. <!--OCPP Backend-->
  207. <article class="envor-sorting-item css">
  208. <header><?php echo $lang->showWord("OCPP_backend"); ?><i class="fa fa-plus"></i></header>
  209. <section>
  210. <div class="form-group" style="display:<?php echo $am101;?>">
  211. <label>Ocpp Connection Status</label>
  212. <input type="text" readonly class="form-control" placeholder="<?php echo $OcppConnStatus;?>">
  213. <input type="hidden" name="OcppConnStatus" id="OcppConnStatus" value="<?php echo $obj->{'OcppConnStatus'};?>">
  214. </div>
  215. <div class="form-group" style="display:<?php echo $am101;?>">
  216. <label>Central System URL</label>
  217. <input type="text" name="OcppServerURL" id="OcppServerURL" class="form-control" value="<?php echo $obj->{'OcppServerURL'};?>">
  218. </div>
  219. <div class="form-group" style="display:<?php echo $am101;?>">
  220. <label>Charge Box Id</label>
  221. <input type="text" name="ChargeBoxId" id="ChargeBoxId" class="form-control" value="<?php echo $obj->{'ChargeBoxId'};?>">
  222. </div>
  223. <div class="form-group" style="display:<?php echo $am101;?>">
  224. <label>Charge Point Vendor</label>
  225. <input type="text" name="chargePointVendor" id="chargePointVendor" class="form-control" value="<?php echo $obj->{'chargePointVendor'};?>">
  226. </div>
  227. <div class="form-group" style="display:<?php echo $am101;?>">
  228. <label>Ocpp Security Profile</label>
  229. <select class="form-control" id="OcppSecurityProfile" name="OcppSecurityProfile" onchange="OcppSecurityProfile_changed()">
  230. <option value="0" <?php echo $obj->{'OcppSecurityProfile'}=="0"?"selected":""?>>None security</option>
  231. <option value="1" <?php echo $obj->{'OcppSecurityProfile'}=="1"?"selected":""?>>Unsecured Transport with Basic Atuentication</option>
  232. <option value="2" <?php echo $obj->{'OcppSecurityProfile'}=="2"?"selected":""?>>TLS with Basic Authentication</option>
  233. </select>
  234. </div>
  235. <div id="OcppSecurityPasswordDiv" class="form-group" style="display:<?php echo $am101;?>">
  236. <label>Ocpp Security Password</label>
  237. <input type="text" name="OcppSecurityPassword" id="OcppSecurityPassword" class="form-control" value="<?php echo $obj->{'OcppSecurityPassword'};?>">
  238. </div>
  239. <?php if(substr($ModelName,0,2)=="AX" || substr($ModelName,0,1)=="D"){?>
  240. <div class="form-group" style="display:block">
  241. <label>Ocpp Receipt URL</label>
  242. <input type="text" name="OcppReceiptrURL" id="OcppReceiptrURL" class="form-control" value="<?php echo $obj->{'OcppReceiptrURL'};?>">
  243. </div>
  244. <?php } if(substr($ModelName,0,2)=="AX"){?>
  245. <div class="form-group" style="display:block">
  246. <label>Local Loading Balance</label>
  247. <select class="form-control" id="isEnableLocalPowerSharging" name="isEnableLocalPowerSharging" onChange="isEnableLocalPowerSharging_changed()">
  248. <option value="0" <?php echo $obj->{'isEnableLocalPowerSharging'}=="0"?"selected":""?>>disable</option>
  249. <option value="1" <?php echo $obj->{'isEnableLocalPowerSharging'}=="1"?"selected":""?>>enable</option>
  250. </select>
  251. </div>
  252. <?php } ?>
  253. <div class="form-group" style="display:<?php echo $am101;?>">
  254. <label>Maintain Server Connection Status</label>
  255. <input type="text" readonly class="form-control" placeholder="<?php echo $MaintainServerConnStatus;?>">
  256. <input type="hidden" name="MaintainServerConnStatus" id="MaintainServerConnStatus" value="<?php echo $obj->{'MaintainServerConnStatus'};?>">
  257. </div>
  258. <div class="form-group" style="display:<?php echo $am101;?>">
  259. <label>Maintain Server URL</label>
  260. <input type="text" name="MaintainServerURL" id="MaintainServerURL" class="form-control" value="<?php echo $obj->{'MaintainServerURL'};?>">
  261. </div>
  262. <div class="form-group" style="display:<?php echo $am101;?>">
  263. <label>Maintain Server Security Profile</label>
  264. <select class="form-control" id="MaintainServerSecurityProfile" name="MaintainServerSecurityProfile" onchange="MaintainServerSecurityProfile_changed()">
  265. <option value="0" <?php echo $obj->{'MaintainServerSecurityProfile'}=="0"?"selected":""?>>None security</option>
  266. <option value="1" <?php echo $obj->{'MaintainServerSecurityProfile'}=="1"?"selected":""?>>Unsecured Transport with Basic Atuentication</option>
  267. <option value="2" <?php echo $obj->{'MaintainServerSecurityProfile'}=="2"?"selected":""?>>TLS with Basic Authentication</option>
  268. </select>
  269. </div>
  270. <div id="MaintainServerSecurityPasswordDiv" class="form-group" style="display:<?php echo $am101;?>">
  271. <label>Maintain Server Security Password</label>
  272. <input type="text" name="MaintainServerSecurityPassword" id="MaintainServerSecurityPassword" class="form-control" value="<?php echo $obj->{'MaintainServerSecurityPassword'};?>">
  273. </div>
  274. </section>
  275. </article>
  276. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){ ?>
  277. <!--TTIA-->
  278. <article class="envor-sorting-item css">
  279. <header>TTIA<i class="fa fa-plus"></i></header>
  280. <section>
  281. <div class="form-group" style="display:<?php echo $am101;?>">
  282. <label>TTIA</label>
  283. <label class="toggle-switchy" for="isEnableTTIA" data-size="" data-style="rounded">
  284. <input type="checkbox" id="isEnableTTIA" <?php echo $obj->{'isEnableTTIA'}==1?"checked":"";?> onclick="isEnableTTIAChecked()">
  285. <span class="toggle">
  286. <span class="switch"></span>
  287. </span>
  288. </label>
  289. </div>
  290. <div id="server_addrDiv" class="form-group">
  291. <label>Server Address</label>
  292. <input type="text" name="server_addr" id="server_addr" class="form-control" value="<?php echo $obj->{'server_addr'};?>">
  293. </div>
  294. <div id="server_portDiv" class="form-group">
  295. <label>Server Port</label>
  296. <input type="text" name="server_port" id="server_port" class="form-control" value="<?php echo $obj->{'server_port'};?>">
  297. </div>
  298. <div id="busVenderIdDiv" class="form-group">
  299. <label>Bus Vender Id</label>
  300. <input type="text" name="busVenderId" id="busVenderId" class="form-control" value="<?php echo $obj->{'busVenderId'};?>">
  301. </div>
  302. <div id="EquipmentProviderDiv" class="form-group">
  303. <label>Equipment Provider</label>
  304. <input type="text" name="EquipmentProvider" id="EquipmentProvider" class="form-control" value="<?php echo $obj->{'EquipmentProvider'};?>">
  305. </div>
  306. <div id="TransportationCompanyNoDiv" class="form-group">
  307. <label>TransportationCompanyNo</label>
  308. <input type="text" name="TransportationCompanyNo" id="TransportationCompanyNo" class="form-control" value="<?php echo $obj->{'TransportationCompanyNo'};?>">
  309. </div>
  310. <div id="ChargeBoxIdDiv" class="form-group">
  311. <label>Charge Box Id</label>
  312. <input type="text" name="TTIAChargeBoxId" id="TTIAChargeBoxId" class="form-control" value="<?php echo $obj->{'TTIAChargeBoxId'};?>">
  313. </div>
  314. <div id="evseStationDiv" class="form-group">
  315. <label>EVSE Station</label>
  316. <input type="text" name="evseStation" id="evseStation" class="form-control" value="<?php echo $obj->{'evseStation'};?>">
  317. </div>
  318. </section>
  319. </article>
  320. <?php } ?>
  321. <article class="envor-sorting-item css">
  322. <div align="center"><button id="save"><?php echo $lang->showWord("set")?></button></div>
  323. </article>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. </section>
  330. </div>
  331. <?php
  332. include 'foot.php';
  333. ?>
  334. <script type="text/JavaScript">
  335. <?php if(substr($ModelName,0,2)=="AX"){?>
  336. $(document).ready(function(){
  337. isEnableLocalPowerSharging_changed();
  338. });
  339. <?php } ?>
  340. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  341. $(document).ready(function(){
  342. isEnableTTIAChecked();
  343. });
  344. <?php } ?>
  345. OcppSecurityProfile_changed();
  346. MaintainServerSecurityProfile_changed();
  347. document.getElementById("save").onclick = function() {
  348. if(formCheck())
  349. {
  350. window.location="#loadinghref";
  351. document.getElementById("loading").style.display="block";
  352. // 發送 Ajax 查詢請求並處理
  353. var request = new XMLHttpRequest();
  354. request.open("POST", "set_backend_action.php");
  355. // POST 參數須使用 send() 發送
  356. var data = "BackendConnTimeout=" + document.getElementById("BackendConnTimeout").value +
  357. "&OfflinePolicy=" + document.getElementById("OfflinePolicy").value +
  358. "&OfflineMaxChargeEnergy=" + document.getElementById("OfflineMaxChargeEnergy").value+
  359. "&OfflineMaxChargeDuration=" + document.getElementById("OfflineMaxChargeDuration").value+
  360. // "&OcppConnStatus=" + document.getElementById("OcppConnStatus").value+
  361. "&OcppServerURL=" + escape(document.getElementById("OcppServerURL").value)+
  362. "&MaintainServerURL=" + escape(document.getElementById("MaintainServerURL").value)+
  363. "&ChargeBoxId=" + escape(document.getElementById("ChargeBoxId").value)+
  364. "&chargePointVendor=" + escape(document.getElementById("chargePointVendor").value)+
  365. "&OcppSecurityProfile=" + document.getElementById("OcppSecurityProfile").value+
  366. "&OcppSecurityPassword=" + escape(document.getElementById("OcppSecurityPassword").value)+
  367. "&MaintainServerSecurityProfile=" + document.getElementById("MaintainServerSecurityProfile").value+
  368. "&MaintainServerSecurityPassword=" + escape(document.getElementById("MaintainServerSecurityPassword").value);
  369. <?php if(substr($ModelName,0,2)=="AX"){?>
  370. data += "&isEnableLocalPowerSharging=" + document.getElementById("isEnableLocalPowerSharging").value+
  371. "&OcppReceiptrURL=" + document.getElementById("OcppReceiptrURL").value;
  372. <?php } ?>
  373. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  374. data += "&isEnableTTIA=" + (document.getElementById("isEnableTTIA").checked?"1":"0")+
  375. "&server_addr=" + document.getElementById("server_addr").value+
  376. "&server_port=" + document.getElementById("server_port").value+
  377. "&busVenderId=" + document.getElementById("busVenderId").value+
  378. "&EquipmentProvider=" + document.getElementById("EquipmentProvider").value+
  379. "&TransportationCompanyNo=" + document.getElementById("TransportationCompanyNo").value+
  380. "&TTIAChargeBoxId=" + document.getElementById("TTIAChargeBoxId").value+
  381. "&evseStation=" + document.getElementById("evseStation").value;
  382. <?php } ?>
  383. // POST 請求必須設置表頭在 open() 下面,send() 上面
  384. request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  385. request.send(data);
  386. request.onreadystatechange = function() {
  387. // 伺服器請求完成
  388. if (request.readyState == 4) {
  389. document.getElementById("loading").style.display="none";
  390. // 伺服器回應成功
  391. if (request.status == 200 && JSON.parse(request.responseText).result=="Success") {
  392. alert("<?php echo $lang->showWord("done")?>");
  393. location.href="set_backend.php";
  394. } else {
  395. alert(JSON.parse(request.responseText).message);
  396. }
  397. request = null;
  398. }
  399. }
  400. }
  401. }
  402. function formCheck()
  403. {
  404. var OcppServerURL = document.getElementById("OcppServerURL").value;
  405. var MaintainServerURL = document.getElementById("MaintainServerURL").value;
  406. var ChargeBoxId = document.getElementById("ChargeBoxId").value;
  407. var chargePointVendor = document.getElementById("chargePointVendor").value;
  408. var tests=/^(ws|wss):\/\/((([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z0-9]+(([\-]?[a-zA-Z0-9]+)*\.)+)*[a-zA-Z]{2,}))+/;
  409. if(OcppServerURL!=""){
  410. if(OcppServerURL.match(tests)==null){
  411. alert("OcppServerURL format error!");
  412. document.getElementById("OcppServerURL").focus();
  413. return false;
  414. }
  415. }
  416. if(MaintainServerURL!=""){
  417. if(MaintainServerURL.match(tests)==null){
  418. alert("MaintainServerURL format error!");
  419. document.getElementById("MaintainServerURL").focus();
  420. return false;
  421. }
  422. }
  423. if(ChargeBoxId!=""){
  424. if(ChargeBoxId.length>25){
  425. alert("Length of ChargeBoxId should be less than 25!");
  426. document.getElementById("ChargeBoxId").focus();
  427. return false;
  428. }
  429. }
  430. if(chargePointVendor!=""){
  431. if(chargePointVendor.length>20){
  432. alert("Length of chargePointVendor should be less than 20!");
  433. document.getElementById("chargePointVendor").focus();
  434. return false;
  435. }
  436. }
  437. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  438. var server_port = document.getElementById("server_port").value;
  439. if(server_port!=""){
  440. if(server_port>65535){
  441. alert("Value of Server Port should be less than 65535!");
  442. document.getElementById("server_port").focus();
  443. return false;
  444. }
  445. }
  446. var busVenderId = document.getElementById("busVenderId").value;
  447. if(busVenderId!=""){
  448. if(busVenderId>65535){
  449. alert("Value of Bus Vender Id should be less than 65535!");
  450. document.getElementById("busVenderId").focus();
  451. return false;
  452. }
  453. }
  454. var EquipmentProvider = document.getElementById("EquipmentProvider").value;
  455. if(EquipmentProvider!=""){
  456. if(UTF8Length(EquipmentProvider)>15){
  457. alert("Length of Equipment Provider should be less than 15(Chinese 5 words)!");
  458. document.getElementById("EquipmentProvider").focus();
  459. return false;
  460. }
  461. }
  462. var evseStation = document.getElementById("evseStation").value;
  463. if(evseStation!=""){
  464. if(UTF8Length(evseStation)>15){
  465. alert("Length of EVSE Station should be less than 15(Chinese 5 words)!");
  466. document.getElementById("evseStation").focus();
  467. return false;
  468. }
  469. }
  470. var TransportationCompanyNo = document.getElementById("TransportationCompanyNo").value;
  471. if(TransportationCompanyNo!=""){
  472. if(TransportationCompanyNo>255){
  473. alert("Value of Transportation Company No should be less than 255!");
  474. document.getElementById("TransportationCompanyNo").focus();
  475. return false;
  476. }
  477. }
  478. var TTIAChargeBoxId = document.getElementById("TTIAChargeBoxId").value;
  479. if(TTIAChargeBoxId!=""){
  480. if(TTIAChargeBoxId>255){
  481. alert("Value of Charge Box Id should be less than 255!");
  482. document.getElementById("TTIAChargeBoxId").focus();
  483. return false;
  484. }
  485. }
  486. <?php } ?>
  487. return true;
  488. }
  489. function OcppSecurityProfile_changed(){
  490. if(document.getElementById("OcppSecurityProfile").value == "1" || document.getElementById("OcppSecurityProfile").value == "2"){
  491. document.getElementById("OcppSecurityPasswordDiv").style.display="block";
  492. }
  493. else{
  494. document.getElementById("OcppSecurityPasswordDiv").style.display="none";
  495. }
  496. }
  497. function MaintainServerSecurityProfile_changed(){
  498. if(document.getElementById("MaintainServerSecurityProfile").value == "1" || document.getElementById("MaintainServerSecurityProfile").value == "2"){
  499. document.getElementById("MaintainServerSecurityPasswordDiv").style.display="block";
  500. }
  501. else{
  502. document.getElementById("MaintainServerSecurityPasswordDiv").style.display="none";
  503. }
  504. }
  505. <?php if(substr($ModelName,0,2)=="AX"){?>
  506. function isEnableLocalPowerSharging_changed(){
  507. if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1){
  508. document.getElementById("OcppServerURL").setAttribute("readOnly","true");
  509. document.getElementById("MaintainServerURL").setAttribute("readOnly","true");
  510. document.getElementById("ChargeBoxId").setAttribute("readOnly","true");
  511. document.getElementById("chargePointVendor").setAttribute("readOnly","true");
  512. }
  513. else{
  514. document.getElementById("OcppServerURL").removeAttribute("readOnly");
  515. document.getElementById("MaintainServerURL").removeAttribute("readOnly");
  516. document.getElementById("ChargeBoxId").removeAttribute("readOnly");
  517. document.getElementById("chargePointVendor").removeAttribute("readOnly");
  518. }
  519. }
  520. <?php } ?>
  521. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  522. function isEnableTTIAChecked(){
  523. if(document.getElementById("isEnableTTIA").checked){
  524. document.getElementById("server_addrDiv").style.display="block";
  525. document.getElementById("server_portDiv").style.display="block";
  526. document.getElementById("busVenderIdDiv").style.display="block";
  527. document.getElementById("EquipmentProviderDiv").style.display="block";
  528. document.getElementById("TransportationCompanyNoDiv").style.display="block";
  529. document.getElementById("ChargeBoxIdDiv").style.display="block";
  530. document.getElementById("evseStationDiv").style.display="block";
  531. }
  532. else{
  533. document.getElementById("server_addrDiv").style.display="none";
  534. document.getElementById("server_portDiv").style.display="none";
  535. document.getElementById("busVenderIdDiv").style.display="none";
  536. document.getElementById("EquipmentProviderDiv").style.display="none";
  537. document.getElementById("TransportationCompanyNoDiv").style.display="none";
  538. document.getElementById("ChargeBoxIdDiv").style.display="none";
  539. document.getElementById("evseStationDiv").style.display="none";
  540. }
  541. }
  542. <?php } ?>
  543. function isNumberKey(evt)
  544. {
  545. var charCode = (evt.which) ? evt.which : event.keyCode
  546. if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode != 46))
  547. return false;
  548. return true;
  549. }
  550. function UTF8Length(tx){
  551. var str = encodeURIComponent(tx);
  552. len = str.replace(/%[A-F\d]{2}/g, 'U').length;
  553. return len;
  554. }
  555. </script>
  556. </html>