@@ -224,52 +224,37 @@ private function isValidDomain(string $domain): bool
224224
225225 public function batchList ($ params )
226226 {
227- $ batches = [
228- [
229- 'reference ' => 'BT-2026-000184 ' ,
230- 'submittedAt ' => '10 Apr 2026, 10:22 ' ,
231- 'status ' => 'Processing ' ,
232- 'processed ' => 68 ,
233- 'total ' => 100 ,
234- 'success ' => 60 ,
235- 'failed ' => 8 ,
236- 'lastUpdated ' => '10 Apr 2026, 10:41 ' ,
237- ],
238- [
239- 'reference ' => 'BT-2026-000183 ' ,
240- 'submittedAt ' => '09 Apr 2026, 16:08 ' ,
241- 'status ' => 'Completed with errors ' ,
242- 'processed ' => 100 ,
243- 'total ' => 100 ,
244- 'success ' => 94 ,
245- 'failed ' => 6 ,
246- 'lastUpdated ' => '09 Apr 2026, 16:31 ' ,
247- ],
248- [
249- 'reference ' => 'BT-2026-000182 ' ,
250- 'submittedAt ' => '09 Apr 2026, 11:05 ' ,
251- 'status ' => 'Completed ' ,
252- 'processed ' => 40 ,
253- 'total ' => 40 ,
254- 'success ' => 40 ,
255- 'failed ' => 0 ,
256- 'lastUpdated ' => '09 Apr 2026, 11:14 ' ,
257- ],
258- [
259- 'reference ' => 'BT-2026-000181 ' ,
260- 'submittedAt ' => '08 Apr 2026, 18:45 ' ,
261- 'status ' => 'Queued ' ,
262- 'processed ' => 0 ,
263- 'total ' => 55 ,
264- 'success ' => 0 ,
265- 'failed ' => 0 ,
266- 'lastUpdated ' => '08 Apr 2026, 18:45 ' ,
267- ],
268- ];
227+ $ batches = [];
228+
229+ for ($ i = 184 ; $ i >= 170 ; $ i --) {
230+ $ total = rand (20 , 120 );
231+ $ processed = rand (0 , $ total );
232+ $ success = rand (0 , $ processed );
233+ $ failed = $ processed - $ success ;
234+
235+ $ statuses = ['Processing ' , 'Completed ' , 'Completed with errors ' , 'Queued ' ];
236+ $ status = $ statuses [array_rand ($ statuses )];
237+
238+ $ batches [] = [
239+ 'reference ' => 'BT-2026-00 ' . $ i ,
240+ 'submittedAt ' => date ('d M Y, H:i ' , strtotime ("- {$ i } minutes " )),
241+ 'status ' => $ status ,
242+ 'processed ' => $ processed ,
243+ 'total ' => $ total ,
244+ 'success ' => $ success ,
245+ 'failed ' => $ failed ,
246+ 'lastUpdated ' => date ('d M Y, H:i ' , strtotime ("- " . ($ i - 2 ) . " minutes " )),
247+ ];
248+ }
249+
250+ $ currentPage = $ this ->getCurrentPage ('page ' );
251+ $ perPage = 10 ;
252+ $ pagination = $ this ->paginateArray ($ batches , $ currentPage , $ perPage );
269253
270254 return $ this ->view ('bulk_domain_transfer/batch_list ' , [
271255 'LANG ' => $ params ['_lang ' ],
272- 'batches ' => $ batches ,
256+ 'batches ' => $ pagination ['items ' ],
257+ 'batchPagination ' => $ pagination ,
273258 ]);
274259 }
275260
@@ -286,47 +271,93 @@ public function batchDetails($params)
286271 'processed ' => 68 ,
287272 'successful ' => 60 ,
288273 'failed ' => 8 ,
289- 'progressPercentage ' => 68 ,
290274 ];
291275
276+ // calculate progress
277+ $ progressPercentage = $ batch ['totalDomains ' ] > 0
278+ ? round (($ batch ['processed ' ] / $ batch ['totalDomains ' ]) * 100 )
279+ : 0 ;
280+
281+ $ batch ['progressPercentage ' ] = $ progressPercentage ;
282+
283+
292284 $ domains = [
293- [
294- 'domain ' => 'example1.com ' ,
295- 'status ' => 'Completed ' ,
296- 'message ' => 'Transfer submitted successfully. ' ,
297- 'lastUpdated ' => '10 Apr 2026, 10:39 ' ,
298- ],
299- [
300- 'domain ' => 'example2.net ' ,
301- 'status ' => 'Transfer in progress ' ,
302- 'message ' => 'Transfer request is being processed. ' ,
303- 'lastUpdated ' => '10 Apr 2026, 10:40 ' ,
304- ],
305- [
306- 'domain ' => 'example3.org ' ,
307- 'status ' => 'Validation failed ' ,
308- 'message ' => 'Authorization code is missing or invalid. Update the auth code and retry. ' ,
309- 'lastUpdated ' => '10 Apr 2026, 10:36 ' ,
310- ],
311- [
312- 'domain ' => 'example4.io ' ,
313- 'status ' => 'Failed ' ,
314- 'message ' => 'Domain is locked at the current registrar. Unlock the domain and retry. ' ,
315- 'lastUpdated ' => '10 Apr 2026, 10:35 ' ,
316- ],
317- [
318- 'domain ' => 'example5.co ' ,
319- 'status ' => 'Queued ' ,
320- 'message ' => 'Waiting to be processed. ' ,
321- 'lastUpdated ' => '10 Apr 2026, 10:22 ' ,
322- ],
285+ ['domain ' => 'example1.com ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:39 ' ],
286+ ['domain ' => 'example2.net ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:40 ' ],
287+ ['domain ' => 'example3.org ' , 'status ' => 'Validation failed ' , 'message ' => 'Authorization code is missing or invalid. ' , 'lastUpdated ' => '10 Apr 2026, 10:36 ' ],
288+ ['domain ' => 'example4.io ' , 'status ' => 'Failed ' , 'message ' => 'Domain is locked at the current registrar. ' , 'lastUpdated ' => '10 Apr 2026, 10:35 ' ],
289+ ['domain ' => 'example5.co ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:22 ' ],
290+ ['domain ' => 'example6.xyz ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:21 ' ],
291+ ['domain ' => 'example7.info ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:20 ' ],
292+ ['domain ' => 'example8.dev ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:19 ' ],
293+ ['domain ' => 'example9.app ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:18 ' ],
294+ ['domain ' => 'example10.io ' , 'status ' => 'Failed ' , 'message ' => 'Domain is locked at the current registrar. ' , 'lastUpdated ' => '10 Apr 2026, 10:17 ' ],
295+
296+ ['domain ' => 'example11.com ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:16 ' ],
297+ ['domain ' => 'example12.net ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:15 ' ],
298+ ['domain ' => 'example13.org ' , 'status ' => 'Validation failed ' , 'message ' => 'Authorization code is missing or invalid. ' , 'lastUpdated ' => '10 Apr 2026, 10:14 ' ],
299+ ['domain ' => 'example14.io ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:13 ' ],
300+ ['domain ' => 'example15.co ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:12 ' ],
301+ ['domain ' => 'example16.xyz ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:11 ' ],
302+ ['domain ' => 'example17.info ' , 'status ' => 'Failed ' , 'message ' => 'Domain is locked at the current registrar. ' , 'lastUpdated ' => '10 Apr 2026, 10:10 ' ],
303+ ['domain ' => 'example18.dev ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:09 ' ],
304+ ['domain ' => 'example19.app ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:08 ' ],
305+ ['domain ' => 'example20.io ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:07 ' ],
306+
307+ ['domain ' => 'example21.com ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:06 ' ],
308+ ['domain ' => 'example22.net ' , 'status ' => 'Validation failed ' , 'message ' => 'Authorization code is missing or invalid. ' , 'lastUpdated ' => '10 Apr 2026, 10:05 ' ],
309+ ['domain ' => 'example23.org ' , 'status ' => 'Failed ' , 'message ' => 'Domain is locked at the current registrar. ' , 'lastUpdated ' => '10 Apr 2026, 10:04 ' ],
310+ ['domain ' => 'example24.io ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:03 ' ],
311+ ['domain ' => 'example25.co ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:02 ' ],
312+ ['domain ' => 'example26.xyz ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 10:01 ' ],
313+ ['domain ' => 'example27.info ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 10:00 ' ],
314+ ['domain ' => 'example28.dev ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 09:59 ' ],
315+ ['domain ' => 'example29.app ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 09:58 ' ],
316+ ['domain ' => 'example30.io ' , 'status ' => 'Failed ' , 'message ' => 'Domain is locked at the current registrar. ' , 'lastUpdated ' => '10 Apr 2026, 09:57 ' ],
317+
318+ ['domain ' => 'example31.com ' , 'status ' => 'Queued ' , 'message ' => 'Waiting to be processed. ' , 'lastUpdated ' => '10 Apr 2026, 09:56 ' ],
319+ ['domain ' => 'example32.net ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 09:55 ' ],
320+ ['domain ' => 'example33.org ' , 'status ' => 'Validation failed ' , 'message ' => 'Authorization code is missing or invalid. ' , 'lastUpdated ' => '10 Apr 2026, 09:54 ' ],
321+ ['domain ' => 'example34.io ' , 'status ' => 'Transfer in progress ' , 'message ' => 'Transfer request is being processed. ' , 'lastUpdated ' => '10 Apr 2026, 09:53 ' ],
322+ ['domain ' => 'example35.co ' , 'status ' => 'Completed ' , 'message ' => 'Transfer submitted successfully. ' , 'lastUpdated ' => '10 Apr 2026, 09:52 ' ],
323323 ];
324324
325+ $ currentPage = $ this ->getCurrentPage ('domainPage ' );
326+ $ perPage = 10 ;
327+ $ pagination = $ this ->paginateArray ($ domains , $ currentPage , $ perPage );
328+
325329 return $ this ->view ('bulk_domain_transfer/batch_details ' , [
326330 'LANG ' => $ params ['_lang ' ],
327331 'batch ' => $ batch ,
328- 'domains ' => $ domains ,
332+ 'domains ' => $ pagination ['items ' ],
333+ 'domainPagination ' => $ pagination ,
329334 ]);
330335 }
331336
337+ private function getCurrentPage (string $ key = 'page ' ): int
338+ {
339+ $ page = isset ($ _GET [$ key ]) ? (int ) $ _GET [$ key ] : 1 ;
340+ return max (1 , $ page );
341+ }
342+
343+ private function paginateArray (array $ items , int $ page , int $ perPage ): array
344+ {
345+ $ totalItems = count ($ items );
346+ $ totalPages = max (1 , (int ) ceil ($ totalItems / $ perPage ));
347+ $ page = min ($ page , $ totalPages );
348+ $ offset = ($ page - 1 ) * $ perPage ;
349+
350+ return [
351+ 'items ' => array_slice ($ items , $ offset , $ perPage ),
352+ 'currentPage ' => $ page ,
353+ 'perPage ' => $ perPage ,
354+ 'totalItems ' => $ totalItems ,
355+ 'totalPages ' => $ totalPages ,
356+ 'hasPreviousPage ' => $ page > 1 ,
357+ 'hasNextPage ' => $ page < $ totalPages ,
358+ 'previousPage ' => $ page > 1 ? $ page - 1 : 1 ,
359+ 'nextPage ' => $ page < $ totalPages ? $ page + 1 : $ totalPages ,
360+ ];
361+ }
362+
332363}
0 commit comments