mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
big commit
This commit is contained in:
@@ -89,7 +89,7 @@ class ScaffoldGeneratorCommand extends BaseCommand
|
||||
*/
|
||||
protected function checkIsThereAnyDataToGenerate()
|
||||
{
|
||||
if (count($this->commandData->fields) > 1) {
|
||||
if (count($this->commandData->fields) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"name": "name",
|
||||
"dbType": "string",
|
||||
"htmlType": "text",
|
||||
"validations": "required",
|
||||
"searchable": true,
|
||||
"fillable": true,
|
||||
"primary": false,
|
||||
"inForm": true,
|
||||
"inIndex": true
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
abstract class AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param HasOneOrMany $relation
|
||||
* @param Model $model
|
||||
* @return Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function handler(HasOneOrMany $relation, Model $model){
|
||||
try{
|
||||
|
||||
if($relation->save($model)){
|
||||
return $model;
|
||||
}
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException('Unable to update the record due to unexpected error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CompanyId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('company_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Documentable
|
||||
{
|
||||
|
||||
public function documents(): morphMany;
|
||||
|
||||
}
|
||||
@@ -5,15 +5,33 @@ namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressDefault;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* CreateAddressLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param ResetsAddressDefault $resetsAddressDefault
|
||||
* @param SetsAddressDefault $setsAddressDefault
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, CreatesAddress $createsAddress, ResetsAddressDefault $resetsAddressDefault, SetsAddressDefault $setsAddressDefault)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->resetsAddressDefault = $resetsAddressDefault;
|
||||
$this->setsAddressDefault = $setsAddressDefault;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@@ -31,16 +49,12 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/**
|
||||
* CreateAddressControllerLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param CreatesAddress $createsAddress
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, CreatesAddress $createsAddress)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->createsAddress = $createsAddress;
|
||||
}
|
||||
/** @var ResetsAddressDefault */
|
||||
private $resetsAddressDefault;
|
||||
|
||||
/** @var SetsAddressDefault */
|
||||
private $setsAddressDefault;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,8 +70,13 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canCreateAddress->passes($object);
|
||||
|
||||
/** @var Address $query */
|
||||
$query = $this->createsAddress->execute($object);
|
||||
|
||||
$this->resetsAddressDefault->execute($query);
|
||||
|
||||
$this->setsAddressDefault->execute($query);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\ResetsAddressDefault;
|
||||
use App\Classes\Modules\Addresses\Services\SetsAddressDefault;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SetAddressDefaultLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* SetAddressDefaultLogic constructor.
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param ResetsAddressDefault $resetsAddressDefault
|
||||
* @param SetsAddressDefault $setsAddressDefault
|
||||
*/
|
||||
public function __construct(FetchesAddress $fetchesAddress, ResetsAddressDefault $resetsAddressDefault, SetsAddressDefault $setsAddressDefault)
|
||||
{
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->resetsAddressDefault = $resetsAddressDefault;
|
||||
$this->setsAddressDefault = $setsAddressDefault;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Set Default Address',
|
||||
'message' => 'You have successfully updated your default address'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var ResetsAddressDefault */
|
||||
private $resetsAddressDefault;
|
||||
|
||||
/** @var SetsAddressDefault */
|
||||
private $setsAddressDefault;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->resetsAddressDefault->execute($address);
|
||||
|
||||
$this->setsAddressDefault->execute($address);
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Models\Address;
|
||||
|
||||
class ResetsAddressDefault
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Address $model
|
||||
* @return void
|
||||
*/
|
||||
public function execute(Address $model) {
|
||||
$model->company->addresses()->update([
|
||||
'default' => false,
|
||||
'billing' => false
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Models\Address;
|
||||
|
||||
class SetsAddressDefault extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Address $model
|
||||
* @return void
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Address $model) {
|
||||
$model->default = true;
|
||||
$model->billing = true;
|
||||
|
||||
$this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFile;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\CompanyTypes;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\OwnerType;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Company Identification',
|
||||
'message' => 'You have successfully created a new Company Identification Document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFile */
|
||||
private $createsFile;
|
||||
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/**
|
||||
* UpdateCompanyIdentificationDocumentLogic constructor.
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFile $createsFile
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
*/
|
||||
public function __construct(FetchesUser $fetchesUser, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFile $createsFile, UpdatesCompanyStatus $updatesCompanyStatus)
|
||||
{
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new DocumentObject(
|
||||
$company->type === CompanyTypes::COMPANY_BUSINESS ? DocumentType::SSM_REGISTRATION: DocumentType::IDENTITY_CARD,
|
||||
$request->input('files'), $request->input('reference'));
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($company, $object);
|
||||
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
$this->updatesCompanyStatus->execute($company, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompanyStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param int $status
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, int $status)
|
||||
{
|
||||
|
||||
$model->status = $status;
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanUpdateDocument;
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ApproveDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Approve Document',
|
||||
'message' => 'You have successfully approved the Document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateDocument */
|
||||
private $canUpdateDocument;
|
||||
|
||||
/** @var ApprovesDocument */
|
||||
private $approvesDocument;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateDocument $canUpdateDocument
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
*/
|
||||
public function __construct(
|
||||
canUpdateDocument $canUpdateDocument,
|
||||
ApprovesDocument $approvesDocument,
|
||||
FetchesDocument $fetchesDocument
|
||||
)
|
||||
{
|
||||
$this->canUpdateDocument = $canUpdateDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->canUpdateDocument->passes($document);
|
||||
|
||||
$document_query = $this->approvesDocument->execute($document);
|
||||
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Document',
|
||||
'message' => 'You have successfully retrieved a list of Document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListDocuments */
|
||||
private $canListDocuments;
|
||||
|
||||
/** @var ListsDocuments */
|
||||
private $listsDocuments;
|
||||
|
||||
/**
|
||||
* ListStandardSegmentLogic constructor.
|
||||
* @param CanListDocuments $canListDocuments
|
||||
* @param ListsDocuments $listsDocuments
|
||||
*/
|
||||
public function __construct(CanListDocuments $canListDocuments, ListsDocuments $listsDocuments)
|
||||
{
|
||||
$this->canListDocuments = $canListDocuments;
|
||||
$this->listsDocuments = $listsDocuments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canListDocuments->passes();
|
||||
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
|
||||
|
||||
class DocumentObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $document_type;
|
||||
|
||||
/** @var array */
|
||||
private $files;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/**
|
||||
* DocumentObject constructor.
|
||||
* @param string $document_type
|
||||
* @param array $files
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(string $document_type, array $files, ?string $reference = null)
|
||||
{
|
||||
$this->document_type = $document_type;
|
||||
$this->files = $files;
|
||||
$this->reference = $reference;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDocumentType(): string
|
||||
{
|
||||
return $this->document_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function getFiles(): array
|
||||
{
|
||||
return (new ConvertsBase64ToFile())->convert($this->files);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManager;
|
||||
|
||||
class FileObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* FileInfoObject constructor.
|
||||
* @param string $data
|
||||
*/
|
||||
public function __construct(string $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Intervention\Image\Image|string
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ? $this->data : (new imageManager())->make($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName(): string
|
||||
{
|
||||
return (string) Str::uuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType(): string
|
||||
{
|
||||
return finfo_file(finfo_open(), $this->data, FILEINFO_MIME_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function getExtension(): string
|
||||
{
|
||||
if(array_key_exists($this->getMimeType(), File::EXTENSION)){
|
||||
return File::EXTENSION[$this->getMimeType()];
|
||||
}
|
||||
|
||||
throw new MalformedRequestException('Failed to save file due to Unknown file extension');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
return $this->getExtension() === 'pdf' ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function setData(string $data): void
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApprovesDocument extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Document $model
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$model->status = ApprovalStatus::ACTIVE;
|
||||
$model->approved_by = Auth()->user()->id;
|
||||
$model->approved_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ConvertsBase64ToFile
|
||||
{
|
||||
|
||||
/** @var string|null */
|
||||
private $path;
|
||||
|
||||
/** @var array */
|
||||
private $filesInfo;
|
||||
|
||||
/**
|
||||
* ConvertsBase64ToFile constructor.
|
||||
* @param null|string $path
|
||||
*/
|
||||
public function __construct(?string $path = 'documents')
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->filesInfo = [];
|
||||
|
||||
File::isDirectory(storage_path($this->path)) or
|
||||
File::makeDirectory(storage_path($this->path), 0777, true, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $files
|
||||
* @return array
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function convert($files = []){
|
||||
foreach ($files as $file) {
|
||||
|
||||
$object = new FileObject($file);
|
||||
$object->getExtension() === 'pdf' ? $this->generatePDF($object) : $this->generateImage($object);
|
||||
|
||||
}
|
||||
|
||||
return $this->filesInfo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $file
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generatePDF(FileObject $file){
|
||||
|
||||
$filePath = $this->generateFile($file);
|
||||
$this->updateFiles($file, [ 'original' => [ 'file' => $filePath ] ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $file
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generateImage(FileObject $file){
|
||||
|
||||
$fileInfo = [];
|
||||
|
||||
foreach (['original' => null, 'large' => 800, 'medium' => 480, 'small' => 320] as $size => $value) {
|
||||
$suffix = $size !== 'original' ? '_'.$size : '';
|
||||
|
||||
if($size !== 'original') {
|
||||
$thumbnail = $file->getData()->widen($value, function ($constraint) {
|
||||
|
||||
$constraint->upsize();
|
||||
|
||||
})->heighten($value, function ($constraint) {
|
||||
|
||||
$constraint->upsize();
|
||||
|
||||
});
|
||||
|
||||
$file->setData($thumbnail->encode('data-url')->encoded);
|
||||
}
|
||||
|
||||
|
||||
$filePath = $this->generateFile($file, $suffix);
|
||||
|
||||
$fileInfo[] = [ $size => [ 'file' => $filePath, 'width' => $file->getData()->width(), 'height' => $file->getData()->height() ]];
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->updateFiles($file, $fileInfo);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $file
|
||||
* @param string $suffix
|
||||
* @return string
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function generateFile(FileObject $file, string $suffix = '') {
|
||||
|
||||
$filePath = storage_path($this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension());
|
||||
|
||||
Storage::put($filePath, $file->getDecodedData());
|
||||
|
||||
return $filePath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $file
|
||||
* @param array $fileInfo
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
private function updateFiles(FileObject $file, array $fileInfo){
|
||||
$this->filesInfo[] = json_encode([
|
||||
'path' => $this->path,
|
||||
'filename' => $file->getFileName().'.'.$file->getExtension(),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'extension' => $file->getExtension(),
|
||||
'file_info' => $fileInfo
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Models\Document;
|
||||
|
||||
class CreatesDocument extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param Documentable $documentable
|
||||
* @param DocumentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Documentable $documentable, DocumentObject $object)
|
||||
{
|
||||
$model = new Document();
|
||||
$model->document_type = $object->getDocumentType();
|
||||
$model->reference = $object->getReference();
|
||||
|
||||
return $this->handler($documentable->documents(), $model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Models\Document;
|
||||
use App\Models\File;
|
||||
|
||||
class CreatesFile extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
/**
|
||||
* @param Document $document
|
||||
* @param DocumentObject $object
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Document $document, DocumentObject $object)
|
||||
{
|
||||
$models = [];
|
||||
|
||||
foreach ($object->getFiles() as $file) {
|
||||
|
||||
$model = new File(['file' => $file]);
|
||||
$models[] = $this->handler($document->files(), $model);
|
||||
|
||||
}
|
||||
|
||||
return $models;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Document;
|
||||
|
||||
class FetchesDocument extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Document */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param Document $repository
|
||||
*/
|
||||
public function __construct(Document $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Document;
|
||||
|
||||
class ListsDocuments extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Document */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsDocuments constructor.
|
||||
* @param Document $repository
|
||||
*/
|
||||
public function __construct(Document $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\DocumentValidation;
|
||||
|
||||
class CanCreateDocument extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var DocumentValidation */
|
||||
private $documentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param DocumentValidation $documentValidation
|
||||
*/
|
||||
public function __construct(DocumentValidation $documentValidation)
|
||||
{
|
||||
$this->documentValidation = $documentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->documentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\FileValidation;
|
||||
|
||||
class CanCreateFile extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var FileValidation */
|
||||
private $fileValidation;
|
||||
|
||||
/**
|
||||
* CanCreateFile constructor.
|
||||
* @param FileValidation $fileValidation
|
||||
*/
|
||||
public function __construct(FileValidation $fileValidation)
|
||||
{
|
||||
$this->fileValidation = $fileValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->fileValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class CanListDocuments extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('view document')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\DocumentValidation;
|
||||
|
||||
class CanUpdateDocument extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var DocumentValidation */
|
||||
private $documentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param DocumentValidation $documentValidation
|
||||
*/
|
||||
public function __construct(DocumentValidation $documentValidation)
|
||||
{
|
||||
$this->documentValidation = $documentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->documentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class DocumentValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'owner_id' => $object->getOwnerId(),
|
||||
'owner_type' => $object->getOwnerType(),
|
||||
'document_type' => $object->getDocumentType(),
|
||||
'reference' => $object->getReference(),
|
||||
'status' => $object->getStatus(),
|
||||
'approved_by' => $object->getApprovedBy(),
|
||||
'issued_date' => $object->getIssuedDate(),
|
||||
'expired_date' => $object->getExpiredDate(),
|
||||
'approved_date' => $object->getApprovedDate()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'owner_id' => 'required',
|
||||
'owner_type' => 'required',
|
||||
'document_type' => 'required',
|
||||
'reference' => 'required',
|
||||
'status' => '',
|
||||
'issued_date' => '',
|
||||
'expired_date' => '',
|
||||
'approved_date' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
|
||||
class FileValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'document_id' => $object->getDocumentId(),
|
||||
'file' => $object->getFile(),
|
||||
'file_type' => $object->getFileType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'document_id' => 'required',
|
||||
'file' => 'required',
|
||||
'file_type' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\PackagesListObject;
|
||||
|
||||
interface createPackagesListLogic
|
||||
{
|
||||
|
||||
public function execute(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\DataTransferObjects;
|
||||
|
||||
|
||||
class ItemObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $unitOfMeasurment;
|
||||
|
||||
/** @var float */
|
||||
private $quantity;
|
||||
|
||||
/** @var double */
|
||||
private $price;
|
||||
|
||||
/** @var string */
|
||||
private $currency;
|
||||
|
||||
/**
|
||||
* ItemObject constructor.
|
||||
* @param string $description
|
||||
* @param string $unitOfMeasurment
|
||||
* @param float $quantity
|
||||
* @param float $price
|
||||
* @param string $currency
|
||||
*/
|
||||
public function __construct(string $description, string $unitOfMeasurment, float $quantity, float $price, string $currency)
|
||||
{
|
||||
$this->description = $description;
|
||||
$this->unitOfMeasurment = $unitOfMeasurment;
|
||||
$this->quantity = $quantity;
|
||||
$this->price = $price;
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUnitOfMeasurment(): string
|
||||
{
|
||||
return $this->unitOfMeasurment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getQuantity(): float
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getPrice(): float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\DataTransferObjects;
|
||||
|
||||
|
||||
class PackageObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var float */
|
||||
private $width;
|
||||
|
||||
/** @var float */
|
||||
private $height;
|
||||
|
||||
/** @var float */
|
||||
private $lenght;
|
||||
|
||||
/** @var array */
|
||||
private $items;
|
||||
|
||||
/**
|
||||
* PackageObject constructor.
|
||||
* @param int $type
|
||||
* @param float $width
|
||||
* @param float $height
|
||||
* @param float $lenght
|
||||
* @param array $items
|
||||
*/
|
||||
public function __construct(int $type, float $width, float $height, float $lenght, array $items)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
$this->lenght = $lenght;
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getWidth(): float
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getHeight(): float
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getLenght(): float
|
||||
{
|
||||
return $this->lenght;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\DataTransferObjects;
|
||||
|
||||
|
||||
class PackagesListObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $orderId;
|
||||
|
||||
/** @var array */
|
||||
private $packages;
|
||||
|
||||
/**
|
||||
* PackagesListObject constructor.
|
||||
* @param int $orderId
|
||||
* @param array $packages
|
||||
*/
|
||||
public function __construct(int $orderId, array $packages)
|
||||
{
|
||||
$this->orderId = $orderId;
|
||||
$this->packages = $packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOrderId(): int
|
||||
{
|
||||
return $this->orderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPackages(): array
|
||||
{
|
||||
return $this->packages;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class ApprovalStatus {
|
||||
|
||||
public const PENDING_SUBMISSION = 0;
|
||||
|
||||
public const PENDING_VERIFICATION = 1;
|
||||
|
||||
public const APPROVED = 2;
|
||||
|
||||
public const COMPLETED = 3;
|
||||
|
||||
public const REJECTED = 4;
|
||||
|
||||
public const SUSPENDED = 5;
|
||||
|
||||
public const EXPIRED = 6;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class DocumentType {
|
||||
public const SSM_REGISTRATION = 'SSM_REGISTRATION';
|
||||
public const IDENTITY_CARD = 'IDENTITY_CARD';
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
|
||||
public const EXTENSION = [
|
||||
'image/gif' => 'gif',
|
||||
'image/png' => 'png',
|
||||
'image/jpeg' => 'jpeg',
|
||||
'application/pdf' => 'pdf',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class OwnerType {
|
||||
public const COMPANY = 1;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Addresses;
|
||||
|
||||
use App\Classes\Modules\Addresses\ControllersLogic\CreateAddressLogic;
|
||||
use App\Classes\Modules\Addresses\ControllersLogic\SetAddressDefaultLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SetAddressDefaultController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param SetAddressDefaultLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function set(Request $request, SetAddressDefaultLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyIdentificationDocumentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyIdentificationDocumentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateCompanyIdentificationDocumentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateCompanyIdentificationDocumentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use App\Models\Company;
|
||||
use App\Models\CompanyConnections;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Barryvdh\DomPDF\PDF;
|
||||
|
||||
class OrderController
|
||||
{
|
||||
@@ -26,8 +27,8 @@ class OrderController
|
||||
$order->company_id = $company->id;
|
||||
$order->order_number = $generatesUniqueOrderNumber->execute();
|
||||
$order->forwarder_id = 1;
|
||||
$order->address_id = $company->addresses()->first()->id;
|
||||
$order->contact_id = $company->contacts()->first()->id;
|
||||
$order->address_id = $company->addresses->first()->id;
|
||||
$order->contact_id = $company->contacts->first()->id;
|
||||
$order->current_step = 'MS_WAREHOUSE_RECEIVING';
|
||||
$order->multiple_batch = false;
|
||||
$order->complete = false;
|
||||
@@ -59,7 +60,7 @@ class OrderController
|
||||
HttpStatus::OK_WITH_MESSAGE, json_decode(OrderResource::collection($orders)->response()->getContent(), true)))->handler();
|
||||
}
|
||||
|
||||
public function download(String $orderId){
|
||||
public function download(String $orderId, PDF $pdf){
|
||||
/** @var Order $order */
|
||||
$order = order::findOrFail($orderId);
|
||||
/** @var Company $warehouse */
|
||||
@@ -78,7 +79,7 @@ class OrderController
|
||||
|
||||
return view('pages.pdf.qr', $data);
|
||||
|
||||
return $this->pdf->loadView('pages.pdf.qr', $data)->stream();
|
||||
return $pdf->loadView('pages.pdf.qr', $data)->download();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\CheckEmailLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TestController
|
||||
{
|
||||
|
||||
public function index(){
|
||||
$cookies = $this->getToken();
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/GetPage');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"controller":"WarehouseList","view":"grid1","request":{"PageSize":10000000, "Filter":["ParcelDate:>%js%\"2020-01-10T00:00:00.000\"\u0000"]}}');
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
|
||||
|
||||
$headers = array();
|
||||
$headers[] = 'Connection: keep-alive';
|
||||
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36';
|
||||
$headers[] = 'X-Requested-With: XMLHttpRequest';
|
||||
$headers[] = 'Content-Type: application/json; charset=UTF-8';
|
||||
$headers[] = 'Accept: */*';
|
||||
$headers[] = 'Origin: http://portalvt.azurewebsites.net';
|
||||
$headers[] = 'Referer: http://portalvt.azurewebsites.net/Pages/WarehouseList.aspx';
|
||||
$headers[] = 'Accept-Language: en-US,en;q=0.9';
|
||||
$headers[] = 'Cookie: '.implode('; ', $cookies);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
echo 'Error:' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
dd(json_decode($result));
|
||||
}
|
||||
private function getToken(){
|
||||
$cookies = $this->getCookies();
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"username":"CIEF","password":"0122120880","createPersistentCookie":true}');
|
||||
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
|
||||
|
||||
$headers = array();
|
||||
$headers[] = 'Connection: keep-alive';
|
||||
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36';
|
||||
$headers[] = 'X-Requested-With: XMLHttpRequest';
|
||||
$headers[] = 'Content-Type: application/json; charset=UTF-8';
|
||||
$headers[] = 'Accept: */*';
|
||||
$headers[] = 'Origin: http://portalvt.azurewebsites.net';
|
||||
$headers[] = 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
|
||||
$headers[] = 'Accept-Language: en-US,en;q=0.9';
|
||||
$headers[] = 'Cookie: '.implode('; ', $cookies);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
echo 'Error:' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
$cookies[] = 'AppVTCC='.json_decode($result)->d->Token;
|
||||
return $cookies;
|
||||
|
||||
}
|
||||
|
||||
private function getCookies(){
|
||||
$cookies = [];
|
||||
$curl_handle = curl_init('http://portalvt.azurewebsites.net/Login.aspx');
|
||||
|
||||
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, false);
|
||||
|
||||
curl_setopt($curl_handle, CURLOPT_HEADER, true);
|
||||
|
||||
|
||||
$data = curl_exec($curl_handle);
|
||||
|
||||
$responseHeader= substr($data,0, intval(curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE)));
|
||||
|
||||
$endPosition = 0;
|
||||
while(true) {
|
||||
$startPosition = strpos($responseHeader, 'Set-Cookie: ', $endPosition);
|
||||
if (!$startPosition){break;}
|
||||
$startPosition += 12;
|
||||
$endPosition = strpos($responseHeader, ';', $startPosition);
|
||||
$cookies[] = substr($responseHeader,$startPosition,$endPosition-$startPosition);
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
|
||||
public function index2() {
|
||||
// curl 'http://portalvt.azurewebsites.net/Services/DataControllerService.asmx/Login' \
|
||||
// -H 'Connection: keep-alive' \
|
||||
// -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' \
|
||||
// -H 'X-Requested-With: XMLHttpRequest' \
|
||||
// -H 'Content-Type: application/json; charset=UTF-8' \
|
||||
// -H 'Accept: */*' \
|
||||
// -H 'Origin: http://portalvt.azurewebsites.net' \
|
||||
// -H 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx' \
|
||||
// -H 'Accept-Language: en-US,en;q=0.9' \
|
||||
// -H 'Cookie: ASP.NET_SessionId=cxe2tgbsi03jtg2p0nlfdcrl; ARRAffinity=2950dd3bc3c86410bd48fe08ed3595e06670f25d93c162510d25040b02f01a67' \
|
||||
// --data-binary '{"username":"CIEF","password":"0122120880","createPersistentCookie":true}' \
|
||||
// --compressed \
|
||||
// --insecure
|
||||
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
|
||||
|
||||
|
||||
$post = array('createPersistentCookie'=>true,
|
||||
'username'=>'CIEF',
|
||||
'password'=>'0122120880');
|
||||
$request = array();
|
||||
$request[] = 'Connection: keep-alive';
|
||||
$request[] = 'Pragma: no-cache';
|
||||
$request[] = 'Cache-Control: no-cache';
|
||||
$request[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
|
||||
$request[] = 'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36';
|
||||
$request[] = 'DNT: 1';
|
||||
$request[] = 'http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
|
||||
$request[] = 'Accept-Encoding: gzip, deflate';
|
||||
$request[] = 'Accept-Language: en-US,en;q=0.8';
|
||||
$request[] = 'Content-Type:multipart/form-data';
|
||||
|
||||
|
||||
$url = 'http://portalvt.azurewebsites.net/Login.aspx';
|
||||
$ch = curl_init($url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $request);
|
||||
curl_setopt($ch, CURLOPT_ENCODING,"");
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT,10);
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR,true);
|
||||
curl_setopt($ch, CURLOPT_ENCODING,"");
|
||||
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
|
||||
|
||||
$data = curl_exec($ch);
|
||||
|
||||
if (curl_errno($ch)){
|
||||
$data .= 'Retreive Base Page Error: ' . curl_error($ch);
|
||||
var_dump($data);
|
||||
}
|
||||
else {
|
||||
$info = rawurldecode(var_export(curl_getinfo($ch),true));
|
||||
|
||||
|
||||
|
||||
$skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
|
||||
$responseHeader= substr($data,0,$skip);
|
||||
|
||||
// The folowing line is for debug
|
||||
// echo "$info\n$responseHeader\n$data\n\n";
|
||||
|
||||
|
||||
|
||||
// Get the cookies:
|
||||
$e = 0;
|
||||
while(true){
|
||||
$s = strpos($responseHeader,'Set-Cookie: ',$e);
|
||||
if (!$s){break;}
|
||||
$s += 12;
|
||||
$e = strpos($responseHeader,';',$s);
|
||||
$cookie = substr($responseHeader,$s,$e-$s) ;
|
||||
$s = strpos($cookie,'=');
|
||||
$key = substr($cookie,0,$s);
|
||||
$value = substr($cookie,$s);
|
||||
$cookies[$key] = $value;
|
||||
}
|
||||
|
||||
// Create cookie for subsequent Requests:
|
||||
|
||||
$cookie = '';
|
||||
$show = '';
|
||||
$head = '';
|
||||
$delim = '';
|
||||
foreach ($cookies as $k => $v){
|
||||
$cookie .= "$delim$k$v";
|
||||
$delim = '; ';
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($cookies);
|
||||
$request = array();
|
||||
$request[] = 'Host: portalvt.azurewebsites.net';
|
||||
$request[] = 'Connection: keep-alive';
|
||||
$request[] = 'Pragma: no-cache';
|
||||
$request[] = 'Cache-Control: no-cache';
|
||||
$request[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
|
||||
$request[] = 'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36';
|
||||
$request[] = 'DNT: 1';
|
||||
$request[] = 'Referer: http://portalvt.azurewebsites.net/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx';
|
||||
$request[] = 'Accept-Encoding: gzip, deflate';
|
||||
$request[] = 'Accept-Language: en-US,en;q=0.8';
|
||||
|
||||
|
||||
$url = 'http://portalvt.azurewebsites.net/Login.aspx';
|
||||
$ch = curl_init($url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $request);
|
||||
curl_setopt($ch, CURLOPT_ENCODING,"");
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT,10);
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR,true);
|
||||
curl_setopt($ch, CURLOPT_ENCODING,"");
|
||||
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_COOKIESESSION , true );
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookie );
|
||||
|
||||
$data = curl_exec($ch);
|
||||
$skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
|
||||
echo substr($data,$skip); //do not transmit header
|
||||
|
||||
|
||||
// if (curl_errno($ch)){
|
||||
// $data .= 'Retreive Base Page Error: ' . curl_error($ch);
|
||||
// var_dump($data);
|
||||
// }
|
||||
// else {
|
||||
// $info = rawurldecode(var_export(curl_getinfo($ch), true));
|
||||
//
|
||||
// // Get the cookies:
|
||||
//
|
||||
// $skip = intval(curl_getinfo($ch, CURLINFO_HEADER_SIZE));
|
||||
// $responseHeader = substr($data, 0, $skip);
|
||||
//
|
||||
// echo "$info\n$responseHeader\n$data\n\n";
|
||||
//
|
||||
// $e = 0;
|
||||
// while (true) {
|
||||
// $s = strpos($responseHeader, 'Set-Cookie: ', $e);
|
||||
// if (!$s) {
|
||||
// break;
|
||||
// }
|
||||
// $s += 12;
|
||||
// $e = strpos($responseHeader, ';', $s);
|
||||
// $cookie = substr($responseHeader, $s, $e - $s);
|
||||
// $s = strpos($cookie, '=');
|
||||
// $key = substr($cookie, 0, $s);
|
||||
// $value = substr($cookie, $s);
|
||||
// $cookies[$key] = $value;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class invoiceClass
|
||||
{
|
||||
$user = User::fetch();
|
||||
public function execute(){
|
||||
|
||||
$company = $user->company();
|
||||
$price = $company->price();
|
||||
$order = Order::fetch();
|
||||
$items = $order->items();
|
||||
|
||||
$deliveryAddress = address();
|
||||
|
||||
$invoice = Invoice::create([
|
||||
$order,
|
||||
$items
|
||||
]);
|
||||
|
||||
|
||||
$convertToPdf = $invoice->pdf();
|
||||
|
||||
$email = email()->pdf();
|
||||
|
||||
solid
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class preformaClass
|
||||
{
|
||||
|
||||
public function execute(){
|
||||
$user = User::fetch();
|
||||
$company = $user->company();
|
||||
$price = $company->price();
|
||||
$order = Order::fetch();
|
||||
$items = $order->items();
|
||||
|
||||
$deliveryAddress = address();
|
||||
|
||||
$invoice = Performa::create([
|
||||
$order,
|
||||
$items
|
||||
]);
|
||||
|
||||
$convertToPdf = $invoice->pdf();
|
||||
|
||||
$email = email()->pdf();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AccountStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\CompanyConnections;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -22,9 +23,10 @@ class CompanyResource extends JsonResource
|
||||
'marking' => CompanyConnections::where('module_one', $this->modules->first()->id)->first()->marking,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'status' => AccountStatus::STATUS[$this->status],
|
||||
'status' => $this->status,
|
||||
'delivery_address' => new AddressResource($this->deliveryAddress),
|
||||
'contact' => new ContactResource($this->contacts->first())
|
||||
'contact' => new ContactResource($this->contacts->first()),
|
||||
'total_orders' => count($this->orders)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DocumentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'document_type' => $this->document_type,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'approved_by' => (int) $this->approved_by,
|
||||
'files' => $this->files()->get()
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -30,11 +31,11 @@ class Address extends AbstractModel
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
**/
|
||||
public function company(): HasOne
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->hasOne(Company::class, 'company_id', 'id');
|
||||
return $this->BelongsTo(Company::class, 'company_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-2
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\AbstractModel as Model;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
@@ -17,7 +18,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property string name
|
||||
* @property integer type
|
||||
*/
|
||||
class Company extends AbstractModel
|
||||
class Company extends AbstractModel implements Documentable
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
@@ -74,6 +75,22 @@ class Company extends AbstractModel
|
||||
return $this->hasManyThrough(Company::class, CompanyConnections::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function documents(): morphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function orders(): hasMany
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Traits\Timestamp;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property int owner_type
|
||||
* @property int document_type
|
||||
* @property string reference
|
||||
* @property int status
|
||||
* @property \App\Models\User approved_by
|
||||
* @property timestamp issued_date
|
||||
* @property timestamp expired_date
|
||||
* @property timestamp approved_date
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'documents';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
*/
|
||||
public function files(): hasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'document_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class File
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Document document_id
|
||||
* @property text file
|
||||
* @property int file_type_id
|
||||
*/
|
||||
class File extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'files';
|
||||
|
||||
protected $fillable = ['file'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getFileAttribute($value)
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class PasswordReset extends AbstractModel
|
||||
{
|
||||
protected $table = 'password_resets';
|
||||
|
||||
protected $fillable = ['token'];
|
||||
/**
|
||||
* @param $query
|
||||
* @return mixed
|
||||
|
||||
+12
-1
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
@@ -18,7 +20,8 @@ class User extends AbstractModel implements
|
||||
JWTSubject,
|
||||
AuthenticatableContract,
|
||||
AuthorizableContract,
|
||||
CanResetPasswordContract
|
||||
CanResetPasswordContract,
|
||||
documentable
|
||||
{
|
||||
use Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
|
||||
|
||||
@@ -62,4 +65,12 @@ class User extends AbstractModel implements
|
||||
return $this->hasMany(Order::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function documents(): morphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'owner');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-2
@@ -9,15 +9,17 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"ext-curl": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-json": "^1.6",
|
||||
"barryvdh/laravel-dompdf": "^0.9.0",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"fruitcake/laravel-cors": "^1.0",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"laravel/framework": "^7.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
"spatie/laravel-activitylog": "^3.14",
|
||||
"tymon/jwt-auth": "^1.0",
|
||||
"ext-curl": "*"
|
||||
"tymon/jwt-auth": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^2.0",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AccountStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -20,7 +21,7 @@ class CreateCompaniesTable extends Migration
|
||||
$table->bigInteger('reference_no')->unique();
|
||||
$table->string('name');
|
||||
$table->integer('type')->comment('business type eg. personal, company');
|
||||
$table->integer('status')->default(AccountStatus::PENDING_VERIFICATION);
|
||||
$table->integer('status')->default(ApprovalStatus::PENDING_SUBMISSION);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDocumentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('owner');
|
||||
$table->string('document_type');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('status')->default(ApprovalStatus::PENDING_VERIFICATION);
|
||||
$table->bigInteger('approved_by')->unsigned()->nullable();
|
||||
$table->timestamp('issued_date')->nullable();
|
||||
$table->timestamp('expired_date')->nullable();
|
||||
$table->timestamp('approved_date')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('documents');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFilesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('document_id')->unsigned();
|
||||
$table->text('file');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
// 1. [Required] Point to the composer or dompdf autoloader
|
||||
require_once "vendor/autoload.php";
|
||||
|
||||
// 2. [Optional] Set the path to your font directory
|
||||
// By default dompdf loads fonts to dompdf/lib/fonts
|
||||
// If you have modified your font directory set this
|
||||
// variable appropriately.
|
||||
//$fontDir = "lib/fonts";
|
||||
|
||||
|
||||
// *** DO NOT MODIFY BELOW THIS POINT ***
|
||||
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\CanvasFactory;
|
||||
use Dompdf\Exception;
|
||||
use Dompdf\FontMetrics;
|
||||
use Dompdf\Options;
|
||||
|
||||
use FontLib\Font;
|
||||
|
||||
/**
|
||||
* Display command line usage
|
||||
*/
|
||||
function usage() {
|
||||
echo <<<EOD
|
||||
|
||||
Usage: {$_SERVER["argv"][0]} font_family [n_file [b_file] [i_file] [bi_file]]
|
||||
|
||||
font_family: the name of the font, e.g. Verdana, 'Times New Roman',
|
||||
monospace, sans-serif. If it equals to "system_fonts",
|
||||
all the system fonts will be installed.
|
||||
|
||||
n_file: the .ttf or .otf file for the normal, non-bold, non-italic
|
||||
face of the font.
|
||||
|
||||
{b|i|bi}_file: the files for each of the respective (bold, italic,
|
||||
bold-italic) faces.
|
||||
|
||||
If the optional b|i|bi files are not specified, load_font.php will search
|
||||
the directory containing normal font file (n_file) for additional files that
|
||||
it thinks might be the correct ones (e.g. that end in _Bold or b or B). If
|
||||
it finds the files they will also be processed. All files will be
|
||||
automatically copied to the DOMPDF font directory, and afm files will be
|
||||
generated using php-font-lib (https://github.com/PhenX/php-font-lib).
|
||||
|
||||
Examples:
|
||||
|
||||
./load_font.php silkscreen /usr/share/fonts/truetype/slkscr.ttf
|
||||
./load_font.php 'Times New Roman' /mnt/c_drive/WINDOWS/Fonts/times.ttf
|
||||
|
||||
EOD;
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $_SERVER["argc"] < 3 && @$_SERVER["argv"][1] != "system_fonts" ) {
|
||||
usage();
|
||||
}
|
||||
|
||||
$dompdf = new Dompdf();
|
||||
if (isset($fontDir) && realpath($fontDir) !== false) {
|
||||
$dompdf->getOptions()->set('fontDir', $fontDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a new font family
|
||||
* This function maps a font-family name to a font. It tries to locate the
|
||||
* bold, italic, and bold italic versions of the font as well. Once the
|
||||
* files are located, ttf versions of the font are copied to the fonts
|
||||
* directory. Changes to the font lookup table are saved to the cache.
|
||||
*
|
||||
* @param Dompdf $dompdf dompdf main object
|
||||
* @param string $fontname the font-family name
|
||||
* @param string $normal the filename of the normal face font subtype
|
||||
* @param string $bold the filename of the bold face font subtype
|
||||
* @param string $italic the filename of the italic face font subtype
|
||||
* @param string $bold_italic the filename of the bold italic face font subtype
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
function install_font_family($dompdf, $fontname, $normal, $bold = null, $italic = null, $bold_italic = null) {
|
||||
$fontMetrics = $dompdf->getFontMetrics();
|
||||
|
||||
// Check if the base filename is readable
|
||||
if ( !is_readable($normal) )
|
||||
throw new Exception("Unable to read '$normal'.");
|
||||
|
||||
$dir = dirname($normal);
|
||||
$basename = basename($normal);
|
||||
$last_dot = strrpos($basename, '.');
|
||||
if ($last_dot !== false) {
|
||||
$file = substr($basename, 0, $last_dot);
|
||||
$ext = strtolower(substr($basename, $last_dot));
|
||||
} else {
|
||||
$file = $basename;
|
||||
$ext = '';
|
||||
}
|
||||
|
||||
if ( !in_array($ext, array(".ttf", ".otf")) ) {
|
||||
throw new Exception("Unable to process fonts of type '$ext'.");
|
||||
}
|
||||
|
||||
// Try $file_Bold.$ext etc.
|
||||
$path = "$dir/$file";
|
||||
|
||||
$patterns = array(
|
||||
"bold" => array("_Bold", "b", "B", "bd", "BD"),
|
||||
"italic" => array("_Italic", "i", "I"),
|
||||
"bold_italic" => array("_Bold_Italic", "bi", "BI", "ib", "IB"),
|
||||
);
|
||||
|
||||
foreach ($patterns as $type => $_patterns) {
|
||||
if ( !isset($$type) || !is_readable($$type) ) {
|
||||
foreach($_patterns as $_pattern) {
|
||||
if ( is_readable("$path$_pattern$ext") ) {
|
||||
$$type = "$path$_pattern$ext";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_null($$type) )
|
||||
echo ("Unable to find $type face file.\n");
|
||||
}
|
||||
}
|
||||
|
||||
$fonts = compact("normal", "bold", "italic", "bold_italic");
|
||||
$entry = array();
|
||||
|
||||
// Copy the files to the font directory.
|
||||
foreach ($fonts as $var => $src) {
|
||||
if ( is_null($src) ) {
|
||||
$entry[$var] = $dompdf->getOptions()->get('fontDir') . '/' . mb_substr(basename($normal), 0, -4);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Verify that the fonts exist and are readable
|
||||
if ( !is_readable($src) )
|
||||
throw new Exception("Requested font '$src' is not readable");
|
||||
|
||||
$dest = $dompdf->getOptions()->get('fontDir') . '/' . basename($src);
|
||||
|
||||
if ( !is_writeable(dirname($dest)) )
|
||||
throw new Exception("Unable to write to destination '$dest'.");
|
||||
|
||||
echo "Copying $src to $dest...\n";
|
||||
|
||||
if ( !copy($src, $dest) )
|
||||
throw new Exception("Unable to copy '$src' to '$dest'");
|
||||
|
||||
$entry_name = mb_substr($dest, 0, -4);
|
||||
|
||||
echo "Generating Adobe Font Metrics for $entry_name...\n";
|
||||
|
||||
$font_obj = Font::load($dest);
|
||||
$font_obj->saveAdobeFontMetrics("$entry_name.ufm");
|
||||
$font_obj->close();
|
||||
|
||||
$entry[$var] = $entry_name;
|
||||
}
|
||||
|
||||
// Store the fonts in the lookup table
|
||||
$fontMetrics->setFontFamily($fontname, $entry);
|
||||
|
||||
// Save the changes
|
||||
$fontMetrics->saveFontFamilies();
|
||||
}
|
||||
|
||||
// If installing system fonts (may take a long time)
|
||||
if ( $_SERVER["argv"][1] === "system_fonts" ) {
|
||||
$fontMetrics = $dompdf->getFontMetrics();
|
||||
$files = glob("/usr/share/fonts/truetype/*.ttf") +
|
||||
glob("/usr/share/fonts/truetype/*/*.ttf") +
|
||||
glob("/usr/share/fonts/truetype/*/*/*.ttf") +
|
||||
glob("C:\\Windows\\fonts\\*.ttf") +
|
||||
glob("C:\\WinNT\\fonts\\*.ttf") +
|
||||
glob("/mnt/c_drive/WINDOWS/Fonts/");
|
||||
$fonts = array();
|
||||
foreach ($files as $file) {
|
||||
$font = Font::load($file);
|
||||
$records = $font->getData("name", "records");
|
||||
$type = $fontMetrics->getType($records[2]);
|
||||
$fonts[mb_strtolower($records[1])][$type] = $file;
|
||||
$font->close();
|
||||
}
|
||||
|
||||
foreach ( $fonts as $family => $files ) {
|
||||
echo " >> Installing '$family'... \n";
|
||||
|
||||
if ( !isset($files["normal"]) ) {
|
||||
echo "No 'normal' style font file\n";
|
||||
}
|
||||
else {
|
||||
install_font_family($dompdf, $family, @$files["normal"], @$files["bold"], @$files["italic"], @$files["bold_italic"]);
|
||||
echo "Done !\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
call_user_func_array("install_font_family", array_merge( array($dompdf), array_slice($_SERVER["argv"], 1) ));
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -7,7 +7,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col bg-white">
|
||||
<div class="col bg-white parentConatiner">
|
||||
<div class="row align-items-center justify-content-center p-t-10 p-b-10">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
@@ -20,8 +20,8 @@
|
||||
<div class="row h-100">
|
||||
<div class="col">
|
||||
<div class="row no-margin">
|
||||
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest m-r-5 ml-auto">
|
||||
<a class="requestModal pointer" data-type="delete">
|
||||
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest m-r-5 ml-auto" v-if="!address.default">
|
||||
<a class="requestModal pointer" data-type="delete" @click="submit(route('api.address.delete', data.id), 'delete', 'addressSection', true, true)">
|
||||
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
|
||||
<div class="col">
|
||||
<i class="fa fa-times text-danger"></i>
|
||||
@@ -30,7 +30,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest">
|
||||
<a class="pointer">
|
||||
<a class="pointer requestModal" data-type="editModal">
|
||||
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
|
||||
<div class="col">
|
||||
<i class="fa fa-pencil text-info"></i>
|
||||
@@ -38,6 +38,11 @@
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<modal-form-component section="addressSection" :data="address">
|
||||
<template slot="form" slot-scope="{section}">
|
||||
<address-form-component section="section" :id="address.company_id" :data="address"></address-form-component>
|
||||
</template>
|
||||
</modal-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,7 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 m-l-15 d-flex align-items-center">
|
||||
<div class="row align-items-center" :class="[{'requestModal': !address.default}, {'pointer': !address.default}, {'link': !address.default}]" data-type="setDefault">
|
||||
<div class="row align-items-center" v-if="!address.default" :class="[{'requestModal': !address.default}, {'pointer': !address.default}, {'link': !address.default}]" @click="submit(route('api.address.default', data.id), 'post', 'addressSection', true, true)" data-type="setDefault">
|
||||
<div class="col-auto text-right p-t-5 p-b-5" :class="[{'bg-warning-lighter': address.default}, {'bg-master-light': !address.default}]">
|
||||
<div data-toggle="tooltip" class="row align-items-center justify-content-center" :class="{'link': !address.default}">
|
||||
<div class="col">
|
||||
@@ -71,6 +76,7 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
section: 'addressSection',
|
||||
address: this.data
|
||||
}
|
||||
},
|
||||
@@ -79,6 +85,12 @@
|
||||
this.address = this.data;
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
successHandler(){
|
||||
this.crudSuccess();
|
||||
EventBus.$emit('updateAddress')
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
@@ -77,11 +77,25 @@
|
||||
newOrder: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.data){
|
||||
this.parameters = this.data;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
'id': function() {
|
||||
this.parameters.company_id = this.id;
|
||||
},
|
||||
'data': function() {
|
||||
this.parameters = this.data;
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -112,7 +126,7 @@
|
||||
},
|
||||
methods:{
|
||||
submitForm(){
|
||||
this.submit((this.route('api.address.create')), 'post', 'address.form', true, true)
|
||||
this.submit(this.data ? (this.route('api.address.update', this.data.id)) : (this.route('api.address.create')), this.data ? 'put' : 'post', 'addressSection', true, true)
|
||||
},
|
||||
successHandler(){
|
||||
this.crudSuccess();
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
<template>
|
||||
<transition-component group enter-class="animated fadeInRightBig delay-1 faster" leave-class="animated fadeOutRightBig faster">
|
||||
<transition-component group enter-class="animate__animated animate__fadeInUp animate__delay-1 animate__faster p-r-30" leave-class="animate__animated animate__fadeOutDown animate__faster p-r-30" style="min-height: 300px;">
|
||||
<loading-component style="height: 200px; top: 0;" key="1" color="success" v-show="$store.getters.isLoading(section)"></loading-component>
|
||||
<div class="row" key="2" v-show="!$store.getters.isLoading(section)">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-show="!$store.getters.getListData(section).length">
|
||||
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-show="!$store.getters.getListData(section).length && !$store.getters.isLoading(section)">
|
||||
<div class="col-10">
|
||||
<div class="row align-items-center justify-content-center hint-text">
|
||||
<div class="col-6 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
<div class="col-4 hint-text"><img src="/images/not-found-illustration.png" class="w-100 hint-text"/></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">No Results Found</p>
|
||||
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-5 align-items-center justify-content-center">
|
||||
<div class="col">
|
||||
<small class="fs-9 muted all-caps font-lato" style="letter-spacing: 2px">Try adjusting your filters to find what you are looking for.</small>
|
||||
<small class="fs-9 muted all-caps font-lato" style="letter-spacing: 2px">There is no results found, Try adjusting your filters to find what you are looking for.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="list disable-text-selection" data-check-all="checkAll">
|
||||
<div class="row" v-for="item in $store.getters.getListData(section)" v-bind:key="item.id" :data="item">
|
||||
<div class="row" ref="list" v-for="item in $store.getters.getListData(section)" v-bind:key="item.id" :data="item">
|
||||
<div class="col">
|
||||
<slot name="list" :data="item"></slot>
|
||||
</div>
|
||||
@@ -71,7 +71,6 @@
|
||||
filters: this.options
|
||||
}
|
||||
},
|
||||
validations: {},
|
||||
created(){
|
||||
this.setDecoratorDefault();
|
||||
this.$store.dispatch('updateListQueue', {'name': this.section, 'page': 1, 'filters': this.filters});
|
||||
@@ -93,6 +92,11 @@
|
||||
let listDecorators = this.$store.getters.getListDetails(this.section);
|
||||
this.submit(this.endpoint + '?page=' + listDecorators.page + '&filters=' + JSON.stringify(listDecorators.filters), 'get', this.section, false, false)
|
||||
},
|
||||
updateFilters(filters){
|
||||
this.filters = filters;
|
||||
this.setDecoratorDefault();
|
||||
this.submit(this.endpoint + '?page=1&filters=' + JSON.stringify(this.filters), 'get', this.section, false, false)
|
||||
},
|
||||
successHandler(response){
|
||||
this.$store.dispatch('completeList', {'name': this.section, 'data': response.payload.data});
|
||||
this.$refs.pagination.makePagination(response.payload.meta, response.payload.links);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="row no-margin">
|
||||
<div class="col b-a " :class="[{'b-grey': !validator.$error}, {'b-danger': validator.$error}]">
|
||||
<div class="row align-items-center b-b b-grey b-dashed">
|
||||
<div class="col p-t-10 p-b-10">
|
||||
<slot name="label"></slot>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto no-padding">
|
||||
<validation-error-component :validator="validator"></validation-error-component>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="fs-12 icon-thumbnail btn-rounded icon-25 m-r-0" :class="[{'bg-master-lightest': !validator.$error}, {'bg-danger': validator.$error}, {'text-white': validator.$error}]" v-show="!files.length">!</div>
|
||||
<div class="bg-success fs-11 text-white icon-thumbnail btn-rounded icon-25 m-r-0" v-show="!!files.length">
|
||||
<i class="fa fa-check fs-11"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-t-15 p-b-15">
|
||||
<div class="row" v-show="!files.length">
|
||||
<div class="col">
|
||||
<slot name="tips"></slot>
|
||||
</div>
|
||||
</div>
|
||||
<file-upload-component v-model="files" :value="value" v-on:input="$emit('input', $event)"></file-upload-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
required: false
|
||||
},
|
||||
validator: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
files: []
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div class="dropzone no-border no-padding text-center" style="min-height: auto;">
|
||||
<div class="dz-message hide"></div>
|
||||
<div class="dragzone row m-l-0 m-r-0 bg-master-lightest" :class="[{'m-b-15': hasFile}]" style="border-width: 1px;">
|
||||
<div class="col">
|
||||
<loading-component style="height: 200px; top: 0;" color="success" v-show="isLoading"></loading-component>
|
||||
<div class="row" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row p-b-20 p-t-15" v-show="!hasFile" style="min-height: 150px;">
|
||||
<div class="col">
|
||||
<div class="row justify-content-center m-b-10 m-t-10">
|
||||
<div class="col-auto">
|
||||
<div class="icon-thumbnail bg-transparent">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
viewBox="0 0 172 172"
|
||||
style=" fill:#000000;"><defs><linearGradient x1="86" y1="79.28125" x2="86" y2="149.85769" gradientUnits="userSpaceOnUse" id="color-1_48264_gr1"><stop offset="0" stop-color="#4ec9ff"></stop><stop offset="1" stop-color="#2bffe6"></stop></linearGradient><linearGradient x1="86" y1="19.48438" x2="86" y2="131.01831" gradientUnits="userSpaceOnUse" id="color-2_48264_gr2"><stop offset="0" stop-color="#009add"></stop><stop offset="1" stop-color="#00baa4"></stop></linearGradient></defs><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g><path d="M104.8125,104.8125l-16.60337,-23.71987c-1.075,-1.53456 -3.34594,-1.53456 -4.41825,0l-16.60338,23.71988h13.4375v40.3125c0,1.4835 1.204,2.6875 2.6875,2.6875h5.375c1.4835,0 2.6875,-1.204 2.6875,-2.6875v-40.3125z" fill="url(#color-1_48264_gr1)"></path><path d="M137.60269,67.97763c1.41362,-3.66575 2.14731,-7.53037 2.14731,-11.54013c0,-17.78319 -14.46681,-32.25 -32.25,-32.25c-13.87287,0 -25.95319,8.82306 -30.41444,21.55912c-0.16394,-0.13437 -0.34937,-0.23919 -0.516,-0.36819c-0.52406,-0.40581 -1.05888,-0.79281 -1.61519,-1.15563c-0.35206,-0.22844 -0.7095,-0.44344 -1.06963,-0.65306c-0.52137,-0.301 -1.05619,-0.57781 -1.60175,-0.84119c-0.31712,-0.15319 -0.62619,-0.3225 -0.95137,-0.45956c-0.8385,-0.36012 -1.70119,-0.66919 -2.58537,-0.93256c-0.29025,-0.086 -0.58588,-0.1505 -0.87881,-0.22575c-0.69875,-0.18006 -1.40825,-0.33325 -2.13119,-0.44881c-0.301,-0.05106 -0.59663,-0.10213 -0.90031,-0.13706c-0.99438,-0.12631 -1.99681,-0.21231 -3.02344,-0.21231c-13.33537,0 -24.1875,10.84944 -24.1875,24.1875v8.0625c-11.85456,0 -21.5,9.64544 -21.5,21.5c0,11.85456 9.64544,21.5 21.5,21.5h2.6875v2.6875c0,4.44512 3.61738,8.0625 8.0625,8.0625h24.1875v-5.375h-24.1875c-1.48081,0 -2.6875,-1.204 -2.6875,-2.6875v-2.6875h26.875v-5.375h-34.9375c-8.89294,0 -16.125,-7.23206 -16.125,-16.125c0,-8.89294 7.23206,-16.125 16.125,-16.125h10.75v-5.375h-5.375v-8.0625c0,-10.37106 8.43875,-18.8125 18.8125,-18.8125c0.7955,0 1.57756,0.06719 2.35156,0.16394c0.23112,0.02956 0.45956,0.06719 0.688,0.1075c0.56975,0.09406 1.12875,0.21231 1.68238,0.35475c0.22037,0.05644 0.44075,0.10481 0.65844,0.16931c0.69338,0.20694 1.37063,0.44881 2.03175,0.73369c0.23381,0.10213 0.45956,0.22306 0.688,0.33325c0.44613,0.215 0.88688,0.44344 1.31419,0.69069c0.26337,0.15319 0.52406,0.30906 0.77669,0.473c0.47569,0.30906 0.93794,0.63963 1.38406,0.99169c0.19081,0.1505 0.38431,0.29831 0.56975,0.45688c0.50525,0.43 0.98631,0.88687 1.44319,1.37063c0.14781,0.15588 0.28756,0.31444 0.43,0.473c0.47837,0.5375 0.93525,1.0965 1.3545,1.69312c0.02419,0.03225 0.04838,0.06181 0.06987,0.09406c0.48375,0.69875 0.92181,1.43781 1.31419,2.21181c1.30612,2.55313 2.05594,5.43413 2.05594,8.49519h5.375c0,-3.913 -0.95406,-7.59756 -2.60956,-10.86825l0.00806,-0.00269c-0.01613,-0.02956 -0.03494,-0.05644 -0.05106,-0.086c-0.4945,-0.96481 -1.04006,-1.89738 -1.6555,-2.78425c-0.05644,-0.08331 -0.12363,-0.15856 -0.18275,-0.24188c-0.05106,-0.06987 -0.10481,-0.13975 -0.15587,-0.20962c2.81919,-12.09106 13.60144,-20.74481 26.14669,-20.74481c14.81888,0 26.875,12.05613 26.875,26.875c0,3.77056 -0.80088,7.3745 -2.29512,10.7715l-8.4495,-0.0215l-0.01344,5.375l8.44144,0.0215c10.1695,0.19888 18.44163,8.62956 18.44163,18.791c0,10.37106 -8.43875,18.8125 -18.8125,18.8125h-32.25v5.375h26.875v2.6875c0,1.4835 -1.20669,2.6875 -2.6875,2.6875h-24.1875v5.375h24.1875c4.44512,0 8.0625,-3.61738 8.0625,-8.0625v-2.6875c13.33538,0 24.1875,-10.84944 24.1875,-24.1875c0,-11.18537 -7.80181,-20.71256 -18.27231,-23.39737z" fill="url(#color-2_48264_gr2)"></path></g></g></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<div class="all-caps fs-12 hint-text" style="letter-spacing: 1px;">Drag and drop files here</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-10 justify-content-center">
|
||||
<div class="col-4">
|
||||
<div class="row align-items-center">
|
||||
<div class="col b-t b-grey"></div>
|
||||
<div class="col-auto all-caps fs-10 hint-text muted">Or</div>
|
||||
<div class="col b-t b-grey"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="btn btn-sm btn-outline-complete b-rad-none pointer select-btn hint-text">Browse files</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-left" v-show="hasFile">
|
||||
<div class="col p-b-15 p-t-15">
|
||||
<div class="all-caps fs-12 hint-text" style="letter-spacing: 1px;">Drag and drop files here</div>
|
||||
</div>
|
||||
<div class="col-2 no-padding">
|
||||
<div class="btn btn-xs btn-primary btn-block b-rad-none pointer select-btn h-100">
|
||||
<div class="row align-items-center h-100">
|
||||
<div class="col">
|
||||
<i class="fa fa-plus"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
isLoading: false,
|
||||
hasFile: false,
|
||||
files: []
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
let vm = this;
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
var dropzone = new Dropzone(this.$el, {
|
||||
url: '#',
|
||||
autoQueue: false,
|
||||
processQueue: false,
|
||||
acceptedFiles: 'image/*, application/pdf',
|
||||
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>'
|
||||
});
|
||||
|
||||
dropzone.on("removedfile", function() {
|
||||
vm.updateFiles(dropzone.files);
|
||||
});
|
||||
|
||||
dropzone.on("addedfile", function(file) {
|
||||
|
||||
vm.isLoading = true;
|
||||
|
||||
if(file.name.split('.').pop() === 'pdf'){
|
||||
$(file.previewElement).find("img[data-dz-thumbnail]").attr("src", "/images/icons/pdf.png");
|
||||
}
|
||||
if(file.name.split('.').pop().indexOf("xls") !== -1){
|
||||
$(file.previewElement).find("img[data-dz-thumbnail]").attr("src", "/images/icons/xlsx.png");
|
||||
}
|
||||
|
||||
Promise.all(dropzone.files.map(function(file){
|
||||
return vm.fileToBase64(file).then(function(data){
|
||||
return data;
|
||||
})
|
||||
})).then(function(files) {
|
||||
vm.isLoading = false;
|
||||
vm.updateFiles(files);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
dropzone.on("dragover", function() {
|
||||
$(vm.$el).find('.dragzone').css('opacity', 0.5)
|
||||
});
|
||||
|
||||
dropzone.on("dragleave", function() {
|
||||
$(vm.$el).find('.dragzone').css('opacity', 1)
|
||||
});
|
||||
|
||||
dropzone.on("drop", function() {
|
||||
$(vm.$el).find('.dragzone').css('opacity', 1)
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
fileToBase64(file) {
|
||||
return new Promise(resolve => {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function(event) {
|
||||
resolve(event.target.result);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
},
|
||||
updateFiles(files){
|
||||
this.hasFile = !!files.length;
|
||||
this.files = files;
|
||||
this.$emit('input', files)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="row p-t-25 text-left">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="b-l b-success p-l-15 m-b-15" style="border-left-width: 3px;">
|
||||
<h6 class="bold all-caps no-margin text-success">Identification Verification</h6>
|
||||
<div class="muted all-caps fs-12">Update your identification document</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.reference">
|
||||
<label class="muted">{{ this.company.type === 0 ? 'IC/Passport Number' : 'Company Registration Number'}}</label>
|
||||
<input class="form-control" name="reference" v-model="parameters.reference">
|
||||
</validation-wrapper-component>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<file-input-component :validator="$v.parameters.files" v-model="parameters.files">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 text-primary all-caps">{{ company.type === 0 ? 'IC Photo' : 'SSM Registration Photo' }}</div>
|
||||
</template>
|
||||
<template slot="tips">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<div class="font-heading fs-11 text-warning m-b-10">{{ company.type === 0 ? 'IC': 'SSM registration'}} number shown in the photo should tally with {{ company.type === 0 ? 'IC': 'SSM registration'}} number provided above.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</file-input-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15 m-t-20">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<button type="button" class="btn btn-outline-dark float-left" @click="closeModal()">Cancel</button>
|
||||
<button type="button" class="btn btn-success" @click="submitForm()">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { required, minLength } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props: {
|
||||
company: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
section:{
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'company': function() {
|
||||
this.parameters.company_id = this.company.id;
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
parameters : {
|
||||
company_id: this.company.id,
|
||||
files: [],
|
||||
reference: ''
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
files: {
|
||||
required,
|
||||
minLength: minLength(1)
|
||||
},
|
||||
reference: { required }
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
submitForm(){
|
||||
this.submit((this.route('api.company.document.identification.update', this.company.id)), 'post', 'identification.form', true, true)
|
||||
},
|
||||
successHandler(){
|
||||
this.crudSuccess();
|
||||
EventBus.$emit('updateDocument')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="col">
|
||||
<h5 class="all-caps bold hint-text">{{company.name}}</h5>
|
||||
</div>
|
||||
<div class="col-auto d-none d-md-block">
|
||||
<div class="col-auto d-none d-md-block hide">
|
||||
<i class="fa fa-ellipsis-h muted bg-white p-t-10 p-b-10 p-r-15 p-l-15 b-a b-grey"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,12 +29,12 @@
|
||||
<div class="col-auto bg-white p-t-10 p-b-10 b-a b-grey">
|
||||
<div class="row align-items-center justify-content-center">
|
||||
<div class="col-auto p-r-10">
|
||||
<div class="btn-rounded bg-warning-lighter" style="padding: 3px;">
|
||||
<div class="btn-rounded bg-warning" style="width: 8px; height: 8px;"></div>
|
||||
<div class="btn-rounded" :class="[{'bg-success': company.status === 2}, {'bg-warning-lighter': company.status !== 2}]" style="padding: 3px;">
|
||||
<div class="btn-rounded " :class="[{'bg-success': company.status === 2}, {'bg-warning': company.status !== 2}]" style="width: 8px; height: 8px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0">
|
||||
<small class="all-caps hint-text text-warning">{{company.status}}</small>
|
||||
<small class="all-caps hint-text text-warning">{{company.status === 2 ? 'Active' : 'Pending Verification'}}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +77,7 @@
|
||||
</template>
|
||||
</modal-form-component>
|
||||
</div>
|
||||
<div class="row m-b-25 d-none d-md-block">
|
||||
<div class="row m-b-25 d-none d-md-block" v-if="!company.delivery_address || company.status === 0 || company.total_orders === 0">
|
||||
<div class="col">
|
||||
<onboarding-section-component :data="company"></onboarding-section-component>
|
||||
</div>
|
||||
@@ -85,9 +85,9 @@
|
||||
<div class="row tabsContainer" >
|
||||
<div class="col">
|
||||
<div class="row m-b-20 m-l-0 m-r-0 d-none d-md-flex">
|
||||
<div class="col">
|
||||
<div class="col-4">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col padding-25 bg-master-lighter active b-r tabButton" tab-name="orders" style=" border-color: #d2d2d2; ">
|
||||
<div class="col padding-25 bg-master-lighter active tabButton" tab-name="orders" style=" border-color: #d2d2d2; ">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -104,7 +104,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col pointer">
|
||||
<div class="col pointer hide">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col padding-25 bg-master-lighter b-r tabButton" tab-name="billing" style=" border-color: #d2d2d2; ">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
@@ -123,9 +123,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col pointer">
|
||||
<div class="col-4 pointer">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col padding-25 bg-master-lighter b-r tabButton" tab-name="settings" style=" border-color: #d2d2d2; ">
|
||||
<div class="col padding-25 bg-master-lighter tabButton" tab-name="settings" style=" border-color: #d2d2d2; ">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
<div class="col-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
|
||||
@@ -142,7 +142,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col pointer">
|
||||
<div class="col pointer hide">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col padding-25 bg-master-lighter tabButton" tab-name="settings">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
@@ -165,7 +165,7 @@
|
||||
<div class="row m-l-0 m-r-0 tabContent" tab-name="orders">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col-auto d-none d-md-block">
|
||||
<div class="col-auto d-none d-md-block hide">
|
||||
<div class="row fs-12 text-center">
|
||||
<div class="col padding-25 bg-white">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
@@ -271,7 +271,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row no-margin tabsContainer tabContent hide" tab-name="settings">
|
||||
<div class="col-auto">
|
||||
<div class="col-auto hide">
|
||||
<div class="row fs-12 text-center b-b" style=" border-color: #d2d2d2; ">
|
||||
<div class="col padding-25 bg-master-lighter active tabButton" tab-name="address-book">
|
||||
<div class="row justify-content-center m-b-10">
|
||||
@@ -372,46 +372,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="addressSection" :endpoint="route('api.address.list')">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<address-component :data="data"></address-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row tabContent hide" tab-name="contacts">
|
||||
<div class="col">
|
||||
<div class="row m-t-20 m-b-20">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h6 class="all-caps bold hint-text no-margin">Contacts</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row fs-13">
|
||||
<div class="col">
|
||||
<small class="muted all-caps">Here you manage all your business contacts</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="row m-b-15 parentContainer">
|
||||
<div class="col">
|
||||
<div class="btn btn-xs btn-success btn-block all-caps b-rad-none p-t-10 p-b-10 requestModal" data-type="createModal">Create New Address</div>
|
||||
<modal-form-component section="addressSection">
|
||||
<template slot="form" slot-scope="{section}">
|
||||
<address-form-component :section="section" :id="id"></address-form-component>
|
||||
</template>
|
||||
</modal-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="addressSection" :endpoint="route('api.address.list')">
|
||||
<list-component key="2" section="addressSection" :endpoint="route('api.address.list')" :options="{'company_id': id}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<address-component :data="data"></address-component>
|
||||
</template>
|
||||
@@ -428,7 +389,7 @@
|
||||
<div class="col-3 d-none d-md-block p-t-20 p-b-20">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="row m-b-20 hide">
|
||||
<div class="col no-padding">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-r-0"><i class="fa fa-life-ring"></i></div>
|
||||
@@ -452,7 +413,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-25">
|
||||
<div class="row m-b-25 m-t-50" v-if="company.total_orders > 0">
|
||||
<div class="col no-padding parentContainer">
|
||||
<div class="btn btn-lg btn-primary b-rad-none text-left p-t-10 p-b-10 pointer requestModal" data-type="createModal" ref="placeOrder">
|
||||
<div class="row align-items-center">
|
||||
@@ -484,7 +445,7 @@
|
||||
</modal-form-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-15">
|
||||
<div class="row m-b-15 hide">
|
||||
<div class="col bg-white">
|
||||
<div class="row fs-10 p-t-10 p-b-10 b-b b-grey">
|
||||
<div class="col">
|
||||
@@ -544,7 +505,7 @@
|
||||
<div class="col">
|
||||
<small class="bold">Default Delivery Addresses</small>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="col-auto hide">
|
||||
<i class="fa fa-ellipsis-h muted"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -553,7 +514,7 @@
|
||||
<small class="fs-10 bold muted">{{company.delivery_address.street_one}} {{company.delivery_address.street_two}} {{company.delivery_address.city}} {{company.delivery_address.state}} {{company.delivery_address.post_code}} {{company.delivery_address.country}}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row hide">
|
||||
<div class="col no-padding">
|
||||
<div class="pointer text-center bg-master-lighter b-rad-none p-t-10 p-b-10">
|
||||
<small class="fs-10 all-caps">Manage Addresses</small>
|
||||
@@ -669,10 +630,16 @@
|
||||
EventBus.$on('updateAddress', () => {
|
||||
this.fetchProfile();
|
||||
});
|
||||
EventBus.$on('updateDocument', () => {
|
||||
this.fetchProfile();
|
||||
});
|
||||
EventBus.$on('placeOrder', () => {
|
||||
this.$refs.placeOrder.click()
|
||||
});
|
||||
EventBus.$on('newOrder', (orderId) => {
|
||||
if(this.company.total_orders === 0){
|
||||
this.fetchProfile();
|
||||
}
|
||||
this.newOrderId = orderId;
|
||||
$(this.$el).find('.modalContainer[data-type="notification"]').modal('show')
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
|
||||
<div class="row no-margin align-items-center justify-content-center p-t-10 p-b-10">
|
||||
<div class="col">
|
||||
<div class="row no-margin align-items-center justify-content-center">
|
||||
<div class="col-auto no-padding all-caps">
|
||||
<div class="col no-padding all-caps">
|
||||
<div class="row">
|
||||
<div class="col fs-10">
|
||||
<span class="bold">#{{order.marking}}</span>
|
||||
@@ -21,7 +21,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-right p-r-0 all-caps">
|
||||
<div class="col text-right p-r-0 all-caps hide">
|
||||
<div class="row">
|
||||
<div class="col fs-10">
|
||||
<span class="bold text-danger">pending supplier</span>
|
||||
|
||||
+2
-10
@@ -7,9 +7,8 @@ export default {
|
||||
|
||||
},
|
||||
resetForm(){
|
||||
if(!this.data) {
|
||||
Object.assign(this.$data, this.$options.data.call(this));
|
||||
}
|
||||
if(this.$v){ this.$v.$reset() }
|
||||
if(!this.data) { Object.assign(this.$data, this.$options.data.call(this)) }
|
||||
},
|
||||
updateFilters(){
|
||||
if(this.$store.getters.isInQueue(this.section)){
|
||||
@@ -29,14 +28,7 @@ export default {
|
||||
this.$store.dispatch('reloadList', {'name': this.section});
|
||||
},
|
||||
closeModal(){
|
||||
|
||||
if(this.$v){
|
||||
this.$v.$reset();
|
||||
}
|
||||
|
||||
$(this.$el).parents('.modal').modal('hide');
|
||||
|
||||
this.resetForm();
|
||||
},
|
||||
setDecoratorDefault(){
|
||||
this.filters.per_page = this.filters.per_page !== undefined ? this.filters.per_page : 10;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Omair Saleh
|
||||
* Date: 4/3/2021
|
||||
* Time: 4:36 AM
|
||||
*/
|
||||
@@ -1,24 +1,19 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>order-qr-{{$order->order_number}}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: SimHei;
|
||||
src: url('{{base_path().'/public/'}}simhei.ttf') format('truetype');
|
||||
}
|
||||
* {
|
||||
font-family: SimHei, serif ;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'HanWangYenHeavy';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(http://eclecticgeek.com/dompdf/fonts/cjk/fireflysung.ttf) format('truetype');
|
||||
}
|
||||
@page { margin: 0px; }
|
||||
body { margin: 0px; }
|
||||
body {
|
||||
font-family: Firefly Sung, DejaVu Sans, sans-serif;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.page-break {
|
||||
page-break-after: always;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<table style="width: 100%; border: 2px solid #000000;">
|
||||
|
||||
@@ -10,9 +10,17 @@
|
||||
<img src="{{asset('images/logo.png')}}" alt="logo" height="22">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col h-100">
|
||||
<div class="dropdown pull-right h-100 bg-primary">
|
||||
<div class="col-auto ml-auto h-100 p-r-30">
|
||||
<a href="{{route('login')}}">
|
||||
<div class="row h-100 bg-primary align-items-center">
|
||||
<div class="col">
|
||||
<i class="fa fa-power-off fs-14 text-white"></i>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<div class="dropdown pull-right h-100 bg-primary hide">
|
||||
<button class="profile-dropdown-toggle h-100 p-r-10 p-l-10 pointer" type="button" data-toggle="dropdown" aria-expanded="false">
|
||||
<i class="fa fa-bell fs-14 text-white"></i>
|
||||
<user-avatar class="bg-primary-dark" username="Omair Saleh" :size="32" color="#ffffff"></user-avatar>
|
||||
</button>
|
||||
{{--<div class="dropdown-menu dropdown-menu-right no-padding" role="menu" x-placement="bottom-end" style="width: 300px;">--}}
|
||||
@@ -53,7 +61,7 @@
|
||||
{{--</div>--}}
|
||||
{{--</div>--}}
|
||||
</div>
|
||||
<div class="dropdown pull-right h-100 bg-master-darker">
|
||||
<div class="dropdown pull-right h-100 bg-master-darker hide">
|
||||
<button class="profile-dropdown-toggle h-100 p-r-15 p-l-15 pointer" type="button" data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="bg-master-darkest btn-rounded relative" style="padding: 5px 7px;">
|
||||
<i class="fa fa-bell fs-14 text-white"></i>
|
||||
|
||||
@@ -13,6 +13,8 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
|
||||
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
|
||||
|
||||
Route::post('/{id}/document/identification/update', 'UpdateCompanyIdentificationDocumentController@update')->name('document.identification.update');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'address', 'as' => 'address.', 'namespace' => 'Addresses'], function () {
|
||||
@@ -23,6 +25,8 @@ Route::group(['prefix' => 'address', 'as' => 'address.', 'namespace' => 'Address
|
||||
|
||||
Route::post('/create', 'CreateAddressController@create')->name('create');
|
||||
|
||||
Route::post('/default/{id}', 'SetAddressDefaultController@set')->name('default');
|
||||
|
||||
Route::put('/update/{id}', 'UpdateAddressController@update')->name('update');
|
||||
|
||||
Route::delete('/delete/{id}', 'DeleteAddressController@destroy')->name('delete');
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['prefix' => 'document', 'as' => 'document.', 'namespace' => 'Documents'], function () {
|
||||
Route::get('/list', 'ListDocumentsController@list')->name('list');
|
||||
Route::put('/approve/{id}', 'ApproveDocumentController@approve')->name('approve');
|
||||
});
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user