diff --git a/cp/app/Controllers/SystemController.php b/cp/app/Controllers/SystemController.php index 74649c7..d9feda1 100644 --- a/cp/app/Controllers/SystemController.php +++ b/cp/app/Controllers/SystemController.php @@ -976,8 +976,6 @@ class SystemController extends Controller $premium_pricing = $db->selectRow('SELECT * FROM premium_domain_pricing WHERE tld_id = ?', [ $tld['id'] ]); $premium_categories = $db->select('SELECT * FROM premium_domain_categories'); - $promotions = $db->select('SELECT * FROM promotion_pricing WHERE tld_id = ?', - [ $tld['id'] ]); $launch_phases = $db->select('SELECT * FROM launch_phases WHERE tld_id = ?', [ $tld['id'] ]); @@ -1169,7 +1167,6 @@ class SystemController extends Controller 'tld_restore' => $tld_restore, 'premium_pricing' => $premium_pricing, 'premium_categories' => $premium_categories, - 'promotions' => $promotions, 'launch_phases' => $launch_phases, 'secureTld' => $secureTld, 'dnssecData' => $dnssecData, @@ -1487,6 +1484,60 @@ class SystemController extends Controller //} } + public function viewPromo(Request $request, Response $response, $args) + { + if ($_SESSION["auth_roles"] != 0) { + return $response->withHeader('Location', '/dashboard')->withStatus(302); + } + + $db = $this->container->get('db'); + // Get the current URI + $uri = $request->getUri()->getPath(); + + if ($args) { + $args = trim($args); + + if (!preg_match('/^\.(xn--[a-zA-Z0-9-]+|[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)?)$/', $args)) { + $this->container->get('flash')->addMessage('error', 'Invalid TLD format'); + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } + + $tld = $db->selectRow('SELECT id, tld, idn_table, secure FROM domain_tld WHERE tld = ?', + [ $args ]); + + if ($tld) { + $promotions = $db->select('SELECT * FROM promotion_pricing WHERE tld_id = ?', + [ $tld['id'] ]); + + if (strpos(strtolower($tld['tld']), '.xn--') === 0) { + $tld['tld'] = ltrim($tld['tld'], '.'); + $tld_u = '.'.idn_to_utf8($tld['tld'], 0, INTL_IDNA_VARIANT_UTS46); + $tld['tld'] = '.'.$tld['tld']; + } else { + $tld_u = $tld['tld']; + } + + $_SESSION['u_tld_id'] = [$tld['id']]; + $_SESSION['u_tld_extension'] = [$tld['tld']]; + + return view($response,'admin/system/viewPromo.twig', [ + 'tld' => $tld, + 'tld_u' => $tld_u, + 'promotions' => $promotions, + 'currentUri' => $uri + ]); + } else { + // TLD does not exist, redirect to the tlds view + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } + + } else { + // Redirect to the tlds view + return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + } + + } + public function managePromo(Request $request, Response $response) { if ($_SESSION["auth_roles"] != 0) { @@ -1568,11 +1619,11 @@ class SystemController extends Controller unset($_SESSION['u_tld_extension']); $this->container->get('flash')->addMessage('success', 'Promotion updates for the ' . $sData['extension'] . ' TLD have been successfully applied'); - return $response->withHeader('Location', '/registry/tlds')->withStatus(302); + return $response->withHeader('Location', '/registry/promotion/'.$sData['extension'])->withStatus(302); } catch (Exception $e) { $db->rollBack(); $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); - return $response->withHeader('Location', '/registry/tld/'.$sData['extension'])->withStatus(302); + return $response->withHeader('Location', '/registry/promotion/'.$sData['extension'])->withStatus(302); } } else { diff --git a/cp/resources/views/admin/system/manageTld.twig b/cp/resources/views/admin/system/manageTld.twig index e61175f..495e902 100644 --- a/cp/resources/views/admin/system/manageTld.twig +++ b/cp/resources/views/admin/system/manageTld.twig @@ -20,11 +20,11 @@
- + {{ __('Export IDN Table') }} - +
@@ -320,98 +320,6 @@
-
-
-
{{ __('Manage Promotions') }}
-
-
-
- - - - - - - - - - - - - {% for promo in promotions %} - - - - - - - - - {% else %} - - - - {% endfor %} - -
{{ __('Promotion Name') }}{{ __('Start Date') }}{{ __('End Date') }}{{ __('Discount') }} (%){{ __('Discount Amount') }}{{ __('Description') }}
{{ promo.promo_name }}{{ promo.start_date }}{{ promo.end_date }}{{ promo.discount_percentage ? promo.discount_percentage ~ '%' : 'N/A' }}{{ promo.discount_amount ? promo.discount_amount : 'N/A' }}{{ promo.description ? promo.description : 'N/A' }}
{{ __('No promotions found.') }}
-
-
{{ __('Create New Promotion') }}
-
- {{ csrf.field | raw }} -
- - -
-
-
-
- - - {{ __('Please Note:') }} {{ __('All times displayed are in') }} Coordinated Universal Time (UTC) -
-
-
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
{{ __('Manage Launch Phases') }}
diff --git a/cp/resources/views/admin/system/viewPromo.twig b/cp/resources/views/admin/system/viewPromo.twig new file mode 100644 index 0000000..bfb97fe --- /dev/null +++ b/cp/resources/views/admin/system/viewPromo.twig @@ -0,0 +1,125 @@ +{% extends "layouts/app.twig" %} + +{% block title %}{{ __('Manage Promotions') }} {{ __('for') }} {{ tld_u }}{% endblock %} + +{% block content %} +
+ + + +
+
+
+ {% include 'partials/flash.twig' %} + +
+
+
{{ __('Manage Promotions') }} {{ __('for') }} {{ tld_u }}
+
+
+
+ + + + + + + + + + + + + {% for promo in promotions %} + + + + + + + + + {% else %} + + + + {% endfor %} + +
{{ __('Promotion Name') }}{{ __('Start Date') }}{{ __('End Date') }}{{ __('Discount') }} (%){{ __('Discount Amount') }}{{ __('Description') }}
{{ promo.promo_name }}{{ promo.start_date }}{{ promo.end_date }}{{ promo.discount_percentage ? promo.discount_percentage ~ '%' : 'N/A' }}{{ promo.discount_amount ? promo.discount_amount : 'N/A' }}{{ promo.description ? promo.description : 'N/A' }}
{{ __('No promotions found.') }}
+
+
{{ __('Create New Promotion') }}
+
+ {{ csrf.field | raw }} +
+ + +
+
+
+
+ + + {{ __('Please Note:') }} {{ __('All times displayed are in') }} Coordinated Universal Time (UTC) +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+ {% include 'partials/footer.twig' %} +
+{% endblock %} \ No newline at end of file diff --git a/cp/resources/views/layouts/app.twig b/cp/resources/views/layouts/app.twig index d755770..9498c4e 100644 --- a/cp/resources/views/layouts/app.twig +++ b/cp/resources/views/layouts/app.twig @@ -200,7 +200,7 @@
-
  • +
  • `; + return ` `; } // Mapping of database string values to script names diff --git a/cp/routes/web.php b/cp/routes/web.php index e26d024..7c34d4f 100644 --- a/cp/routes/web.php +++ b/cp/routes/web.php @@ -145,6 +145,7 @@ $app->group('', function ($route) { $route->get('/registry/tokens/update/{token}', SystemController::class . ':updateToken')->setName('updateToken'); $route->post('/registry/tokens/update', SystemController::class . ':updateTokenProcess')->setName('updateTokenProcess'); $route->map(['GET', 'POST'], '/registry/tokens/delete/{token}', SystemController::class . ':deleteToken')->setName('deleteToken'); + $route->get('/registry/promotion/{tld}', SystemController::class . ':viewPromo')->setName('viewPromo'); $route->post('/registry/promotions', SystemController::class . ':managePromo')->setName('managePromo'); $route->post('/registry/phases', SystemController::class . ':managePhases')->setName('managePhases'); $route->get('/registry/idnexport/{script}', SystemController::class .':idnexport')->setName('idnexport');