2019-02-17 11:34:46 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-02-17 11:34:46 +01:00
|
|
|
|
|
|
|
namespace App\DataMapper;
|
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
use App\DataMapper\ClientSettings;
|
|
|
|
use App\DataMapper\CompanySettings;
|
2019-04-29 07:50:08 +02:00
|
|
|
use App\Models\Client;
|
2019-03-02 22:44:08 +01:00
|
|
|
use App\Utils\TranslationHelper;
|
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
/**
|
|
|
|
* ClientSettings
|
2019-04-08 14:43:20 +02:00
|
|
|
*
|
|
|
|
* Client settings are built as a superset of Company Settings
|
|
|
|
*
|
|
|
|
* If no client settings is specified, the default company setting is used.
|
|
|
|
*
|
|
|
|
* Client settings are passed down to the entity level where they can be further customized and then saved
|
|
|
|
* into the settings column of the entity, so there is no need to create additional entity level settings handlers.
|
|
|
|
*
|
2019-02-17 11:34:46 +01:00
|
|
|
*/
|
|
|
|
class ClientSettings extends BaseSettings
|
|
|
|
{
|
2019-03-02 22:44:08 +01:00
|
|
|
/**
|
2019-04-08 14:43:20 +02:00
|
|
|
* Settings which also have a parent company setting
|
2019-03-02 22:44:08 +01:00
|
|
|
*/
|
2019-02-17 11:34:46 +01:00
|
|
|
public $timezone_id;
|
2019-08-28 03:13:10 +02:00
|
|
|
public $date_format;
|
|
|
|
public $datetime_format;
|
2019-03-02 22:44:08 +01:00
|
|
|
public $military_time;
|
|
|
|
public $start_of_week;
|
|
|
|
public $financial_year_start;
|
2019-04-29 00:40:38 +02:00
|
|
|
public $payment_terms;
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
public $language_id;
|
2019-05-16 00:26:21 +02:00
|
|
|
public $precision;
|
2019-03-02 22:44:08 +01:00
|
|
|
public $default_task_rate;
|
|
|
|
public $send_reminders;
|
|
|
|
public $show_tasks_in_portal;
|
|
|
|
public $custom_message_dashboard;
|
|
|
|
public $custom_message_unpaid_invoice;
|
|
|
|
public $custom_message_paid_invoice;
|
|
|
|
public $custom_message_unapproved_quote;
|
|
|
|
public $show_currency_symbol;
|
|
|
|
public $show_currency_code;
|
2019-04-08 14:43:20 +02:00
|
|
|
public $inclusive_taxes;
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-09-18 14:43:37 +02:00
|
|
|
public $custom_invoice_taxes1;
|
|
|
|
public $custom_invoice_taxes2;
|
2019-04-22 01:21:57 +02:00
|
|
|
public $lock_sent_invoices;
|
2019-04-23 14:22:13 +02:00
|
|
|
public $auto_bill;
|
2019-05-14 06:05:05 +02:00
|
|
|
public $auto_archive_invoice;
|
|
|
|
|
2019-04-29 00:40:38 +02:00
|
|
|
/**
|
|
|
|
* Counter Variables
|
2019-05-28 07:55:50 +02:00
|
|
|
*
|
|
|
|
* Currently we have only engineered counters to be implemented at the client level
|
|
|
|
* prefix/patterns and padding are not there yet.
|
2019-04-29 00:40:38 +02:00
|
|
|
*/
|
|
|
|
public $invoice_number_prefix;
|
|
|
|
public $invoice_number_pattern;
|
2019-04-29 07:50:08 +02:00
|
|
|
public $invoice_number_counter;
|
2019-04-29 00:40:38 +02:00
|
|
|
|
|
|
|
public $quote_number_prefix;
|
|
|
|
public $quote_number_pattern;
|
2019-04-29 07:50:08 +02:00
|
|
|
public $quote_number_counter;
|
2019-04-29 14:14:11 +02:00
|
|
|
|
2019-04-29 00:40:38 +02:00
|
|
|
public $credit_number_prefix;
|
|
|
|
public $credit_number_pattern;
|
2019-04-29 07:50:08 +02:00
|
|
|
public $credit_number_counter;
|
2019-04-29 00:40:38 +02:00
|
|
|
|
|
|
|
public $shared_invoice_quote_counter;
|
2019-04-30 08:02:39 +02:00
|
|
|
public $recurring_invoice_number_prefix;
|
|
|
|
|
2019-04-29 14:14:11 +02:00
|
|
|
public $counter_padding;
|
2019-04-29 00:40:38 +02:00
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
/**
|
2019-04-29 02:54:26 +02:00
|
|
|
* Settings which which are unique to client settings
|
2019-03-02 22:44:08 +01:00
|
|
|
*/
|
|
|
|
public $industry_id;
|
|
|
|
public $size_id;
|
2019-08-22 03:58:42 +02:00
|
|
|
|
2019-08-29 14:47:45 +02:00
|
|
|
public $design;
|
2019-09-08 14:13:55 +02:00
|
|
|
|
2019-09-09 13:24:22 +02:00
|
|
|
public $company_gateways;
|
2019-09-18 14:43:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
public $invoice_design_id;
|
|
|
|
public $quote_design_id;
|
|
|
|
public $email_footer;
|
|
|
|
public $email_subject_invoice;
|
|
|
|
public $email_subject_quote;
|
|
|
|
public $email_subject_payment;
|
|
|
|
public $email_template_invoice;
|
|
|
|
public $email_template_quote;
|
|
|
|
public $email_template_payment;
|
|
|
|
public $email_subject_reminder1;
|
|
|
|
public $email_subject_reminder2;
|
|
|
|
public $email_subject_reminder3;
|
|
|
|
public $email_template_reminder1;
|
|
|
|
public $email_template_reminder2;
|
|
|
|
public $email_template_reminder3;
|
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
parent::__construct($obj);
|
|
|
|
}
|
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
/**
|
2019-03-02 22:44:08 +01:00
|
|
|
*
|
|
|
|
* Default Client Settings scaffold
|
|
|
|
*
|
2019-02-17 11:34:46 +01:00
|
|
|
* @return \stdClass
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public static function defaults() : \stdClass
|
|
|
|
{
|
|
|
|
|
|
|
|
return (object)[
|
2019-04-29 07:50:08 +02:00
|
|
|
'entity' => Client::class,
|
2019-04-29 00:40:38 +02:00
|
|
|
'industry_id' => NULL,
|
|
|
|
'size_id' => NULL,
|
2019-02-17 11:34:46 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
/**
|
|
|
|
* Merges settings from Company to Client
|
|
|
|
*
|
|
|
|
* @param \stdClass $company_settings
|
|
|
|
* @param \stdClass $client_settings
|
|
|
|
* @return \stdClass of merged settings
|
|
|
|
*/
|
2019-04-17 08:20:32 +02:00
|
|
|
public static function buildClientSettings($company_settings, $client_settings)
|
2019-03-02 22:44:08 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
foreach($client_settings as $key => $value)
|
|
|
|
{
|
|
|
|
|
2019-04-24 12:01:40 +02:00
|
|
|
if(!isset($client_settings->{$key}) && property_exists($company_settings, $key)) {
|
2019-03-02 22:44:08 +01:00
|
|
|
$client_settings->{$key} = $company_settings->{$key};
|
2019-04-24 12:01:40 +02:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2019-04-08 14:43:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
return $client_settings;
|
|
|
|
}
|
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
}
|
|
|
|
|