Compare commits

...

10 Commits

Author SHA1 Message Date
suresh
f0862fe372 suresh 2023-09-14 13:12:19 +05:30
sriramv
5dda40c872 gwm 2023-09-14 12:58:02 +05:30
sriramv
28e3aa2e95 orderDAte:GWM 2023-09-14 11:27:23 +05:30
sriramv
22437099ae payment:gwm 2023-09-13 19:44:03 +05:30
sriramv
2a30fb895c payment:GWM 2023-09-13 19:16:31 +05:30
venkateswaran ubuntu
a098635f9b susee 2023-09-04 13:12:32 +05:30
venkateswaran ubuntu
f5de441090 susee 2023-09-04 12:53:24 +05:30
venkateswaran ubuntu
06036d41c4 susee 2023-09-04 12:35:09 +05:30
venkateswaran ubuntu
fc8e736a31 susee 2023-09-04 12:30:30 +05:30
venkateswaran ubuntu
d29dc0e51f susee 2023-09-04 11:19:37 +05:30
14 changed files with 608 additions and 1040 deletions

View File

@ -63,6 +63,7 @@ $routes->get('/payment_failed/(:any)', 'PaymentController::payment_failed/$1');
$routes->post('/payment/(:any)', 'PaymentController::index/$1');
$routes->get('payment_form', 'PaymentController::payment_form');
$routes->post('processPayment', 'PaymentController::processPayment');
$routes->get('createCreditPackCatalogObject', 'PaymentController::createCreditPackCatalogObject');
$routes->match(['get','post'],'/test','Test_controller::sendEmail');

View File

@ -1209,7 +1209,7 @@ class Admin_controller extends BaseController
->where('is_active',1)
->get()->getRow()->running_balance;
if($CreditBalanceSum > $needed_points)
if($CreditBalanceSum >= $needed_points)
{
$creditsData = $this->creditsModel->where('member_id',$member_id)->where('is_active',1)->findAll();
@ -1259,7 +1259,7 @@ public function view_credit_details($member_id)
$fname = $this->MemberModel->select('name')->where('md5(id)', $member_id )->get()->getRow()->name;
$lname = $this->MemberModel->select('last_name')->where('md5(id)', $member_id )->get()->getRow()->last_name;
$id = $this->MemberModel->select('id')->where('md5(id)', $member_id )->get()->getRow()->id;
$creditsData = $this->creditsModel->where('md5(member_id)',$member_id)->orderBy('id' , 'ASC')->findAll();
$creditsData = $this->creditsModel->where('md5(member_id)',$member_id)->where('is_active',1)->orderBy('id' , 'ASC')->findAll();
$data['id'] = $id;
$data['fname'] = $fname;
$data['lname'] = $lname;

View File

@ -7,43 +7,33 @@ namespace App\Controllers;
use Square\SquareClient;
use Square\Models\Money;
use Square\Models\CreatePaymentRequest;
use Square\Api\CatalogApi;
use Square\Model\CreateCatalogObjectRequest;
use Square\Model\CatalogObject;
use Square\Model\CatalogTax;
use Square\Model\Money;
use Square\Model\OrderLineItem;
use Square\Model\CreatePaymentRequest;
use Square\Exceptions\ApiException;
use Square\Api\Orders\CreateOrderRequest;
use Square\Api\OrdersApi;
use Square\Api\PaymentsApi;
use Ramsey\Uuid\Uuid;
use App\Models\Transaction_model;
use App\Models\Member_model;
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;
use App\Models\Credits_usage_tracking_model;
use App\Models\Rule_model;
use App\Models\Cart_token_model;
use App\Models\Member_address_model;
use App\Models\Zipcode_model;
use App\Models\Country_model;
class PaymentController extends BaseController
{
@ -51,35 +41,20 @@ class PaymentController extends BaseController
public function __construct()
{
$this->session = session();
$this->MemberModel = new Member_model();
$this->dModel = new Dashboard_model();
$this->cModel = new Common_model();
$this->creditsModel = new Member_credits_model();
$this->PackagesModel = new Packages_and_pricing_model();
$this->cartModel = new Cart_model();
$this->CreditsUsageTrackingModel = new Credits_usage_tracking_model();
$this->TransactionModel = new Transaction_model();
$this->RuleModel = new Rule_model();
$this->Cart_token_model = new Cart_token_model();
$this->MemberAddressModel = new Member_address_model();
$this->ZipcodeModel = new Zipcode_model();
$this->CountryModel = new Country_model();
}
@ -89,12 +64,9 @@ class PaymentController extends BaseController
public function index($token = null)
{
if($this->request->getmethod() == 'post')
{
// echo $token;die();
if(!session()->has('logged_user'))
{
@ -106,22 +78,14 @@ class PaymentController extends BaseController
$this->session->set('token',$token);
return redirect()->to(base_url());
}
else{
$this->payment_form();
}
} else {
// echo $this->session->get('logged_user');die();
$this->payment_form();
@ -140,9 +104,7 @@ class PaymentController extends BaseController
public function payment_form()
{
// if(!session()->has('logged_user'))
// {
// return redirect()->to(base_url());
@ -172,7 +134,6 @@ class PaymentController extends BaseController
for($i=0;$i<$count;$i++)
{
$packageData = $this->PackagesModel->where('id',$CartData[$i]['pack_id'])->find();
$packageData[0]['count'] = $CartData[$i]['count'];
array_push($packageArray , $packageData[0]);
@ -225,6 +186,7 @@ class PaymentController extends BaseController
$data['gst'] = $gst;
$data['pst'] = $pst;
$data['packageArray'] = $packageArray;
$data['EncodedArray'] = json_encode($packageArray);
$data['country'] = $this->CountryModel->findAll();
$data['userdata'] = $this->MemberModel->where('id', session()->get('logged_user'))->find();
@ -247,8 +209,10 @@ class PaymentController extends BaseController
$output .= '<option value="'.$row['id'].'">'.$row['code'].'</option>';
}
$data['zipcode'] = $output;
// echo '<pre>';
// print_r($data);
// echo '</pre>';
// die();
echo view('checkout',$data);
} else { return redirect()->to(base_url()."view/".md5(session()->get('logged_user'))); }
@ -256,141 +220,112 @@ class PaymentController extends BaseController
public function processPayment()
{
public function processPayment()
{
try {
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
error_log('Received a non-POST request');
echo 'Request not allowed';
http_response_code(405);
return;
}
include 'app/Libraries/LocationInfo.php';
$json = file_get_contents('php://input');
$data = json_decode($json);
$gst = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
$pst = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value;
$token = $data->token;
$idempotencyKey = $data->idempotencyKey;
$amount = $data->amount;
$order_id = $data->order_id;
$add = $data->address;
$EncodedArray = json_decode($data->EncodedArray,true);
parse_str( $add, $address);
//print_r($add);die();
$Final_amount = round( ( $amount + (($amount * ($gst + $pst) ) / 100) ) , 2 );
$Final_amount = $Final_amount * 100;
$locationId = getenv('SQUARE_LOCATION_ID');
$square_client = new SquareClient([
'accessToken' => getenv('SQUARE_ACCESS_TOKEN'),
'environment' => getenv('ENVIRONMENT'),
'userAgentDetail' => 'golf_evo', // Remove or replace this detail when building your own app
]);
$payments_api = $square_client->getPaymentsApi();
// To learn more about splitting payments with additional recipients,
// see the Payments API documentation on our [developer site]
// (https://developer.squareup.com/docs/payments-api/overview).
$money = new Money();
// Monetary amounts are specified in the smallest unit of the applicable currency.
// This amount is in cents. It's also hard-coded for $1.00, which isn't very useful.
$money->setAmount($Final_amount);
// Set currency to the currency for the location
$money->setCurrency($location_info->getCurrency());
//print_r($money); die();
try {
//create order for the payment
// $order_line_item = new \Square\Models\OrderLineItem('1');
// $order_line_item->setCatalogObjectId('EVYRQAQXPNUJWLLMAAHDXUHI');
// $order_line_item1 = new \Square\Models\OrderLineItem('2');
// $order_line_item1->setCatalogObjectId('CMU64OVJDUL7YJAFGQI33IZM');
// Every payment you process with the SDK must have a unique idempotency key.
// $line_items = [$order_line_item,$order_line_item1];
$line_items = [];
foreach ($EncodedArray as $key => $row)
{
$order_line_item = '';
$order = $order_line_item.$key;
// If you're unsure whether a particular payment succeeded, you can reattempt
$order = new \Square\Models\OrderLineItem($row['count']);
$order->setCatalogObjectId($row['variation_id']);
array_push($line_items , $order);
}
// it with the same idempotency key without worrying about double charging
$pricing_options = new \Square\Models\OrderPricingOptions();
$pricing_options->setAutoApplyTaxes(true);
// the buyer.
$order = new \Square\Models\Order($locationId);
$order->setLineItems($line_items);
$order->setPricingOptions($pricing_options);
$create_payment_request = new CreatePaymentRequest($token, $idempotencyKey, $money);
$body = new \Square\Models\CreateOrderRequest();
$body->setOrder($order);
$body->setIdempotencyKey($idempotencyKey);
$create_payment_request->setLocationId($location_info->getId());
$order_api_response = $square_client->getOrdersApi()->createOrder($body);
if ($order_api_response->isSuccess()) {
$Data['order'] = json_encode($order_api_response->getResult());
$this->TransactionModel->where('member_id', session()->get('logged_user'))
->where('order_id', $order_id )
->set($Data)->update();
$order_api_response_result = json_encode($order_api_response->getResult());
$order_api_response_result = json_decode( $order_api_response_result ,true);
$orderIdFromSquare = $order_api_response_result['order']['id'];
$response = $payments_api->createPayment($create_payment_request);
// Create a payment for the order
$amount_money = new \Square\Models\Money();
$amount_money->setAmount($Final_amount);
$amount_money->setCurrency($location_info->getCurrency());
$body = new \Square\Models\CreatePaymentRequest($token, $idempotencyKey,$amount_money);
$body->setOrderId($orderIdFromSquare);
$body->setReferenceId($order_id);
$body->setLocationId($locationId);
$response = $square_client->getPaymentsApi()->createPayment($body);
if ($response->isSuccess()) {
$data = json_encode($response->getResult());
$result = json_decode( $data ,true);
//Trancaction Table Data
@ -403,49 +338,30 @@ class PaymentController extends BaseController
$TrancactionData['city'] = $address['city'];
$TrancactionData['zip_code'] = $address['pincode'];
if($address['country']=='Canada'){ $TrancactionData['state'] = $address['canada_state']; }else{ $TrancactionData['state'] = $address['state'];}
$TrancactionData['transaction_id'] = $result['payment']['id'];
$TrancactionData['payment_order_id'] = $result['payment']['order_id'];
$TrancactionData['transaction'] = json_encode($response->getResult());
$TrancactionData['created_at'] = date("Y-m-d H:i:s");
$update = $this->TransactionModel->where('member_id', session()->get('logged_user'))
->where('order_id', $order_id )
->set($TrancactionData)->update();
if( $update)
{
$this->creditsModel->where('order_id', $order_id )->where('member_id', session()->get('logged_user'))
->set(array( 'is_active' => 1 , 'transaction_id' => $result['payment']['id'] ))->update();
$this->creditsModel->where('order_id', $order_id )->where('member_id', session()->get('logged_user'))->set(array( 'is_active' => 1 , 'transaction_id' => $result['payment']['id'] ))->update();
$this->cartModel->where('order_id', $order_id )->delete();
}
echo json_encode($response->getResult());
} else {
$data = json_encode($response->getErrors());
$result = json_decode( $data ,true);
//Trancaction Table Data
$TrancactionData['status'] = 'Failed';
// $TrancactionData['member_id'] = session()->get('logged_user');
$TrancactionData['first_name'] = $address['name'];
$TrancactionData['last_name'] = $address['last_name'];
@ -454,35 +370,31 @@ class PaymentController extends BaseController
$TrancactionData['city'] = $address['city'];
$TrancactionData['zip_code'] = $address['pincode'];
if($address['country']=='Canada'){ $TrancactionData['state'] = $address['canada_state']; }else{ $TrancactionData['state'] = $address['state'];}
//$TrancactionData['order_id'] = $order_id;
$TrancactionData['transaction'] = json_encode($response->getErrors());
$update = $this->TransactionModel->where('member_id', session()->get('logged_user'))
->where('order_id', $order_id )
->set($TrancactionData)->update();
if( $update)
{
$this->creditsModel->where('order_id', $order_id )->delete();
$this->cartModel->where('order_id', $order_id )->set(array('order_id'=>null))->update();
}
echo json_encode(array('errors' => $response->getErrors()));
}
} else {
$errors = $order_api_response->getErrors();
}
} catch (ApiException $e) {
echo json_encode(array('errors' => $e));
@ -491,42 +403,18 @@ class PaymentController extends BaseController
} catch (\Exception $e) {
// Handle exceptions
// Example: Logging the exception
log_message('error', 'Exception: ' . $e->getMessage());
// Example: Displaying a custom error message
echo 'An exception occurred: ' . $e->getMessage();
} catch (\Error $e) {
// Handle errors
// Example: Logging the error
log_message('error', 'Error: ' . $e->getMessage());
// Example: Displaying a custom error message
echo 'An error occurred: ' . $e->getMessage();
}
}
}
@ -534,111 +422,54 @@ class PaymentController extends BaseController
public function payment_success( $local_order_id = null)
{
// $data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find();
// $memberCredits = $this->creditsModel->where('order_id', $local_order_id )
// ->where('member_id', session()->get('logged_user'))
// ->select('package_name')
// ->select('cost')
// ->selectSum('credit_points', 'credit_points')
// ->selectSum('cost', 'costSum')
// ->selectCount('package_name', 'pack_count')
// ->groupBy('package_name')->findAll();
// $Subtotal = 0;
// foreach ($memberCredits as $key => $ele) {
// $Subtotal = $Subtotal + $ele['costSum'];
// }
// $data['memberCredits'] =$memberCredits;
// $data['order_id'] = $local_order_id;
// $timestamp = strtotime($data['TransactionData'][0]['created_at']);
// $data['formattedDate'] = date('l, F j, Y', $timestamp);
// $data['Subtotal'] = $Subtotal;
// $data['gst'] = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
// $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'];
// echo view('success_mail',$data);
// die();
if( $local_order_id != null)
{
$data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find();
if($data['TransactionData']){
$memberCredits = $this->creditsModel->where('order_id', $local_order_id )
->where('member_id', session()->get('logged_user'))
->select('package_name')
->select('cost')
->selectSum('credit_points', 'credit_points')
->selectSum('cost', 'costSum')
->selectCount('package_name', 'pack_count')
->groupBy('package_name')->findAll();
if($data['TransactionData'][0]['is_mail_triggered'] == 0){
$sendmail_controller = new Sendmail_controller();
$mail = $sendmail_controller->index(session()->get('logged_user_email') , $local_order_id , 5);
if($mail == true){
$this->TransactionModel->where('order_id', $local_order_id )->set(array('is_mail_triggered'=>1))->update();
}
$admin_email = $this->RuleModel->select('value')->where('rule_key', 10 )->get()->getRow()->value;
$sendmail_controller->index($admin_email , $local_order_id , 5);
}
$Subtotal = 0;
foreach ($memberCredits as $key => $ele) {
$Subtotal = $Subtotal + $ele['costSum'];
}
$data['memberCredits'] =$memberCredits;
$data['order_id'] = $local_order_id;
$timestamp = strtotime($data['TransactionData'][0]['created_at']);
$data['formattedDate'] = date('l, F j, Y', $timestamp);
$data['Subtotal'] = $Subtotal;
$data['gst'] = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
$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'];
echo view('payment',$data);
}else{
// echo 'invalid order_id';
return redirect()->to(base_url());
@ -653,55 +484,140 @@ class PaymentController extends BaseController
public function payment_failed( $local_order_id = null)
{
if( $local_order_id != null)
{
$data['TransactionData'] = $this->TransactionModel->where('order_id', $local_order_id )->where('member_id', session()->get('logged_user'))->find();
if($data['TransactionData']){
$sendmail_controller = new Sendmail_controller();
$mail = $sendmail_controller->index(session()->get('logged_user_email') , $local_order_id , 7);
$admin_email = $this->RuleModel->select('value')->where('rule_key', 10 )->get()->getRow()->value;
$sendmail_controller->index($admin_email , $local_order_id , 7 ,'admin');
$data['category'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['category'];
$data['code'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['code'];
$data['detail'] = json_decode($data['TransactionData'][0]['transaction'] , true)[0]['detail'];
$data['order_id'] = $data['TransactionData'][0]['order_id'];
$timestamp = strtotime($data['TransactionData'][0]['created_at']);
$data['formattedDate'] = date('l, F j, Y', $timestamp);
echo view('payment_failed',$data);
}else{
// echo 'invalid order_id';
return redirect()->to(base_url());
}
}
}
public function createCreditPackCatalogObject()
{
include 'app/Libraries/LocationInfo.php';
$gst = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
$pst = $this->RuleModel->select('value')->where('rule_key', 4 )->get()->getRow()->value;
$idempotencyKey = $this->generateIdempotencyKey();
$locationId = getenv('SQUARE_LOCATION_ID');
// Initialize the Square Client
$square_client = new SquareClient([
'accessToken' => getenv('SQUARE_ACCESS_TOKEN'),
'environment' => getenv('ENVIRONMENT'),
'userAgentDetail' => 'golf_evo', // Replace with your app's user agent detail
]);
$money1 = new \Square\Models\Money();
$money1->setAmount(550*100);
$money1->setCurrency($location_info->getCurrency());
$money2 = new \Square\Models\Money();
$money2->setAmount(1000*100);
$money2->setCurrency($location_info->getCurrency());
$item_variation_data = new \Square\Models\CatalogItemVariation();
$item_variation_data->setItemId('#PaymentItems');
$item_variation_data->setName('Evo Pack 1');
$item_variation_data->setPricingType('FIXED_PRICING');
$item_variation_data->setPriceMoney($money1);
$catalog_object1 = new \Square\Models\CatalogObject('ITEM_VARIATION', '#creditPack1');
$catalog_object1->setItemVariationData($item_variation_data);
$item_variation_data2 = new \Square\Models\CatalogItemVariation();
$item_variation_data2->setItemId('#PaymentItems');
$item_variation_data2->setName('Evo Pack 2');
$item_variation_data2->setPricingType('FIXED_PRICING');
$item_variation_data2->setPriceMoney($money2);
$catalog_object2 = new \Square\Models\CatalogObject('ITEM_VARIATION', '#creditPack2');
$catalog_object2->setItemVariationData($item_variation_data2);
$variations = [$catalog_object1 , $catalog_object2];
$tax_data = new \Square\Models\CatalogTax();
$tax_data->setName('GST/PST');
$tax_data->setCalculationPhase('TAX_SUBTOTAL_PHASE');
$tax_data->setInclusionType('ADDITIVE');
$tax_data->setPercentage($gst + $pst);
$catalog_object3 = new \Square\Models\CatalogObject('TAX', '#sales_tax');
$catalog_object3->setTaxData($tax_data);
//echo json_encode($catalog_object3);
$tax_ids = ['#sales_tax'];
$item_data = new \Square\Models\CatalogItem();
$item_data->setName('Evo pack Items');
$item_data->setTaxIds($tax_ids);
$item_data->setVariations($variations);
$item_data->setProductType('REGULAR');
$catalog_object = new \Square\Models\CatalogObject('ITEM', '#PaymentItems');
$catalog_object->setItemData($item_data);
$objects = [$catalog_object, $catalog_object3];
$catalog_object_batch = new \Square\Models\CatalogObjectBatch($objects);
$batches = [$catalog_object_batch];
$body = new \Square\Models\BatchUpsertCatalogObjectsRequest($idempotencyKey, $batches);
$api_response = $square_client->getCatalogApi()->batchUpsertCatalogObjects($body);
if ($api_response->isSuccess()) {
$result = $api_response->getResult();
echo json_encode($result);
} else {
$errors = $api_response->getErrors();
echo json_encode($errors);
}
}
function generateIdempotencyKey($length = 32) {
// Define characters that can be used in the key
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Get the total number of characters
$characterCount = strlen($characters);
// Initialize the idempotency key
$idempotencyKey = '';
// Generate a random key of the specified length
for ($i = 0; $i < $length; $i++) {
$idempotencyKey .= $characters[random_int(0, $characterCount - 1)];
}
return $idempotencyKey;
}
@ -709,33 +625,6 @@ class PaymentController extends BaseController
}
// $data['TransactionData'] = $this->TransactionModel->where('order_id', $code )->where('member_id', session()->get('logged_user'))->find();
// $memberCredits = $this->creditsModel->where('order_id', $code )
// ->where('member_id', session()->get('logged_user'))
// ->select('package_name')
// ->select('cost')
// ->selectSum('credit_points', 'credit_points')
// ->selectSum('cost', 'costSum')
// ->selectCount('package_name', 'pack_count')
// ->groupBy('package_name')->findAll();
// $Subtotal = 0;
// foreach ($memberCredits as $key => $ele) {
// $Subtotal = $Subtotal + $ele['costSum'];
// }
// $data['memberCredits'] =$memberCredits;
// $data['order_id'] = $code;
// $timestamp = strtotime($data['TransactionData'][0]['created_at']);
// $data['formattedDate'] = date('l, F j, Y', $timestamp);
// $data['Subtotal'] = $Subtotal;
// $data['gst'] = $this->RuleModel->select('value')->where('rule_key', 3 )->get()->getRow()->value;
// $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'];
// echo view('success_mail',$data);

View File

@ -7,7 +7,7 @@ class Packages_and_pricing_model extends Model
protected $table = 'packages_and_pricing';
protected $primaryKey = 'id';
protected $allowedFields = ['package_name','package_type', 'credit','cost','discription','offer_label', 'is_active'];
protected $allowedFields = ['package_name','package_type', 'credit','cost','discription','offer_label', 'is_active', 'catalog_object' , 'variation_id'];
}

View File

@ -16,7 +16,7 @@ class Transaction_model extends Model
protected $allowedFields = ['status','member_id','transaction_id','payment_order_id','order_id','transaction','is_mail_triggered', 'first_name','last_name','address', 'city' , 'state' , 'zip_code' , 'country'];
protected $allowedFields = ['status','member_id','transaction_id','payment_order_id','order_id','transaction','is_mail_triggered', 'first_name','last_name','address', 'city' , 'state' , 'zip_code' , 'country', 'order' , 'created_at'];

View File

@ -55,7 +55,12 @@
<div class="qty-no">
<button type="button" class="minus"><i class="fa fa-minus"></i></button>
<input type="number" onKeyDown="return false" id="0" class="input-text qty text" name="count[]" value="5" title="Qty" size="4" min="1" max="" step="1" placeholder="" inputmode="numeric" autocomplete="off" disabled/>
<input type="number" onKeyDown="return false" id="<?php echo $key; ?>" class="input-text qty text" name="count[]" value="<?php if ($pack_id[$key]['count'] == 0) {
echo 1;
} else {
echo $pack_id[$key]['count'];
}
?>" title="Qty" size="4" min="1" max="" step="1" placeholder="" inputmode="numeric" autocomplete="off" disabled/>
<button type="button" class="plus"><i class="fa fa-plus"></i></button>
</div>
</div>

View File

@ -455,7 +455,7 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https
<div class="col-xl-8">
<div class="address-form remember-section mb-5">
<label class="rember-label" for="rememberMe">By placing your order, you agree to our company privacy policy and condition of use.
<label class="rember-label" for="rememberMe">By placing your order, you agree to our company privacy policy and <a href="https://<?php echo $_SERVER['SERVER_NAME']; ?>/terms-conditions/" target="_blank">condition of use</a>.
<input type="checkbox" id="rememberMe">
<span class="checkmark"></span>
</label>
@ -480,6 +480,8 @@ $web_payment_sdk_url = $_ENV["ENVIRONMENT"] === Environment::PRODUCTION ? "https
<input type="hidden" value="<?= $order_id; ?>" name="order_id" id="order_id">
<input type="hidden" value="<?= htmlspecialchars($EncodedArray); ?>" name="EncodedArray" id="EncodedArray">
<input type="hidden" value="" name="address_id" id="address_id">
<div id="card-container"></div>

View File

@ -198,7 +198,7 @@ $(document).on('click','.manage-credits',function(){
</div>
<div class="mb-1 mt-2 col-md-4">
<label class="form-label">Cost($)<span style="color: red;margin-left: 4px;">*</label>
<input type="text" class="form-control" name="cost" id="cost" readonly required value="${res.OnePackValue[0]['value']}">
<input type="number" class="form-control" name="cost" id="cost" onkeypress = "return matchnum(event)" required value="${res.OnePackValue[0]['value']}">
</div>
<div class="mb-1 mt-2 col-md-4">
<label class="form-label">Transaction Method<span style="color: red;margin-left: 4px;">*</label>
@ -209,8 +209,8 @@ $(document).on('click','.manage-credits',function(){
</select>
</div>
<div class="mb-1 mt-2 col-md-12">
<label class="form-label">Remarks</label>
<input type="text" class="form-control" id="remarks" name="remarks" maxlength="30">
<label for="remarks" class="form-label">Remarks<span style="color: red;margin-left: 4px;">*</span></label>
<input type="text" class="form-control" id="remarks" name="remarks" required maxlength="30">
<span style="color: red;margin-left: 4px;"><i>Remarks must be 30 characters</i></span>
</div>
</div>
@ -238,6 +238,19 @@ $(document).on('click','.manage-credits',function(){
});
$('#method').on('click', function(){
if($(this).val() == 'Others')
{
$('#remarks').prop('required', true);
$('label[for="remarks"]').html('Remarks<span style="color: red;margin-left: 4px;">*</span>');
}
else
{
$('#remarks').prop('required', false);
$('label[for="remarks"]').text('Remarks');
}
});
$('#credit').on('click', function(){
if($('#packs').val() == 'CreditPoints')
{
@ -348,7 +361,9 @@ $(document).on('change','#packs',function(){
title: 'Member Name : <?php echo $fname." ".$lname; ?> (Total Credits : <?php echo $avaiable_credit; ?>)', // Set your custom PDF title here
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
doc.content[1].table.body.forEach(function(row) {
row.splice(0, 1); // Remove the first column (ID column)
});
}
},
{
@ -356,18 +371,24 @@ $(document).on('change','#packs',function(){
title: 'Member Name : <?php echo $fname." ".$lname; ?> (Total Credits : <?php echo $avaiable_credit; ?>)', // Set your custom print title here
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'copy',
text: 'Copy', // Set the title for the Copy button
titleAttr: 'Copy', // Set the tooltip for the Copy button
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
},
{
extend: 'csv',
text: 'CSV', // Set the title for the CSV button
title: 'Member Name : <?php echo $fname." ".$lname; ?> (Total Credits : <?php echo $avaiable_credit; ?>)', // Set your custom print title here
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
}
]
});
@ -382,10 +403,12 @@ function matchnum(event)
}
$(document).on('change','.add_or_sub',function(){
var selectedValue = $('input[name="add_or_sub"]:checked').val();
// alert(selectedValue)
packSel = $('#packs').val();
if (selectedValue === 'sub') {
$("#packs").val(""); // Clear the Pack select
$("#packs").val("CreditPoints");
$('#count').val("")
$('#method option[value="card"]').hide();
$('#method option[value="cash"]').hide();
$('#method').val("Others")
@ -396,15 +419,20 @@ $(document).on('change','.add_or_sub',function(){
$("#credit").val("1"); // Reset Credit to 1 (you can set it to any default value)
$("#cost").val($("#costHidden").val());
$('#credit').prop('readonly', false);
$('#cost').prop('readonly', false);
$('.changeClass').removeClass('col-md-8').addClass('col-md-12');
$('label[for="remarks"]').html('Remarks<span style="color: red;margin-left: 4px;">*</span>');
} else {
$("#packs").val("CreditPoints");
$('#method option[value="card"]').show();
$('#method option[value="cash"]').show();
$("#packs option[value='6']").show();
$("#packs option[value='7']").show();
$('#remarks').prop('required', false);
// $('#remarks').prop('required', false);
$("#cost").val($("#costHidden").val());
// $('label[for="remarks"]').text('Remarks');
$('#remarks').prop('required', true);
$('label[for="remarks"]').html('Remarks<span style="color: red;margin-left: 4px;">*</span>');
if(packSel == 'CreditPoints'){
$('#count_hide_show').hide();
}
@ -427,20 +455,6 @@ $(document).on('change','.add_or_sub',function(){
</script>
<!-- <script>
$('#packs').on('change', function () {
// Get the selected value of the dropdown
var selectedValue = $(this).val();
alert(selectedValue)
if(selectedValue == 'CreditPoints'){
$('#count_hide_show').hide();
}
else
{
$('#count_hide_show').show();
}
});
</script> -->

View File

@ -153,6 +153,9 @@ $(document).on('click','.transaction',function(){
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
doc.content[1].table.body.forEach(function(row) {
row.splice(0, 1); // Remove the first column (ID column)
});
}
},
{
@ -161,17 +164,24 @@ $(document).on('click','.transaction',function(){
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'copy',
text: 'Copy', // Set the title for the Copy button
titleAttr: 'Copy', // Set the tooltip for the Copy button
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
},
{
extend: 'csv',
text: 'CSV', // Set the title for the CSV button
title: 'Members', // Set your custom print title here
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
}
]
});

View File

@ -159,16 +159,12 @@ $(document).on('click','.order_details',function(){
title: 'Transactions', // Set your custom PDF title here
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
}
},
{
extend: 'print',
title: 'Transactions', // Set your custom print title here
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
}
},
{
extend: 'copy',

View File

@ -99,7 +99,9 @@
title: 'Users', // Set your custom PDF title here
text: 'PDF',
customize: function(doc) {
// You can further customize the PDF here if needed
doc.content[1].table.body.forEach(function(row) {
row.splice(0, 1); // Remove the first column (ID column)
});
}
},
{
@ -107,18 +109,24 @@
title: 'Users', // Set your custom print title here
text: 'Print',
customize: function(win) {
// You can further customize the print output here if needed
$(win.document.body).find('table').find('th:first-child, td:first-child').remove();
}
},
{
extend: 'copy',
text: 'Copy', // Set the title for the Copy button
titleAttr: 'Copy', // Set the tooltip for the Copy button
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
},
{
extend: 'csv',
text: 'CSV', // Set the title for the CSV button
title: 'Users', // Set your custom print title here
exportOptions: {
columns: ':not(:first-child)' // Exclude the first column (ID column)
}
}
],
"language": {

View File

@ -6,12 +6,11 @@
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"codeigniter4/framework": "^4.0",
"codeigniter4/framework": "4.3.7",
"daycry/cronjob": "^2.2",
"google/apiclient": "^2.15",
"guzzlehttp/guzzle": "^7.7",
"ramsey/uuid": "^4.2",
"square/square": "18.0.0.20220420"
"square/square": "20.1.0.20220720"
},
"require-dev": {
"fakerphp/faker": "^1.9",

1030
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -76,6 +76,8 @@ window.createPayment = async function(token) {
order_id : document.getElementById('order_id').value,
EncodedArray : document.getElementById('EncodedArray').value,
address : address
});
@ -113,8 +115,6 @@ window.createPayment = async function(token) {
if (data.errors && data.errors.length > 0) {
if (data.errors[0].detail) {