mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
Merge branch 'development' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
This commit is contained in:
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
|
||||
class DownloadBookingDocumentLogic
|
||||
{
|
||||
@@ -26,9 +27,9 @@ class DownloadBookingDocumentLogic
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
Auth::login(User::findOrFail(1));
|
||||
$zip_file = $request->input('type').'.zip';
|
||||
$document_type = str_replace(' ', '', $request->input('type'));
|
||||
$zip_file = $document_type.'.zip';
|
||||
$attachment = storage_path().'/app/documents/collections/' . $zip_file;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
@@ -36,19 +37,40 @@ class DownloadBookingDocumentLogic
|
||||
|
||||
$bookings = Booking::where('status', ApprovalStatus::COMPLETED)
|
||||
->whereDate('created_at', '>=', Carbon::parse($request->input('startDate')))
|
||||
->whereDate('created_at', '<=', Carbon::parse($request->input('endDate')))->whereHas('transactions', function ($query) use ($request){
|
||||
->whereDate('created_at', '<=', Carbon::parse($request->input('endDate')))
|
||||
->whereHas('transactions', function ($query) use ($request){
|
||||
return $query->where('type', TransactionType::PAYMENT)->whereHas('transactions', function ($query) use ($request){
|
||||
return $query->where('type', TransactionType::BILL)->where('issuer', $request->input('supplier'));
|
||||
});
|
||||
})->get();
|
||||
|
||||
|
||||
if (!count($bookings)) throw new MalformedRequestException('No available file to download');
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$file = $booking->documents()->where('document_type', $request->input('type'))->first()->files()->first();
|
||||
$zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
|
||||
if ($document_type == 'INVOICEPODO' || $document_type == 'INVOICEPODOSDO') {
|
||||
$invoice_file = $booking->documents()->where('document_type', DocumentType::INVOICE)->first()->files()->first();
|
||||
$purchase_file = $booking->documents()->where('document_type', DocumentType::PURCHASE_ORDER)->first()->files()->first();
|
||||
$deliver_file = $booking->documents()->where('document_type', DocumentType::DELIVER_ORDER)->first()->files()->first();
|
||||
if ($document_type == 'INVOICEPODOSDO') {
|
||||
$supplier_deliver_order_file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first();
|
||||
}
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($invoice_file->file->file_info->original->file), 'invoice-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($purchase_file->file->file_info->original->file), 'purchase-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($deliver_file->file->file_info->original->file), 'deliver-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
|
||||
$zip->addFile(Storage::disk('documents')->path($supplier_deliver_order_file->file->file_info->original->file), 'supplier-deliver-order-' . $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
else {
|
||||
$file = $booking->documents()->where('document_type', $document_type)->first()->files()->first();
|
||||
$zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf');
|
||||
}
|
||||
|
||||
}
|
||||
$zip->close();
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
|
||||
@@ -102,10 +102,6 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createNotificationProcessor->execute($object);
|
||||
|
||||
if($status === 'approve'){
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Company Account Status',
|
||||
'message' => 'You have successfully updated the Company Account Status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/**
|
||||
* UpdateCompanyStatusLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
UpdatesCompanyStatus $updatesCompanyStatus
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$company_query = $this->updatesCompanyStatus->execute($company, $request->input('status'));
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company_query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,9 @@ use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
|
||||
class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping
|
||||
class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
@@ -58,6 +59,20 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping
|
||||
6 => 'EXPIRED'
|
||||
];
|
||||
|
||||
switch ($transaction->owner_type) {
|
||||
case "App\Models\Booking":
|
||||
$marking = $transaction->booking->company->reference;
|
||||
break;
|
||||
case "App\Models\Transaction":
|
||||
$marking = $transaction->transactions()->first()->booking->company->reference;
|
||||
break;
|
||||
case "App\Models\Wallet":
|
||||
$marking = $transaction->owner->owner->reference;
|
||||
break;
|
||||
default:
|
||||
$marking = '';
|
||||
}
|
||||
|
||||
return [
|
||||
$transaction->bill_no,
|
||||
$transaction->owner_id,
|
||||
@@ -75,6 +90,7 @@ class ExportsTransactions implements FromQuery, WithHeadingRow, WithMapping
|
||||
$transactionStatus[$transaction->status],
|
||||
\PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->created_at),
|
||||
\PhpOffice\PhpSpreadsheet\Shared\Date::dateTimeToExcel($transaction->updated_at),
|
||||
$marking
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyStatusLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyStatusController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyStatusLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyStatusLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,7 +84,14 @@ export default {
|
||||
type: 'INVOICE',
|
||||
supplier: null
|
||||
},
|
||||
documents: ['INVOICE', 'PURCHASE_ORDER', 'DELIVER_ORDER', 'SUPPLIER_DELIVER_ORDER'],
|
||||
documents: [
|
||||
'INVOICE',
|
||||
'PURCHASE_ORDER',
|
||||
'DELIVER_ORDER',
|
||||
'SUPPLIER_DELIVER_ORDER',
|
||||
'INVOICE + PO + DO',
|
||||
'INVOICE + PO + DO + SDO'
|
||||
],
|
||||
selectedDocumentStatus: false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -61,6 +61,18 @@
|
||||
<div class="col-auto">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-xs btn-outline-primary b-rad-none m-r-5 requestModal" data-type="activateSupplierModal" v-if="item.status === 5">
|
||||
Activate
|
||||
</button>
|
||||
<modal-component type="activateSupplierModal">
|
||||
<activate-supplier-form-component :data="item" section="suppliersSection"></activate-supplier-form-component>
|
||||
</modal-component>
|
||||
<button class="btn btn-xs btn-outline-danger b-rad-none m-r-5 requestModal" data-type="suspendSupplierModal" v-if="item.status !== 5">
|
||||
Suspend
|
||||
</button>
|
||||
<modal-component type="suspendSupplierModal">
|
||||
<suspend-supplier-form-component :data="item" section="suppliersSection"></suspend-supplier-form-component>
|
||||
</modal-component>
|
||||
<button class="btn btn-xs btn-outline-warning b-rad-none m-r-5 requestModal" data-type="editServiceCharge">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to activate this Supplier?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submitForm()">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
section: {
|
||||
default: 'suppliersSection'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.parameters.status = 1;
|
||||
this.submit(this.route('api.company.status.update', this.data.id), 'put', this.section, true, false);
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to suspend this Supplier?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-success btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-danger btn-block b-rad-none" @click="submitForm()">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
section: {
|
||||
default: 'suppliersSection'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.parameters.status = 5;
|
||||
this.submit(this.route('api.company.status.update', this.data.id), 'put', this.section, true, false);
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -7,6 +7,7 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
Route::get('/list', 'ListCompaniesController@list')->name('list');
|
||||
Route::post('/create', 'CreateCompanyController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
|
||||
Route::put('update/{id}/status', 'UpdateCompanyStatusController@update')->name('status.update');
|
||||
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
|
||||
|
||||
Route::put('/update/debtor/{id}', 'UpdateCompanyDebtorController@update')->name('delete');
|
||||
|
||||
Reference in New Issue
Block a user