mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:57:33 -05:00 
			
		
		
		
	Events
This commit is contained in:
		
							parent
							
								
									e620438186
								
							
						
					
					
						commit
						62f084b2aa
					
				
							
								
								
									
										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()
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -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,6 +262,15 @@ class EventServiceProvider extends ServiceProvider
 | 
			
		||||
        QuoteWasViewed::class => [
 | 
			
		||||
            QuoteViewedActivity::class,
 | 
			
		||||
        ],
 | 
			
		||||
        QuoteWasArchived::class => [
 | 
			
		||||
            QuoteArchivedActivity::class,
 | 
			
		||||
        ],
 | 
			
		||||
        QuoteWasDeleted::class => [
 | 
			
		||||
            QuoteDeletedActivity::class,
 | 
			
		||||
        ],
 | 
			
		||||
        QuoteWasRestored::class => [
 | 
			
		||||
            QuoteRestoredActivity::class,
 | 
			
		||||
        ],
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user