Skip to content

Commit

Permalink
fix invoice and expense
Browse files Browse the repository at this point in the history
  • Loading branch information
itsemon245 committed Apr 26, 2024
1 parent 0eab5a0 commit 15bc87c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 41 deletions.
22 changes: 10 additions & 12 deletions app/Http/Controllers/Backend/Invoice/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ public function store(StoreInvoiceRequest $request)
$fiscalYear = FiscalYear::where('year', $request->year)->first();
$fiscalYear = $fiscalYear === null ? FiscalYear::create(['year' => $request->year]) : $fiscalYear;
// dd($fiscalYear);
if ($request->hasFile('header_image')) {
$header_image = saveImage($request->image, 'invoices', 'invoice');
} else {
$header_image = Invoice::first()->header_image;
}
// if ($request->hasFile('header_image')) {
// $header_image = saveImage($request->image, 'invoices', 'invoice');
// } else {
// $header_image = Invoice::first()->header_image;
// }
$invoice = Invoice::create([
'client_id' => $request->client,
'header_image' => $header_image,
'reference_no' => $request->reference,
'note' => $request->note,
'payment_note' => $request->payment_note,
Expand Down Expand Up @@ -218,14 +217,13 @@ public function update(UpdateInvoiceRequest $request, Invoice $invoice)
$fiscalYear = $fiscalYear === null ? FiscalYear::create(['year' => $request->year]) : $fiscalYear;

// dd($fiscalYear);
if ($request->hasFile('header_image')) {
$header_image = saveImage($request->image, 'invoices', 'invoice');
} else {
$header_image = Invoice::first()->header_image;
}
// if ($request->hasFile('header_image')) {
// $header_image = saveImage($request->image, 'invoices', 'invoice');
// } else {
// $header_image = Invoice::first()->header_image;
// }
$invoice->update([
'client_id' => $request->client,
'header_image' => $header_image,
'reference_no' => $request->reference,
'note' => $request->note,
'payment_note' => $request->payment_note,
Expand Down
31 changes: 16 additions & 15 deletions resources/views/backend/expense/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
width: 100% !important;
}
}
@page{
@page {
margin: 1rem;
}
</style>
Expand Down Expand Up @@ -71,10 +72,10 @@ class="mb-1 btn-secondary btn-sm d-print-none">Back</x-backend.ui.button>
<tbody>
<tr>
<td colspan="7">
@if (app('setting')->basic->header_image)
@isset(app('setting')->basic->header_image)
<img style="object-fit: cover; max-width:100%;height:200px;"
src="{{ asset('storage/' . app('setting')->basic->header_image) }}" alt="">
@endif
@endisset
</td>
</tr>
<tr>
Expand Down Expand Up @@ -144,11 +145,11 @@ class="rounded w-75 rounded-3 float-end"
</tr>
<tr>
<td colspan="7">
@if (app('setting')->basic->footer_image)
@isset(app('setting')->basic->footer_image)
<img style="object-fit: cover; max-width:100%;height:200px;"
src="{{ asset('storage/' . app('setting')->basic->footer_image) }}"
alt="">
@endif
@endisset
</td>
</tr>
<tr style="border-bottom: 0px solid transparent;">
Expand Down Expand Up @@ -176,10 +177,10 @@ class="print-btn d-print-none btn-sm btn-info float-end"
class="row justify-content-center">
@csrf
<div class="col-md-12 ">
@if (app('setting')->basic->header_image)
@isset(app('setting')->basic->footer_image)
<img style="object-fit: cover; max-width:100%;height:200px;"
src="{{ asset('storage/' . app('setting')->basic->header_image) }}" alt="">
@endif
@endisset
</div>
<div class="col-md-6 col-xl-4">
<x-form.selectize class="mb-3" id="category" name="category" placeholder="Choose Category..."
Expand Down Expand Up @@ -236,8 +237,8 @@ class="rounded w-100 h-100 w-xl-75 rounded-3 float-end" style="max-width: 300px;
<tr>
<td>1</td>
<td>
<x-form.text-area class="" placehoder="Description"
name="descriptions[]" rows="2"></x-form.text-area>
<x-form.text-area class="" placehoder="Description" name="descriptions[]"
rows="2"></x-form.text-area>
</td>
<td style="max-width: 100px;">
<x-backend.form.text-input class="mb-3 amounts" type="number"
Expand All @@ -259,13 +260,14 @@ class="p-1 mdi mdi-plus bg-soft-success me-1 text-success rounded-circle"></span
</div>
</div>
</div>
@if (app('setting')->basic->footer_image)
@isset(app('setting')->basic->footer_image)
<img style="object-fit: cover; max-width:100%;height:200px;"
src="{{ asset('storage/' . app('setting')->basic->footer_image) }}" alt="">
@endif
@endisset
<div class="col-12 col-md-12 col-xl-8 mt-3">
<x-backend.ui.button class="btn-primary float-end fw-bold">Submit</x-backend.ui.button>
<input type="submit" value="Submit & Print" name="print" class="fw-bold float-end me-2 btn btn-blue rounded rounded-2 waves-effect waves-light" />
<input type="submit" value="Submit & Print" name="print"
class="fw-bold float-end me-2 btn btn-blue rounded rounded-2 waves-effect waves-light" />
</div>
</div>

Expand Down Expand Up @@ -363,14 +365,13 @@ function calcTotal() {
})
});
</script>

@endpush
@if (session()->has('print'))
@push('customJs')
<script>
$(document).ready(function () {
$(document).ready(function() {
window.print()
});
});
</script>
@endpush
@endif
Expand Down
46 changes: 32 additions & 14 deletions resources/views/backend/invoice/createInvoice.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,30 @@
<div>
<div class="row">
{{-- {{ dd($basic->header_image) }} --}}
<div class="d-flex border my-5 justify-content-center">
<img style="object-fit: cover; max-width:1240px;height:250px;" src="{{ asset('storage/'. app('setting')->basic->header_image) }}" alt="">
</div>
@isset($basic->header_image)
<div class="d-flex border my-5 justify-content-center">
<img style="object-fit: cover; max-width:1240px;height:250px;"
src="{{ asset('storage/' . app('setting')->basic->header_image) }}" alt="">
</div>
@else
<div class="p-5 text-center">
No Header Image found
</div>
@endisset
</div>
<div class="row">
<div class="col-sm-4 col-md-3">
<div class="pe-2 mb-2">
<select class="mb-2 tail-select" id="client" name="client"
placeholder="Select Client..." label="Bill To" required>
@foreach ($clients as $client)
<option data-description="{{"<div class='fw-normal'>Company: $client->company_name,</br>Phone: $client->phone,</br> TIN: $client->tin, Ref: $client->ref_no, </br> Circle: $client->circle </div>"}}" value="{{ $client->id }}">{{ $client->name }}</option>
<option
data-description="{{ "<div class='fw-normal'>Company: $client->company_name,</br>Phone: $client->phone,</br> TIN: $client->tin, Ref: $client->ref_no, </br> Circle: $client->circle </div>" }}"
value="{{ $client->id }}">{{ $client->name }}</option>
@endforeach
</select>
<a href="{{ route('client.create') }}" class="text-blue mt-2" style="font-weight: 500;">Create
<a href="{{ route('client.create') }}" class="text-blue mt-2"
style="font-weight: 500;">Create
New
Client</a>
</div>
Expand Down Expand Up @@ -199,13 +209,21 @@
</div>

<div class="row">
<div class="d-flex border my-5 justify-content-center">
<img style="object-fit: cover; max-width:1240px;height:250px;" src="{{asset('storage/'.app('setting')->basic->footer_image)}}" alt="">
</div>
@isset($basic->footer_image)
<div class="d-flex border my-5 justify-content-center">
<img style="object-fit: cover; max-width:1240px;height:250px;"
src="{{ asset('storage/' . app('setting')->basic->footer_image) }}" alt="">
</div>
@else
<div class="p-5 text-center">
No Footer Image found
</div>
@endisset
</div>

<button type="submit" class="btn btn-primary waves-effect waves-light mt-2 me-2 fw-bold">Submit</button>
<input type="submit" class="btn btn-success waves-effect waves-light mt-2 fw-bold" name="print" value="Submit & Print"/>
<input type="submit" class="btn btn-success waves-effect waves-light mt-2 fw-bold" name="print"
value="Submit & Print" />

</form>

Expand All @@ -216,18 +234,18 @@

@push('customJs')
<script>
$(document).ready(function () {
$('#client').on('change', function(e){
let url = "{{route('api.get.client', ':CLIENT')}}"
$(document).ready(function() {
$('#client').on('change', function(e) {
let url = "{{ route('api.get.client', ':CLIENT') }}"
url = url.replace(':CLIENT', e.target.value)
$.ajax({
type: "get",
url: url,
success: function (response) {
success: function(response) {
$('input[name="reference"]').val(response.client.ref_no)
}
});
})
});
</script>
@endpush
@endpush

0 comments on commit 15bc87c

Please sign in to comment.