Configure coupons
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<div class="panel-heading">
|
||||
<h6><b>Generate Coupons</b> </h6>
|
||||
</div>
|
||||
<form name="resonform">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td >
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>
|
||||
<select class="form-select" name="amount" id="amount">
|
||||
<option value="1000">1000 Naira</option>
|
||||
<option value="5000">5000 Naira</option>
|
||||
<option value="10000">10,000 Naira</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-select" name="quantity" id="quantity">
|
||||
<option value="10">10 Coupons</option>
|
||||
<option value="20">20 Coupons</option>
|
||||
<option value="40">40 Coupons</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width: 80px;">
|
||||
<button id='acc<?=$page_id?>' class="btn btn-info" onclick="generateCoupons();">Generate</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td >
|
||||
<div id="reason_msg"></div>
|
||||
------
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
||||
function generateCoupons() {
|
||||
|
||||
var amount = document.getElementById('amount').value;
|
||||
var quantity = document.getElementById('quantity').value;
|
||||
|
||||
//alert(amount);
|
||||
|
||||
$('#reason_msg').html('Processing...');
|
||||
//$('#acc' + page_id).prop('disabled', true);
|
||||
$.ajax({
|
||||
url: "/confg/addCoupons?amount=" + amount + "&quantity=" + quantity
|
||||
}).done(function (data) {
|
||||
$('#reason_msg').html(data);
|
||||
// $('#acc' + page_id).prop('disabled', false);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
@@ -169,7 +169,7 @@
|
||||
<!-- Today's revenue -->
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<a href='#'><h5 class="no-margin">Item X</h5></a>
|
||||
<a href='#' onclick="openConfig('GENCOUPONS');"><h5 class="no-margin">Generate Coupons</h5></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user