1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Improvements to client import/export

This commit is contained in:
Hillel Coren 2017-08-03 20:07:16 +03:00
parent 1d1621f11d
commit 0493848d7e
5 changed files with 75 additions and 77 deletions

View File

@ -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();
}

View File

@ -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',
];

View File

@ -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'),
];
});
}

View File

@ -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',
);

View File

@ -14,7 +14,8 @@
<td>{{ trans('texts.id_number') }}</td>
<td>{{ trans('texts.vat_number') }}</td>
<td>{{ trans('texts.website') }}</td>
<td>{{ trans('texts.phone') }}</td>
<td>{{ trans('texts.work_phone') }}</td>
<td>{{ trans('texts.currency') }}</td>
<td>{{ trans('texts.public_notes') }}</td>
<td>{{ trans('texts.private_notes') }}</td>
@if ($account->custom_client_label1)
@ -23,6 +24,16 @@
@if ($account->custom_client_label2)
<td>{{ $account->custom_client_label2 }}</td>
@endif
<td>{{ trans('texts.first_name') }}</td>
<td>{{ trans('texts.last_name') }}</td>
<td>{{ trans('texts.email') }}</td>
<td>{{ trans('texts.phone') }}</td>
@if ($account->custom_contact_label1)
<td>{{ $account->custom_contact_label1 }}</td>
@endif
@if ($account->custom_contact_label2)
<td>{{ $account->custom_contact_label2 }}</td>
@endif
</tr>
@foreach ($clients as $client)
@ -43,6 +54,7 @@
<td>{{ $client->vat_number }}</td>
<td>{{ $client->website }}</td>
<td>{{ $client->work_phone }}</td>
<td>{{ $client->currency ? $client->currency->code : '' }}</td>
<td>{{ $client->public_notes }}</td>
<td>{{ $client->private_notes }}</td>
@if ($account->custom_client_label1)
@ -51,5 +63,15 @@
@if ($account->custom_client_label2)
<td>{{ $client->custom_value2 }}</td>
@endif
<td>{{ $client->contacts[0]->first_name }}</td>
<td>{{ $client->contacts[0]->last_name }}</td>
<td>{{ $client->contacts[0]->email }}</td>
<td>{{ $client->contacts[0]->phone }}</td>
@if ($account->custom_contact_label1)
<td>{{ $client->contacts[0]->custom_value1 }}</td>
@endif
@if ($account->custom_contact_label2)
<td>{{ $client->contacts[0]->custom_value2 }}</td>
@endif
</tr>
@endforeach