@@ -133,7 +133,7 @@ function ($table) {
133133 $ script = '' ;
134134 if (!empty ($ errors ))
135135 {
136- $ script = '<script>$("#tab3").prepend( \'<div class="alert alert-warning" role="alert"> ' .$ errors .'</div> \')</script> ' ;
136+ $ script = '<script>$("#ampAlert").remove(); $("# tab3").prepend( \'<div id="ampAlert" class="alert alert-warning" role="alert"> ' .$ errors .'</div> \')</script> ' ;
137137 }
138138
139139
@@ -144,6 +144,28 @@ function ($table) {
144144 $ options [$ t ['Id ' ]] = $ t ['Name ' ];
145145 }
146146
147+ $ scriptExtraProvisionSettings = '
148+ <script>
149+ $( \'[name="packageconfigoption[4]"] \').hide();
150+ clone.appendTo($( \'[name="packageconfigoption[4]"] \').parent()).show();
151+
152+
153+ formEl = document.getElementById("extraProvisionSettingsForm");
154+ tbodyEl = document.getElementById("extraProvisionSettingsTableBody");
155+ tableEl = document.getElementById("extraProvisionSettingsTable");
156+ formEl.addEventListener("submit", onAddWebsite);
157+ tableEl.addEventListener("click", onDeleteRow);
158+
159+
160+ try {
161+ a = JSON.parse($( \'[name="packageconfigoption[4]"] \').val());
162+ tbodyEl.innerHTML = "";
163+ for (const element of a) {
164+ tbodyEl.innerHTML += \'<tr><td> \'+element[0]+ \'</td><td> \'+element[1]+ \'</td><td><button class="btn btn-danger deleteBtn">Delete</button></td> </tr> \';
165+ }
166+ } catch(e) {}
167+
168+ </script> ' ;
147169 $ fields = [
148170 'Provisioning Template ' => array (
149171 'Type ' => 'dropdown ' ,
@@ -160,7 +182,20 @@ function ($table) {
160182 30 => 'Full application startup ' ,
161183 ],
162184 'Description ' => 'Choose one ' .$ script ,
163- )
185+ ),
186+ 'Required Tags ' => array (
187+ 'Type ' => 'text ' ,
188+ 'Size ' => '25 ' ,
189+ 'Default ' => '' ,
190+ 'Description ' => 'comma separated ' ,
191+ ),
192+ 'Extra Provision Settings ' => array (
193+ 'Type ' => 'text ' ,
194+ 'Size ' => '25 ' ,
195+ 'Default ' => '' ,
196+ 'Description ' => $ scriptExtraProvisionSettings ,
197+ ),
198+
164199 ];
165200 return $ fields ;
166201
@@ -229,6 +264,7 @@ function AMP_TestConnection(array $params)
229264
230265function AMP_CreateAccount (array $ params )
231266{
267+
232268 try {
233269 AMP_commercialCheck ($ params );
234270 $ client = new Client ($ params );
@@ -245,19 +281,28 @@ function AMP_CreateAccount(array $params)
245281 }
246282 }
247283
248- $ username = $ params ['userid ' ].$ params ['serviceid ' ];
284+ $ t = str_replace ("- " , "" , $ params ['clientsdetails ' ]['uuid ' ]);
285+ $ username = str_replace ('== ' ,'' , base64_encode (pack ("h* " , $ t )));
286+
249287 $ password = sprintf ('%04X%04X-%04X-%04X-%04X-%04X%04X%04X ' , mt_rand (0 , 65535 ), mt_rand (0 , 65535 ), mt_rand (0 , 65535 ), mt_rand (16384 , 20479 ), mt_rand (32768 , 49151 ), mt_rand (0 , 65535 ), mt_rand (0 , 65535 ), mt_rand (0 , 65535 ));
250288
251289 Capsule::table ('tblhosting ' )->updateOrInsert (['id ' => $ params ['serviceid ' ]], ['username ' => $ username , 'password ' => encrypt ($ password )]);
252290
291+ $ array = json_decode ($ params ['configoption4 ' ]);
292+ $ extraProvisionSettings = [];
293+ foreach ($ array as $ key => $ value ) {
294+ $ extraProvisionSettings [$ value [0 ]] = $ value [1 ];
295+ }
253296 $ data = [
254297 'TemplateID ' => $ provisioningTemplateId ,
255298 'NewUsername ' => $ username ,
256299 'NewPassword ' => $ password ,
257300 'Tag ' => $ params ['model ' ]->orderid ,
258301 'FriendlyName ' => '' ,
259302 'Secret ' => 'secretwhmcs ' . $ params ['serviceid ' ],
260- 'PostCreate ' => $ postCreate
303+ 'PostCreate ' => $ postCreate ,
304+ 'RequiredTags ' => explode (', ' , trim ($ params ['configoption3 ' ])),
305+ 'ExtraProvisionSettings ' => $ extraProvisionSettings
261306 ];
262307
263308
0 commit comments