diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index bef47f2386a6..046682cc7ee2 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -170,7 +170,7 @@ class ExportController extends BaseController if ($request->input('include') === 'all' || $request->input('clients')) { $data['clients'] = Client::scope() - ->with('user', 'contacts', 'country') + ->with('user', 'contacts', 'country', 'currency') ->withArchived() ->get(); } diff --git a/app/Models/Client.php b/app/Models/Client.php index 31009197ff9a..f5c8be3d8fdf 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -54,54 +54,7 @@ class Client extends EntityModel 'public_notes', ]; - /** - * @var string - */ - public static $fieldName = 'name'; - /** - * @var string - */ - public static $fieldPhone = 'work_phone'; - /** - * @var string - */ - public static $fieldAddress1 = 'address1'; - /** - * @var string - */ - public static $fieldAddress2 = 'address2'; - /** - * @var string - */ - public static $fieldCity = 'city'; - /** - * @var string - */ - public static $fieldState = 'state'; - /** - * @var string - */ - public static $fieldPostalCode = 'postal_code'; - /** - * @var string - */ - public static $fieldNotes = 'notes'; - /** - * @var string - */ - public static $fieldCountry = 'country'; - /** - * @var string - */ - public static $fieldWebsite = 'website'; - /** - * @var string - */ - public static $fieldVatNumber = 'vat_number'; - /** - * @var string - */ - public static $fieldIdNumber = 'id_number'; + /** * @return array @@ -109,22 +62,28 @@ class Client extends EntityModel public static function getImportColumns() { return [ - self::$fieldName, - self::$fieldPhone, - self::$fieldAddress1, - self::$fieldAddress2, - self::$fieldCity, - self::$fieldState, - self::$fieldPostalCode, - self::$fieldCountry, - self::$fieldNotes, - self::$fieldWebsite, - self::$fieldVatNumber, - self::$fieldIdNumber, - Contact::$fieldFirstName, - Contact::$fieldLastName, - Contact::$fieldPhone, - Contact::$fieldEmail, + 'name', + 'work_phone', + 'address1', + 'address2', + 'city', + 'state', + 'postal_code', + 'public_notes', + 'private_notes', + 'country', + 'website', + 'currency', + 'vat_number', + 'id_number', + 'custom1', + 'custom2', + 'contact_first_name', + 'contact_last_name', + 'contact_phone', + 'contact_email', + 'contact_custom1', + 'contact_custom2', ]; } @@ -134,10 +93,11 @@ class Client extends EntityModel public static function getImportMap() { return [ - 'first' => 'first_name', - 'last' => 'last_name', - 'email' => 'email', - 'mobile|phone' => 'phone', + 'first' => 'contact_first_name', + 'last' => 'contact_last_name', + 'email' => 'contact_email', + 'work|office' => 'work_phone', + 'mobile|phone' => 'contact_phone', 'name|organization' => 'name', 'apt|street2|address2' => 'address2', 'street|address|address1' => 'address1', @@ -145,8 +105,10 @@ class Client extends EntityModel 'state|province' => 'state', 'zip|postal|code' => 'postal_code', 'country' => 'country', - 'note' => 'notes', + 'public' => 'public_notes', + 'private|note' => 'private_notes', 'site|website' => 'website', + 'currency' => 'currency', 'vat' => 'vat_number', 'number' => 'id_number', ]; diff --git a/app/Ninja/Import/CSV/ClientTransformer.php b/app/Ninja/Import/CSV/ClientTransformer.php index b53a714530af..07ccab2ea5d4 100644 --- a/app/Ninja/Import/CSV/ClientTransformer.php +++ b/app/Ninja/Import/CSV/ClientTransformer.php @@ -26,22 +26,29 @@ class ClientTransformer extends BaseTransformer 'name' => $this->getString($data, 'name'), 'work_phone' => $this->getString($data, 'work_phone'), 'address1' => $this->getString($data, 'address1'), + 'address2' => $this->getString($data, 'address2'), 'city' => $this->getString($data, 'city'), 'state' => $this->getString($data, 'state'), 'postal_code' => $this->getString($data, 'postal_code'), - 'private_notes' => $this->getString($data, 'notes'), + 'public_notes' => $this->getString($data, 'public_notes'), + 'private_notes' => $this->getString($data, 'private_notes'), 'website' => $this->getString($data, 'website'), 'vat_number' => $this->getString($data, 'vat_number'), 'id_number' => $this->getString($data, 'id_number'), + 'custom_value1' => $this->getString($data, 'custom1'), + 'custom_value2' => $this->getString($data, 'custom2'), 'contacts' => [ [ - 'first_name' => $this->getString($data, 'first_name'), - 'last_name' => $this->getString($data, 'last_name'), - 'email' => $this->getString($data, 'email'), - 'phone' => $this->getString($data, 'phone'), + 'first_name' => $this->getString($data, 'contact_first_name'), + 'last_name' => $this->getString($data, 'contact_last_name'), + 'email' => $this->getString($data, 'contact_email'), + 'phone' => $this->getString($data, 'contact_phone'), + 'custom_value1' => $this->getString($data, 'contact_custom1'), + 'custom_value2' => $this->getString($data, 'contact_custom2'), ], ], 'country_id' => isset($data->country) ? $this->getCountryId($data->country) : null, + 'currency_code' => $this->getString($data, 'currency'), ]; }); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 2d938a6a96aa..9a34b368b0a7 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2392,7 +2392,14 @@ $LANG = array( 'tax1' => 'First Tax', 'tax2' => 'Second Tax', 'fee_help' => 'Gateway fees are the costs charged for access to the financial networks that handle the processing of online payments.', - 'format_export' => 'Exporting format' + 'format_export' => 'Exporting format', + 'custom1' => 'First Custom', + 'custom2' => 'Second Custom', + 'contact_first_name' => 'Contact First Name', + 'contact_last_name' => 'Contact Last Name', + 'contact_custom1' => 'Contact First Custom', + 'contact_custom2' => 'Contact Second Custom', + 'currency' => 'Currency', ); diff --git a/resources/views/export/clients.blade.php b/resources/views/export/clients.blade.php index ad4f7f38033c..316bb5cdbf0f 100644 --- a/resources/views/export/clients.blade.php +++ b/resources/views/export/clients.blade.php @@ -14,7 +14,8 @@ {{ trans('texts.id_number') }} {{ trans('texts.vat_number') }} {{ trans('texts.website') }} - {{ trans('texts.phone') }} + {{ trans('texts.work_phone') }} + {{ trans('texts.currency') }} {{ trans('texts.public_notes') }} {{ trans('texts.private_notes') }} @if ($account->custom_client_label1) @@ -23,6 +24,16 @@ @if ($account->custom_client_label2) {{ $account->custom_client_label2 }} @endif + {{ trans('texts.first_name') }} + {{ trans('texts.last_name') }} + {{ trans('texts.email') }} + {{ trans('texts.phone') }} + @if ($account->custom_contact_label1) + {{ $account->custom_contact_label1 }} + @endif + @if ($account->custom_contact_label2) + {{ $account->custom_contact_label2 }} + @endif @foreach ($clients as $client) @@ -43,6 +54,7 @@ {{ $client->vat_number }} {{ $client->website }} {{ $client->work_phone }} + {{ $client->currency ? $client->currency->code : '' }} {{ $client->public_notes }} {{ $client->private_notes }} @if ($account->custom_client_label1) @@ -51,5 +63,15 @@ @if ($account->custom_client_label2) {{ $client->custom_value2 }} @endif + {{ $client->contacts[0]->first_name }} + {{ $client->contacts[0]->last_name }} + {{ $client->contacts[0]->email }} + {{ $client->contacts[0]->phone }} + @if ($account->custom_contact_label1) + {{ $client->contacts[0]->custom_value1 }} + @endif + @if ($account->custom_contact_label2) + {{ $client->contacts[0]->custom_value2 }} + @endif @endforeach