diff --git a/app/Constants.php b/app/Constants.php index d5d88a153b95..8ed02d2f1332 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -49,20 +49,20 @@ if (! defined('APP_NAME')) { define('ENTITY_PROPOSAL_INVITATION', 'proposal_invitation'); $permissionEntities = [ - ENTITY_PROPOSAL, - ENTITY_EXPENSE, - ENTITY_PROJECT, - ENTITY_VENDOR, - ENTITY_PRODUCT, - ENTITY_TASK, - ENTITY_QUOTE, - ENTITY_CREDIT, - ENTITY_PAYMENT, - ENTITY_CONTACT, - ENTITY_INVOICE, ENTITY_CLIENT, - ENTITY_RECURRING_INVOICE, + //ENTITY_CONTACT, + ENTITY_CREDIT, + ENTITY_EXPENSE, + ENTITY_INVOICE, + ENTITY_PAYMENT, + ENTITY_PRODUCT, + ENTITY_PROJECT, + ENTITY_PROPOSAL, + ENTITY_QUOTE, 'reports', + ENTITY_TASK, + ENTITY_VENDOR, + ENTITY_RECURRING_INVOICE, ]; define('PERMISSION_ENTITIES', json_encode($permissionEntities)); diff --git a/app/Policies/GenericEntityPolicy.php b/app/Policies/GenericEntityPolicy.php index 24cfad36178d..c8a7750bbecf 100644 --- a/app/Policies/GenericEntityPolicy.php +++ b/app/Policies/GenericEntityPolicy.php @@ -81,6 +81,37 @@ class GenericEntityPolicy return false; } + /** + * @param User $user + * @param $item - entity name or object + * + * @return bool + */ + + public static function edit(User $user, $item) + { + if (! static::checkModuleEnabled($user, $item)) + return false; + + + $entityType = is_string($item) ? $item : $item->getEntityType(); + return $user->hasPermission('edit_' . $entityType) || $user->owns($item); + } + + /** + * @param User $user + * @param $item - entity name or object + * @return bool + */ + + private static function checkModuleEnabled(User $user, $item) + { + $entityType = is_string($item) ? $item : $item->getEntityType(); + return $user->account->isModuleEnabled($entityType); + } + + + private static function className($entityType) { if (! Utils::isNinjaProd()) { diff --git a/database/seeds/CountriesSeeder.php b/database/seeds/CountriesSeeder.php index 426deec1a2da..7e7cf5bf924a 100644 --- a/database/seeds/CountriesSeeder.php +++ b/database/seeds/CountriesSeeder.php @@ -162,6 +162,9 @@ class CountriesSeeder extends Seeder 'thousand_separator' => ',', 'decimal_separator' => '.', ], + 'SR' => [ // Suriname + 'swap_currency_symbol' => true, + ], 'UY' => [ 'swap_postal_code' => true, ], diff --git a/database/seeds/CurrenciesSeeder.php b/database/seeds/CurrenciesSeeder.php index 561138fb470e..78fa38d2235a 100644 --- a/database/seeds/CurrenciesSeeder.php +++ b/database/seeds/CurrenciesSeeder.php @@ -85,6 +85,7 @@ class CurrenciesSeeder extends Seeder ['name' => 'Georgian Lari', 'code' => 'GEL', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => ','], ['name' => 'Qatari Riyal', 'code' => 'QAR', 'symbol' => 'QR', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Honduran Lempira', 'code' => 'HNL', 'symbol' => 'L', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Surinamese Dollar', 'code' => 'SRD', 'symbol' => 'SRD', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], ]; foreach ($currencies as $currency) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 63790dddd6cf..8996450aafec 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2410,6 +2410,7 @@ $LANG = array( 'currency_georgian_lari' => 'Georgian Lari', 'currency_qatari_riyal' => 'Qatari Riyal', 'currency_honduran_lempira' => 'Honduran Lempira', + 'currency_surinamese_dollar' => 'Surinamese Dollar', 'review_app_help' => 'We hope you\'re enjoying using the app.
If you\'d consider :link we\'d greatly appreciate it!', 'writing_a_review' => 'writing a review', diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index c7f94c012152..b532168f77ab 100644 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -102,6 +102,9 @@ ->check(is_array($permissions) && in_array('edit_' . $permissionEntity, $permissions, FALSE) ? true : false) !!} @endforeach + + + @@ -148,10 +151,12 @@ .replace(']',"") .replace('[',""); //get entity name - $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox + setCheckboxEditValue(entity); + setContactPermission(); }); + /* * * Checks state of View/Edit checkbox, will enable/disable check/uncheck @@ -168,10 +173,27 @@ .replace(']',"") .replace('[',""); //get entity name - $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox + setCheckboxEditValue(entity); + setContactPermission(); - if(!$('#view_' + entity).is(':checked')) { - $('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state. + }); + + $('#edit_client, #view_client, #create_client').change(function() { + switch($(this).val()) { + case 'create_client': + $('#create_contact').prop('disabled', false); //set state of edit checkbox + $('#create_contact').prop('checked', $('#create_client').is(':checked') ); + break; + + case 'view_client': + $('#view_contact').prop('disabled', false); //set state of edit checkbox + $('#view_contact').prop('checked', $('#view_client').is(':checked') ); + break; + + case 'edit_client': + $('#edit_contact').prop('disabled', false); //set state of edit checkbox + $('#edit_contact').prop('checked', $('#edit_client').is(':checked') ); + break; } }); @@ -192,17 +214,28 @@ $('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox - if(!$('#view_' + entity).is(':checked')) { - $('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state. - } - - $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox - + setCheckboxEditValue(entity); + setContactPermission(); }); - }); + function setCheckboxEditValue(entity) { + if(!$('#view_' + entity).is(':checked')) { + $('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state. + } + + $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox + + } + + function setContactPermission() { + + $('#view_contact').prop('checked', $('#view_client').is(':checked') ); + $('#edit_contact').prop('checked', $('#edit_client').is(':checked') ); + $('#create_contact').prop('checked', $('#create_client').is(':checked') ); + + } @stop