Files

263 lines
19 KiB
PHP
Raw Permalink Normal View History

2026-03-15 17:08:23 +07:00
@extends('layouts.business.master')
@section('title')
{{ __('Inventory Sales') }}
@endsection
@php
$modules = product_setting()->modules ?? [];
@endphp
@section('main_content')
<div class="container-fluid">
<div class="card">
<div class="table-header p-16">
<h4>{{ __('Inventory Sales') }}</h4>
</div>
<div class="order-form-section p-16">
<form action="{{ route('business.sales.store') }}" method="post" enctype="multipart/form-data"
class="ajaxform">
@csrf
<input type="hidden" name="type" value="inventory">
<div class="row mt-3">
<div class="col-lg-4">
<label>{{ __('Customer') }}</label>
<div class="input-group">
<select name="party_id" class="form-control inventory-customer-select" aria-label="Select Customer">
<option value="">{{ __('Guest') }}</option>
@foreach ($customers as $customer)
<option value="{{ $customer->id }}" data-type="{{ $customer->type }}">
{{ $customer->name }} ({{ $customer->type }}{{ $customer->due ? ' ' . currency_format($customer->due, currency:business_currency()) : '' }})
</option>
@endforeach
</select>
<a type="button" href="#customer-create-modal" data-bs-toggle="modal"
class="btn btn-danger square-btn d-flex justify-content-center align-items-center">
<img src="{{ asset('assets/images/icons/plus.svg') }}" alt=""></a>
</div>
</div>
<div class="col-lg-4">
<label>{{ __('Invoice No') }}.</label>
<input type="text" name="invoiceNumber" value="{{ $invoice_no }}" class="form-control"
placeholder="{{ __('Invoice no') }}." readonly>
</div>
<div class="col-lg-4">
<label>{{ __('Date') }}</label>
<input type="date" name="saleDate" class="form-control"
value="{{ now()->format('Y-m-d') }}">
</div>
<div class="col-lg-8">
<label>{{ __('Select Product') }}</label>
<div class="product-dropdown" id="productDropdown">
<div class="input-group w-100">
<div class="product-selected w-100">
<span id="selectedValue">{{ __('Select Product') }}</span><span id="arrow">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 6L8 10L12 6" stroke="#4B5563" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</span>
</div>
<a type="button" href="jsvascript:void(0)" class="btn btn-danger inventory-square-btn square-btn d-flex justify-content-center align-items-center">
<svg class="bar-code-icon" width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.75 7.03125H5.625V22.9688H3.75V7.03125ZM13.5938 7.03125H15.4688V22.9688H13.5938V7.03125ZM24.375 7.03125H26.25V22.9688H24.375V7.03125ZM9.375 7.03125H10.3125V22.9688H9.375V7.03125ZM11.25 7.03125H12.1875V22.9688H11.25V7.03125ZM19.6875 7.03125H20.625V22.9688H19.6875V7.03125ZM21.5625 7.03125H22.5V22.9688H21.5625V7.03125ZM7.03125 7.03125H8.4375V22.9688H7.03125V7.03125ZM16.875 7.03125H18.2812V22.9688H16.875V7.03125Z" fill="white"/>
<path d="M1.40625 9.84375C1.28193 9.84375 1.1627 9.79436 1.07479 9.70646C0.986886 9.61855 0.9375 9.49932 0.9375 9.375V4.6875C0.9375 4.56318 0.986886 4.44395 1.07479 4.35604C1.1627 4.26814 1.28193 4.21875 1.40625 4.21875H6.09375C6.21807 4.21875 6.3373 4.26814 6.42521 4.35604C6.51311 4.44395 6.5625 4.56318 6.5625 4.6875C6.5625 4.81182 6.51311 4.93105 6.42521 5.01896C6.3373 5.10686 6.21807 5.15625 6.09375 5.15625H1.875V9.375C1.875 9.49932 1.82561 9.61855 1.73771 9.70646C1.6498 9.79436 1.53057 9.84375 1.40625 9.84375ZM28.5938 9.84375C28.4694 9.84375 28.3502 9.79436 28.2623 9.70646C28.1744 9.61855 28.125 9.49932 28.125 9.375V5.15625H23.9062C23.7819 5.15625 23.6627 5.10686 23.5748 5.01896C23.4869 4.93105 23.4375 4.81182 23.4375 4.6875C23.4375 4.56318 23.4869 4.44395 23.5748 4.35604C23.6627 4.26814 23.7819 4.21875 23.9062 4.21875H28.5938C28.7181 4.21875 28.8373 4.26814 28.9252 4.35604C29.0131 4.44395 29.0625 4.56318 29.0625 4.6875V9.375C29.0625 9.49932 29.0131 9.61855 28.9252 9.70646C28.8373 9.79436 28.7181 9.84375 28.5938 9.84375ZM6.09375 25.7812H1.40625C1.28193 25.7812 1.1627 25.7319 1.07479 25.644C0.986886 25.556 0.9375 25.4368 0.9375 25.3125V20.625C0.9375 20.5007 0.986886 20.3815 1.07479 20.2935C1.1627 20.2056 1.28193 20.1562 1.40625 20.1562C1.53057 20.1562 1.6498 20.2056 1.73771 20.2935C1.82561 20.3815 1.875 20.5007 1.875 20.625V24.8438H6.09375C6.21807 24.8438 6.3373 24.8931 6.42521 24.981C6.51311 25.069 6.5625 25.1882 6.5625 25.3125C6.5625 25.4368 6.51311 25.556 6.42521 25.644C6.3373 25.7319 6.21807 25.7812 6.09375 25.7812ZM28.5938 25.7812H23.9062C23.7819 25.7812 23.6627 25.7319 23.5748 25.644C23.4869 25.556 23.4375 25.4368 23.4375 25.3125C23.4375 25.1882 23.4869 25.069 23.5748 24.981C23.6627 24.8931 23.7819 24.8438 23.9062 24.8438H28.125V20.625C28.125 20.5007 28.1744 20.3815 28.2623 20.2935C28.3502 20.2056 28.4694 20.1562 28.5938 20.1562C28.7181 20.1562 28.8373 20.2056 28.9252 20.2935C29.0131 20.3815 29.0625 20.5007 29.0625 20.625V25.3125C29.0625 25.4368 29.0131 25.556 28.9252 25.644C28.8373 25.7319 28.7181 25.7812 28.5938 25.7812Z" fill="white"/>
<path d="M1.40625 14.0625H28.5938V15.9375H1.40625V14.0625Z" fill="white"/>
</svg>
</a>
</div>
<div class="dropdown-search hidden" id="searchContainer">
<input type="text" id="productSearch" placeholder="Search product..." />
</div>
<div class="product-dropdown-options" id="dropdownList">
{{-- load dynamically from js --}}
</div>
</div>
</div>
<div class="col-lg-4">
<label>{{ __('Category') }}</label>
<div class="input-group">
<select name="category_id" id="categorySelect" class="form-control" aria-label="Select Category">
<option value="">{{ __('All') }}</option>
@foreach ($categories as $category)
<option value="{{ $category->id }}">{{ $category->categoryName }}</option>
@endforeach
</select>
</div>
</div>
<div class="table-responsive mt-4">
<table class="table table-bordered text-center">
<thead>
<tr>
<th class="border p-2 table-background">{{ __('Image') }}</th>
<th class="border p-2 table-background">{{ __('Items') }}</th>
<th class="border p-2 table-background">{{ __('Code') }}</th>
<th class="border p-2 table-background">{{ __('Batch') }}</th>
<th class="border p-2 table-background">{{ __('Unit') }}</th>
<th class="border p-2 table-background">{{ __('Sale Price') }}</th>
@if ($modules['allow_product_discount'] ?? false)
<th class="border p-2 table-background">{{ __('Discount') }}</th>
@endif
<th class="border p-2 table-background">{{ __('Vat %') }}</th>
<th class="border p-2 table-background">{{ __('Vat Value') }}</th>
<th class="border p-2 table-background">{{ __('Qty') }}</th>
<th class="border p-2 table-background">{{ __('Sub Total') }}</th>
<th class="border p-2 table-background">{{ __('Action') }}</th>
</tr>
</thead>
<tbody id="cart-list">
@include('business::sales.cart-list')
</tbody>
</table>
</div>
<div class="col-sm-12 col-md-6 col-lg-6 mt-5">
<div class="amount-info-container inventory-amount-info-container">
<div class="row amount-container align-items-center mb-2">
<h6 class="payment-title">{{ __('Receive Amount') }}</h6>
<input name="receive_amount" type="number" step="any" id="receive_amount"
min="0" class="form-control receive_amount" placeholder="0">
</div>
<div class="row amount-container align-items-center mb-2">
<h6 class="payment-title">{{ __('Change Amount') }}</h6>
<input type="number" step="any" id="change_amount" class="form-control"
placeholder="0" readonly>
</div>
<div class="row amount-container align-items-center mb-2">
<h6 class="payment-title">{{ __('Due Amount') }}</h6>
<input type="number" step="any" id="due_amount" class="form-control"
placeholder="0" readonly>
</div>
<div class="row amount-container align-items-center mb-2">
<h6 class="payment-title">{{ __('Payment Type') }}</h6>
@include('business::component.payment_type', ['context' => 'sale', 'payment_types' => $payment_types])
</div>
<div class="row amount-container align-items-center mb-2">
<h6 class="payment-title">{{ __('Note') }}</h6>
<input type="text" name="note" class="form-control"
placeholder="{{ __('Type note...') }}">
</div>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-6 mt-5 sub-total-container">
<div class="payment-container mb-3 amount-info-container inventory-amount-info-container">
<div class="mb-2 d-flex align-items-center justify-content-between">
<h6>{{ __('Sub Total') }}</h6>
<h6 class="fw-bold" id="sub_total">
{{ currency_format(0, currency: business_currency()) }}</h6>
</div>
<div class="mb-2 d-flex align-items-center justify-content-between">
<h6>{{ get_business_option('business-settings')['vat_name'] ?? 'Vat' }}</h6>
<h6 class="fw-bold" id="vat_amount_txt">
{{ currency_format(0, currency: business_currency()) }}</h6>
</div>
<div class="row save-amount-container align-items-center mb-2 d-none">
<h6 class="payment-title col-6">{{ get_business_option('business-settings')['vat_name'] ?? 'Vat' }}</h6>
<div class="col-6 w-100 d-flex justify-content-between gap-2">
<div class="d-flex d-flex align-items-center gap-2">
<select name="vat_id" class="form-select vat_select" id='form-ware'>
<option value="">{{ __('Select') }}</option>
@foreach ($vats as $vat)
<option value="{{ $vat->id }}" data-rate="{{ $vat->rate }}">
{{ $vat->name }}
({{ $vat->rate }}%)
</option>
@endforeach
</select>
</div>
<input type="number" step="any" name="vat_amount" id="vat_amount"
min="0" class="form-control right-start-input"
placeholder="{{ __('0') }}" readonly>
</div>
</div>
<div class="row save-amount-container align-items-center mb-2">
<h6 class="payment-title col-6">{{ __('Discount') }}</h6>
<div class="col-6 w-100 d-flex justify-content-between gap-2">
<div class="d-flex d-flex align-items-center gap-2">
<select name="discount_type" class="form-select discount_type"
id='form-ware'>
<option value="flat">{{ __('Flat') }}
({{ business_currency()->symbol }})</option>
<option value="percent">{{ __('Percent (%)') }}</option>
</select>
</div>
<input type="number" step="any" name="discountAmount" id="discount_amount"
min="0" class="form-control right-start-input"
placeholder="{{ __('0') }}">
</div>
</div>
<div class="shopping-crg-grid mb-2">
<h6 class="payment-title">{{ __('Shipping Charge') }}</h6>
<div class="">
<input type="number" step="any" name="shipping_charge" id="shipping_charge"
class="form-control right-start-input" placeholder="0">
</div>
</div>
<div class=" d-flex align-items-center justify-content-between fw-bold">
<div class="fw-bold">{{ __('Total Amount') }}</div>
<h6 class='fw-bold' id="total_amount">
{{ currency_format(0, currency: business_currency()) }}</h6>
</div>
<div class="mb-2 d-flex align-items-center justify-content-between">
<h6>{{ __('Rounding(+/-)') }}</h6>
<h6 id="rounding_amount">
{{ currency_format(0, currency: business_currency()) }}</h6>
</div>
<div class="mb-2 d-flex align-items-center justify-content-between">
<h6 class="fw-bold">{{ __('Payable Amount') }}</h6>
<h6 class="fw-bold" id="payable_amount">
{{ currency_format(0, currency: business_currency()) }}</h6>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="button-group text-center ">
<button data-route="{{ route('business.carts.remove-all') }}"
class="theme-btn border-btn m-2">{{__('Cancel')}}
</button>
@usercan('inventory.create')
<button class="theme-btn m-2 submit-btn">{{__('Submit')}}</button>
@endusercan
</div>
</div>
</div>
</form>
</div>
</div>
</div>
@php
$rounding_amount_option = sale_rounding();
@endphp
<input type="hidden" id="get_product" value="{{ route('business.products.prices') }}">
<input type="hidden" value="{{ route('business.carts.index') }}" id="get-cart">
<input type="hidden" value="{{ route('business.sales.cart-data') }}" id="get-cart-data">
<input type="hidden" value="{{ route('business.carts.remove-all') }}" id="clear-cart">
<input type="hidden" id="rounding_amount_option" value="{{ $rounding_amount_option }}">
<input type="hidden" id="all-products" value="{{ route('business.products.all-product') }}">
<input type="hidden" id="get-by-category" value="{{ route('business.products.get-by-category') }}">
<input type="hidden" id="cart-store-url" value="{{ route('business.carts.store') }}">
<input type="hidden" id="selectedProductValue" name="selectedProductValue">
<input type="hidden" id="asset_base_url" value="{{ url('/') }}">
<input type="hidden" id="get_stock_prices" value="{{ route('business.products.stocks-prices') }}">
@endsection
@push('modal')
@include('business::sales.calculator')
@include('business::sales.customer-create')
@endpush
@push('js')
<script src="{{ asset('assets/js/custom/sale.js') }}?v={{ time() }}"></script>
<script src="{{ asset('assets/js/custom/math.min.js') }}"></script>
<script src="{{ asset('assets/js/custom/calculator.js') }}"></script>
@endpush