diff --git a/.env.example b/.env.example index ac748637..49803372 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost +MAIN_SYSTEM_URL= LOG_CHANNEL=stack diff --git a/.gitignore b/.gitignore index dfbd610f..f5578e7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /node_modules +/public/build /public/hot /public/storage /storage/*.key diff --git a/README.md b/README.md index 96ea7fe0..25336060 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@
Product Name | -Quantity | -Price | -
---|---|---|
{c.name} | -- - this.handleChangeQty( - c.id, - event.target.value - ) - } - /> - - | -- {window.APP.currency_symbol}{" "} - {( - c.price * c.pivot.quantity - ).toFixed(2)} - | -
Product | +Option | +Notes | +Price({window.APP.currency_symbol}) | +
---|---|---|---|
{productFound.name} | +
+ {detail.product_options.map((option, index) => {
+ let key = Object.keys(option)[0];
+ let optionFound = productFound.product_options.find(opt => { return opt.id === parseInt(key) });
+ let detailFound = optionFound.option_details.find(detail => { return detail.id == option[key.toString()] });
+ console.log(optionFound);
+ console.log(detailFound);
+ return
+ ;
+ })}
+ {optionFound.name}: {detailFound.name} + |
+ {detail.notes} | +{detail.price} | +
Product | +Option | +Notes | +Price({window.APP.currency_symbol}) | +
---|---|---|---|
{productFound.name} | +
+ {order.product_options.map((option, index) => {
+ let key = parseInt(Object.keys(option)[0]);
+ let optionFound = productFound.product_options.find(opt => { return opt.id === key });
+ let detailFound = optionFound.option_details.find(detail => { return detail.id == option[key.toString()] });
+ return
+ ;
+ })}
+ {optionFound.name}: {detailFound.name} + |
+ {order.notes} | +{order.price} | +
' + productFound.description + '
' + window.APP.currency_symbol + productFound.price + '
' + htmlResult + Cart.noteTemplate; + + window.SwalWithBootstrap.fire({ + title: productFound.name, + imageWidth: 300, + imageHeight: 200, + imageUrl: productFound.media_path === null ? main_server_url + '/storage/defaults/product.png' : main_server_url + '/' + productFound.media_path, + showCancelButton: true, + reverseButtons: true, + html: html, + preConfirm: () => { + let note = SwalWithBootstrap.getPopup().querySelector('#note').value; + let data = { + note: note, + price: parseFloat(productFound.price).toFixed(2), + options: [], + } + + for (let i = 0; i < productFound.product_options.length; i++) { + let input = SwalWithBootstrap.getPopup().querySelector('#option' + productFound.product_options[i].id + ':checked').value; + data.options.push({ + [productFound.product_options[i].id]: input, + }); + let details = productFound.product_options[i].option_details; + let detailFound = details.find(detail => { return detail.id == input }); + data.price = (parseFloat(data.price) + parseFloat(detailFound.extra_price)).toFixed(2); + } + + return data; + }, + }).then((swalResult) => { + let value = swalResult.value; + + let orderDetail = { + product_id: productFound.id, + product_options: value.options, + price: value.price, + notes: value.note, + } + + let orders = this.state.newOrder; + orders.push(orderDetail); + + let total = (parseFloat(this.state.total) + parseFloat(value.price)).toFixed(2); + + this.setState({ newOrder: orders, total: total }); + }); + + } else { + if (this.state.isOrderExist) { + window.SwalWithBootstrap.fire({ + title: 'Warning', + text: 'The student has order haven\'t complete.', + icon: 'warning', + }); + } else { + window.SwalWithBootstrap.fire({ + title: 'Warning', + text: 'Please enter a student number first.', + icon: 'warning', + }); + } + } + + } + + handleChangeSearch(event) { + const search = event.target.value; + this.setState({ search, products: this.state.allProducts }); + } + + handleSeach(event) { + if (event.keyCode === 13) { + this.loadProducts(event.target.value); + } + } + + handleOnChangeBarcode(event) { + const barcode = event.target.value; + this.setState({ barcode, products: this.state.allProducts }); + } + + handleScanBarcode(event) { + + if(event.keyCode === 13){ + + const barcode = this.state.barcode; + if(!!barcode){ + + window.axios.get(base_url + '/cart/get_products_barcode?barcode=' + barcode).then(response => { + const products = response.data.products; + this.setState({products}); + }).catch(error => { + console.log(error); + window.SwalWithBootstrap.fire({ + title: 'Error', + html: error.response.data.message, + icon: 'error', + }); + }); + + } + + } + } + + handleEmptyOrder() { + this.setState({ newOrder: [], orders: [], student_number: '', student: {}, isStudentExist: false, isOrderExist: false }); + } + + handleClickSubmit() { + + if(this.state.isOrderExist){ + let orderIds = []; + this.state.orders.forEach(order => { + orderIds.push(order.id); + }); + + window.axios.post( + base_url + '/cart/store', + { + isNewOrder: !this.state.isOrderExist, + student_number: this.state.student_number, + order_ids: orderIds, + }) + .then(response => { + window.SwalWithBootstrap.fire({ + title: 'Success', + text: response.data.message, + icon: 'success', + }).then(() => { + this.handleEmptyOrder(); + }); + }) + .catch(error => { + console.log(error); + window.SwalWithBootstrap.fire({ + title: 'Error', + text: response.message, + icon: 'error', + }); + }); + } else { + console.log(this.state.newOrder); + + window.axios.post(base_url + '/cart/store', { + isNewOrder: !this.state.isOrderExist, + student_number: this.state.student_number, + order_details: this.state.newOrder, + total_price: this.state.total, + }) + .then(response => { + console.log(response); + window.SwalWithBootstrap.fire({ + title: 'Success', + text: response.data.message, + icon: 'success', + }).then(() => { + this.handleEmptyOrder(); + }); + }) + .catch(error => { + console.log(error); + window.SwalWithBootstrap.fire({ + title: 'Error', + text: error.message, + icon: 'error', + }); + }); + } + + /*Swal.fire({ + title: 'Received Amount', + input: 'text', + inputValue: this.getTotal(this.state.cart), + showCancelButton: true, + confirmButtonText: 'Send', + showLoaderOnConfirm: true, + preConfirm: (amount) => { + return axios.post('/admin/orders', { customer_id: this.state.customer_id, amount }).then(res => { + this.loadCart(); + return res.data; + }).catch(err => { + Swal.showValidationMessage(err.response.data.message) + }) + }, + allowOutsideClick: () => !Swal.isLoading() + }).then((result) => { + if (result.value) { + // + } + })*/ + + } + + render() { + const { cart, products, barcode, student_number, student, orders, newOrder, total } = this.state; + return ( +Sign in to start your session
@@ -17,8 +21,8 @@--}} +{{-- I forgot my password--}} +{{--
--}} +{{----}} +{{-- Register a new membership--}} +{{--
--}} +@endsection diff --git a/resources/views/cart/index.blade.php b/resources/views/cart/index.blade.php index 41adf395..c3b84dd4 100644 --- a/resources/views/cart/index.blade.php +++ b/resources/views/cart/index.blade.php @@ -3,6 +3,10 @@ @section('title', 'Open POS') @section('content') - + -@endsection + +@endsection \ No newline at end of file diff --git a/resources/views/customers/create.blade.php b/resources/views/customers/create.blade.php deleted file mode 100644 index 4327c955..00000000 --- a/resources/views/customers/create.blade.php +++ /dev/null @@ -1,99 +0,0 @@ -@extends('layouts.admin') - -@section('title', 'Create Customer') -@section('content-header', 'Create Customer') - -@section('content') - -Income
-Income Today
-Products Pick Up Today
+