From ccd7a9f3a76de42ba5abfeaf2c71bbbbb891ec56 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 8 Dec 2013 15:32:49 +0200 Subject: [PATCH] Floats Handling and PDF.js support --- app/controllers/InvoiceController.php | 4 +- app/controllers/PaymentController.php | 2 +- ...11_05_180133_confide_setup_users_table.php | 4 +- app/libraries/utils.php | 16 +- app/views/accounts/settings.blade.php | 6 +- app/views/credits/edit.blade.php | 3 +- app/views/header.blade.php | 10 +- app/views/invoices/edit.blade.php | 73 +- app/views/payments/edit.blade.php | 8 +- public/js/bootstrap-combobox.js | 4 + public/js/compatibility.js | 483 + public/js/pdf.js | 49 + public/js/pdf_viewer.js | 7420 +++ public/js/pdf_viewer.worker.js | 39769 ++++++++++++++++ public/js/script.js | 8 +- 15 files changed, 47814 insertions(+), 45 deletions(-) create mode 100755 public/js/compatibility.js create mode 100755 public/js/pdf.js create mode 100755 public/js/pdf_viewer.js create mode 100755 public/js/pdf_viewer.worker.js diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index fd26459061..bf8afddb51 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -370,7 +370,7 @@ class InvoiceController extends \BaseController { $item->qty = 0; } - $total += intval($item->qty) * floatval($item->cost); + $total += floatval($item->qty) * floatval($item->cost); } if ($action == 'email' && $invoice->invoice_status_id == INVOICE_STATUS_DRAFT) @@ -415,7 +415,7 @@ class InvoiceController extends \BaseController { $invoiceItem->product_key = trim($item->product_key); $invoiceItem->notes = trim($item->notes); $invoiceItem->cost = floatval($item->cost); - $invoiceItem->qty = intval($item->qty); + $invoiceItem->qty = floatval($item->qty); $invoice->invoice_items()->save($invoiceItem); } diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index 038fbb90ef..d1b73cd2b1 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -36,7 +36,7 @@ class PaymentController extends \BaseController $table->addColumn('client_name', function($model) { return link_to('clients/' . $model->client_public_id, $model->client_name); }); } - return $table->addColumn('invoice_number', function($model) { return $model->invoice_public_id ? link_to('invoices/' . $model->invoice_public_id . '/edit', $model->invoice_invoice_number) : ''; }) + return $table->addColumn('invoice_number', function($model) { return $model->invoice_public_id ? link_to('invoices/' . $model->invoice_public_id . '/edit', $model->invoice_number) : ''; }) ->addColumn('amount', function($model) { return '$' . $model->amount; }) ->addColumn('payment_date', function($model) { return Utils::timestampToDateString($model->payment_date); }) ->addColumn('dropdown', function($model) diff --git a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php index 56e8ba9b6e..7b72e3359a 100755 --- a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -256,7 +256,7 @@ class ConfideSetupUsersTable extends Migration { $t->string('product_key'); $t->string('notes'); $t->decimal('cost', 10, 2); - $t->integer('qty'); + $t->decimal('qty', 10, 2); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); @@ -277,7 +277,7 @@ class ConfideSetupUsersTable extends Migration { $t->string('product_key'); $t->string('notes'); $t->decimal('cost', 10, 2); - $t->integer('qty'); + $t->decimal('qty', 10, 2); $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->foreign('product_id')->references('id')->on('products'); diff --git a/app/libraries/utils.php b/app/libraries/utils.php index eb433f0e7a..c5e3139e42 100755 --- a/app/libraries/utils.php +++ b/app/libraries/utils.php @@ -35,23 +35,23 @@ class Utils return $phoneNumber; } - function pluralize($string, $count) + public static function pluralize($string, $count) { $string = str_replace('?', $count, $string); return $count == 1 ? $string : $string . 's'; } - function toArray($data) + public static function toArray($data) { return json_decode(json_encode((array) $data), true); } - function toSpaceCase($camelStr) + public static function toSpaceCase($camelStr) { return preg_replace('/([a-z])([A-Z])/s','$1 $2', $camelStr); } - function timestampToDateTimeString($timestamp) { + public static function timestampToDateTimeString($timestamp) { $tz = Session::get('tz'); if (!$tz) { $tz = 'US/Eastern'; @@ -65,7 +65,7 @@ class Utils return $date->format('l M jS, Y g:ia'); } - function timestampToDateString($timestamp) { + public static function timestampToDateString($timestamp) { $tz = Session::get('tz'); if (!$tz) { $tz = 'US/Eastern'; @@ -93,7 +93,7 @@ class Utils } */ - function toSqlDate($date) + public static function toSqlDate($date) { if (!$date) { @@ -103,7 +103,7 @@ class Utils return DateTime::createFromFormat('m/d/Y', $date); } - function fromSqlDate($date) + public static function fromSqlDate($date) { if (!$date || $date == '0000-00-00') { @@ -113,7 +113,7 @@ class Utils return DateTime::createFromFormat('Y-m-d', $date)->format('m/d/Y'); } - function trackViewed($name, $type) + public static function trackViewed($name, $type) { $url = Request::url(); $viewed = Session::get(RECENTLY_VIEWED); diff --git a/app/views/accounts/settings.blade.php b/app/views/accounts/settings.blade.php index 10aba2fedc..83d9e5fd58 100755 --- a/app/views/accounts/settings.blade.php +++ b/app/views/accounts/settings.blade.php @@ -6,9 +6,6 @@ {{ Former::open()->addClass('col-md-10 col-md-offset-1') }} {{ Former::populate($account) }} - {{ Former::legend('Invoices') }} - {{ Former::textarea('invoice_terms') }} - {{ Former::legend('Payment Gateway') }} @if ($accountGateway) @@ -39,6 +36,9 @@ @endforeach + {{ Former::legend('Invoices') }} + {{ Former::textarea('invoice_terms') }} + {{ Former::actions( Button::lg_primary_submit('Save') ) }} {{ Former::close() }} diff --git a/app/views/credits/edit.blade.php b/app/views/credits/edit.blade.php index a41db7052e..54364fe027 100755 --- a/app/views/credits/edit.blade.php +++ b/app/views/credits/edit.blade.php @@ -9,7 +9,8 @@ {{ Former::open($url)->addClass('col-md-10 col-md-offset-1 main_form')->method($method)->rules(array( - 'amount' => 'required' + 'client' => 'required', + 'amount' => 'required', )); }} @if ($credit) diff --git a/app/views/header.blade.php b/app/views/header.blade.php index e15179c84d..cabd6b9e53 100755 --- a/app/views/header.blade.php +++ b/app/views/header.blade.php @@ -102,7 +102,10 @@ } */ + /* table sorting indicators */ + /*table.table thead .sorting { background: url('images/sort_both.png') no-repeat center right; }*/ + /* table.table thead .sorting, table.table thead .sorting_asc, table.table thead .sorting_desc, @@ -112,14 +115,13 @@ *cursor: hand; } - /*table.table thead .sorting { background: url('images/sort_both.png') no-repeat center right; }*/ table.table thead .sorting_asc { background: url('images/sort_asc.png') no-repeat center right; } table.table thead .sorting_desc { background: url('images/sort_desc.png') no-repeat center right; } table.table thead .sorting_asc_disabled { background: url('images/sort_asc_disabled.png') no-repeat center right; } table.table thead .sorting_desc_disabled { background: url('images/sort_desc_disabled.png') no-repeat center right; } - + */ /* Hover nav */ @@ -195,6 +197,10 @@ border-style: none !important; } + .invoice-table td.td-icon { + vertical-align: middle !important; + } + .fa-bars { cursor: move !important; } diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php index 2d796ae057..2ee9b1c06a 100755 --- a/app/views/invoices/edit.blade.php +++ b/app/views/invoices/edit.blade.php @@ -1,10 +1,18 @@ @extends('header') +@section('head') + @parent + + + +@stop + @section('content')

 

{{ Former::open($url)->method($method)->addClass('main_form')->rules(array( + 'client' => 'required', 'invoice_number' => 'required', 'invoice_date' => 'required', 'product_key' => 'max:14', @@ -55,9 +63,8 @@ - - - + + {{ Former::text('product_key')->useDatalist(Product::getProductKeys($products), 'key')->onkeyup('onChange()') @@ -80,7 +87,7 @@ - +   @@ -145,7 +152,8 @@ - + +