gwm
This commit is contained in:
parent
69645b2b6d
commit
3854e3fca0
@ -144,67 +144,33 @@ class PaymentController extends BaseController
|
||||
{
|
||||
|
||||
// if(!session()->has('logged_user'))
|
||||
|
||||
// {
|
||||
|
||||
// return redirect()->to(base_url());
|
||||
|
||||
// }
|
||||
|
||||
$CartData = $this->cartModel->where('member_id',session()->get('logged_user'))->findAll();
|
||||
|
||||
$count = count($CartData);
|
||||
|
||||
if($count)
|
||||
|
||||
{
|
||||
|
||||
$credit_pack_expiry_duration = $this->RuleModel->select('value')->where('rule_key', 1 )->get()->getRow()->value;
|
||||
|
||||
$gst = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
|
||||
|
||||
$pst = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value;
|
||||
|
||||
$today = date("Y-m-d");
|
||||
|
||||
$days = "+".$credit_pack_expiry_duration." days";
|
||||
|
||||
$amount = 0;
|
||||
|
||||
$item_count = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($CartData[0]['order_id'] == null)
|
||||
|
||||
{
|
||||
|
||||
$orderId = 'EGF'.rand(10,100).rand(10,100).rand(10,100);
|
||||
|
||||
}else{
|
||||
|
||||
$orderId = $CartData[0]['order_id'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$packageArray = [];
|
||||
|
||||
for($i=0;$i<$count;$i++)
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$packageData = $this->PackagesModel->where('id',$CartData[$i]['pack_id'])->find();
|
||||
|
||||
$packageData[0]['count'] = $CartData[$i]['count'];
|
||||
@ -212,132 +178,78 @@ class PaymentController extends BaseController
|
||||
array_push($packageArray , $packageData[0]);
|
||||
|
||||
$cost = $packageData[0]['cost'] * $CartData[$i]['count'];
|
||||
|
||||
|
||||
|
||||
$credits_data['member_id'] = session()->get('logged_user');
|
||||
|
||||
$credits_data['pack_id'] = $packageData[0]['id'];
|
||||
$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($days, strtotime($today)));
|
||||
|
||||
$credits_data['cost'] = $packageData[0]['cost'];
|
||||
|
||||
$credits_data['is_active'] = 0;
|
||||
|
||||
$credits_data['order_id'] = $orderId;
|
||||
|
||||
$credits_data['cost_with_tax'] = ( $packageData[0]['cost'] + (($packageData[0]['cost'] * ($gst + $pst) ) / 100) );
|
||||
|
||||
|
||||
|
||||
$creditsModel_pack_count = $this->creditsModel->selectCount('id')->where('package_name',$packageData[0]['package_name'])->where('order_id',$orderId)->where('member_id', session()->get('logged_user'))->get()->getRow()->id;
|
||||
|
||||
$creditsModel_pack_count = $this->creditsModel->selectCount('id')->where('pack_id',$packageData[0]['id'])->where('order_id',$orderId)->where('member_id', session()->get('logged_user'))->get()->getRow()->id;
|
||||
if($creditsModel_pack_count)
|
||||
{
|
||||
$this->creditsModel->where('pack_id',$packageData[0]['id'])->where('order_id',$orderId)->where('member_id', session()->get('logged_user'))
|
||||
->set(array('cost'=>$packageData[0]['cost'],'cost_with_tax'=>( $packageData[0]['cost'] + (($packageData[0]['cost'] * ($gst + $pst) ) / 100) ),'credit_points'=>$packageData[0]['credit'],'running_balance'=>$packageData[0]['credit'],'package_name'=>$packageData[0]['package_name'],'package_type'=>$packageData[0]['package_type']))->update();
|
||||
}
|
||||
$single_pack_no_of_count = $CartData[$i]['count'] - $creditsModel_pack_count;
|
||||
|
||||
// if($CartData[0]['order_id'] == null)
|
||||
|
||||
// {
|
||||
|
||||
for($j=0;$j<$single_pack_no_of_count;$j++)
|
||||
|
||||
{
|
||||
|
||||
$insert_data = $this->creditsModel->save($credits_data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->cartModel->where('id', $CartData[$i]['id'] )
|
||||
|
||||
->where('member_id', session()->get('logged_user'))
|
||||
|
||||
->set(array( 'order_id' => $orderId ))->update();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$amount = $amount + $cost;
|
||||
|
||||
$item_count = $item_count + $CartData[$i]['count'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data['amount'] = $amount;
|
||||
|
||||
$data['item_count'] = $item_count;
|
||||
|
||||
$data['order_id'] = $orderId;
|
||||
|
||||
$data['gst'] = $gst;
|
||||
|
||||
$data['pst'] = $pst;
|
||||
|
||||
$data['packageArray'] = $packageArray;
|
||||
|
||||
$data['country'] = $this->CountryModel->findAll();
|
||||
|
||||
$data['userdata'] = $this->MemberModel->where('id', session()->get('logged_user'))->find();
|
||||
|
||||
|
||||
|
||||
$if_trans_exist = $this->TransactionModel->where('member_id', session()->get('logged_user'))
|
||||
|
||||
->where('order_id', $orderId )->find();
|
||||
|
||||
if($if_trans_exist){
|
||||
|
||||
//skip insertion
|
||||
|
||||
//skip insertion
|
||||
}else{
|
||||
|
||||
//Trancaction Table initial entry for this transaction
|
||||
|
||||
$TrancactionData['status'] = 'In-Progress';
|
||||
|
||||
$TrancactionData['member_id'] = session()->get('logged_user');
|
||||
|
||||
$TrancactionData['order_id'] = $orderId;
|
||||
|
||||
$insert = $this->TransactionModel->save($TrancactionData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$zip = $this->ZipcodeModel->findAll();
|
||||
|
||||
$output = '<option value="">'.$data['userdata'][0]['pincode'].'</option>';
|
||||
|
||||
foreach($zip as $row)
|
||||
|
||||
{
|
||||
|
||||
$output .= '<option value="'.$row['id'].'">'.$row['code'].'</option>';
|
||||
|
||||
}
|
||||
|
||||
$data['zipcode'] = $output;
|
||||
|
||||
|
||||
|
||||
|
||||
echo view('checkout',$data);
|
||||
|
||||
|
||||
|
||||
} else { return redirect()->to(base_url()."view/".md5(session()->get('logged_user'))); }
|
||||
|
||||
}
|
||||
|
||||
@ -319,7 +319,8 @@ class Sendmail_controller extends BaseController
|
||||
->selectSum('credit_points', 'credit_points')
|
||||
->selectSum('cost', 'costSum')
|
||||
->selectCount('package_name', 'pack_count')
|
||||
->groupBy('package_name')->findAll();
|
||||
->groupBy('package_name')->findAll();
|
||||
|
||||
$Subtotal = 0;
|
||||
foreach ($memberCredits as $key => $ele) {
|
||||
$Subtotal = $Subtotal + $ele['costSum'];
|
||||
@ -333,6 +334,7 @@ class Sendmail_controller extends BaseController
|
||||
$data['pst'] = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value;
|
||||
$data['card_brand'] = json_decode($data['TransactionData'][0]['transaction'] , true)['payment']['card_details']['card']['card_brand'];
|
||||
$data['last_4'] = json_decode($data['TransactionData'][0]['transaction'] , true)['payment']['card_details']['card']['last_4'];
|
||||
$data['profile'] = $this->MemberModel->select()->where('id', session()->get('logged_user'))->find();
|
||||
$data['html'] = view('success_mail',$data);
|
||||
|
||||
|
||||
@ -396,6 +398,7 @@ class Sendmail_controller extends BaseController
|
||||
$data['order_id'] = $data['TransactionData'][0]['order_id'];
|
||||
$timestamp = strtotime($data['TransactionData'][0]['created_at']);
|
||||
$data['formattedDate'] = date('l, F j, Y', $timestamp);
|
||||
$data['profile'] = $this->MemberModel->select()->where('id', session()->get('logged_user'))->find();
|
||||
$data['html'] = view('failed_mail',$data);
|
||||
|
||||
|
||||
|
||||
@ -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','used_points', 'expired_points','expiring_date', 'cost' ,'is_active', 'order_id','transaction_id' ,'cost_with_tax'];
|
||||
protected $allowedFields = ['member_id','pack_id','package_name','package_type','credit_points','running_balance','used_points', 'expired_points','expiring_date', 'cost' ,'is_active', 'order_id','transaction_id' ,'cost_with_tax'];
|
||||
|
||||
|
||||
}
|
||||
@ -31,8 +31,7 @@
|
||||
<!-- Details Table -->
|
||||
<tr>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0"
|
||||
style="width: 100%; border: 1px solid #ededed">
|
||||
<table cellpadding="0" cellspacing="0" style="width: 100%; border: 2px solid #ededed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td
|
||||
@ -58,6 +57,14 @@
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; color: #455056;">
|
||||
<?= $detail; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; border-right: 1px solid #ededed; width: 35%; font-weight:500; color:rgba(0,0,0,.64)">
|
||||
Transaction by :</td>
|
||||
<td
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; color: #455056;">
|
||||
<?= $profile[0]['name']." ".$profile[0]['last_name']." (".$profile[0]['mobile'].")"; ?>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
<!-- Details Table -->
|
||||
<tr>
|
||||
<td>
|
||||
<table cellpadding="0" cellspacing="0"
|
||||
style="width: 100%; border: 1px solid #ededed">
|
||||
<table cellpadding="0" cellspacing="0" style="width: 100%; border: 2px solid #ededed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td
|
||||
@ -60,6 +59,14 @@
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; color: #455056;">
|
||||
<?= $card_brand; ?> card ending with <?= $last_4; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; border-right: 1px solid #ededed; width: 35%; font-weight:500; color:rgba(0,0,0,.64)">
|
||||
Transaction by :</td>
|
||||
<td
|
||||
style="padding: 10px; border-bottom: 1px solid #ededed; color: #455056;">
|
||||
<?= $profile[0]['name']." ".$profile[0]['last_name']." (".$profile[0]['mobile'].")"; ?>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user