Merge pull request #1480 from cuneytsenturk/master
Invoice/Bill add payment change method..
This commit is contained in:
		@@ -67,6 +67,19 @@ class BillTransactions extends Controller
 | 
				
			|||||||
            'error' => false,
 | 
					            'error' => false,
 | 
				
			||||||
            'message' => 'null',
 | 
					            'message' => 'null',
 | 
				
			||||||
            'html' => $html,
 | 
					            'html' => $html,
 | 
				
			||||||
 | 
					            'data' => [
 | 
				
			||||||
 | 
					                'title' => trans('general.title.new', ['type' => trans_choice('general.payments', 1)]),
 | 
				
			||||||
 | 
					                'buttons' => [
 | 
				
			||||||
 | 
					                    'cancel' => [
 | 
				
			||||||
 | 
					                        'text' => trans('general.cancel'),
 | 
				
			||||||
 | 
					                        'class' => 'btn-outline-secondary'
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    'confirm' => [
 | 
				
			||||||
 | 
					                        'text' => trans('general.save'),
 | 
				
			||||||
 | 
					                        'class' => 'btn-success'
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
 | 
					                ]
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,6 +67,24 @@ class InvoiceTransactions extends Controller
 | 
				
			|||||||
            'error' => false,
 | 
					            'error' => false,
 | 
				
			||||||
            'message' => 'null',
 | 
					            'message' => 'null',
 | 
				
			||||||
            'html' => $html,
 | 
					            'html' => $html,
 | 
				
			||||||
 | 
					            'data' => [
 | 
				
			||||||
 | 
					                'title' => trans('general.title.new', ['type' => trans_choice('general.payments', 1)]),
 | 
				
			||||||
 | 
					                'buttons' => [
 | 
				
			||||||
 | 
					                    'cancel' => [
 | 
				
			||||||
 | 
					                        'text' => trans('general.cancel'),
 | 
				
			||||||
 | 
					                        'class' => 'btn-outline-secondary'
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    'payment' => [
 | 
				
			||||||
 | 
					                        'text' => trans('invoices.accept_payments'),
 | 
				
			||||||
 | 
					                        'class' => 'long-texts',
 | 
				
			||||||
 | 
					                        'url' => route('apps.categories.show', 'payment-method')
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    'confirm' => [
 | 
				
			||||||
 | 
					                        'text' => trans('general.save'),
 | 
				
			||||||
 | 
					                        'class' => 'btn-success'
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
 | 
					                ]
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,10 @@
 | 
				
			|||||||
                                        {{ buttons.cancel.text }}
 | 
					                                        {{ buttons.cancel.text }}
 | 
				
			||||||
                                    </button>
 | 
					                                    </button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    <a v-if="buttons.payment" :href="buttons.payment.url" class="btn btn-white" :class="buttons.payment.class">
 | 
				
			||||||
 | 
					                                        {{ buttons.payment.text }}
 | 
				
			||||||
 | 
					                                    </a>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    <button  :disabled="form.loading" type="button" class="btn button-submit" :class="buttons.confirm.class" @click="onSubmit">
 | 
					                                    <button  :disabled="form.loading" type="button" class="btn button-submit" :class="buttons.confirm.class" @click="onSubmit">
 | 
				
			||||||
                                        <div class="aka-loader"></div><span>{{ buttons.confirm.text }}</span>
 | 
					                                        <div class="aka-loader"></div><span>{{ buttons.confirm.text }}</span>
 | 
				
			||||||
                                    </button>
 | 
					                                    </button>
 | 
				
			||||||
@@ -217,7 +221,24 @@ export default {
 | 
				
			|||||||
                            })
 | 
					                            })
 | 
				
			||||||
                            .catch(error => {
 | 
					                            .catch(error => {
 | 
				
			||||||
                            });
 | 
					                            });
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        // Change bank account get money and currency rate
 | 
				
			||||||
 | 
					                        async onChangePaymentAccount(account_id) {
 | 
				
			||||||
 | 
					                            let payment_account = Promise.resolve(window.axios.get(url + '/banking/accounts/currency', {
 | 
				
			||||||
 | 
					                                params: {
 | 
				
			||||||
 | 
					                                    account_id: account_id
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					                            }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            payment_account.then(response => {
 | 
				
			||||||
 | 
					                                this.form.currency = response.data.currency_name;
 | 
				
			||||||
 | 
					                                this.form.currency_code = response.data.currency_code;
 | 
				
			||||||
 | 
					                                this.form.currency_rate = response.data.currency_rate;
 | 
				
			||||||
 | 
					                            })
 | 
				
			||||||
 | 
					                            .catch(error => {
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        },
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										141
									
								
								resources/assets/js/views/purchases/bills.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										141
									
								
								resources/assets/js/views/purchases/bills.js
									
									
									
									
										vendored
									
									
								
							@@ -38,15 +38,6 @@ const app = new Vue({
 | 
				
			|||||||
                tax: 0,
 | 
					                tax: 0,
 | 
				
			||||||
                total: 0
 | 
					                total: 0
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            transaction_form: new Form('transaction'),
 | 
					 | 
				
			||||||
            payment: {
 | 
					 | 
				
			||||||
                modal: false,
 | 
					 | 
				
			||||||
                amount: 0,
 | 
					 | 
				
			||||||
                title: '',
 | 
					 | 
				
			||||||
                message: '',
 | 
					 | 
				
			||||||
                html: '',
 | 
					 | 
				
			||||||
                errors: new Error()
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            transaction: [],
 | 
					            transaction: [],
 | 
				
			||||||
            items: '',
 | 
					            items: '',
 | 
				
			||||||
            discount: false,
 | 
					            discount: false,
 | 
				
			||||||
@@ -60,7 +51,9 @@ const app = new Vue({
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
 | 
					        if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
 | 
				
			||||||
            this.colspan = document.getElementById("items").rows[0].cells.length - 1;
 | 
					            this.colspan = document.getElementById("items").rows[0].cells.length - 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.form.items = [];
 | 
					        this.form.items = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.form.method) {
 | 
					        if (this.form.method) {
 | 
				
			||||||
@@ -322,51 +315,113 @@ const app = new Vue({
 | 
				
			|||||||
            this.onCalculateTotal();
 | 
					            this.onCalculateTotal();
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onPayment() {
 | 
					        async onPayment() {
 | 
				
			||||||
            this.payment.modal = true;
 | 
					            let bill_id = document.getElementById('bill_id').value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let form = this.transaction_form;
 | 
					            let payment = {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.transaction_form = new Form('transaction');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.transaction_form.paid_at = form.paid_at;
 | 
					 | 
				
			||||||
            this.transaction_form.account_id = form.account_id;
 | 
					 | 
				
			||||||
            this.transaction_form.payment_method = form.payment_method;
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        addPayment() {
 | 
					 | 
				
			||||||
            this.transaction_form.submit();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.payment.errors = this.transaction_form.errors;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.form.loading = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.$emit("confirm");
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        closePayment() {
 | 
					 | 
				
			||||||
            this.payment = {
 | 
					 | 
				
			||||||
                modal: false,
 | 
					                modal: false,
 | 
				
			||||||
                amount: 0,
 | 
					                url: url + '/modals/bills/' + bill_id + '/transactions/create',
 | 
				
			||||||
                title: '',
 | 
					                title: '',
 | 
				
			||||||
                message: '',
 | 
					                html: '',
 | 
				
			||||||
                errors: this.transaction_form.errors
 | 
					                buttons:{}
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            let payment_promise = Promise.resolve(window.axios.get(payment.url));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            payment_promise.then(response => {
 | 
				
			||||||
 | 
					                payment.modal = true;
 | 
				
			||||||
 | 
					                payment.title = response.data.data.title;
 | 
				
			||||||
 | 
					                payment.html = response.data.html;
 | 
				
			||||||
 | 
					                payment.buttons = response.data.data.buttons;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                this.component = Vue.component('add-new-component', (resolve, reject) => {
 | 
				
			||||||
 | 
					                    resolve({
 | 
				
			||||||
 | 
					                        template: '<div id="dynamic-component"><akaunting-modal-add-new :show="payment.modal" @submit="onSubmit" @cancel="onCancel" :buttons="payment.buttons" :title="payment.title" :is_component=true :message="payment.html"></akaunting-modal-add-new></div>',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        mixins: [
 | 
				
			||||||
 | 
					                            Global
 | 
				
			||||||
 | 
					                        ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        data: function () {
 | 
				
			||||||
 | 
					                            return {
 | 
				
			||||||
 | 
					                                form:{},
 | 
				
			||||||
 | 
					                                payment: payment,
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Change bank account get money and currency rate
 | 
					                        methods: {
 | 
				
			||||||
        onChangePaymentAccount(account_id) {
 | 
					                            onSubmit(event) {
 | 
				
			||||||
            axios.get(url + '/banking/accounts/currency', {
 | 
					                                this.form = event;
 | 
				
			||||||
                params: {
 | 
					
 | 
				
			||||||
                    account_id: account_id
 | 
					                                this.loading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let data = this.form.data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                FormData.prototype.appendRecursive = function(data, wrapper = null) {
 | 
				
			||||||
 | 
					                                    for(var name in data) {
 | 
				
			||||||
 | 
					                                        if (wrapper) {
 | 
				
			||||||
 | 
					                                            if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
 | 
				
			||||||
 | 
					                                                this.appendRecursive(data[name], wrapper + '[' + name + ']');
 | 
				
			||||||
 | 
					                                            } else {
 | 
				
			||||||
 | 
					                                                this.append(wrapper + '[' + name + ']', data[name]);
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        } else {
 | 
				
			||||||
 | 
					                                            if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
 | 
				
			||||||
 | 
					                                                this.appendRecursive(data[name], name);
 | 
				
			||||||
 | 
					                                            } else {
 | 
				
			||||||
 | 
					                                                this.append(name, data[name]);
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let form_data = new FormData();
 | 
				
			||||||
 | 
					                                form_data.appendRecursive(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                window.axios({
 | 
				
			||||||
 | 
					                                    method: this.form.method,
 | 
				
			||||||
 | 
					                                    url: this.form.action,
 | 
				
			||||||
 | 
					                                    data: form_data,
 | 
				
			||||||
 | 
					                                    headers: {
 | 
				
			||||||
 | 
					                                        'X-CSRF-TOKEN': window.Laravel.csrfToken,
 | 
				
			||||||
 | 
					                                        'X-Requested-With': 'XMLHttpRequest',
 | 
				
			||||||
 | 
					                                        'Content-Type': 'multipart/form-data'
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                })
 | 
					                                })
 | 
				
			||||||
                                .then(response => {
 | 
					                                .then(response => {
 | 
				
			||||||
                this.transaction_form.currency = response.data.currency_name;
 | 
					                                    if (response.data.success) {
 | 
				
			||||||
                this.transaction_form.currency_code = response.data.currency_code;
 | 
					                                        if (response.data.redirect) {
 | 
				
			||||||
                this.transaction_form.currency_rate = response.data.currency_rate;
 | 
					                                            this.form.loading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                            window.location.href = response.data.redirect;
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                })
 | 
					                                })
 | 
				
			||||||
                                .catch(error => {
 | 
					                                .catch(error => {
 | 
				
			||||||
 | 
					                                    this.form.loading = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    this.form.onFail(error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    this.method_show_html = error.message;
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            onCancel() {
 | 
				
			||||||
 | 
					                                this.payment.modal = false;
 | 
				
			||||||
 | 
					                                this.payment.html = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let documentClasses = document.body.classList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                documentClasses.remove("modal-open");
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            .catch(error => {
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            .finally(function () {
 | 
				
			||||||
 | 
					                // always executed
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										142
									
								
								resources/assets/js/views/sales/invoices.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										142
									
								
								resources/assets/js/views/sales/invoices.js
									
									
									
									
										vendored
									
									
								
							@@ -38,15 +38,6 @@ const app = new Vue({
 | 
				
			|||||||
                tax: 0,
 | 
					                tax: 0,
 | 
				
			||||||
                total: 0
 | 
					                total: 0
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            transaction_form: new Form('transaction'),
 | 
					 | 
				
			||||||
            payment: {
 | 
					 | 
				
			||||||
                modal: false,
 | 
					 | 
				
			||||||
                amount: 0,
 | 
					 | 
				
			||||||
                title: '',
 | 
					 | 
				
			||||||
                message: '',
 | 
					 | 
				
			||||||
                html: '',
 | 
					 | 
				
			||||||
                errors: new Error()
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            transaction: [],
 | 
					            transaction: [],
 | 
				
			||||||
            items: '',
 | 
					            items: '',
 | 
				
			||||||
            discount: false,
 | 
					            discount: false,
 | 
				
			||||||
@@ -60,7 +51,10 @@ const app = new Vue({
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
 | 
					        if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) {
 | 
				
			||||||
            this.colspan = document.getElementById("items").rows[0].cells.length - 1;
 | 
					            this.colspan = document.getElementById("items").rows[0].cells.length - 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.form.items = [];
 | 
					        this.form.items = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.form.method) {
 | 
					        if (this.form.method) {
 | 
				
			||||||
@@ -322,51 +316,113 @@ const app = new Vue({
 | 
				
			|||||||
            this.onCalculateTotal();
 | 
					            this.onCalculateTotal();
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        onPayment() {
 | 
					        async onPayment() {
 | 
				
			||||||
            this.payment.modal = true;
 | 
					            let invoice_id = document.getElementById('invoice_id').value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let form = this.transaction_form;
 | 
					            let payment = {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.transaction_form = new Form('transaction');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.transaction_form.paid_at = form.paid_at;
 | 
					 | 
				
			||||||
            this.transaction_form.account_id = form.account_id;
 | 
					 | 
				
			||||||
            this.transaction_form.payment_method = form.payment_method;
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        addPayment() {
 | 
					 | 
				
			||||||
            this.transaction_form.submit();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.payment.errors = this.transaction_form.errors;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.form.loading = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            this.$emit("confirm");
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        closePayment() {
 | 
					 | 
				
			||||||
            this.payment = {
 | 
					 | 
				
			||||||
                modal: false,
 | 
					                modal: false,
 | 
				
			||||||
                amount: 0,
 | 
					                url: url + '/modals/invoices/' + invoice_id + '/transactions/create',
 | 
				
			||||||
                title: '',
 | 
					                title: '',
 | 
				
			||||||
                message: '',
 | 
					                html: '',
 | 
				
			||||||
                errors: this.transaction_form.errors
 | 
					                buttons:{}
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            let payment_promise = Promise.resolve(window.axios.get(payment.url));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            payment_promise.then(response => {
 | 
				
			||||||
 | 
					                payment.modal = true;
 | 
				
			||||||
 | 
					                payment.title = response.data.data.title;
 | 
				
			||||||
 | 
					                payment.html = response.data.html;
 | 
				
			||||||
 | 
					                payment.buttons = response.data.data.buttons;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                this.component = Vue.component('add-new-component', (resolve, reject) => {
 | 
				
			||||||
 | 
					                    resolve({
 | 
				
			||||||
 | 
					                        template: '<div id="dynamic-component"><akaunting-modal-add-new :show="payment.modal" @submit="onSubmit" @cancel="onCancel" :buttons="payment.buttons" :title="payment.title" :is_component=true :message="payment.html"></akaunting-modal-add-new></div>',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        mixins: [
 | 
				
			||||||
 | 
					                            Global
 | 
				
			||||||
 | 
					                        ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        data: function () {
 | 
				
			||||||
 | 
					                            return {
 | 
				
			||||||
 | 
					                                form:{},
 | 
				
			||||||
 | 
					                                payment: payment,
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Change bank account get money and currency rate
 | 
					                        methods: {
 | 
				
			||||||
        onChangePaymentAccount(account_id) {
 | 
					                            onSubmit(event) {
 | 
				
			||||||
            axios.get(url + '/banking/accounts/currency', {
 | 
					                                this.form = event;
 | 
				
			||||||
                params: {
 | 
					
 | 
				
			||||||
                    account_id: account_id
 | 
					                                this.loading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let data = this.form.data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                FormData.prototype.appendRecursive = function(data, wrapper = null) {
 | 
				
			||||||
 | 
					                                    for(var name in data) {
 | 
				
			||||||
 | 
					                                        if (wrapper) {
 | 
				
			||||||
 | 
					                                            if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
 | 
				
			||||||
 | 
					                                                this.appendRecursive(data[name], wrapper + '[' + name + ']');
 | 
				
			||||||
 | 
					                                            } else {
 | 
				
			||||||
 | 
					                                                this.append(wrapper + '[' + name + ']', data[name]);
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        } else {
 | 
				
			||||||
 | 
					                                            if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
 | 
				
			||||||
 | 
					                                                this.appendRecursive(data[name], name);
 | 
				
			||||||
 | 
					                                            } else {
 | 
				
			||||||
 | 
					                                                this.append(name, data[name]);
 | 
				
			||||||
 | 
					                                            }
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let form_data = new FormData();
 | 
				
			||||||
 | 
					                                form_data.appendRecursive(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                window.axios({
 | 
				
			||||||
 | 
					                                    method: this.form.method,
 | 
				
			||||||
 | 
					                                    url: this.form.action,
 | 
				
			||||||
 | 
					                                    data: form_data,
 | 
				
			||||||
 | 
					                                    headers: {
 | 
				
			||||||
 | 
					                                        'X-CSRF-TOKEN': window.Laravel.csrfToken,
 | 
				
			||||||
 | 
					                                        'X-Requested-With': 'XMLHttpRequest',
 | 
				
			||||||
 | 
					                                        'Content-Type': 'multipart/form-data'
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                })
 | 
					                                })
 | 
				
			||||||
                                .then(response => {
 | 
					                                .then(response => {
 | 
				
			||||||
                this.transaction_form.currency = response.data.currency_name;
 | 
					                                    if (response.data.success) {
 | 
				
			||||||
                this.transaction_form.currency_code = response.data.currency_code;
 | 
					                                        if (response.data.redirect) {
 | 
				
			||||||
                this.transaction_form.currency_rate = response.data.currency_rate;
 | 
					                                            this.form.loading = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                            window.location.href = response.data.redirect;
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                })
 | 
					                                })
 | 
				
			||||||
                                .catch(error => {
 | 
					                                .catch(error => {
 | 
				
			||||||
 | 
					                                    this.form.loading = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    this.form.onFail(error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                    this.method_show_html = error.message;
 | 
				
			||||||
 | 
					                                });
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            onCancel() {
 | 
				
			||||||
 | 
					                                this.payment.modal = false;
 | 
				
			||||||
 | 
					                                this.payment.html = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                let documentClasses = document.body.classList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                documentClasses.remove("modal-open");
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            .catch(error => {
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            .finally(function () {
 | 
				
			||||||
 | 
					                // always executed
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,32 +1,28 @@
 | 
				
			|||||||
<div class="modal-body">
 | 
					{!! Form::open([
 | 
				
			||||||
    {!! Form::open([
 | 
					    'id' => 'form-transaction',
 | 
				
			||||||
        'route' => ['modals.bills.bill.transactions.store', $bill->id],
 | 
					 | 
				
			||||||
        'id' => 'transaction',
 | 
					 | 
				
			||||||
    '@submit.prevent' => 'onSubmit',
 | 
					    '@submit.prevent' => 'onSubmit',
 | 
				
			||||||
        '@keydown' => 'transaction_form.errors.clear($event.target.name)',
 | 
					    '@keydown' => 'form.errors.clear($event.target.name)',
 | 
				
			||||||
        'files' => true,
 | 
					 | 
				
			||||||
    'role' => 'form',
 | 
					    'role' => 'form',
 | 
				
			||||||
    'class' => 'form-loading-button',
 | 
					    'class' => 'form-loading-button',
 | 
				
			||||||
 | 
					    'route' => ['modals.bills.bill.transactions.store', $bill->id],
 | 
				
			||||||
    'novalidate' => true
 | 
					    'novalidate' => true
 | 
				
			||||||
    ]) !!}
 | 
					]) !!}
 | 
				
			||||||
    <div class="row">
 | 
					    <div class="row">
 | 
				
			||||||
            <base-alert type="warning" v-if="typeof transaction_form.response !== 'undefined' && transaction_form.response.error" v-html="transaction_form.response.message"></base-alert>
 | 
					        <base-alert type="warning" v-if="typeof form.response !== 'undefined' && form.response.error" v-html="form.response.message"></base-alert>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'v-model' => 'transaction_form.paid_at', 'v-error' => 'payment.errors.get("paid_at")', 'v-error-message' => 'payment.errors.get("paid_at")'], Date::now()->toDateString()) }}
 | 
					        {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::now()->toDateString()) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'autofocus' => 'autofocus', 'v-model' => 'transaction_form.amount', 'v-error' => 'payment.errors.get("amount")', 'v-error-message' => 'payment.errors.get("amount")', 'currency' => $currency, 'dynamic-currency' => 'currency'], $bill->grand_total) }}
 | 
					        {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency, 'dynamic-currency' => 'currency'], $bill->grand_total) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::selectGroup('account_id', trans_choice('general.accounts', 1), 'university', $accounts, setting('default.account'), ['required' => 'required', 'v-model' => 'transaction_form.account_id', 'v-error' => 'payment.errors.get("account_id")', 'v-error-message' => 'payment.errors.get("account_id")', 'change' => 'onChangePaymentAccount']) }}
 | 
					        {{ Form::selectGroup('account_id', trans_choice('general.accounts', 1), 'university', $accounts, setting('default.account'), ['required' => 'required', 'change' => 'onChangePaymentAccount']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            @stack('currency_code_input_start')
 | 
					        {{ Form::textGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', ['disabled' => 'true'], $currencies[$bill->currency_code]) }}
 | 
				
			||||||
                {{ Form::textGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', ['disabled' => 'true', 'v-model' => 'transaction_form.currency', 'v-error' => 'payment.errors.get("currency")', 'v-error-message' => 'payment.errors.get("currency")'], $currencies[$bill->currency_code]) }}
 | 
					 | 
				
			||||||
            @stack('currency_code_input_end')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::textareaGroup('description', trans('general.description'), '', null, ['rows' => '3', 'v-model' => 'transaction_form.description', 'v-error' => 'payment.errors.get("description")', 'v-error-message' => 'payment.errors.get("description")']) }}
 | 
					        {{ Form::textareaGroup('description', trans('general.description'), '', null, ['rows' => '3']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('default.payment_method'), ['required' => 'requied', 'v-model' => 'transaction_form.payment_method', 'v-error' => 'payment.errors.get("payment_method")', 'v-error-message' => 'payment.errors.get("payment_method")']) }}
 | 
					        {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('default.payment_method'), ['required' => 'requied']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::textGroup('reference', trans('general.reference'), 'fa fa-file', ['v-model' => 'transaction_form.reference', 'v-error' => 'payment.errors.get("reference")', 'v-error-message' => 'payment.errors.get("reference")']) }}
 | 
					        {{ Form::textGroup('reference', trans('general.reference'), 'fa fa-file') }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {!! Form::hidden('bill_id', $bill->id, ['id' => 'bill_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
					        {!! Form::hidden('bill_id', $bill->id, ['id' => 'bill_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
				
			||||||
        {!! Form::hidden('category_id', $bill->category->id, ['id' => 'category_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
					        {!! Form::hidden('category_id', $bill->category->id, ['id' => 'category_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
				
			||||||
@@ -35,5 +31,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        {!! Form::hidden('type', 'expense') !!}
 | 
					        {!! Form::hidden('type', 'expense') !!}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    {!! Form::close() !!}
 | 
					{!! Form::close() !!}
 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,30 +1,28 @@
 | 
				
			|||||||
<div class="modal-body pb-0">
 | 
					{!! Form::open([
 | 
				
			||||||
    {!! Form::open([
 | 
					    'id' => 'form-transaction',
 | 
				
			||||||
        'route' => ['modals.invoices.invoice.transactions.store', $invoice->id],
 | 
					 | 
				
			||||||
        'id' => 'transaction',
 | 
					 | 
				
			||||||
    '@submit.prevent' => 'onSubmit',
 | 
					    '@submit.prevent' => 'onSubmit',
 | 
				
			||||||
        '@keydown' => 'transaction_form.errors.clear($event.target.name)',
 | 
					    '@keydown' => 'form.errors.clear($event.target.name)',
 | 
				
			||||||
        'files' => true,
 | 
					 | 
				
			||||||
    'role' => 'form',
 | 
					    'role' => 'form',
 | 
				
			||||||
    'class' => 'form-loading-button',
 | 
					    'class' => 'form-loading-button',
 | 
				
			||||||
 | 
					    'route' => ['modals.invoices.invoice.transactions.store', $invoice->id],
 | 
				
			||||||
    'novalidate' => true
 | 
					    'novalidate' => true
 | 
				
			||||||
    ]) !!}
 | 
					]) !!}
 | 
				
			||||||
    <div class="row">
 | 
					    <div class="row">
 | 
				
			||||||
            <base-alert type="warning" v-if="typeof transaction_form.response !== 'undefined' && transaction_form.response.error" v-html="transaction_form.response.message"></base-alert>
 | 
					        <base-alert type="warning" v-if="typeof form.response !== 'undefined' && form.response.error" v-html="form.response.message"></base-alert>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off', 'v-model' => 'transaction_form.paid_at', 'v-error' => 'payment.errors.get("paid_at")', 'v-error-message' => 'payment.errors.get("paid_at")'], Date::now()->toDateString()) }}
 | 
					        {{ Form::dateGroup('paid_at', trans('general.date'), 'calendar', ['id' => 'paid_at', 'required' => 'required', 'date-format' => 'Y-m-d', 'autocomplete' => 'off'], Date::now()->toDateString()) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'autofocus' => 'autofocus', 'v-model' => 'transaction_form.amount', 'v-error' => 'payment.errors.get("amount")', 'v-error-message' => 'payment.errors.get("amount")', 'currency' => $currency, 'dynamic-currency' => 'currency'], $invoice->grand_total) }}
 | 
					        {{ Form::moneyGroup('amount', trans('general.amount'), 'money-bill-alt', ['required' => 'required', 'autofocus' => 'autofocus', 'currency' => $currency, 'dynamic-currency' => 'currency'], $invoice->grand_total) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::selectGroup('account_id', trans_choice('general.accounts', 1), 'university', $accounts, setting('default.account'), ['required' => 'required', 'v-model' => 'transaction_form.account_id', 'v-error' => 'payment.errors.get("account_id")', 'v-error-message' => 'payment.errors.get("account_id")', 'change' => 'onChangePaymentAccount']) }}
 | 
					        {{ Form::selectGroup('account_id', trans_choice('general.accounts', 1), 'university', $accounts, setting('default.account'), ['required' => 'required', 'change' => 'onChangePaymentAccount']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::textGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', ['disabled' => 'true', 'v-model' => 'transaction_form.currency', 'v-error' => 'payment.errors.get("currency")', 'v-error-message' => 'payment.errors.get("currency")'], $currencies[$invoice->currency_code]) }}
 | 
					        {{ Form::textGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', ['disabled' => 'true'], $currencies[$invoice->currency_code]) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::textareaGroup('description', trans('general.description'), '', null, ['rows' => '3', 'v-model' => 'transaction_form.description', 'v-error' => 'payment.errors.get("description")', 'v-error-message' => 'payment.errors.get("description")']) }}
 | 
					        {{ Form::textareaGroup('description', trans('general.description'), '', null, ['rows' => '3']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('default.payment_method'), ['required' => 'requied', 'v-model' => 'transaction_form.payment_method', 'v-error' => 'payment.errors.get("payment_method")', 'v-error-message' => 'payment.errors.get("payment_method")']) }}
 | 
					        {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('default.payment_method'), ['required' => 'requied']) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            {{ Form::textGroup('reference', trans('general.reference'), 'fa fa-file', ['v-model' => 'transaction_form.reference', 'v-error' => 'payment.errors.get("reference")', 'v-error-message' => 'payment.errors.get("reference")']) }}
 | 
					        {{ Form::textGroup('reference', trans('general.reference'), 'fa fa-file') }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {!! Form::hidden('invoice_id', $invoice->id, ['id' => 'invoice_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
					        {!! Form::hidden('invoice_id', $invoice->id, ['id' => 'invoice_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
				
			||||||
        {!! Form::hidden('category_id', $invoice->category->id, ['id' => 'category_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
					        {!! Form::hidden('category_id', $invoice->category->id, ['id' => 'category_id', 'class' => 'form-control', 'required' => 'required']) !!}
 | 
				
			||||||
@@ -33,5 +31,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        {!! Form::hidden('type', 'income') !!}
 | 
					        {!! Form::hidden('type', 'income') !!}
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    {!! Form::close() !!}
 | 
					{!! Form::close() !!}
 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -601,35 +601,10 @@
 | 
				
			|||||||
            @stack('row_footer_transaction_end')
 | 
					            @stack('row_footer_transaction_end')
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    @stack('row_footer_end')
 | 
					    @stack('row_footer_end')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {{ Form::hidden('bill_id', $bill->id, ['id' => 'bill_id']) }}
 | 
				
			||||||
@endsection
 | 
					@endsection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@push('content_content_end')
 | 
					 | 
				
			||||||
    <akaunting-modal
 | 
					 | 
				
			||||||
        class="modal-payment"
 | 
					 | 
				
			||||||
        :show="payment.modal"
 | 
					 | 
				
			||||||
        @cancel="payment.modal = false"
 | 
					 | 
				
			||||||
        :title="'{{ trans('general.title.new', ['type' => trans_choice('general.payments', 1)]) }}'"
 | 
					 | 
				
			||||||
        :message="payment.html"
 | 
					 | 
				
			||||||
        :button_cancel="'{{ trans('general.button.save') }}'"
 | 
					 | 
				
			||||||
        :button_delete="'{{ trans('general.button.cancel') }}'">
 | 
					 | 
				
			||||||
        <template #modal-body>
 | 
					 | 
				
			||||||
            @include('modals.bills.payment')
 | 
					 | 
				
			||||||
        </template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        <template #card-footer>
 | 
					 | 
				
			||||||
            <div class="float-right">
 | 
					 | 
				
			||||||
                <button type="button" class="btn btn-outline-secondary header-button-top" @click="closePayment">
 | 
					 | 
				
			||||||
                    {{ trans('general.cancel') }}
 | 
					 | 
				
			||||||
                </button>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                <button :disabled="form.loading" type="button" class="btn btn-success button-submit header-button-top" @click="addPayment">
 | 
					 | 
				
			||||||
                    <div class="aka-loader"></div><span>{{ trans('general.confirm') }}</span>
 | 
					 | 
				
			||||||
                </button>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </template>
 | 
					 | 
				
			||||||
    </akaunting-modal>
 | 
					 | 
				
			||||||
@endpush
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@push('scripts_start')
 | 
					@push('scripts_start')
 | 
				
			||||||
    <script src="{{ asset('public/js/purchases/bills.js?v=' . version('short')) }}"></script>
 | 
					    <script src="{{ asset('public/js/purchases/bills.js?v=' . version('short')) }}"></script>
 | 
				
			||||||
@endpush
 | 
					@endpush
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -636,39 +636,10 @@
 | 
				
			|||||||
            @stack('row_footer_transaction_end')
 | 
					            @stack('row_footer_transaction_end')
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    @stack('row_footer_end')
 | 
					    @stack('row_footer_end')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {{ Form::hidden('invoice_id', $invoice->id, ['id' => 'invoice_id']) }}
 | 
				
			||||||
@endsection
 | 
					@endsection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@push('content_content_end')
 | 
					 | 
				
			||||||
    <akaunting-modal
 | 
					 | 
				
			||||||
        class="modal-payment"
 | 
					 | 
				
			||||||
        :show="payment.modal"
 | 
					 | 
				
			||||||
        @cancel="payment.modal = false"
 | 
					 | 
				
			||||||
        :title="'{{ trans('general.title.new', ['type' => trans_choice('general.payments', 1)]) }}'"
 | 
					 | 
				
			||||||
        :message="payment.html"
 | 
					 | 
				
			||||||
        :button_cancel="'{{ trans('general.button.save') }}'"
 | 
					 | 
				
			||||||
        :button_delete="'{{ trans('general.button.cancel') }}'">
 | 
					 | 
				
			||||||
        <template #modal-body>
 | 
					 | 
				
			||||||
            @include('modals.invoices.payment')
 | 
					 | 
				
			||||||
        </template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        <template #card-footer>
 | 
					 | 
				
			||||||
            <div class="float-right">
 | 
					 | 
				
			||||||
                <button type="button" class="btn btn-outline-secondary header-button-top" @click="closePayment">
 | 
					 | 
				
			||||||
                    {{ trans('general.cancel') }}
 | 
					 | 
				
			||||||
                </button>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                <a href="{{ route('apps.categories.show', 'payment-method') }}" class="btn btn-white header-button-top long-texts">
 | 
					 | 
				
			||||||
                    {{ trans('invoices.accept_payments') }}</span>
 | 
					 | 
				
			||||||
                </a>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                <button :disabled="form.loading" type="button" class="btn btn-success button-submit header-button-top" @click="addPayment">
 | 
					 | 
				
			||||||
                    <div class="aka-loader"></div><span>{{ trans('general.confirm') }}</span>
 | 
					 | 
				
			||||||
                </button>
 | 
					 | 
				
			||||||
            </div>
 | 
					 | 
				
			||||||
        </template>
 | 
					 | 
				
			||||||
    </akaunting-modal>
 | 
					 | 
				
			||||||
@endpush
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@push('scripts_start')
 | 
					@push('scripts_start')
 | 
				
			||||||
    <script src="{{ asset('public/js/sales/invoices.js?v=' . version('short')) }}"></script>
 | 
					    <script src="{{ asset('public/js/sales/invoices.js?v=' . version('short')) }}"></script>
 | 
				
			||||||
@endpush
 | 
					@endpush
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user