mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-02 22:57:33 -05:00 
			
		
		
		
	Merge pull request #6132 from turbo124/v5-develop
Minor fixes for subdomain filling
This commit is contained in:
		
						commit
						db9d16b90b
					
				@ -60,36 +60,36 @@ class SubdomainFill extends Command
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $db1 = Company::on('db-ninja-01')->get();
 | 
					        // $db1 = Company::on('db-ninja-01')->get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $db1->each(function ($company){
 | 
					        // $db1->each(function ($company){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $db2 = Company::on('db-ninja-02a')->find($company->id);
 | 
					        //     $db2 = Company::on('db-ninja-02a')->find($company->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($db2)
 | 
					        //     if($db2)
 | 
				
			||||||
            {
 | 
					        //     {
 | 
				
			||||||
                $db2->subdomain = $company->subdomain;
 | 
					        //         $db2->subdomain = $company->subdomain;
 | 
				
			||||||
                $db2->save();
 | 
					        //         $db2->save();
 | 
				
			||||||
            }
 | 
					        //     }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        });
 | 
					        // });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $db1 = null;
 | 
					        // $db1 = null;
 | 
				
			||||||
        $db2 = null;
 | 
					        // $db2 = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $db2 = Company::on('db-ninja-02')->get();
 | 
					        // $db2 = Company::on('db-ninja-02')->get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $db2->each(function ($company){
 | 
					        // $db2->each(function ($company){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $db1 = Company::on('db-ninja-01a')->find($company->id);
 | 
					        //     $db1 = Company::on('db-ninja-01a')->find($company->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($db1)
 | 
					        //     if($db1)
 | 
				
			||||||
            {
 | 
					        //     {
 | 
				
			||||||
                $db1->subdomain = $company->subdomain;
 | 
					        //         $db1->subdomain = $company->subdomain;
 | 
				
			||||||
                $db1->save();
 | 
					        //         $db1->save();
 | 
				
			||||||
            }
 | 
					        //     }
 | 
				
			||||||
        });
 | 
					        // });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -76,7 +76,7 @@ class RecurringInvoicesCron
 | 
				
			|||||||
                nlog(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);
 | 
					                nlog(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $recurring_invoices->each(function ($recurring_invoice, $key) {
 | 
					                $recurring_invoices->each(function ($recurring_invoice, $key) {
 | 
				
			||||||
                    nlog("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date);
 | 
					                    nlog("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date ." Recurring #id = ". $recurring_invoice->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (!$recurring_invoice->company->is_disabled) {
 | 
					                    if (!$recurring_invoice->company->is_disabled) {
 | 
				
			||||||
                        SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
 | 
					                        SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
 | 
				
			||||||
 | 
				
			|||||||
@ -337,6 +337,10 @@ class Import implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if(!MultiDB::checkDomainAvailable($data['subdomain']))
 | 
					            if(!MultiDB::checkDomainAvailable($data['subdomain']))
 | 
				
			||||||
                $data['subdomain'] = MultiDB::randomSubdomainGenerator();
 | 
					                $data['subdomain'] = MultiDB::randomSubdomainGenerator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(strlen($data['subdomain']) == 0)
 | 
				
			||||||
 | 
					                $data['subdomain'] = MultiDB::randomSubdomainGenerator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules = (new UpdateCompanyRequest())->rules();
 | 
					        $rules = (new UpdateCompanyRequest())->rules();
 | 
				
			||||||
 | 
				
			|||||||
@ -56,6 +56,7 @@ class ReminderJob implements ShouldQueue
 | 
				
			|||||||
        nlog("Sending invoice reminders " . now()->format('Y-m-d h:i:s'));
 | 
					        nlog("Sending invoice reminders " . now()->format('Y-m-d h:i:s'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Invoice::where('next_send_date', '<=', now()->toDateTimeString())
 | 
					        Invoice::where('next_send_date', '<=', now()->toDateTimeString())
 | 
				
			||||||
 | 
					                 ->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)
 | 
				
			||||||
 | 
				
			|||||||
@ -11,12 +11,14 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Repositories;
 | 
					namespace App\Repositories;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Models\Client;
 | 
				
			||||||
use App\Models\GroupSetting;
 | 
					use App\Models\GroupSetting;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GroupSettingRepository extends BaseRepository
 | 
					class GroupSettingRepository extends BaseRepository
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public function save($data, GroupSetting $group_setting) :?GroupSetting
 | 
					    public function save($data, GroupSetting $group_setting) :?GroupSetting
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $group_setting->fill($data);
 | 
					        $group_setting->fill($data);
 | 
				
			||||||
        $group_setting->save();
 | 
					        $group_setting->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,6 +29,15 @@ class GroupSettingRepository extends BaseRepository
 | 
				
			|||||||
            $group_setting->save();
 | 
					            $group_setting->save();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        nlog($data['settings']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(count((array)$data['settings']) == 0){
 | 
				
			||||||
 | 
					            $settings = new \stdClass;
 | 
				
			||||||
 | 
					            $settings->entity = Client::class;
 | 
				
			||||||
 | 
					            $group_setting->settings = $settings;
 | 
				
			||||||
 | 
					            $group_setting->save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $group_setting;
 | 
					        return $group_setting;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user