Browse Source

Add payment print view and Add terbilang package

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
39bf5dc7bf
  1. 123
      app/Http/Controllers/PaymentsController.php
  2. 7
      composer.json
  3. 48
      composer.lock
  4. 2
      config/app.php
  5. 1
      resources/lang/id/payment.php
  6. 2
      resources/views/layouts/partials/sidebar.blade.php
  7. 79
      resources/views/payments/pdf.blade.php
  8. 1
      resources/views/payments/show.blade.php
  9. 3
      routes/web/payments.php

123
app/Http/Controllers/PaymentsController.php

@ -2,84 +2,83 @@
namespace App\Http\Controllers;
use App\Entities\Payments\Payment;
use App\Entities\Payments\PaymentsRepository;
use App\Entities\Users\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\Payments\CreateRequest;
use App\Http\Requests\Payments\DeleteRequest;
use App\Http\Requests\Payments\UpdateRequest;
use Illuminate\Http\Request;
class PaymentsController extends Controller {
class PaymentsController extends Controller
{
private $repo;
private $repo;
public function __construct(PaymentsRepository $repo)
{
$this->repo = $repo;
}
public function __construct(PaymentsRepository $repo)
{
$this->repo = $repo;
}
public function index(Request $request)
{
$payments = $this->repo->getPayments($request->only('q', 'customer_id'));
$usersList = User::pluck('name', 'id')->all();
return view('payments.index', compact('payments', 'usersList'));
}
public function index(Request $request)
{
$payments = $this->repo->getPayments($request->only('q', 'customer_id'));
$usersList = User::pluck('name', 'id')->all();
return view('payments.index',compact('payments', 'usersList'));
}
public function create()
{
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersAndVendorsList();
return view('payments.create', compact('projects', 'customers'));
}
public function create()
{
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersAndVendorsList();
return view('payments.create',compact('projects','customers'));
}
public function store(CreateRequest $request)
{
$payment = $this->repo->create($request->except('_token'));
flash()->success(trans('payment.created'));
return redirect()->route('projects.payments', $payment->project_id);
}
public function store(CreateRequest $req)
{
$payment = $this->repo->create($req->except('_token'));
flash()->success(trans('payment.created'));
return redirect()->route('projects.payments', $payment->project_id);
}
public function show(Payment $payment)
{
return view('payments.show', compact('payment'));
}
public function show($paymentId)
{
$payment = $this->repo->requireById($paymentId);
return view('payments.show', compact('payment'));
}
public function edit(Payment $payment)
{
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersAndVendorsList();
return view('payments.edit', compact('payment', 'projects', 'customers'));
}
public function edit($paymentId)
{
$payment = $this->repo->requireById($paymentId);
$projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersAndVendorsList();
return view('payments.edit',compact('payment','projects','customers'));
}
public function update(UpdateRequest $request, $paymentId)
{
$payment = $this->repo->update($request->except(['_method','_token']), $paymentId);
flash()->success(trans('payment.updated'));
return redirect()->route('payments.show', $paymentId);
}
public function update(UpdateRequest $req, $paymentId)
{
$payment = $this->repo->update($req->except(['_method','_token']), $paymentId);
flash()->success(trans('payment.updated'));
return redirect()->route('payments.show', $paymentId);
}
public function delete(Payment $payment)
{
return view('payments.delete', compact('payment'));
}
public function delete($paymentId)
{
$payment = $this->repo->requireById($paymentId);
return view('payments.delete', compact('payment'));
}
public function destroy(DeleteRequest $request, Payment $payment)
{
$projectId = $payment->project_id;
if ($payment->id == $request->get('payment_id')) {
$payment->delete();
flash()->success(trans('payment.deleted'));
} else {
flash()->error(trans('payment.undeleted'));
}
public function destroy(DeleteRequest $req, $paymentId)
{
$payment = $this->repo->requireById($paymentId);
$projectId = $payment->project_id;
if ($paymentId == $req->get('payment_id'))
{
$payment->delete();
flash()->success(trans('payment.deleted'));
}
else
flash()->error(trans('payment.undeleted'));
return redirect()->route('projects.payments', $projectId);
}
return redirect()->route('projects.payments', $projectId);
}
public function pdf(Payment $payment)
{
return view('payments.pdf', compact('payment'));
}
}

7
composer.json

@ -6,14 +6,15 @@
"type": "project",
"require": {
"php": ">=7.0.0",
"backup-manager/laravel": "^1.0",
"barryvdh/laravel-dompdf": "^0.8.0",
"intervention/image": "^2.3",
"laravel/framework": "5.5.*",
"luthfi/formfield": "^0.2.0",
"laracasts/flash": "~2",
"laracasts/presenter": "^0.2.1",
"backup-manager/laravel": "^1.0",
"laravel/framework": "5.5.*",
"luthfi/formfield": "^0.2.0",
"maatwebsite/excel": "~2.1.0",
"riskihajar/terbilang": "^1.2",
"spatie/laravel-fractal": "^5.0"
},
"require-dev": {

48
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "6c61f297d80073ba97f8138e4ebd7a31",
"content-hash": "eb58ad569b92d48f00e1a5774b96dbca",
"packages": [
{
"name": "backup-manager/backup-manager",
@ -1907,6 +1907,52 @@
"time": "2017-09-22T20:46:04+00:00"
},
{
"name": "riskihajar/terbilang",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/riskihajar/terbilang.git",
"reference": "8294ee3a854bd71e16f5e9c1516e8b5eebc1f497"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/riskihajar/terbilang/zipball/8294ee3a854bd71e16f5e9c1516e8b5eebc1f497",
"reference": "8294ee3a854bd71e16f5e9c1516e8b5eebc1f497",
"shasum": ""
},
"require": {
"illuminate/support": "~4.2||~5",
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Riskihajar\\Terbilang\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "riskihajar",
"email": "riskihajar@gmail.com",
"homepage": "http://riskihajar.com"
}
],
"description": "Convert number & date to words in any language for Laravel 4 | 5",
"homepage": "https://github.com/riskihajar/terbilang",
"keywords": [
"date to words",
"laravel",
"number to roman",
"number to words",
"terbilang"
],
"time": "2017-09-08T07:28:55+00:00"
},
{
"name": "sabberworm/php-css-parser",
"version": "8.1.0",
"source": {

2
config/app.php

@ -163,6 +163,7 @@ return [
Laracasts\Flash\FlashServiceProvider::class,
Luthfi\FormField\FormFieldServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Riskihajar\Terbilang\TerbilangServiceProvider::class,
Spatie\Fractal\FractalServiceProvider::class,
],
@ -218,6 +219,7 @@ return [
'FormField' => Luthfi\FormField\FormFieldFacade::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Terbilang' => Riskihajar\Terbilang\Facades\Terbilang::class,
],

1
resources/lang/id/payment.php

@ -20,6 +20,7 @@ return [
'deleted' => 'Hapus data Pembayaran telah berhasil.',
'undeleted' => 'Data Pembayaran gagal dihapus.',
'search' => 'Cari Pembayaran Project',
'print' => 'Cetak Kuitansi',
// Attrubutes
'description' => 'Deskripsi',

2
resources/views/layouts/partials/sidebar.blade.php

@ -9,7 +9,7 @@
<div class="navbar-default sidebar hidden-print" role="navigation">
<div class="sidebar-nav navbar-collapse">
<a class="navbar-brand text-center" title="Home | {{ Option::get('app_tagline', 'Laravel app description') }}" href="{{ route('home') }}">
{!! Html::image(url('assets/imgs/logo.png'),'Logo ' . Option::get('app_name','Laravel'), ['class' => 'sidebar-logo']) !!}
{!! Html::image(url('assets/imgs/logo.png'), 'Logo '.Option::get('app_name','Laravel'), ['class' => 'sidebar-logo']) !!}
<div class="small" style="margin-top:10px">{{ Option::get('app_name','Laravel') }}</div>
</a>
<ul class="nav" id="side-menu">

79
resources/views/payments/pdf.blade.php

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ trans('payment.print') }}</title>
<style>
html {
margin: 10px 20px 0px 20px;
}
table.receipt-table {
/*border: 1px solid #aaa;*/
border-collapse: collapse;
font-size:14px;
max-width: 750px;
}
table.receipt-table td {
padding: 5px;
}
</style>
</head>
<body>
<table class="receipt-table">
<tbody>
<tr>
<td style="width:120px;">
{{ Html::image(url('assets/imgs/logo.png'), '', ['style' => 'width:100%']) }}
</td>
<td style="width:350px">
<div style="width:280px">
<h4 style="margin:0px; border-bottom: 3px; font-size: 21.5px">JasaWebsiteBanjarmasin.com</h4>
<div style="font-size:13px">Jasa Pembuatan Website dan Aplikasi Berbasis Web</div>
<hr style="margin: 2px 0">
<div style="font-size:11px">
Jln. Pramuka, Gg. Mawar, Rt. 09, No. 60, Kel. Pemurus Luar<br>
Kec. Banjarmasin Timur, Kota Banjarmasin,
Kalsel - 70249,<br>
Telp. 0817 532 654 / 0823 5035 5470
</div>
</div>
</td>
<td style="width:250px; text-align: center;">
<h3 style="margin: 3px 0; font-size: 24px">Bukti Pembayaran</h3>
{{-- <p>No. Invoice: __________</p> --}}
</td>
</tr>
<tr>
<td>Terima Dari : </td>
<td colspan="2" style="border-bottom: 1px solid #ccc;">{{ $payment->customer->name }}</td>
</tr>
<tr style="vertical-align: top;">
<td>Uang Sejumlah : </td>
<td colspan="2" style="border-bottom: 1px solid #ccc;height: 35px">
{{ ucwords(Terbilang::make($payment->amount)) }} Rupiah
</td>
</tr>
<tr style="vertical-align: top;">
<td>Untuk Pembayaran :</td>
<td colspan="2" style="border-bottom: 1px solid #ccc;height: 35px">
{{ $payment->description }}
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td style="text-align: center;">
Banjarmasin, {{ dateId($payment->date) }}
</td>
</tr>
<tr>
<td style="font-size: 20px; font-weight: bold; text-align: center;height: 80px;vertical-align: bottom;">Terbilang</td>
<td style="font-size: 20px; font-weight: bold; vertical-align: bottom;">
{{ formatRp($payment->amount) }},-
</td>
<td style="text-align: center;vertical-align: bottom; font-weight: bold;">JasaWebsiteBanjarmasin.com</td>
</tr>
</tbody>
</table>
</body>
</html>

1
resources/views/payments/show.blade.php

@ -6,6 +6,7 @@
@include('payments.partials.breadcrumb')
<h1 class="page-header">
<div class="pull-right">
{!! link_to_route('payments.pdf', trans('payment.print'), [$payment->id], ['class' => 'btn btn-success']) !!}
{!! link_to_route('payments.index', 'Lihat Semua Pembayaran', [], ['class' => 'btn btn-default']) !!}
</div>
{{ trans('payment.show') }}

3
routes/web/payments.php

@ -4,6 +4,7 @@ Route::group(['middleware' => ['web','role:admin']], function() {
/**
* Payments Routes
*/
Route::get('payments/{id}/delete', ['as'=>'payments.delete', 'uses'=>'PaymentsController@delete']);
Route::get('payments/{payment}/pdf', ['as'=>'payments.pdf', 'uses'=>'PaymentsController@pdf']);
Route::get('payments/{payment}/delete', ['as'=>'payments.delete', 'uses'=>'PaymentsController@delete']);
Route::resource('payments','PaymentsController');
});
Loading…
Cancel
Save