mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
fix dashbord & using FROM_MAIL_ADDRESS issues
This commit is contained in:
@ -36,7 +36,8 @@ class DashboardController extends Controller
|
|||||||
$start = Carbon::now();
|
$start = Carbon::now();
|
||||||
$end = Carbon::now();
|
$end = Carbon::now();
|
||||||
$terms = explode('-', $fiscalYear);
|
$terms = explode('-', $fiscalYear);
|
||||||
if ($terms[0] < $start->month) {
|
|
||||||
|
if ($terms[0] <= $start->month) {
|
||||||
$startDate->month($terms[0])->startOfMonth();
|
$startDate->month($terms[0])->startOfMonth();
|
||||||
$start->month($terms[0])->startOfMonth();
|
$start->month($terms[0])->startOfMonth();
|
||||||
$end->month($terms[0])->endOfMonth();
|
$end->month($terms[0])->endOfMonth();
|
||||||
@ -93,6 +94,7 @@ class DashboardController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$start->subMonth()->endOfMonth();
|
$start->subMonth()->endOfMonth();
|
||||||
|
|
||||||
$salesTotal = Invoice::whereCompany($request->header('company'))
|
$salesTotal = Invoice::whereCompany($request->header('company'))
|
||||||
->whereBetween(
|
->whereBetween(
|
||||||
'invoice_date',
|
'invoice_date',
|
||||||
|
|||||||
@ -168,10 +168,6 @@ class EstimatesController extends Controller
|
|||||||
$data['user'] = User::find($userId)->toArray();
|
$data['user'] = User::find($userId)->toArray();
|
||||||
$data['company'] = Company::find($estimate->company_id);
|
$data['company'] = Company::find($estimate->company_id);
|
||||||
$email = $data['user']['email'];
|
$email = $data['user']['email'];
|
||||||
$notificationEmail = CompanySetting::getSetting(
|
|
||||||
'notification_email',
|
|
||||||
$request->header('company')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@ -179,13 +175,13 @@ class EstimatesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notificationEmail) {
|
if (!config('mail.from.name')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'notification_email_does_not_exist'
|
'error' => 'from_email_does_not_exist'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new EstimatePdf($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
$estimate = Estimate::with([
|
$estimate = Estimate::with([
|
||||||
@ -340,10 +336,6 @@ class EstimatesController extends Controller
|
|||||||
$data['company'] = Company::find($estimate->company_id);
|
$data['company'] = Company::find($estimate->company_id);
|
||||||
|
|
||||||
$email = $data['user']['email'];
|
$email = $data['user']['email'];
|
||||||
$notificationEmail = CompanySetting::getSetting(
|
|
||||||
'notification_email',
|
|
||||||
$request->header('company')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@ -351,13 +343,13 @@ class EstimatesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notificationEmail) {
|
if (!config('mail.from.name')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'notification_email_does_not_exist'
|
'error' => 'from_email_does_not_exist'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new EstimatePdf($data));
|
||||||
|
|
||||||
if ($estimate->status == Estimate::STATUS_DRAFT) {
|
if ($estimate->status == Estimate::STATUS_DRAFT) {
|
||||||
$estimate->status = Estimate::STATUS_SENT;
|
$estimate->status = Estimate::STATUS_SENT;
|
||||||
|
|||||||
@ -167,11 +167,6 @@ class InvoicesController extends Controller
|
|||||||
$data['user'] = User::find($request->user_id)->toArray();
|
$data['user'] = User::find($request->user_id)->toArray();
|
||||||
$data['company'] = Company::find($invoice->company_id);
|
$data['company'] = Company::find($invoice->company_id);
|
||||||
|
|
||||||
$notificationEmail = CompanySetting::getSetting(
|
|
||||||
'notification_email',
|
|
||||||
$request->header('company')
|
|
||||||
);
|
|
||||||
|
|
||||||
$email = $data['user']['email'];
|
$email = $data['user']['email'];
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
@ -180,13 +175,13 @@ class InvoicesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notificationEmail) {
|
if (!config('mail.from.name')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'notification_email_does_not_exist'
|
'error' => 'from_email_does_not_exist'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new invoicePdf($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = Invoice::with(['items', 'user', 'invoiceTemplate', 'taxes'])->find($invoice->id);
|
$invoice = Invoice::with(['items', 'user', 'invoiceTemplate', 'taxes'])->find($invoice->id);
|
||||||
@ -408,10 +403,6 @@ class InvoicesController extends Controller
|
|||||||
$data['user'] = User::find($userId)->toArray();
|
$data['user'] = User::find($userId)->toArray();
|
||||||
$data['company'] = Company::find($invoice->company_id);
|
$data['company'] = Company::find($invoice->company_id);
|
||||||
$email = $data['user']['email'];
|
$email = $data['user']['email'];
|
||||||
$notificationEmail = CompanySetting::getSetting(
|
|
||||||
'notification_email',
|
|
||||||
$request->header('company')
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@ -419,13 +410,13 @@ class InvoicesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notificationEmail) {
|
if (!config('mail.from.name')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'notification_email_does_not_exist'
|
'error' => 'from_email_does_not_exist'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new invoicePdf($data));
|
||||||
|
|
||||||
if ($invoice->status == Invoice::STATUS_DRAFT) {
|
if ($invoice->status == Invoice::STATUS_DRAFT) {
|
||||||
$invoice->status = Invoice::STATUS_SENT;
|
$invoice->status = Invoice::STATUS_SENT;
|
||||||
|
|||||||
@ -12,17 +12,14 @@ class EstimatePdf extends Mailable
|
|||||||
|
|
||||||
public $data = [];
|
public $data = [];
|
||||||
|
|
||||||
public $notificationEmail = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($data, $notificationEmail)
|
public function __construct($data)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->notificationEmail = $notificationEmail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +29,6 @@ class EstimatePdf extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
return $this->from($this->notificationEmail)->markdown('emails.send.estimate', ['data', $this->data]);
|
return $this->markdown('emails.send.estimate', ['data', $this->data]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,17 +12,14 @@ class invoicePdf extends Mailable
|
|||||||
|
|
||||||
public $data = [];
|
public $data = [];
|
||||||
|
|
||||||
public $notificationEmail = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* Create a new message instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($data, $notificationEmail)
|
public function __construct($data)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->notificationEmail = $notificationEmail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +29,6 @@ class invoicePdf extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
return $this->from($this->notificationEmail)->markdown('emails.send.invoice', ['data', $this->data]);
|
return $this->markdown('emails.send.invoice', ['data', $this->data]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,13 +13,13 @@ export const loadData = ({ commit, dispatch, state }, params) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getChart = ({ commit, dispatch, state }) => {
|
// export const getChart = ({ commit, dispatch, state }) => {
|
||||||
return new Promise((resolve, reject) => {
|
// return new Promise((resolve, reject) => {
|
||||||
window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
|
// window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
|
||||||
commit(types.SET_INITIAL_DATA, response.data)
|
// commit(types.SET_INITIAL_DATA, response.data)
|
||||||
resolve(response)
|
// resolve(response)
|
||||||
}).catch((err) => {
|
// }).catch((err) => {
|
||||||
reject(err)
|
// reject(err)
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -398,7 +398,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.loadChart()
|
|
||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -422,11 +421,6 @@ export default {
|
|||||||
'markEstimateAsSent': 'markAsSent'
|
'markEstimateAsSent': 'markAsSent'
|
||||||
}),
|
}),
|
||||||
|
|
||||||
async loadChart () {
|
|
||||||
await this.$store.dispatch('dashboard/getChart')
|
|
||||||
this.isLoaded = true
|
|
||||||
},
|
|
||||||
|
|
||||||
async loadData (params) {
|
async loadData (params) {
|
||||||
await this.$store.dispatch('dashboard/loadData', params)
|
await this.$store.dispatch('dashboard/loadData', params)
|
||||||
this.isLoaded = true
|
this.isLoaded = true
|
||||||
@ -434,7 +428,7 @@ export default {
|
|||||||
|
|
||||||
async removeEstimate (id) {
|
async removeEstimate (id) {
|
||||||
this.id = id
|
this.id = id
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$tc('estimates.confirm_delete', 1),
|
text: this.$tc('estimates.confirm_delete', 1),
|
||||||
icon: '/assets/icon/trash-solid.svg',
|
icon: '/assets/icon/trash-solid.svg',
|
||||||
@ -462,7 +456,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async convertInToinvoice (id) {
|
async convertInToinvoice (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('estimates.confirm_conversion'),
|
text: this.$t('estimates.confirm_conversion'),
|
||||||
icon: '/assets/icon/file-alt-solid.svg',
|
icon: '/assets/icon/file-alt-solid.svg',
|
||||||
@ -483,7 +477,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async onMarkAsSent (id) {
|
async onMarkAsSent (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('estimates.confirm_mark_as_sent'),
|
text: this.$t('estimates.confirm_mark_as_sent'),
|
||||||
icon: '/assets/icon/check-circle-solid.svg',
|
icon: '/assets/icon/check-circle-solid.svg',
|
||||||
@ -505,7 +499,7 @@ export default {
|
|||||||
|
|
||||||
async removeInvoice (id) {
|
async removeInvoice (id) {
|
||||||
this.id = id
|
this.id = id
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$tc('invoices.confirm_delete'),
|
text: this.$tc('invoices.confirm_delete'),
|
||||||
icon: '/assets/icon/trash-solid.svg',
|
icon: '/assets/icon/trash-solid.svg',
|
||||||
@ -525,7 +519,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async sendInvoice (id) {
|
async sendInvoice (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('invoices.confirm_send'),
|
text: this.$t('invoices.confirm_send'),
|
||||||
icon: '/assets/icon/paper-plane-solid.svg',
|
icon: '/assets/icon/paper-plane-solid.svg',
|
||||||
@ -552,7 +546,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async sentInvoice (id) {
|
async sentInvoice (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('invoices.invoice_mark_as_sent'),
|
text: this.$t('invoices.invoice_mark_as_sent'),
|
||||||
icon: '/assets/icon/check-circle-solid.svg',
|
icon: '/assets/icon/check-circle-solid.svg',
|
||||||
@ -573,7 +567,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async onMarkAsAccepted (id) {
|
async onMarkAsAccepted (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('estimates.confirm_mark_as_accepted'),
|
text: this.$t('estimates.confirm_mark_as_accepted'),
|
||||||
icon: '/assets/icon/check-circle-solid.svg',
|
icon: '/assets/icon/check-circle-solid.svg',
|
||||||
@ -595,7 +589,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async onMarkAsRejected (id) {
|
async onMarkAsRejected (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('estimates.confirm_mark_as_rejected'),
|
text: this.$t('estimates.confirm_mark_as_rejected'),
|
||||||
icon: '/assets/icon/times-circle-solid.svg',
|
icon: '/assets/icon/times-circle-solid.svg',
|
||||||
@ -617,7 +611,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async sendEstimate (id) {
|
async sendEstimate (id) {
|
||||||
swal({
|
window.swal({
|
||||||
title: this.$t('general.are_you_sure'),
|
title: this.$t('general.are_you_sure'),
|
||||||
text: this.$t('estimates.confirm_send_estimate'),
|
text: this.$t('estimates.confirm_send_estimate'),
|
||||||
icon: '/assets/icon/paper-plane-solid.svg',
|
icon: '/assets/icon/paper-plane-solid.svg',
|
||||||
|
|||||||
Reference in New Issue
Block a user