mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:07:32 -05:00 
			
		
		
		
	
						commit
						8366ffa3bb
					
				
							
								
								
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							@ -12,7 +12,7 @@ jobs:
 | 
				
			|||||||
      - name: Setup PHP
 | 
					      - name: Setup PHP
 | 
				
			||||||
        uses: shivammathur/setup-php@v2
 | 
					        uses: shivammathur/setup-php@v2
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          php-version: 7.4
 | 
					          php-version: 8.1
 | 
				
			||||||
          extensions: mysql, mysqlnd, sqlite3, bcmath, gd, curl, zip, openssl, mbstring, xml
 | 
					          extensions: mysql, mysqlnd, sqlite3, bcmath, gd, curl, zip, openssl, mbstring, xml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Checkout code
 | 
					      - name: Checkout code
 | 
				
			||||||
@ -50,7 +50,7 @@ jobs:
 | 
				
			|||||||
          cd ..
 | 
					          cd ..
 | 
				
			||||||
          rm -rf ui
 | 
					          rm -rf ui
 | 
				
			||||||
          php artisan ninja:react
 | 
					          php artisan ninja:react
 | 
				
			||||||
          
 | 
					
 | 
				
			||||||
      - name: Prepare JS/CSS assets
 | 
					      - name: Prepare JS/CSS assets
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          npm i
 | 
					          npm i
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -3,6 +3,7 @@
 | 
				
			|||||||
/public/storage
 | 
					/public/storage
 | 
				
			||||||
/public/react
 | 
					/public/react
 | 
				
			||||||
/storage/*.key
 | 
					/storage/*.key
 | 
				
			||||||
 | 
					/storage/debugbar
 | 
				
			||||||
/vendor
 | 
					/vendor
 | 
				
			||||||
/.idea
 | 
					/.idea
 | 
				
			||||||
/.vscode
 | 
					/.vscode
 | 
				
			||||||
 | 
				
			|||||||
@ -1 +1 @@
 | 
				
			|||||||
5.4.12
 | 
					5.5.8
 | 
				
			||||||
@ -66,39 +66,25 @@ class BackupUpdate extends Command
 | 
				
			|||||||
                $this->handleOnDb();
 | 
					                $this->handleOnDb();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MultiDB::setDB($current_db);
 | 
					            MultiDB::setDB($current_db);
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function handleOnDb()
 | 
					    private function handleOnDb()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        set_time_limit(0);
 | 
					        set_time_limit(0);
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        Backup::whereHas('activity')->whereRaw('html_backup IS NOT NULL')->cursor()->each( function ($backup) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					        Backup::whereHas('activity')->whereRaw('html_backup IS NOT NULL')->cursor()->each(function ($backup) {
 | 
				
			||||||
                if(strlen($backup->html_backup) > 1 && $backup->activity->invoice->exists()){
 | 
					            if (strlen($backup->html_backup) > 1 && $backup->activity->invoice->exists()) {
 | 
				
			||||||
 | 
					                $client = $backup->activity->invoice->client;
 | 
				
			||||||
                    $client = $backup->activity->invoice->client;
 | 
					                $backup->storeRemotely($backup->html_backup, $client);
 | 
				
			||||||
                    $backup->storeRemotely($backup->html_backup, $client);
 | 
					            } elseif (strlen($backup->html_backup) > 1 && $backup->activity->quote->exists()) {
 | 
				
			||||||
 | 
					                $client = $backup->activity->quote->client;
 | 
				
			||||||
                }else if(strlen($backup->html_backup) > 1 && $backup->activity->quote->exists()){
 | 
					                $backup->storeRemotely($backup->html_backup, $client);
 | 
				
			||||||
 | 
					            } elseif (strlen($backup->html_backup) > 1 && $backup->activity->credit->exists()) {
 | 
				
			||||||
                    $client = $backup->activity->quote->client;
 | 
					                $client = $backup->activity->credit->client;
 | 
				
			||||||
                    $backup->storeRemotely($backup->html_backup, $client);
 | 
					                $backup->storeRemotely($backup->html_backup, $client);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
                }else if(strlen($backup->html_backup) > 1 && $backup->activity->credit->exists()){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    $client = $backup->activity->credit->client;
 | 
					 | 
				
			||||||
                    $backup->storeRemotely($backup->html_backup, $client);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,6 +12,7 @@
 | 
				
			|||||||
namespace App\Console\Commands;
 | 
					namespace App\Console\Commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App;
 | 
					use App;
 | 
				
			||||||
 | 
					use App\DataMapper\ClientSettings;
 | 
				
			||||||
use App\Factory\ClientContactFactory;
 | 
					use App\Factory\ClientContactFactory;
 | 
				
			||||||
use App\Factory\VendorContactFactory;
 | 
					use App\Factory\VendorContactFactory;
 | 
				
			||||||
use App\Models\Account;
 | 
					use App\Models\Account;
 | 
				
			||||||
@ -126,7 +127,7 @@ class CheckData extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $errorEmail = config('ninja.error_email');
 | 
					        $errorEmail = config('ninja.error_email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($errorEmail) {
 | 
					        if (strlen($errorEmail) > 1) {
 | 
				
			||||||
            Mail::raw($this->log, function ($message) use ($errorEmail, $database) {
 | 
					            Mail::raw($this->log, function ($message) use ($errorEmail, $database) {
 | 
				
			||||||
                $message->to($errorEmail)
 | 
					                $message->to($errorEmail)
 | 
				
			||||||
                        ->from(config('mail.from.address'), config('mail.from.name'))
 | 
					                        ->from(config('mail.from.address'), config('mail.from.name'))
 | 
				
			||||||
@ -893,6 +894,45 @@ class CheckData extends Command
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function checkClientSettings()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($this->option('fix') == 'true') {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Client::query()->whereNull('settings->currency_id')->cursor()->each(function ($client){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if(is_array($client->settings) && count($client->settings) == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    $settings = ClientSettings::defaults();
 | 
				
			||||||
 | 
					                    $settings->currency_id = $client->company->settings->currency_id;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else {
 | 
				
			||||||
 | 
					                    $settings = $client->settings;
 | 
				
			||||||
 | 
					                    $settings->currency_id = $client->company->settings->currency_id;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $client->settings = $settings;
 | 
				
			||||||
 | 
					                $client->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $this->logMessage("Fixing currency for # {$client->id}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Client::query()->whereNull('country_id')->cursor()->each(function ($client){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $client->country_id = $client->company->settings->country_id;
 | 
				
			||||||
 | 
					                $client->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $this->logMessage("Fixing country for # {$client->id}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function checkBalanceVsPaidStatus()
 | 
					    public function checkBalanceVsPaidStatus()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->wrong_paid_status = 0;
 | 
					        $this->wrong_paid_status = 0;
 | 
				
			||||||
 | 
				
			|||||||
@ -36,8 +36,8 @@ use App\Models\GroupSetting;
 | 
				
			|||||||
use App\Models\Invoice;
 | 
					use App\Models\Invoice;
 | 
				
			||||||
use App\Models\InvoiceInvitation;
 | 
					use App\Models\InvoiceInvitation;
 | 
				
			||||||
use App\Models\Payment;
 | 
					use App\Models\Payment;
 | 
				
			||||||
use App\Models\PaymentHash;
 | 
					 | 
				
			||||||
use App\Models\Paymentable;
 | 
					use App\Models\Paymentable;
 | 
				
			||||||
 | 
					use App\Models\PaymentHash;
 | 
				
			||||||
use App\Models\Product;
 | 
					use App\Models\Product;
 | 
				
			||||||
use App\Models\Project;
 | 
					use App\Models\Project;
 | 
				
			||||||
use App\Models\Quote;
 | 
					use App\Models\Quote;
 | 
				
			||||||
@ -61,13 +61,11 @@ use Illuminate\Support\Str;
 | 
				
			|||||||
use Mail;
 | 
					use Mail;
 | 
				
			||||||
use Symfony\Component\Console\Input\InputOption;
 | 
					use Symfony\Component\Console\Input\InputOption;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Class CheckDb.
 | 
					 * Class CheckDb.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class CheckDb extends Command
 | 
					class CheckDb extends Command
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected $signature = 'ninja:check-db';
 | 
					    protected $signature = 'ninja:check-db';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected $description = 'Check MultiDB';
 | 
					    protected $description = 'Check MultiDB';
 | 
				
			||||||
@ -118,33 +116,30 @@ class CheckDb extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        $this->LogMessage('Checking - V5_DB1');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->LogMessage("Checking - V5_DB1");
 | 
					        foreach ($this->entities as $entity) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach($this->entities as $entity) {
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            $count_db_1 = $entity::on('db-ninja-01')->count();
 | 
					            $count_db_1 = $entity::on('db-ninja-01')->count();
 | 
				
			||||||
            $count_db_2 = $entity::on('db-ninja-02a')->count();
 | 
					            $count_db_2 = $entity::on('db-ninja-02a')->count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $diff = $count_db_1 - $count_db_2;
 | 
					            $diff = $count_db_1 - $count_db_2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($diff != 0)
 | 
					            if ($diff != 0) {
 | 
				
			||||||
                $this->logMessage("{$entity} DB1: {$count_db_1} - DB2: {$count_db_2} - diff = {$diff}");
 | 
					                $this->logMessage("{$entity} DB1: {$count_db_1} - DB2: {$count_db_2} - diff = {$diff}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->LogMessage("Checking - V5_DB2");
 | 
					        $this->LogMessage('Checking - V5_DB2');
 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach($this->entities as $entity) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($this->entities as $entity) {
 | 
				
			||||||
            $count_db_1 = $entity::on('db-ninja-02')->count();
 | 
					            $count_db_1 = $entity::on('db-ninja-02')->count();
 | 
				
			||||||
            $count_db_2 = $entity::on('db-ninja-01a')->count();
 | 
					            $count_db_2 = $entity::on('db-ninja-01a')->count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $diff = $count_db_1 - $count_db_2;
 | 
					            $diff = $count_db_1 - $count_db_2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($diff != 0)
 | 
					            if ($diff != 0) {
 | 
				
			||||||
                $this->logMessage("{$entity} DB1: {$count_db_1} - DB2: {$count_db_2} - diff = {$diff}");
 | 
					                $this->logMessage("{$entity} DB1: {$count_db_1} - DB2: {$count_db_2} - diff = {$diff}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -154,5 +149,4 @@ class CheckDb extends Command
 | 
				
			|||||||
        $this->info($str);
 | 
					        $this->info($str);
 | 
				
			||||||
        $this->log .= $str."\n";
 | 
					        $this->log .= $str."\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -51,10 +51,12 @@ use Illuminate\Support\Str;
 | 
				
			|||||||
class CreateAccount extends Command
 | 
					class CreateAccount extends Command
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use MakesHash, GeneratesCounter;
 | 
					    use MakesHash, GeneratesCounter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $description = 'Create Single Account';
 | 
					    protected $description = 'Create Single Account';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@ -82,12 +84,10 @@ class CreateAccount extends Command
 | 
				
			|||||||
        $this->warmCache();
 | 
					        $this->warmCache();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->createAccount();
 | 
					        $this->createAccount();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createAccount()
 | 
					    private function createAccount()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $account = Account::factory()->create();
 | 
					        $account = Account::factory()->create();
 | 
				
			||||||
        $company = Company::factory()->create([
 | 
					        $company = Company::factory()->create([
 | 
				
			||||||
            'account_id' => $account->id,
 | 
					            'account_id' => $account->id,
 | 
				
			||||||
@ -131,10 +131,9 @@ class CreateAccount extends Command
 | 
				
			|||||||
            'settings' => null,
 | 
					            'settings' => null,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CreateCompanyPaymentTerms::dispatchNow($company, $user);
 | 
					        (new CreateCompanyPaymentTerms($company, $user))->handle();
 | 
				
			||||||
        CreateCompanyTaskStatuses::dispatchNow($company, $user);
 | 
					        (new CreateCompanyTaskStatuses($company, $user))->handle();
 | 
				
			||||||
        VersionCheck::dispatchNow();
 | 
					        (new VersionCheck())->handle();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function warmCache()
 | 
					    private function warmCache()
 | 
				
			||||||
@ -164,5 +163,4 @@ class CreateAccount extends Command
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -48,10 +48,12 @@ use Illuminate\Support\Str;
 | 
				
			|||||||
class CreateTestData extends Command
 | 
					class CreateTestData extends Command
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use MakesHash, GeneratesCounter;
 | 
					    use MakesHash, GeneratesCounter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $description = 'Create Test Data';
 | 
					    protected $description = 'Create Test Data';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@ -66,14 +68,16 @@ class CreateTestData extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(config('ninja.is_docker'))
 | 
					        if (config('ninja.is_docker')) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!$this->confirm('Are you sure you want to inject dummy data?'))
 | 
					        if (! $this->confirm('Are you sure you want to inject dummy data?')) {
 | 
				
			||||||
        return;
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->invoice_repo = new InvoiceRepository();
 | 
					        $this->invoice_repo = new InvoiceRepository();
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $this->info(date('r').' Running CreateTestData...');
 | 
					        $this->info(date('r').' Running CreateTestData...');
 | 
				
			||||||
        $this->count = $this->argument('count');
 | 
					        $this->count = $this->argument('count');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -125,14 +129,14 @@ class CreateTestData extends Command
 | 
				
			|||||||
            'is_admin' => 1,
 | 
					            'is_admin' => 1,
 | 
				
			||||||
            'is_locked' => 0,
 | 
					            'is_locked' => 0,
 | 
				
			||||||
            'notifications' => CompanySettings::notificationDefaults(),
 | 
					            'notifications' => CompanySettings::notificationDefaults(),
 | 
				
			||||||
           // 'permissions' => '',
 | 
					            // 'permissions' => '',
 | 
				
			||||||
            'settings' => null,
 | 
					            'settings' => null,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Product::factory()->count(50)->create([
 | 
					        Product::factory()->count(50)->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->info('Creating '.$this->count.' clients');
 | 
					        $this->info('Creating '.$this->count.' clients');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -219,15 +223,14 @@ class CreateTestData extends Command
 | 
				
			|||||||
            'is_admin' => 1,
 | 
					            'is_admin' => 1,
 | 
				
			||||||
            'is_locked' => 0,
 | 
					            'is_locked' => 0,
 | 
				
			||||||
            'notifications' => CompanySettings::notificationDefaults(),
 | 
					            'notifications' => CompanySettings::notificationDefaults(),
 | 
				
			||||||
         //   'permissions' => '',
 | 
					            //   'permissions' => '',
 | 
				
			||||||
            'settings' => null,
 | 
					            'settings' => null,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Product::factory()->count(50)->create([
 | 
					        Product::factory()->count(50)->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->count = $this->count * 10;
 | 
					        $this->count = $this->count * 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -317,14 +320,14 @@ class CreateTestData extends Command
 | 
				
			|||||||
            'is_admin' => 1,
 | 
					            'is_admin' => 1,
 | 
				
			||||||
            'is_locked' => 0,
 | 
					            'is_locked' => 0,
 | 
				
			||||||
            'notifications' => CompanySettings::notificationDefaults(),
 | 
					            'notifications' => CompanySettings::notificationDefaults(),
 | 
				
			||||||
         //   'permissions' => '',
 | 
					            //   'permissions' => '',
 | 
				
			||||||
            'settings' => null,
 | 
					            'settings' => null,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Product::factory()->count(15000)->create([
 | 
					        Product::factory()->count(15000)->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->count = $this->count * 10;
 | 
					        $this->count = $this->count * 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -382,30 +385,29 @@ class CreateTestData extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // });
 | 
					        // });
 | 
				
			||||||
        $client = Client::factory()->create([
 | 
					        $client = Client::factory()->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Document::factory()->count(50)->create([
 | 
					        Document::factory()->count(50)->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
                'documentable_type' => Client::class,
 | 
					            'documentable_type' => Client::class,
 | 
				
			||||||
                'documentable_id' => $client->id
 | 
					            'documentable_id' => $client->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ClientContact::factory()->create([
 | 
					        ClientContact::factory()->create([
 | 
				
			||||||
                    'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                    'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                    'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
                    'is_primary' => 1,
 | 
					            'is_primary' => 1,
 | 
				
			||||||
                ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ClientContact::factory()->count(rand(1, 5))->create([
 | 
					        ClientContact::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                    'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                    'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                    'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
                ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client->number = $this->getNextClientNumber($client);
 | 
					        $client->number = $this->getNextClientNumber($client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -422,70 +424,69 @@ class CreateTestData extends Command
 | 
				
			|||||||
    private function createExpense($client)
 | 
					    private function createExpense($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Expense::factory()->count(rand(1, 5))->create([
 | 
					        Expense::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createVendor($client)
 | 
					    private function createVendor($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $vendor = Vendor::factory()->create([
 | 
					        $vendor = Vendor::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Document::factory()->count(50)->create([
 | 
					        Document::factory()->count(50)->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'documentable_type' => Vendor::class,
 | 
					            'documentable_type' => Vendor::class,
 | 
				
			||||||
                'documentable_id' => $vendor->id
 | 
					            'documentable_id' => $vendor->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VendorContact::factory()->create([
 | 
					        VendorContact::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'vendor_id' => $vendor->id,
 | 
					            'vendor_id' => $vendor->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
                'is_primary' => 1,
 | 
					            'is_primary' => 1,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VendorContact::factory()->count(rand(1, 5))->create([
 | 
					        VendorContact::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'vendor_id' => $vendor->id,
 | 
					            'vendor_id' => $vendor->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
                'is_primary' => 0,
 | 
					            'is_primary' => 0,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createTask($client)
 | 
					    private function createTask($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $vendor = Task::factory()->create([
 | 
					        $vendor = Task::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Document::factory()->count(5)->create([
 | 
					        Document::factory()->count(5)->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'documentable_type' => Task::class,
 | 
					            'documentable_type' => Task::class,
 | 
				
			||||||
                'documentable_id' => $vendor->id
 | 
					            'documentable_id' => $vendor->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createProject($client)
 | 
					    private function createProject($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $vendor = Project::factory()->create([
 | 
					        $vendor = Project::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company->id,
 | 
					            'company_id' => $client->company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Document::factory()->count(5)->create([
 | 
					        Document::factory()->count(5)->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'documentable_type' => Project::class,
 | 
					            'documentable_type' => Project::class,
 | 
				
			||||||
                'documentable_id' => $vendor->id
 | 
					            'documentable_id' => $vendor->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createInvoice($client)
 | 
					    private function createInvoice($client)
 | 
				
			||||||
@ -516,7 +517,7 @@ class CreateTestData extends Command
 | 
				
			|||||||
            $invoice->tax_rate3 = 5;
 | 
					            $invoice->tax_rate3 = 5;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->custom_value1 = $faker->date;
 | 
					        $invoice->custom_value1 = $faker->date();
 | 
				
			||||||
        $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
					        $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->save();
 | 
					        $invoice->save();
 | 
				
			||||||
@ -537,16 +538,15 @@ class CreateTestData extends Command
 | 
				
			|||||||
            $invoice = $invoice->service()->markPaid()->save();
 | 
					            $invoice = $invoice->service()->markPaid()->save();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Document::factory()->count(5)->create([
 | 
					        Document::factory()->count(5)->create([
 | 
				
			||||||
                'user_id' => $invoice->user->id,
 | 
					            'user_id' => $invoice->user->id,
 | 
				
			||||||
                'company_id' => $invoice->company_id,
 | 
					            'company_id' => $invoice->company_id,
 | 
				
			||||||
                'documentable_type' => Invoice::class,
 | 
					            'documentable_type' => Invoice::class,
 | 
				
			||||||
                'documentable_id' => $invoice->id
 | 
					            'documentable_id' => $invoice->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        RecurringInvoice::factory()->create(['user_id' => $invoice->user->id, 'company_id' => $invoice->company->id, 'client_id' => $invoice->client_id]);
 | 
					        RecurringInvoice::factory()->create(['user_id' => $invoice->user->id, 'company_id' => $invoice->company->id, 'client_id' => $invoice->client_id]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
 | 
					        event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -73,8 +73,9 @@ class DemoMode extends Command
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        set_time_limit(0);
 | 
					        set_time_limit(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(config('ninja.is_docker'))
 | 
					        if (config('ninja.is_docker')) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->invoice_repo = new InvoiceRepository();
 | 
					        $this->invoice_repo = new InvoiceRepository();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -111,9 +112,9 @@ class DemoMode extends Command
 | 
				
			|||||||
        $this->info('Seeding Random Data');
 | 
					        $this->info('Seeding Random Data');
 | 
				
			||||||
        $this->createSmallAccount();
 | 
					        $this->createSmallAccount();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VersionCheck::dispatchNow();
 | 
					        (new VersionCheck())->handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CompanySizeCheck::dispatchNow();
 | 
					        (new CompanySizeCheck())->handle();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createSmallAccount()
 | 
					    private function createSmallAccount()
 | 
				
			||||||
@ -136,15 +137,15 @@ class DemoMode extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $settings = $company->settings;
 | 
					        $settings = $company->settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $settings->name = $faker->company;
 | 
					        $settings->name = $faker->company();
 | 
				
			||||||
        $settings->address1 = $faker->buildingNumber;
 | 
					        $settings->address1 = $faker->buildingNumber();
 | 
				
			||||||
        $settings->address2 = $faker->streetAddress;
 | 
					        $settings->address2 = $faker->streetAddress();
 | 
				
			||||||
        $settings->city = $faker->city;
 | 
					        $settings->city = $faker->city();
 | 
				
			||||||
        $settings->state = $faker->state;
 | 
					        $settings->state = $faker->state();
 | 
				
			||||||
        $settings->postal_code = $faker->postcode;
 | 
					        $settings->postal_code = $faker->postcode();
 | 
				
			||||||
        $settings->website = $faker->url;
 | 
					        $settings->website = $faker->url();
 | 
				
			||||||
        $settings->vat_number = (string) $faker->numberBetween(123456789, 987654321);
 | 
					        $settings->vat_number = (string) $faker->numberBetween(123456789, 987654321);
 | 
				
			||||||
        $settings->phone = (string) $faker->phoneNumber;
 | 
					        $settings->phone = (string) $faker->phoneNumber();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $company->settings = $settings;
 | 
					        $company->settings = $settings;
 | 
				
			||||||
        $company->save();
 | 
					        $company->save();
 | 
				
			||||||
@ -163,8 +164,8 @@ class DemoMode extends Command
 | 
				
			|||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CreateCompanyPaymentTerms::dispatchNow($company, $user);
 | 
					        (new CreateCompanyPaymentTerms($company, $user))->handle();
 | 
				
			||||||
        CreateCompanyTaskStatuses::dispatchNow($company, $user);
 | 
					        (new CreateCompanyTaskStatuses($company, $user))->handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $company_token = new CompanyToken;
 | 
					        $company_token = new CompanyToken;
 | 
				
			||||||
        $company_token->user_id = $user->id;
 | 
					        $company_token->user_id = $user->id;
 | 
				
			||||||
@ -182,7 +183,7 @@ class DemoMode extends Command
 | 
				
			|||||||
            'is_admin' => 1,
 | 
					            'is_admin' => 1,
 | 
				
			||||||
            'is_locked' => 0,
 | 
					            'is_locked' => 0,
 | 
				
			||||||
            'notifications' => CompanySettings::notificationDefaults(),
 | 
					            'notifications' => CompanySettings::notificationDefaults(),
 | 
				
			||||||
           // 'permissions' => '',
 | 
					            // 'permissions' => '',
 | 
				
			||||||
            'settings' => null,
 | 
					            'settings' => null,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -217,9 +218,9 @@ class DemoMode extends Command
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Product::factory()->count(50)->create([
 | 
					        Product::factory()->count(50)->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->info('Creating '.$this->count.' clients');
 | 
					        $this->info('Creating '.$this->count.' clients');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -265,22 +266,22 @@ class DemoMode extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // });
 | 
					        // });
 | 
				
			||||||
        $client = Client::factory()->create([
 | 
					        $client = Client::factory()->create([
 | 
				
			||||||
                'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ClientContact::factory()->create([
 | 
					        ClientContact::factory()->create([
 | 
				
			||||||
                    'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                    'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                    'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
                    'is_primary' => 1,
 | 
					            'is_primary' => 1,
 | 
				
			||||||
                ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ClientContact::factory()->count(rand(1, 5))->create([
 | 
					        ClientContact::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                    'user_id' => $user->id,
 | 
					            'user_id' => $user->id,
 | 
				
			||||||
                    'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                    'company_id' => $company->id,
 | 
					            'company_id' => $company->id,
 | 
				
			||||||
                ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client->number = $this->getNextClientNumber($client);
 | 
					        $client->number = $this->getNextClientNumber($client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -299,41 +300,37 @@ class DemoMode extends Command
 | 
				
			|||||||
    private function createExpense($client)
 | 
					    private function createExpense($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Expense::factory()->count(rand(1, 5))->create([
 | 
					        Expense::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                'user_id' => $client->user_id,
 | 
					            'user_id' => $client->user_id,
 | 
				
			||||||
                'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        Expense::all()->each(function ($expense){
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Expense::all()->each(function ($expense) {
 | 
				
			||||||
            $expense->number = $this->getNextExpenseNumber($expense);
 | 
					            $expense->number = $this->getNextExpenseNumber($expense);
 | 
				
			||||||
            $expense->save();
 | 
					            $expense->save();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createVendor($client, $assigned_user_id = null)
 | 
					    private function createVendor($client, $assigned_user_id = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $vendor = Vendor::factory()->create([
 | 
					        $vendor = Vendor::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user_id,
 | 
					            'user_id' => $client->user_id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VendorContact::factory()->create([
 | 
					        VendorContact::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'vendor_id' => $vendor->id,
 | 
					            'vendor_id' => $vendor->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'is_primary' => 1,
 | 
					            'is_primary' => 1,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VendorContact::factory()->count(rand(1, 5))->create([
 | 
					        VendorContact::factory()->count(rand(1, 5))->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'vendor_id' => $vendor->id,
 | 
					            'vendor_id' => $vendor->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'is_primary' => 0,
 | 
					            'is_primary' => 0,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $vendor->number = $this->getNextVendorNumber($vendor);
 | 
					        $vendor->number = $this->getNextVendorNumber($vendor);
 | 
				
			||||||
        $vendor->save();
 | 
					        $vendor->save();
 | 
				
			||||||
@ -342,25 +339,24 @@ class DemoMode extends Command
 | 
				
			|||||||
    private function createTask($client, $assigned_user_id = null)
 | 
					    private function createTask($client, $assigned_user_id = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $task = Task::factory()->create([
 | 
					        $task = Task::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'client_id' => $client->id
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $task->status_id = TaskStatus::all()->random()->id;
 | 
					        $task->status_id = TaskStatus::all()->random()->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $task->number = $this->getNextTaskNumber($task);
 | 
					        $task->number = $this->getNextTaskNumber($task);
 | 
				
			||||||
        $task->save();
 | 
					        $task->save();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function createProject($client, $assigned_user_id = null)
 | 
					    private function createProject($client, $assigned_user_id = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $project = Project::factory()->create([
 | 
					        $project = Project::factory()->create([
 | 
				
			||||||
                'user_id' => $client->user->id,
 | 
					            'user_id' => $client->user->id,
 | 
				
			||||||
                'company_id' => $client->company_id,
 | 
					            'company_id' => $client->company_id,
 | 
				
			||||||
                'client_id' => $client->id,
 | 
					            'client_id' => $client->id,
 | 
				
			||||||
            ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $project->number = $this->getNextProjectNumber($project);
 | 
					        $project->number = $this->getNextProjectNumber($project);
 | 
				
			||||||
        $project->save();
 | 
					        $project->save();
 | 
				
			||||||
@ -399,7 +395,7 @@ class DemoMode extends Command
 | 
				
			|||||||
        //     $invoice->tax_rate3 = 5;
 | 
					        //     $invoice->tax_rate3 = 5;
 | 
				
			||||||
        // }
 | 
					        // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // $invoice->custom_value1 = $faker->date;
 | 
					        // $invoice->custom_value1 = $faker->date();
 | 
				
			||||||
        // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
					        // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->save();
 | 
					        $invoice->save();
 | 
				
			||||||
@ -466,7 +462,7 @@ class DemoMode extends Command
 | 
				
			|||||||
        //     $invoice->tax_rate3 = 5;
 | 
					        //     $invoice->tax_rate3 = 5;
 | 
				
			||||||
        // }
 | 
					        // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // $invoice->custom_value1 = $faker->date;
 | 
					        // $invoice->custom_value1 = $faker->date();
 | 
				
			||||||
        // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
					        // $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice->save();
 | 
					        $invoice->save();
 | 
				
			||||||
 | 
				
			|||||||
@ -64,11 +64,8 @@ class DesignUpdate extends Command
 | 
				
			|||||||
                $this->handleOnDb($db);
 | 
					                $this->handleOnDb($db);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MultiDB::setDB($current_db);
 | 
					            MultiDB::setDB($current_db);
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function handleOnDb()
 | 
					    private function handleOnDb()
 | 
				
			||||||
 | 
				
			|||||||
@ -71,26 +71,27 @@ class HostedMigrations extends Command
 | 
				
			|||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->buildCache();
 | 
					        $this->buildCache();
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        if(!MultiDB::userFindAndSetDb($this->option('email'))){
 | 
					        if (! MultiDB::userFindAndSetDb($this->option('email'))) {
 | 
				
			||||||
            $this->info("Could not find a user with that email address");
 | 
					            $this->info('Could not find a user with that email address');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user = User::where('email', $this->option('email'))->first();
 | 
					        $user = User::where('email', $this->option('email'))->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!$user){
 | 
					        if (! $user) {
 | 
				
			||||||
            $this->info("There was a problem getting the user, did you set the right DB?");
 | 
					            $this->info('There was a problem getting the user, did you set the right DB?');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $path = public_path('storage/migrations/import');
 | 
					        $path = public_path('storage/migrations/import');
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $directory = new DirectoryIterator($path);
 | 
					        $directory = new DirectoryIterator($path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($directory as $file) {
 | 
					        foreach ($directory as $file) {
 | 
				
			||||||
            if ($file->getExtension() === 'zip') {
 | 
					            if ($file->getExtension() === 'zip') {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                $company = $user->companies()->first();
 | 
					                $company = $user->companies()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $this->info('Started processing: '.$file->getBasename().' at '.now());
 | 
					                $this->info('Started processing: '.$file->getBasename().' at '.now());
 | 
				
			||||||
@ -104,14 +105,13 @@ class HostedMigrations extends Command
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME);
 | 
					                    $filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME);
 | 
				
			||||||
                        
 | 
					
 | 
				
			||||||
                    $zip->extractTo(public_path("storage/migrations/{$filename}"));
 | 
					                    $zip->extractTo(public_path("storage/migrations/{$filename}"));
 | 
				
			||||||
                    $zip->close();
 | 
					                    $zip->close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $import_file = public_path("storage/migrations/$filename/migration.json");
 | 
					                    $import_file = public_path("storage/migrations/$filename/migration.json");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Import::dispatch($import_file, $user->companies()->first(), $user);
 | 
					                    Import::dispatch($import_file, $user->companies()->first(), $user);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                } catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
 | 
					                } catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
 | 
				
			||||||
                    \Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
 | 
					                    \Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -122,5 +122,4 @@ class HostedMigrations extends Command
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -41,21 +41,16 @@ class HostedUsers extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        Company::on('db-ninja-01')->each(function ($company) {
 | 
				
			||||||
        Company::on('db-ninja-01')->each(function ($company){
 | 
					            if (Ninja::isHosted()) {
 | 
				
			||||||
 | 
					                (new \Modules\Admin\Jobs\Account\NinjaUser([], $company))->handle();
 | 
				
			||||||
            if(Ninja::isHosted())
 | 
					            }
 | 
				
			||||||
                \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Company::on('db-ninja-02')->each(function ($company){
 | 
					        Company::on('db-ninja-02')->each(function ($company) {
 | 
				
			||||||
            
 | 
					            if (Ninja::isHosted()) {
 | 
				
			||||||
            if(Ninja::isHosted())
 | 
					                (new \Modules\Admin\Jobs\Account\NinjaUser([], $company))->handle();
 | 
				
			||||||
                \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
 | 
					            }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -77,9 +77,9 @@ class ImportMigrations extends Command
 | 
				
			|||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->buildCache();
 | 
					        $this->buildCache();
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        $path = $this->option('path') ?? public_path('storage/migrations/import');
 | 
					        $path = $this->option('path') ?? public_path('storage/migrations/import');
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $directory = new DirectoryIterator($path);
 | 
					        $directory = new DirectoryIterator($path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($directory as $file) {
 | 
					        foreach ($directory as $file) {
 | 
				
			||||||
@ -98,7 +98,7 @@ class ImportMigrations extends Command
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME);
 | 
					                    $filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME);
 | 
				
			||||||
                        
 | 
					
 | 
				
			||||||
                    $zip->extractTo(public_path("storage/migrations/{$filename}"));
 | 
					                    $zip->extractTo(public_path("storage/migrations/{$filename}"));
 | 
				
			||||||
                    $zip->close();
 | 
					                    $zip->close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -124,7 +124,7 @@ class ImportMigrations extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $user = User::factory()->create([
 | 
					        $user = User::factory()->create([
 | 
				
			||||||
            'account_id' => $account->id,
 | 
					            'account_id' => $account->id,
 | 
				
			||||||
            'email' => Str::random(10) . "@example.com",
 | 
					            'email' => Str::random(10).'@example.com',
 | 
				
			||||||
            'confirmation_code' => $this->createDbHash($company->db),
 | 
					            'confirmation_code' => $this->createDbHash($company->db),
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -137,7 +137,7 @@ class ImportMigrations extends Command
 | 
				
			|||||||
            'name' => 'First token',
 | 
					            'name' => 'First token',
 | 
				
			||||||
            'token' => Str::random(64),
 | 
					            'token' => Str::random(64),
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $user->companies()->attach($company->id, [
 | 
					        $user->companies()->attach($company->id, [
 | 
				
			||||||
            'account_id' => $account->id,
 | 
					            'account_id' => $account->id,
 | 
				
			||||||
            'is_owner' => 1,
 | 
					            'is_owner' => 1,
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,6 @@ class MobileLocalization extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $description = 'Generate mobile localization resources';
 | 
					    protected $description = 'Generate mobile localization resources';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new command instance.
 | 
					     * Create a new command instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -83,9 +82,9 @@ class MobileLocalization extends Command
 | 
				
			|||||||
                    $text = $resources->$key;
 | 
					                    $text = $resources->$key;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $text = str_replace(array('<b>', '</b>'), '', $text);
 | 
					                $text = str_replace(['<b>', '</b>'], '', $text);
 | 
				
			||||||
                $text = str_replace(array('<i>', '</i>'), '', $text);
 | 
					                $text = str_replace(['<i>', '</i>'], '', $text);
 | 
				
			||||||
                $text = str_replace(array('<strong>', '</strong>'), '', $text);
 | 
					                $text = str_replace(['<strong>', '</strong>'], '', $text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                echo "'$key': '$text',\n";
 | 
					                echo "'$key': '$text',\n";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -103,11 +102,11 @@ class MobileLocalization extends Command
 | 
				
			|||||||
        $end = strpos($data, '},', $start);
 | 
					        $end = strpos($data, '},', $start);
 | 
				
			||||||
        $data = substr($data, $start, $end - $start - 5);
 | 
					        $data = substr($data, $start, $end - $start - 5);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = str_replace("\n", "", $data);
 | 
					        $data = str_replace("\n", '', $data);
 | 
				
			||||||
        $data = str_replace("\"", "\'", $data);
 | 
					        $data = str_replace('"', "\'", $data);
 | 
				
			||||||
        $data = str_replace("'", "\"", $data);
 | 
					        $data = str_replace("'", '"', $data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return json_decode('{' . rtrim($data, ',') . '}');
 | 
					        return json_decode('{'.rtrim($data, ',').'}');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function getOptions()
 | 
					    protected function getOptions()
 | 
				
			||||||
@ -116,5 +115,4 @@ class MobileLocalization extends Command
 | 
				
			|||||||
            ['type', null, InputOption::VALUE_OPTIONAL, 'Type', null],
 | 
					            ['type', null, InputOption::VALUE_OPTIONAL, 'Type', null],
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -52,15 +52,10 @@ class ParallelCheckData extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    
 | 
					        $hash = Str::random(32);
 | 
				
			||||||
    	$hash = Str::random(32);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    	Company::cursor()->each(function ($company) use ($hash){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    		CheckCompanyData::dispatch($company, $hash)->onQueue('checkdata');
 | 
					 | 
				
			||||||
    		
 | 
					 | 
				
			||||||
    	});
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Company::cursor()->each(function ($company) use ($hash) {
 | 
				
			||||||
 | 
					            CheckCompanyData::dispatch($company, $hash)->onQueue('checkdata');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -50,24 +50,22 @@ class PostUpdate extends Command
 | 
				
			|||||||
            info("I wasn't able to migrate the data.");
 | 
					            info("I wasn't able to migrate the data.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info("finished migrating");
 | 
					        info('finished migrating');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $output = [];
 | 
					        $output = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // exec('vendor/bin/composer install --no-dev -o', $output);
 | 
					        // exec('vendor/bin/composer install --no-dev -o', $output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info(print_r($output,1));
 | 
					        info(print_r($output, 1));
 | 
				
			||||||
        info("finished running composer install ");
 | 
					        info('finished running composer install ');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            Artisan::call('optimize');
 | 
					            Artisan::call('optimize');
 | 
				
			||||||
 | 
					 | 
				
			||||||
        } catch (\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            info("I wasn't able to optimize.");
 | 
					            info("I wasn't able to optimize.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info("optimized");
 | 
					        info('optimized');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Artisan::call('view:clear');
 | 
					            Artisan::call('view:clear');
 | 
				
			||||||
@ -75,7 +73,7 @@ class PostUpdate extends Command
 | 
				
			|||||||
            info("I wasn't able to clear the views.");
 | 
					            info("I wasn't able to clear the views.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info("view cleared");
 | 
					        info('view cleared');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Artisan::call('queue:restart');
 | 
					            Artisan::call('queue:restart');
 | 
				
			||||||
@ -83,11 +81,10 @@ class PostUpdate extends Command
 | 
				
			|||||||
            info("I wasn't able to restart the queue.");
 | 
					            info("I wasn't able to restart the queue.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info("queue restarted");
 | 
					        info('queue restarted');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VersionCheck::dispatch();
 | 
					        VersionCheck::dispatch();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info("Sent for version check");
 | 
					        info('Sent for version check');
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -56,33 +56,19 @@ class ReactBuilder extends Command
 | 
				
			|||||||
        $directoryIterator = new \RecursiveDirectoryIterator(public_path('react'), \RecursiveDirectoryIterator::SKIP_DOTS);
 | 
					        $directoryIterator = new \RecursiveDirectoryIterator(public_path('react'), \RecursiveDirectoryIterator::SKIP_DOTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
 | 
					        foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
 | 
				
			||||||
 | 
					            if (str_contains($file->getFileName(), '.js')) {
 | 
				
			||||||
          if(str_contains($file->getFileName(), '.js')) {
 | 
					                if (str_contains($file->getFileName(), 'index.')) {
 | 
				
			||||||
 | 
					                    $includes .= '<script type="module" crossorigin src="/react/'.$file->getFileName().'"></script>'."\n";
 | 
				
			||||||
            if(str_contains($file->getFileName(), 'index.')){            
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $includes .= '<link rel="modulepreload" href="/react/'.$file->getFileName().'">'."\n";
 | 
				
			||||||
                $includes .= '<script type="module" crossorigin src="/react/' . $file->getFileName() . '"></script>'."\n";
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $includes .= '<link rel="modulepreload" href="/react/' . $file->getFileName() . '">'."\n";
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          }
 | 
					            if (str_contains($file->getFileName(), '.css')) {
 | 
				
			||||||
 | 
					                $includes .= '<link rel="stylesheet" href="/react/'.$file->getFileName().'">'."\n";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
          if(str_contains($file->getFileName(), '.css')) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $includes .= '<link rel="stylesheet" href="/react/' . $file->getFileName() . '">'."\n";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        file_put_contents(resource_path('views/react/head.blade.php'), $includes);
 | 
					        file_put_contents(resource_path('views/react/head.blade.php'), $includes);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -47,6 +47,6 @@ class RecurringCommand extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        RecurringInvoicesCron::dispatchNow();
 | 
					        (new RecurringInvoicesCron())->handle();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -42,10 +42,10 @@ class S3Cleanup extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (! Ninja::isHosted()) {
 | 
				
			||||||
        if(!Ninja::isHosted())
 | 
					 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $c1 = Company::on('db-ninja-01')->pluck('company_key');
 | 
					        $c1 = Company::on('db-ninja-01')->pluck('company_key');
 | 
				
			||||||
        $c2 = Company::on('db-ninja-02')->pluck('company_key');
 | 
					        $c2 = Company::on('db-ninja-02')->pluck('company_key');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -53,23 +53,20 @@ class S3Cleanup extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $directories = Storage::disk(config('filesystems.default'))->directories();
 | 
					        $directories = Storage::disk(config('filesystems.default'))->directories();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->LogMessage("Disk Cleanup");
 | 
					        $this->LogMessage('Disk Cleanup');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            foreach($directories as $dir)
 | 
					        foreach ($directories as $dir) {
 | 
				
			||||||
            {
 | 
					            if (! in_array($dir, $merged)) {
 | 
				
			||||||
                if(!in_array($dir, $merged))
 | 
					                $this->logMessage("Deleting $dir");
 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    $this->logMessage("Deleting $dir");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    /* Ensure we are not deleting the root folder */
 | 
					                /* Ensure we are not deleting the root folder */
 | 
				
			||||||
                    if(strlen($dir) > 1)
 | 
					                if (strlen($dir) > 1) {
 | 
				
			||||||
                        Storage::disk(config('filesystems.default'))->deleteDirectory($dir);
 | 
					                    Storage::disk(config('filesystems.default'))->deleteDirectory($dir);
 | 
				
			||||||
                    
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }        
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        $this->logMessage("exiting");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->logMessage('exiting');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function logMessage($str)
 | 
					    private function logMessage($str)
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ use Illuminate\Support\Facades\App;
 | 
				
			|||||||
class SendRemindersCron extends Command
 | 
					class SendRemindersCron extends Command
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use MakesReminders, MakesDates;
 | 
					    use MakesReminders, MakesDates;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The name and signature of the console command.
 | 
					     * The name and signature of the console command.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -60,56 +61,49 @@ class SendRemindersCron extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        Invoice::where('next_send_date', '<=', now()->toDateTimeString())
 | 
					        Invoice::where('next_send_date', '<=', now()->toDateTimeString())
 | 
				
			||||||
                 ->whereNull('deleted_at')
 | 
					                 ->whereNull('deleted_at')
 | 
				
			||||||
                 ->where('is_deleted', 0)
 | 
					                 ->where('is_deleted', 0)
 | 
				
			||||||
                 ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
 | 
					                 ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
 | 
				
			||||||
                 ->where('balance', '>', 0)
 | 
					                 ->where('balance', '>', 0)
 | 
				
			||||||
                 ->whereHas('client', function ($query) {
 | 
					                 ->whereHas('client', function ($query) {
 | 
				
			||||||
                     $query->where('is_deleted',0)
 | 
					                     $query->where('is_deleted', 0)
 | 
				
			||||||
                           ->where('deleted_at', NULL);
 | 
					                           ->where('deleted_at', null);
 | 
				
			||||||
                 })
 | 
					                 })
 | 
				
			||||||
                 ->whereHas('company', function ($query) {
 | 
					                 ->whereHas('company', function ($query) {
 | 
				
			||||||
                     $query->where('is_disabled',0);
 | 
					                     $query->where('is_disabled', 0);
 | 
				
			||||||
                 })
 | 
					                 })
 | 
				
			||||||
                 ->with('invitations')->cursor()->each(function ($invoice) {
 | 
					                 ->with('invitations')->cursor()->each(function ($invoice) {
 | 
				
			||||||
 | 
					                     if ($invoice->isPayable()) {
 | 
				
			||||||
 | 
					                         $reminder_template = $invoice->calculateTemplate('invoice');
 | 
				
			||||||
 | 
					                         $invoice->service()->touchReminder($reminder_template)->save();
 | 
				
			||||||
 | 
					                         $invoice = $this->calcLateFee($invoice, $reminder_template);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($invoice->isPayable()) {
 | 
					                         //check if this reminder needs to be emailed
 | 
				
			||||||
                $reminder_template = $invoice->calculateTemplate('invoice');
 | 
					                         if (in_array($reminder_template, ['reminder1', 'reminder2', 'reminder3']) && $invoice->client->getSetting('enable_'.$reminder_template)) {
 | 
				
			||||||
                $invoice->service()->touchReminder($reminder_template)->save();
 | 
					                             $invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
 | 
				
			||||||
                $invoice = $this->calcLateFee($invoice, $reminder_template);
 | 
					                                 EmailEntity::dispatch($invitation, $invitation->company, $reminder_template);
 | 
				
			||||||
 | 
					                                 nlog("Firing reminder email for invoice {$invoice->number}");
 | 
				
			||||||
 | 
					                             });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                //check if this reminder needs to be emailed
 | 
					                             if ($invoice->invitations->count() > 0) {
 | 
				
			||||||
                if(in_array($reminder_template, ['reminder1','reminder2','reminder3']) && $invoice->client->getSetting("enable_".$reminder_template))
 | 
					                                 event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $reminder_template));
 | 
				
			||||||
                {
 | 
					                             }
 | 
				
			||||||
                    $invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
 | 
					                         }
 | 
				
			||||||
                        EmailEntity::dispatch($invitation, $invitation->company, $reminder_template);
 | 
					                         $invoice->service()->setReminder()->save();
 | 
				
			||||||
                        nlog("Firing reminder email for invoice {$invoice->number}");
 | 
					                     } else {
 | 
				
			||||||
                    });
 | 
					                         $invoice->next_send_date = null;
 | 
				
			||||||
 | 
					                         $invoice->save();
 | 
				
			||||||
 | 
					                     }
 | 
				
			||||||
 | 
					                 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ($invoice->invitations->count() > 0) {
 | 
					        //  SendReminders::dispatchNow();
 | 
				
			||||||
                        event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $reminder_template));
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                $invoice->service()->setReminder()->save();
 | 
					 | 
				
			||||||
                
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $invoice->next_send_date = null;
 | 
					 | 
				
			||||||
                $invoice->save();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
       //  SendReminders::dispatchNow();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
       // $this->webHookOverdueInvoices();
 | 
					       // $this->webHookOverdueInvoices();
 | 
				
			||||||
       // $this->webHookExpiredQuotes();
 | 
					       // $this->webHookExpiredQuotes();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private function calcLateFee($invoice, $template) :Invoice
 | 
				
			||||||
 private function calcLateFee($invoice, $template) :Invoice
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $late_fee_amount = 0;
 | 
					        $late_fee_amount = 0;
 | 
				
			||||||
        $late_fee_percent = 0;
 | 
					        $late_fee_percent = 0;
 | 
				
			||||||
@ -151,7 +145,6 @@ class SendRemindersCron extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private function setLateFee($invoice, $amount, $percent) :Invoice
 | 
					    private function setLateFee($invoice, $amount, $percent) :Invoice
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        $t = app('translator');
 | 
					        $t = app('translator');
 | 
				
			||||||
        $t->replace(Ninja::transformTranslations($invoice->client->getMergedSettings()));
 | 
					        $t->replace(Ninja::transformTranslations($invoice->client->getMergedSettings()));
 | 
				
			||||||
@ -187,49 +180,20 @@ class SendRemindersCron extends Command
 | 
				
			|||||||
        $invoice->calc()->getInvoice()->save();
 | 
					        $invoice->calc()->getInvoice()->save();
 | 
				
			||||||
        $invoice->fresh();
 | 
					        $invoice->fresh();
 | 
				
			||||||
        $invoice->service()->deletePdf();
 | 
					        $invoice->service()->deletePdf();
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        /* Refresh the client here to ensure the balance is fresh */
 | 
					        /* Refresh the client here to ensure the balance is fresh */
 | 
				
			||||||
        $client = $invoice->client;
 | 
					        $client = $invoice->client;
 | 
				
			||||||
        $client = $client->fresh();
 | 
					        $client = $client->fresh();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        nlog("adjusting client balance and invoice balance by ". ($invoice->balance - $temp_invoice_balance));
 | 
					        nlog('adjusting client balance and invoice balance by '.($invoice->balance - $temp_invoice_balance));
 | 
				
			||||||
        $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save();
 | 
					        $client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save();
 | 
				
			||||||
        $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}");
 | 
					        $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$invoice->number}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $invoice;
 | 
					        return $invoice;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function webHookOverdueInvoices()
 | 
					    private function webHookOverdueInvoices()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (! config('ninja.db.multi_db_enabled')) {
 | 
					        if (! config('ninja.db.multi_db_enabled')) {
 | 
				
			||||||
            $this->executeWebhooks();
 | 
					            $this->executeWebhooks();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
@ -240,12 +204,10 @@ class SendRemindersCron extends Command
 | 
				
			|||||||
                $this->executeWebhooks();
 | 
					                $this->executeWebhooks();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function webHookExpiredQuotes()
 | 
					    private function webHookExpiredQuotes()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function executeWebhooks()
 | 
					    private function executeWebhooks()
 | 
				
			||||||
@ -255,21 +217,18 @@ class SendRemindersCron extends Command
 | 
				
			|||||||
                          ->where('balance', '>', 0)
 | 
					                          ->where('balance', '>', 0)
 | 
				
			||||||
                          ->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
 | 
					                          ->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
 | 
				
			||||||
                          ->cursor();
 | 
					                          ->cursor();
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        $invoices->each(function ($invoice) {
 | 
					        $invoices->each(function ($invoice) {
 | 
				
			||||||
            WebhookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company);
 | 
					            WebhookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company);
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $quotes = Quote::where('is_deleted', 0)
 | 
					        $quotes = Quote::where('is_deleted', 0)
 | 
				
			||||||
                          ->where('status_id', Quote::STATUS_SENT)
 | 
					                          ->where('status_id', Quote::STATUS_SENT)
 | 
				
			||||||
                          ->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
 | 
					                          ->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
 | 
				
			||||||
                          ->cursor();
 | 
					                          ->cursor();
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        $quotes->each(function ($quote) {
 | 
					        $quotes->each(function ($quote) {
 | 
				
			||||||
            WebhookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company);
 | 
					            WebhookHandler::dispatch(Webhook::EVENT_EXPIRED_QUOTE, $quote, $quote->company);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -70,7 +70,7 @@ class SendTestEmails extends Command
 | 
				
			|||||||
        $user = User::factory()->create([
 | 
					        $user = User::factory()->create([
 | 
				
			||||||
            'account_id' => $account->id,
 | 
					            'account_id' => $account->id,
 | 
				
			||||||
            'confirmation_code' => '123',
 | 
					            'confirmation_code' => '123',
 | 
				
			||||||
            'email' => $faker->safeEmail,
 | 
					            'email' => $faker->safeEmail(),
 | 
				
			||||||
            'first_name' => 'John',
 | 
					            'first_name' => 'John',
 | 
				
			||||||
            'last_name' => 'Doe',
 | 
					            'last_name' => 'Doe',
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
@ -96,6 +96,6 @@ class SendTestEmails extends Command
 | 
				
			|||||||
        $nmo->settings = $user->account->companies()->first()->settings;
 | 
					        $nmo->settings = $user->account->companies()->first()->settings;
 | 
				
			||||||
        $nmo->to_user = $user;
 | 
					        $nmo->to_user = $user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        NinjaMailerJob::dispatchNow($nmo);
 | 
					        (new NinjaMailerJob($nmo))->handle();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -40,25 +40,17 @@ class SubdomainFill extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $c1 = Company::on('db-ninja-01')->whereNull('subdomain')->orWhere('subdomain', '')->get();
 | 
					        $c1 = Company::on('db-ninja-01')->whereNull('subdomain')->orWhere('subdomain', '')->get();
 | 
				
			||||||
        $c2 = Company::on('db-ninja-02')->whereNull('subdomain')->orWhere('subdomain', '')->get();
 | 
					        $c2 = Company::on('db-ninja-02')->whereNull('subdomain')->orWhere('subdomain', '')->get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $c1->each(function ($company) {
 | 
				
			||||||
        $c1->each(function ($company){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
					            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
				
			||||||
            $company->save();
 | 
					            $company->save();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $c2->each(function ($company){
 | 
					        $c2->each(function ($company) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
					            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
				
			||||||
            $company->save();
 | 
					            $company->save();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -69,8 +69,9 @@ class TranslationsExport extends Command
 | 
				
			|||||||
        'sv',
 | 
					        'sv',
 | 
				
			||||||
        'th',
 | 
					        'th',
 | 
				
			||||||
        'tr_TR',
 | 
					        'tr_TR',
 | 
				
			||||||
        'zh_TW'
 | 
					        'zh_TW',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new command instance.
 | 
					     * Create a new command instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -88,19 +89,14 @@ class TranslationsExport extends Command
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        Storage::makeDirectory(storage_path('lang'));
 | 
					        Storage::makeDirectory(storage_path('lang'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach($this->langs as $lang)
 | 
					        foreach ($this->langs as $lang) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Storage::makeDirectory(storage_path("lang/{$lang}"));
 | 
					            Storage::makeDirectory(storage_path("lang/{$lang}"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $translations = Lang::getLoader()->load($lang,'texts');
 | 
					            $translations = Lang::getLoader()->load($lang, 'texts');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Storage::put(storage_path("lang/{$lang}/{$lang}.json"), json_encode(Arr::dot($translations), JSON_UNESCAPED_UNICODE));
 | 
					            Storage::put(storage_path("lang/{$lang}/{$lang}.json"), json_encode(Arr::dot($translations), JSON_UNESCAPED_UNICODE));
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -43,7 +43,6 @@ class TypeCheck extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected $log = '';
 | 
					    protected $log = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new command instance.
 | 
					     * Create a new command instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -65,91 +64,74 @@ class TypeCheck extends Command
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $current_db = config('database.default');
 | 
					        $current_db = config('database.default');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($this->option('all'))
 | 
					        if ($this->option('all')) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (! config('ninja.db.multi_db_enabled')) {
 | 
					            if (! config('ninja.db.multi_db_enabled')) {
 | 
				
			||||||
                    $this->checkAll();
 | 
					                $this->checkAll();
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
 | 
					                foreach (MultiDB::$dbs as $db) {
 | 
				
			||||||
                foreach (MultiDB::$dbs as $db) 
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    MultiDB::setDB($db);
 | 
					                    MultiDB::setDB($db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $this->checkAll();
 | 
					                    $this->checkAll();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                MultiDB::setDB($current_db);
 | 
					                MultiDB::setDB($current_db);
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($this->option('client_id'))
 | 
					        if ($this->option('client_id')) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $client = MultiDB::findAndSetDbByClientId($this->option('client_id'));
 | 
					            $client = MultiDB::findAndSetDbByClientId($this->option('client_id'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($client)
 | 
					            if ($client) {
 | 
				
			||||||
                $this->checkClient($client);
 | 
					                $this->checkClient($client);
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $this->logMessage(date('Y-m-d h:i:s').' Could not find this client');
 | 
					                $this->logMessage(date('Y-m-d h:i:s').' Could not find this client');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($this->option('company_id'))
 | 
					        if ($this->option('company_id')) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $company = MultiDB::findAndSetDbByCompanyId($this->option('company_id'));
 | 
					            $company = MultiDB::findAndSetDbByCompanyId($this->option('company_id'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($company) {
 | 
				
			||||||
            if($company)
 | 
					 | 
				
			||||||
                $this->checkCompany($company);
 | 
					                $this->checkCompany($company);
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $this->logMessage(date('Y-m-d h:i:s').' Could not find this company');
 | 
					                $this->logMessage(date('Y-m-d h:i:s').' Could not find this company');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function checkClient($client)
 | 
					    private function checkClient($client)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->logMessage(date('Y-m-d h:i:s').' Checking Client => ' . $client->present()->name(). " " . $client->id);
 | 
					        $this->logMessage(date('Y-m-d h:i:s').' Checking Client => '.$client->present()->name().' '.$client->id);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $entity_settings = $this->checkSettingType($client->settings);
 | 
					 | 
				
			||||||
            $entity_settings->md5 = md5(time());
 | 
					 | 
				
			||||||
            $client->settings = $entity_settings;
 | 
					 | 
				
			||||||
            $client->save();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $entity_settings = $this->checkSettingType($client->settings);
 | 
				
			||||||
 | 
					        $entity_settings->md5 = md5(time());
 | 
				
			||||||
 | 
					        $client->settings = $entity_settings;
 | 
				
			||||||
 | 
					        $client->save();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function checkCompany($company)
 | 
					    private function checkCompany($company)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->logMessage(date('Y-m-d h:i:s').' Checking Company => ' . $company->present()->name(). " " . $company->id);
 | 
					        $this->logMessage(date('Y-m-d h:i:s').' Checking Company => '.$company->present()->name().' '.$company->id);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $company->saveSettings((array)$company->settings, $company);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $company->saveSettings((array) $company->settings, $company);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function checkAll()
 | 
					    private function checkAll()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->logMessage(date('Y-m-d h:i:s').' Checking all clients and companies.');
 | 
					        $this->logMessage(date('Y-m-d h:i:s').' Checking all clients and companies.');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Client::withTrashed()->cursor()->each( function ($client) {
 | 
					        Client::withTrashed()->cursor()->each(function ($client) {
 | 
				
			||||||
            $this->logMessage("Checking client {$client->id}");
 | 
					            $this->logMessage("Checking client {$client->id}");
 | 
				
			||||||
            $entity_settings = $this->checkSettingType($client->settings);
 | 
					            $entity_settings = $this->checkSettingType($client->settings);
 | 
				
			||||||
            $entity_settings->md5 = md5(time());
 | 
					            $entity_settings->md5 = md5(time());
 | 
				
			||||||
            $client->settings = $entity_settings;
 | 
					            $client->settings = $entity_settings;
 | 
				
			||||||
            $client->save();
 | 
					            $client->save();
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Company::cursor()->each( function ($company) {
 | 
					        Company::cursor()->each(function ($company) {
 | 
				
			||||||
            $this->logMessage("Checking company {$company->id}");
 | 
					            $this->logMessage("Checking company {$company->id}");
 | 
				
			||||||
            $company->saveSettings($company->settings, $company);
 | 
					            $company->saveSettings($company->settings, $company);
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function logMessage($str)
 | 
					    private function logMessage($str)
 | 
				
			||||||
@ -159,4 +141,3 @@ class TypeCheck extends Command
 | 
				
			|||||||
        $this->log .= $str."\n";
 | 
					        $this->log .= $str."\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -34,15 +34,6 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class Kernel extends ConsoleKernel
 | 
					class Kernel extends ConsoleKernel
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * The Artisan commands provided by your application.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @var array
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected $commands = [
 | 
					 | 
				
			||||||
        //
 | 
					 | 
				
			||||||
    ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Define the application's command schedule.
 | 
					     * Define the application's command schedule.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -51,7 +42,6 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function schedule(Schedule $schedule)
 | 
					    protected function schedule(Schedule $schedule)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $schedule->job(new VersionCheck)->daily();
 | 
					        $schedule->job(new VersionCheck)->daily();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $schedule->job(new DiskCleanup)->daily()->withoutOverlapping();
 | 
					        $schedule->job(new DiskCleanup)->daily()->withoutOverlapping();
 | 
				
			||||||
@ -78,17 +68,14 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $schedule->job(new SystemMaintenance)->weekly()->withoutOverlapping();
 | 
					        $schedule->job(new SystemMaintenance)->weekly()->withoutOverlapping();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(Ninja::isSelfHost())
 | 
					        if (Ninja::isSelfHost()) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $schedule->call(function () {
 | 
					            $schedule->call(function () {
 | 
				
			||||||
                Account::whereNotNull('id')->update(['is_scheduler_running' => true]);
 | 
					                Account::whereNotNull('id')->update(['is_scheduler_running' => true]);
 | 
				
			||||||
            })->everyFiveMinutes();
 | 
					            })->everyFiveMinutes();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Run hosted specific jobs */
 | 
					        /* Run hosted specific jobs */
 | 
				
			||||||
        if (Ninja::isHosted()) {
 | 
					        if (Ninja::isHosted()) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping();
 | 
					            $schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
 | 
					            $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
 | 
				
			||||||
@ -98,17 +85,13 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
            $schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('02:05')->withoutOverlapping();
 | 
					            $schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('02:05')->withoutOverlapping();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
 | 
					            $schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && !config('ninja.is_docker')) {
 | 
					        if (config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && ! config('ninja.is_docker')) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $schedule->command('queue:work database --stop-when-empty --memory=256')->everyMinute()->withoutOverlapping();
 | 
					            $schedule->command('queue:work database --stop-when-empty --memory=256')->everyMinute()->withoutOverlapping();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping();
 | 
					            $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -118,7 +101,7 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function commands()
 | 
					    protected function commands()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->load(__DIR__ . '/Commands');
 | 
					        $this->load(__DIR__.'/Commands');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        require base_path('routes/console.php');
 | 
					        require base_path('routes/console.php');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,8 @@ class AccountPlatform extends GenericMixedMetric
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public $string_metric7 = 'ip_address';
 | 
					    public $string_metric7 = 'ip_address';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric5, $string_metric6, $string_metric7) {
 | 
					    public function __construct($string_metric5, $string_metric6, $string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->string_metric5 = $string_metric5;
 | 
					        $this->string_metric5 = $string_metric5;
 | 
				
			||||||
        $this->string_metric6 = $string_metric6;
 | 
					        $this->string_metric6 = $string_metric6;
 | 
				
			||||||
        $this->string_metric7 = $string_metric7;
 | 
					        $this->string_metric7 = $string_metric7;
 | 
				
			||||||
 | 
				
			|||||||
@ -52,6 +52,7 @@ class DbQuery extends GenericMixedMetric
 | 
				
			|||||||
    public $string_metric6 = 'url';
 | 
					    public $string_metric6 = 'url';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $string_metric7 = 'ip_address';
 | 
					    public $string_metric7 = 'ip_address';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The counter
 | 
					     * The counter
 | 
				
			||||||
     * set to 1.
 | 
					     * set to 1.
 | 
				
			||||||
@ -62,7 +63,8 @@ class DbQuery extends GenericMixedMetric
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public $double_metric2 = 1;
 | 
					    public $double_metric2 = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric5, $string_metric6, $int_metric1, $double_metric2, $string_metric7) {
 | 
					    public function __construct($string_metric5, $string_metric6, $int_metric1, $double_metric2, $string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->int_metric1 = $int_metric1;
 | 
					        $this->int_metric1 = $int_metric1;
 | 
				
			||||||
        $this->string_metric5 = $string_metric5;
 | 
					        $this->string_metric5 = $string_metric5;
 | 
				
			||||||
        $this->string_metric6 = $string_metric6;
 | 
					        $this->string_metric6 = $string_metric6;
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,8 @@ class EmailFailure extends GenericMixedMetric
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $string_metric7 = '';
 | 
					    public $string_metric7 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric7) {
 | 
					    public function __construct($string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->string_metric7 = $string_metric7;
 | 
					        $this->string_metric7 = $string_metric7;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,6 @@ use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class EmailSuccess extends GenericMixedMetric
 | 
					class EmailSuccess extends GenericMixedMetric
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The type of Sample.
 | 
					     * The type of Sample.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -72,8 +71,8 @@ class EmailSuccess extends GenericMixedMetric
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $string_metric7 = '';
 | 
					    public $string_metric7 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric7) {
 | 
					    public function __construct($string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->string_metric7 = $string_metric7;
 | 
					        $this->string_metric7 = $string_metric7;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,8 @@ class EmailBounce extends GenericMixedMetric
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $int_metric1 = 1;
 | 
					    public $int_metric1 = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric5,$string_metric6,$string_metric7) {
 | 
					    public function __construct($string_metric5, $string_metric6, $string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->string_metric5 = $string_metric5;
 | 
					        $this->string_metric5 = $string_metric5;
 | 
				
			||||||
        $this->string_metric6 = $string_metric6;
 | 
					        $this->string_metric6 = $string_metric6;
 | 
				
			||||||
        $this->string_metric7 = $string_metric7;
 | 
					        $this->string_metric7 = $string_metric7;
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,8 @@ class EmailSpam extends GenericMixedMetric
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $int_metric1 = 1;
 | 
					    public $int_metric1 = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($string_metric5,$string_metric6,$string_metric7) {
 | 
					    public function __construct($string_metric5, $string_metric6, $string_metric7)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->string_metric5 = $string_metric5;
 | 
					        $this->string_metric5 = $string_metric5;
 | 
				
			||||||
        $this->string_metric6 = $string_metric6;
 | 
					        $this->string_metric6 = $string_metric6;
 | 
				
			||||||
        $this->string_metric7 = $string_metric7;
 | 
					        $this->string_metric7 = $string_metric7;
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,6 @@ use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class QueueSize extends GenericMixedMetric
 | 
					class QueueSize extends GenericMixedMetric
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The type of Sample.
 | 
					     * The type of Sample.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -72,8 +71,8 @@ class QueueSize extends GenericMixedMetric
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public $string_metric7 = '';
 | 
					    public $string_metric7 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct($int_metric1) {
 | 
					    public function __construct($int_metric1)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        $this->int_metric1 = $int_metric1;
 | 
					        $this->int_metric1 = $int_metric1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\DataMapper\Billing;
 | 
					namespace App\DataMapper\Billing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class SubscriptionContextMapper
 | 
					class SubscriptionContextMapper
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\DataMapper\Billing;
 | 
					namespace App\DataMapper\Billing;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class WebhookConfiguration
 | 
					class WebhookConfiguration
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -33,11 +32,11 @@ class WebhookConfiguration
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public $post_purchase_body =  '';
 | 
					    public $post_purchase_body = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var string
 | 
					     * @var string
 | 
				
			||||||
     */ 
 | 
					     */
 | 
				
			||||||
    public $post_purchase_rest_method = 'POST';
 | 
					    public $post_purchase_rest_method = 'POST';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -13,89 +13,88 @@ namespace App\DataMapper;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class ClientRegistrationFields
 | 
					class ClientRegistrationFields
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static function generate()
 | 
					    public static function generate()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $data = 
 | 
					        $data =
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'first_name',
 | 
					                'key' => 'first_name',
 | 
				
			||||||
                'required' => true
 | 
					                'required' => true,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'last_name',
 | 
					                'key' => 'last_name',
 | 
				
			||||||
                'required' => true
 | 
					                'required' => true,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'email',
 | 
					                'key' => 'email',
 | 
				
			||||||
                'required' => true
 | 
					                'required' => true,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'phone',
 | 
					                'key' => 'phone',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'password',
 | 
					                'key' => 'password',
 | 
				
			||||||
                'required' => true
 | 
					                'required' => true,
 | 
				
			||||||
            ], 
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'name',
 | 
					                'key' => 'name',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'website',
 | 
					                'key' => 'website',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'address1',
 | 
					                'key' => 'address1',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'address2',
 | 
					                'key' => 'address2',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'city',
 | 
					                'key' => 'city',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'state',
 | 
					                'key' => 'state',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'postal_code',
 | 
					                'key' => 'postal_code',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],            
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'country_id',
 | 
					                'key' => 'country_id',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],            
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'custom_value1',
 | 
					                'key' => 'custom_value1',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],            
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'custom_value2',
 | 
					                'key' => 'custom_value2',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'custom_value3',
 | 
					                'key' => 'custom_value3',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],            
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'custom_value4',
 | 
					                'key' => 'custom_value4',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],                       
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'public_notes',
 | 
					                'key' => 'public_notes',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],   
 | 
					            ],
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
                'key' => 'vat_number',
 | 
					                'key' => 'vat_number',
 | 
				
			||||||
                'required' => false
 | 
					                'required' => false,
 | 
				
			||||||
            ],          
 | 
					            ],
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $data;
 | 
					        return $data;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -30,6 +30,7 @@ class ClientSettings extends BaseSettings
 | 
				
			|||||||
     * Settings which which are unique to client settings.
 | 
					     * Settings which which are unique to client settings.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public $industry_id;
 | 
					    public $industry_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $size_id;
 | 
					    public $size_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static $casts = [
 | 
					    public static $casts = [
 | 
				
			||||||
 | 
				
			|||||||
@ -31,20 +31,29 @@ class CompanySettings extends BaseSettings
 | 
				
			|||||||
    public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented
 | 
					    public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_client_portal_tasks = false; //@ben to implement
 | 
					    public $enable_client_portal_tasks = false; //@ben to implement
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $show_all_tasks_client_portal = 'invoiced'; // all, uninvoiced, invoiced
 | 
					    public $show_all_tasks_client_portal = 'invoiced'; // all, uninvoiced, invoiced
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_client_portal_password = false; //@implemented
 | 
					    public $enable_client_portal_password = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_client_portal = true; //@implemented
 | 
					    public $enable_client_portal = true; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_client_portal_dashboard = false; // @TODO There currently is no dashboard so this is pending
 | 
					    public $enable_client_portal_dashboard = false; // @TODO There currently is no dashboard so this is pending
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $signature_on_pdf = false; //@implemented
 | 
					    public $signature_on_pdf = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $document_email_attachment = false; //@TODO I assume this is 3rd party attachments on the entity to be included
 | 
					    public $document_email_attachment = false; //@TODO I assume this is 3rd party attachments on the entity to be included
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_design_id = '1'; //?@deprecated
 | 
					    public $portal_design_id = '1'; //?@deprecated
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $timezone_id = ''; //@implemented
 | 
					    public $timezone_id = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $date_format_id = ''; //@implemented
 | 
					    public $date_format_id = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $military_time = false; // @TODOImplemented in Tasks only?
 | 
					    public $military_time = false; // @TODOImplemented in Tasks only?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $language_id = ''; //@implemented
 | 
					    public $language_id = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $show_currency_code = false; //@implemented
 | 
					    public $show_currency_code = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company_gateway_ids = ''; //@implemented
 | 
					    public $company_gateway_ids = ''; //@implemented
 | 
				
			||||||
@ -52,243 +61,379 @@ class CompanySettings extends BaseSettings
 | 
				
			|||||||
    public $currency_id = '1'; //@implemented
 | 
					    public $currency_id = '1'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value1 = ''; //@implemented
 | 
					    public $custom_value1 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value2 = ''; //@implemented
 | 
					    public $custom_value2 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value3 = ''; //@implemented
 | 
					    public $custom_value3 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value4 = ''; //@implemented
 | 
					    public $custom_value4 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $default_task_rate = 0; // @TODO Where do we inject this?
 | 
					    public $default_task_rate = 0; // @TODO Where do we inject this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_terms = ''; //@implemented
 | 
					    public $payment_terms = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $send_reminders = true; //@TODO
 | 
					    public $send_reminders = true; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending
 | 
					    public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_message_unpaid_invoice = '';
 | 
					    public $custom_message_unpaid_invoice = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_message_paid_invoice = '';
 | 
					    public $custom_message_paid_invoice = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_message_unapproved_quote = '';
 | 
					    public $custom_message_unapproved_quote = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_archive_quote = false; //@implemented
 | 
					    public $auto_archive_quote = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_convert_quote = true; //@implemented
 | 
					    public $auto_convert_quote = true; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send?
 | 
					    public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $entity_send_time = 6;
 | 
					    public $entity_send_time = 6;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $inclusive_taxes = false; //@implemented
 | 
					    public $inclusive_taxes = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_footer = ''; //@implmented
 | 
					    public $quote_footer = ''; //@implmented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $translations;
 | 
					    public $translations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $counter_number_applied = 'when_saved'; // when_saved , when_sent //@implemented
 | 
					    public $counter_number_applied = 'when_saved'; // when_saved , when_sent //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_number_applied = 'when_saved'; // when_saved , when_sent //@implemented
 | 
					    public $quote_number_applied = 'when_saved'; // when_saved , when_sent //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Counters */
 | 
					    /* Counters */
 | 
				
			||||||
    public $invoice_number_pattern = ''; //@implemented
 | 
					    public $invoice_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_number_counter = 1; //@implemented
 | 
					    public $invoice_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_invoice_number_pattern = ''; //@implemented
 | 
					    public $recurring_invoice_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_invoice_number_counter = 1; //@implemented
 | 
					    public $recurring_invoice_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_number_pattern = ''; //@implemented
 | 
					    public $quote_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_number_counter = 1; //@implemented
 | 
					    public $quote_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_number_pattern = ''; //@implemented
 | 
					    public $client_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_number_counter = 1; //@implemented
 | 
					    public $client_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_number_pattern = ''; //@implemented
 | 
					    public $credit_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_number_counter = 1; //@implemented
 | 
					    public $credit_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $task_number_pattern = ''; //@implemented
 | 
					    public $task_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $task_number_counter = 1; //@implemented
 | 
					    public $task_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $expense_number_pattern = ''; //@implemented
 | 
					    public $expense_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $expense_number_counter = 1; //@implemented
 | 
					    public $expense_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_expense_number_pattern = '';
 | 
					    public $recurring_expense_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_expense_number_counter = 1;
 | 
					    public $recurring_expense_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_quote_number_pattern = '';
 | 
					    public $recurring_quote_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_quote_number_counter = 1;
 | 
					    public $recurring_quote_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vendor_number_pattern = ''; //@implemented
 | 
					    public $vendor_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vendor_number_counter = 1; //@implemented
 | 
					    public $vendor_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $ticket_number_pattern = ''; //@implemented
 | 
					    public $ticket_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $ticket_number_counter = 1; //@implemented
 | 
					    public $ticket_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_number_pattern = ''; //@implemented
 | 
					    public $payment_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_number_counter = 1; //@implemented
 | 
					    public $payment_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $project_number_pattern = ''; //@implemented
 | 
					    public $project_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $project_number_counter = 1; //@implemented
 | 
					    public $project_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_number_pattern = ''; //@implemented
 | 
					    public $purchase_order_number_pattern = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_number_counter = 1; //@implemented
 | 
					    public $purchase_order_number_counter = 1; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $shared_invoice_quote_counter = false; //@implemented
 | 
					    public $shared_invoice_quote_counter = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $shared_invoice_credit_counter = false; //@implemented
 | 
					    public $shared_invoice_credit_counter = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $recurring_number_prefix = ''; //@implemented
 | 
					    public $recurring_number_prefix = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $reset_counter_frequency_id = '0'; //@implemented
 | 
					    public $reset_counter_frequency_id = '0'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $reset_counter_date = ''; //@implemented
 | 
					    public $reset_counter_date = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $counter_padding = 4; //@implemented
 | 
					    public $counter_padding = 4; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_bill = 'off'; //off,always,optin,optout //@implemented
 | 
					    public $auto_bill = 'off'; //off,always,optin,optout //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date //@implemented
 | 
					    public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_terms = ''; //@implemented
 | 
					    public $invoice_terms = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_terms = ''; //@implemented
 | 
					    public $quote_terms = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_taxes = 0; // ? used in AP only?
 | 
					    public $invoice_taxes = 0; // ? used in AP only?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
					    public $invoice_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
					    public $quote_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
					    public $credit_design_id = 'Wpmbk5ezJn'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_design_id = 'Wpmbk5ezJn';
 | 
					    public $purchase_order_design_id = 'Wpmbk5ezJn';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_footer = ''; //@implemented
 | 
					    public $purchase_order_footer = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_terms = ''; //@implemented
 | 
					    public $purchase_order_terms = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $purchase_order_public_notes = ''; //@implemented
 | 
					    public $purchase_order_public_notes = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $require_purchase_order_signature = false;  //@TODO ben to confirm
 | 
					    public $require_purchase_order_signature = false;  //@TODO ben to confirm
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public $invoice_footer = ''; //@implemented
 | 
					    public $invoice_footer = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_footer = ''; //@implemented
 | 
					    public $credit_footer = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_terms = ''; //@implemented
 | 
					    public $credit_terms = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_labels = ''; //@TODO used in AP only?
 | 
					    public $invoice_labels = ''; //@TODO used in AP only?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name1 = ''; //@TODO where do we use this?
 | 
					    public $tax_name1 = ''; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate1 = 0; //@TODO where do we use this?
 | 
					    public $tax_rate1 = 0; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name2 = ''; //@TODO where do we use this?
 | 
					    public $tax_name2 = ''; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate2 = 0; //@TODO where do we use this?
 | 
					    public $tax_rate2 = 0; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name3 = ''; //@TODO where do we use this?
 | 
					    public $tax_name3 = ''; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate3 = 0; //@TODO where do we use this?
 | 
					    public $tax_rate3 = 0; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_type_id = '0'; //@TODO where do we use this?
 | 
					    public $payment_type_id = '0'; //@TODO where do we use this?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $valid_until = ''; //@implemented
 | 
					    public $valid_until = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $show_accept_invoice_terms = false; //@TODO ben to confirm
 | 
					    public $show_accept_invoice_terms = false; //@TODO ben to confirm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $show_accept_quote_terms = false;  //@TODO ben to confirm
 | 
					    public $show_accept_quote_terms = false;  //@TODO ben to confirm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $require_invoice_signature = false;  //@TODO ben to confirm
 | 
					    public $require_invoice_signature = false;  //@TODO ben to confirm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $require_quote_signature = false;  //@TODO ben to confirm
 | 
					    public $require_quote_signature = false;  //@TODO ben to confirm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //email settings
 | 
					    //email settings
 | 
				
			||||||
    public $email_sending_method = 'default'; //enum 'default','gmail','office365' //@implemented
 | 
					    public $email_sending_method = 'default'; //enum 'default','gmail','office365' //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $gmail_sending_user_id = '0'; //@implemented
 | 
					    public $gmail_sending_user_id = '0'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $reply_to_email = ''; //@implemented
 | 
					    public $reply_to_email = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $reply_to_name = ''; //@implemented
 | 
					    public $reply_to_name = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $bcc_email = ''; //@TODO
 | 
					    public $bcc_email = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $pdf_email_attachment = false; //@implemented
 | 
					    public $pdf_email_attachment = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $ubl_email_attachment = false; //@implemented
 | 
					    public $ubl_email_attachment = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_style = 'light'; //plain, light, dark, custom  //@implemented
 | 
					    public $email_style = 'light'; //plain, light, dark, custom  //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_style_custom = '';      //the template itself  //@implemented
 | 
					    public $email_style_custom = '';      //the template itself  //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_invoice = '';  //@implemented
 | 
					    public $email_subject_invoice = '';  //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_quote = '';  //@implemented
 | 
					    public $email_subject_quote = '';  //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_credit = ''; //@implemented
 | 
					    public $email_subject_credit = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_payment = ''; //@implemented
 | 
					    public $email_subject_payment = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_payment_partial = ''; //@implemented
 | 
					    public $email_subject_payment_partial = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_statement = ''; //@implemented
 | 
					    public $email_subject_statement = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_purchase_order = ''; //@implemented
 | 
					    public $email_subject_purchase_order = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_purchase_order = ''; //@implemented
 | 
					    public $email_template_purchase_order = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_invoice = ''; //@implemented
 | 
					    public $email_template_invoice = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_credit = ''; //@implemented
 | 
					    public $email_template_credit = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_quote = ''; //@implemented
 | 
					    public $email_template_quote = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_payment = ''; //@implemented
 | 
					    public $email_template_payment = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_payment_partial = ''; //@implemented
 | 
					    public $email_template_payment_partial = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_statement = ''; //@implemented
 | 
					    public $email_template_statement = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_reminder1 = ''; //@implemented
 | 
					    public $email_subject_reminder1 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_reminder2 = ''; //@implemented
 | 
					    public $email_subject_reminder2 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_reminder3 = ''; //@implemented
 | 
					    public $email_subject_reminder3 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_reminder_endless = ''; //@implemented
 | 
					    public $email_subject_reminder_endless = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_reminder1 = ''; //@implemented
 | 
					    public $email_template_reminder1 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_reminder2 = ''; //@implemented
 | 
					    public $email_template_reminder2 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_reminder3 = ''; //@implemented
 | 
					    public $email_template_reminder3 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_reminder_endless = ''; //@implemented
 | 
					    public $email_template_reminder_endless = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_signature = ''; //@implemented
 | 
					    public $email_signature = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_email_markup = true; //@TODO -
 | 
					    public $enable_email_markup = true; //@TODO -
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_custom1 = ''; //@TODO
 | 
					    public $email_subject_custom1 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_custom2 = ''; //@TODO
 | 
					    public $email_subject_custom2 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_subject_custom3 = ''; //@TODO
 | 
					    public $email_subject_custom3 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_custom1 = ''; //@TODO
 | 
					    public $email_template_custom1 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_custom2 = ''; //@TODO
 | 
					    public $email_template_custom2 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_template_custom3 = ''; //@TODO
 | 
					    public $email_template_custom3 = ''; //@TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_reminder1 = false; //@implmemented
 | 
					    public $enable_reminder1 = false; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_reminder2 = false; //@implmemented
 | 
					    public $enable_reminder2 = false; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_reminder3 = false; //@implmemented
 | 
					    public $enable_reminder3 = false; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $enable_reminder_endless = false; //@implmemented
 | 
					    public $enable_reminder_endless = false; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $num_days_reminder1 = 0;//@implmemented
 | 
					    public $num_days_reminder1 = 0; //@implmemented
 | 
				
			||||||
    public $num_days_reminder2 = 0;//@implmemented
 | 
					
 | 
				
			||||||
    public $num_days_reminder3 = 0;//@implmemented
 | 
					    public $num_days_reminder2 = 0; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $num_days_reminder3 = 0; //@implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
					    public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
					    public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
					    public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $reminder_send_time = 0; //number of seconds from UTC +0 to send reminders @TODO
 | 
					    public $reminder_send_time = 0; //number of seconds from UTC +0 to send reminders @TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_amount1 = 0; //@implemented
 | 
					    public $late_fee_amount1 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_amount2 = 0; //@implemented
 | 
					    public $late_fee_amount2 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_amount3 = 0; //@implemented
 | 
					    public $late_fee_amount3 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_percent1 = 0; //@implemented
 | 
					    public $late_fee_percent1 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_percent2 = 0; //@implemented
 | 
					    public $late_fee_percent2 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_percent3 = 0; //@implemented
 | 
					    public $late_fee_percent3 = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $endless_reminder_frequency_id = '0'; //@implemented
 | 
					    public $endless_reminder_frequency_id = '0'; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_endless_amount = 0; //@implemented
 | 
					    public $late_fee_endless_amount = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $late_fee_endless_percent = 0; //@implemented
 | 
					    public $late_fee_endless_percent = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_online_payment_notification = true; //@todo implement in notifications check this bool prior to sending payment notification to client
 | 
					    public $client_online_payment_notification = true; //@todo implement in notifications check this bool prior to sending payment notification to client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_manual_payment_notification = true; //@todo implement in notifications check this bool prior to sending manual payment notification to client
 | 
					    public $client_manual_payment_notification = true; //@todo implement in notifications check this bool prior to sending manual payment notification to client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Company Meta data that we can use to build sub companies*/
 | 
					    /* Company Meta data that we can use to build sub companies*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $name = ''; //@implemented
 | 
					    public $name = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company_logo = ''; //@implemented
 | 
					    public $company_logo = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $website = ''; //@implemented
 | 
					    public $website = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $address1 = ''; //@implemented
 | 
					    public $address1 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $address2 = ''; //@implemented
 | 
					    public $address2 = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $city = ''; //@implemented
 | 
					    public $city = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $state = ''; //@implemented
 | 
					    public $state = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $postal_code = ''; //@implemented
 | 
					    public $postal_code = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $phone = ''; //@implemented
 | 
					    public $phone = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email = ''; //@implemented
 | 
					    public $email = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $country_id; //@implemented
 | 
					    public $country_id; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vat_number = ''; //@implemented
 | 
					    public $vat_number = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $id_number = ''; //@implemented
 | 
					    public $id_number = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $page_size = 'A4';  //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
 | 
					    public $page_size = 'A4';  //Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $page_layout = 'portrait';
 | 
					    public $page_layout = 'portrait';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $font_size = 7; //@implemented
 | 
					    public $font_size = 7; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $primary_font = 'Roboto';
 | 
					    public $primary_font = 'Roboto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $secondary_font = 'Roboto';
 | 
					    public $secondary_font = 'Roboto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $primary_color = '#298AAB';
 | 
					    public $primary_color = '#298AAB';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $secondary_color = '#7081e0';
 | 
					    public $secondary_color = '#7081e0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $page_numbering = false;
 | 
					    public $page_numbering = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $page_numbering_alignment = 'C';  //C,R,L
 | 
					    public $page_numbering_alignment = 'C';  //C,R,L
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $hide_paid_to_date = false; //@TODO where?
 | 
					    public $hide_paid_to_date = false; //@TODO where?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $embed_documents = false; //@TODO where?
 | 
					    public $embed_documents = false; //@TODO where?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $all_pages_header = false; //@deprecated 31-05-2021
 | 
					    public $all_pages_header = false; //@deprecated 31-05-2021
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $all_pages_footer = false; //@deprecated 31-05-2021
 | 
					    public $all_pages_footer = false; //@deprecated 31-05-2021
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $pdf_variables = ''; //@implemented
 | 
					    public $pdf_variables = ''; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_custom_head = ''; //@TODO @BEN
 | 
					    public $portal_custom_head = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_custom_css = ''; //@TODO @BEN
 | 
					    public $portal_custom_css = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_custom_footer = ''; //@TODO @BEN
 | 
					    public $portal_custom_footer = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_custom_js = ''; //@TODO @BEN
 | 
					    public $portal_custom_js = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_can_register = false; //@deorecated 04/06/2021
 | 
					    public $client_can_register = false; //@deorecated 04/06/2021
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_terms = ''; //@TODO @BEN
 | 
					    public $client_portal_terms = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_privacy_policy = ''; //@TODO @BEN
 | 
					    public $client_portal_privacy_policy = ''; //@TODO @BEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_enable_uploads = false; //@implemented
 | 
					    public $client_portal_enable_uploads = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_allow_under_payment = false; //@implemented
 | 
					    public $client_portal_allow_under_payment = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_under_payment_minimum = 0; //@implemented
 | 
					    public $client_portal_under_payment_minimum = 0; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_portal_allow_over_payment = false; //@implemented
 | 
					    public $client_portal_allow_over_payment = false; //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $use_credits_payment = 'off'; //always, option, off //@implemented
 | 
					    public $use_credits_payment = 'off'; //always, option, off //@implemented
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $hide_empty_columns_on_pdf = false;
 | 
					    public $hide_empty_columns_on_pdf = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email_from_name = '';
 | 
					    public $email_from_name = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $auto_archive_invoice_cancelled = false;
 | 
					    public $auto_archive_invoice_cancelled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vendor_portal_enable_uploads=false;
 | 
					    public $vendor_portal_enable_uploads=false;
 | 
				
			||||||
 | 
				
			|||||||
@ -26,12 +26,11 @@ class DefaultSettings extends BaseSettings
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return stdClass
 | 
					     * @return stdClass
 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static function userSettings() : stdClass
 | 
					    public static function userSettings() : stdClass
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return (object) [
 | 
					        return (object) [
 | 
				
			||||||
        //    class_basename(User::class) => self::userSettingsObject(),
 | 
					            //    class_basename(User::class) => self::userSettingsObject(),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -41,7 +40,7 @@ class DefaultSettings extends BaseSettings
 | 
				
			|||||||
    private static function userSettingsObject() : stdClass
 | 
					    private static function userSettingsObject() : stdClass
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return (object) [
 | 
					        return (object) [
 | 
				
			||||||
        //    'per_page' => self::$per_page,
 | 
					            //    'per_page' => self::$per_page,
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -162,11 +162,9 @@ class EmailTemplateDefaults
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public static function emailPurchaseOrderTemplate()
 | 
					    public static function emailPurchaseOrderTemplate()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $purchase_order_message = '<p>$vendor<br><br>'.self::transformText('purchase_order_message').'</p><div class="center">$view_button</div>';
 | 
					        $purchase_order_message = '<p>$vendor<br><br>'.self::transformText('purchase_order_message').'</p><div class="center">$view_button</div>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $purchase_order_message;
 | 
					        return $purchase_order_message;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static function emailPaymentTemplate()
 | 
					    public static function emailPaymentTemplate()
 | 
				
			||||||
@ -249,6 +247,6 @@ class EmailTemplateDefaults
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        //preformat the string, removing trailing colons.
 | 
					        //preformat the string, removing trailing colons.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return str_replace(':', '$', rtrim( ctrans('texts.'.$string), ":"));
 | 
					        return str_replace(':', '$', rtrim(ctrans('texts.'.$string), ':'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -20,67 +20,123 @@ use stdClass;
 | 
				
			|||||||
class FreeCompanySettings extends BaseSettings
 | 
					class FreeCompanySettings extends BaseSettings
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use MakesHash;
 | 
					    use MakesHash;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*Group settings based on functionality*/
 | 
					    /*Group settings based on functionality*/
 | 
				
			||||||
    public $credit_design_id = 'VolejRejNm';
 | 
					    public $credit_design_id = 'VolejRejNm';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_number_pattern = '';
 | 
					    public $client_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $client_number_counter = 1;
 | 
					    public $client_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_number_pattern = '';
 | 
					    public $credit_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $credit_number_counter = 1;
 | 
					    public $credit_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $currency_id = '1';
 | 
					    public $currency_id = '1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value1 = '';
 | 
					    public $custom_value1 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value2 = '';
 | 
					    public $custom_value2 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value3 = '';
 | 
					    public $custom_value3 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $custom_value4 = '';
 | 
					    public $custom_value4 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $date_format_id = '';
 | 
					    public $date_format_id = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//    public $enabled_item_tax_rates          = 0;
 | 
					//    public $enabled_item_tax_rates          = 0;
 | 
				
			||||||
    public $expense_number_pattern = '';
 | 
					    public $expense_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $expense_number_counter = 1;
 | 
					    public $expense_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $inclusive_taxes = false;
 | 
					    public $inclusive_taxes = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_design_id = 'VolejRejNm';
 | 
					    public $invoice_design_id = 'VolejRejNm';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_number_pattern = '';
 | 
					    public $invoice_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_number_counter = 1;
 | 
					    public $invoice_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $invoice_taxes = 0;
 | 
					    public $invoice_taxes = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $language_id = '';
 | 
					    public $language_id = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $military_time = false;
 | 
					    public $military_time = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_number_pattern = '';
 | 
					    public $payment_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_number_counter = 1;
 | 
					    public $payment_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_terms = '';
 | 
					    public $payment_terms = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $payment_type_id = '0';
 | 
					    public $payment_type_id = '0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $portal_design_id = '1';
 | 
					    public $portal_design_id = '1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_design_id = 'VolejRejNm';
 | 
					    public $quote_design_id = 'VolejRejNm';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_number_pattern = '';
 | 
					    public $quote_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $quote_number_counter = 1;
 | 
					    public $quote_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $timezone_id = '';
 | 
					    public $timezone_id = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $show_currency_code = false;
 | 
					    public $show_currency_code = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company_gateway_ids = '';
 | 
					    public $company_gateway_ids = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $task_number_pattern = '';
 | 
					    public $task_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $task_number_counter = 1;
 | 
					    public $task_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name1 = '';
 | 
					    public $tax_name1 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate1 = 0;
 | 
					    public $tax_rate1 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name2 = '';
 | 
					    public $tax_name2 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate2 = 0;
 | 
					    public $tax_rate2 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_name3 = '';
 | 
					    public $tax_name3 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tax_rate3 = 0;
 | 
					    public $tax_rate3 = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $ticket_number_pattern = '';
 | 
					    public $ticket_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $ticket_number_counter = 1;
 | 
					    public $ticket_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $translations;
 | 
					    public $translations;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vendor_number_pattern = '';
 | 
					    public $vendor_number_pattern = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vendor_number_counter = 1;
 | 
					    public $vendor_number_counter = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Company Meta data that we can use to build sub companies*/
 | 
					    /* Company Meta data that we can use to build sub companies*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $address1 = '';
 | 
					    public $address1 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $address2 = '';
 | 
					    public $address2 = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $city = '';
 | 
					    public $city = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company_logo = '';
 | 
					    public $company_logo = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $country_id;
 | 
					    public $country_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $email = '';
 | 
					    public $email = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $id_number = '';
 | 
					    public $id_number = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $name = '';
 | 
					    public $name = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $phone = '';
 | 
					    public $phone = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $postal_code = '';
 | 
					    public $postal_code = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $state = '';
 | 
					    public $state = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $vat_number = '';
 | 
					    public $vat_number = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $website = '';
 | 
					    public $website = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static $casts = [
 | 
					    public static $casts = [
 | 
				
			||||||
 | 
				
			|||||||
@ -22,8 +22,7 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class BaseTransaction implements TransactionInterface
 | 
					class BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_MARK_PAID;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_MARK_PAID; 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public array $model = [
 | 
					    public array $model = [
 | 
				
			||||||
        'client_id',
 | 
					        'client_id',
 | 
				
			||||||
@ -56,7 +55,7 @@ class BaseTransaction implements TransactionInterface
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        // $invoice = $data['invoice'];
 | 
					        // $invoice = $data['invoice'];
 | 
				
			||||||
        // $payment = $data['payment'];
 | 
					        // $payment = $data['payment'];
 | 
				
			||||||
        // $client = $data['client']; 
 | 
					        // $client = $data['client'];
 | 
				
			||||||
        // $credit = $data['credit'];
 | 
					        // $credit = $data['credit'];
 | 
				
			||||||
        // $payment_request = $data['payment']['payment_request'];
 | 
					        // $payment_request = $data['payment']['payment_request'];
 | 
				
			||||||
        // $metadata = $data['metadata'];
 | 
					        // $metadata = $data['metadata'];
 | 
				
			||||||
@ -95,6 +94,5 @@ class BaseTransaction implements TransactionInterface
 | 
				
			|||||||
        //     'credit_status' => $credit?->status_id,
 | 
					        //     'credit_status' => $credit?->status_id,
 | 
				
			||||||
        //     'timestamp' => time(),
 | 
					        //     'timestamp' => time(),
 | 
				
			||||||
        // ];
 | 
					        // ];
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class ClientStatusTransaction extends BaseTransaction implements TransactionInterface
 | 
					class ClientStatusTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::CLIENT_STATUS;
 | 
				
			||||||
    public $event_id = TransactionEvent::CLIENT_STATUS; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class GatewayPaymentMadeTransaction extends BaseTransaction implements TransactionInterface
 | 
					class GatewayPaymentMadeTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::GATEWAY_PAYMENT_MADE;
 | 
				
			||||||
    public $event_id = TransactionEvent::GATEWAY_PAYMENT_MADE; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoiceCancelledTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoiceCancelledTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_CANCELLED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_CANCELLED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoiceDeletedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoiceDeletedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_DELETED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_DELETED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoiceFeeAppliedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoiceFeeAppliedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_FEE_APPLIED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_FEE_APPLIED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoicePaymentTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoicePaymentTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_PAYMENT_APPLIED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_PAYMENT_APPLIED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoiceReversalTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoiceReversalTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_REVERSED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_REVERSED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class InvoiceUpdatedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class InvoiceUpdatedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_UPDATED;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_UPDATED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class MarkPaidTransaction extends BaseTransaction implements TransactionInterface
 | 
					class MarkPaidTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::INVOICE_MARK_PAID;
 | 
				
			||||||
    public $event_id = TransactionEvent::INVOICE_MARK_PAID; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class PaymentAppliedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class PaymentAppliedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::PAYMENT_APPLIED;
 | 
				
			||||||
    public $event_id = TransactionEvent::PAYMENT_APPLIED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class PaymentDeletedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class PaymentDeletedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::PAYMENT_DELETED;
 | 
				
			||||||
    public $event_id = TransactionEvent::PAYMENT_DELETED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class PaymentFailedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class PaymentFailedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::PAYMENT_FAILED;
 | 
				
			||||||
    public $event_id = TransactionEvent::PAYMENT_FAILED; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class PaymentMadeTransaction extends BaseTransaction implements TransactionInterface
 | 
					class PaymentMadeTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::PAYMENT_MADE;
 | 
				
			||||||
    public $event_id = TransactionEvent::PAYMENT_MADE; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,5 @@ use App\Models\TransactionEvent;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class PaymentRefundedTransaction extends BaseTransaction implements TransactionInterface
 | 
					class PaymentRefundedTransaction extends BaseTransaction implements TransactionInterface
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    
 | 
					    public $event_id = TransactionEvent::PAYMENT_REFUND;
 | 
				
			||||||
    public $event_id = TransactionEvent::PAYMENT_REFUND; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ class ClientWasRestored
 | 
				
			|||||||
    public $client;
 | 
					    public $client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
				
			|||||||
@ -28,6 +28,7 @@ class CreditWasEmailed
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $template;
 | 
					    public $template;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@ use Illuminate\Queue\SerializesModels;
 | 
				
			|||||||
class CreditWasMarkedSent
 | 
					class CreditWasMarkedSent
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use SerializesModels;
 | 
					    use SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @var Credit
 | 
					     * @var Credit
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class CreditWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class DesignWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class DocumentWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class ExpenseWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@ class InvoiceWasRestored
 | 
				
			|||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -26,8 +26,11 @@ class PaymentWasRestored
 | 
				
			|||||||
     * @var Payment
 | 
					     * @var Payment
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public $payment;
 | 
					    public $payment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class ProductWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -34,6 +34,7 @@ class PurchaseOrderWasAccepted
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $contact;
 | 
					    public $contact;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class PurchaseOrderWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -30,6 +30,7 @@ class QuoteWasEmailed
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $template;
 | 
					    public $template;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ class QuoteWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class RecurringExpenseWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@ class RecurringInvoiceWasRestored
 | 
				
			|||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@ class RecurringQuoteWasRestored
 | 
				
			|||||||
    public $company;
 | 
					    public $company;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -2,8 +2,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Events\Subscription;
 | 
					namespace App\Events\Subscription;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App\Models\Subscription;
 | 
					 | 
				
			||||||
use App\Models\Company;
 | 
					use App\Models\Company;
 | 
				
			||||||
 | 
					use App\Models\Subscription;
 | 
				
			||||||
use Illuminate\Broadcasting\Channel;
 | 
					use Illuminate\Broadcasting\Channel;
 | 
				
			||||||
use Illuminate\Broadcasting\InteractsWithSockets;
 | 
					use Illuminate\Broadcasting\InteractsWithSockets;
 | 
				
			||||||
use Illuminate\Broadcasting\PresenceChannel;
 | 
					use Illuminate\Broadcasting\PresenceChannel;
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class SubscriptionWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -32,6 +32,7 @@ class TaskWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								app/Events/Vendor/VendorWasRestored.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								app/Events/Vendor/VendorWasRestored.php
									
									
									
									
										vendored
									
									
								
							@ -32,6 +32,7 @@ class VendorWasRestored
 | 
				
			|||||||
    public $event_vars;
 | 
					    public $event_vars;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $fromDeleted;
 | 
					    public $fromDeleted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new event instance.
 | 
					     * Create a new event instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -62,6 +62,7 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
     * @var array
 | 
					     * @var array
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected $dontFlash = [
 | 
					    protected $dontFlash = [
 | 
				
			||||||
 | 
					        'current_password',
 | 
				
			||||||
        'password',
 | 
					        'password',
 | 
				
			||||||
        'password_confirmation',
 | 
					        'password_confirmation',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
@ -77,37 +78,33 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (! Schema::hasTable('accounts')) {
 | 
					        if (! Schema::hasTable('accounts')) {
 | 
				
			||||||
            info('account table not found');
 | 
					            info('account table not found');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(Ninja::isHosted() && !($exception instanceof ValidationException)){
 | 
					        if (Ninja::isHosted() && ! ($exception instanceof ValidationException)) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            app('sentry')->configureScope(function (Scope $scope): void {
 | 
					            app('sentry')->configureScope(function (Scope $scope): void {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                $name = 'hosted@invoiceninja.com';
 | 
					                $name = 'hosted@invoiceninja.com';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(auth()->guard('contact') && auth()->guard('contact')->user()){
 | 
					                if (auth()->guard('contact') && auth()->guard('contact')->user()) {
 | 
				
			||||||
                    $name = "Contact = ".auth()->guard('contact')->user()->email;
 | 
					                    $name = 'Contact = '.auth()->guard('contact')->user()->email;
 | 
				
			||||||
                    $key = auth()->guard('contact')->user()->company->account->key;
 | 
					                    $key = auth()->guard('contact')->user()->company->account->key;
 | 
				
			||||||
                }
 | 
					                } elseif (auth()->guard('user') && auth()->guard('user')->user()) {
 | 
				
			||||||
                elseif (auth()->guard('user') && auth()->guard('user')->user()){
 | 
					                    $name = 'Admin = '.auth()->guard('user')->user()->email;
 | 
				
			||||||
                    $name = "Admin = ".auth()->guard('user')->user()->email;                    
 | 
					 | 
				
			||||||
                    $key = auth()->user()->account->key;
 | 
					                    $key = auth()->user()->account->key;
 | 
				
			||||||
                } 
 | 
					                } else {
 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                    $key = 'Anonymous';
 | 
					                    $key = 'Anonymous';
 | 
				
			||||||
                
 | 
					                }
 | 
				
			||||||
                 $scope->setUser([
 | 
					
 | 
				
			||||||
                        'id'    => $key,
 | 
					                $scope->setUser([
 | 
				
			||||||
                        'email' => 'hosted@invoiceninja.com',
 | 
					                    'id'    => $key,
 | 
				
			||||||
                        'name'  => $name,
 | 
					                    'email' => 'hosted@invoiceninja.com',
 | 
				
			||||||
                    ]);
 | 
					                    'name'  => $name,
 | 
				
			||||||
 | 
					                ]);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                app('sentry')->captureException($exception);
 | 
					            app('sentry')->captureException($exception);
 | 
				
			||||||
 | 
					        } elseif (app()->bound('sentry') && $this->shouldReport($exception)) {
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        elseif (app()->bound('sentry') && $this->shouldReport($exception)) {
 | 
					 | 
				
			||||||
            app('sentry')->configureScope(function (Scope $scope): void {
 | 
					            app('sentry')->configureScope(function (Scope $scope): void {
 | 
				
			||||||
                if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) {
 | 
					                if (auth()->guard('contact') && auth()->guard('contact')->user() && auth()->guard('contact')->user()->company->account->report_errors) {
 | 
				
			||||||
                    $scope->setUser([
 | 
					                    $scope->setUser([
 | 
				
			||||||
@ -130,28 +127,33 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        parent::report($exception);
 | 
					        parent::report($exception);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function validException($exception)
 | 
					    private function validException($exception)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (strpos($exception->getMessage(), 'file_put_contents') !== false) 
 | 
					        if (strpos($exception->getMessage(), 'file_put_contents') !== false) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (strpos($exception->getMessage(), 'Permission denied') !== false) 
 | 
					        if (strpos($exception->getMessage(), 'Permission denied') !== false) {
 | 
				
			||||||
            return false;
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        if (strpos($exception->getMessage(), 'flock') !== false) 
 | 
					 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (strpos($exception->getMessage(), 'expects parameter 1 to be resource') !== false) 
 | 
					        if (strpos($exception->getMessage(), 'flock') !== false) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (strpos($exception->getMessage(), 'fwrite()') !== false)
 | 
					        if (strpos($exception->getMessage(), 'expects parameter 1 to be resource') !== false) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        
 | 
					        }
 | 
				
			||||||
        if(strpos($exception->getMessage(), 'LockableFile') !== false)
 | 
					
 | 
				
			||||||
 | 
					        if (strpos($exception->getMessage(), 'fwrite()') !== false) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (strpos($exception->getMessage(), 'LockableFile') !== false) {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -168,11 +170,11 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($exception instanceof ModelNotFoundException && $request->expectsJson()) {
 | 
					        if ($exception instanceof ModelNotFoundException && $request->expectsJson()) {
 | 
				
			||||||
            return response()->json(['message'=>$exception->getMessage()], 400);
 | 
					            return response()->json(['message'=>$exception->getMessage()], 400);
 | 
				
			||||||
        }elseif($exception instanceof InternalPDFFailure && $request->expectsJson()){
 | 
					        } elseif ($exception instanceof InternalPDFFailure && $request->expectsJson()) {
 | 
				
			||||||
            return response()->json(['message' => $exception->getMessage()], 500);
 | 
					            return response()->json(['message' => $exception->getMessage()], 500);
 | 
				
			||||||
        }elseif($exception instanceof PhantomPDFFailure && $request->expectsJson()){
 | 
					        } elseif ($exception instanceof PhantomPDFFailure && $request->expectsJson()) {
 | 
				
			||||||
            return response()->json(['message' => $exception->getMessage()], 500);
 | 
					            return response()->json(['message' => $exception->getMessage()], 500);
 | 
				
			||||||
        }elseif($exception instanceof FilePermissionsFailure) {
 | 
					        } elseif ($exception instanceof FilePermissionsFailure) {
 | 
				
			||||||
            return response()->json(['message' => $exception->getMessage()], 500);
 | 
					            return response()->json(['message' => $exception->getMessage()], 500);
 | 
				
			||||||
        } elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
 | 
					        } elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
 | 
				
			||||||
            return response()->json(['message'=>'Too many requests'], 429);
 | 
					            return response()->json(['message'=>'Too many requests'], 429);
 | 
				
			||||||
@ -202,7 +204,7 @@ class Handler extends ExceptionHandler
 | 
				
			|||||||
            return response()->json(['message' => $exception->getMessage()], 400);
 | 
					            return response()->json(['message' => $exception->getMessage()], 400);
 | 
				
			||||||
        } elseif ($exception instanceof StripeConnectFailure) {
 | 
					        } elseif ($exception instanceof StripeConnectFailure) {
 | 
				
			||||||
            return response()->json(['message' => $exception->getMessage()], 400);
 | 
					            return response()->json(['message' => $exception->getMessage()], 400);
 | 
				
			||||||
        } 
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return parent::render($request, $exception);
 | 
					        return parent::render($request, $exception);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,7 @@ class PaymentFailed extends Exception
 | 
				
			|||||||
    public function render($request)
 | 
					    public function render($request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (auth()->guard('contact')->user() || ($request->has('cko-session-id') && $request->query('cko-session-id') )) {
 | 
					        if (auth()->guard('contact')->user() || ($request->has('cko-session-id') && $request->query('cko-session-id') )) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return render('gateways.unsuccessful', [
 | 
					            return render('gateways.unsuccessful', [
 | 
				
			||||||
                'message' => $this->getMessage(),
 | 
					                'message' => $this->getMessage(),
 | 
				
			||||||
                'code' => $this->getCode(),
 | 
					                'code' => $this->getCode(),
 | 
				
			||||||
 | 
				
			|||||||
@ -30,12 +30,12 @@ class PaymentRefundFailed extends Exception
 | 
				
			|||||||
        // $msg = 'Unable to refund the transaction';
 | 
					        // $msg = 'Unable to refund the transaction';
 | 
				
			||||||
        $msg = ctrans('texts.warning_local_refund');
 | 
					        $msg = ctrans('texts.warning_local_refund');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($this->getMessage() && strlen($this->getMessage()) >=1 )
 | 
					        if ($this->getMessage() && strlen($this->getMessage()) >= 1) {
 | 
				
			||||||
            $msg = $this->getMessage();
 | 
					            $msg = $this->getMessage();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return response()->json([
 | 
					        return response()->json([
 | 
				
			||||||
           'message' => $msg,
 | 
					            'message' => $msg,
 | 
				
			||||||
       ], 401);
 | 
					        ], 401);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -13,12 +13,9 @@ class SystemError extends Exception
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function render($request)
 | 
					    public function render($request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return view('errors.guest', [
 | 
					        return view('errors.guest', [
 | 
				
			||||||
            'message' => $this->getMessage(),
 | 
					            'message' => $this->getMessage(),
 | 
				
			||||||
            'code' => $this->getCode(),
 | 
					            'code' => $this->getCode(),
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -15,28 +15,22 @@ use Illuminate\Support\Carbon;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class BaseExport
 | 
					class BaseExport
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected function addDateRange($query)
 | 
					    protected function addDateRange($query)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $date_range = $this->input['date_range'];
 | 
					        $date_range = $this->input['date_range'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(array_key_exists('date_key', $this->input) && strlen($this->input['date_key']) > 1)
 | 
					        if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key']) > 1) {
 | 
				
			||||||
            $this->date_key = $this->input['date_key'];
 | 
					            $this->date_key = $this->input['date_key'];
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        try{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $custom_start_date = Carbon::parse($this->input['start_date']);
 | 
					 | 
				
			||||||
            $custom_end_date = Carbon::parse($this->input['end_date']);    
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        catch(\Exception $e){
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            $custom_start_date = Carbon::parse($this->input['start_date']);
 | 
				
			||||||
 | 
					            $custom_end_date = Carbon::parse($this->input['end_date']);
 | 
				
			||||||
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            $custom_start_date = now()->startOfYear();
 | 
					            $custom_start_date = now()->startOfYear();
 | 
				
			||||||
            $custom_end_date = now();
 | 
					            $custom_end_date = now();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        switch ($date_range) {
 | 
					        switch ($date_range) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            case 'all':
 | 
					            case 'all':
 | 
				
			||||||
@ -61,26 +55,23 @@ class BaseExport
 | 
				
			|||||||
                return $query->whereBetween($this->date_key, [now()->startOfYear(), now()])->orderBy($this->date_key, 'ASC');
 | 
					                return $query->whereBetween($this->date_key, [now()->startOfYear(), now()])->orderBy($this->date_key, 'ASC');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function buildHeader() :array
 | 
					    protected function buildHeader() :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $header = [];
 | 
					        $header = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach($this->input['report_keys'] as $value){
 | 
					        foreach ($this->input['report_keys'] as $value) {
 | 
				
			||||||
 | 
					            $key = array_search($value, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $key = array_search ($value, $this->entity_keys);
 | 
					            $key = str_replace('item.', '', $key);
 | 
				
			||||||
            
 | 
					            $key = str_replace('invoice.', '', $key);
 | 
				
			||||||
            $key = str_replace("item.", "", $key);
 | 
					            $key = str_replace('client.', '', $key);
 | 
				
			||||||
            $key = str_replace("invoice.", "", $key);
 | 
					            $key = str_replace('contact.', '', $key);
 | 
				
			||||||
            $key = str_replace("client.", "", $key);
 | 
					 | 
				
			||||||
            $key = str_replace("contact.", "", $key);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $header[] = ctrans("texts.{$key}");
 | 
					            $header[] = ctrans("texts.{$key}");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $header;
 | 
					        return $header;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -17,9 +17,9 @@ use App\Models\Company;
 | 
				
			|||||||
use App\Transformers\ClientContactTransformer;
 | 
					use App\Transformers\ClientContactTransformer;
 | 
				
			||||||
use App\Transformers\ClientTransformer;
 | 
					use App\Transformers\ClientTransformer;
 | 
				
			||||||
use App\Utils\Ninja;
 | 
					use App\Utils\Ninja;
 | 
				
			||||||
 | 
					use Illuminate\Support\Carbon;
 | 
				
			||||||
use Illuminate\Support\Facades\App;
 | 
					use Illuminate\Support\Facades\App;
 | 
				
			||||||
use League\Csv\Writer;
 | 
					use League\Csv\Writer;
 | 
				
			||||||
use Illuminate\Support\Carbon;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ClientExport extends BaseExport
 | 
					class ClientExport extends BaseExport
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -95,7 +95,6 @@ class ClientExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -105,8 +104,9 @@ class ClientExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -114,69 +114,65 @@ class ClientExport extends BaseExport
 | 
				
			|||||||
        $query = Client::query()->with('contacts')
 | 
					        $query = Client::query()->with('contacts')
 | 
				
			||||||
                                ->withTrashed()
 | 
					                                ->withTrashed()
 | 
				
			||||||
                                ->where('company_id', $this->company->id)
 | 
					                                ->where('company_id', $this->company->id)
 | 
				
			||||||
                                ->where('is_deleted',0);
 | 
					                                ->where('is_deleted', 0);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
              ->each(function ($client){
 | 
					              ->each(function ($client) {
 | 
				
			||||||
                        $this->csv->insertOne($this->buildRow($client)); 
 | 
					                  $this->csv->insertOne($this->buildRow($client));
 | 
				
			||||||
                    });
 | 
					              });
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Client $client) :array
 | 
					    private function buildRow(Client $client) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_contact = false;
 | 
					        $transformed_contact = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $transformed_client = $this->client_transformer->transform($client);
 | 
					        $transformed_client = $this->client_transformer->transform($client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($contact = $client->contacts()->first())
 | 
					        if ($contact = $client->contacts()->first()) {
 | 
				
			||||||
            $transformed_contact = $this->contact_transformer->transform($contact);
 | 
					            $transformed_contact = $this->contact_transformer->transform($contact);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					            $parts = explode('.', $key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $parts = explode(".",$key);
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($parts[0] == 'client' && array_key_exists($parts[1], $transformed_client)) {
 | 
					            if ($parts[0] == 'client' && array_key_exists($parts[1], $transformed_client)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_client[$parts[1]];
 | 
					                $entity[$keyval] = $transformed_client[$parts[1]];
 | 
				
			||||||
            }
 | 
					            } elseif ($parts[0] == 'contact' && array_key_exists($parts[1], $transformed_contact)) {
 | 
				
			||||||
            elseif($parts[0] == 'contact' && array_key_exists($parts[1], $transformed_contact)) {
 | 
					 | 
				
			||||||
                $entity[$keyval] = $transformed_contact[$parts[1]];
 | 
					                $entity[$keyval] = $transformed_contact[$parts[1]];
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else 
 | 
					 | 
				
			||||||
                $entity[$keyval] = "";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($client, $entity);
 | 
					        return $this->decorateAdvancedFields($client, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Client $client, array $entity) :array
 | 
					    private function decorateAdvancedFields(Client $client, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('client.country_id', $this->input['report_keys'])) {
 | 
				
			||||||
 | 
					            $entity['country'] = $client->country ? ctrans("texts.country_{$client->country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.country_id', $this->input['report_keys']))
 | 
					        if (in_array('client.shipping_country_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['country'] = $client->country ? ctrans("texts.country_{$client->country->name}") : ""; 
 | 
					            $entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.shipping_country_id', $this->input['report_keys']))
 | 
					        if (in_array('client.currency', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ""; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(in_array('client.currency', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['currency'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
 | 
					            $entity['currency'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.industry_id', $this->input['report_keys']))
 | 
					        if (in_array('client.industry_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ""; 
 | 
					            $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -91,7 +91,6 @@ class ContactExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -101,8 +100,9 @@ class ContactExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -112,19 +112,15 @@ class ContactExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()->each(function ($contact){
 | 
					        $query->cursor()->each(function ($contact) {
 | 
				
			||||||
 | 
					            $this->csv->insertOne($this->buildRow($contact));
 | 
				
			||||||
            $this->csv->insertOne($this->buildRow($contact)); 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					        return $this->csv->toString();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(ClientContact $contact) :array
 | 
					    private function buildRow(ClientContact $contact) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_contact = false;
 | 
					        $transformed_contact = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $transformed_client = $this->client_transformer->transform($contact->client);
 | 
					        $transformed_client = $this->client_transformer->transform($contact->client);
 | 
				
			||||||
@ -132,41 +128,40 @@ class ContactExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					            $parts = explode('.', $key);
 | 
				
			||||||
            $parts = explode(".",$key);
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($parts[0] == 'client' && array_key_exists($parts[1], $transformed_client)) {
 | 
					            if ($parts[0] == 'client' && array_key_exists($parts[1], $transformed_client)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_client[$parts[1]];
 | 
					                $entity[$keyval] = $transformed_client[$parts[1]];
 | 
				
			||||||
            }
 | 
					            } elseif ($parts[0] == 'contact' && array_key_exists($parts[1], $transformed_contact)) {
 | 
				
			||||||
            elseif($parts[0] == 'contact' && array_key_exists($parts[1], $transformed_contact)) {
 | 
					 | 
				
			||||||
                $entity[$keyval] = $transformed_contact[$parts[1]];
 | 
					                $entity[$keyval] = $transformed_contact[$parts[1]];
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else 
 | 
					 | 
				
			||||||
                $entity[$keyval] = "";
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($contact->client, $entity);
 | 
					        return $this->decorateAdvancedFields($contact->client, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Client $client, array $entity) :array
 | 
					    private function decorateAdvancedFields(Client $client, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('client.country_id', $this->input['report_keys'])) {
 | 
				
			||||||
 | 
					            $entity['country'] = $client->country ? ctrans("texts.country_{$client->country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.country_id', $this->input['report_keys']))
 | 
					        if (in_array('client.shipping_country_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['country'] = $client->country ? ctrans("texts.country_{$client->country->name}") : ""; 
 | 
					            $entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.shipping_country_id', $this->input['report_keys']))
 | 
					        if (in_array('client.currency', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['shipping_country'] = $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ""; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(in_array('client.currency', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['currency'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
 | 
					            $entity['currency'] = $client->currency() ? $client->currency()->code : $client->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client.industry_id', $this->input['report_keys']))
 | 
					        if (in_array('client.industry_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ""; 
 | 
					            $entity['industry_id'] = $client->industry ? ctrans("texts.industry_{$client->industry->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -65,7 +65,7 @@ class CreditExport extends BaseExport
 | 
				
			|||||||
        'tax_rate3' => 'tax_rate3',
 | 
					        'tax_rate3' => 'tax_rate3',
 | 
				
			||||||
        'terms' => 'terms',
 | 
					        'terms' => 'terms',
 | 
				
			||||||
        'total_taxes' => 'total_taxes',
 | 
					        'total_taxes' => 'total_taxes',
 | 
				
			||||||
        'currency' => 'currency'
 | 
					        'currency' => 'currency',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private array $decorate_keys = [
 | 
					    private array $decorate_keys = [
 | 
				
			||||||
@ -84,7 +84,6 @@ class CreditExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -94,71 +93,69 @@ class CreditExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
        
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = Credit::query()
 | 
					        $query = Credit::query()
 | 
				
			||||||
                        ->withTrashed()
 | 
					                        ->withTrashed()
 | 
				
			||||||
                        ->with('client')->where('company_id', $this->company->id)
 | 
					                        ->with('client')->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
            ->each(function ($credit){
 | 
					            ->each(function ($credit) {
 | 
				
			||||||
 | 
					                $this->csv->insertOne($this->buildRow($credit));
 | 
				
			||||||
                $this->csv->insertOne($this->buildRow($credit)); 
 | 
					            });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Credit $credit) :array
 | 
					    private function buildRow(Credit $credit) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_credit = $this->credit_transformer->transform($credit);
 | 
					        $transformed_credit = $this->credit_transformer->transform($credit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_credit))
 | 
					            if (array_key_exists($key, $transformed_credit)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_credit[$key];
 | 
					                $entity[$keyval] = $transformed_credit[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($credit, $entity);
 | 
					        return $this->decorateAdvancedFields($credit, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Credit $credit, array $entity) :array
 | 
					    private function decorateAdvancedFields(Credit $credit, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('country_id', $this->input['report_keys'])) {
 | 
				
			||||||
 | 
					            $entity['country'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('country_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['country'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : ""; 
 | 
					            $entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $invoice->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('invoice_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $invoice->company->currency()->code;;
 | 
					            $entity['invoice'] = $credit->invoice ? $credit->invoice->number : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('invoice_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['invoice'] = $credit->invoice ? $credit->invoice->number : "";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['client'] = $credit->client->present()->name();
 | 
					            $entity['client'] = $credit->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('status_id',$this->input['report_keys']))
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['status'] = $credit->stringStatus($credit->status_id);
 | 
					            $entity['status'] = $credit->stringStatus($credit->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -52,7 +52,6 @@ class DocumentExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -62,8 +61,9 @@ class DocumentExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -73,47 +73,41 @@ class DocumentExport extends BaseExport
 | 
				
			|||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
              ->each(function ($entity){
 | 
					              ->each(function ($entity) {
 | 
				
			||||||
 | 
					                  $this->csv->insertOne($this->buildRow($entity));
 | 
				
			||||||
            $this->csv->insertOne($this->buildRow($entity)); 
 | 
					              });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Document $document) :array
 | 
					    private function buildRow(Document $document) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_entity = $this->entity_transformer->transform($document);
 | 
					        $transformed_entity = $this->entity_transformer->transform($document);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_entity))
 | 
					            if (array_key_exists($key, $transformed_entity)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_entity[$key];
 | 
					                $entity[$keyval] = $transformed_entity[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';        
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($document, $entity);
 | 
					        return $this->decorateAdvancedFields($document, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Document $document, array $entity) :array
 | 
					    private function decorateAdvancedFields(Document $document, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('record_type', $this->input['report_keys'])) {
 | 
				
			||||||
        if(in_array('record_type', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['record_type'] = class_basename($document->documentable);
 | 
					            $entity['record_type'] = class_basename($document->documentable);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // if(in_array('record_name', $this->input['report_keys']))
 | 
					        // if(in_array('record_name', $this->input['report_keys']))
 | 
				
			||||||
        //     $entity['record_name'] = $document->hashed_id;
 | 
					        //     $entity['record_name'] = $document->hashed_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -82,7 +82,6 @@ class ExpenseExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -92,8 +91,9 @@ class ExpenseExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -102,69 +102,67 @@ class ExpenseExport extends BaseExport
 | 
				
			|||||||
                        ->with('client')
 | 
					                        ->with('client')
 | 
				
			||||||
                        ->withTrashed()
 | 
					                        ->withTrashed()
 | 
				
			||||||
                        ->where('company_id', $this->company->id)
 | 
					                        ->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
                ->each(function ($expense){
 | 
					                ->each(function ($expense) {
 | 
				
			||||||
 | 
					                    $this->csv->insertOne($this->buildRow($expense));
 | 
				
			||||||
                    $this->csv->insertOne($this->buildRow($expense)); 
 | 
					                });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Expense $expense) :array
 | 
					    private function buildRow(Expense $expense) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_expense = $this->expense_transformer->transform($expense);
 | 
					        $transformed_expense = $this->expense_transformer->transform($expense);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_expense))
 | 
					            if (array_key_exists($key, $transformed_expense)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_expense[$key];
 | 
					                $entity[$keyval] = $transformed_expense[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($expense, $entity);
 | 
					        return $this->decorateAdvancedFields($expense, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Expense $expense, array $entity) :array
 | 
					    private function decorateAdvancedFields(Expense $expense, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency'] = $expense->currency ? $expense->currency->code : "";
 | 
					            $entity['currency'] = $expense->currency ? $expense->currency->code : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $expense->client ? $expense->client->present()->name() : "";
 | 
					            $entity['client'] = $expense->client ? $expense->client->present()->name() : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('invoice_id', $this->input['report_keys']))
 | 
					        if (in_array('invoice_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['invoice'] = $expense->invoice ? $expense->invoice->number : "";
 | 
					            $entity['invoice'] = $expense->invoice ? $expense->invoice->number : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('category_id', $this->input['report_keys']))
 | 
					        if (in_array('category_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['category'] = $expense->category ? $expense->category->name : "";
 | 
					            $entity['category'] = $expense->category ? $expense->category->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('vendor_id', $this->input['report_keys']))
 | 
					        if (in_array('vendor_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['vendor'] = $expense->vendor ? $expense->vendor->name : "";
 | 
					            $entity['vendor'] = $expense->vendor ? $expense->vendor->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('payment_type_id', $this->input['report_keys']))
 | 
					        if (in_array('payment_type_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['payment_type'] = $expense->payment_type ? $expense->payment_type->name : "";
 | 
					            $entity['payment_type'] = $expense->payment_type ? $expense->payment_type->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if(in_array('project_id', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['project'] = $expense->project ? $expense->project->name : "";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (in_array('project_id', $this->input['report_keys'])) {
 | 
				
			||||||
 | 
					            $entity['project'] = $expense->project ? $expense->project->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ class InvoiceExport extends BaseExport
 | 
				
			|||||||
        'tax_rate3' => 'tax_rate3',
 | 
					        'tax_rate3' => 'tax_rate3',
 | 
				
			||||||
        'terms' => 'terms',
 | 
					        'terms' => 'terms',
 | 
				
			||||||
        'total_taxes' => 'total_taxes',
 | 
					        'total_taxes' => 'total_taxes',
 | 
				
			||||||
        'currency_id' => 'currency_id'
 | 
					        'currency_id' => 'currency_id',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private array $decorate_keys = [
 | 
					    private array $decorate_keys = [
 | 
				
			||||||
@ -84,7 +84,6 @@ class InvoiceExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -94,9 +93,10 @@ class InvoiceExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
        
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -104,57 +104,55 @@ class InvoiceExport extends BaseExport
 | 
				
			|||||||
                        ->withTrashed()
 | 
					                        ->withTrashed()
 | 
				
			||||||
                        ->with('client')
 | 
					                        ->with('client')
 | 
				
			||||||
                        ->where('company_id', $this->company->id)
 | 
					                        ->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
            ->each(function ($invoice){
 | 
					            ->each(function ($invoice) {
 | 
				
			||||||
 | 
					                $this->csv->insertOne($this->buildRow($invoice));
 | 
				
			||||||
                $this->csv->insertOne($this->buildRow($invoice)); 
 | 
					            });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Invoice $invoice) :array
 | 
					    private function buildRow(Invoice $invoice) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_invoice = $this->invoice_transformer->transform($invoice);
 | 
					        $transformed_invoice = $this->invoice_transformer->transform($invoice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_invoice))
 | 
					            if (array_key_exists($key, $transformed_invoice)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_invoice[$key];
 | 
					                $entity[$keyval] = $transformed_invoice[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($invoice, $entity);
 | 
					        return $this->decorateAdvancedFields($invoice, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Invoice $invoice, array $entity) :array
 | 
					    private function decorateAdvancedFields(Invoice $invoice, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(in_array('country_id', $this->input['report_keys']))
 | 
					        if (in_array('country_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ""; 
 | 
					            $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
 | 
					            $entity['currency_id'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $invoice->client->present()->name();
 | 
					            $entity['client'] = $invoice->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('status_id',$this->input['report_keys']))
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['status'] = $invoice->stringStatus($invoice->status_id);
 | 
					            $entity['status'] = $invoice->stringStatus($invoice->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -73,7 +73,6 @@ class PaymentExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -83,8 +82,9 @@ class PaymentExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -94,66 +94,66 @@ class PaymentExport extends BaseExport
 | 
				
			|||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
              ->each(function ($entity){
 | 
					              ->each(function ($entity) {
 | 
				
			||||||
 | 
					                  $this->csv->insertOne($this->buildRow($entity));
 | 
				
			||||||
            $this->csv->insertOne($this->buildRow($entity)); 
 | 
					              });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Payment $payment) :array
 | 
					    private function buildRow(Payment $payment) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_entity = $this->entity_transformer->transform($payment);
 | 
					        $transformed_entity = $this->entity_transformer->transform($payment);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_entity))
 | 
					            if (array_key_exists($key, $transformed_entity)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_entity[$key];
 | 
					                $entity[$keyval] = $transformed_entity[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
        
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($payment, $entity);
 | 
					        return $this->decorateAdvancedFields($payment, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Payment $payment, array $entity) :array
 | 
					    private function decorateAdvancedFields(Payment $payment, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
        if(in_array('status_id', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['status'] = $payment->stringStatus($payment->status_id);
 | 
					            $entity['status'] = $payment->stringStatus($payment->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('vendor_id', $this->input['report_keys']))
 | 
					        if (in_array('vendor_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['vendor'] = $payment->vendor()->exists() ? $payment->vendor->name : '';
 | 
					            $entity['vendor'] = $payment->vendor()->exists() ? $payment->vendor->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('project_id', $this->input['report_keys']))
 | 
					        if (in_array('project_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['project'] = $payment->project()->exists() ? $payment->project->name : '';
 | 
					            $entity['project'] = $payment->project()->exists() ? $payment->project->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency'] = $payment->currency()->exists() ? $payment->currency->code : '';
 | 
					            $entity['currency'] = $payment->currency()->exists() ? $payment->currency->code : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('exchange_currency_id', $this->input['report_keys']))
 | 
					        if (in_array('exchange_currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['exchange_currency'] = $payment->exchange_currency()->exists() ? $payment->exchange_currency->code : '';
 | 
					            $entity['exchange_currency'] = $payment->exchange_currency()->exists() ? $payment->exchange_currency->code : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $payment->client->present()->name();
 | 
					            $entity['client'] = $payment->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('type_id', $this->input['report_keys']))
 | 
					        if (in_array('type_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['type'] = $payment->translatedType();
 | 
					            $entity['type'] = $payment->translatedType();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('gateway_type_id', $this->input['report_keys']))
 | 
					        if (in_array('gateway_type_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['gateway'] = $payment->gateway_type ? $payment->gateway_type->name : "Unknown Type";
 | 
					            $entity['gateway'] = $payment->gateway_type ? $payment->gateway_type->name : 'Unknown Type';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -66,7 +66,6 @@ class ProductExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -76,8 +75,9 @@ class ProductExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -87,49 +87,42 @@ class ProductExport extends BaseExport
 | 
				
			|||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
              ->each(function ($entity){
 | 
					              ->each(function ($entity) {
 | 
				
			||||||
 | 
					                  $this->csv->insertOne($this->buildRow($entity));
 | 
				
			||||||
            $this->csv->insertOne($this->buildRow($entity)); 
 | 
					              });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Product $product) :array
 | 
					    private function buildRow(Product $product) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_entity = $this->entity_transformer->transform($product);
 | 
					        $transformed_entity = $this->entity_transformer->transform($product);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_entity))
 | 
					            if (array_key_exists($key, $transformed_entity)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_entity[$key];
 | 
					                $entity[$keyval] = $transformed_entity[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
        
 | 
					            }
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($product, $entity);
 | 
					        return $this->decorateAdvancedFields($product, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Product $product, array $entity) :array
 | 
					    private function decorateAdvancedFields(Product $product, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('vendor_id', $this->input['report_keys'])) {
 | 
				
			||||||
        if(in_array('vendor_id', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['vendor'] = $product->vendor()->exists() ? $product->vendor->name : '';
 | 
					            $entity['vendor'] = $product->vendor()->exists() ? $product->vendor->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(array_key_exists('project_id', $this->input['report_keys']))
 | 
					        if (array_key_exists('project_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['project'] = $product->project()->exists() ? $product->project->name : '';
 | 
					            $entity['project'] = $product->project()->exists() ? $product->project->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -70,7 +70,7 @@ class QuoteExport extends BaseExport
 | 
				
			|||||||
    private array $decorate_keys = [
 | 
					    private array $decorate_keys = [
 | 
				
			||||||
        'client',
 | 
					        'client',
 | 
				
			||||||
        'currency',
 | 
					        'currency',
 | 
				
			||||||
        'invoice'
 | 
					        'invoice',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(Company $company, array $input)
 | 
					    public function __construct(Company $company, array $input)
 | 
				
			||||||
@ -82,7 +82,6 @@ class QuoteExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -92,8 +91,9 @@ class QuoteExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -101,58 +101,55 @@ class QuoteExport extends BaseExport
 | 
				
			|||||||
        $query = Quote::query()
 | 
					        $query = Quote::query()
 | 
				
			||||||
                        ->with('client')
 | 
					                        ->with('client')
 | 
				
			||||||
                        ->where('company_id', $this->company->id)
 | 
					                        ->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
            ->each(function ($quote){
 | 
					            ->each(function ($quote) {
 | 
				
			||||||
 | 
					                $this->csv->insertOne($this->buildRow($quote));
 | 
				
			||||||
                $this->csv->insertOne($this->buildRow($quote)); 
 | 
					            });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Quote $quote) :array
 | 
					    private function buildRow(Quote $quote) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_quote = $this->quote_transformer->transform($quote);
 | 
					        $transformed_quote = $this->quote_transformer->transform($quote);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_quote))
 | 
					            if (array_key_exists($key, $transformed_quote)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_quote[$key];
 | 
					                $entity[$keyval] = $transformed_quote[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($quote, $entity);
 | 
					        return $this->decorateAdvancedFields($quote, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Quote $quote, array $entity) :array
 | 
					    private function decorateAdvancedFields(Quote $quote, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency'] = $quote->client->currency()->code;
 | 
					            $entity['currency'] = $quote->client->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $quote->client->present()->name();
 | 
					            $entity['client'] = $quote->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('status_id',$this->input['report_keys']))
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['status'] = $quote->stringStatus($quote->status_id);
 | 
					            $entity['status'] = $quote->stringStatus($quote->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('invoice_id', $this->input['report_keys']))
 | 
					        if (in_array('invoice_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['invoice'] = $quote->invoice ? $quote->invoice->number : "";
 | 
					            $entity['invoice'] = $quote->invoice ? $quote->invoice->number : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -85,7 +85,6 @@ class QuoteItemExport extends BaseExport
 | 
				
			|||||||
        'custom_value4' => 'item.custom_value4',
 | 
					        'custom_value4' => 'item.custom_value4',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private array $decorate_keys = [
 | 
					    private array $decorate_keys = [
 | 
				
			||||||
        'client',
 | 
					        'client',
 | 
				
			||||||
        'currency',
 | 
					        'currency',
 | 
				
			||||||
@ -100,7 +99,6 @@ class QuoteItemExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -110,28 +108,25 @@ class QuoteItemExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = Quote::query()
 | 
					        $query = Quote::query()
 | 
				
			||||||
                        ->with('client')->where('company_id', $this->company->id)
 | 
					                        ->with('client')->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
            ->each(function ($quote){
 | 
					            ->each(function ($quote) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                $this->iterateItems($quote);
 | 
					                $this->iterateItems($quote);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        });
 | 
					        return $this->csv->toString();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function iterateItems(Quote $quote)
 | 
					    private function iterateItems(Quote $quote)
 | 
				
			||||||
@ -140,76 +135,68 @@ class QuoteItemExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $transformed_items = [];
 | 
					        $transformed_items = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach($quote->line_items as $item)
 | 
					        foreach ($quote->line_items as $item) {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            $item_array = [];
 | 
					            $item_array = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            foreach(array_values($this->input['report_keys']) as $key){
 | 
					            foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
            
 | 
					                if (str_contains($key, 'item.')) {
 | 
				
			||||||
                if(str_contains($key, "item.")){
 | 
					                    $key = str_replace('item.', '', $key);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    $key = str_replace("item.", "", $key);
 | 
					 | 
				
			||||||
                    $item_array[$key] = $item->{$key};
 | 
					                    $item_array[$key] = $item->{$key};
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $entity = [];
 | 
					            $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            foreach(array_values($this->input['report_keys']) as $key)
 | 
					            foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                $keyval = array_search($key, $this->entity_keys);
 | 
					                $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(array_key_exists($key, $transformed_items))
 | 
					                if (array_key_exists($key, $transformed_items)) {
 | 
				
			||||||
                    $entity[$keyval] = $transformed_items[$key];
 | 
					                    $entity[$keyval] = $transformed_items[$key];
 | 
				
			||||||
                else 
 | 
					                } else {
 | 
				
			||||||
                    $entity[$keyval] = "";
 | 
					                    $entity[$keyval] = '';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $transformed_items = array_merge($transformed_quote, $item_array);
 | 
					            $transformed_items = array_merge($transformed_quote, $item_array);
 | 
				
			||||||
            $entity = $this->decorateAdvancedFields($quote, $transformed_items);
 | 
					            $entity = $this->decorateAdvancedFields($quote, $transformed_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->csv->insertOne($entity); 
 | 
					            $this->csv->insertOne($entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Quote $quote) :array
 | 
					    private function buildRow(Quote $quote) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_quote = $this->quote_transformer->transform($quote);
 | 
					        $transformed_quote = $this->quote_transformer->transform($quote);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_quote))
 | 
					            if (array_key_exists($key, $transformed_quote)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_quote[$key];
 | 
					                $entity[$keyval] = $transformed_quote[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = "";
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($quote, $entity);
 | 
					        return $this->decorateAdvancedFields($quote, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Quote $quote, array $entity) :array
 | 
					    private function decorateAdvancedFields(Quote $quote, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency'] = $quote->client->currency() ? $quote->client->currency()->code : $quote->company->currency()->code;
 | 
					            $entity['currency'] = $quote->client->currency() ? $quote->client->currency()->code : $quote->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $quote->client->present()->name();
 | 
					            $entity['client'] = $quote->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('status_id', $this->input['report_keys']))
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['status'] = $quote->stringStatus($quote->status_id);
 | 
					            $entity['status'] = $quote->stringStatus($quote->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -74,7 +74,7 @@ class RecurringInvoiceExport extends BaseExport
 | 
				
			|||||||
        'currency',
 | 
					        'currency',
 | 
				
			||||||
        'status',
 | 
					        'status',
 | 
				
			||||||
        'vendor',
 | 
					        'vendor',
 | 
				
			||||||
        'project'
 | 
					        'project',
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(Company $company, array $input)
 | 
					    public function __construct(Company $company, array $input)
 | 
				
			||||||
@ -86,7 +86,6 @@ class RecurringInvoiceExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -96,8 +95,9 @@ class RecurringInvoiceExport extends BaseExport
 | 
				
			|||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -105,64 +105,63 @@ class RecurringInvoiceExport extends BaseExport
 | 
				
			|||||||
        $query = RecurringInvoice::query()
 | 
					        $query = RecurringInvoice::query()
 | 
				
			||||||
                        ->withTrashed()
 | 
					                        ->withTrashed()
 | 
				
			||||||
                        ->with('client')->where('company_id', $this->company->id)
 | 
					                        ->with('client')->where('company_id', $this->company->id)
 | 
				
			||||||
                        ->where('is_deleted',0);
 | 
					                        ->where('is_deleted', 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
            ->each(function ($invoice){
 | 
					            ->each(function ($invoice) {
 | 
				
			||||||
 | 
					                $this->csv->insertOne($this->buildRow($invoice));
 | 
				
			||||||
                $this->csv->insertOne($this->buildRow($invoice)); 
 | 
					            });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(RecurringInvoice $invoice) :array
 | 
					    private function buildRow(RecurringInvoice $invoice) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $transformed_invoice = $this->invoice_transformer->transform($invoice);
 | 
					        $transformed_invoice = $this->invoice_transformer->transform($invoice);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach(array_values($this->input['report_keys']) as $key){
 | 
					        foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            $keyval = array_search($key, $this->entity_keys);
 | 
					            $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(array_key_exists($key, $transformed_invoice))
 | 
					            if (array_key_exists($key, $transformed_invoice)) {
 | 
				
			||||||
                $entity[$keyval] = $transformed_invoice[$key];
 | 
					                $entity[$keyval] = $transformed_invoice[$key];
 | 
				
			||||||
            else
 | 
					            } else {
 | 
				
			||||||
                $entity[$keyval] = '';
 | 
					                $entity[$keyval] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->decorateAdvancedFields($invoice, $entity);
 | 
					        return $this->decorateAdvancedFields($invoice, $entity);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity) :array
 | 
					    private function decorateAdvancedFields(RecurringInvoice $invoice, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if(in_array('country_id', $this->input['report_keys']))
 | 
					        if (in_array('country_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : ""; 
 | 
					            $entity['country'] = $invoice->client->country ? ctrans("texts.country_{$invoice->client->country->name}") : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('currency_id', $this->input['report_keys']))
 | 
					        if (in_array('currency_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['currency'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
 | 
					            $entity['currency'] = $invoice->client->currency() ? $invoice->client->currency()->code : $invoice->company->currency()->code;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $invoice->client->present()->name();
 | 
					            $entity['client'] = $invoice->client->present()->name();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('status_id',$this->input['report_keys']))
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['status'] = $invoice->stringStatus($invoice->status_id);
 | 
					            $entity['status'] = $invoice->stringStatus($invoice->status_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('project_id',$this->input['report_keys']))
 | 
					        if (in_array('project_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['project'] = $invoice->project ? $invoice->project->name : "";
 | 
					            $entity['project'] = $invoice->project ? $invoice->project->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('vendor_id',$this->input['report_keys']))
 | 
					        if (in_array('vendor_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['vendor'] = $invoice->vendor ? $invoice->vendor->name : "";
 | 
					            $entity['vendor'] = $invoice->vendor ? $invoice->vendor->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,6 @@ class TaskExport extends BaseExport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        MultiDB::setDb($this->company->db);
 | 
					        MultiDB::setDb($this->company->db);
 | 
				
			||||||
        App::forgetInstance('translator');
 | 
					        App::forgetInstance('translator');
 | 
				
			||||||
        App::setLocale($this->company->locale());
 | 
					        App::setLocale($this->company->locale());
 | 
				
			||||||
@ -79,15 +78,15 @@ class TaskExport extends BaseExport
 | 
				
			|||||||
        $t->replace(Ninja::transformTranslations($this->company->settings));
 | 
					        $t->replace(Ninja::transformTranslations($this->company->settings));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->date_format = DateFormat::find($this->company->settings->date_format_id)->format;
 | 
					        $this->date_format = DateFormat::find($this->company->settings->date_format_id)->format;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
        //load the CSV document from a string
 | 
					        //load the CSV document from a string
 | 
				
			||||||
        $this->csv = Writer::createFromString();
 | 
					        $this->csv = Writer::createFromString();
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        ksort($this->entity_keys);
 | 
					        ksort($this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(count($this->input['report_keys']) == 0)
 | 
					        if (count($this->input['report_keys']) == 0) {
 | 
				
			||||||
            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
					            $this->input['report_keys'] = array_values($this->entity_keys);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //insert the header
 | 
					        //insert the header
 | 
				
			||||||
        $this->csv->insertOne($this->buildHeader());
 | 
					        $this->csv->insertOne($this->buildHeader());
 | 
				
			||||||
@ -97,59 +96,50 @@ class TaskExport extends BaseExport
 | 
				
			|||||||
        $query = $this->addDateRange($query);
 | 
					        $query = $this->addDateRange($query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $query->cursor()
 | 
					        $query->cursor()
 | 
				
			||||||
              ->each(function ($entity){
 | 
					              ->each(function ($entity) {
 | 
				
			||||||
 | 
					                  $this->buildRow($entity);
 | 
				
			||||||
                $this->buildRow($entity); 
 | 
					              });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $this->csv->toString(); 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->csv->toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function buildRow(Task $task) 
 | 
					    private function buildRow(Task $task)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $entity = [];
 | 
					        $entity = [];
 | 
				
			||||||
        $transformed_entity = $this->entity_transformer->transform($task);
 | 
					        $transformed_entity = $this->entity_transformer->transform($task);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(is_null($task->time_log) || (is_array(json_decode($task->time_log,1)) && count(json_decode($task->time_log,1)) == 0)){
 | 
					        if (is_null($task->time_log) || (is_array(json_decode($task->time_log, 1)) && count(json_decode($task->time_log, 1)) == 0)) {
 | 
				
			||||||
 | 
					            foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
            foreach(array_values($this->input['report_keys']) as $key){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $keyval = array_search($key, $this->entity_keys);
 | 
					                $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(array_key_exists($key, $transformed_entity))
 | 
					                if (array_key_exists($key, $transformed_entity)) {
 | 
				
			||||||
                    $entity[$keyval] = $transformed_entity[$key];
 | 
					                    $entity[$keyval] = $transformed_entity[$key];
 | 
				
			||||||
                else
 | 
					                } else {
 | 
				
			||||||
                    $entity[$keyval] = '';            
 | 
					                    $entity[$keyval] = '';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $entity['start_date'] = "";
 | 
					            $entity['start_date'] = '';
 | 
				
			||||||
            $entity['end_date'] = "";
 | 
					            $entity['end_date'] = '';
 | 
				
			||||||
            $entity['duration'] = "";
 | 
					            $entity['duration'] = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $entity = $this->decorateAdvancedFields($task, $entity);
 | 
					            $entity = $this->decorateAdvancedFields($task, $entity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ksort($entity);
 | 
					            ksort($entity);
 | 
				
			||||||
            $this->csv->insertOne($entity);
 | 
					            $this->csv->insertOne($entity);
 | 
				
			||||||
 | 
					        } elseif (is_array(json_decode($task->time_log, 1)) && count(json_decode($task->time_log, 1)) > 0) {
 | 
				
			||||||
        }
 | 
					            foreach (array_values($this->input['report_keys']) as $key) {
 | 
				
			||||||
        elseif(is_array(json_decode($task->time_log,1)) && count(json_decode($task->time_log,1)) > 0) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            foreach(array_values($this->input['report_keys']) as $key){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $keyval = array_search($key, $this->entity_keys);
 | 
					                $keyval = array_search($key, $this->entity_keys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(array_key_exists($key, $transformed_entity))
 | 
					                if (array_key_exists($key, $transformed_entity)) {
 | 
				
			||||||
                    $entity[$keyval] = $transformed_entity[$key];
 | 
					                    $entity[$keyval] = $transformed_entity[$key];
 | 
				
			||||||
                else
 | 
					                } else {
 | 
				
			||||||
                    $entity[$keyval] = '';            
 | 
					                    $entity[$keyval] = '';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->iterateLogs($task, $entity);
 | 
					            $this->iterateLogs($task, $entity);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function iterateLogs(Task $task, array $entity)
 | 
					    private function iterateLogs(Task $task, array $entity)
 | 
				
			||||||
@ -157,48 +147,51 @@ class TaskExport extends BaseExport
 | 
				
			|||||||
        $timezone = Timezone::find($task->company->settings->timezone_id);
 | 
					        $timezone = Timezone::find($task->company->settings->timezone_id);
 | 
				
			||||||
        $timezone_name = 'US/Eastern';
 | 
					        $timezone_name = 'US/Eastern';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($timezone)
 | 
					        if ($timezone) {
 | 
				
			||||||
            $timezone_name = $timezone->name;
 | 
					            $timezone_name = $timezone->name;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $logs = json_decode($task->time_log,1);
 | 
					        $logs = json_decode($task->time_log, 1);
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $date_format_default = "Y-m-d";
 | 
					        $date_format_default = 'Y-m-d';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $date_format = DateFormat::find($task->company->settings->date_format_id);
 | 
					        $date_format = DateFormat::find($task->company->settings->date_format_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($date_format)
 | 
					        if ($date_format) {
 | 
				
			||||||
            $date_format_default = $date_format->format;
 | 
					            $date_format_default = $date_format->format;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach($logs as $key => $item)
 | 
					        foreach ($logs as $key => $item) {
 | 
				
			||||||
        {
 | 
					            if (in_array('start_date', $this->input['report_keys'])) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if(in_array("start_date", $this->input['report_keys'])){
 | 
					 | 
				
			||||||
                $entity['start_date'] = Carbon::createFromTimeStamp($item[0])->setTimezone($timezone_name)->format($date_format_default);
 | 
					                $entity['start_date'] = Carbon::createFromTimeStamp($item[0])->setTimezone($timezone_name)->format($date_format_default);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(in_array("end_date", $this->input['report_keys']) && $item[1] > 0){
 | 
					            if (in_array('end_date', $this->input['report_keys']) && $item[1] > 0) {
 | 
				
			||||||
                $entity['end_date'] = Carbon::createFromTimeStamp($item[1])->setTimezone($timezone_name)->format($date_format_default);
 | 
					                $entity['end_date'] = Carbon::createFromTimeStamp($item[1])->setTimezone($timezone_name)->format($date_format_default);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(in_array("end_date", $this->input['report_keys']) && $item[1] == 0){
 | 
					            if (in_array('end_date', $this->input['report_keys']) && $item[1] == 0) {
 | 
				
			||||||
                $entity['end_date'] = ctrans('texts.is_running');
 | 
					                $entity['end_date'] = ctrans('texts.is_running');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(in_array("duration", $this->input['report_keys'])){
 | 
					            if (in_array('duration', $this->input['report_keys'])) {
 | 
				
			||||||
                $entity['duration'] = $task->calcDuration();
 | 
					                $entity['duration'] = $task->calcDuration();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(!array_key_exists('duration', $entity))
 | 
					            if (! array_key_exists('duration', $entity)) {
 | 
				
			||||||
                $entity['duration'] = "";
 | 
					                $entity['duration'] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(!array_key_exists('start_date', $entity))
 | 
					            if (! array_key_exists('start_date', $entity)) {
 | 
				
			||||||
                $entity['start_date'] = "";
 | 
					                $entity['start_date'] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(!array_key_exists('end_date', $entity))
 | 
					            if (! array_key_exists('end_date', $entity)) {
 | 
				
			||||||
                $entity['end_date'] = "";
 | 
					                $entity['end_date'] = '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $entity = $this->decorateAdvancedFields($task, $entity);
 | 
					            $entity = $this->decorateAdvancedFields($task, $entity);
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            ksort($entity);
 | 
					            ksort($entity);
 | 
				
			||||||
            $this->csv->insertOne($entity);
 | 
					            $this->csv->insertOne($entity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -206,25 +199,26 @@ class TaskExport extends BaseExport
 | 
				
			|||||||
            unset($entity['end_date']);
 | 
					            unset($entity['end_date']);
 | 
				
			||||||
            unset($entity['duration']);
 | 
					            unset($entity['duration']);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function decorateAdvancedFields(Task $task, array $entity) :array
 | 
					    private function decorateAdvancedFields(Task $task, array $entity) :array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        if (in_array('status_id', $this->input['report_keys'])) {
 | 
				
			||||||
        if(in_array('status_id', $this->input['report_keys']))
 | 
					 | 
				
			||||||
            $entity['status'] = $task->status()->exists() ? $task->status->name : '';
 | 
					            $entity['status'] = $task->status()->exists() ? $task->status->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('project_id', $this->input['report_keys']))
 | 
					        if (in_array('project_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['project'] = $task->project()->exists() ? $task->project->name : '';
 | 
					            $entity['project'] = $task->project()->exists() ? $task->project->name : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('client_id', $this->input['report_keys']))
 | 
					        if (in_array('client_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['client'] = $task->client ? $task->client->present()->name() : "";
 | 
					            $entity['client'] = $task->client ? $task->client->present()->name() : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array('invoice_id', $this->input['report_keys']))
 | 
					        if (in_array('invoice_id', $this->input['report_keys'])) {
 | 
				
			||||||
            $entity['invoice'] = $task->invoice ? $task->invoice->number : "";
 | 
					            $entity['invoice'] = $task->invoice ? $task->invoice->number : '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $entity;
 | 
					        return $entity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,7 @@ class ClientGatewayTokenFactory
 | 
				
			|||||||
        $client_gateway_token->is_deleted = false;
 | 
					        $client_gateway_token->is_deleted = false;
 | 
				
			||||||
        $client_gateway_token->token = '';
 | 
					        $client_gateway_token->token = '';
 | 
				
			||||||
        $client_gateway_token->routing_number = '';
 | 
					        $client_gateway_token->routing_number = '';
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        return $client_gateway_token;
 | 
					        return $client_gateway_token;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -28,11 +28,12 @@ class CloneQuoteToInvoiceFactory
 | 
				
			|||||||
        unset($quote_array['invoice_id']);
 | 
					        unset($quote_array['invoice_id']);
 | 
				
			||||||
        unset($quote_array['id']);
 | 
					        unset($quote_array['id']);
 | 
				
			||||||
        unset($quote_array['invitations']);
 | 
					        unset($quote_array['invitations']);
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        //preserve terms if they exist on Quotes
 | 
					        //preserve terms if they exist on Quotes
 | 
				
			||||||
        //if(array_key_exists('terms', $quote_array) && strlen($quote_array['terms']) < 2)
 | 
					        //if(array_key_exists('terms', $quote_array) && strlen($quote_array['terms']) < 2)
 | 
				
			||||||
        if(!$quote->company->use_quote_terms_on_conversion)
 | 
					        if (! $quote->company->use_quote_terms_on_conversion) {
 | 
				
			||||||
            unset($quote_array['terms']);
 | 
					            unset($quote_array['terms']);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // unset($quote_array['public_notes']);
 | 
					        // unset($quote_array['public_notes']);
 | 
				
			||||||
        unset($quote_array['footer']);
 | 
					        unset($quote_array['footer']);
 | 
				
			||||||
 | 
				
			|||||||
@ -37,12 +37,13 @@ class CompanyFactory
 | 
				
			|||||||
        //$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
 | 
					        //$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
 | 
				
			||||||
        $company->custom_fields = (object) [];
 | 
					        $company->custom_fields = (object) [];
 | 
				
			||||||
        $company->client_registration_fields = ClientRegistrationFields::generate();
 | 
					        $company->client_registration_fields = ClientRegistrationFields::generate();
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        if(Ninja::isHosted())
 | 
					        if (Ninja::isHosted()) {
 | 
				
			||||||
            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
					            $company->subdomain = MultiDB::randomSubdomainGenerator();
 | 
				
			||||||
        else 
 | 
					        } else {
 | 
				
			||||||
            $company->subdomain = '';
 | 
					            $company->subdomain = '';
 | 
				
			||||||
        
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
 | 
					        $company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
 | 
				
			||||||
        $company->default_password_timeout = 1800000;
 | 
					        $company->default_password_timeout = 1800000;
 | 
				
			||||||
        $company->markdown_email_enabled = false;
 | 
					        $company->markdown_email_enabled = false;
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ class CompanyGatewayFactory
 | 
				
			|||||||
        $company_gateway->require_billing_address = false;
 | 
					        $company_gateway->require_billing_address = false;
 | 
				
			||||||
        $company_gateway->require_shipping_address = false;
 | 
					        $company_gateway->require_shipping_address = false;
 | 
				
			||||||
        $company_gateway->config = encrypt(json_encode(new \stdClass));
 | 
					        $company_gateway->config = encrypt(json_encode(new \stdClass));
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        return $company_gateway;
 | 
					        return $company_gateway;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ class ExpenseCategoryFactory
 | 
				
			|||||||
        $expense->name = '';
 | 
					        $expense->name = '';
 | 
				
			||||||
        $expense->is_deleted = false;
 | 
					        $expense->is_deleted = false;
 | 
				
			||||||
        $expense->color = '';
 | 
					        $expense->color = '';
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        return $expense;
 | 
					        return $expense;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ class ExpenseFactory
 | 
				
			|||||||
        $expense->tax_amount1 = 0;
 | 
					        $expense->tax_amount1 = 0;
 | 
				
			||||||
        $expense->tax_amount2 = 0;
 | 
					        $expense->tax_amount2 = 0;
 | 
				
			||||||
        $expense->tax_amount3 = 0;
 | 
					        $expense->tax_amount3 = 0;
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        return $expense;
 | 
					        return $expense;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,8 @@ class GroupSettingFactory
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public static function create(int $company_id, int $user_id) :GroupSetting
 | 
					    public static function create(int $company_id, int $user_id) :GroupSetting
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	$settings = new \stdClass;
 | 
					        $settings = new \stdClass;
 | 
				
			||||||
    	$settings->entity = Client::class;
 | 
					        $settings->entity = Client::class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $gs = new GroupSetting;
 | 
					        $gs = new GroupSetting;
 | 
				
			||||||
        $gs->name = '';
 | 
					        $gs->name = '';
 | 
				
			||||||
 | 
				
			|||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user