fix conflicts and issue with add_number_length migration

This commit is contained in:
Mohit Panjwani
2021-04-12 11:53:03 +05:30
16 changed files with 237 additions and 105 deletions

View File

@@ -78,6 +78,10 @@ class Estimate extends Model implements HasMedia
->orderBy('estimate_number', 'desc')
->first();
// Get number length config
$numberLength = CompanySetting::getSetting('estimate_number_length', request()->header('company'));
$numberLengthText = "%0{$numberLength}d";
if (!$lastOrder) {
// We get here if there is no order at all
// If there is no number set it to 0, which will be 1 at the end.
@@ -94,7 +98,7 @@ class Estimate extends Model implements HasMedia
// the %05d part makes sure that there are always 6 numbers in the string.
// so it adds the missing zero's when needed.
return sprintf('%06d', intval($number) + 1);
return sprintf($numberLengthText, intval($number) + 1);
}
public function emailLogs()
@@ -379,7 +383,7 @@ class Estimate extends Model implements HasMedia
$data['user'] = $this->user->toArray();
$data['company'] = $this->company->toArray();
$data['body'] = $this->getEmailBody($data['body']);
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
$data['attach']['data'] = ($this->getEmailAttachmentSetting()) ? $this->getPDFData() : null;
\Mail::to($data['to'])->send(new SendEstimateMail($data));
@@ -427,6 +431,10 @@ class Estimate extends Model implements HasMedia
$estimateTemplate = EstimateTemplate::find($this->estimate_template_id);
$company = Company::find($this->company_id);
$locale = CompanySetting::getSetting('language', $company->id);
App::setLocale($locale);
$logo = $company->logo_path;
view()->share([
@@ -473,7 +481,7 @@ class Estimate extends Model implements HasMedia
{
$estimateAsAttachment = CompanySetting::getSetting('estimate_email_attachment', $this->company_id);
if($estimateAsAttachment == 'NO') {
if ($estimateAsAttachment == 'NO') {
return false;
}