Updated: Sales Module

This commit is contained in:
Fahim 2021-08-05 22:33:55 +06:00
parent 5c24e3be49
commit 208f909824
13 changed files with 336 additions and 19 deletions

View File

@ -100,7 +100,9 @@ class SaleController extends Controller
public function show(Sale $sale) {
abort_if(Gate::denies('show_sales'), 403);
return view('sale::show', compact('sale'));
$customer = Customer::findOrFail($sale->customer_id);
return view('sale::show', compact('sale', 'customer'));
}

View File

@ -83,10 +83,15 @@
</div>
</div>
<div class="col-lg-4">
<div class="from-group">
<div class="form-group">
<label for="paid_amount">Amount Received <span class="text-danger">*</span></label>
<div class="form-group">
<label for="paid_amount">Amount Received <span class="text-danger">*</span></label>
<div class="input-group">
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required>
<div class="input-group-append">
<button id="getTotalAmount" class="btn btn-primary" type="button">
<i class="bi bi-check-square"></i>
</button>
</div>
</div>
</div>
</div>
@ -121,6 +126,10 @@
allowZero: true,
});
$('#getTotalAmount').click(function () {
$('#paid_amount').maskMoney('mask', {{ Cart::instance('sale')->total() }});
});
$('#sale-form').submit(function () {
var paid_amount = $('#paid_amount').maskMoney('unmasked')[0];
$('#paid_amount').val(paid_amount);

View File

@ -83,10 +83,15 @@
</div>
</div>
<div class="col-lg-4">
<div class="from-group">
<div class="form-group">
<label for="paid_amount">Amount Received <span class="text-danger">*</span></label>
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required value="{{ $sale->paid_amount }}" min="0" max="{{ $sale->total_amount }}">
<div class="form-group">
<label for="paid_amount">Amount Received <span class="text-danger">*</span></label>
<div class="input-group">
<input id="paid_amount" type="text" class="form-control" name="paid_amount" required value="{{ $sale->paid_amount }}">
<div class="input-group-append">
<button id="getTotalAmount" class="btn btn-primary" type="button">
<i class="bi bi-check-square"></i>
</button>
</div>
</div>
</div>
</div>
@ -122,7 +127,10 @@
});
$('#paid_amount').maskMoney('mask');
$('#paid_amount').maskMoney('mask');
$('#getTotalAmount').click(function () {
$('#paid_amount').maskMoney('mask', {{ \Gloudemans\Shoppingcart\Facades\Cart::instance('sale')->total() }});
});
$('#sale-form').submit(function () {
var paid_amount = $('#paid_amount').maskMoney('unmasked')[0];

View File

@ -1,16 +1,16 @@
<div class="btn-group dropleft">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots-vertical"></i>
<button type="button" class="btn btn-outline-primary dropdown rounded" data-toggle="dropdown" aria-expanded="false">
<i class="bi bi-wrench"></i>
</button>
<div class="dropdown-menu">
@can('edit_sales')
<a href="{{ route('sales.edit', $data->id) }}" class="dropdown-item">
<i class="bi bi-pencil mr-2" style="line-height: 1;"></i> Edit
<i class="bi bi-pencil mr-2 text-primary" style="line-height: 1;"></i> Edit
</a>
@endcan
@can('show_sales')
<a href="{{ route('sales.show', $data->id) }}" class="dropdown-item">
<i class="bi bi-eye mr-2" style="line-height: 1;"></i> Details
<i class="bi bi-eye mr-2 text-info" style="line-height: 1;"></i> Details
</a>
@endcan
@can('delete_sales')
@ -19,7 +19,7 @@
if (confirm('Are you sure? It will delete the dNPata permanently!')) {
document.getElementById('destroy{{ $data->id }}').submit()
}">
<i class="bi bi-trash mr-2" style="line-height: 1;"></i> Delete
<i class="bi bi-trash mr-2 text-danger" style="line-height: 1;"></i> Delete
<form id="destroy{{ $data->id }}" class="d-none" action="{{ route('sales.destroy', $data->id) }}" method="POST">
@csrf
@method('delete')

View File

@ -0,0 +1,133 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sale Details</title>
<link rel="stylesheet" href="{{ public_path('b3/bootstrap.min.css') }}">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div style="text-align: center;margin-bottom: 25px;">
<img width="180" src="{{ public_path('images/logo-dark.png') }}" alt="Logo">
<h4 style="margin-bottom: 20px;">
<span>Reference::</span> <strong>{{ $sale->reference }}</strong>
</h4>
</div>
<div class="card">
<div class="card-body">
<div class="row mb-4">
<div class="col-xs-4 mb-3 mb-md-0">
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Company Info:</h4>
<div><strong>{{ settings()->company_name }}</strong></div>
<div>{{ settings()->company_address }}</div>
<div>Email: {{ settings()->company_email }}</div>
<div>Phone: {{ settings()->company_phone }}</div>
</div>
<div class="col-xs-4 mb-3 mb-md-0">
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Customer Info:</h4>
<div><strong>{{ $customer->customer_name }}</strong></div>
<div>{{ $customer->address }}</div>
<div>Email: {{ $customer->customer_email }}</div>
<div>Phone: {{ $customer->customer_phone }}</div>
</div>
<div class="col-xs-4 mb-3 mb-md-0">
<h4 class="mb-2" style="border-bottom: 1px solid #dddddd;padding-bottom: 10px;">Invoice Info:</h4>
<div>Invoice: <strong>#90-98792</strong></div>
<div>Date: {{ \Carbon\Carbon::parse($sale->date)->format('d M, Y') }}</div>
<div>
Status: <strong>{{ $sale->status }}</strong>
</div>
<div>
Payment Status: <strong>{{ $sale->payment_status }}</strong>
</div>
</div>
</div>
<div class="table-responsive-sm" style="margin-top: 30px;">
<table class="table table-striped">
<thead>
<tr>
<th class="align-middle">Product</th>
<th class="align-middle">Net Unit Price</th>
<th class="align-middle">Stock</th>
<th class="align-middle">Quantity</th>
<th class="align-middle">Discount</th>
<th class="align-middle">Tax</th>
<th class="align-middle">Sub Total</th>
</tr>
</thead>
<tbody>
@foreach($sale->saleDetails as $item)
<tr>
<td class="align-middle">
{{ $item->product_name }} <br>
<span class="badge badge-success">
{{ $item->product_code }}
</span>
</td>
<td class="align-middle">{{ format_currency($item->unit_price) }}</td>
<td class="align-middle">
<span class="badge badge-info">{{ $item->product->product_quantity }}</span>
</td>
<td class="align-middle">
{{ $item->quantity }}
</td>
<td class="align-middle">
{{ format_currency($item->product_discount_amount) }}
</td>
<td class="align-middle">
{{ format_currency($item->product_tax_amount) }}
</td>
<td class="align-middle">
{{ format_currency($item->sub_total) }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="row">
<div class="col-xs-4 col-xs-offset-8">
<table class="table">
<tbody>
<tr>
<td class="left"><strong>Discount ({{ $sale->discount_percentage }}%)</strong></td>
<td class="right">{{ format_currency($sale->discount_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Tax ({{ $sale->tax_percentage }}%)</strong></td>
<td class="right">{{ format_currency($sale->tax_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Shipping)</strong></td>
<td class="right">{{ format_currency($sale->shipping_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Grand Total</strong></td>
<td class="right"><strong>{{ format_currency($sale->total_amount) }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,140 @@
@extends('layouts.app')
@section('title', 'Sales Details')
@section('breadcrumb')
<ol class="breadcrumb border-0 m-0">
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ route('sales.index') }}">Sales</a></li>
<li class="breadcrumb-item active">Details</li>
</ol>
@endsection
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header d-flex flex-wrap align-items-center">
<div>
Reference: <strong>{{ $sale->reference }}</strong>
</div>
<a target="_blank" class="btn btn-sm btn-secondary mfs-auto mfe-1 d-print-none" href="{{ route('sales.pdf', $sale->id) }}">
<i class="bi bi-printer"></i> Print
</a>
<a target="_blank" class="btn btn-sm btn-info mfe-1 d-print-none" href="{{ route('sales.pdf', $sale->id) }}">
<i class="bi bi-save"></i> Save
</a>
</div>
<div class="card-body">
<div class="row mb-4">
<div class="col-sm-4 mb-3 mb-md-0">
<h5 class="mb-2 border-bottom pb-2">Company Info:</h5>
<div><strong>{{ settings()->company_name }}</strong></div>
<div>{{ settings()->company_address }}</div>
<div>Email: {{ settings()->company_email }}</div>
<div>Phone: {{ settings()->company_phone }}</div>
</div>
<div class="col-sm-4 mb-3 mb-md-0">
<h5 class="mb-2 border-bottom pb-2">Customer Info:</h5>
<div><strong>{{ $customer->customer_name }}</strong></div>
<div>{{ $customer->address }}</div>
<div>Email: {{ $customer->customer_email }}</div>
<div>Phone: {{ $customer->customer_phone }}</div>
</div>
<div class="col-sm-4 mb-3 mb-md-0">
<h5 class="mb-2 border-bottom pb-2">Invoice Info:</h5>
<div>Invoice: <strong>#90-98792</strong></div>
<div>Date: {{ \Carbon\Carbon::parse($sale->date)->format('d M, Y') }}</div>
<div>
Status: <strong>{{ $sale->status }}</strong>
</div>
<div>
Payment Status: <strong>{{ $sale->payment_status }}</strong>
</div>
</div>
</div>
<div class="table-responsive-sm">
<table class="table table-striped">
<thead>
<tr>
<th class="align-middle">Product</th>
<th class="align-middle">Net Unit Price</th>
<th class="align-middle">Stock</th>
<th class="align-middle">Quantity</th>
<th class="align-middle">Discount</th>
<th class="align-middle">Tax</th>
<th class="align-middle">Sub Total</th>
</tr>
</thead>
<tbody>
@foreach($sale->saleDetails as $item)
<tr>
<td class="align-middle">
{{ $item->product_name }} <br>
<span class="badge badge-success">
{{ $item->product_code }}
</span>
</td>
<td class="align-middle">{{ format_currency($item->unit_price) }}</td>
<td class="align-middle">
<span class="badge badge-info">{{ $item->product->product_quantity }}</span>
</td>
<td class="align-middle">
{{ $item->quantity }}
</td>
<td class="align-middle">
{{ format_currency($item->product_discount_amount) }}
</td>
<td class="align-middle">
{{ format_currency($item->product_tax_amount) }}
</td>
<td class="align-middle">
{{ format_currency($item->sub_total) }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="row">
<div class="col-lg-4 col-sm-5 ml-md-auto">
<table class="table">
<tbody>
<tr>
<td class="left"><strong>Discount ({{ $sale->discount_percentage }}%)</strong></td>
<td class="right">{{ format_currency($sale->discount_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Tax ({{ $sale->tax_percentage }}%)</strong></td>
<td class="right">{{ format_currency($sale->tax_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Shipping)</strong></td>
<td class="right">{{ format_currency($sale->shipping_amount) }}</td>
</tr>
<tr>
<td class="left"><strong>Grand Total</strong></td>
<td class="right"><strong>{{ format_currency($sale->total_amount) }}</strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -13,6 +13,18 @@
Route::group(['middleware' => 'auth'], function () {
Route::get('/sales/pdf/{id}', function ($id) {
$sale = \Modules\Sale\Entities\Sale::findOrFail($id);
$customer = \Modules\People\Entities\Customer::findOrFail($sale->customer_id);
$pdf = \PDF::loadView('sale::print', [
'sale' => $sale,
'customer' => $customer,
])->setPaper('a4');
return $pdf->stream('sale-'. $sale->reference .'.pdf');
})->name('sales.pdf');
Route::resource('sales', 'SaleController');
});

View File

@ -22,7 +22,7 @@ class CreateSettingsTable extends Migration
$table->integer('default_currency_id');
$table->string('default_currency_position');
$table->string('notification_email');
$table->string('footer_text');
$table->text('footer_text');
$table->text('company_address');
$table->timestamps();
});

View File

@ -22,7 +22,7 @@ class SettingDatabaseSeeder extends Seeder
'notification_email' => 'notification@test.com',
'default_currency_id' => 1,
'default_currency_position' => 'prefix',
'footer_text' => 'Triangle Pos &copy; 2021',
'footer_text' => 'Triangle Pos © 2021 || Developed by <strong><a target="_blank" href="https://fahim.codes">Fahim Anzam</a></strong>',
'company_address' => 'Tangail, Bangladesh'
]);
}

View File

@ -81,7 +81,7 @@
<div class="col-lg-6">
<div class="form-group">
<label for="footer_text">Footer Text <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="footer_text" value="{!! $settings->footer_text !!}">
<textarea rows="1" name="footer_text" class="form-control">{!! $settings->footer_text !!}</textarea>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
<footer class="c-footer">
<div>{!! settings()->footer_text !!} || Developed by <strong><a target="_blank" href="https://fahim.codes">Fahim Anzam</a></strong></div>
<div>{!! settings()->footer_text !!}</div>
<div class="mfs-auto d-md-down-none">Powered by&nbsp;<a href="https://laravel.com" target="_blank">Laravel</a></div>
</footer>

View File

@ -16,6 +16,19 @@
</a>
</li>
<li class="c-header-nav-item dropdown d-md-down-none mx-2">
<a class="c-header-nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
<i class="bi bi-bell" style="font-size: 20px;"></i>
<span class="badge badge-pill badge-danger">0</span>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-lg pt-0">
<div class="dropdown-header bg-light"><strong>You have 0 notification!</strong></div>
<a class="dropdown-item" href="#">
No Notification...
</a>
</div>
</li>
<li class="c-header-nav-item dropdown">
<a class="c-header-nav-link" data-toggle="dropdown" href="#" role="button"
aria-haspopup="true" aria-expanded="false">

View File

@ -13,7 +13,7 @@
<div class="table-responsive">
<table class="table table-bordered">
<thead class="thead-dark">
<tr class="align-middle">
<tr>
<th class="align-middle">Product</th>
<th class="align-middle">Net Unit Price</th>
<th class="align-middle">Stock</th>