mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
update debtors import
This commit is contained in:
@@ -28,7 +28,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data);
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ?
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConvertsBase64ToFile
|
||||
foreach ($files as $file) {
|
||||
|
||||
$object = new FileObject($file);
|
||||
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
|
||||
in_array($object->getExtension(), ['pdf', 'excel']) ? $this->generatePDF($object) : $this->generateImage($object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,14 @@ class FileType
|
||||
|
||||
public const PDF = 'application/pdf';
|
||||
|
||||
public const EXCEL = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
|
||||
public const EXTENSION = [
|
||||
'image/gif' => 'gif',
|
||||
'image/png' => 'png',
|
||||
'image/jpeg' => 'jpeg',
|
||||
'application/pdf' => 'pdf',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers\Imports;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Imports\Services\ImportsDebtor;
|
||||
use App\Classes\General\ExcelHandel;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -12,14 +14,16 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ImportUpdateDebtorController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Maatwebsite\Excel\Excel
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function import(Request $request) {
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$excel_file = $request->input('excel_file');
|
||||
|
||||
$excel_file = ExcelHandel::insertExcel('debtor', $excel_file);
|
||||
|
||||
return $import = Excel::import(new ImportsDebtor(), $excel_file[0]['file_info']['original']['file']);
|
||||
$object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
|
||||
return $import = Excel::import(new ImportsDebtor(), $object->getFiles()[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<div class="row" @keyup.enter="submitForm">
|
||||
<div class="col no-padding">
|
||||
<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)">
|
||||
<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 Debtors</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">Debtor Excel</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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModalFromHandler from '../../../general/mixins/modalFormHandler'
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
files: [],
|
||||
parameters: {}
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
files: {
|
||||
required
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm(){
|
||||
|
||||
this.parameters = {
|
||||
files: this.files
|
||||
};
|
||||
|
||||
this.submit(this.route('api.debtor.import'), 'post', this.section, true, false)
|
||||
}
|
||||
},
|
||||
mixins: [ModalFromHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -81,7 +81,7 @@
|
||||
url: '#',
|
||||
autoQueue: false,
|
||||
processQueue: false,
|
||||
acceptedFiles: 'image/*, application/pdf',
|
||||
acceptedFiles: 'image/*, application/*',
|
||||
uploadMultiple: true,
|
||||
clickable: '.select-btn',
|
||||
previewTemplate: '<div class="row m-l-0 m-r-0 align-items-center m-t-5 m-b-5 bg-master-lightest text-left p-t-10 p-b-10 "> <div class="col-auto p-r-0"> <img data-dz-thumbnail style="width: 35px; height: 35px;" /> </div> <div class="col"> <div class="row m-b-5"> <div class="col"> <div class="dz-filename fs-8 bold"><span data-dz-name></span></div> </div> </div> <div class="row"> <div class="col"> <div class="dz-size muted light fs-10" data-dz-size></div> </div> </div> </div> <div class="col-auto"><i class="fs-16 fa fa-times-circle pointer hint-text" data-dz-remove></i></div> </div>'
|
||||
|
||||
@@ -303,6 +303,11 @@
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<upload-debtor-excel-component section="uploadDebtorExcelSection"></upload-debtor-excel-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,6 +28,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
Route::group(['middleware' => 'valid.token'], 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');
|
||||
|
||||
require __DIR__ . '/company.php';
|
||||
|
||||
|
||||
@@ -147,8 +147,6 @@ Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\Expo
|
||||
Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions');
|
||||
Route::get('/export/wallet-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@walletTransactions');
|
||||
|
||||
Route::get('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import');
|
||||
|
||||
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
|
||||
return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
|
||||
})->name('products.random');
|
||||
|
||||
Reference in New Issue
Block a user