From 4a3beeeae7c2d4256b80a56d0f85e463e0ab8d83 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 25 Oct 2015 13:08:11 +0200 Subject: [PATCH] Bug fixes --- app/Http/Controllers/AccountController.php | 6 +++++- app/Providers/AppServiceProvider.php | 4 ++++ resources/lang/da/validation.php | 1 + resources/lang/de/validation.php | 3 ++- resources/lang/en/validation.php | 1 + resources/lang/es/validation.php | 3 ++- resources/lang/es_ES/validation.php | 1 + resources/lang/fr/validation.php | 1 + resources/lang/fr_CA/validation.php | 1 + resources/lang/it/validation.php | 1 + resources/lang/nb_NO/validation.php | 1 + resources/lang/nl/validation.php | 1 + resources/lang/pt_BR/validation.php | 1 + resources/lang/sv/validation.php | 1 + resources/views/accounts/invoice_settings.blade.php | 4 ++-- 15 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index a2785e1e0..d4a358ebc 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -476,7 +476,11 @@ class AccountController extends BaseController { if (Auth::user()->account->isPro()) { - $rules = []; + $rules = [ + 'invoice_number_pattern' => 'has_counter', + 'quote_number_pattern' => 'has_counter', + ]; + $user = Auth::user(); $iframeURL = preg_replace('/[^a-zA-Z0-9_\-\:\/\.]/', '', substr(strtolower(Input::get('iframe_url')), 0, MAX_IFRAME_URL_LENGTH)); $iframeURL = rtrim($iframeURL, "/"); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 8cf422da9..07e5f0313 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -144,6 +144,10 @@ class AppServiceProvider extends ServiceProvider { Validator::replacer('less_than', function($message, $attribute, $rule, $parameters) { return str_replace(':value', $parameters[0], $message); }); + + Validator::extend('has_counter', function($attribute, $value, $parameters) { + return !$value || strstr($value, '{$counter}'); + }); } /** diff --git a/resources/lang/da/validation.php b/resources/lang/da/validation.php index 4fb673d7b..6162f3f14 100644 --- a/resources/lang/da/validation.php +++ b/resources/lang/da/validation.php @@ -77,6 +77,7 @@ return array( "has_credit" => "The client does not have enough credit.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/de/validation.php b/resources/lang/de/validation.php index e5199303c..2290a944a 100644 --- a/resources/lang/de/validation.php +++ b/resources/lang/de/validation.php @@ -75,7 +75,8 @@ return array( "has_credit" => "Der Kunde hat nicht genug Guthaben.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', - + "has_counter" => 'The value must contain {$counter}', + /* |-------------------------------------------------------------------------- | Custom Validation Language Lines diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index c43c94cbd..bd46a6106 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -73,6 +73,7 @@ return array( "has_credit" => "The client does not have enough credit.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/es/validation.php b/resources/lang/es/validation.php index d46abe4a1..9d1c2e724 100644 --- a/resources/lang/es/validation.php +++ b/resources/lang/es/validation.php @@ -74,7 +74,8 @@ return array( "has_credit" => "el cliente no tiene crédito suficiente.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', - + "has_counter" => 'The value must contain {$counter}', + /* |-------------------------------------------------------------------------- | Custom Validation Language Lines diff --git a/resources/lang/es_ES/validation.php b/resources/lang/es_ES/validation.php index d46abe4a1..407fe133e 100644 --- a/resources/lang/es_ES/validation.php +++ b/resources/lang/es_ES/validation.php @@ -74,6 +74,7 @@ return array( "has_credit" => "el cliente no tiene crédito suficiente.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index ad7961b57..b32593461 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -75,6 +75,7 @@ return array( "has_credit" => "The client does not have enough credit.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/fr_CA/validation.php b/resources/lang/fr_CA/validation.php index 13f6df0d6..ec1009388 100644 --- a/resources/lang/fr_CA/validation.php +++ b/resources/lang/fr_CA/validation.php @@ -75,6 +75,7 @@ return array( "has_credit" => "Le client n'a pas un crédit suffisant.", "notmasked" => "Les valeurs sont masquées", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/it/validation.php b/resources/lang/it/validation.php index f30a246e2..e250da743 100644 --- a/resources/lang/it/validation.php +++ b/resources/lang/it/validation.php @@ -74,6 +74,7 @@ return array( "has_credit" => "The client does not have enough credit.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/nb_NO/validation.php b/resources/lang/nb_NO/validation.php index dc38eebec..75d5ca3a2 100644 --- a/resources/lang/nb_NO/validation.php +++ b/resources/lang/nb_NO/validation.php @@ -73,6 +73,7 @@ return array( "has_credit" => "Klienten har ikke høy nok kreditt.", "notmasked" => "Verdiene er skjult", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/nl/validation.php b/resources/lang/nl/validation.php index 8cd5c1f11..38e3e49ad 100644 --- a/resources/lang/nl/validation.php +++ b/resources/lang/nl/validation.php @@ -75,6 +75,7 @@ return array( "has_credit" => "De klant heeft niet voldoende krediet.", "notmasked" => "De waarden zijn verborgen", "less_than" => 'Het :attribute moet minder zijn dan :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/pt_BR/validation.php b/resources/lang/pt_BR/validation.php index d998f3fb2..93a51c821 100644 --- a/resources/lang/pt_BR/validation.php +++ b/resources/lang/pt_BR/validation.php @@ -73,6 +73,7 @@ return array( "has_credit" => "O cliente não possui crédito suficiente.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', +"has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/sv/validation.php b/resources/lang/sv/validation.php index 6d0ee4e75..6110162bf 100644 --- a/resources/lang/sv/validation.php +++ b/resources/lang/sv/validation.php @@ -77,6 +77,7 @@ return [ "has_credit" => "The client does not have enough credit.", "notmasked" => "The values are masked", "less_than" => 'The :attribute must be less than :value', + "has_counter" => 'The value must contain {$counter}', /* |-------------------------------------------------------------------------- diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 5f05ff444..f7f2ed174 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -241,9 +241,9 @@