Merge branch 'master' of bitbucket.org:venbainformationtechnology/golf_backend
This commit is contained in:
commit
04891de24d
@ -39,6 +39,8 @@ $routes->match(['get','post'],'/member_add','Member_controller::member_add');
|
||||
|
||||
$routes->match(['post'],'/buy_pack','Member_controller::buy_pack');
|
||||
$routes->match(['post'],'/use_points','Member_controller::use_points');
|
||||
$routes->match(['post'],'/add_to_cart','Member_controller::add_to_cart');
|
||||
$routes->match(['post'],'/cart_checkout','Member_controller::cart_checkout');
|
||||
|
||||
$routes->match(['get','post'],'/set_password/(:any)','Member_controller::set_password/$1');
|
||||
$routes->match(['get','post'],'/update_password','Member_controller::update_password');
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
use App\Models\Dashboard_model;
|
||||
use App\Models\Packages_and_pricing_model;
|
||||
use App\Models\Member_credits_model;
|
||||
use App\Models\Cart_model;
|
||||
|
||||
|
||||
class Dashboard extends BaseController
|
||||
{
|
||||
@ -12,6 +14,7 @@ class Dashboard extends BaseController
|
||||
$this->dModel = new Dashboard_model();
|
||||
$this->PackagesModel = new Packages_and_pricing_model();
|
||||
$this->creditsModel = new Member_credits_model();
|
||||
$this->cartModel = new Cart_model();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
@ -43,10 +46,14 @@ class Dashboard extends BaseController
|
||||
return redirect()->to(base_url());
|
||||
}
|
||||
|
||||
$id = session()->get('logged_user');
|
||||
$data['userdata']=$this->dModel->getLoggedInMemberData($id);
|
||||
|
||||
$data['userdata']=$this->dModel->getLoggedInMemberData(session()->get('logged_user'));
|
||||
$data['packageData']=$this->PackagesModel->findAll();
|
||||
$data['creditsData']=$this->creditsModel->findAll();
|
||||
$data['creditsData']=$this->creditsModel->where('member_id' , session()->get('logged_user') )->findAll();
|
||||
$data['cartData'] = $this->cartModel->select('cart.* ,packages_and_pricing.*')
|
||||
->join('packages_and_pricing', 'cart.pack_id = packages_and_pricing.id', 'left')
|
||||
->where('cart.member_id', session()->get('logged_user') )
|
||||
->findAll();
|
||||
//print_r($data);die();
|
||||
//echo view('layout/header',$data);
|
||||
echo view('member_dashboard',$data);
|
||||
|
||||
@ -6,6 +6,8 @@ use App\Models\Dashboard_model;
|
||||
use App\Models\Common_model;
|
||||
use App\Models\Member_credits_model;
|
||||
use App\Models\Packages_and_pricing_model;
|
||||
use App\Models\Cart_model;
|
||||
|
||||
class Member_controller extends BaseController
|
||||
{
|
||||
public $session;
|
||||
@ -18,6 +20,7 @@ class Member_controller extends BaseController
|
||||
$this->cModel = new Common_model();
|
||||
$this->creditsModel = new Member_credits_model();
|
||||
$this->PackagesModel = new Packages_and_pricing_model();
|
||||
$this->cartModel = new Cart_model();
|
||||
helper('form');
|
||||
}
|
||||
public function index()
|
||||
@ -297,51 +300,109 @@ class Member_controller extends BaseController
|
||||
|
||||
public function use_points()
|
||||
{
|
||||
//insert member details
|
||||
|
||||
$FormData = $this->request->getVar();
|
||||
|
||||
|
||||
//print_r($FormData);die();
|
||||
$needed_points = $FormData['points'];
|
||||
$creditsData = $this->creditsModel->where('member_id',$FormData['member_id'])->findAll();
|
||||
$newArray = array();
|
||||
foreach ($creditsData as $creditsDataindex => $creditsDataValue) {
|
||||
echo $needed_points;
|
||||
echo "--";
|
||||
|
||||
if($creditsDataValue['expiring_date'] > date("Y-m-d"))
|
||||
{
|
||||
if($creditsDataValue['running_balance'] != 0)
|
||||
$columnName = 'running_balance';
|
||||
$count = $this->creditsModel->selectSum($columnName)->where('member_id',$FormData['member_id'])->get()->getRow()->$columnName;
|
||||
if($count > $needed_points)
|
||||
{
|
||||
|
||||
|
||||
$creditsData = $this->creditsModel->where('member_id',$FormData['member_id'])->findAll();
|
||||
//$newArray = array();
|
||||
foreach ($creditsData as $creditsDataindex => $creditsDataValue) {
|
||||
if($creditsDataValue['expiring_date'] > date("Y-m-d"))
|
||||
{
|
||||
|
||||
|
||||
$needed_points = ($needed_points - $creditsDataValue['running_balance']);
|
||||
|
||||
$newArray[$creditsDataValue['running_balance']] = $needed_points;
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
print_r($newArray);die();
|
||||
$temp_needed_points = $needed_points;
|
||||
if($creditsDataValue['running_balance'] != 0 && $needed_points > 0)
|
||||
{
|
||||
|
||||
$needed_points = ($needed_points - $creditsDataValue['running_balance']);
|
||||
if($needed_points < 0 ){
|
||||
$running_balance = $creditsDataValue['running_balance'] - $temp_needed_points;
|
||||
$this->update_credit_package_data($creditsDataValue['id'] , array( 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['used_points'] + $creditsDataValue['running_balance'] - $running_balance));
|
||||
}else { $running_balance = 0;
|
||||
$this->update_credit_package_data($creditsDataValue['id'] , array( 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['used_points'] + $creditsDataValue['running_balance'] - $running_balance));
|
||||
}
|
||||
//$newArray[$creditsDataValue['running_balance']] = array('needed_points'=>$needed_points , 'running_balance'=>$running_balance , 'used_points'=> $creditsDataValue['running_balance'] - $running_balance);
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo true;
|
||||
|
||||
}else{
|
||||
echo "u need to purchase points";
|
||||
}
|
||||
|
||||
|
||||
$packageData = $this->PackagesModel->where('id',$newArray['pack_id'])->find();
|
||||
|
||||
// $insert_data = $this->creditsModel->save($credits_data);
|
||||
// if($insert_data)
|
||||
// {
|
||||
// echo true;
|
||||
// }else{
|
||||
// echo false;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function update_credit_package_data($id , $array)
|
||||
{
|
||||
$this->creditsModel->where('id', $id )->set($array)->update();
|
||||
}
|
||||
|
||||
|
||||
public function add_to_cart()
|
||||
{
|
||||
//insert member details
|
||||
$array = $this->request->getVar();
|
||||
//print_r($array);die();
|
||||
$newArray = array();
|
||||
foreach ($array as $key => $value) {
|
||||
$newKey = substr($key, 0, -2);
|
||||
$newArray[$newKey] = $value;
|
||||
}
|
||||
//print_r($newArray);die();
|
||||
$insert_data = $this->cartModel->save($newArray);
|
||||
if($insert_data)
|
||||
{
|
||||
echo true;
|
||||
}else{
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
|
||||
public function cart_checkout()
|
||||
{
|
||||
|
||||
$CartData = $this->cartModel->where('member_id',session()->get('logged_user'))->findAll();
|
||||
|
||||
|
||||
$today = date("Y-m-d");
|
||||
foreach ($CartData as $creditsDataindex => $creditsDataValue)
|
||||
{
|
||||
$packageData = $this->PackagesModel->where('id',$creditsDataValue['pack_id'])->find();
|
||||
|
||||
$credits_data['member_id'] = session()->get('logged_user');
|
||||
$credits_data['package_name'] = $packageData[0]['package_name'];
|
||||
$credits_data['package_type'] = $packageData[0]['package_type'];
|
||||
$credits_data['credit_points'] = $packageData[0]['credit'] ;
|
||||
$credits_data['running_balance'] = $packageData[0]['credit'] ;
|
||||
$credits_data['expired_points'] = 0;
|
||||
$credits_data['expiring_date'] = date('Y-m-d', strtotime('+1 month', strtotime($today)));
|
||||
$credits_data['cost'] = $packageData[0]['cost'];
|
||||
$insert_data = $this->creditsModel->save($credits_data);
|
||||
if($insert_data)
|
||||
{
|
||||
$this->creditsModel->where('id',$creditsDataValue['id'])->delete();
|
||||
}
|
||||
}
|
||||
echo true;
|
||||
}
|
||||
// -----------------------------------------------
|
||||
}
|
||||
|
||||
@ -50,23 +50,26 @@ class Sendmail_controller extends BaseController
|
||||
$user_data = $this->MemberModel->where('md5(verification_code)', $verification_code)->find();
|
||||
if($user_data)
|
||||
{
|
||||
// Update the users status
|
||||
// $update_data = $this->MemberModel->update_status($user_data['id']);
|
||||
$data['is_email_verified'] = 1;
|
||||
$update_data = $this->MemberModel->where('id', $user_data[0]['id'] )->set($data)->update();
|
||||
if($update_data)
|
||||
{
|
||||
// Show success message
|
||||
// $this->session->setTempdata('mail_success', "Email verification sucessfully.",3);
|
||||
// return redirect()->to(base_url());
|
||||
return redirect()->to(base_url()."set_password/".md5($user_data[0]['id']));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show error message
|
||||
echo 'Error in verifying email. Please try again.';
|
||||
}
|
||||
//print_r($user_data);die();
|
||||
if($user_data[0]['is_email_verified'] == 0)
|
||||
{
|
||||
// Update the users status
|
||||
// $update_data = $this->MemberModel->update_status($user_data['id']);
|
||||
$data['is_email_verified'] = 1;
|
||||
$update_data = $this->MemberModel->where('id', $user_data[0]['id'] )->set($data)->update();
|
||||
if($update_data)
|
||||
{
|
||||
return redirect()->to(base_url()."set_password/".md5($user_data[0]['id']));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show error message
|
||||
echo 'Error in verifying email. Please try again.';
|
||||
}
|
||||
}else{
|
||||
// Show error message
|
||||
echo 'Email already verified.';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
13
app/Models/Cart_model.php
Normal file
13
app/Models/Cart_model.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class Cart_model extends Model
|
||||
{
|
||||
protected $table = 'cart';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $allowedFields = ['member_id','pack_id'];
|
||||
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ class Member_credits_model extends Model
|
||||
protected $table = 'member_credits';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $allowedFields = ['member_id','package_name','package_type','credit_points','running_balance', 'expired_points','expiring_date','is_active'];
|
||||
protected $allowedFields = ['member_id','package_name','package_type','credit_points','running_balance','used_points', 'expired_points','expiring_date', 'cost' ,'is_active'];
|
||||
|
||||
|
||||
}
|
||||
@ -15,12 +15,8 @@ $(document).on('click','.submit',function(){
|
||||
data: formData,
|
||||
json: true,
|
||||
success: function(response) {
|
||||
alert(window.location);
|
||||
|
||||
if (response == true) {
|
||||
|
||||
$("#mytable").load(window.location + " #mytable");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@ -41,12 +37,52 @@ $(document).on('click','.use_points',function(){
|
||||
data: formData,
|
||||
json: true,
|
||||
success: function(response) {
|
||||
alert(response);die();
|
||||
|
||||
if (response == true) {
|
||||
|
||||
$("#mytable").load(window.location + " #mytable");
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click','.Addtocart',function(){
|
||||
var formId = $(this).closest('form').attr('id');
|
||||
var formData = $('#' + formId).serialize(); // Serialize form data
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "<?php echo base_url(); ?>add_to_cart",
|
||||
data: formData,
|
||||
json: true,
|
||||
success: function(response) {
|
||||
if (response == true) {
|
||||
$("#mycarttable").load(window.location + " #mycarttable");
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click','.checkout',function(){
|
||||
alert(1);
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "<?php echo base_url(); ?>cart_checkout",
|
||||
//data: formData,
|
||||
json: true,
|
||||
success: function(response) {
|
||||
alert(response);
|
||||
if (response == true) {
|
||||
$("#mytable").load(window.location + " #mytable");
|
||||
$("#mycarttable").load(window.location + " #mycarttable");
|
||||
}
|
||||
else {
|
||||
|
||||
@ -66,17 +102,32 @@ $(document).on('click','.use_points',function(){
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3 ">
|
||||
<div class="list-group ">
|
||||
<a href="<?=base_url()."member_home"; ?>" class="list-group-item list-group-item-action active">Dashboard</a>
|
||||
<a href="#" class="list-group-item list-group-item-action">My Credits</a>
|
||||
<a href="#" class="list-group-item list-group-item-action">Credit Packages</a>
|
||||
<a href="<?=base_url()."member_logout"; ?>" class="list-group-item list-group-item-action">Logout</a>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-3 ">
|
||||
<div class="list-group ">
|
||||
<a href="#" class="list-group-item list-group-item-action">My Credits</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 ">
|
||||
<div class="list-group ">
|
||||
<a href="#" class="list-group-item list-group-item-action">Credit Packages</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 ">
|
||||
<div class="list-group ">
|
||||
<a href="<?=base_url()."member_logout"; ?>" class="list-group-item list-group-item-action">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</br>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
@ -99,10 +150,12 @@ $(document).on('click','.use_points',function(){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</br><h1>Credit Packs</h1></br>
|
||||
<div class="row ">
|
||||
|
||||
|
||||
<?php foreach ($packageData as $index => $row) { ?>
|
||||
<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
|
||||
<div class="col-xs-12 col-sm-2 col-md-2 col-lg-2">
|
||||
<div class="db-wrapper">
|
||||
<div class="db-pricing-seven">
|
||||
<ul>
|
||||
@ -121,7 +174,8 @@ $(document).on('click','.use_points',function(){
|
||||
<input type="hidden" value="<?= $userdata->id; ?>" name="member_id_<?php echo $index; ?>" id="<?php echo $index; ?>">
|
||||
<input type="hidden" value=" <?= $row['id']; ?>" name="pack_id_<?php echo $index; ?>" id="<?php echo $index; ?>">
|
||||
<input type="hidden" value="1" name="pack_count_<?php echo $index; ?>" id="<?php echo $index; ?>">
|
||||
<button type="button" class="btn btn-default btn-lg submit"> BUY</button>
|
||||
<button type="button" class="btn btn-default btn-sm submit"> BUY</button>
|
||||
<button type="button" class="btn btn-default btn-sm Addtocart"> Add to cart</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -131,16 +185,17 @@ $(document).on('click','.use_points',function(){
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<table id="mytable">
|
||||
</br><h1>My credits table</h1></br>
|
||||
<table id="mytable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pack type</th>
|
||||
<th>Pack name</th>
|
||||
<th>Credits</th>
|
||||
<th>Cost</th>
|
||||
<th>Used credits</th>
|
||||
<th>Available credits</th>
|
||||
<th>Expired credits</th>
|
||||
<th>Cost</th>
|
||||
<th>Expiring date </th>
|
||||
|
||||
</tr>
|
||||
@ -151,9 +206,10 @@ $(document).on('click','.use_points',function(){
|
||||
<td><?= $row['package_type']; ?></td>
|
||||
<td><?= $row['package_name']; ?></td>
|
||||
<td><?= $row['credit_points']; ?></td>
|
||||
<td><?= $row['cost']; ?></td>
|
||||
<td><?= $row['running_balance'] - $row['credit_points']; ?></td>
|
||||
<td><?= $row['used_points'] ?></td>
|
||||
<td><?= $row['running_balance'] ?></td>
|
||||
<td><?= $row['expired_points']; ?></td>
|
||||
<td><?= $row['cost']; ?></td>
|
||||
<td><?= $row['expiring_date']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -162,13 +218,39 @@ $(document).on('click','.use_points',function(){
|
||||
|
||||
</br>
|
||||
|
||||
</br><h1>Book slot</h1></br>
|
||||
|
||||
<form id="myform">
|
||||
<input type="hidden" value="<?= $userdata->id; ?>" name="member_id" >
|
||||
<lable>Book slot With <lable> <input type="text " value="" name="points"> <lable>Credit points <lable>
|
||||
<button type="button" class="btn btn-default btn-lg use_points"> Use points</button>
|
||||
</form>
|
||||
|
||||
</br><h1>My cart</h1></br>
|
||||
<table id="mycarttable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pack type</th>
|
||||
<th>Pack name</th>
|
||||
<th>Credits</th>
|
||||
<th>Cost</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($cartData as $index => $row) { ?>
|
||||
<tr>
|
||||
<td><?= $row['package_type']; ?></td>
|
||||
<td><?= $row['package_name']; ?></td>
|
||||
<td><?= $row['credit']; ?></td>
|
||||
<td><?= $row['cost']; ?></td>
|
||||
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<button type="button" class="btn btn-default btn-lg checkout">Check out</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user