Merge branch 'admin_customer_profile' into 'master'

Admin customer profile

See merge request CIEFWorldwideSdnBhd/exchange-2.0!47
This commit is contained in:
omair saleh
2021-05-31 08:42:01 +00:00
8 changed files with 239 additions and 39 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\General\Eloquent\Filters;
use Illuminate\Database\Eloquent\Builder;
class IssuerIn implements Filter
{
/**
* @param Builder $builder
* @param $value
* @return Builder|mixed
*/
public static function apply(Builder $builder, $value)
{
return $builder->whereIn('issuer', $value);
}
}
@@ -6,6 +6,7 @@ namespace App\Classes\Modules\Addresses\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Addresses\Services\UpdatesAddress;
use App\Classes\Modules\Addresses\Services\FetchesAddress;
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress;
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
use App\Http\Resources\AddressResource;
@@ -35,17 +36,22 @@ class UpdateAddressLogic extends AbstractControllerLogic
/** @var FetchesAddress */
private $fetchesAddress;
/** @var FetchesDistrict */
private $fetchesDistrict;
/**
* UpdateAddressLogic constructor.
* @param CanUpdateAddress $canUpdateAddress
* @param UpdatesAddress $updatesAddress
* @param FetchesAddress $fetchesAddress
* @param FetchesDistrict $fetchesDistrict
*/
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress)
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict)
{
$this->canUpdateAddress = $canUpdateAddress;
$this->updatesAddress = $updatesAddress;
$this->fetchesAddress = $fetchesAddress;
$this->fetchesDistrict = $fetchesDistrict;
}
@@ -58,7 +64,9 @@ class UpdateAddressLogic extends AbstractControllerLogic
{
try {
$object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
//$object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
$this->canUpdateAddress->passes($object);
@@ -17,15 +17,15 @@ class UpdatesAddress extends AbstractUpdateRecord
*/
public function execute(Address $model, AddressObject $object) {
$model->company_id = $object->getCompanyId();
//$model->company_id = $object->getCompanyId();
$model->street_one = $object->getStreetOne();
$model->street_two = $object->getStreetTwo();
$model->city = $object->getCity();
$model->state = $object->getState();
$model->post_code = $object->getPostCode();
$model->country = $object->getCountry();
$model->default = $object->getDefault();
$model->billing = $object->getBilling();
$model->district_id = $object->getDistrictId();
$model->state_id = $object->getStateId();
$model->postcode = $object->getPostCode();
$model->country_id = $object->getCountryId();
//$model->default = $object->getDefault();
//$model->billing = $object->getBilling();
return $this->handler($model);
@@ -12,7 +12,7 @@
<div class="col">
<div class="row">
<div class="col">
<span class="fs-10 muted">{{address.street_one}} {{address.street_two}} {{address.city}} {{address.state}} {{address.post_code}} {{address.country}}</span>
<span class="fs-10 muted">{{address.street_one}} {{address.street_two}} {{address.city}} {{address.state.name}} {{address.post_code}} {{address.country.name}}</span>
</div>
</div>
</div>
@@ -20,7 +20,7 @@
<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">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest m-r-5 ml-auto" @click="deleteAddress(address.id)">
<a class="requestModal pointer" data-type="delete">
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
<div class="col">
@@ -29,7 +29,7 @@
</div>
</a>
</div>
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest">
<div class="col-auto text-right p-t-10 p-b-10 bg-master-lightest" @click="updateAddress(address.id)">
<a class="pointer">
<div data-toggle="tooltip" title="" data-placement="bottom" class="row link align-items-center justify-content-center" data-original-title="Delete">
<div class="col">
@@ -45,29 +45,33 @@
</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="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="row align-items-center" :class="[{'requestModal': !address.billing}, {'pointer': !address.billing}, {'link': !address.billing}]" data-type="setDefault" @click="!address.billing ? setDefaultAddress() : null">
<div class="col-auto text-right p-t-5 p-b-5" :class="[{'bg-warning-lighter': address.billing}, {'bg-master-light': !address.billing}]">
<div data-toggle="tooltip" class="row align-items-center justify-content-center" :class="{'link': !address.billing}">
<div class="col">
<i class="fa fa-star" :class="[{'text-warning': address.default}, {'text-master': !address.default}]"></i>
<i class="fa fa-star" :class="[{'text-warning': address.billing}, {'text-master': !address.billing}]"></i>
</div>
</div>
</div>
<div class="col bg-white p-t-5 p-b-5">
<small class="fs-12 all-caps bold" :class="[{'text-warning': address.default}, {'text-master': !address.default}]">Default Address</small>
<small class="fs-12 all-caps bold" :class="[{'text-warning': address.billing}, {'text-master': !address.billing}]">Default Address</small>
</div>
</div>
</div>
</div>
</template>
<script>
import FormHandler from '../../../general/mixins/formHandler';
export default {
props: {
'data': {
type: Object,
required: true
}
},
},
data() {
return {
@@ -79,6 +83,20 @@
this.address = this.data;
}
},
methods: {
setDefaultAddress(){
this.submit(route('api.address.default',this.address.id), 'put', this.section, true, true);
},
updateAddress(id){
this.$root.$emit('updateAddressForm', this.address, true);
},
deleteAddress(id){
this.$root.$emit('deleteAddressConfirm', id);
},
successHandler(){
this.$store.dispatch('reloadList', {'name': "addresslist"});
}
},
mixins: [FormHandler]
}
</script>
@@ -0,0 +1,54 @@
<template>
<div class="row m-b-10 parentContainer">
<div class="col">
<div class="row align-items-center">
<div class="col p-t-5 p-b-5">
<div class="col text-center">
<div class="row m-b-20">
<div class="col">
<h5 class="all-caps">Delete address</h5>
<div class="fs-11">Are you sure you want to delete? This action is undoable.</div>
</div>
</div>
<div class="row">
<div class="col p-r-5">
<div data-dismiss="modal" class="btn btn-sm btn-default bg-master-lighter btn-block b-rad-none">Cancel</div>
</div>
<div class="col p-l-5">
<div data-dismiss="modal" class="btn btn-sm btn-success btn-block b-rad-none" @click="deleteAddress()">Delete</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import componentHandler from '../../../general/mixins/componentHandler';
import staticFormHandler from '../../../general/mixins/staticFormHandler'
export default {
props: {
'address_id' : {
type: Number,
required:true,
},
},
data(){
return {
parameters:null,
isLoading: false,
}
},
methods: {
deleteAddress(){
this.submit(route('api.address.delete',this.address_id), 'delete', this.section, true, true);
},
successHandler(){
this.$store.dispatch('reloadList', {'name': "addresslist"});
},
},
mixins: [componentHandler, staticFormHandler]
}
</script>
@@ -39,7 +39,8 @@
<div class="col">
<div class="row">
<div class="col text-right">
<button type="button" class="btn btn-sm btn-success b-rad-none" @click="submitForm()">Create Billing Address</button>
<button type="button" class="btn btn-sm btn-success b-rad-none" @click="submitForm()">{{(this.type==3)?"Update":"Create"}} Billing Address</button>
<button v-show="this.type==3" type="button" class="btn btn-sm bg-master-lighter b-rad-none m-l-5" @click="closeForm()">Cancel</button>
</div>
</div>
</div>
@@ -56,20 +57,36 @@
required: true
},
type: {
//Npte: type 1 = create, type 2 = update set default, type 3 = update address
type: Number,
default: 1
},
addressData: {
type: Object,
default: {},
required:false
},
},
watch: {
'id': function() {
this.parameters.company_id = this.id;
},
'addressData': function() {
this.resetForm();
this.parameters = {
company_id: this.id,
street_one: this.addressData.street_one,
street_two: this.addressData.street_two,
district_id: this.addressData.district.id,
post_code: this.addressData.post_code,
}
}
},
data() {
return {
parameters : {
company_id: this.id,
street_one: '',
street_one: '',
street_two: '',
district_id: '',
post_code: '',
@@ -87,11 +104,23 @@
},
methods:{
submitForm(){
this.submit((this.route('api.address.create')), 'post', 'bookingDetailSection', true, true)
if(this.type==3){
this.submit((this.route('api.address.update',this.addressData.id)), 'put', 'bookingDetailSection', true, true)
}else {
this.submit((this.route('api.address.create')), 'post', 'bookingDetailSection', true, true)
}
},
closeForm(){
this.$root.$emit('updateAddressForm', {}, false);
},
successHandler(response){
this.type !== 2 ? this.$emit('updateDefaultAddress', response.payload.data) : this.$emit('createdAddress', response.payload.data);
this.resetForm();
if(this.type==3){
this.closeForm();
this.$store.dispatch('reloadList', {'name': "addresslist"});
}else {
this.type !== 2 ? this.$emit('updateDefaultAddress', response.payload.data) : this.$emit('createdAddress', response.payload.data);
this.resetForm();
}
}
}
}
@@ -1,13 +1,6 @@
<template>
<div class="row align-items-center m-b-10 parentContainer">
<div class="container p-0 m-0" @click="backToCompanyList()">
<i class="fa fa-arrow-left fs-11 align-middle"></i>
<span class="fs-11 m-0 align-middle pl-2 text-uppercase">Back to list</span>
</div>
<div class="row w-100 m-0 p-0">
<div class="col-auto p-0 pt-2 m-b-10" :style="minWidth">
<div class="h5 m-0">{{this.company_details.name ? this.company_details.name : ""}}</div>
</div>
<div class="col-12 p-0">
<label class="muted" :style="minWidth">Reference</label>
<label>{{this.company_details.reference ? this.company_details.reference : ""}}</label>
@@ -24,6 +17,23 @@
<label class="muted" :style="minWidth">&nbsp;</label>
<label><i class="fa fa-phone text-primary fs-10"></i>&nbsp;{{this.company_details.contact ? this.company_details.contact.phone : ""}}</label>
</div>
<div class="col-12 p-0" v-if="this.company_details.identification && this.company_details.identification.document_type">
<label class="muted pull-left" :style="minWidth">Identification</label>
<div class="col-4 pull-left p-l-0 p-b-5">
<label>{{ this.company_details.identification.document_type === 'IDENTITY_CARD' ? 'IC' : 'SSM Registration' }}</label>
<div class="row no-margin">
<div v-for="file in this.company_details.identification.files" v-bind:key="file.id" class="col-auto no-padding m-r-5">
<document-file-viewer-component :file="file">
<template slot="button">
<div class="icon-thumbnail fs-11 text-white icon-25 bg-primary btn-rounded float-left m-r-5">
<i class="fa fa-file-image-o fs-10"></i>
</div>
</template>
</document-file-viewer-component>
</div>
</div>
</div>
</div>
<div class="col-12 p-0">
<label class="muted" :style="minWidth">Total Booking</label>
<label>{{this.company_details.bookings ? this.company_details.bookings.length : ""}}</label>
@@ -58,6 +68,9 @@
},
watch: {
company_details: function(newVal, oldVal) {
this.company_details=newVal;
console.log(newVal);
console.log('hellp');
if(newVal !== null) {
let approved = 0, completed = 0, rejected = 0, expired = 0, pending = 0;
@@ -55,7 +55,7 @@
</div>
<div class="col">
<div class="row fs-12 text-center">
<div class="col p-t-15 p-b-15 bg-master-lighter tabButton" tab-name="transfers">
<div class="col p-t-15 p-b-15 bg-master-lighter tabButton" tab-name="credit">
<div class="row justify-content-center">
<div class="col-auto">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
@@ -78,7 +78,7 @@
<div class="row justify-content-end">
<div class="col-6">
<div class="row fs-12 text-center">
<div class="col p-t-15 p-b-15 bg-master-lighter tabButton" tab-name="transfers">
<div class="col p-t-15 p-b-15 bg-master-lighter tabButton" tab-name="profile" @click="refreshCompanyDetails()">
<div class="row justify-content-center">
<div class="col-auto">
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
@@ -139,12 +139,49 @@
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<list-component key="2" section="purchaseOrderSection" :endpoint="route('api.address.list')">
<div class="col" v-show="!displayAddressForm">
<list-component key="2" section="addresslist" :endpoint="route('api.address.list')" :options="{'company_id':this.id}">
<template slot="list" slot-scope="{data}">
<address-component :data="data"></address-component>
<address-component :data="data" section="addressListItem"></address-component>
</template>
</list-component>
<modal-component id="deleteAddressModal">
<address-modal-component section="deleteAddressModal" :address_id="this.address_id"></address-modal-component>
</modal-component>
</div>
<div class="col" v-show="this.displayAddressForm">
<div>Address form</div>
<address-form-component :id="parseInt(this.id)" :type="3" :addressData="this.address"></address-form-component>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row tabsContainer hide tabContent" tab-name="credit">
<div class="col">
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<list-component key="2" section="paymentVerificationSection" :endpoint="route('api.transaction.list')" :options="{'type': 1, 'status': 3,'issuer_in':[this.id]}">
<template slot="list" slot-scope="{data}">
<payment-verification-component section="paymentVerificationSection" :data="data" :no_action="true"></payment-verification-component>
</template>
</list-component>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row tabsContainer hide tabContent" tab-name="profile">
<div class="col">
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<company-details-component :company_details="company_details" section="customerProfileSection"></company-details-component>
</div>
</div>
</div>
@@ -170,7 +207,7 @@
export default {
props: {
id: {
type: Number,
type: String,
required: true
}
},
@@ -178,6 +215,7 @@
return {
section: 'customerProfileSection',
company: null,
company_details: {},
bookingFilters: {
reference: '',
type: 0,
@@ -185,7 +223,10 @@
created_before: '',
created_after: '',
status: ''
}
},
address_id:0,
address:{},
displayAddressForm:false,
}
},
computed: {
@@ -202,17 +243,34 @@
})
}
},
mounted(){
this.$root.$on('deleteAddressConfirm', (id) => {
this.address_id=id;
$("#deleteAddressModal").closest('.modal').modal('show');
});
this.$root.$on('updateAddressForm', (address, show) => {
if(show) {
this.address = address;
this.displayAddressForm = true;
}else{
this.displayAddressForm = false;
}
});
},
watch: {
pendingQueue(inComplete){
if(inComplete){
this.fetchCompany();
}
}
},
},
created(){
this.$store.dispatch('updateListQueue', {'name': this.section});
},
methods: {
refreshCompanyDetails(){
this.company_details = this.company ;
},
fetchCompany(){
this.submit(route('api.company.show', this.id), 'get', this.section, false, false)
},