mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for self-update (#3514)
* minor fix for payment notifications * styleci * Limit Self updating to self hosters only : * Fixes for designs * Minor fixes for self-update
This commit is contained in:
parent
d631a4954c
commit
43e57d0117
@ -48,34 +48,25 @@ class ArtisanUpgrade extends Command
|
||||
// call `composer install` command programmatically
|
||||
$input = new ArrayInput(array('command' => 'install'));
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false); // prevent `$application->run` method from exitting the script
|
||||
//$application->setAutoExit(false); // prevent `$application->run` method from exitting the script
|
||||
$application->run($input);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
Artisan::call('migrate');
|
||||
|
||||
}catch(Exception $e) {
|
||||
|
||||
} catch (Exception $e) {
|
||||
\Log::error("I wasn't able to migrate the data.");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Artisan::call('optimize');
|
||||
|
||||
}catch(Exception $e) {
|
||||
|
||||
} catch (Exception $e) {
|
||||
\Log::error("I wasn't able to optimize.");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Artisan::call('queue:restart');
|
||||
|
||||
}catch(Exception $e) {
|
||||
|
||||
} catch (Exception $e) {
|
||||
\Log::error("I wasn't able to restart the queue");
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class CreateTestData extends Command
|
||||
'settings' => null,
|
||||
]);
|
||||
|
||||
factory(\App\Models\Product::class,50)->create([
|
||||
factory(\App\Models\Product::class, 50)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
@ -136,8 +136,7 @@ class CreateTestData extends Command
|
||||
$this->createClient($company, $user);
|
||||
}
|
||||
|
||||
foreach($company->clients as $client) {
|
||||
|
||||
foreach ($company->clients as $client) {
|
||||
$this->info('creating invoice for client #'.$client->id);
|
||||
$this->createInvoice($client);
|
||||
|
||||
@ -158,10 +157,7 @@ class CreateTestData extends Command
|
||||
|
||||
$this->info('creating project for client #'.$client->id);
|
||||
$this->createProject($client);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function createMediumAccount()
|
||||
@ -208,7 +204,7 @@ class CreateTestData extends Command
|
||||
]);
|
||||
|
||||
|
||||
factory(\App\Models\Product::class,50)->create([
|
||||
factory(\App\Models\Product::class, 50)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
@ -224,45 +220,51 @@ class CreateTestData extends Command
|
||||
$this->createClient($company, $user);
|
||||
}
|
||||
|
||||
foreach($company->clients as $client) {
|
||||
|
||||
foreach ($company->clients as $client) {
|
||||
$this->info('creating invoice for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createInvoice($client);
|
||||
}
|
||||
|
||||
$this->info('creating credit for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createCredit($client);
|
||||
}
|
||||
|
||||
|
||||
$this->info('creating quote for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createQuote($client);
|
||||
}
|
||||
|
||||
$this->info('creating expense for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createExpense($client);
|
||||
}
|
||||
|
||||
$this->info('creating vendor for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createVendor($client);
|
||||
}
|
||||
|
||||
$this->info('creating task for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createTask($client);
|
||||
}
|
||||
|
||||
$this->info('creating project for client #'.$client->id);
|
||||
|
||||
for($i=0; $i<$this->count; $i++)
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
$this->createProject($client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createLargeAccount()
|
||||
{
|
||||
@ -308,7 +310,7 @@ class CreateTestData extends Command
|
||||
]);
|
||||
|
||||
|
||||
factory(\App\Models\Product::class,50)->create([
|
||||
factory(\App\Models\Product::class, 50)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
@ -325,8 +327,7 @@ class CreateTestData extends Command
|
||||
$this->createClient($company, $user);
|
||||
}
|
||||
|
||||
foreach($company->clients as $client) {
|
||||
|
||||
foreach ($company->clients as $client) {
|
||||
$this->info('creating invoice for client #'.$client->id);
|
||||
$this->createInvoice($client);
|
||||
|
||||
@ -348,7 +349,6 @@ class CreateTestData extends Command
|
||||
$this->info('creating project for client #'.$client->id);
|
||||
$this->createProject($client);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function createClient($company, $user)
|
||||
@ -374,25 +374,19 @@ class CreateTestData extends Command
|
||||
'client_id' => $client->id,
|
||||
'company_id' => $company->id
|
||||
]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function createExpense($client)
|
||||
{
|
||||
|
||||
factory(\App\Models\Expense::class, rand(1, 5))->create([
|
||||
'user_id' => $client->user->id,
|
||||
'client_id' => $client->id,
|
||||
'company_id' => $client->company->id
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
private function createVendor($client)
|
||||
{
|
||||
|
||||
$vendor = factory(\App\Models\Vendor::class)->create([
|
||||
'user_id' => $client->user->id,
|
||||
'company_id' => $client->company->id
|
||||
@ -412,12 +406,10 @@ class CreateTestData extends Command
|
||||
'company_id' => $client->company->id,
|
||||
'is_primary' => 0
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
private function createTask($client)
|
||||
{
|
||||
|
||||
$vendor = factory(\App\Models\Task::class)->create([
|
||||
'user_id' => $client->user->id,
|
||||
'company_id' => $client->company->id
|
||||
@ -426,7 +418,6 @@ class CreateTestData extends Command
|
||||
|
||||
private function createProject($client)
|
||||
{
|
||||
|
||||
$vendor = factory(\App\Models\Project::class)->create([
|
||||
'user_id' => $client->user->id,
|
||||
'company_id' => $client->company->id
|
||||
@ -444,10 +435,10 @@ class CreateTestData extends Command
|
||||
$invoice = InvoiceFactory::create($client->company->id, $client->user->id);//stub the company and user_id
|
||||
$invoice->client_id = $client->id;
|
||||
// $invoice->date = $faker->date();
|
||||
$dateable = Carbon::now()->subDays(rand(0,90));
|
||||
$dateable = Carbon::now()->subDays(rand(0, 90));
|
||||
$invoice->date = $dateable;
|
||||
|
||||
$invoice->line_items = $this->buildLineItems(rand(1,10));
|
||||
$invoice->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$invoice->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -517,10 +508,10 @@ class CreateTestData extends Command
|
||||
|
||||
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
|
||||
|
||||
$dateable = Carbon::now()->subDays(rand(0,90));
|
||||
$dateable = Carbon::now()->subDays(rand(0, 90));
|
||||
$credit->date = $dateable;
|
||||
|
||||
$credit->line_items = $this->buildLineItems(rand(1,10));
|
||||
$credit->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$credit->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -548,7 +539,6 @@ class CreateTestData extends Command
|
||||
$credit->save();
|
||||
$credit->service()->markSent()->save();
|
||||
$credit->service()->createInvitations();
|
||||
|
||||
}
|
||||
|
||||
private function createQuote($client)
|
||||
@ -566,7 +556,7 @@ class CreateTestData extends Command
|
||||
|
||||
$quote->setRelation('client', $client);
|
||||
|
||||
$quote->line_items = $this->buildLineItems(rand(1,10));
|
||||
$quote->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$quote->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -595,15 +585,13 @@ class CreateTestData extends Command
|
||||
|
||||
$quote->service()->markSent()->save();
|
||||
$quote->service()->createInvitations();
|
||||
|
||||
}
|
||||
|
||||
private function buildLineItems($count = 1)
|
||||
{
|
||||
$line_items = [];
|
||||
|
||||
for($x=0; $x<$count; $x++)
|
||||
{
|
||||
for ($x=0; $x<$count; $x++) {
|
||||
$item = InvoiceItemFactory::create();
|
||||
$item->quantity = 1;
|
||||
//$item->cost = 10;
|
||||
|
@ -38,9 +38,7 @@ class DesignUpdate extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
foreach(Design::whereIsCustom(false)->get() as $design){
|
||||
|
||||
foreach (Design::whereIsCustom(false)->get() as $design) {
|
||||
$class = 'App\Designs\\'.$design->name;
|
||||
$invoice_design = new $class();
|
||||
|
||||
@ -55,7 +53,5 @@ class DesignUpdate extends Command
|
||||
$design->design = $design_object;
|
||||
$design->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ class ImportMigrations extends Command
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->faker = \Faker\Factory::create();
|
||||
|
||||
parent::__construct();
|
||||
|
@ -72,7 +72,6 @@ class SendTestEmails extends Command
|
||||
|
||||
|
||||
if (!$user) {
|
||||
|
||||
$user = factory(\App\Models\User::class)->create([
|
||||
'confirmation_code' => '123',
|
||||
'email' => $faker->safeEmail,
|
||||
@ -97,10 +96,7 @@ class SendTestEmails extends Command
|
||||
//'settings' => DefaultSettings::userSettings(),
|
||||
'settings' => null,
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$company = $user->company_users->first()->company;
|
||||
$account = $company->account;
|
||||
}
|
||||
@ -111,7 +107,6 @@ class SendTestEmails extends Command
|
||||
|
||||
|
||||
if (!$client) {
|
||||
|
||||
$client = ClientFactory::create($company->id, $user->id);
|
||||
$client->save();
|
||||
|
||||
|
@ -46,7 +46,6 @@ class CreateTestCreditJob implements ShouldQueue
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,10 +62,10 @@ class CreateTestCreditJob implements ShouldQueue
|
||||
//$invoice = InvoiceFactory::create($this->client->company->id, $this->client->user->id);//stub the company and user_id
|
||||
//$invoice->client_id = $this->client->id;
|
||||
// $invoice->date = $faker->date();
|
||||
$dateable = Carbon::now()->subDays(rand(0,90));
|
||||
$dateable = Carbon::now()->subDays(rand(0, 90));
|
||||
$credit->date = $dateable;
|
||||
|
||||
$credit->line_items = $this->buildLineItems(rand(1,10));
|
||||
$credit->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$credit->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -101,8 +100,7 @@ class CreateTestCreditJob implements ShouldQueue
|
||||
{
|
||||
$line_items = [];
|
||||
|
||||
for($x=0; $x<$count; $x++)
|
||||
{
|
||||
for ($x=0; $x<$count; $x++) {
|
||||
$item = InvoiceItemFactory::create();
|
||||
$item->quantity = 1;
|
||||
//$item->cost = 10;
|
||||
|
@ -45,7 +45,6 @@ class CreateTestInvoiceJob implements ShouldQueue
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,16 +54,15 @@ class CreateTestInvoiceJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$faker = \Faker\Factory::create();
|
||||
|
||||
$invoice = InvoiceFactory::create($this->client->company->id, $this->client->user->id);//stub the company and user_id
|
||||
$invoice->client_id = $this->client->id;
|
||||
// $invoice->date = $faker->date();
|
||||
$dateable = Carbon::now()->subDays(rand(0,90));
|
||||
$dateable = Carbon::now()->subDays(rand(0, 90));
|
||||
$invoice->date = $dateable;
|
||||
|
||||
$invoice->line_items = $this->buildLineItems(rand(1,10));
|
||||
$invoice->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$invoice->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -127,8 +125,7 @@ class CreateTestInvoiceJob implements ShouldQueue
|
||||
{
|
||||
$line_items = [];
|
||||
|
||||
for($x=0; $x<$count; $x++)
|
||||
{
|
||||
for ($x=0; $x<$count; $x++) {
|
||||
$item = InvoiceItemFactory::create();
|
||||
$item->quantity = 1;
|
||||
//$item->cost = 10;
|
||||
|
@ -46,7 +46,6 @@ class CreateTestQuoteJob implements ShouldQueue
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +60,7 @@ class CreateTestQuoteJob implements ShouldQueue
|
||||
$quote =factory(\App\Models\Quote::class)->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
|
||||
$quote->date = $faker->date();
|
||||
|
||||
$quote->line_items = $this->buildLineItems(rand(1,10));
|
||||
$quote->line_items = $this->buildLineItems(rand(1, 10));
|
||||
$quote->uses_inclusive_taxes = false;
|
||||
|
||||
if (rand(0, 1)) {
|
||||
@ -88,7 +87,6 @@ class CreateTestQuoteJob implements ShouldQueue
|
||||
$quote->service()->markSent()->save();
|
||||
|
||||
CreateQuoteInvitations::dispatch($quote, $quote->company);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -97,8 +95,7 @@ class CreateTestQuoteJob implements ShouldQueue
|
||||
{
|
||||
$line_items = [];
|
||||
|
||||
for($x=0; $x<$count; $x++)
|
||||
{
|
||||
for ($x=0; $x<$count; $x++) {
|
||||
$item = InvoiceItemFactory::create();
|
||||
$item->quantity = 1;
|
||||
//$item->cost = 10;
|
||||
@ -135,5 +132,4 @@ class CreateTestQuoteJob implements ShouldQueue
|
||||
|
||||
return $line_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ use App\Utils\Traits\MakesHash;
|
||||
* CompanySettings
|
||||
*/
|
||||
|
||||
class CompanySettings extends BaseSettings {
|
||||
|
||||
class CompanySettings extends BaseSettings
|
||||
{
|
||||
use MakesHash;
|
||||
/*Group settings based on functionality*/
|
||||
|
||||
@ -144,8 +144,8 @@ class CompanySettings extends BaseSettings {
|
||||
public $pdf_email_attachment = false;
|
||||
public $ubl_email_attachment = false;
|
||||
|
||||
public $email_style = 'plain';//plain, light, dark, custom
|
||||
public $email_style_custom = '';//the template itself
|
||||
public $email_style = 'plain'; //plain, light, dark, custom
|
||||
public $email_style_custom = ''; //the template itself
|
||||
public $email_subject_invoice = '';
|
||||
public $email_subject_quote = '';
|
||||
public $email_subject_payment = '';
|
||||
@ -404,7 +404,8 @@ class CompanySettings extends BaseSettings {
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function __construct($obj) {
|
||||
public function __construct($obj)
|
||||
{
|
||||
// parent::__construct($obj);
|
||||
}
|
||||
|
||||
@ -412,11 +413,11 @@ class CompanySettings extends BaseSettings {
|
||||
* Provides class defaults on init
|
||||
* @return object
|
||||
*/
|
||||
public static function defaults():\stdClass {
|
||||
|
||||
public static function defaults():\stdClass
|
||||
{
|
||||
$config = json_decode(config('ninja.settings'));
|
||||
|
||||
$data = (object) get_class_vars(CompanySettings::class );
|
||||
$data = (object) get_class_vars(CompanySettings::class);
|
||||
|
||||
unset($data->casts);
|
||||
unset($data->protected_fields);
|
||||
@ -441,8 +442,9 @@ class CompanySettings extends BaseSettings {
|
||||
*
|
||||
* @param object $data The settings object to be checked
|
||||
*/
|
||||
public static function setProperties($settings):\stdClass {
|
||||
$company_settings = (object) get_class_vars(CompanySettings::class );
|
||||
public static function setProperties($settings):\stdClass
|
||||
{
|
||||
$company_settings = (object) get_class_vars(CompanySettings::class);
|
||||
|
||||
foreach ($company_settings as $key => $value) {
|
||||
if (!property_exists($settings, $key)) {
|
||||
@ -453,16 +455,16 @@ class CompanySettings extends BaseSettings {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function notificationDefaults() {
|
||||
|
||||
public static function notificationDefaults()
|
||||
{
|
||||
$notification = new \stdClass;
|
||||
$notification->email = ['all_notifications'];
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
||||
private static function getEntityVariableDefaults() {
|
||||
|
||||
private static function getEntityVariableDefaults()
|
||||
{
|
||||
$variables = [
|
||||
'client_details' => [
|
||||
'$client.name' => ctrans('texts.client_name'),
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Bold extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function includes()
|
||||
@ -33,8 +33,8 @@ class Bold extends AbstractDesign
|
||||
</style>';
|
||||
}
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="flex static bg-gray-800 p-12">
|
||||
<div class="w-1/2">
|
||||
<div class="absolute bg-white pt-10 px-10 pb-4 inline-block align-middle">
|
||||
@ -50,11 +50,10 @@ class Bold extends AbstractDesign
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex mt-32 pl-12">
|
||||
<div class="w-1/2 mr-40 flex flex-col">
|
||||
<h2 class="text-2xl uppercase font-semibold text-teal-600 tracking-tight">$entity_label</h2> $client_details
|
||||
@ -86,19 +85,20 @@ class Bold extends AbstractDesign
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function product() {
|
||||
public function product()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="flex px-4 mt-6 w-full px-12">
|
||||
<div class="w-1/2">
|
||||
$entity.public_notes
|
||||
@ -127,7 +127,5 @@ class Bold extends AbstractDesign
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ namespace App\Designs;
|
||||
|
||||
class Business extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@ -48,7 +47,6 @@ class Business extends AbstractDesign
|
||||
|
||||
public function header()
|
||||
{
|
||||
|
||||
return '<div class="my-16 mx-10">
|
||||
<div class="flex justify-between">
|
||||
<div class="w-1/2">
|
||||
@ -63,12 +61,10 @@ class Business extends AbstractDesign
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body()
|
||||
{
|
||||
|
||||
return '<div class="flex items-center justify-between mt-20">
|
||||
<div class="w-1/2 flex flex-col">
|
||||
<span>$entity_label</span>
|
||||
@ -103,7 +99,6 @@ class Business extends AbstractDesign
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task()
|
||||
@ -118,7 +113,6 @@ class Business extends AbstractDesign
|
||||
|
||||
public function footer()
|
||||
{
|
||||
|
||||
return '<div class="flex items-center justify-between px-4 pb-4 bg-gray-200 rounded py-2">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -157,7 +151,5 @@ class Business extends AbstractDesign
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Clean extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ class Clean extends AbstractDesign
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="px-12 my-10">
|
||||
<div class="flex items-center">
|
||||
<div class="w-1/3">
|
||||
@ -57,8 +57,8 @@ class Clean extends AbstractDesign
|
||||
</div>';
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<h1 class="mt-12 uppercase text-2xl text-blue-500 ml-4">
|
||||
$entity_label
|
||||
</h1>
|
||||
@ -95,7 +95,6 @@ class Clean extends AbstractDesign
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task()
|
||||
@ -108,8 +107,8 @@ class Clean extends AbstractDesign
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="flex px-4 mt-6 w-full">
|
||||
<div class="w-1/2">
|
||||
$entity.public_notes
|
||||
@ -145,7 +144,5 @@ class Clean extends AbstractDesign
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ namespace App\Designs;
|
||||
*/
|
||||
class Creative extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ margin-top: 6mm;
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="py-16 mx-16">
|
||||
<div class="flex justify-between">
|
||||
<div class="w-2/3 flex">
|
||||
@ -59,11 +59,10 @@ margin-top: 6mm;
|
||||
</div>
|
||||
$company_logo
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex justify-between mt-8">
|
||||
<div class="w-2/3 flex flex-col">
|
||||
<h1 class="text-5xl uppercase font-semibold">$entity_label</h1>
|
||||
@ -96,7 +95,8 @@ margin-top: 6mm;
|
||||
</table>';
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -106,8 +106,8 @@ margin-top: 6mm;
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="border-b-4 border-pink-700">
|
||||
<div class="flex items-center justify-between mt-2 px-4 pb-4">
|
||||
<div class="w-1/2">
|
||||
@ -146,7 +146,5 @@ margin-top: 6mm;
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,5 +43,4 @@ class Custom extends AbstractDesign
|
||||
|
||||
$this->footer = $design->design->footer;
|
||||
}
|
||||
|
||||
}
|
@ -14,8 +14,8 @@ namespace App\Designs;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class Designer {
|
||||
|
||||
class Designer
|
||||
{
|
||||
public $design;
|
||||
|
||||
protected $input_variables;
|
||||
@ -57,10 +57,9 @@ class Designer {
|
||||
|
||||
$this->design = $design->design;
|
||||
|
||||
$this->input_variables = json_decode(json_encode($input_variables),1);
|
||||
$this->input_variables = json_decode(json_encode($input_variables), 1);
|
||||
|
||||
$this->entity_string = $entity_string;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +69,6 @@ class Designer {
|
||||
*/
|
||||
public function build():Designer
|
||||
{
|
||||
|
||||
$this->setHtml()
|
||||
->exportVariables()
|
||||
->setDesign($this->getSection('includes'))
|
||||
@ -79,7 +77,6 @@ class Designer {
|
||||
->setDesign($this->getSection('footer'));
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
public function init()
|
||||
@ -99,7 +96,6 @@ class Designer {
|
||||
|
||||
public function getHeader()
|
||||
{
|
||||
|
||||
$this->setDesign($this->getSection('header'));
|
||||
|
||||
return $this;
|
||||
@ -107,7 +103,6 @@ class Designer {
|
||||
|
||||
public function getFooter()
|
||||
{
|
||||
|
||||
$this->setDesign($this->getSection('footer'));
|
||||
|
||||
return $this;
|
||||
@ -115,7 +110,6 @@ class Designer {
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
|
||||
$this->setDesign($this->getSection('body'));
|
||||
|
||||
return $this;
|
||||
@ -135,7 +129,6 @@ class Designer {
|
||||
|
||||
private function setDesign($section)
|
||||
{
|
||||
|
||||
$this->html .= $section;
|
||||
|
||||
return $this;
|
||||
@ -155,7 +148,6 @@ class Designer {
|
||||
|
||||
private function exportVariables()
|
||||
{
|
||||
|
||||
$company = $this->entity->company;
|
||||
|
||||
$this->exported_variables['$app_url'] = $this->entity->generateAppUrl();
|
||||
@ -163,18 +155,13 @@ class Designer {
|
||||
$this->exported_variables['$company_details'] = $this->processVariables($this->input_variables['company_details'], $this->companyDetails($company));
|
||||
$this->exported_variables['$company_address'] = $this->processVariables($this->input_variables['company_address'], $this->companyAddress($company));
|
||||
|
||||
if($this->entity_string == 'invoice')
|
||||
{
|
||||
if ($this->entity_string == 'invoice') {
|
||||
$this->exported_variables['$entity_labels'] = $this->processLabels($this->input_variables['invoice_details'], $this->invoiceDetails($company));
|
||||
$this->exported_variables['$entity_details'] = $this->processVariables($this->input_variables['invoice_details'], $this->invoiceDetails($company));
|
||||
}
|
||||
elseif($this->entity_string == 'credit')
|
||||
{
|
||||
} elseif ($this->entity_string == 'credit') {
|
||||
$this->exported_variables['$entity_labels'] = $this->processLabels($this->input_variables['credit_details'], $this->creditDetails($company));
|
||||
$this->exported_variables['$entity_details'] = $this->processVariables($this->input_variables['credit_details'], $this->creditDetails($company));
|
||||
}
|
||||
elseif($this->entity_string == 'quote')
|
||||
{
|
||||
} elseif ($this->entity_string == 'quote') {
|
||||
$this->exported_variables['$entity_labels'] = $this->processLabels($this->input_variables['quote_details'], $this->quoteDetails($company));
|
||||
$this->exported_variables['$entity_details'] = $this->processVariables($this->input_variables['quote_details'], $this->quoteDetails($company));
|
||||
}
|
||||
@ -184,11 +171,13 @@ class Designer {
|
||||
$this->exported_variables['$task_table_header'] = $this->entity->buildTableHeader($this->input_variables['task_columns']);
|
||||
$this->exported_variables['$task_table_body'] = $this->entity->buildTableBody($this->input_variables['task_columns'], $this->design->task, '$task');
|
||||
|
||||
if(strlen($this->exported_variables['$task_table_body']) == 0)
|
||||
if (strlen($this->exported_variables['$task_table_body']) == 0) {
|
||||
$this->exported_variables['$task_table_header'] = '';
|
||||
}
|
||||
|
||||
if(strlen($this->exported_variables['$product_table_body']) == 0)
|
||||
if (strlen($this->exported_variables['$product_table_body']) == 0) {
|
||||
$this->exported_variables['$product_table_header'] = '';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -197,20 +186,18 @@ class Designer {
|
||||
{
|
||||
$output = '';
|
||||
|
||||
foreach (array_keys($input_variables) as $value)
|
||||
foreach (array_keys($input_variables) as $value) {
|
||||
$output .= $variables[$value];
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
private function processLabels($input_variables, $variables):string
|
||||
{
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach (array_keys($input_variables) as $value) {
|
||||
|
||||
$tmp = str_replace("</span>", "_label</span>", $variables[$value]);
|
||||
//$output .= $variables[$value];
|
||||
$output .= $tmp;
|
||||
@ -221,7 +208,6 @@ class Designer {
|
||||
|
||||
private function clientDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$client.name' => '<p>$client.name</p>',
|
||||
'$client.id_number' => '<p>$client.id_number</p>',
|
||||
@ -247,7 +233,6 @@ class Designer {
|
||||
|
||||
private function companyDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$company.company_name' => '<span>$company.company_name</span>',
|
||||
'$company.id_number' => '<span>$company.id_number</span>',
|
||||
@ -262,12 +247,10 @@ class Designer {
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
||||
}
|
||||
|
||||
private function companyAddress(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$company.address1' => '<span>$company.address1</span>',
|
||||
'$company.address2' => '<span>$company.address2</span>',
|
||||
@ -281,12 +264,10 @@ class Designer {
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
||||
}
|
||||
|
||||
private function invoiceDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$invoice.invoice_number' => '<span>$invoice_number_label</span><span>$invoice_number</span>',
|
||||
'$invoice.po_number' => '<span>$po_number_label</span><span>$po_number</span>',
|
||||
@ -306,12 +287,10 @@ class Designer {
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
||||
}
|
||||
|
||||
private function quoteDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$quote.quote_number' => '<span>$quote_number</span>',
|
||||
'$quote.po_number' => '<span>$po_number</span>',
|
||||
@ -331,12 +310,10 @@ class Designer {
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
||||
}
|
||||
|
||||
private function creditDetails(Company $company)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'$credit.credit_number' => '<span>$credit_number</span>',
|
||||
'$credit.po_number' => '<span>$po_number</span>',
|
||||
@ -355,12 +332,10 @@ class Designer {
|
||||
];
|
||||
|
||||
return $this->processCustomFields($company, $data);
|
||||
|
||||
}
|
||||
|
||||
private function processCustomFields(Company $company, $data)
|
||||
{
|
||||
|
||||
$custom_fields = $company->custom_fields;
|
||||
|
||||
if (!$custom_fields) {
|
||||
@ -368,15 +343,12 @@ class Designer {
|
||||
}
|
||||
|
||||
foreach (self::$custom_fields as $cf) {
|
||||
|
||||
if (!property_exists($custom_fields, $cf) || (strlen($custom_fields->{$cf}) == 0)) {
|
||||
unset($data[$cf]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
// private function processInputVariables($company, $variables)
|
||||
@ -403,5 +375,4 @@ class Designer {
|
||||
// return $variables;
|
||||
|
||||
// }
|
||||
|
||||
}
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Elegant extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ class Elegant extends AbstractDesign
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="py-16 px-8">
|
||||
<div class="flex flex justify-between border-b-4 border-black">
|
||||
<div style="margin-bottom: 15px">
|
||||
@ -56,11 +56,10 @@ class Elegant extends AbstractDesign
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-px border-b border-black mt-1"></div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex mt-8">
|
||||
<div class="w-1/3 mr-6 flex flex-col pr-2 border-r border-dashed border-black">
|
||||
$client_details
|
||||
@ -88,10 +87,10 @@ class Elegant extends AbstractDesign
|
||||
$product_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -100,8 +99,8 @@ class Elegant extends AbstractDesign
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="flex items-center justify-between mt-2 px-4 pb-4">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -142,7 +141,5 @@ class Elegant extends AbstractDesign
|
||||
</div>
|
||||
<div class="p-px border-b border-black mt-1"></div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Hipster extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,8 @@ body {font-size:90%}
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="px-12 py-16">
|
||||
<div class="flex">
|
||||
<div class="w-1/2 border-l pl-4 border-black mr-4">
|
||||
@ -63,11 +63,10 @@ body {font-size:90%}
|
||||
$company_logo
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex flex-col mx-6 mt-10">
|
||||
<h1 class="font-semibold uppercase text-6xl">$entity_label</h1>
|
||||
<div class="flex mt-1">
|
||||
@ -102,10 +101,10 @@ body {font-size:90%}
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -114,8 +113,8 @@ body {font-size:90%}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="flex justify-between mt-8">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -148,7 +147,5 @@ body {font-size:90%}
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Modern extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ class Modern extends AbstractDesign
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="div_header bg-orange-600 flex justify-between py-12 px-12" style="page-break-inside: avoid;">
|
||||
<div class="w-1/2">
|
||||
<h1 class="text-white font-bold text-5xl">$company.name</h1>
|
||||
@ -76,11 +76,10 @@ class Modern extends AbstractDesign
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<section>
|
||||
<div class="flex justify-between px-12 pt-12">
|
||||
<div class="w-1/2">
|
||||
@ -112,10 +111,10 @@ class Modern extends AbstractDesign
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -124,8 +123,8 @@ class Modern extends AbstractDesign
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '
|
||||
<div class="flex px-4 mt-6 w-full" style="page-break-inside: avoid;">
|
||||
<div class="w-1/2">
|
||||
@ -181,7 +180,5 @@ class Modern extends AbstractDesign
|
||||
</footer>
|
||||
</html>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Photo extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -44,8 +44,8 @@ body {font-size:90%}
|
||||
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="px-16 py-10">
|
||||
<div class="flex items-center justify-between mt-2s">
|
||||
<div ref="logo">
|
||||
@ -61,11 +61,10 @@ body {font-size:90%}
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex content-center flex-wrap bg-gray-200 h-auto p-16" id="imageContainer">
|
||||
<div class="flex flex-col">
|
||||
<div class="flex">
|
||||
@ -99,10 +98,10 @@ body {font-size:90%}
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -111,8 +110,8 @@ body {font-size:90%}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '<div class="flex items-center justify-between mt-2 px-4 pb-4">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -153,7 +152,5 @@ body {font-size:90%}
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Plain extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ body {font-size:90%}
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return ' <div class="px-12 py-8">
|
||||
<div class="flex justify-between">
|
||||
$company_logo
|
||||
@ -58,11 +58,10 @@ body {font-size:90%}
|
||||
</section>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex flex-col mt-8">
|
||||
$client_details
|
||||
</div>
|
||||
@ -81,22 +80,8 @@ body {font-size:90%}
|
||||
<tbody>
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
return '<div class="flex justify-between mt-8">
|
||||
</table>
|
||||
<div class="flex justify-between mt-8">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
<p>$entity.public_notes</p>
|
||||
@ -124,11 +109,21 @@ body {font-size:90%}
|
||||
<p class="text-right w-1/2">$balance_due</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
</div>';
|
||||
}
|
||||
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace App\Designs;
|
||||
|
||||
class Playful extends AbstractDesign
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ body {font-size:90%}
|
||||
}
|
||||
|
||||
|
||||
public function header() {
|
||||
|
||||
public function header()
|
||||
{
|
||||
return '<div class="my-12 mx-16">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="w-1/2">
|
||||
@ -57,11 +57,10 @@ body {font-size:90%}
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
public function body() {
|
||||
|
||||
public function body()
|
||||
{
|
||||
return '<div class="flex mt-16">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -99,22 +98,8 @@ body {font-size:90%}
|
||||
<tbody>
|
||||
$task_table_body
|
||||
</tbody>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public function task() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer() {
|
||||
|
||||
return '<div class="flex items-center justify-between mt-2 px-4 pb-4">
|
||||
</table>
|
||||
<div class="flex items-center justify-between mt-2 px-4 pb-4">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
<p>$entity.public_notes</p>
|
||||
@ -134,7 +119,6 @@ body {font-size:90%}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between mt-4 pb-4 px-4">
|
||||
<div class="w-1/2">
|
||||
<div class="flex flex-col">
|
||||
@ -147,14 +131,21 @@ body {font-size:90%}
|
||||
<p class="w-1/2">$balance_due_label</p>
|
||||
<p class="text-right w-1/2">$balance_due</p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
</div>';
|
||||
}
|
||||
|
||||
public function task()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class CreditFilters extends QueryFilters
|
||||
$this->builder->where('status_id', Credit::STAUTS_PARTIAL);
|
||||
}
|
||||
|
||||
if(in_array('applied', $status_parameters)) {
|
||||
if (in_array('applied', $status_parameters)) {
|
||||
$this->builder->where('status_id', Credit::STATUS_APPLIED);
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,6 @@ class DesignFilters extends QueryFilters
|
||||
public function entityFilter()
|
||||
{
|
||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||
return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id',null);
|
||||
return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
||||
}
|
||||
}
|
||||
|
@ -8,55 +8,62 @@
|
||||
|
||||
namespace App\Helpers\Email;
|
||||
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Number;
|
||||
|
||||
class InvoiceEmail extends EmailBuilder
|
||||
{
|
||||
|
||||
public function build(InvoiceInvitation $invitation, $reminder_template)
|
||||
{
|
||||
$client = $invitation->contact->client;
|
||||
$invoice = $invitation->invoice;
|
||||
$contact = $invitation->contact;
|
||||
|
||||
if(!$reminder_template)
|
||||
if (!$reminder_template) {
|
||||
$reminder_template = $invoice->calculateTemplate();
|
||||
}
|
||||
|
||||
$body_template = $client->getSetting('email_template_' . $reminder_template);
|
||||
|
||||
|
||||
/* Use default translations if a custom message has not been set*/
|
||||
if (iconv_strlen($body_template) == 0) {
|
||||
$body_template = trans('texts.invoice_message',
|
||||
$body_template = trans(
|
||||
'texts.invoice_message',
|
||||
[
|
||||
'invoice' => $invoice->number,
|
||||
'company' => $invoice->company->present()->name(),
|
||||
'amount' => Number::formatMoney($invoice->balance, $invoice->client),
|
||||
],
|
||||
null,
|
||||
$invoice->client->locale());
|
||||
$invoice->client->locale()
|
||||
);
|
||||
}
|
||||
|
||||
$subject_template = $client->getSetting('email_subject_' . $reminder_template);
|
||||
|
||||
if (iconv_strlen($subject_template) == 0) {
|
||||
if ($reminder_template == 'quote') {
|
||||
$subject_template = trans('texts.invoice_subject',
|
||||
$subject_template = trans(
|
||||
'texts.invoice_subject',
|
||||
[
|
||||
'invoice' => $invoice->present()->invoice_number(),
|
||||
'account' => $invoice->company->present()->name()
|
||||
],
|
||||
null, $invoice->client->locale());
|
||||
null,
|
||||
$invoice->client->locale()
|
||||
);
|
||||
} else {
|
||||
$subject_template = trans('texts.reminder_subject',
|
||||
$subject_template = trans(
|
||||
'texts.reminder_subject',
|
||||
[
|
||||
'invoice' => $invoice->present()->invoice_number(),
|
||||
'account' => $invoice->company->present()->name()
|
||||
],
|
||||
null, $invoice->client->locale());
|
||||
null,
|
||||
$invoice->client->locale()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,28 +10,33 @@ namespace App\Helpers\Email;
|
||||
|
||||
use App\Models\Payment;
|
||||
|
||||
|
||||
class EmailPayment extends EmailBuilder
|
||||
{
|
||||
public function build(Payment $payment, $contact = null) {
|
||||
public function build(Payment $payment, $contact = null)
|
||||
{
|
||||
$client = $payment->client;
|
||||
|
||||
$body_template = $client->getSetting('email_template_payment');
|
||||
|
||||
/* Use default translations if a custom message has not been set*/
|
||||
if (iconv_strlen($body_template) == 0) {
|
||||
|
||||
$body_template = trans('texts.payment_message',
|
||||
['amount' => $payment->amount, 'company' => $payment->company->present()->name()], null,
|
||||
$this->client->locale());
|
||||
$body_template = trans(
|
||||
'texts.payment_message',
|
||||
['amount' => $payment->amount, 'company' => $payment->company->present()->name()],
|
||||
null,
|
||||
$this->client->locale()
|
||||
);
|
||||
}
|
||||
|
||||
$subject_template = $client->getSetting('email_subject_payment');
|
||||
|
||||
if (iconv_strlen($subject_template) == 0) {
|
||||
$subject_template = trans('texts.payment_subject',
|
||||
['number' => $payment->number, 'company' => $payment->company->present()->name()], null,
|
||||
$payment->client->locale());
|
||||
$subject_template = trans(
|
||||
'texts.payment_subject',
|
||||
['number' => $payment->number, 'company' => $payment->company->present()->name()],
|
||||
null,
|
||||
$payment->client->locale()
|
||||
);
|
||||
}
|
||||
|
||||
$this->setTemplate($payment->client->getSetting('email_style'))
|
||||
|
@ -11,10 +11,8 @@ namespace App\Helpers\Email;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
|
||||
|
||||
class QuoteEmail extends EmailBuilder
|
||||
{
|
||||
|
||||
public function build(QuoteInvitation $invitation, $reminder_template)
|
||||
{
|
||||
$client = $invitation->contact->client;
|
||||
@ -27,22 +25,31 @@ class QuoteEmail extends EmailBuilder
|
||||
|
||||
/* Use default translations if a custom message has not been set*/
|
||||
if (iconv_strlen($body_template) == 0) {
|
||||
$body_template = trans('texts.quote_message',
|
||||
['amount' => $quote->amount, 'company' => $quote->company->present()->name()], null,
|
||||
$quote->client->locale());
|
||||
$body_template = trans(
|
||||
'texts.quote_message',
|
||||
['amount' => $quote->amount, 'company' => $quote->company->present()->name()],
|
||||
null,
|
||||
$quote->client->locale()
|
||||
);
|
||||
}
|
||||
|
||||
$subject_template = $client->getSetting('email_subject_' . $reminder_template);
|
||||
|
||||
if (iconv_strlen($subject_template) == 0) {
|
||||
if ($reminder_template == 'quote') {
|
||||
$subject_template = trans('texts.quote_subject',
|
||||
$subject_template = trans(
|
||||
'texts.quote_subject',
|
||||
['number' => $quote->number, 'company' => $quote->company->present()->name()],
|
||||
null, $quote->client->locale());
|
||||
null,
|
||||
$quote->client->locale()
|
||||
);
|
||||
} else {
|
||||
$subject_template = trans('texts.reminder_subject',
|
||||
$subject_template = trans(
|
||||
'texts.reminder_subject',
|
||||
['number' => $quote->number, 'company' => $quote->company->present()->name()],
|
||||
null, $quote->client->locale());
|
||||
null,
|
||||
$quote->client->locale()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,4 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Document;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
@ -13,7 +9,10 @@ use Illuminate\Support\Facades\Storage;
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
/**
|
||||
use App\Models\Document;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Generate url for the asset.
|
||||
*
|
||||
* @param Document $document
|
||||
@ -24,9 +23,13 @@ function generateUrl(Document $document, $absolute = false)
|
||||
{
|
||||
$url = Storage::disk($document->disk)->url($document->path);
|
||||
|
||||
if($url && $absolute) return url($url);
|
||||
if ($url && $absolute) {
|
||||
return url($url);
|
||||
}
|
||||
|
||||
if ($url) return $url;
|
||||
if ($url) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
@ -173,22 +173,18 @@ class InvoiceSum
|
||||
|
||||
public function getQuote()
|
||||
{
|
||||
|
||||
$this->setCalculatedAttributes();
|
||||
$this->invoice->save();
|
||||
|
||||
return $this->invoice;
|
||||
|
||||
}
|
||||
|
||||
public function getCredit()
|
||||
{
|
||||
|
||||
$this->setCalculatedAttributes();
|
||||
$this->invoice->save();
|
||||
|
||||
return $this->invoice;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,8 +147,9 @@ class AccountController extends BaseController
|
||||
{
|
||||
$account = CreateAccount::dispatchNow($request->all());
|
||||
|
||||
if(!($account instanceof Account))
|
||||
if (!($account instanceof Account)) {
|
||||
return $account;
|
||||
}
|
||||
|
||||
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
||||
|
||||
|
@ -175,9 +175,7 @@ class LoginController extends BaseController
|
||||
$ct = CompanyUser::whereUserId($user->id)->with('company');
|
||||
|
||||
return $this->listResponse($ct);
|
||||
|
||||
} else {
|
||||
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
return response()
|
||||
|
@ -67,7 +67,8 @@ class ResetPasswordController extends Controller
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$response = $this->broker()->reset(
|
||||
$this->credentials($request), function ($user, $password) {
|
||||
$this->credentials($request),
|
||||
function ($user, $password) {
|
||||
$this->resetPassword($user, $password);
|
||||
}
|
||||
);
|
||||
|
@ -58,35 +58,25 @@ class BaseController extends Controller
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->manager = new Manager();
|
||||
|
||||
$this->forced_includes = [];
|
||||
|
||||
$this->forced_index = 'data';
|
||||
|
||||
}
|
||||
|
||||
private function buildManager()
|
||||
{
|
||||
|
||||
$include = '';
|
||||
|
||||
if(request()->has('first_load') && request()->input('first_load') == 'true') {
|
||||
|
||||
$include = implode("," , array_merge($this->forced_includes, $this->getRequestIncludes([])));
|
||||
|
||||
}
|
||||
else if (request()->input('include') !== null) {
|
||||
|
||||
if (request()->has('first_load') && request()->input('first_load') == 'true') {
|
||||
$include = implode(",", array_merge($this->forced_includes, $this->getRequestIncludes([])));
|
||||
} elseif (request()->input('include') !== null) {
|
||||
$include = array_merge($this->forced_includes, explode(",", request()->input('include')));
|
||||
|
||||
$include = implode(",", $include);
|
||||
|
||||
} elseif (count($this->forced_includes) >= 1) {
|
||||
|
||||
$include = implode(",", $this->forced_includes);
|
||||
|
||||
}
|
||||
|
||||
$this->manager->parseIncludes($include);
|
||||
@ -94,15 +84,10 @@ class BaseController extends Controller
|
||||
$this->serializer = request()->input('serializer') ?: EntityTransformer::API_SERIALIZER_ARRAY;
|
||||
|
||||
if ($this->serializer === EntityTransformer::API_SERIALIZER_JSON) {
|
||||
|
||||
$this->manager->setSerializer(new JsonApiSerializer());
|
||||
|
||||
} else {
|
||||
|
||||
$this->manager->setSerializer(new ArraySerializer());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,23 +96,18 @@ class BaseController extends Controller
|
||||
*/
|
||||
public function notFound()
|
||||
{
|
||||
|
||||
return response()->json(['message' => '404 | Nothing to see here!'], 404)
|
||||
->header('X-API-VERSION', config('ninja.api_version'))
|
||||
->header('X-APP-VERSION', config('ninja.app_version'));
|
||||
|
||||
}
|
||||
|
||||
public function notFoundClient()
|
||||
{
|
||||
|
||||
return abort(404);
|
||||
|
||||
}
|
||||
|
||||
protected function errorResponse($response, $httpErrorCode = 400)
|
||||
{
|
||||
|
||||
$error['error'] = $response;
|
||||
|
||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||
@ -135,12 +115,10 @@ class BaseController extends Controller
|
||||
$headers = self::getApiHeaders();
|
||||
|
||||
return response()->make($error, $httpErrorCode, $headers);
|
||||
|
||||
}
|
||||
|
||||
protected function listResponse($query)
|
||||
{
|
||||
|
||||
$this->buildManager();
|
||||
|
||||
$transformer = new $this->entity_transformer(Input::get('serializer'));
|
||||
@ -152,7 +130,7 @@ class BaseController extends Controller
|
||||
$query->with($includes);
|
||||
|
||||
if (auth()->user()->cannot('view_'.$this->entity_type)) {
|
||||
if ($this->entity_type == Company::class || $this->entity_type == Design::class ) {
|
||||
if ($this->entity_type == Company::class || $this->entity_type == Design::class) {
|
||||
//no user keys exist on the company table, so we need to skip
|
||||
} elseif ($this->entity_type == User::class) {
|
||||
//$query->where('id', '=', auth()->user()->id); @todo why?
|
||||
@ -169,40 +147,33 @@ class BaseController extends Controller
|
||||
$data = $this->createCollection($query, $transformer, $this->entity_type);
|
||||
|
||||
return $this->response($data);
|
||||
|
||||
}
|
||||
|
||||
protected function createCollection($query, $transformer, $entity_type)
|
||||
{
|
||||
|
||||
$this->buildManager();
|
||||
|
||||
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON)
|
||||
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
|
||||
$entity_type = null;
|
||||
}
|
||||
|
||||
|
||||
if (is_a($query, "Illuminate\Database\Eloquent\Builder")) {
|
||||
|
||||
$limit = Input::get('per_page', 20);
|
||||
|
||||
$paginator = $query->paginate($limit);
|
||||
$query = $paginator->getCollection();
|
||||
$resource = new Collection($query, $transformer, $entity_type);
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
} else {
|
||||
|
||||
$resource = new Collection($query, $transformer, $entity_type);
|
||||
|
||||
}
|
||||
|
||||
return $this->manager->createData($resource)->toArray();
|
||||
|
||||
}
|
||||
|
||||
protected function response($response)
|
||||
{
|
||||
|
||||
$index = request()->input('index') ?: $this->forced_index;
|
||||
|
||||
if ($index == 'none') {
|
||||
@ -230,52 +201,46 @@ class BaseController extends Controller
|
||||
$headers = self::getApiHeaders();
|
||||
|
||||
return response()->make($response, 200, $headers);
|
||||
|
||||
}
|
||||
|
||||
protected function itemResponse($item)
|
||||
{
|
||||
|
||||
$this->buildManager();
|
||||
|
||||
$transformer = new $this->entity_transformer(Input::get('serializer'));
|
||||
|
||||
$data = $this->createItem($item, $transformer, $this->entity_type);
|
||||
|
||||
if (request()->include_static)
|
||||
if (request()->include_static) {
|
||||
$data['static'] = Statics::company(auth()->user()->getCompany()->getLocale());
|
||||
}
|
||||
|
||||
return $this->response($data);
|
||||
|
||||
}
|
||||
|
||||
protected function createItem($data, $transformer, $entity_type)
|
||||
{
|
||||
|
||||
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON)
|
||||
if ($this->serializer && $this->serializer != EntityTransformer::API_SERIALIZER_JSON) {
|
||||
$entity_type = null;
|
||||
}
|
||||
|
||||
$resource = new Item($data, $transformer, $entity_type);
|
||||
|
||||
return $this->manager->createData($resource)->toArray();
|
||||
|
||||
}
|
||||
|
||||
public static function getApiHeaders($count = 0)
|
||||
{
|
||||
|
||||
return [
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Api-Version' => config('ninja.api_version'),
|
||||
'X-App-Version' => config('ninja.app_version'),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function getRequestIncludes($data)
|
||||
{
|
||||
|
||||
$first_load = [
|
||||
'account',
|
||||
'user.company_user',
|
||||
@ -311,25 +276,13 @@ class BaseController extends Controller
|
||||
/**
|
||||
* Thresholds for displaying large account on first load
|
||||
*/
|
||||
if (request()->has('first_load') && request()->input('first_load') == 'true')
|
||||
{
|
||||
|
||||
if (auth()->user()->getCompany()->invoices->count() > 1000)
|
||||
{
|
||||
|
||||
if (request()->has('first_load') && request()->input('first_load') == 'true') {
|
||||
if (auth()->user()->getCompany()->invoices->count() > 1000) {
|
||||
$data = $mini_load;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
} else {
|
||||
$data = $first_load;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
} else {
|
||||
$included = request()->input('include');
|
||||
$included = explode(',', $included);
|
||||
|
||||
@ -340,20 +293,16 @@ class BaseController extends Controller
|
||||
$data[] = $include;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
public function flutterRoute()
|
||||
{
|
||||
|
||||
if(!$this->checkAppSetup());
|
||||
if (!$this->checkAppSetup());
|
||||
return redirect('/setup');
|
||||
|
||||
return view('index.index');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -279,8 +279,9 @@ class ClientController extends BaseController
|
||||
*/
|
||||
public function update(UpdateClientRequest $request, Client $client)
|
||||
{
|
||||
if($request->entityIsDeleted($client))
|
||||
if ($request->entityIsDeleted($client)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$client = $this->client_repo->save($request->all(), $client);
|
||||
|
||||
|
@ -38,26 +38,22 @@ class InvitationController extends Controller
|
||||
$invitation = $entity_obj::whereRaw("BINARY `key`= ?", [$invitation_key])->first();
|
||||
|
||||
if ($invitation) {
|
||||
|
||||
if ((bool)$invitation->contact->client->getSetting('enable_client_portal_password') !== false) {
|
||||
$this->middleware('auth:contact');
|
||||
} else {
|
||||
auth()->guard('contact')->login($invitation->contact, false);
|
||||
}
|
||||
|
||||
if(!request()->has('silent')){
|
||||
|
||||
if (!request()->has('silent')) {
|
||||
$invitation->markViewed();
|
||||
|
||||
event(new InvitationWasViewed($entity, $invitation));
|
||||
|
||||
}
|
||||
|
||||
return redirect()->route('client.'.$entity.'.show', [$entity => $this->encodePrimaryKey($invitation->{$key})]);
|
||||
|
||||
} else
|
||||
} else {
|
||||
abort(404);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function routerForDownload(string $entity, string $invitation_key)
|
||||
|
@ -461,33 +461,23 @@ class CompanyController extends BaseController
|
||||
{
|
||||
$company_count = $company->account->companies->count();
|
||||
|
||||
if($company_count == 1){
|
||||
|
||||
if ($company_count == 1) {
|
||||
$company->company_users->each(function ($company_user) {
|
||||
|
||||
$company_user->user->forceDelete();
|
||||
|
||||
});
|
||||
|
||||
$company->account->delete();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
$account = $company->account;
|
||||
$company_id = $company->id;
|
||||
$company->delete();
|
||||
|
||||
//If we are deleting the default companies, we'll need to make a new company the default.
|
||||
if($account->default_company_id == $company_id){
|
||||
|
||||
if ($account->default_company_id == $company_id) {
|
||||
$new_default_company = Company::whereAccountId($account->id)->first();
|
||||
$account->default_company_id = $new_default_company->id;
|
||||
$account->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//@todo delete documents also!!
|
||||
@ -496,6 +486,5 @@ class CompanyController extends BaseController
|
||||
//account will trigger an account refund.
|
||||
|
||||
return response()->json(['message' => 'success'], 200);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ use Illuminate\Http\Request;
|
||||
|
||||
class CompanyUserController extends BaseController
|
||||
{
|
||||
|
||||
protected $entity_type = CompanyUser::class;
|
||||
|
||||
protected $entity_transformer = CompanyUserTransformer::class;
|
||||
@ -55,7 +54,6 @@ class CompanyUserController extends BaseController
|
||||
|
||||
public function store(CreateAccountRequest $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,15 +130,14 @@ class CompanyUserController extends BaseController
|
||||
|
||||
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
|
||||
|
||||
if(!$company_user){
|
||||
if (!$company_user) {
|
||||
throw new ModelNotFoundException("Company User record not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(auth()->user()->isAdmin()){
|
||||
if (auth()->user()->isAdmin()) {
|
||||
$company_user->fill($request->input('company_user'));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$company_user->fill($request->input('company_user')['settings']);
|
||||
$company_user->fill($request->input('company_user')['notifications']);
|
||||
}
|
||||
|
@ -33,8 +33,9 @@ class Controller extends BaseController
|
||||
|
||||
if (array_key_exists('root', $options)) {
|
||||
return view(
|
||||
sprintf('%s.%s.%s', $options['root'], $theme, $path)
|
||||
, $options);
|
||||
sprintf('%s.%s.%s', $options['root'], $theme, $path),
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
return view("portal.$theme.$path", $options);
|
||||
|
@ -362,8 +362,9 @@ class CreditController extends BaseController
|
||||
*/
|
||||
public function update(UpdateCreditRequest $request, Credit $credit)
|
||||
{
|
||||
if($request->entityIsDeleted($credit))
|
||||
if ($request->entityIsDeleted($credit)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$credit = $this->credit_repository->save($request->all(), $credit);
|
||||
|
||||
@ -574,7 +575,6 @@ class CreditController extends BaseController
|
||||
|
||||
public function downloadPdf($invitation_key)
|
||||
{
|
||||
|
||||
$invitation = $this->credit_repository->getInvitationByKey($invitation_key);
|
||||
$contact = $invitation->contact;
|
||||
$credit = $invitation->credit;
|
||||
@ -582,6 +582,5 @@ class CreditController extends BaseController
|
||||
$file_path = $credit->service()->getCreditPdf($contact);
|
||||
|
||||
return response()->download($file_path);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -255,8 +255,9 @@ class DesignController extends BaseController
|
||||
*/
|
||||
public function update(UpdateDesignRequest $request, Design $design)
|
||||
{
|
||||
if($request->entityIsDeleted($design))
|
||||
if ($request->entityIsDeleted($design)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$design->fill($request->all());
|
||||
$design->save();
|
||||
@ -485,6 +486,4 @@ class DesignController extends BaseController
|
||||
|
||||
return $this->listResponse(Design::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -267,8 +267,9 @@ class ExpenseController extends BaseController
|
||||
*/
|
||||
public function update(UpdateExpenseRequest $request, Expense $expense)
|
||||
{
|
||||
if($request->entityIsDeleted($expense))
|
||||
if ($request->entityIsDeleted($expense)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$expense = $this->client_repo->save($request->all(), $expense);
|
||||
|
||||
|
@ -45,8 +45,8 @@ use Illuminate\Support\Facades\Storage;
|
||||
* @package App\Http\Controllers\InvoiceController
|
||||
*/
|
||||
|
||||
class InvoiceController extends BaseController {
|
||||
|
||||
class InvoiceController extends BaseController
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected $entity_type = Invoice::class ;
|
||||
@ -63,12 +63,11 @@ class InvoiceController extends BaseController {
|
||||
*
|
||||
* @param \App\Repositories\InvoiceRepository $invoice_repo The invoice repo
|
||||
*/
|
||||
public function __construct(InvoiceRepository $invoice_repo) {
|
||||
|
||||
public function __construct(InvoiceRepository $invoice_repo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->invoice_repo = $invoice_repo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +111,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function index(InvoiceFilters $filters) {
|
||||
public function index(InvoiceFilters $filters)
|
||||
{
|
||||
$invoices = Invoice::filter($filters);
|
||||
|
||||
return $this->listResponse($invoices);
|
||||
@ -158,8 +158,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function create(CreateInvoiceRequest $request) {
|
||||
|
||||
public function create(CreateInvoiceRequest $request)
|
||||
{
|
||||
$invoice = InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
||||
|
||||
return $this->itemResponse($invoice);
|
||||
@ -205,8 +205,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function store(StoreInvoiceRequest $request) {
|
||||
|
||||
public function store(StoreInvoiceRequest $request)
|
||||
{
|
||||
$client = Client::find($request->input('client_id'));
|
||||
|
||||
$invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
@ -270,7 +270,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function show(ShowInvoiceRequest $request, Invoice $invoice) {
|
||||
public function show(ShowInvoiceRequest $request, Invoice $invoice)
|
||||
{
|
||||
return $this->itemResponse($invoice);
|
||||
}
|
||||
|
||||
@ -325,7 +326,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function edit(EditInvoiceRequest $request, Invoice $invoice) {
|
||||
public function edit(EditInvoiceRequest $request, Invoice $invoice)
|
||||
{
|
||||
return $this->itemResponse($invoice);
|
||||
}
|
||||
|
||||
@ -381,7 +383,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function update(UpdateInvoiceRequest $request, Invoice $invoice) {
|
||||
public function update(UpdateInvoiceRequest $request, Invoice $invoice)
|
||||
{
|
||||
if ($request->entityIsDeleted($invoice)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
@ -443,7 +446,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function destroy(DestroyInvoiceRequest $request, Invoice $invoice) {
|
||||
public function destroy(DestroyInvoiceRequest $request, Invoice $invoice)
|
||||
{
|
||||
$invoice->delete();
|
||||
|
||||
return response()->json([], 200);
|
||||
@ -500,7 +504,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function bulk() {
|
||||
public function bulk()
|
||||
{
|
||||
|
||||
/*
|
||||
* WIP!
|
||||
@ -519,31 +524,25 @@ class InvoiceController extends BaseController {
|
||||
* Download Invoice/s
|
||||
*/
|
||||
|
||||
if($action == 'download' && $invoices->count() > 1)
|
||||
{
|
||||
|
||||
if ($action == 'download' && $invoices->count() > 1) {
|
||||
$invoices->each(function ($invoice) {
|
||||
|
||||
if(auth()->user()->cannot('view', $invoice)){
|
||||
if (auth()->user()->cannot('view', $invoice)) {
|
||||
return response()->json(['message'=>'Insufficient privileges to access invoice '. $invoice->number]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ZipInvoices::dispatch($invoices, $invoices->first()->company, auth()->user()->email);
|
||||
|
||||
return response()->json(['message' => 'Email Sent!'],200);
|
||||
return response()->json(['message' => 'Email Sent!'], 200);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the other actions to the switch
|
||||
*/
|
||||
$invoices->each(function ($invoice, $key) use ($action) {
|
||||
|
||||
if (auth()->user()->can('edit', $invoice)) {
|
||||
$this->performAction($invoice, $action, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Need to understand which permission are required for the given bulk action ie. view / edit */
|
||||
@ -619,11 +618,13 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function action(ActionInvoiceRequest $request, Invoice $invoice, $action) {
|
||||
public function action(ActionInvoiceRequest $request, Invoice $invoice, $action)
|
||||
{
|
||||
return $this->performAction($invoice, $action);
|
||||
}
|
||||
|
||||
private function performAction(Invoice $invoice, $action, $bulk = false) {
|
||||
private function performAction(Invoice $invoice, $action, $bulk = false)
|
||||
{
|
||||
/*If we are using bulk actions, we don't want to return anything */
|
||||
switch ($action) {
|
||||
case 'clone_to_invoice':
|
||||
@ -679,15 +680,13 @@ class InvoiceController extends BaseController {
|
||||
|
||||
$this->reminder_template = $invoice->calculateTemplate();
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use($invoice){
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||
$email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template);
|
||||
|
||||
EmailInvoice::dispatch($email_builder, $invitation, $invoice->company);
|
||||
|
||||
});
|
||||
|
||||
if($invoice->invitations->count() > 0){
|
||||
if ($invoice->invitations->count() > 0) {
|
||||
\Log::error("more than one invitation to send");
|
||||
event(new InvoiceWasEmailed($invoice->invitations->first()));
|
||||
}
|
||||
@ -747,8 +746,8 @@ class InvoiceController extends BaseController {
|
||||
* )
|
||||
*
|
||||
*/
|
||||
public function downloadPdf($invitation_key) {
|
||||
|
||||
public function downloadPdf($invitation_key)
|
||||
{
|
||||
$invitation = $this->invoice_repo->getInvitationByKey($invitation_key);
|
||||
$contact = $invitation->contact;
|
||||
$invoice = $invitation->invoice;
|
||||
@ -756,6 +755,5 @@ class InvoiceController extends BaseController {
|
||||
$file_path = $invoice->service()->getInvoicePdf($contact);
|
||||
|
||||
return response()->download($file_path);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use Illuminate\Http\Request;
|
||||
|
||||
class LicenseController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -84,9 +83,7 @@ class LicenseController extends BaseController
|
||||
{
|
||||
|
||||
/* Catch claim license requests */
|
||||
if(config('ninja.environment') == 'selfhost' && $request->has('license_key'))
|
||||
{
|
||||
|
||||
if (config('ninja.environment') == 'selfhost' && $request->has('license_key')) {
|
||||
$license_key = $request->input('license_key');
|
||||
$product_id = 3;
|
||||
|
||||
@ -94,29 +91,23 @@ class LicenseController extends BaseController
|
||||
$data = trim(CurlUtils::get($url));
|
||||
|
||||
if ($data == Account::RESULT_FAILURE) {
|
||||
|
||||
$error = [
|
||||
'message' => trans('texts.invalid_white_label_license'),
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
return response()->json($error, 400);
|
||||
|
||||
} elseif ($data) {
|
||||
|
||||
$date = date_create($data)->modify('+1 year');
|
||||
|
||||
if ($date < date_create()) {
|
||||
|
||||
$error = [
|
||||
'message' => trans('texts.invalid_white_label_license'),
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
return response()->json($error, 400);
|
||||
|
||||
} else {
|
||||
|
||||
$account = auth()->user()->company()->account;
|
||||
|
||||
$account->plan_term = Account::PLAN_TERM_YEARLY;
|
||||
@ -131,19 +122,15 @@ class LicenseController extends BaseController
|
||||
];
|
||||
|
||||
return response()->json($error, 200);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
$error = [
|
||||
'message' => trans('texts.white_label_license_error'),
|
||||
'errors' => []
|
||||
];
|
||||
|
||||
return response()->json($error, 400);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$error = [
|
||||
@ -153,6 +140,4 @@ class LicenseController extends BaseController
|
||||
|
||||
return response()->json($error, 400);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -226,7 +226,9 @@ class MigrationController extends BaseController
|
||||
$migration_file = $request->file('migration')
|
||||
->storeAs('migrations', $request->file('migration')->getClientOriginalName());
|
||||
|
||||
if (app()->environment() == 'testing') return;
|
||||
if (app()->environment() == 'testing') {
|
||||
return;
|
||||
}
|
||||
|
||||
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $company);
|
||||
|
||||
|
@ -381,8 +381,9 @@ class PaymentController extends BaseController
|
||||
*/
|
||||
public function update(UpdatePaymentRequest $request, Payment $payment)
|
||||
{
|
||||
if($request->entityIsDeleted($payment))
|
||||
if ($request->entityIsDeleted($payment)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$payment = $this->payment_repo->save($request->all(), $payment);
|
||||
|
||||
@ -674,12 +675,10 @@ class PaymentController extends BaseController
|
||||
*/
|
||||
public function refund(RefundPaymentRequest $request)
|
||||
{
|
||||
|
||||
$payment = $request->payment();
|
||||
|
||||
$payment = $payment->refund($request->all());
|
||||
|
||||
return $this->itemResponse($payment);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\MakesInvoiceHtml;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class PreviewController extends BaseController
|
||||
{
|
||||
use MakesHash;
|
||||
@ -88,16 +87,14 @@ class PreviewController extends BaseController
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
|
||||
if (request()->has('entity') &&
|
||||
request()->has('entity_id') &&
|
||||
request()->has('body'))
|
||||
{
|
||||
|
||||
request()->has('body')) {
|
||||
$design_object = json_decode(json_encode(request()->input('design')));
|
||||
|
||||
if(!is_object($design_object))
|
||||
if (!is_object($design_object)) {
|
||||
return response()->json(['message' => 'Invalid custom design object'], 400);
|
||||
}
|
||||
|
||||
$entity = ucfirst(request()->input('entity'));
|
||||
|
||||
@ -107,8 +104,9 @@ class PreviewController extends BaseController
|
||||
|
||||
$entity_obj = $class::whereId($this->decodePrimaryKey(request()->input('entity_id')))->company()->first();
|
||||
|
||||
if(!$entity_obj)
|
||||
if (!$entity_obj) {
|
||||
return $this->blankEntity();
|
||||
}
|
||||
|
||||
$entity_obj->load('client');
|
||||
|
||||
@ -119,11 +117,9 @@ class PreviewController extends BaseController
|
||||
$file_path = PreviewPdf::dispatchNow($html, auth()->user()->company());
|
||||
|
||||
return response()->download($file_path)->deleteFileAfterSend(true);
|
||||
|
||||
}
|
||||
|
||||
return $this->blankEntity();
|
||||
|
||||
}
|
||||
|
||||
private function blankEntity()
|
||||
@ -153,8 +149,9 @@ class PreviewController extends BaseController
|
||||
|
||||
$design_object = json_decode(json_encode(request()->input('design')));
|
||||
|
||||
if(!is_object($design_object))
|
||||
if (!is_object($design_object)) {
|
||||
return response()->json(['message' => 'Invalid custom design object'], 400);
|
||||
}
|
||||
|
||||
$designer = new Designer($invoice, $design_object, $invoice->client->getSetting('pdf_variables'), lcfirst(request()->has('entity')));
|
||||
|
||||
@ -167,9 +164,5 @@ class PreviewController extends BaseController
|
||||
$client->forceDelete();
|
||||
|
||||
return response()->file($file_path, array('content-type' => 'application/pdf'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -345,9 +345,9 @@ class ProductController extends BaseController
|
||||
*/
|
||||
public function update(UpdateProductRequest $request, Product $product)
|
||||
{
|
||||
|
||||
if($request->entityIsDeleted($product))
|
||||
if ($request->entityIsDeleted($product)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$product = $this->product_repo->save($request->all(), $product);
|
||||
|
||||
|
@ -378,8 +378,9 @@ class QuoteController extends BaseController
|
||||
*/
|
||||
public function update(UpdateQuoteRequest $request, Quote $quote)
|
||||
{
|
||||
if($request->entityIsDeleted($quote))
|
||||
if ($request->entityIsDeleted($quote)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$quote = $this->quote_repo->save($request->all(), $quote);
|
||||
|
||||
@ -516,31 +517,25 @@ class QuoteController extends BaseController
|
||||
* Download Invoice/s
|
||||
*/
|
||||
|
||||
if($action == 'download' && $quotes->count() > 1)
|
||||
{
|
||||
|
||||
if ($action == 'download' && $quotes->count() > 1) {
|
||||
$quotes->each(function ($quote) {
|
||||
|
||||
if(auth()->user()->cannot('view', $quote)){
|
||||
if (auth()->user()->cannot('view', $quote)) {
|
||||
return response()->json(['message'=>'Insufficient privileges to access quote '. $quote->number]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ZipInvoices::dispatch($quotes, $quotes->first()->company, auth()->user()->email);
|
||||
|
||||
return response()->json(['message' => 'Email Sent!'],200);
|
||||
return response()->json(['message' => 'Email Sent!'], 200);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the other actions to the switch
|
||||
*/
|
||||
$quotes->each(function ($quote, $key) use ($action) {
|
||||
|
||||
if (auth()->user()->can('edit', $quote)) {
|
||||
$this->performAction($quote, $action, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Need to understand which permission are required for the given bulk action ie. view / edit */
|
||||
@ -620,7 +615,8 @@ class QuoteController extends BaseController
|
||||
*
|
||||
*/
|
||||
|
||||
public function action(ActionQuoteRequest $request, Quote $quote, $action) {
|
||||
public function action(ActionQuoteRequest $request, Quote $quote, $action)
|
||||
{
|
||||
return $this->performAction($quote, $action);
|
||||
}
|
||||
|
||||
@ -642,8 +638,9 @@ class QuoteController extends BaseController
|
||||
break;
|
||||
case 'approve':
|
||||
//make sure it hasn't already been approved!!
|
||||
if($quote->status_id != Quote::STATUS_SENT)
|
||||
if ($quote->status_id != Quote::STATUS_SENT) {
|
||||
return response()->json(['message' => 'Unable to approve this quote as it has expired.'], 400);
|
||||
}
|
||||
|
||||
return $this->itemResponse($quote->service()->approve()->save());
|
||||
break;
|
||||
@ -679,6 +676,7 @@ class QuoteController extends BaseController
|
||||
if (!$bulk) {
|
||||
return $this->itemResponse($quote);
|
||||
}
|
||||
// no break
|
||||
default:
|
||||
return response()->json(['message' => "The requested action `{$action}` is not available."], 400);
|
||||
break;
|
||||
@ -687,7 +685,6 @@ class QuoteController extends BaseController
|
||||
|
||||
public function downloadPdf($invitation_key)
|
||||
{
|
||||
|
||||
$invitation = $this->quote_repo->getInvitationByKey($invitation_key);
|
||||
$contact = $invitation->contact;
|
||||
$quote = $invitation->quote;
|
||||
@ -695,7 +692,5 @@ class QuoteController extends BaseController
|
||||
$file_path = $quote->service()->getQuotePdf($contact);
|
||||
|
||||
return response()->download($file_path);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -377,8 +377,9 @@ class RecurringInvoiceController extends BaseController
|
||||
*/
|
||||
public function update(UpdateRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
||||
{
|
||||
if($request->entityIsDeleted($recurring_invoice))
|
||||
if ($request->entityIsDeleted($recurring_invoice)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$recurring_invoice = $this->recurring_invoice_repo->save($request->all(), $recurring_invoice);
|
||||
|
||||
|
@ -375,9 +375,9 @@ class RecurringQuoteController extends BaseController
|
||||
*/
|
||||
public function update(UpdateRecurringQuoteRequest $request, RecurringQuote $recurring_quote)
|
||||
{
|
||||
|
||||
if($request->entityIsDeleted($recurring_quote))
|
||||
if ($request->entityIsDeleted($recurring_quote)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$recurring_quote = $this->recurring_quote_repo->save(request(), $recurring_quote);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Utils\Ninja;
|
||||
use Codedge\Updater\UpdaterManager;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -21,7 +22,6 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,18 +58,13 @@ class SelfUpdateController extends BaseController
|
||||
*/
|
||||
public function update(UpdaterManager $updater)
|
||||
{
|
||||
if(Ninja::isNinja())
|
||||
return response()->json(['message' => 'Self update not available on this system.'], 403);
|
||||
|
||||
$res = $updater->update();
|
||||
|
||||
return response()->json(['message'=>$res], 200);
|
||||
|
||||
}
|
||||
|
||||
public function checkVersion(UpdaterManager $updater)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -17,25 +17,20 @@ use App\Utils\SystemHealth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
|
||||
/**
|
||||
* Class SetupController
|
||||
*/
|
||||
class SetupController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$system_health = SystemHealth::check();
|
||||
|
||||
return view();
|
||||
|
||||
}
|
||||
|
||||
public function doSetup(StoreSetupRequest $request)
|
||||
{
|
||||
|
||||
$_ENV['APP_URL'] = $request->input('url');
|
||||
$_ENV['APP_DEBUG'] = $request->input('debug') ? 'true' : 'false';
|
||||
$_ENV['REQUIRE_HTTPS'] = $request->input('https') ? 'true' : 'false';
|
||||
@ -82,11 +77,10 @@ class SetupController extends Controller
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('db:seed');
|
||||
|
||||
if(Account::count() == 0)
|
||||
if (Account::count() == 0) {
|
||||
$account = CreateAccount::dispatchNow($request->all());
|
||||
|
||||
return view('index.index');
|
||||
|
||||
}
|
||||
|
||||
return view('index.index');
|
||||
}
|
||||
}
|
@ -71,8 +71,9 @@ class SendingController extends Controller
|
||||
|
||||
$send_logs = false;
|
||||
|
||||
if($request->has('send_logs'))
|
||||
if ($request->has('send_logs')) {
|
||||
$send_logs = $request->input('send_logs');
|
||||
}
|
||||
|
||||
Mail::to(config('ninja.contact.ninja_official_contact'))
|
||||
->send(new SupportMessageSent($request->message, $send_logs));
|
||||
|
@ -29,7 +29,6 @@ trait VerifiesUserEmail
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
|
||||
if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->route('confirmation_code'))->first()) {
|
||||
$user->email_verified_at = now();
|
||||
$user->confirmation_code = null;
|
||||
|
@ -501,7 +501,6 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function bulk()
|
||||
{
|
||||
|
||||
$action = request()->input('action');
|
||||
|
||||
$ids = request()->input('ids');
|
||||
@ -517,19 +516,14 @@ class UserController extends BaseController
|
||||
$return_user_collection = collect();
|
||||
|
||||
$users->each(function ($user, $key) use ($action, $return_user_collection) {
|
||||
|
||||
if (auth()->user()->can('edit', $user)) {
|
||||
|
||||
$user = $this->user_repo->{$action}($user);
|
||||
|
||||
$return_user_collection->push($user->id);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $this->listResponse(User::withTrashed()->whereIn('id', $return_user_collection));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -589,13 +583,16 @@ class UserController extends BaseController
|
||||
{
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$user->companies()->attach($company->id,
|
||||
array_merge($request->all(),
|
||||
$user->companies()->attach(
|
||||
$company->id,
|
||||
array_merge(
|
||||
$request->all(),
|
||||
[
|
||||
'account_id' => $company->account->id,
|
||||
'notifications' => CompanySettings::notificationDefaults(),
|
||||
]
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$ct = CreateCompanyToken::dispatchNow($company, $user, 'User token created by'.auth()->user()->present()->name());
|
||||
|
||||
|
@ -267,8 +267,9 @@ class VendorController extends BaseController
|
||||
*/
|
||||
public function update(UpdateVendorRequest $request, Vendor $vendor)
|
||||
{
|
||||
if($request->entityIsDeleted($vendor))
|
||||
if ($request->entityIsDeleted($vendor)) {
|
||||
return $request->disallowUpdate();
|
||||
}
|
||||
|
||||
$vendor = $this->client_repo->save($request->all(), $vendor);
|
||||
|
||||
|
@ -40,7 +40,6 @@ class PasswordProtection
|
||||
return response()->json($error, 403);
|
||||
}
|
||||
} elseif (Cache::get(auth()->user()->email."_logged_in")) {
|
||||
|
||||
Cache::pull(auth()->user()->email."_logged_in");
|
||||
Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(10));
|
||||
|
||||
|
@ -51,7 +51,6 @@ class QueryLogging
|
||||
|
||||
// if($count > 50)
|
||||
// Log::info($queries);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,11 @@ class SetInviteDb
|
||||
**/
|
||||
$entity = null;
|
||||
|
||||
if(!$request->route('entity'))
|
||||
if (!$request->route('entity')) {
|
||||
$entity = $request->segment(2);
|
||||
else
|
||||
} else {
|
||||
$entity = $request->route('entity');
|
||||
}
|
||||
|
||||
if ($request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByInvitation($entity, $request->route('invitation_key'))) {
|
||||
if (request()->json) {
|
||||
|
@ -28,7 +28,6 @@ class TokenAuth
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with(['user','company'])->whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first())) {
|
||||
|
||||
$user = $company_token->user;
|
||||
|
||||
$error = [
|
||||
@ -51,7 +50,7 @@ class TokenAuth
|
||||
|
||||
config(['ninja.company_id' => $company_token->company->id]);
|
||||
|
||||
app('queue')->createPayloadUsing(function () use($company_token) {
|
||||
app('queue')->createPayloadUsing(function () use ($company_token) {
|
||||
return ['db' => $company_token->company->db];
|
||||
});
|
||||
|
||||
|
@ -69,72 +69,56 @@ class StoreClientRequest extends Request
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
//@todo implement feature permissions for > 100 clients
|
||||
//
|
||||
$settings = ClientSettings::defaults();
|
||||
|
||||
if(array_key_exists('settings', $input) && !empty($input['settings']))
|
||||
{
|
||||
|
||||
foreach($input['settings'] as $key => $value)
|
||||
{
|
||||
if (array_key_exists('settings', $input) && !empty($input['settings'])) {
|
||||
foreach ($input['settings'] as $key => $value) {
|
||||
$settings->{$key} = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//is no settings->currency_id is set then lets dive in and find either a group or company currency all the below may be redundant!!
|
||||
if(!property_exists($settings, 'currency_id') && isset($input['group_settings_id']))
|
||||
{
|
||||
|
||||
if (!property_exists($settings, 'currency_id') && isset($input['group_settings_id'])) {
|
||||
$input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']);
|
||||
$group_settings = GroupSetting::find($input['group_settings_id']);
|
||||
|
||||
if($group_settings && property_exists($group_settings->settings, 'currency_id') && isset($group_settings->settings->currency_id))
|
||||
if ($group_settings && property_exists($group_settings->settings, 'currency_id') && isset($group_settings->settings->currency_id)) {
|
||||
$settings->currency_id = (string)$group_settings->settings->currency_id;
|
||||
else
|
||||
} else {
|
||||
$settings->currency_id = (string)auth()->user()->company()->settings->currency_id;
|
||||
|
||||
}
|
||||
elseif(!property_exists($settings, 'currency_id'))
|
||||
{
|
||||
} elseif (!property_exists($settings, 'currency_id')) {
|
||||
$settings->currency_id = (string)auth()->user()->company()->settings->currency_id;
|
||||
}
|
||||
|
||||
|
||||
$input['settings'] = $settings;
|
||||
|
||||
if(isset($input['contacts']))
|
||||
{
|
||||
foreach($input['contacts'] as $key => $contact)
|
||||
{
|
||||
if(array_key_exists('id', $contact) && is_numeric($contact['id']))
|
||||
if (isset($input['contacts'])) {
|
||||
foreach ($input['contacts'] as $key => $contact) {
|
||||
if (array_key_exists('id', $contact) && is_numeric($contact['id'])) {
|
||||
unset($input['contacts'][$key]['id']);
|
||||
elseif(array_key_exists('id', $contact) && is_string($contact['id']))
|
||||
} elseif (array_key_exists('id', $contact) && is_string($contact['id'])) {
|
||||
$input['contacts'][$key]['id'] = $this->decodePrimaryKey($contact['id']);
|
||||
}
|
||||
|
||||
|
||||
//Filter the client contact password - if it is sent with ***** we should ignore it!
|
||||
if(isset($contact['password']))
|
||||
{
|
||||
|
||||
if(strlen($contact['password']) == 0){
|
||||
if (isset($contact['password'])) {
|
||||
if (strlen($contact['password']) == 0) {
|
||||
$input['contacts'][$key]['password'] = '';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$contact['password'] = str_replace("*", "", $contact['password']);
|
||||
|
||||
if(strlen($contact['password']) == 0){
|
||||
if (strlen($contact['password']) == 0) {
|
||||
unset($input['contacts'][$key]['password']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,34 +80,27 @@ class UpdateClientRequest extends Request
|
||||
$input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']);
|
||||
}
|
||||
|
||||
if(isset($input['contacts']))
|
||||
{
|
||||
foreach($input['contacts'] as $key => $contact)
|
||||
{
|
||||
if(array_key_exists('id', $contact) && is_numeric($contact['id']))
|
||||
if (isset($input['contacts'])) {
|
||||
foreach ($input['contacts'] as $key => $contact) {
|
||||
if (array_key_exists('id', $contact) && is_numeric($contact['id'])) {
|
||||
unset($input['contacts'][$key]['id']);
|
||||
elseif(array_key_exists('id', $contact) && is_string($contact['id']))
|
||||
} elseif (array_key_exists('id', $contact) && is_string($contact['id'])) {
|
||||
$input['contacts'][$key]['id'] = $this->decodePrimaryKey($contact['id']);
|
||||
}
|
||||
|
||||
|
||||
//Filter the client contact password - if it is sent with ***** we should ignore it!
|
||||
if(isset($contact['password']))
|
||||
{
|
||||
|
||||
if(strlen($contact['password']) == 0){
|
||||
if (isset($contact['password'])) {
|
||||
if (strlen($contact['password']) == 0) {
|
||||
$input['contacts'][$key]['password'] = '';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$contact['password'] = str_replace("*", "", $contact['password']);
|
||||
|
||||
if(strlen($contact['password']) == 0){
|
||||
if (strlen($contact['password']) == 0) {
|
||||
unset($input['contacts'][$key]['password']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$this->replace($input);
|
||||
|
@ -52,19 +52,14 @@ class StoreCompanyRequest extends Request
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
$company_settings = CompanySettings::defaults();
|
||||
|
||||
if(array_key_exists('settings', $input) && !empty($input['settings']))
|
||||
{
|
||||
|
||||
foreach($input['settings'] as $key => $value)
|
||||
{
|
||||
if (array_key_exists('settings', $input) && !empty($input['settings'])) {
|
||||
foreach ($input['settings'] as $key => $value) {
|
||||
$company_settings->{$key} = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// $company_settings->invoice_design_id = $this->encodePrimaryKey(1);
|
||||
|
@ -52,7 +52,5 @@ class UpdateCompanyRequest extends Request
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,5 +38,4 @@ class UpdateCompanyUserRequest extends Request
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,41 +40,36 @@ class StoreCreditRequest extends FormRequest
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if($input['client_id'])
|
||||
if ($input['client_id']) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['client_contacts']))
|
||||
{
|
||||
foreach($input['client_contacts'] as $key => $contact)
|
||||
{
|
||||
if(!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact))
|
||||
{
|
||||
if (isset($input['client_contacts'])) {
|
||||
foreach ($input['client_contacts'] as $key => $contact) {
|
||||
if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) {
|
||||
unset($input['client_contacts'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($input['invitations']))
|
||||
{
|
||||
|
||||
foreach($input['invitations'] as $key => $value)
|
||||
{
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id']))
|
||||
if (isset($input['invitations'])) {
|
||||
foreach ($input['invitations'] as $key => $value) {
|
||||
if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) {
|
||||
unset($input['invitations'][$key]['id']);
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id']))
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['client_contact_id']))
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
|
||||
}
|
||||
|
||||
if (isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id'])) {
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['client_contact_id'])) {
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
|
@ -42,30 +42,28 @@ class UpdateCreditRequest extends FormRequest
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if (isset($input['client_id'])) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['invitations']))
|
||||
{
|
||||
|
||||
foreach($input['invitations'] as $key => $value)
|
||||
{
|
||||
|
||||
if(is_numeric($input['invitations'][$key]['id']))
|
||||
if (isset($input['invitations'])) {
|
||||
foreach ($input['invitations'] as $key => $value) {
|
||||
if (is_numeric($input['invitations'][$key]['id'])) {
|
||||
unset($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['id']))
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['client_contact_id']))
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['id'])) {
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['client_contact_id'])) {
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
|
@ -40,11 +40,13 @@ class StoreDesignRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!array_key_exists('product', $input['design']) || is_null($input['design']['product']))
|
||||
if (!array_key_exists('product', $input['design']) || is_null($input['design']['product'])) {
|
||||
$input['design']['product'] = '';
|
||||
}
|
||||
|
||||
if(!array_key_exists('task', $input['design']) || is_null($input['design']['task']))
|
||||
if (!array_key_exists('task', $input['design']) || is_null($input['design']['task'])) {
|
||||
$input['design']['task'] = '';
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -39,11 +39,13 @@ class UpdateDesignRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!array_key_exists('product', $input['design']) || is_null($input['design']['product']))
|
||||
if (!array_key_exists('product', $input['design']) || is_null($input['design']['product'])) {
|
||||
$input['design']['product'] = '';
|
||||
}
|
||||
|
||||
if(!array_key_exists('task', $input['design']) || is_null($input['design']['task']))
|
||||
if (!array_key_exists('task', $input['design']) || is_null($input['design']['task'])) {
|
||||
$input['design']['task'] = '';
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -44,14 +44,10 @@ class StoreGroupSettingRequest extends Request
|
||||
|
||||
$group_settings = ClientSettings::defaults();
|
||||
|
||||
if(array_key_exists('settings', $input) && !empty($input['settings']))
|
||||
{
|
||||
|
||||
foreach($input['settings'] as $key => $value)
|
||||
{
|
||||
if (array_key_exists('settings', $input) && !empty($input['settings'])) {
|
||||
foreach ($input['settings'] as $key => $value) {
|
||||
$group_settings->{$key} = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$input['settings'] = $group_settings;
|
||||
|
@ -26,5 +26,4 @@ class EditInvoiceRequest extends Request
|
||||
{
|
||||
return auth()->user()->can('edit', $this->invoice);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,41 +46,36 @@ class StoreInvoiceRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if(array_key_exists('client_id', $input) && is_string($input['client_id']))
|
||||
if (array_key_exists('client_id', $input) && is_string($input['client_id'])) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['client_contacts']))
|
||||
{
|
||||
foreach($input['client_contacts'] as $key => $contact)
|
||||
{
|
||||
if(!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact))
|
||||
{
|
||||
if (isset($input['client_contacts'])) {
|
||||
foreach ($input['client_contacts'] as $key => $contact) {
|
||||
if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) {
|
||||
unset($input['client_contacts'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($input['invitations']))
|
||||
{
|
||||
|
||||
foreach($input['invitations'] as $key => $value)
|
||||
{
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id']))
|
||||
if (isset($input['invitations'])) {
|
||||
foreach ($input['invitations'] as $key => $value) {
|
||||
if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) {
|
||||
unset($input['invitations'][$key]['id']);
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id']))
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['client_contact_id']))
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
|
||||
}
|
||||
|
||||
if (isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id'])) {
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['client_contact_id'])) {
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
|
@ -49,30 +49,28 @@ class UpdateInvoiceRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if (isset($input['client_id'])) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['invitations']))
|
||||
{
|
||||
|
||||
foreach($input['invitations'] as $key => $value)
|
||||
{
|
||||
|
||||
if(is_numeric($input['invitations'][$key]['id']))
|
||||
if (isset($input['invitations'])) {
|
||||
foreach ($input['invitations'] as $key => $value) {
|
||||
if (is_numeric($input['invitations'][$key]['id'])) {
|
||||
unset($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['id']))
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['client_contact_id']))
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['id'])) {
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['client_contact_id'])) {
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
|
@ -28,7 +28,7 @@ class UploadMigrationFileRequest extends FormRequest
|
||||
];
|
||||
|
||||
/** We'll skip mime validation while running tests. */
|
||||
if(app()->environment() !== 'testing') {
|
||||
if (app()->environment() !== 'testing') {
|
||||
$rules['migration'] = ['required', 'file', 'mimes:zip'];
|
||||
}
|
||||
|
||||
|
@ -33,32 +33,30 @@ class RefundPaymentRequest extends Request
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
if(!isset($input['gateway_refund']))
|
||||
if (!isset($input['gateway_refund'])) {
|
||||
$input['gateway_refund'] = false;
|
||||
|
||||
if(!isset($input['send_email']))
|
||||
$input['send_email'] = false;
|
||||
|
||||
if(isset($input['id']))
|
||||
$input['id'] = $this->decodePrimaryKey($input['id']);
|
||||
|
||||
if(isset($input['invoices']))
|
||||
{
|
||||
|
||||
foreach($input['invoices'] as $key => $invoice)
|
||||
$input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($invoice['invoice_id']);
|
||||
|
||||
}
|
||||
|
||||
if(isset($input['credits']))
|
||||
{
|
||||
if (!isset($input['send_email'])) {
|
||||
$input['send_email'] = false;
|
||||
}
|
||||
|
||||
if (isset($input['id'])) {
|
||||
$input['id'] = $this->decodePrimaryKey($input['id']);
|
||||
}
|
||||
|
||||
if (isset($input['invoices'])) {
|
||||
foreach ($input['invoices'] as $key => $invoice) {
|
||||
$input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($invoice['invoice_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($input['credits'])) {
|
||||
unset($input['credits']);
|
||||
// foreach($input['credits'] as $key => $credit)
|
||||
// $input['credits'][$key]['credit_id'] = $this->decodePrimaryKey($credit['credit_id']);
|
||||
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -46,7 +46,6 @@ class StorePaymentRequest extends Request
|
||||
}
|
||||
|
||||
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
||||
|
||||
foreach ($input['invoices'] as $key => $value) {
|
||||
$input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']);
|
||||
$invoices_total += $value['amount'];
|
||||
@ -61,9 +60,7 @@ class StorePaymentRequest extends Request
|
||||
|
||||
if (isset($input['credits']) && is_array($input['credits']) !== false) {
|
||||
foreach ($input['credits'] as $key => $value) {
|
||||
|
||||
if(array_key_exists('credit_id', $input['credits'][$key]))
|
||||
{
|
||||
if (array_key_exists('credit_id', $input['credits'][$key])) {
|
||||
$input['credits'][$key]['credit_id'] = $this->decodePrimaryKey($value['credit_id']);
|
||||
$credits_total += $value['amount'];
|
||||
}
|
||||
@ -74,7 +71,7 @@ class StorePaymentRequest extends Request
|
||||
$input['credits'] = null;
|
||||
}
|
||||
|
||||
if(!isset($input['amount']) || $input['amount'] == 0){
|
||||
if (!isset($input['amount']) || $input['amount'] == 0) {
|
||||
$input['amount'] = $invoices_total - $credits_total;
|
||||
}
|
||||
|
||||
|
@ -46,23 +46,29 @@ class UpdatePaymentRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(isset($input['client_id']))
|
||||
if (isset($input['client_id'])) {
|
||||
unset($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['amount']))
|
||||
if (isset($input['amount'])) {
|
||||
unset($input['amount']);
|
||||
}
|
||||
|
||||
if(isset($input['type_id']))
|
||||
if (isset($input['type_id'])) {
|
||||
unset($input['type_id']);
|
||||
}
|
||||
|
||||
if(isset($input['date']))
|
||||
if (isset($input['date'])) {
|
||||
unset($input['date']);
|
||||
}
|
||||
|
||||
if(isset($input['transaction_reference']))
|
||||
if (isset($input['transaction_reference'])) {
|
||||
unset($input['transaction_reference']);
|
||||
}
|
||||
|
||||
if(isset($input['number']))
|
||||
if (isset($input['number'])) {
|
||||
unset($input['number']);
|
||||
}
|
||||
|
||||
if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
|
||||
foreach ($input['invoices'] as $key => $value) {
|
||||
|
@ -26,6 +26,4 @@ class EditQuoteRequest extends Request
|
||||
{
|
||||
return auth()->user()->can('edit', $this->quote);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -32,45 +32,40 @@ class StoreQuoteRequest extends Request
|
||||
return auth()->user()->can('create', Quote::class);
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if($input['client_id'])
|
||||
if ($input['client_id']) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
if(isset($input['client_contacts']))
|
||||
{
|
||||
foreach($input['client_contacts'] as $key => $contact)
|
||||
{
|
||||
if(!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact))
|
||||
{
|
||||
if (isset($input['client_contacts'])) {
|
||||
foreach ($input['client_contacts'] as $key => $contact) {
|
||||
if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) {
|
||||
unset($input['client_contacts'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($input['invitations']))
|
||||
{
|
||||
|
||||
foreach($input['invitations'] as $key => $value)
|
||||
{
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id']))
|
||||
if (isset($input['invitations'])) {
|
||||
foreach ($input['invitations'] as $key => $value) {
|
||||
if (isset($input['invitations'][$key]['id']) && is_numeric($input['invitations'][$key]['id'])) {
|
||||
unset($input['invitations'][$key]['id']);
|
||||
|
||||
if(isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id']))
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
|
||||
if(is_string($input['invitations'][$key]['client_contact_id']))
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
|
||||
}
|
||||
|
||||
if (isset($input['invitations'][$key]['id']) && is_string($input['invitations'][$key]['id'])) {
|
||||
$input['invitations'][$key]['id'] = $this->decodePrimaryKey($input['invitations'][$key]['id']);
|
||||
}
|
||||
|
||||
if (is_string($input['invitations'][$key]['client_contact_id'])) {
|
||||
$input['invitations'][$key]['client_contact_id'] = $this->decodePrimaryKey($input['invitations'][$key]['client_contact_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
@ -86,4 +81,3 @@ protected function prepareForValidation()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,9 @@ class UpdateQuoteRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(array_key_exists('design_id', $input) && is_string($input['design_id']))
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
||||
if (isset($input['client_id'])) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
|
@ -45,8 +45,9 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if($input['client_id'])
|
||||
if ($input['client_id']) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
//$input['line_items'] = json_encode($input['line_items']);
|
||||
|
@ -49,6 +49,4 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||
//$input['line_items'] = json_encode($input['line_items']);
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,12 +45,12 @@ class StoreRecurringQuoteRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if($input['client_id'])
|
||||
if ($input['client_id']) {
|
||||
$input['client_id'] = $this->decodePrimaryKey($input['client_id']);
|
||||
}
|
||||
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
//$input['line_items'] = json_encode($input['line_items']);
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,5 +48,4 @@ class UpdateRecurringQuoteRequest extends Request
|
||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,8 +44,9 @@ class UpdateUserRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if (isset($input['company_user']) && !auth()->user()->isAdmin())
|
||||
if (isset($input['company_user']) && !auth()->user()->isAdmin()) {
|
||||
unset($input['company_user']);
|
||||
}
|
||||
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -27,9 +27,7 @@ class ValidCompanyQuantity implements Rule
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
return auth()->user()->company()->account->companies->count() <= 10;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,6 +37,4 @@ class ValidCompanyQuantity implements Rule
|
||||
{
|
||||
return "Limit of 10 companies per account.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -44,47 +44,41 @@ class ValidInvoicesRules implements Rule
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
return $this->checkInvoicesAreHomogenous();
|
||||
|
||||
}
|
||||
|
||||
private function checkInvoicesAreHomogenous()
|
||||
{
|
||||
|
||||
if(!array_key_exists('client_id', $this->input)){
|
||||
if (!array_key_exists('client_id', $this->input)) {
|
||||
$this->error_msg = "Client id is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
$unique_array = [];
|
||||
|
||||
foreach($this->input['invoices'] as $invoice)
|
||||
{
|
||||
foreach ($this->input['invoices'] as $invoice) {
|
||||
$unique_array[] = $invoice['invoice_id'];
|
||||
|
||||
$inv = Invoice::whereId($invoice['invoice_id'])->first();
|
||||
|
||||
if(!$inv){
|
||||
if (!$inv) {
|
||||
$this->error_msg = "Invoice not found ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($inv->client_id != $this->input['client_id']){
|
||||
if ($inv->client_id != $this->input['client_id']) {
|
||||
$this->error_msg = "Selected invoices are not from a single client";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!(array_unique($unique_array) == $unique_array))
|
||||
{
|
||||
if (!(array_unique($unique_array) == $unique_array)) {
|
||||
$this->error_msg = "Duplicate invoices submitted.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -95,6 +89,4 @@ class ValidInvoicesRules implements Rule
|
||||
{
|
||||
return $this->error_msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -44,11 +44,9 @@ class ValidRefundableRequest implements Rule
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
$payment = Payment::whereId($this->input['id'])->first();
|
||||
|
||||
if(!$payment)
|
||||
{
|
||||
if (!$payment) {
|
||||
$this->error_msg = "Unable to retrieve specified payment";
|
||||
return false;
|
||||
}
|
||||
@ -63,11 +61,11 @@ class ValidRefundableRequest implements Rule
|
||||
// $request_credits[$key]['credit_id'] = $this->decodePrimaryKey($value['credit_id']);
|
||||
|
||||
|
||||
if($payment->invoices()->exists())
|
||||
{
|
||||
foreach($payment->invoices as $paymentable_invoice)
|
||||
if ($payment->invoices()->exists()) {
|
||||
foreach ($payment->invoices as $paymentable_invoice) {
|
||||
$this->checkInvoice($paymentable_invoice, $request_invoices);
|
||||
}
|
||||
}
|
||||
|
||||
// if($payment->credits()->exists())
|
||||
// {
|
||||
@ -75,36 +73,32 @@ class ValidRefundableRequest implements Rule
|
||||
// $this->checkCredit($paymentable_credit, $request_credits);
|
||||
// }
|
||||
|
||||
foreach($request_invoices as $request_invoice)
|
||||
foreach ($request_invoices as $request_invoice) {
|
||||
$this->checkInvoiceIsPaymentable($request_invoice, $payment);
|
||||
}
|
||||
|
||||
// foreach($request_credits as $request_credit)
|
||||
// $this->checkCreditIsPaymentable($request_credit, $payment);
|
||||
|
||||
if(strlen($this->error_msg) > 0 )
|
||||
if (strlen($this->error_msg) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkInvoiceIsPaymentable($invoice, $payment)
|
||||
{
|
||||
|
||||
$invoice = Invoice::whereId($invoice['invoice_id'])->whereCompanyId($payment->company_id)->first();
|
||||
|
||||
if($payment->invoices()->exists())
|
||||
{
|
||||
|
||||
if ($payment->invoices()->exists()) {
|
||||
$paymentable_invoice = $payment->invoices->where('id', $invoice->id)->first();
|
||||
|
||||
if(!$paymentable_invoice){
|
||||
if (!$paymentable_invoice) {
|
||||
$this->error_msg = "Invoice id ".$invoice->hashed_id." is not related to this payment";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error_msg = "Invoice id ".$invoice->hashed_id." is not related to this payment";
|
||||
return false;
|
||||
}
|
||||
@ -114,19 +108,14 @@ class ValidRefundableRequest implements Rule
|
||||
{
|
||||
$credit = Credit::whereId($credit['credit_id'])->whereCompanyId($payment->company_id)->first();
|
||||
|
||||
if($payment->credits()->exists())
|
||||
{
|
||||
|
||||
if ($payment->credits()->exists()) {
|
||||
$paymentable_credit = $payment->credits->where('id', $credit->id)->first();
|
||||
|
||||
if(!$paymentable_invoice){
|
||||
if (!$paymentable_invoice) {
|
||||
$this->error_msg = "Credit id ".$credit->hashed_id." is not related to this payment";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->error_msg = "Credit id ".$credit->hashed_id." is not related to this payment";
|
||||
return false;
|
||||
}
|
||||
@ -136,33 +125,25 @@ class ValidRefundableRequest implements Rule
|
||||
{
|
||||
$record_found = false;
|
||||
|
||||
foreach($request_invoices as $request_invoice)
|
||||
{
|
||||
if($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id)
|
||||
{
|
||||
foreach ($request_invoices as $request_invoice) {
|
||||
if ($request_invoice['invoice_id'] == $paymentable->pivot->paymentable_id) {
|
||||
$record_found = true;
|
||||
|
||||
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
|
||||
|
||||
if($request_invoice['amount'] > $refundable_amount){
|
||||
|
||||
if ($request_invoice['amount'] > $refundable_amount) {
|
||||
$invoice = $paymentable;
|
||||
|
||||
$this->error_msg = "Attempting to refund more than allowed for invoice id ".$invoice->hashed_id.", maximum refundable amount is ". $refundable_amount;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$record_found)
|
||||
{
|
||||
if (!$record_found) {
|
||||
$this->error_msg = "Attempting to refund a payment with invoices attached, please specify valid invoice/s to be refunded.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -170,33 +151,25 @@ class ValidRefundableRequest implements Rule
|
||||
{
|
||||
$record_found = null;
|
||||
|
||||
foreach($request_credits as $request_credit)
|
||||
{
|
||||
if($request_credit['credit_id'] == $paymentable->pivot->paymentable_id)
|
||||
{
|
||||
|
||||
foreach ($request_credits as $request_credit) {
|
||||
if ($request_credit['credit_id'] == $paymentable->pivot->paymentable_id) {
|
||||
$record_found = true;
|
||||
|
||||
$refundable_amount = ($paymentable->pivot->amount - $paymentable->pivot->refunded);
|
||||
|
||||
if($request_credit['amount'] > $refundable_amount){
|
||||
|
||||
if ($request_credit['amount'] > $refundable_amount) {
|
||||
$credit = $paymentable;
|
||||
|
||||
$this->error_msg = "Attempting to refund more than allowed for credit ".$credit->number.", maximum refundable amount is ". $refundable_amount;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$record_found)
|
||||
{
|
||||
if (!$record_found) {
|
||||
$this->error_msg = "Attempting to refund a payment with credits attached, please specify valid credit/s to be refunded.";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,5 +179,4 @@ class ValidRefundableRequest implements Rule
|
||||
{
|
||||
return $this->error_msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,36 +48,33 @@ class PaymentAmountsBalanceRule implements Rule
|
||||
* have been presented!
|
||||
*/
|
||||
|
||||
if(!request()->has('amount'))
|
||||
if (!request()->has('amount')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(request()->has('amount') && request()->input('amount') == 0)
|
||||
if (request()->has('amount') && request()->input('amount') == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$payment_amounts = 0;
|
||||
$invoice_amounts = 0;
|
||||
|
||||
$payment_amounts += request()->input('amount');
|
||||
|
||||
if(request()->input('credits') && is_array(request()->input('credits')))
|
||||
{
|
||||
foreach(request()->input('credits') as $credit)
|
||||
{
|
||||
if (request()->input('credits') && is_array(request()->input('credits'))) {
|
||||
foreach (request()->input('credits') as $credit) {
|
||||
$payment_amounts += $credit['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
if(request()->input('invoices') && is_array(request()->input('invoices')))
|
||||
{
|
||||
foreach(request()->input('invoices') as $invoice)
|
||||
{
|
||||
if (request()->input('invoices') && is_array(request()->input('invoices'))) {
|
||||
foreach (request()->input('invoices') as $invoice) {
|
||||
$invoice_amounts += $invoice['amount'];
|
||||
}
|
||||
}
|
||||
else
|
||||
return true; // if no invoices are present, then this is an unapplied payment, let this pass validation!
|
||||
} else {
|
||||
return true;
|
||||
} // if no invoices are present, then this is an unapplied payment, let this pass validation!
|
||||
|
||||
return $payment_amounts >= $invoice_amounts;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -45,34 +45,29 @@ class PaymentAppliedValidAmount implements Rule
|
||||
|
||||
private function calculateAmounts() :bool
|
||||
{
|
||||
|
||||
$payment = Payment::whereId($this->decodePrimaryKey(request()->segment(4)))->company()->first();
|
||||
|
||||
if(!$payment)
|
||||
if (!$payment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$payment_amounts = 0;
|
||||
$invoice_amounts = 0;
|
||||
|
||||
$payment_amounts = $payment->amount - $payment->applied;
|
||||
|
||||
if(request()->input('credits') && is_array(request()->input('credits')))
|
||||
{
|
||||
foreach(request()->input('credits') as $credit)
|
||||
{
|
||||
if (request()->input('credits') && is_array(request()->input('credits'))) {
|
||||
foreach (request()->input('credits') as $credit) {
|
||||
$payment_amounts += $credit['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
if(request()->input('invoices') && is_array(request()->input('invoices')))
|
||||
{
|
||||
foreach(request()->input('invoices') as $invoice)
|
||||
{
|
||||
if (request()->input('invoices') && is_array(request()->input('invoices'))) {
|
||||
foreach (request()->input('invoices') as $invoice) {
|
||||
$invoice_amounts += $invoice['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
return $payment_amounts >= $invoice_amounts;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -47,20 +47,18 @@ class ValidCreditsPresentRule implements Rule
|
||||
|
||||
private function validCreditsPresent() :bool
|
||||
{
|
||||
//todo need to ensure the clients credits are here not random ones!
|
||||
//todo need to ensure the clients credits are here not random ones!
|
||||
|
||||
if(request()->input('credits') && is_array(request()->input('credits')))
|
||||
{
|
||||
foreach(request()->input('credits') as $credit)
|
||||
{
|
||||
if (request()->input('credits') && is_array(request()->input('credits'))) {
|
||||
foreach (request()->input('credits') as $credit) {
|
||||
$cred = Credit::find($this->decodePrimaryKey($credit['credit_id']));
|
||||
|
||||
if($cred->balance == 0)
|
||||
if ($cred->balance == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -43,15 +43,14 @@ class ValidRefundableInvoices implements Rule
|
||||
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
|
||||
$payment = Payment::whereId($this->input['id'])->first();
|
||||
|
||||
if(!$payment){
|
||||
if (!$payment) {
|
||||
$this->error_msg = "Payment couldn't be retrieved cannot be refunded ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(request()->has('amount') && (request()->input('amount') > ($payment->amount - $payment->refunded))){
|
||||
if (request()->has('amount') && (request()->input('amount') > ($payment->amount - $payment->refunded))) {
|
||||
$this->error_msg = "Attempting to refunded more than payment amount, enter a value equal to or lower than the payment amount of ". $payment->amount;
|
||||
return false;
|
||||
}
|
||||
@ -61,9 +60,9 @@ class ValidRefundableInvoices implements Rule
|
||||
|
||||
if (is_array($value)) {
|
||||
$invoices = Invoice::whereIn('id', array_column($this->input['invoices'], 'invoice_id'))->company()->get();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
if (! $invoice->isRefundable()) {
|
||||
@ -78,13 +77,12 @@ class ValidRefundableInvoices implements Rule
|
||||
//$pivot_record = $invoice->payments->where('id', $invoice->id)->first();
|
||||
$pivot_record = $payment->paymentables->where('paymentable_id', $invoice->id)->first();
|
||||
|
||||
if($val['amount'] > ($pivot_record->amount - $pivot_record->refunded)) {
|
||||
if ($val['amount'] > ($pivot_record->amount - $pivot_record->refunded)) {
|
||||
$this->error_msg = "Attempting to refund ". $val['amount'] ." only ".($pivot_record->amount - $pivot_record->refunded)." available for refund";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,2 +1,54 @@
|
||||
<?php
|
||||
namespace App\Jobs\Account; use App\Events\Account\AccountCreated; use App\Jobs\Company\CreateCompany; use App\Jobs\Company\CreateCompanyToken; use App\Jobs\User\CreateUser; use App\Models\Account; use App\Models\User; use App\Notifications\Ninja\NewAccountCreated; use App\Utils\Ninja; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; use Symfony\Component\HttpFoundation\Response; class CreateAccount { use Dispatchable; protected $request; public function __construct(array $sp660339) { $this->request = $sp660339; } public function handle() { if (config('ninja.environment') == 'selfhost' && Account::all()->count() > 1) { return response()->json(array('message' => Ninja::selfHostedMessage()), 400); } elseif (Ninja::boot()) { return response()->json(array('message' => Ninja::parse()), 401); } $sp794f3f = Account::create($this->request); $sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f); $sp035a66->load('account'); $sp794f3f->default_company_id = $sp035a66->id; $sp794f3f->save(); $spaa9f78 = CreateUser::dispatchNow($this->request, $sp794f3f, $sp035a66, true); if ($spaa9f78) { auth()->login($spaa9f78, false); } $spaa9f78->setCompany($sp035a66); $spafe62e = isset($this->request['token_name']) ? $this->request['token_name'] : request()->server('HTTP_USER_AGENT'); $sp2d97e8 = CreateCompanyToken::dispatchNow($sp035a66, $spaa9f78, $spafe62e); if ($spaa9f78) { event(new AccountCreated($spaa9f78)); } $spaa9f78->fresh(); $sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja(); return $sp794f3f; } }
|
||||
namespace App\Jobs\Account;
|
||||
|
||||
use App\Events\Account\AccountCreated;
|
||||
use App\Jobs\Company\CreateCompany;
|
||||
use App\Jobs\Company\CreateCompanyToken;
|
||||
use App\Jobs\User\CreateUser;
|
||||
use App\Models\Account;
|
||||
use App\Models\User;
|
||||
use App\Notifications\Ninja\NewAccountCreated;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\UserSessionAttributes;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CreateAccount
|
||||
{
|
||||
use Dispatchable;
|
||||
protected $request;
|
||||
public function __construct(array $sp660339)
|
||||
{
|
||||
$this->request = $sp660339;
|
||||
}
|
||||
public function handle()
|
||||
{
|
||||
if (config('ninja.environment') == 'selfhost' && Account::all()->count() > 1) {
|
||||
return response()->json(array('message' => Ninja::selfHostedMessage()), 400);
|
||||
} elseif (Ninja::boot()) {
|
||||
return response()->json(array('message' => Ninja::parse()), 401);
|
||||
}
|
||||
$sp794f3f = Account::create($this->request);
|
||||
$sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f);
|
||||
$sp035a66->load('account');
|
||||
$sp794f3f->default_company_id = $sp035a66->id;
|
||||
$sp794f3f->save();
|
||||
$spaa9f78 = CreateUser::dispatchNow($this->request, $sp794f3f, $sp035a66, true);
|
||||
if ($spaa9f78) {
|
||||
auth()->login($spaa9f78, false);
|
||||
}
|
||||
$spaa9f78->setCompany($sp035a66);
|
||||
$spafe62e = isset($this->request['token_name']) ? $this->request['token_name'] : request()->server('HTTP_USER_AGENT');
|
||||
$sp2d97e8 = CreateCompanyToken::dispatchNow($sp035a66, $spaa9f78, $spafe62e);
|
||||
if ($spaa9f78) {
|
||||
event(new AccountCreated($spaa9f78));
|
||||
}
|
||||
$spaa9f78->fresh();
|
||||
$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
|
||||
return $sp794f3f;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class ApplyCreditPayment implements ShouldQueue
|
||||
if ($this->amount == $credit_balance) { //total credit applied.
|
||||
$this->credit->setStatus(Credit::STATUS_APPLIED);
|
||||
$this->credit->updateBalance($this->amount*-1);
|
||||
} elseif($this->amount < $credit_balance) { //compare number appropriately
|
||||
} elseif ($this->amount < $credit_balance) { //compare number appropriately
|
||||
$this->credit->setStatus(Credit::PARTIAL);
|
||||
$this->credit->updateBalance($this->amount*-1);
|
||||
}
|
||||
@ -78,6 +78,4 @@ class ApplyCreditPayment implements ShouldQueue
|
||||
/* Update Payment Applied Amount*/
|
||||
$this->payment->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
|
||||
class CreateCreditPdf implements ShouldQueue {
|
||||
|
||||
class CreateCreditPdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash;
|
||||
|
||||
public $credit;
|
||||
@ -51,7 +51,6 @@ class CreateCreditPdf implements ShouldQueue {
|
||||
*/
|
||||
public function __construct($credit, Company $company, ClientContact $contact = null)
|
||||
{
|
||||
|
||||
$this->credit = $credit;
|
||||
|
||||
$this->company = $company;
|
||||
@ -59,17 +58,17 @@ class CreateCreditPdf implements ShouldQueue {
|
||||
$this->contact = $contact;
|
||||
|
||||
$this->disk = $disk ?? config('filesystems.default');
|
||||
|
||||
}
|
||||
|
||||
public function handle() {
|
||||
|
||||
public function handle()
|
||||
{
|
||||
MultiDB::setDB($this->company->db);
|
||||
|
||||
$this->credit->load('client');
|
||||
|
||||
if(!$this->contact)
|
||||
if (!$this->contact) {
|
||||
$this->contact = $this->credit->client->primary_contact()->first();
|
||||
}
|
||||
|
||||
App::setLocale($this->contact->preferredLocale());
|
||||
|
||||
@ -82,7 +81,7 @@ class CreateCreditPdf implements ShouldQueue {
|
||||
$designer = new Designer($this->credit, $design, $this->credit->client->getSetting('pdf_variables'), 'credit');
|
||||
|
||||
//get invoice design
|
||||
// $html = $this->generateInvoiceHtml($designer->build()->getHtml(), $this->credit, $this->contact);
|
||||
// $html = $this->generateInvoiceHtml($designer->build()->getHtml(), $this->credit, $this->contact);
|
||||
$html = $this->generateEntityHtml($designer, $this->credit, $this->contact);
|
||||
|
||||
//todo - move this to the client creation stage so we don't keep hitting this unnecessarily
|
||||
@ -97,5 +96,4 @@ class CreateCreditPdf implements ShouldQueue {
|
||||
//
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
|
||||
class CreateInvoicePdf implements ShouldQueue {
|
||||
|
||||
class CreateInvoicePdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash;
|
||||
|
||||
public $invoice;
|
||||
@ -51,7 +51,6 @@ class CreateInvoicePdf implements ShouldQueue {
|
||||
*/
|
||||
public function __construct($invoice, Company $company, ClientContact $contact = null)
|
||||
{
|
||||
|
||||
$this->invoice = $invoice;
|
||||
|
||||
$this->company = $company;
|
||||
@ -59,15 +58,15 @@ class CreateInvoicePdf implements ShouldQueue {
|
||||
$this->contact = $contact;
|
||||
|
||||
$this->disk = $disk ?? config('filesystems.default');
|
||||
|
||||
}
|
||||
|
||||
public function handle() {
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->invoice->load('client');
|
||||
|
||||
if(!$this->contact)
|
||||
if (!$this->contact) {
|
||||
$this->contact = $this->invoice->client->primary_contact()->first();
|
||||
}
|
||||
|
||||
App::setLocale($this->contact->preferredLocale());
|
||||
|
||||
@ -93,8 +92,5 @@ class CreateInvoicePdf implements ShouldQueue {
|
||||
$instance = Storage::disk($this->disk)->put($file_path, $pdf);
|
||||
|
||||
return $file_path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -54,9 +54,10 @@ class EmailInvoice implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
Mail::to($this->invoice_invitation->contact->email, $this->invoice_invitation->contact->present()->name())
|
||||
->send(new TemplateEmail($this->email_builder,
|
||||
->send(
|
||||
new TemplateEmail(
|
||||
$this->email_builder,
|
||||
$this->invoice_invitation->contact->user,
|
||||
$this->invoice_invitation->contact->client
|
||||
)
|
||||
@ -65,7 +66,6 @@ class EmailInvoice implements ShouldQueue
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function logMailError($errors)
|
||||
|
@ -19,7 +19,8 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceNotification implements ShouldQueue {
|
||||
class InvoiceNotification implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
@ -29,7 +30,8 @@ class InvoiceNotification implements ShouldQueue {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Invoice $invoice) {
|
||||
public function __construct(Invoice $invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
@ -39,7 +41,8 @@ class InvoiceNotification implements ShouldQueue {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle() {
|
||||
public function handle()
|
||||
{
|
||||
|
||||
//notification for the invoice.
|
||||
//
|
||||
|
@ -59,7 +59,6 @@ class ZipInvoices implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$tempStream = fopen('php://memory', 'w+');
|
||||
|
||||
$options = new Archive();
|
||||
|
@ -52,7 +52,6 @@ class EmailPayment implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if ($this->contact->email) {
|
||||
Mail::to($this->contact->email, $this->contact->present()->name())
|
||||
->send(new TemplateEmail($this->email_builder, $this->contact->user, $this->contact->customer));
|
||||
@ -68,7 +67,6 @@ class EmailPayment implements ShouldQueue
|
||||
|
||||
//sleep(5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function logMailError($errors)
|
||||
|
@ -32,8 +32,8 @@ use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
|
||||
class CreateQuotePdf implements ShouldQueue {
|
||||
|
||||
class CreateQuotePdf implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash;
|
||||
|
||||
public $quote;
|
||||
@ -51,7 +51,6 @@ class CreateQuotePdf implements ShouldQueue {
|
||||
*/
|
||||
public function __construct($quote, Company $company, ClientContact $contact = null)
|
||||
{
|
||||
|
||||
$this->quote = $quote;
|
||||
|
||||
$this->company = $company;
|
||||
@ -59,19 +58,19 @@ class CreateQuotePdf implements ShouldQueue {
|
||||
$this->contact = $contact;
|
||||
|
||||
$this->disk = $disk ?? config('filesystems.default');
|
||||
|
||||
}
|
||||
|
||||
public function handle() {
|
||||
|
||||
public function handle()
|
||||
{
|
||||
MultiDB::setDB($this->company->db);
|
||||
|
||||
$settings = $this->quote->client->getMergedSettings();
|
||||
|
||||
$this->quote->load('client');
|
||||
|
||||
if(!$this->contact)
|
||||
if (!$this->contact) {
|
||||
$this->contact = $this->quote->client->primary_contact()->first();
|
||||
}
|
||||
|
||||
App::setLocale($this->contact->preferredLocale());
|
||||
|
||||
@ -115,7 +114,7 @@ class CreateQuotePdf implements ShouldQueue {
|
||||
|
||||
|
||||
//get invoice design
|
||||
// $html = $this->generateInvoiceHtml($design_body, $this->quote, $this->contact);
|
||||
// $html = $this->generateInvoiceHtml($design_body, $this->quote, $this->contact);
|
||||
$html = $this->generateEntityHtml($designer, $this->quote, $this->contact);
|
||||
|
||||
$pdf = $this->makePdf($all_pages_header, $all_pages_footer, $html);
|
||||
@ -127,5 +126,4 @@ class CreateQuotePdf implements ShouldQueue {
|
||||
//
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
}
|
||||
|
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