From b35344305ae2c5aee48f06d8f8753af7766681a3 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Thu, 4 Jul 2024 10:48:14 -0400 Subject: [PATCH] Configure coupons --- application/controllers/Confg.php | 44 ++++++++++++ .../views/bko/configure/extra/gen_coupons.php | 69 +++++++++++++++++++ .../bko/configure/view_bko_configure.php | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 application/views/bko/configure/extra/gen_coupons.php diff --git a/application/controllers/Confg.php b/application/controllers/Confg.php index 8c0f343..69996bc 100644 --- a/application/controllers/Confg.php +++ b/application/controllers/Confg.php @@ -168,6 +168,9 @@ class Confg extends Bko_Controller { $data['cron_jobs_table'] = $this->table->generate($query); $this->load->view('bko/configure/extra/cron_jobs', $data); break; + case "GENCOUPONS": + $this->load->view('bko/configure/extra/gen_coupons', $data); + break; default: echo "Your favorite color is neither red, blue, nor green!"; @@ -175,6 +178,47 @@ class Confg extends Bko_Controller { } } + //define('WRENCHBOARD_COUPON_CREATE', 85010); + public function addCoupons(){ + + echo 'Ameye....'; + + if ($_GET) { + $amount = $this->input->get('amount'); + $quantity = trim($this->input->get('quantity')); + + if($amount !='' & $quantity !='' & $quantity > 0 ){ + $this->load->model('backend_model'); + $data['action'] = WRENCHBOARD_COUPON_CREATE; + $out = array(); + $result =''; + for ($i = 1; $i <= $quantity; $i++) { + $data['amount'] = $amount; + $data['code'] = strtoupper( $this->getCouponsCode(10) ); + $res = $this->backend_model->wrenchboard_api($data, $out); + $result .= $data['code']." - ".$res." \n"; + } + + echo $result; + } + else{ + echo 'Not Generated'; + } + } + } + + private function getCouponsCode($n) { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $randomString = ''; + + for ($i = 0; $i < $n; $i++) { + $index = rand(0, strlen($characters) - 1); + $randomString .= $characters[$index]; + } + + return $randomString; + } + public function allowCountry(){ if ($_GET) { diff --git a/application/views/bko/configure/extra/gen_coupons.php b/application/views/bko/configure/extra/gen_coupons.php new file mode 100644 index 0000000..4a231b6 --- /dev/null +++ b/application/views/bko/configure/extra/gen_coupons.php @@ -0,0 +1,69 @@ +
+
Generate Coupons
+
+
+
+ + + + + + + + + + + +
+ + + + + + +
+ + + + + +
+
+
+ ------ +
+
+ +
+ + \ No newline at end of file diff --git a/application/views/bko/configure/view_bko_configure.php b/application/views/bko/configure/view_bko_configure.php index eccb70d..4cc5d8f 100644 --- a/application/views/bko/configure/view_bko_configure.php +++ b/application/views/bko/configure/view_bko_configure.php @@ -169,7 +169,7 @@