-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Clean up Client Show * Working on Show Client menu action * working on client view permissions * Finishing up Client Statement View * Workig on client settings * add mix manifest * css for client settings * Client Settings * Working on Client Settings * Implement StartupCheck and static seeders * Implement cached statics in view composers * Working on client settings * Payment Terms * Working on Payment Terms View Composer * Payment Terms builder * Client Settings * refactor companies table * Refactor for company settings, move settings to json * Set object cast on settings column of Company table * Fixes for refactor of companies and clients table * Test * Client Settings Datamapper * Client Settings * Default client language * Client Settings * Working on client settings options * Client Settings * Settings Json serialization/deserialization handling
- Loading branch information
Showing
45 changed files
with
3,470 additions
and
1,756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\DataMapper; | ||
|
||
/** | ||
* ClientSettings | ||
*/ | ||
class BaseSettings | ||
{ | ||
/** | ||
* Migrates properties of the datamapper classes when new properties are added | ||
* | ||
* @param \stdClass $object Datamapper settings object | ||
* @return \stdClass $object Datamapper settings object updated | ||
*/ | ||
public function migrate(\stdClass $object) : \stdClass | ||
{ | ||
$properties = self::default(); | ||
|
||
foreach($properties as $property) | ||
{ | ||
if(!property_exists($object, $property)) | ||
$object->{$property} = NULL; | ||
} | ||
|
||
return $object; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\DataMapper; | ||
|
||
/** | ||
* ClientSettings | ||
*/ | ||
class ClientSettings extends BaseSettings | ||
{ | ||
public $timezone_id; | ||
public $language_id; | ||
public $currency_id; | ||
|
||
/** | ||
* @return \stdClass | ||
* | ||
*/ | ||
public static function defaults() : \stdClass | ||
{ | ||
|
||
return (object)[ | ||
'timezone_id' => NULL, | ||
'language_id' => NULL, | ||
'currency_id' => NULL, | ||
'payment_terms' => NULL, | ||
]; | ||
|
||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace App\DataMapper; | ||
|
||
/** | ||
* CompanySettings | ||
*/ | ||
class CompanySettings extends BaseSettings | ||
{ | ||
|
||
public $timezone_id; | ||
public $language_id; | ||
public $currency_id; | ||
public $payment_terms; | ||
public $custom_label1; | ||
public $custom_value1; | ||
public $custom_label2; | ||
public $custom_value2; | ||
public $custom_label3; | ||
public $custom_value3; | ||
public $custom_label4; | ||
public $custom_value5; | ||
public $custom_client_label1; | ||
public $custom_client_label2; | ||
public $custom_client_label3; | ||
public $custom_client_label4; | ||
public $custom_client_contact_label1; | ||
public $custom_client_contact_label2; | ||
public $custom_client_contact_label3; | ||
public $custom_client_contact_label4; | ||
public $custom_invoice_label1; | ||
public $custom_invoice_label2; | ||
public $custom_invoice_label3; | ||
public $custom_invoice_label4; | ||
public $custom_product_label1; | ||
public $custom_product_label2; | ||
public $custom_product_label3; | ||
public $custom_product_label4; | ||
public $custom_task_label1; | ||
public $custom_task_label2; | ||
public $custom_task_label3; | ||
public $custom_task_label4; | ||
public $custom_expense_label1; | ||
public $custom_expense_label2; | ||
public $custom_expense_label3; | ||
public $custom_expense_label4; | ||
public $translations; | ||
|
||
/** | ||
* Cast object values and return entire class | ||
* prevents missing properties from not being returned | ||
* and always ensure an up to date class is returned | ||
* | ||
* @return \stdClass | ||
*/ | ||
public function __construct($obj) | ||
{ | ||
foreach($obj as $key => $value) | ||
$this->{$key} = $value; | ||
} | ||
|
||
/** | ||
* Provides class defaults on init | ||
* @return object | ||
*/ | ||
public static function defaults() : object | ||
{ | ||
$config = json_decode(config('ninja.settings')); | ||
|
||
return (object) [ | ||
'timezone_id' => $config->timezone_id, | ||
'language_id' => $config->language_id, | ||
'currency_id' => $config->currency_id, | ||
'payment_terms' => $config->payment_terms, | ||
'translations' => (object) [], | ||
]; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\Input; | ||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Support\Facades\Session; | ||
use Closure; | ||
|
||
|
||
/** | ||
* Class StartupCheck. | ||
*/ | ||
class StartupCheck | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param Request $request | ||
* @param Closure $next | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
|
||
$cached_tables = unserialize(CACHED_TABLES); | ||
|
||
if (Input::has('clear_cache')) { | ||
Session::flash('message', 'Cache cleared'); | ||
} | ||
foreach ($cached_tables as $name => $class) { | ||
if (Input::has('clear_cache') || ! Cache::has($name)) { | ||
// check that the table exists in case the migration is pending | ||
if (! Schema::hasTable((new $class())->getTable())) { | ||
continue; | ||
} | ||
if ($name == 'paymentTerms') { | ||
$orderBy = 'num_days'; | ||
} elseif ($name == 'fonts') { | ||
$orderBy = 'sort_order'; | ||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) { | ||
$orderBy = 'name'; | ||
} else { | ||
$orderBy = 'id'; | ||
} | ||
$tableData = $class::orderBy($orderBy)->get(); | ||
if ($tableData->count()) { | ||
Cache::forever($name, $tableData); | ||
} | ||
} | ||
} | ||
|
||
$response = $next($request); | ||
|
||
return $response; | ||
} | ||
} |
Oops, something went wrong.