Add client phone to invoice design fields

This commit is contained in:
Hillel Coren 2017-03-29 18:02:36 +03:00
parent 06acbe5460
commit 5ee474035a
4 changed files with 22 additions and 6 deletions

View File

@ -1201,10 +1201,18 @@ class Invoice extends EntityModel implements BalanceAffecting
if (! $this->last_sent_date) { if (! $this->last_sent_date) {
return true; return true;
} else { } else {
$date1 = new DateTime($this->last_sent_date);
$date2 = new DateTime();
$diff = $date2->diff($date1);
$daysSinceLastSent = $diff->format('%a');
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
/*
$date1 = Carbon::parse($this->last_sent_date, $timezone); $date1 = Carbon::parse($this->last_sent_date, $timezone);
$date2 = Carbon::now($timezone); $date2 = Carbon::now($timezone);
$daysSinceLastSent = $date1->diffInDays($date2); $daysSinceLastSent = $date1->diffInDays($date2);
$monthsSinceLastSent = $date1->diffInMonths($date2); $monthsSinceLastSent = $date1->diffInMonths($date2);
*/
if ($daysSinceLastSent == 0) { if ($daysSinceLastSent == 0) {
return false; return false;

View File

@ -39,6 +39,10 @@ trait GeneratesNumbers
$number = $prefix . str_pad($counter, $this->invoice_number_padding, '0', STR_PAD_LEFT); $number = $prefix . str_pad($counter, $this->invoice_number_padding, '0', STR_PAD_LEFT);
} }
if ($entity->recurring_invoice_id) {
$number = $this->recurring_invoice_number_prefix . $number;
}
if ($entity->isEntityType(ENTITY_CLIENT)) { if ($entity->isEntityType(ENTITY_CLIENT)) {
$check = Client::scope(false, $this->id)->whereIdNumber($number)->withTrashed()->first(); $check = Client::scope(false, $this->id)->whereIdNumber($number)->withTrashed()->first();
} else { } else {
@ -66,10 +70,6 @@ trait GeneratesNumbers
} }
} }
if ($entity->recurring_invoice_id) {
$number = $this->recurring_invoice_number_prefix . $number;
}
return $number; return $number;
} }
@ -161,7 +161,8 @@ trait GeneratesNumbers
if (count($matches) > 1) { if (count($matches) > 1) {
$format = $matches[1]; $format = $matches[1];
$search[] = $matches[0]; $search[] = $matches[0];
$date = Carbon::now(session(SESSION_TIMEZONE, DEFAULT_TIMEZONE))->format($format); $date = date_create()->format($format);
//$date = Carbon::now(session(SESSION_TIMEZONE, DEFAULT_TIMEZONE))->format($format);
$replace[] = str_replace($format, $date, $matches[1]); $replace[] = str_replace($format, $date, $matches[1]);
} }

View File

@ -96,14 +96,16 @@ trait PresentsInvoice
'client.client_name', 'client.client_name',
'client.id_number', 'client.id_number',
'client.vat_number', 'client.vat_number',
'client.website',
'client.work_phone',
'client.address1', 'client.address1',
'client.address2', 'client.address2',
'client.city_state_postal', 'client.city_state_postal',
'client.postal_city_state', 'client.postal_city_state',
'client.country', 'client.country',
'client.contact_name',
'client.email', 'client.email',
'client.phone', 'client.phone',
'client.contact_name',
'client.custom_value1', 'client.custom_value1',
'client.custom_value2', 'client.custom_value2',
'.blank', '.blank',
@ -138,6 +140,8 @@ trait PresentsInvoice
list($entityType, $fieldName) = explode('.', $field); list($entityType, $fieldName) = explode('.', $field);
if (substr($fieldName, 0, 6) == 'custom') { if (substr($fieldName, 0, 6) == 'custom') {
$fields[$section][$field] = $labels[$field]; $fields[$section][$field] = $labels[$field];
} elseif (in_array($field, ['client.phone', 'client.email'])) {
$fields[$section][$field] = trans('texts.contact_' . $fieldName);
} else { } else {
$fields[$section][$field] = $labels[$fieldName]; $fields[$section][$field] = $labels[$fieldName];
} }
@ -222,6 +226,7 @@ trait PresentsInvoice
'credit_issued_to', 'credit_issued_to',
'credit_to', 'credit_to',
'your_credit', 'your_credit',
'work_phone',
]; ];
foreach ($fields as $field) { foreach ($fields as $field) {

View File

@ -2456,6 +2456,8 @@ $LANG = array(
'purge_successful' => 'Successfully purged account data', 'purge_successful' => 'Successfully purged account data',
'forbidden' => 'Forbidden', 'forbidden' => 'Forbidden',
'purge_data_message' => 'Warning: This will permanently erase your data, there is no undo.', 'purge_data_message' => 'Warning: This will permanently erase your data, there is no undo.',
'contact_phone' => 'Contact Phone',
'contact_email' => 'Contact Email',
); );