mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'master' into promo-code
This commit is contained in:
@@ -25,6 +25,7 @@ use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Wallets\Services\RecalculatesWalletBalance;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
@@ -45,20 +46,25 @@ class CallbackBillplzLogic
|
||||
/** @var CreateCashBackTransactionProcessor */
|
||||
private $createCashBackTransactionProcessor;
|
||||
|
||||
/** @var RecalculatesWalletBalance */
|
||||
private $recalculatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param RecalculatesWalletBalance $recalculatesWalletBalance
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdatesWalletBalance $updatesWalletBalance, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor, RecalculatesWalletBalance $recalculatesWalletBalance)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createCashBackTransactionProcessor = $createCashBackTransactionProcessor;
|
||||
$this->recalculatesWalletBalance = $recalculatesWalletBalance;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,13 +97,12 @@ class CallbackBillplzLogic
|
||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
}
|
||||
|
||||
if($transaction->status !== ApprovalStatus::COMPLETED){
|
||||
|
||||
if($transaction->owner instanceof Wallet && $transaction->status !== ApprovalStatus::APPROVED && $status === ApprovalStatus::APPROVED) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
if($transaction->status !== ApprovalStatus::COMPLETED && $transaction->status !== ApprovalStatus::APPROVED){
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
}
|
||||
|
||||
if($transaction->owner instanceof Wallet) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
// if ($transaction->type == TransactionType::PAYMENT) {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesBillplzBill
|
||||
@@ -26,7 +27,7 @@ class CreatesBillplzBill
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
|
||||
@@ -65,7 +65,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$bookings = Booking::where('service_id', '!=', 4)->where(function($query){
|
||||
return $query->whereMonth('created_at', '>', 07)->whereYear('created_at', 2022);
|
||||
return $query->whereMonth('created_at', '<', 03)->whereYear('created_at', 2023);
|
||||
})->whereDoesntHave('transactions', function($q){
|
||||
$q->where('type', TransactionType::PURCHASE_ORDER);
|
||||
$q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]);
|
||||
|
||||
@@ -29,6 +29,7 @@ use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Services\RecalculatesWalletBalance;
|
||||
|
||||
class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -70,6 +71,9 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
/** @var CreateCashBackTransactionProcessor */
|
||||
private $createCashBackTransactionProcessor;
|
||||
|
||||
/** @var RecalculatesWalletBalance */
|
||||
private $recalculatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CreateBookingPaymentLogic constructor.
|
||||
* @param FetchesBookingQuotation $fetchBookingQuotation
|
||||
@@ -81,8 +85,9 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreateCashBackTransactionProcessor $createCashBackTransactionProcessor
|
||||
* @param RecalculatesWalletBalance $recalculatesWalletBalance
|
||||
*/
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor)
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesCompanyPaymentAttemptLimit $fetchesCompanyPaymentAttemptLimit, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, CalculatesBookingOutstanding $calculatesBookingOutstanding, CreatesBillplzBill $createsBillplzBill, UpdatesWalletBalance $updatesWalletBalance, UpdatesTransactionStatus $updatesTransactionStatus, CreateCashBackTransactionProcessor $createCashBackTransactionProcessor, RecalculatesWalletBalance $recalculatesWalletBalance)
|
||||
{
|
||||
$this->fetchBookingQuotation = $fetchBookingQuotation;
|
||||
$this->fetchesCompanyPaymentAttemptLimit = $fetchesCompanyPaymentAttemptLimit;
|
||||
@@ -93,6 +98,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createCashBackTransactionProcessor = $createCashBackTransactionProcessor;
|
||||
$this->recalculatesWalletBalance = $recalculatesWalletBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +144,8 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic
|
||||
|
||||
$paymentReference = $billNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
$walletBalance = $this->recalculatesWalletBalance->execute($wallet);
|
||||
$this->updatesWalletBalance->execute($wallet, $walletBalance);
|
||||
}
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Imports\Services;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
|
||||
|
||||
class GenericImport implements ToCollection, WithHeadingRow
|
||||
{
|
||||
function headingRow(): int { return 1; }
|
||||
|
||||
public $rows;
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function collection(Collection $collection)
|
||||
{
|
||||
$this->rows = $collection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class RecalculatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
private $updatesWalletBalance;
|
||||
|
||||
public function __construct(UpdatesWalletBalance $updatesWalletBalance)
|
||||
{
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
}
|
||||
/**
|
||||
* @param Wallet $model
|
||||
* @param $amount
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $wallet)
|
||||
{
|
||||
|
||||
$i = 0;
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
foreach ($wallet->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) {
|
||||
$topups += (float) $transaction->amount;
|
||||
}
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
return $auditBalance;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,9 @@
|
||||
namespace App\Classes\Modules\Wallets\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -16,10 +15,24 @@ class UpdatesWalletBalance extends AbstractUpdateRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Wallet $model, $amount) {
|
||||
public function execute(Wallet $model, $amount)
|
||||
{
|
||||
$i = 0;
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
$model->amount = $model->amount + $amount;
|
||||
foreach ($model->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) $topups += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
|
||||
$model->amount = $auditBalance;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\SeasonalSegment;
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\Modules\Companies\Services\RemovesCompanyFromSegment;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Wallet;
|
||||
|
||||
class AuditAndUpdateWallletBalance extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'auditWalletBalance';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Audit and Update Wallet Balance';
|
||||
|
||||
/** @var RemovesCompanyFromSegment */
|
||||
private $removesCompanyFromSegment;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(RemovesCompanyFromSegment $removesCompanyFromSegment)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->removesCompanyFromSegment = $removesCompanyFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$wallets = Wallet::all();
|
||||
|
||||
$i = 0;
|
||||
foreach ($wallets as $wallet) {
|
||||
$topups = 0;
|
||||
$credit = 0;
|
||||
$payments = 0;
|
||||
$debit = 0;
|
||||
|
||||
foreach ($wallet->transactions as $transaction) {
|
||||
if (!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue;
|
||||
if ((int) $transaction->type === TransactionType::TOP_UP) {
|
||||
$topups += (float) $transaction->amount;
|
||||
}
|
||||
if ((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount;
|
||||
if ((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount;
|
||||
}
|
||||
$auditBalance = ($topups + $credit) - ($payments + $debit);
|
||||
$diffenrence = round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2);
|
||||
if ((($diffenrence == 0) || ($diffenrence == -0)) and $wallet->amount > -0.01) continue;
|
||||
|
||||
$i++;
|
||||
|
||||
$this->info($i . ". Marking: " . $wallet->owner->reference . "(" . $wallet->id . ")" . PHP_EOL . "Current Balance: " . $wallet->amount . PHP_EOL . "Audit Balance: " . ($auditBalance) . PHP_EOL . "Difference: " . $diffenrence . PHP_EOL);
|
||||
|
||||
Wallet::where('id', $wallet->id)->update(['amount' => $auditBalance]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\GenericImport;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SeasonalSegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Segment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSeasonalSegment;
|
||||
use App\Classes\Modules\Companies\Processors\AssignSegmentProcessor;
|
||||
use App\Models\SeasonalSegment;
|
||||
|
||||
class ImportHoneyTrapController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request)
|
||||
{
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
$file = json_decode($object->getFiles()[0])->file_info->original->file;
|
||||
|
||||
$import = new GenericImport();
|
||||
Excel::import($import, $file);
|
||||
$excelRows = $import->rows;
|
||||
$excelRows = $excelRows->toArray();
|
||||
|
||||
$returnArray = [];
|
||||
|
||||
$segment_id = Segment::where('name', 'honey trap platinum')->first()->id;
|
||||
|
||||
foreach ($excelRows as $row) {
|
||||
|
||||
if (is_null($row['email']) || empty($row['email'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($row['end_date']) || empty($row['end_date'])) {
|
||||
// use csv import must have an end_date
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = 'End Date is required';
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['end_date'] = $end_date = $this->changeExcelDate($row['end_date']);
|
||||
$start_date = $row['start_date'] ? $this->changeExcelDate($row['start_date']) : Carbon::now();
|
||||
$row['start_date'] = $start_date;
|
||||
|
||||
$end_date = Carbon::parse($end_date);
|
||||
// Check if the end_date is in the past
|
||||
if ($end_date->isPast()) {
|
||||
// end_date must be after today's date
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = "End Date must be after today's date";
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
$user = User::where('email', $row['email'])->first();
|
||||
if (!$user) {
|
||||
// if user not found
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = 'Email not found';
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
$company = $user->company->first();
|
||||
if (!$company) {
|
||||
// if company not found
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = 'Company not found';
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
$company_seasonal_honey_trap_count = SeasonalSegment::where('company_id', $company->id)->where('segment_id', $segment_id)->get();
|
||||
if (count($company_seasonal_honey_trap_count)) {
|
||||
// seasonal segment already exists
|
||||
$row['status'] = 'failed';
|
||||
$row['message'] = 'Company is already in the Honey Trap Segment';
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
$seasonalSegmentObject = new SeasonalSegmentObject($company->id, $segment_id, $start_date, $end_date ?? null);
|
||||
|
||||
(App()->make(createsSeasonalSegment::class))->execute($seasonalSegmentObject);
|
||||
(App()->make(assignSegmentProcessor::class))->execute($company, $segment_id);
|
||||
|
||||
// success added honey trap seasonal segment
|
||||
$row['status'] = 'success';
|
||||
$row['message'] = '';
|
||||
$returnArray[] = $row;
|
||||
continue;
|
||||
}
|
||||
|
||||
return response()->json($returnArray);
|
||||
}
|
||||
|
||||
public function changeExcelDate($date)
|
||||
{
|
||||
$unixTime = (($date - 25569) * 86400);
|
||||
$date = new DateTime("@$unixTime");
|
||||
return $date->format('d/m/Y');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row" @keyup.enter="submitForm">
|
||||
<div class="col ml-md-3 ml-0 mt-md-0 mt-3 bg-white padding-15">
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" v-show="!$store.getters.isLoading(section)" v-if="!returnData">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-16 all-caps bold m-b-15">Upload Honey Trap Csv</div>
|
||||
</div>
|
||||
</div>
|
||||
<error-message-component class="m-b-20" :error="error"></error-message-component>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 text-primary all-caps">Honey Trap Csv</div>
|
||||
</template>
|
||||
</file-input-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block p-t-10 p-b-10 p-r-35 p-l-35 btn-success b-rad-none" @click="submitForm">Upload & Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="returnData">
|
||||
<div class="font-heading fs-16 all-caps bold m-b-15">Uploaded Customer</div>
|
||||
<table class="w-100 table table-bordered">
|
||||
<tr class="thead-dark">
|
||||
<th class="text-capitalize" v-for="key in returnDataKeys"> {{ key }}</th>
|
||||
</tr>
|
||||
<tr v-for="row in returnData">
|
||||
<td v-for="col in row" :class="[{'text-danger': row['status'] == 'failed'}]">
|
||||
{{ col }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModalFromHandler from '../../../general/mixins/modalFormHandler'
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
files: [],
|
||||
parameters: {},
|
||||
returnData: null
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
files: {
|
||||
required
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
returnDataKeys() {
|
||||
return Object.keys(Object.assign({}, this.returnData[0]))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
this.parameters = {
|
||||
files: this.files
|
||||
};
|
||||
this.submit(this.route('api.honey_trap.upload'), 'post', this.section, true, false);
|
||||
},
|
||||
errorHandler(error){
|
||||
console.log(error);
|
||||
},
|
||||
successHandler(response) {
|
||||
console.log(response);
|
||||
this.returnData = response;
|
||||
console.log(this.returnDataKeys);
|
||||
},
|
||||
},
|
||||
mixins: [ModalFromHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
@extends('layouts.base_portal')
|
||||
@section('inner_content')
|
||||
<div class="row d-none" :class="[{'d-flex': $store.getters.isAdmin}]" v-if="$store.getters.isAdmin">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<upload-honey-trap-csv-component section="uploadHoneyTrapCsvComponent"></upload-honey-trap-csv-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -29,6 +29,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
Route::get('/storage/{fileName}/fetch', 'Documents\RenderDocumentController@fileStorageServe')->where(['fileName' => '.*'])->name('storage.document.file');
|
||||
Route::post('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import')->name('debtor.import');
|
||||
Route::post('/import/upload-honey-trap', 'Imports\ImportHoneyTrapController@import')->name('honey_trap.upload');
|
||||
|
||||
require __DIR__ . '/company.php';
|
||||
|
||||
|
||||
@@ -598,3 +598,6 @@ Route::get('/po/outsource/check', function(){
|
||||
|
||||
});
|
||||
|
||||
Route::get('/upload-honey-trap', function () {
|
||||
return view('pages.honey_trap');
|
||||
})->name('upload_honey_trap');
|
||||
Reference in New Issue
Block a user