mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 08:07:33 -04:00 
			
		
		
		
	
						commit
						4f50dd81c6
					
				
							
								
								
									
										45
									
								
								app/Events/Credit/CreditWasRestored.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								app/Events/Credit/CreditWasRestored.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Events\Credit; | ||||
| 
 | ||||
| use App\Models\Credit; | ||||
| use Illuminate\Queue\SerializesModels; | ||||
| 
 | ||||
| /** | ||||
|  * Class CreditWasRestored. | ||||
|  */ | ||||
| class CreditWasRestored | ||||
| { | ||||
|     use SerializesModels; | ||||
| 
 | ||||
|     /** | ||||
|      * @var Client | ||||
|      */ | ||||
|     public $credit; | ||||
| 
 | ||||
|     public $company; | ||||
| 
 | ||||
|     public $event_vars; | ||||
| 
 | ||||
|     /** | ||||
|      * Create a new event instance. | ||||
|      * | ||||
|      * @param Client $client | ||||
|      */ | ||||
|     public function __construct(Credit $credit, Company $company, array $event_vars) | ||||
|     { | ||||
|         $this->credit = $credit; | ||||
|         $this->company = $company; | ||||
|         $this->event_vars = $event_vars; | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| @ -25,6 +25,8 @@ class QuoteWasApproved | ||||
| { | ||||
|     use Dispatchable, InteractsWithSockets, SerializesModels; | ||||
| 
 | ||||
|     public $contact; | ||||
| 
 | ||||
|     public $quote; | ||||
| 
 | ||||
|     public $company; | ||||
| @ -35,8 +37,9 @@ class QuoteWasApproved | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(Quote $quote, Company $company, array $event_vars) | ||||
|     public function __construct(ClientContact $contact, Quote $quote, Company $company, array $event_vars) | ||||
|     { | ||||
|         $this->contact = $contact; | ||||
|         $this->quote = $quote; | ||||
|         $this->company = $company; | ||||
|         $this->event_vars = $event_vars; | ||||
|  | ||||
| @ -109,7 +109,7 @@ class QuoteController extends Controller | ||||
|         if ($process) { | ||||
|             foreach ($quotes as $quote) { | ||||
|                 $quote->service()->approve()->save(); | ||||
|                 event(new QuoteWasApproved($quote, $quote->company, Ninja::eventVars())); | ||||
|                 event(new QuoteWasApproved(auth()->user(), $quote, $quote->company, Ninja::eventVars())); | ||||
|             } | ||||
| 
 | ||||
|             return redirect() | ||||
|  | ||||
| @ -27,8 +27,6 @@ class CompanyUserController extends BaseController | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
| 
 | ||||
|         //$this->middleware('guest');
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -38,7 +36,6 @@ class CompanyUserController extends BaseController | ||||
|      */ | ||||
|     public function index() | ||||
|     { | ||||
|         // return view('signup.index');
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -48,11 +45,10 @@ class CompanyUserController extends BaseController | ||||
|      */ | ||||
|     public function create() | ||||
|     { | ||||
|         //
 | ||||
|     } | ||||
| 
 | ||||
|      | ||||
|     public function store(CreateAccountRequest $request) | ||||
|     public function store() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
| @ -125,8 +121,8 @@ class CompanyUserController extends BaseController | ||||
|      */ | ||||
|     public function update(UpdateCompanyUserRequest $request, User $user) | ||||
|     { | ||||
|         $company = auth()->user()->company(); | ||||
| 
 | ||||
|         $company = auth()->user()->company(); | ||||
|              | ||||
|         $company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first(); | ||||
| 
 | ||||
| @ -145,6 +141,7 @@ class CompanyUserController extends BaseController | ||||
|         $company_user->save(); | ||||
| 
 | ||||
|         return $this->itemResponse($company_user->fresh()); | ||||
|          | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -13,6 +13,8 @@ namespace App\Http\Controllers; | ||||
| 
 | ||||
| use App\DataMapper\CompanySettings; | ||||
| use App\DataMapper\DefaultSettings; | ||||
| use App\Events\User\UserEmailAddressChangedNewEmail; | ||||
| use App\Events\User\UserEmailAddressChangedOldEmail; | ||||
| use App\Factory\UserFactory; | ||||
| use App\Filters\UserFilters; | ||||
| use App\Http\Controllers\Traits\VerifiesUserEmail; | ||||
| @ -25,11 +27,13 @@ use App\Http\Requests\User\ShowUserRequest; | ||||
| use App\Http\Requests\User\StoreUserRequest; | ||||
| use App\Http\Requests\User\UpdateUserRequest; | ||||
| use App\Jobs\Company\CreateCompanyToken; | ||||
| use App\Jobs\User\UserEmailChanged; | ||||
| use App\Models\CompanyToken; | ||||
| use App\Models\CompanyUser; | ||||
| use App\Models\User; | ||||
| use App\Repositories\UserRepository; | ||||
| use App\Transformers\UserTransformer; | ||||
| use App\Utils\Ninja; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| @ -367,8 +371,14 @@ class UserController extends BaseController | ||||
|      */ | ||||
|     public function update(UpdateUserRequest $request, User $user) | ||||
|     { | ||||
|         $old_email = $user->email; | ||||
|         $new_email = $request->input('email'); | ||||
| 
 | ||||
|         $user = $this->user_repo->save($request->all(), $user); | ||||
| 
 | ||||
|         if($user) | ||||
|             UserEmailChanged::dispatch($new_email, $old_email, auth()->user()->company()); | ||||
| 
 | ||||
|         return $this->itemResponse($user); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -83,6 +83,24 @@ class ValidCreditsRules implements Rule | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         if(count($this->input['credits']) >=1){ | ||||
| 
 | ||||
|             $total_payments = $this->input['amount'] + array_sum(array_column($this->input['credits'], 'amount')); | ||||
| 
 | ||||
| info(print_r($this->input,1)); | ||||
| info("total payments = {$total_payments}"); | ||||
| info("total credits available = " . array_sum(array_column($this->input['credits'], 'amount'))); | ||||
| info("total invoices payable = " . array_sum(array_column($this->input['invoices'], 'amount'))); | ||||
| 
 | ||||
|             if($total_payments > array_sum(array_column($this->input['invoices'], 'amount'))){ | ||||
| 
 | ||||
|                 $this->error_msg = "Sum of total payments and credits is greater than the total of invoices"; | ||||
|                 return false; | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
|      | ||||
|  | ||||
| @ -49,14 +49,15 @@ class QuoteWorkflowSettings implements ShouldQueue | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         if ($this->client->getSetting('auto_archive_quote')) { | ||||
|             $this->base_repository->archive($this->quote); | ||||
|         } | ||||
| 
 | ||||
|         if ($this->client->getSetting('auto_email_quote')) { | ||||
|             $this->quote->invitations->each(function ($invitation, $key) { | ||||
|                 $this->quote->service()->sendEmail($invitation->contact); | ||||
|            }); | ||||
|         } | ||||
|          | ||||
|         if ($this->client->getSetting('auto_archive_quote')) { | ||||
|             $this->base_repository->archive($this->quote); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										109
									
								
								app/Jobs/User/UserEmailChanged.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								app/Jobs/User/UserEmailChanged.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,109 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Jobs\User; | ||||
| 
 | ||||
| use App\Jobs\Mail\BaseMailerJob; | ||||
| use App\Jobs\Util\SystemLogger; | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Mail\User\UserNotificationMailer; | ||||
| use App\Models\Company; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Foundation\Bus\Dispatchable; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Queue\SerializesModels; | ||||
| use Illuminate\Support\Facades\Mail; | ||||
| use Illuminate\Bus\Queueable; | ||||
| 
 | ||||
| class UserEmailChanged extends BaseMailerJob implements ShouldQueue | ||||
| { | ||||
|     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||||
| 
 | ||||
|     protected $new_email; | ||||
| 
 | ||||
|     protected $old_email; | ||||
| 
 | ||||
|     protected $company; | ||||
| 
 | ||||
|     /** | ||||
|      * Create a new job instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| 
 | ||||
|     public function __construct(string $new_email, string $old_email, Company $company) | ||||
|     { | ||||
|         $this->new_email = $new_email; | ||||
|         $this->old_email = $old_email; | ||||
|         $this->company = $company; | ||||
|     } | ||||
| 
 | ||||
|      public function handle() | ||||
|     { | ||||
|         //Set DB
 | ||||
|         MultiDB::setDb($this->company->db); | ||||
| 
 | ||||
|         //if we need to set an email driver do it now
 | ||||
|         $this->setMailDriver($this->company->settings->email_sending_method); | ||||
| 
 | ||||
|         $mail_obj = new \stdClass; | ||||
|         $mail_obj->subject = ctrans('texts.email_address_changed'); | ||||
|         $mail_obj->markdown = 'email.admin.generic'; | ||||
|         $mail_obj->from = [$this->company->owner()->email, $this->company->owner()->present()->name()]; | ||||
|         $mail_obj->tag = $this->company->company_key; | ||||
|         $mail_obj->data = $this->getData(); | ||||
| 
 | ||||
| 
 | ||||
|         //send email
 | ||||
|         Mail::to($this->old_email) | ||||
|             ->send(new UserNotificationMailer($mail_obj)); | ||||
| 
 | ||||
|         Mail::to($this->new_email) | ||||
|             ->send(new UserNotificationMailer($mail_obj)); | ||||
| 
 | ||||
| 
 | ||||
|         //catch errors
 | ||||
|         if (count(Mail::failures()) > 0) { | ||||
|             $this->logMailError(Mail::failures()); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private function getData() | ||||
|     { | ||||
|         return [ | ||||
|             'title' => ctrans('texts.email_address_changed'), | ||||
|             'message' => ctrans( | ||||
|                 'texts.email_address_changed_message', | ||||
|                 ['old_email' => $this->old_email, | ||||
|                 'new_email' => $this->new_email, | ||||
|             ] | ||||
|             ), | ||||
|             'url' => config('ninja.app_url'), | ||||
|             'button' => ctrans('texts.account_login'), | ||||
|             'signature' => $this->company->owner()->signature, | ||||
|             'logo' => $this->company->present()->logo(), | ||||
|         ]; | ||||
|     } | ||||
| 
 | ||||
|     private function logMailError($errors) | ||||
|     { | ||||
|         SystemLogger::dispatch( | ||||
|             $errors, | ||||
|             SystemLog::CATEGORY_MAIL, | ||||
|             SystemLog::EVENT_MAIL_SEND, | ||||
|             SystemLog::TYPE_FAILURE, | ||||
|             $this->company | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										58
									
								
								app/Listeners/Credit/CreditRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Listeners/Credit/CreditRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Credit; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class CreditRestoredActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->credit_id = $event->credit->id; | ||||
|         $fields->user_id = $event->credit->user_id; | ||||
|         $fields->company_id = $event->credit->company_id; | ||||
|         $fields->activity_type_id = Activity::RESTORE_CREDIT; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->credit, $event->event_vars); | ||||
|          | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								app/Listeners/Invoice/InvoiceRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								app/Listeners/Invoice/InvoiceRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Invoice; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class InvoiceRestoredActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->invoice_id = $event->invoice->id; | ||||
|         $fields->user_id = $event->invoice->user_id; | ||||
|         $fields->company_id = $event->invoice->company_id; | ||||
|         $fields->activity_type_id = Activity::RESTORE_INVOICE; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->invoice, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								app/Listeners/Payment/PaymentRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								app/Listeners/Payment/PaymentRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Payment; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class PaymentRestoredActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->payment_id = $event->payment->id; | ||||
|         $fields->user_id = $event->payment->user_id; | ||||
|         $fields->company_id = $event->payment->company_id; | ||||
|         $fields->activity_type_id = Activity::RESTORE_PAYMENT; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->payment, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										58
									
								
								app/Listeners/Quote/QuoteApprovedActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								app/Listeners/Quote/QuoteApprovedActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Quote; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class QuoteApprovedActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->quote_id = $event->quote->id; | ||||
|         $fields->user_id = $event->quote->user_id; | ||||
|         $fields->client_contact_id = $event->contact->id; | ||||
|         $fields->company_id = $event->payment->company_id; | ||||
|         $fields->activity_type_id = Activity::RESTORE_PAYMENT; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->payment, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								app/Listeners/Quote/QuoteArchivedActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								app/Listeners/Quote/QuoteArchivedActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Quote; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class QuoteArchivedActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->quote_id = $event->quote->id; | ||||
|         $fields->user_id = $event->quote->user_id; | ||||
|         $fields->company_id = $event->quote->company_id; | ||||
|         $fields->activity_type_id = Activity::ARCHIVE_QUOTE; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->quote, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								app/Listeners/Quote/QuoteDeletedActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								app/Listeners/Quote/QuoteDeletedActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Quote; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class QuoteDeletedActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->quote_id = $event->quote->id; | ||||
|         $fields->user_id = $event->quote->user_id; | ||||
|         $fields->company_id = $event->quote->company_id; | ||||
|         $fields->activity_type_id = Activity::DELETE_QUOTE; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->quote, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										57
									
								
								app/Listeners/Quote/QuoteRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								app/Listeners/Quote/QuoteRestoredActivity.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Listeners\Quote; | ||||
| 
 | ||||
| use App\Libraries\MultiDB; | ||||
| use App\Models\Activity; | ||||
| use App\Models\ClientContact; | ||||
| use App\Models\InvoiceInvitation; | ||||
| use App\Repositories\ActivityRepository; | ||||
| use App\Utils\Traits\MakesHash; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| class QuoteRestoredActivity implements ShouldQueue | ||||
| { | ||||
|     protected $activity_repo; | ||||
|     /** | ||||
|      * Create the event listener. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct(ActivityRepository $activity_repo) | ||||
|     { | ||||
|         $this->activity_repo = $activity_repo; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Handle the event. | ||||
|      * | ||||
|      * @param  object  $event | ||||
|      * @return void | ||||
|      */ | ||||
|     public function handle($event) | ||||
|     { | ||||
| 
 | ||||
|         MultiDB::setDb($event->company->db); | ||||
| 
 | ||||
|         $fields = new \stdClass; | ||||
| 
 | ||||
|         $fields->quote_id = $event->quote->id; | ||||
|         $fields->user_id = $event->quote->user_id; | ||||
|         $fields->company_id = $event->quote->company_id; | ||||
|         $fields->activity_type_id = Activity::RESTORE_QUOTE; | ||||
| 
 | ||||
|         $this->activity_repo->save($fields, $event->quote, $event->event_vars); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										46
									
								
								app/Mail/User/UserNotificationMailer.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								app/Mail/User/UserNotificationMailer.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Mail\User; | ||||
| 
 | ||||
| use App\Models\User; | ||||
| use Illuminate\Mail\Mailable; | ||||
| 
 | ||||
| class UserNotificationMailer extends Mailable | ||||
| { | ||||
| 
 | ||||
|     public $mail_obj; | ||||
| 
 | ||||
|     /** | ||||
|      * Create a new message instance. | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|     public function __construct($mail_obj) | ||||
|     { | ||||
|         $this->mail_obj = $mail_obj; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Build the message. | ||||
|      * | ||||
|      * @return $this | ||||
|      */ | ||||
|     public function build() | ||||
|     { | ||||
|         return $this->from($this->mail_obj->from[0], $this->mail_obj->from[1]) //todo
 | ||||
|                     ->subject($this->mail_obj->subject) | ||||
|                     ->markdown($this->mail_obj->markdown, $this->mail_obj->data) | ||||
|                     ->withSwiftMessage(function ($message) { | ||||
|                             $message->getHeaders()->addTextHeader('Tag', $this->mail_obj->tag); | ||||
|                         }); | ||||
|     } | ||||
| } | ||||
| @ -36,14 +36,14 @@ class Activity extends StaticModel | ||||
|     const UPDATE_QUOTE=19; //
 | ||||
|     const EMAIL_QUOTE=20; //
 | ||||
|     const VIEW_QUOTE=21; //
 | ||||
|     const ARCHIVE_QUOTE=22; | ||||
|     const DELETE_QUOTE=23; | ||||
|     const RESTORE_QUOTE=24; | ||||
|     const RESTORE_INVOICE=25; | ||||
|     const RESTORE_CLIENT=26; | ||||
|     const RESTORE_PAYMENT=27; | ||||
|     const RESTORE_CREDIT=28; | ||||
|     const APPROVE_QUOTE=29; | ||||
|     const ARCHIVE_QUOTE=22; //
 | ||||
|     const DELETE_QUOTE=23; //
 | ||||
|     const RESTORE_QUOTE=24; //
 | ||||
|     const RESTORE_INVOICE=25; //
 | ||||
|     const RESTORE_CLIENT=26; //
 | ||||
|     const RESTORE_PAYMENT=27; //
 | ||||
|     const RESTORE_CREDIT=28; //
 | ||||
|     const APPROVE_QUOTE=29; //
 | ||||
|     const CREATE_VENDOR=30; | ||||
|     const ARCHIVE_VENDOR=31; | ||||
|     const DELETE_VENDOR=32; | ||||
|  | ||||
| @ -65,7 +65,8 @@ class Payment extends BaseModel | ||||
|         'date', | ||||
|         'transaction_reference', | ||||
|         'number', | ||||
|         'is_manual' | ||||
|         'is_manual', | ||||
|         'private_notes', | ||||
|     ]; | ||||
| 
 | ||||
|     protected $casts = [ | ||||
|  | ||||
| @ -26,6 +26,7 @@ use App\Events\Credit\CreditWasCreated; | ||||
| use App\Events\Credit\CreditWasDeleted; | ||||
| use App\Events\Credit\CreditWasEmailedAndFailed; | ||||
| use App\Events\Credit\CreditWasMarkedSent; | ||||
| use App\Events\Credit\CreditWasRestored; | ||||
| use App\Events\Credit\CreditWasUpdated; | ||||
| use App\Events\Design\DesignWasArchived; | ||||
| use App\Events\Invoice\InvoiceWasArchived; | ||||
| @ -35,6 +36,7 @@ use App\Events\Invoice\InvoiceWasDeleted; | ||||
| use App\Events\Invoice\InvoiceWasEmailed; | ||||
| use App\Events\Invoice\InvoiceWasMarkedSent; | ||||
| use App\Events\Invoice\InvoiceWasPaid; | ||||
| use App\Events\Invoice\InvoiceWasRestored; | ||||
| use App\Events\Invoice\InvoiceWasReversed; | ||||
| use App\Events\Invoice\InvoiceWasUpdated; | ||||
| use App\Events\Invoice\InvoiceWasViewed; | ||||
| @ -43,11 +45,15 @@ use App\Events\Payment\PaymentWasArchived; | ||||
| use App\Events\Payment\PaymentWasCreated; | ||||
| use App\Events\Payment\PaymentWasDeleted; | ||||
| use App\Events\Payment\PaymentWasRefunded; | ||||
| use App\Events\Payment\PaymentWasRestored; | ||||
| use App\Events\Payment\PaymentWasUpdated; | ||||
| use App\Events\Payment\PaymentWasVoided; | ||||
| use App\Events\Quote\QuoteWasApproved; | ||||
| use App\Events\Quote\QuoteWasArchived; | ||||
| use App\Events\Quote\QuoteWasCreated; | ||||
| use App\Events\Quote\QuoteWasDeleted; | ||||
| use App\Events\Quote\QuoteWasEmailed; | ||||
| use App\Events\Quote\QuoteWasRestored; | ||||
| use App\Events\Quote\QuoteWasUpdated; | ||||
| use App\Events\Quote\QuoteWasViewed; | ||||
| use App\Events\User\UserLoggedIn; | ||||
| @ -69,6 +75,7 @@ use App\Listeners\Activity\QuoteUpdatedActivity; | ||||
| use App\Listeners\Activity\RestoreClientActivity; | ||||
| use App\Listeners\Activity\UpdatedCreditActivity; | ||||
| use App\Listeners\Contact\UpdateContactLastLogin; | ||||
| use App\Listeners\Credit\CreditRestoredActivity; | ||||
| use App\Listeners\Document\DeleteCompanyDocuments; | ||||
| use App\Listeners\Invoice\CreateInvoiceActivity; | ||||
| use App\Listeners\Invoice\CreateInvoiceHtmlBackup; | ||||
| @ -79,12 +86,17 @@ use App\Listeners\Invoice\InvoiceDeletedActivity; | ||||
| use App\Listeners\Invoice\InvoiceEmailActivity; | ||||
| use App\Listeners\Invoice\InvoiceEmailFailedActivity; | ||||
| use App\Listeners\Invoice\InvoiceEmailedNotification; | ||||
| use App\Listeners\Invoice\InvoiceRestoredActivity; | ||||
| use App\Listeners\Invoice\InvoiceViewedActivity; | ||||
| use App\Listeners\Invoice\UpdateInvoiceActivity; | ||||
| use App\Listeners\Invoice\UpdateInvoiceInvitations; | ||||
| use App\Listeners\Misc\InvitationViewedListener; | ||||
| use App\Listeners\Payment\PaymentNotification; | ||||
| use App\Listeners\Payment\PaymentRestoredActivity; | ||||
| use App\Listeners\Quote\QuoteArchivedActivity; | ||||
| use App\Listeners\Quote\QuoteDeletedActivity; | ||||
| use App\Listeners\Quote\QuoteEmailActivity; | ||||
| use App\Listeners\Quote\QuoteRestoredActivity; | ||||
| use App\Listeners\Quote\QuoteViewedActivity; | ||||
| use App\Listeners\Quote\ReachWorkflowSettings; | ||||
| use App\Listeners\SendVerificationNotification; | ||||
| @ -132,6 +144,9 @@ class EventServiceProvider extends ServiceProvider | ||||
|         PaymentWasVoided::class => [ | ||||
|             PaymentVoidedActivity::class, | ||||
|         ], | ||||
|         PaymentWasRestored::class =>[ | ||||
|             PaymentRestoredActivity::class, | ||||
|         ], | ||||
|         // Clients
 | ||||
|         ClientWasCreated::class =>[ | ||||
|             CreatedClientActivity::class, | ||||
| @ -176,6 +191,9 @@ class EventServiceProvider extends ServiceProvider | ||||
|         CreditWasArchived::class => [ | ||||
|             CreditArchivedActivity::class, | ||||
|         ], | ||||
|         CreditWasRestored::class => [ | ||||
|             CreditRestoredActivity::class, | ||||
|         ], | ||||
|         //Designs
 | ||||
|         DesignWasArchived::class => [ | ||||
|         ], | ||||
| @ -216,6 +234,9 @@ class EventServiceProvider extends ServiceProvider | ||||
|         InvoiceWasArchived::class => [ | ||||
|             InvoiceArchivedActivity::class, | ||||
|         ], | ||||
|         InvoiceWasRestored::class => [ | ||||
|             InvoiceRestoredActivity::class, | ||||
|         ], | ||||
|         InvoiceWasReversed::class => [ | ||||
|         ], | ||||
|         InvoiceWasCancelled::class => [ | ||||
| @ -241,7 +262,15 @@ class EventServiceProvider extends ServiceProvider | ||||
|         QuoteWasViewed::class => [ | ||||
|             QuoteViewedActivity::class, | ||||
|         ], | ||||
| 
 | ||||
|         QuoteWasArchived::class => [ | ||||
|             QuoteArchivedActivity::class, | ||||
|         ], | ||||
|         QuoteWasDeleted::class => [ | ||||
|             QuoteDeletedActivity::class, | ||||
|         ], | ||||
|         QuoteWasRestored::class => [ | ||||
|             QuoteRestoredActivity::class, | ||||
|         ], | ||||
|     ]; | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -82,13 +82,15 @@ class PaymentRepository extends BaseRepository | ||||
|                     $data['amount'] = array_sum(array_column($data['invoices'], 'amount')); | ||||
|                  | ||||
|                 $client = Client::find($data['client_id']); | ||||
|                 info("updating client balance from {$client->balance} by this much ".$data['amount']); | ||||
|                 //info("updating client balance from {$client->balance} by this much ".$data['amount']);
 | ||||
| 
 | ||||
|                 $client->service()->updatePaidToDate($data['amount'])->save(); | ||||
| 
 | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         //info(print_r($data,1));
 | ||||
| 
 | ||||
|         /*Fill the payment*/ | ||||
|         $payment->fill($data); | ||||
|         $payment->status_id = Payment::STATUS_COMPLETED; | ||||
|  | ||||
							
								
								
									
										28
									
								
								app/Services/Recurring/RecurringService.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								app/Services/Recurring/RecurringService.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com) | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| namespace App\Services\Recurring; | ||||
| 
 | ||||
| use App\Models\RecurringInvoice; | ||||
| 
 | ||||
| class RecurringService | ||||
| { | ||||
| 
 | ||||
|     protected $recurring_entity; | ||||
| 
 | ||||
|     public function __construct($recurring_entity) | ||||
|     { | ||||
|         $this->recurring_entity = $recurring_entity; | ||||
|     } | ||||
| 
 | ||||
|     //set schedules - update next_send_dates
 | ||||
| } | ||||
							
								
								
									
										10
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							| @ -5841,16 +5841,16 @@ | ||||
|         }, | ||||
|         { | ||||
|             "name": "spatie/browsershot", | ||||
|             "version": "3.37.1", | ||||
|             "version": "3.37.2", | ||||
|             "source": { | ||||
|                 "type": "git", | ||||
|                 "url": "https://github.com/spatie/browsershot.git", | ||||
|                 "reference": "7d526a458ce870a07669bd2416313a4d62f3f15d" | ||||
|                 "reference": "32d2984079ed8fe690f4dc5b7b6c205ae0a7b0fd" | ||||
|             }, | ||||
|             "dist": { | ||||
|                 "type": "zip", | ||||
|                 "url": "https://api.github.com/repos/spatie/browsershot/zipball/7d526a458ce870a07669bd2416313a4d62f3f15d", | ||||
|                 "reference": "7d526a458ce870a07669bd2416313a4d62f3f15d", | ||||
|                 "url": "https://api.github.com/repos/spatie/browsershot/zipball/32d2984079ed8fe690f4dc5b7b6c205ae0a7b0fd", | ||||
|                 "reference": "32d2984079ed8fe690f4dc5b7b6c205ae0a7b0fd", | ||||
|                 "shasum": "" | ||||
|             }, | ||||
|             "require": { | ||||
| @ -5899,7 +5899,7 @@ | ||||
|                     "type": "github" | ||||
|                 } | ||||
|             ], | ||||
|             "time": "2020-07-08T07:20:45+00:00" | ||||
|             "time": "2020-07-21T22:40:58+00:00" | ||||
|         }, | ||||
|         { | ||||
|             "name": "spatie/image", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user