Label reminder activity records

This commit is contained in:
Hillel Coren 2017-01-05 12:46:03 +02:00
parent b6b5ba154d
commit 6ff1c79db3
13 changed files with 60 additions and 29 deletions

View File

@ -17,14 +17,20 @@ class InvoiceInvitationWasEmailed extends Event
*/
public $invitation;
/**
* @var String
*/
public $notes;
/**
* Create a new event instance.
*
* @param Invitation $invitation
*/
public function __construct(Invitation $invitation)
public function __construct(Invitation $invitation, $notes)
{
$this->invitation = $invitation;
$this->notes = $notes;
}
}

View File

@ -15,14 +15,20 @@ class QuoteInvitationWasEmailed extends Event
*/
public $invitation;
/**
* @var String
*/
public $notes;
/**
* Create a new event instance.
*
* @param Invitation $invitation
*/
public function __construct(Invitation $invitation)
public function __construct(Invitation $invitation, $notes)
{
$this->invitation = $invitation;
$this->notes = $notes;
}
}

View File

@ -43,8 +43,8 @@ class DashboardController extends BaseController
$expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll);
$tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll);
$showBlueVinePromo = ! $account->company->bluevine_status
&& env('BLUEVINE_PARTNER_UNIQUE_ID')
$showBlueVinePromo = env('BLUEVINE_PARTNER_UNIQUE_ID')
&& ! $account->company->bluevine_status
&& $account->created_at <= date( 'Y-m-d', strtotime( '-1 month' ));
$showWhiteLabelExpired = Utils::isSelfHost() && $account->company->hasExpiredPlan(PLAN_WHITE_LABEL);

View File

@ -196,7 +196,8 @@ class ActivityListener
ACTIVITY_TYPE_EMAIL_INVOICE,
false,
false,
$event->invitation
$event->invitation,
$event->notes
);
}
@ -294,7 +295,8 @@ class ActivityListener
ACTIVITY_TYPE_EMAIL_QUOTE,
false,
false,
$event->invitation
$event->invitation,
$event->notes
);
}

View File

@ -395,14 +395,14 @@ class Invoice extends EntityModel implements BalanceAffecting
/**
* @param bool $notify
*/
public function markInvitationsSent($notify = false)
public function markInvitationsSent($notify = false, $reminder = false)
{
if ( ! $this->relationLoaded('invitations')) {
$this->load('invitations');
}
foreach ($this->invitations as $invitation) {
$this->markInvitationSent($invitation, false, $notify);
$this->markInvitationSent($invitation, false, $notify, $reminder);
}
}
@ -426,7 +426,7 @@ class Invoice extends EntityModel implements BalanceAffecting
* @param bool $messageId
* @param bool $notify
*/
public function markInvitationSent($invitation, $messageId = false, $notify = true)
public function markInvitationSent($invitation, $messageId = false, $notify = true, $notes = false)
{
if (!$this->isSent()) {
$this->invoice_status_id = INVOICE_STATUS_SENT;
@ -442,9 +442,9 @@ class Invoice extends EntityModel implements BalanceAffecting
}
if ($this->isType(INVOICE_TYPE_QUOTE)) {
event(new QuoteInvitationWasEmailed($invitation));
event(new QuoteInvitationWasEmailed($invitation, $notes));
} else {
event(new InvoiceInvitationWasEmailed($invitation));
event(new InvoiceInvitationWasEmailed($invitation, $notes));
}
}

View File

@ -206,7 +206,9 @@ trait GeneratesNumbers
public function incrementCounter($entity)
{
if ($entity->isEntityType(ENTITY_CLIENT)) {
$this->client_number_counter += 1;
if ($this->client_number_counter) {
$this->client_number_counter += 1;
}
} elseif ($entity->isType(INVOICE_TYPE_QUOTE) && ! $this->share_counter) {
$this->quote_number_counter += 1;
} else {

View File

@ -32,7 +32,13 @@ class ActivityDatatable extends EntityDatatable
'expense' => $model->expense_public_id ? link_to('/expenses/' . $model->expense_public_id, substr($model->expense_public_notes, 0, 30).'...') : null,
];
return trans("texts.activity_{$model->activity_type_id}", $data);
$str = trans("texts.activity_{$model->activity_type_id}", $data);
if ($model->notes) {
$str .= ' - ' . trans("texts.notes_{$model->notes}");
}
return $str;
}
],
[

View File

@ -107,7 +107,7 @@ class ContactMailer extends Mailer
}
foreach ($invoice->invitations as $invitation) {
$response = $this->sendInvitation($invitation, $invoice, $emailTemplate, $emailSubject, $pdfString, $documentStrings);
$response = $this->sendInvitation($invitation, $invoice, $emailTemplate, $emailSubject, $pdfString, $documentStrings, $reminder);
if ($response === true) {
$sent = true;
}
@ -142,7 +142,8 @@ class ContactMailer extends Mailer
$body,
$subject,
$pdfString,
$documentStrings
$documentStrings,
$reminder
)
{
@ -197,6 +198,7 @@ class ContactMailer extends Mailer
'client' => $client,
'invoice' => $invoice,
'documents' => $documentStrings,
'notes' => $reminder,
];
if ($account->attachPDF()) {

View File

@ -21,11 +21,6 @@ class Mailer
*/
public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = [])
{
// check the username is set
if ( ! env('POSTMARK_API_TOKEN') && ! env('MAIL_USERNAME')) {
return trans('texts.invalid_mail_config');
}
// don't send emails to dummy addresses
if (stristr($toEmail, '@example.com')) {
return true;
@ -89,7 +84,8 @@ class Mailer
$messageId = $json->MessageID;
}
$invoice->markInvitationSent($invitation, $messageId);
$notes = isset($data['notes']) ? $data['notes']: false;
$invoice->markInvitationSent($invitation, $messageId, true, $notes);
}
return true;

View File

@ -10,7 +10,7 @@ use App\Models\Invitation;
class ActivityRepository
{
public function create($entity, $activityTypeId, $balanceChange = 0, $paidToDateChange = 0, $altEntity = null)
public function create($entity, $activityTypeId, $balanceChange = 0, $paidToDateChange = 0, $altEntity = null, $notes = false)
{
if ($entity instanceof Client) {
$client = $entity;
@ -29,6 +29,7 @@ class ActivityRepository
$activity->adjustment = $balanceChange;
$activity->client_id = $client ? $client->id : 0;
$activity->balance = $client ? ($client->balance + $balanceChange) : 0;
$activity->notes = $notes ?: '';
$keyField = $entity->getKeyField();
$activity->$keyField = $entity->id;
@ -53,10 +54,7 @@ class ActivityRepository
} else {
$activity->user_id = $entity->user_id;
$activity->account_id = $entity->account_id;
if ( ! $entity instanceof Invitation) {
$activity->is_system = true;
}
$activity->is_system = true;
}
$activity->token_id = session('token_id');
@ -89,6 +87,7 @@ class ActivityRepository
'activities.is_system',
'activities.balance',
'activities.adjustment',
'activities.notes',
'users.first_name as user_first_name',
'users.last_name as user_last_name',
'users.email as user_email',

View File

@ -35,6 +35,10 @@ class AddInclusiveTaxes extends Migration
$table->text('client_number_pattern')->nullable();
});
Schema::table('activities', function ($table)
{
$table->text('notes')->nullable();
});
}
/**
@ -62,5 +66,10 @@ class AddInclusiveTaxes extends Migration
$table->dropColumn('client_number_counter');
$table->dropColumn('client_number_pattern');
});
Schema::table('activities', function ($table)
{
$table->dropColumn('notes');
});
}
}

View File

@ -2301,6 +2301,9 @@ $LANG = array(
'client_number_help' => 'Specify a prefix or use a custom pattern to dynamically set the client number.',
'next_client_number' => 'The next client number is :number.',
'generated_numbers' => 'Generated Numbers',
'notes_reminder1' => 'First Reminder',
'notes_reminder2' => 'Second Reminder',
'notes_reminder3' => 'Third Reminder',
);

View File

@ -1,6 +1,6 @@
<iframe id="theFrame" style="display:block" frameborder="1" width="100%" height="{{ isset($pdfHeight) ? $pdfHeight : 1180 }}px"></iframe>
<div style="width:100%;background-color:#525659;border:solid 2px #9a9a9a;padding-top:40px;text-align:center">
<canvas id="theCanvas" style="display:none;max-width:100%;border:solid 1px #CCCCCC;"></canvas>
<div id="theCanvasDiv" style="display:none;width:100%;background-color:#525659;border:solid 2px #9a9a9a;padding-top:40px;text-align:center">
<canvas id="theCanvas" style="max-width:100%;border:solid 1px #CCCCCC;"></canvas>
</div>
@if (!Utils::isNinja() || !Utils::isPro())
@ -144,7 +144,7 @@
page.render({canvasContext: context, viewport: viewport});
$('#theFrame').hide();
$('#theCanvas').show();
$('#theCanvasDiv').show();
isRefreshing = false;
if (needsRefresh) {
needsRefresh = false;