Created quotes, invoices and payments pages for clients

This commit is contained in:
Hillel Coren 2014-11-16 12:41:07 +02:00
parent 113cb6747c
commit 012347afda
10 changed files with 92 additions and 39 deletions

View File

@ -64,7 +64,12 @@ class InvoiceController extends \BaseController {
//$accountId = Auth::user()->account_id;
$search = Input::get('sSearch');
$invitationKey = Session::get('invitation_key');
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->firstOrFail();
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
if (!$invitation || $invitation->is_deleted)
{
return [];
}
$invoice = $invitation->invoice;

View File

@ -77,7 +77,12 @@ class PaymentController extends \BaseController
{
$search = Input::get('sSearch');
$invitationKey = Session::get('invitation_key');
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->with('contact.client')->firstOrFail();
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->with('contact.client')->first();
if (!$invitation)
{
return [];
}
$invoice = $invitation->invoice;
@ -86,10 +91,10 @@ class PaymentController extends \BaseController
return [];
}
$payments = $this->paymentRepo->find($invitation->contact->client->public_id, Input::get('sSearch'));
$payments = $this->paymentRepo->findForContact($invitation->contact->id, Input::get('sSearch'));
return Datatable::query($payments)
->addColumn('invoice_number', function($model) { return $model->invoice_number; })
->addColumn('invoice_number', function($model) { return $model->invitation_key ? link_to('/view/' . $model->invitation_key, $model->invoice_number) : $model->invoice_number; })
->addColumn('transaction_reference', function($model) { return $model->transaction_reference ? $model->transaction_reference : '<i>Manual entry</i>'; })
->addColumn('payment_type', function($model) { return $model->payment_type ? $model->payment_type : ($model->account_gateway_id ? '<i>Online payment</i>' : ''); })
->addColumn('amount', function($model) { return Utils::formatMoney($model->amount, $model->currency_id); })

View File

@ -72,7 +72,12 @@ class QuoteController extends \BaseController {
{
$search = Input::get('sSearch');
$invitationKey = Session::get('invitation_key');
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->firstOrFail();
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
if (!$invitation || $invitation->is_deleted)
{
return [];
}
$invoice = $invitation->invoice;

View File

@ -8,8 +8,8 @@ use Utils;
class PaymentRepository
{
public function find($clientPublicId = null, $filter = null)
{
public function find($clientPublicId = null, $filter = null)
{
$query = \DB::table('payments')
->join('clients', 'clients.id', '=','payments.client_id')
->join('invoices', 'invoices.id', '=','payments.invoice_id')
@ -39,7 +39,37 @@ class PaymentRepository
}
return $query;
}
}
public function findForContact($contactId = null, $filter = null)
{
$query = \DB::table('payments')
->join('clients', 'clients.id', '=','payments.client_id')
->join('invoices', 'invoices.id', '=','payments.invoice_id')
->join('contacts', 'contacts.client_id', '=', 'clients.id')
->leftJoin('invitations', function($join)
{
$join->on('invitations.invoice_id', '=', 'invoices.id')
->on('invitations.contact_id', '=', 'contacts.id');
})
->leftJoin('payment_types', 'payment_types.id', '=', 'payments.payment_type_id')
->where('payments.account_id', '=', \Auth::user()->account_id)
->where('clients.is_deleted', '=', false)
->where('payments.is_deleted', '=', false)
->where('invitations.deleted_at', '=', null)
->where('contacts.id', '=', $contactId)
->select('invitations.invitation_key', 'payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type', 'payments.account_gateway_id');
if ($filter)
{
$query->where(function($query) use ($filter)
{
$query->where('clients.name', 'like', '%'.$filter.'%');
});
}
return $query;
}
public function getErrors($input)
{

View File

@ -1,5 +1,6 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
@ -366,6 +367,23 @@ function uctrans($text)
return ucwords(trans($text));
}
// optional trans: only return the string if it's translated
function otrans($text)
{
$locale = Session::get(SESSION_LOCALE);
if ($locale == 'en')
{
return trans($text);
}
else
{
$string = trans($text);
$english = trans($text, [], 'en');
return $string != $english ? $string : '';
}
}
if (Auth::check() && !Session::has(SESSION_TIMEZONE))
{
@ -423,4 +441,3 @@ if (Auth::check() && Auth::user()->id === 1)
}
*/

View File

@ -45,6 +45,7 @@
/* Set the defaults for DataTables initialisation */
$.extend( true, $.fn.dataTable.defaults, {
"bSortClasses": false,
"sDom": "t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"bInfo": true,

View File

@ -66,7 +66,7 @@
<div class="col-md-7 info">
<div class="col-md-12 alignCenterText" >
{{ trans('texts.payment_title') }}
{{ otrans('texts.payment_title') }}
</div>
<div class="row">
@ -113,10 +113,10 @@
<div class="row">
<h5 class="col-md-12 boldText" >
{{ trans('texts.payment_footer1') }}
{{ otrans('texts.payment_footer1') }}
</h5>
<h5 class="col-md-12 boldText">
{{ trans('texts.payment_footer2') }}
{{ otrans('texts.payment_footer2') }}
</h5>
</div>
@ -141,7 +141,7 @@
<div class="col-md-5">
<div class="col-md-12 alignCenterText" >
{{ trans('texts.balance_due') . ' ' . Utils::formatMoney($amount, $currencyId) }}
&nbsp;<!--{{ trans('texts.balance_due') . ' ' . Utils::formatMoney($amount, $currencyId) }}-->
</div>
<div class="col-md-12">
<div class="card">
@ -189,7 +189,7 @@
{{ Former::text('cvv') }}
</div>
<div>
<h5 class="boldText" style="margin-top: 8%;margin-left: 5%;">{{ trans('texts.payment_cvv') }}</h5>
<h5 class="boldText" style="margin-top: 8%;margin-left: 5%;">{{ otrans('texts.payment_cvv') }}</h5>
</div>
<div class="col-md-6">
<!-- <p><span class="glyphicon glyphicon-credit-card" style="margin-right: 10px;"></span><a href="#">Where Do I find CVV?</a></p> -->

View File

@ -1,7 +1,7 @@
@extends('public.header')
@section('content')
<style type="text/css">
body {
@ -24,6 +24,11 @@
}
tr {border: none;}
td {
padding-top: 16px !important;
padding-bottom: 16px !important;
}
/*th {border-left: 1px solid #d26b26; }*/
th {border-left: 1px solid #FFFFFF; }
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
@ -34,8 +39,9 @@
table.dataTable.no-footer {
border-bottom: none;
}
.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th {
background-color: #fff;
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: #FDFDFD;
}
table.table thead .sorting_asc {
background: url('../images/sort_asc.png') no-repeat 90% 50%;
@ -72,12 +78,6 @@
/* hide table sorting indicators */
table.table thead .sorting { background: url('') no-repeat center right; }
table.dataTable tr.odd td.sorting_1 { background-color: white; }
table.dataTable tr.odd td.sorting_2 { background-color: white; }
table.dataTable tr.odd td.sorting_3 { background-color: white; }
table.dataTable tr.even td.sorting_1 { background-color: white; }
table.dataTable tr.even td.sorting_2 { background-color: white; }
table.dataTable tr.even td.sorting_3 { background-color: white; }
</style>

View File

@ -2882,8 +2882,9 @@ border-bottom: 1px solid #dfe0e1;
table.dataTable.no-footer {
border-bottom: none;
}
.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th {
background-color: #fff;
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: #FDFDFD;
}
table.table thead .sorting_asc {
background: url('css/../images/sort_asc.png') no-repeat 90% 50%;
@ -3117,12 +3118,6 @@ border-top-left-radius: 3px;
/* hide table sorting indicators */
table.table thead .sorting { background: url('') no-repeat center right; }
table.dataTable tr.odd td.sorting_1 { background-color: white; }
table.dataTable tr.odd td.sorting_2 { background-color: white; }
table.dataTable tr.odd td.sorting_3 { background-color: white; }
table.dataTable tr.even td.sorting_1 { background-color: white; }
table.dataTable tr.even td.sorting_2 { background-color: white; }
table.dataTable tr.even td.sorting_3 { background-color: white; }

View File

@ -82,8 +82,9 @@ border-bottom: 1px solid #dfe0e1;
table.dataTable.no-footer {
border-bottom: none;
}
.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th {
background-color: #fff;
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: #FDFDFD;
}
table.table thead .sorting_asc {
background: url('../images/sort_asc.png') no-repeat 90% 50%;
@ -317,12 +318,6 @@ border-top-left-radius: 3px;
/* hide table sorting indicators */
table.table thead .sorting { background: url('') no-repeat center right; }
table.dataTable tr.odd td.sorting_1 { background-color: white; }
table.dataTable tr.odd td.sorting_2 { background-color: white; }
table.dataTable tr.odd td.sorting_3 { background-color: white; }
table.dataTable tr.even td.sorting_1 { background-color: white; }
table.dataTable tr.even td.sorting_2 { background-color: white; }
table.dataTable tr.even td.sorting_3 { background-color: white; }