mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
Merge branch 'export-customer-order-list' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into development
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\Container;
|
||||
use App\Models\Package;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsCompanyModuleSummary implements FromCollection, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
protected $companyModuleId, $containerIds;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Date',
|
||||
'Full Marking',
|
||||
'Container',
|
||||
'Description',
|
||||
'Ctns',
|
||||
'L (cm)',
|
||||
'H (cm)',
|
||||
'W (cm)',
|
||||
'CBM'
|
||||
];
|
||||
}
|
||||
|
||||
public function setParameters($companyModuleId, $containerIds)
|
||||
{
|
||||
$this->companyModuleId = $companyModuleId;
|
||||
$this->containerIds = $containerIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$packagesArray = collect();
|
||||
$containers = Container::whereIn('reference', explode(',', $this->containerIds))->get();
|
||||
foreach ($containers as $container){
|
||||
$company_module_id = $this->companyModuleId;
|
||||
$packingLists = $container->packingLists()->get()->filter(function ($packingList) use ($company_module_id) {
|
||||
return $packingList->owner->company_module_id == $company_module_id;
|
||||
});
|
||||
foreach ($packingLists as $packingList){
|
||||
if($packingList->packingLists->first()){
|
||||
$packingList = $packingList->packingLists->first();
|
||||
}
|
||||
$packages = $packingList->packages;
|
||||
foreach ($packages as $package){
|
||||
$packagesArray->push($package);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Package $package
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($package): array
|
||||
{
|
||||
$connection = $package->packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
return [
|
||||
Carbon::parse($package->created_at)->format('d-m-Y'),
|
||||
$marking,
|
||||
$package->packingList->containers()->first()->reference,
|
||||
$package->description,
|
||||
$package->quantity,
|
||||
$package->length,
|
||||
$package->height,
|
||||
$package->width,
|
||||
((($package->length / 100) * ($package->height / 100) * ($package->width / 100)) * $package->quantity)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Exports;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsCompanyModuleSummary;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportCompanyModuleSummaryController
|
||||
{
|
||||
/**
|
||||
* ExportCompanyModuleSummaryController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
$exportsCompanyModuleSummary = new ExportsCompanyModuleSummary($request);
|
||||
$exportsCompanyModuleSummary->setParameters($request->route('company_module_id'), $request->input('containerNumber'));
|
||||
$response = $exportsCompanyModuleSummary->download('customer-report-by-containers.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -82,16 +82,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row parentContainer" v-if="!item.identification">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col no-padding">
|
||||
<button class="btn btn-sm btn-success btn-block b-rad-none requestModal" data-type="identificationVerificationModal">Upload Identification</button>
|
||||
<div class="row parentContainer" v-if="!item.identification">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col no-padding">
|
||||
<button class="btn btn-sm btn-success btn-block b-rad-none requestModal" data-type="identificationVerificationModal">Upload Identification</button>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component type="identificationVerificationModal">
|
||||
<identification-verification-form-component section="orderListSection" :data="item"></identification-verification-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row parentContainer">
|
||||
<div class="col no-padding">
|
||||
<button type="button" class=" btn btn-sm btn-block p-t-10 p-b-10 p-r-35 p-l-35 btn-primary b-rad-none requestModal" data-type="exportCompanyModuleSummary">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-r-0 p-l-0">
|
||||
<i class="fa fa-file-excel-o fs-16"></i>
|
||||
</div>
|
||||
<div class="col p-r-5">Export To Excel</div>
|
||||
</div>
|
||||
</button>
|
||||
<modal-component type="exportCompanyModuleSummary">
|
||||
<export-company-module-summary-form-component section="exportCompanyModuleSummarySection" :data="item.company_module" @exit="closeModal"></export-company-module-summary-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component type="identificationVerificationModal">
|
||||
<identification-verification-form-component section="orderListSection" :data="item"></identification-verification-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
-31
@@ -6,37 +6,6 @@
|
||||
<customer-profile-component :data="company"></customer-profile-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info padding-15" role="alert">
|
||||
<div class="row">
|
||||
<div class="col"></div>
|
||||
<div class="col-auto">
|
||||
<i class="fa fa-times text-info-darker pointer" data-dismiss="alert"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>[清明节仓库放假通知 Qing Ming Warehouse Holiday Notice]<br>
|
||||
|
||||
尊敬的客户们:<br>
|
||||
|
||||
仓库将为 2022年清明节假期做出如下安排 :<br>
|
||||
|
||||
广州仓库 : 2022 年 4月 4日 - 2022 年 4月 5日 (4月6日复工)<br>
|
||||
义乌仓库 : 2022 年 4月 3日 - 2022 年 4月 4日 (4月5日复工)<br>
|
||||
|
||||
*放假期间没有仓库人员值班, 请大家安排好送货时间, 感谢<br><br>
|
||||
|
||||
Dear Customers :<br>
|
||||
|
||||
Our warehouse holiday for Qing Ming is as below :<br>
|
||||
|
||||
Guangzhou : 4 April 2022 - 5 April 2022 (Resume date : 6 April)<br>
|
||||
Yiwu : 3 April 2022 - 4 April 2022 (Resume date : 5 April)<br>
|
||||
|
||||
*Warehouse personnel are on leave during the holiday period, please arrange delivery date in advance, thank you</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-show="!$store.getters.isShowing('createOrderForm')">
|
||||
<div class="col">
|
||||
<on-boarding-section-component v-if="company.last_order && company.status === 0"></on-boarding-section-component>
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<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 text-center">Export Customer Summary</h3>
|
||||
<div class="fs-11 text-center">Please key in the Container Number spereated by a comma.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.containerIds">
|
||||
<label>Container Number</label>
|
||||
<input class="form-control" v-model="containerIds">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-r-5">
|
||||
<div class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-primary 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';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
containerIds: '',
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
containerIds: {
|
||||
required
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.validate();
|
||||
if(this.validate()){
|
||||
this.$v.$reset();
|
||||
this.closeModal();
|
||||
window.open(this.route('customer.summary.export', this.item.id)+'?containerNumber='+this.containerIds, '_blank');
|
||||
}
|
||||
return;
|
||||
}
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -257,6 +257,8 @@ Route::get('/settings', function () {
|
||||
return view('pages.settings');
|
||||
})->name('settings');
|
||||
|
||||
Route::get('/customer/{company_module_id}/summary', 'Exports\ExportCompanyModuleSummaryController@export')->name('customer.summary.export');
|
||||
|
||||
Route::get('/customer/summary/monthly', function () {
|
||||
// $containers = Container::whereMonth('loading_date', 1)->where('owner_id', 3)->get();
|
||||
$containers = Container::whereIn('reference', ['EPS-3850', 'EPS-3863', 'WP-1331', 'EPS-3856'])->get();
|
||||
|
||||
Reference in New Issue
Block a user