Configure coupons

This commit is contained in:
CHIEFSOFT\ameye
2024-07-04 10:48:14 -04:00
parent d30e00fc75
commit b35344305a
3 changed files with 114 additions and 1 deletions
+44
View File
@@ -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) {