set_backend.php 26 KB

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