diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 0305dd78..1977c4b3 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -36,7 +36,8 @@ class DashboardController extends Controller $start = Carbon::now(); $end = Carbon::now(); $terms = explode('-', $fiscalYear); - if ($terms[0] < $start->month) { + + if ($terms[0] <= $start->month) { $startDate->month($terms[0])->startOfMonth(); $start->month($terms[0])->startOfMonth(); $end->month($terms[0])->endOfMonth(); @@ -93,6 +94,7 @@ class DashboardController extends Controller } $start->subMonth()->endOfMonth(); + $salesTotal = Invoice::whereCompany($request->header('company')) ->whereBetween( 'invoice_date', diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index f49f6f4b..aec266e1 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -168,10 +168,6 @@ class EstimatesController extends Controller $data['user'] = User::find($userId)->toArray(); $data['company'] = Company::find($estimate->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -179,13 +175,13 @@ class EstimatesController extends Controller ]); } - if (!$notificationEmail) { + if (!config('mail.from.name')) { 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([ @@ -340,10 +336,6 @@ class EstimatesController extends Controller $data['company'] = Company::find($estimate->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -351,13 +343,13 @@ class EstimatesController extends Controller ]); } - if (!$notificationEmail) { + if (!config('mail.from.name')) { 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) { $estimate->status = Estimate::STATUS_SENT; diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 01e4e674..2a3eb089 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -167,11 +167,6 @@ class InvoicesController extends Controller $data['user'] = User::find($request->user_id)->toArray(); $data['company'] = Company::find($invoice->company_id); - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); - $email = $data['user']['email']; if (!$email) { @@ -180,13 +175,13 @@ class InvoicesController extends Controller ]); } - if (!$notificationEmail) { + if (!config('mail.from.name')) { 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); @@ -408,10 +403,6 @@ class InvoicesController extends Controller $data['user'] = User::find($userId)->toArray(); $data['company'] = Company::find($invoice->company_id); $email = $data['user']['email']; - $notificationEmail = CompanySetting::getSetting( - 'notification_email', - $request->header('company') - ); if (!$email) { return response()->json([ @@ -419,13 +410,13 @@ class InvoicesController extends Controller ]); } - if (!$notificationEmail) { + if (!config('mail.from.name')) { 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) { $invoice->status = Invoice::STATUS_SENT; diff --git a/app/Mail/EstimatePdf.php b/app/Mail/EstimatePdf.php index 42e88ee2..b6a4f225 100644 --- a/app/Mail/EstimatePdf.php +++ b/app/Mail/EstimatePdf.php @@ -12,17 +12,14 @@ class EstimatePdf extends Mailable public $data = []; - public $notificationEmail = ''; - /** * Create a new message instance. * * @return void */ - public function __construct($data, $notificationEmail) + public function __construct($data) { $this->data = $data; - $this->notificationEmail = $notificationEmail; } /** @@ -32,6 +29,6 @@ class EstimatePdf extends Mailable */ public function build() { - return $this->from($this->notificationEmail)->markdown('emails.send.estimate', ['data', $this->data]); + return $this->markdown('emails.send.estimate', ['data', $this->data]); } } diff --git a/app/Mail/invoicePdf.php b/app/Mail/invoicePdf.php index a7a4e5a9..3e2645ec 100644 --- a/app/Mail/invoicePdf.php +++ b/app/Mail/invoicePdf.php @@ -12,17 +12,14 @@ class invoicePdf extends Mailable public $data = []; - public $notificationEmail = ''; - /** * Create a new message instance. * * @return void */ - public function __construct($data, $notificationEmail) + public function __construct($data) { $this->data = $data; - $this->notificationEmail = $notificationEmail; } /** @@ -32,6 +29,6 @@ class invoicePdf extends Mailable */ public function build() { - return $this->from($this->notificationEmail)->markdown('emails.send.invoice', ['data', $this->data]); + return $this->markdown('emails.send.invoice', ['data', $this->data]); } } diff --git a/resources/assets/js/store/modules/dashboard/actions.js b/resources/assets/js/store/modules/dashboard/actions.js index 4bd4a691..26ac7be0 100644 --- a/resources/assets/js/store/modules/dashboard/actions.js +++ b/resources/assets/js/store/modules/dashboard/actions.js @@ -13,13 +13,13 @@ export const loadData = ({ commit, dispatch, state }, params) => { }) } -export const getChart = ({ commit, dispatch, state }) => { - return new Promise((resolve, reject) => { - window.axios.get(`/api/dashboard/expense/chart`).then((response) => { - commit(types.SET_INITIAL_DATA, response.data) - resolve(response) - }).catch((err) => { - reject(err) - }) - }) -} +// export const getChart = ({ commit, dispatch, state }) => { +// return new Promise((resolve, reject) => { +// window.axios.get(`/api/dashboard/expense/chart`).then((response) => { +// commit(types.SET_INITIAL_DATA, response.data) +// resolve(response) +// }).catch((err) => { +// reject(err) +// }) +// }) +// } diff --git a/resources/assets/js/views/dashboard/Dashboard.vue b/resources/assets/js/views/dashboard/Dashboard.vue index 7c4eae6b..748259cc 100644 --- a/resources/assets/js/views/dashboard/Dashboard.vue +++ b/resources/assets/js/views/dashboard/Dashboard.vue @@ -398,7 +398,6 @@ export default { } }, created () { - this.loadChart() this.loadData() }, methods: { @@ -422,11 +421,6 @@ export default { 'markEstimateAsSent': 'markAsSent' }), - async loadChart () { - await this.$store.dispatch('dashboard/getChart') - this.isLoaded = true - }, - async loadData (params) { await this.$store.dispatch('dashboard/loadData', params) this.isLoaded = true @@ -434,7 +428,7 @@ export default { async removeEstimate (id) { this.id = id - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$tc('estimates.confirm_delete', 1), icon: '/assets/icon/trash-solid.svg', @@ -462,7 +456,7 @@ export default { }, async convertInToinvoice (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('estimates.confirm_conversion'), icon: '/assets/icon/file-alt-solid.svg', @@ -483,7 +477,7 @@ export default { }, async onMarkAsSent (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('estimates.confirm_mark_as_sent'), icon: '/assets/icon/check-circle-solid.svg', @@ -505,7 +499,7 @@ export default { async removeInvoice (id) { this.id = id - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$tc('invoices.confirm_delete'), icon: '/assets/icon/trash-solid.svg', @@ -525,7 +519,7 @@ export default { }, async sendInvoice (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('invoices.confirm_send'), icon: '/assets/icon/paper-plane-solid.svg', @@ -552,7 +546,7 @@ export default { }, async sentInvoice (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('invoices.invoice_mark_as_sent'), icon: '/assets/icon/check-circle-solid.svg', @@ -573,7 +567,7 @@ export default { }, async onMarkAsAccepted (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('estimates.confirm_mark_as_accepted'), icon: '/assets/icon/check-circle-solid.svg', @@ -595,7 +589,7 @@ export default { }, async onMarkAsRejected (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('estimates.confirm_mark_as_rejected'), icon: '/assets/icon/times-circle-solid.svg', @@ -617,7 +611,7 @@ export default { }, async sendEstimate (id) { - swal({ + window.swal({ title: this.$t('general.are_you_sure'), text: this.$t('estimates.confirm_send_estimate'), icon: '/assets/icon/paper-plane-solid.svg',