mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-02 22:57:33 -05:00 
			
		
		
		
	Design.php:
- Add `aging` property - Add `statement-invoice-table-totals`, `statement-payment-table-totals` - Update `entityDetails` for statements
This commit is contained in:
		
							parent
							
								
									bcd29b93e1
								
							
						
					
					
						commit
						cc95f89a9c
					
				@ -53,6 +53,9 @@ class Design extends BaseDesign
 | 
				
			|||||||
    /** @var Payment[] */
 | 
					    /** @var Payment[] */
 | 
				
			||||||
    public $payments;
 | 
					    public $payments;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** @var array */
 | 
				
			||||||
 | 
					    public $aging = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const BOLD = 'bold';
 | 
					    const BOLD = 'bold';
 | 
				
			||||||
    const BUSINESS = 'business';
 | 
					    const BUSINESS = 'business';
 | 
				
			||||||
    const CLEAN = 'clean';
 | 
					    const CLEAN = 'clean';
 | 
				
			||||||
@ -82,9 +85,7 @@ class Design extends BaseDesign
 | 
				
			|||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $path = isset($this->options['custom_path'])
 | 
					        $path = $this->options['custom_path'] ?? config('ninja.designs.base_path');
 | 
				
			||||||
            ? $this->options['custom_path']
 | 
					 | 
				
			||||||
            : config('ninja.designs.base_path');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return file_get_contents(
 | 
					        return file_get_contents(
 | 
				
			||||||
            $path . $this->design
 | 
					            $path . $this->design
 | 
				
			||||||
@ -132,10 +133,22 @@ class Design extends BaseDesign
 | 
				
			|||||||
                'id' => 'statement-invoice-table',
 | 
					                'id' => 'statement-invoice-table',
 | 
				
			||||||
                'elements' => $this->statementInvoiceTable(),
 | 
					                'elements' => $this->statementInvoiceTable(),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
 | 
					            'statement-invoice-table-totals' => [
 | 
				
			||||||
 | 
					                'id' => 'statement-invoice-table-totals',
 | 
				
			||||||
 | 
					                'elements' => [
 | 
				
			||||||
 | 
					                    ['element' => 'p', 'content' => '$outstanding_label: $outstanding'],
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
            'statement-payment-table' => [
 | 
					            'statement-payment-table' => [
 | 
				
			||||||
                'id' => 'statement-payment-table',
 | 
					                'id' => 'statement-payment-table',
 | 
				
			||||||
                'elements' => $this->statementPaymentTable(),
 | 
					                'elements' => $this->statementPaymentTable(),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
 | 
					            'statement-payment-table-totals' => [
 | 
				
			||||||
 | 
					                'id' => 'statement-payment-table-totals',
 | 
				
			||||||
 | 
					                'elements' => [
 | 
				
			||||||
 | 
					                    ['element' => 'p', 'content' => \sprintf('%s: %s', ctrans('texts.amount_paid'), 1000)],
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
            'statement-aging-table' => [
 | 
					            'statement-aging-table' => [
 | 
				
			||||||
                'id' => 'statement-aging-table',
 | 
					                'id' => 'statement-aging-table',
 | 
				
			||||||
                'elements' => $this->statementAgingTable(),
 | 
					                'elements' => $this->statementAgingTable(),
 | 
				
			||||||
@ -218,8 +231,8 @@ class Design extends BaseDesign
 | 
				
			|||||||
        if ($this->type === 'statement') {
 | 
					        if ($this->type === 'statement') {
 | 
				
			||||||
            return [
 | 
					            return [
 | 
				
			||||||
                ['element' => 'tr', 'properties' => [], 'elements' => [
 | 
					                ['element' => 'tr', 'properties' => [], 'elements' => [
 | 
				
			||||||
                    ['element' => 'th', 'properties' => [], 'content' => '$statement_date_label'],
 | 
					                    ['element' => 'th', 'properties' => [], 'content' => ctrans('texts.statement_date')],
 | 
				
			||||||
                    ['element' => 'th', 'properties' => [], 'content' => '$statement_date'],
 | 
					                    ['element' => 'th', 'properties' => [], 'content' => $this->options['end_date'] ?? ''],
 | 
				
			||||||
                ]],
 | 
					                ]],
 | 
				
			||||||
                ['element' => 'tr', 'properties' => [], 'elements' => [
 | 
					                ['element' => 'tr', 'properties' => [], 'elements' => [
 | 
				
			||||||
                    ['element' => 'th', 'properties' => [], 'content' => '$balance_due_label'],
 | 
					                    ['element' => 'th', 'properties' => [], 'content' => '$balance_due_label'],
 | 
				
			||||||
@ -369,9 +382,9 @@ class Design extends BaseDesign
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return array
 | 
					     * @return array
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function statementPaymentTable()
 | 
					    public function statementPaymentTable(): array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (is_null($this->payments) || $this->type !== self::STATEMENT) {
 | 
					        if (is_null($this->payments) && $this->type !== self::STATEMENT) {
 | 
				
			||||||
            return [];
 | 
					            return [];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -396,30 +409,29 @@ class Design extends BaseDesign
 | 
				
			|||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function statementAgingTable()
 | 
					    public function statementAgingTable(): array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (is_null($this->payments) || $this->type !== self::STATEMENT) {
 | 
					        if ($this->type !== self::STATEMENT) {
 | 
				
			||||||
            return [];
 | 
					            return [];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return [
 | 
					        if (\array_key_exists('show_aging_table', $this->options) && $this->options['show_aging_table'] === false) {
 | 
				
			||||||
            ['element' => 'thead', 'elements' => [
 | 
					            return [];
 | 
				
			||||||
                ['element' => 'th', 'content' => '0-30', 'properties' => []],
 | 
					        }
 | 
				
			||||||
                ['element' => 'th', 'content' => '30-60', 'properties' => []],
 | 
					
 | 
				
			||||||
                ['element' => 'th', 'content' => '60-90', 'properties' => []],
 | 
					        $elements = [
 | 
				
			||||||
                ['element' => 'th', 'content' => '90-120', 'properties' => []],
 | 
					            ['element' => 'thead', 'elements' => []],
 | 
				
			||||||
                ['element' => 'th', 'content' => '120+', 'properties' => []],
 | 
					 | 
				
			||||||
            ]],
 | 
					 | 
				
			||||||
            ['element' => 'tbody', 'elements' => [
 | 
					            ['element' => 'tbody', 'elements' => [
 | 
				
			||||||
                ['element' => 'tr', 'elements' => [
 | 
					                ['element' => 'tr', 'elements' => []],
 | 
				
			||||||
                    ['element' => 'td', 'content' => '$0.00'],
 | 
					 | 
				
			||||||
                    ['element' => 'td', 'content' => '$0.00'],
 | 
					 | 
				
			||||||
                    ['element' => 'td', 'content' => '$0.00'],
 | 
					 | 
				
			||||||
                    ['element' => 'td', 'content' => '$0.00'],
 | 
					 | 
				
			||||||
                    ['element' => 'td', 'content' => '$0.00'],
 | 
					 | 
				
			||||||
                ]],
 | 
					 | 
				
			||||||
            ]],
 | 
					            ]],
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($this->aging as $column => $value) {
 | 
				
			||||||
 | 
					            $elements[0]['elements'][] = ['element' => 'th', 'content' => $column];
 | 
				
			||||||
 | 
					            $elements[1]['elements'][] = ['element' => 'td', 'content' => $value];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $elements;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -559,22 +571,6 @@ class Design extends BaseDesign
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function tableTotals(): array
 | 
					    public function tableTotals(): array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->type === 'statement') {
 | 
					 | 
				
			||||||
            return [
 | 
					 | 
				
			||||||
                ['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
 | 
					 | 
				
			||||||
                    ['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start;'], 'elements' => [
 | 
					 | 
				
			||||||
                        ['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => $this->entity->user->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']],
 | 
					 | 
				
			||||||
                    ]],
 | 
					 | 
				
			||||||
                ]],
 | 
					 | 
				
			||||||
                ['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => [
 | 
					 | 
				
			||||||
                    ['element' => 'div', 'elements' => [
 | 
					 | 
				
			||||||
                        ['element' => 'span', 'content' => '$balance_due_label', 'properties' => ['data-ref' => 'total-table-balance-due-label']],
 | 
					 | 
				
			||||||
                        ['element' => 'span', 'content' => '$balance_due', 'properties' => ['data-ref' => 'total-table-balance-due']],
 | 
					 | 
				
			||||||
                    ]],
 | 
					 | 
				
			||||||
                ]],
 | 
					 | 
				
			||||||
            ];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $_variables = array_key_exists('variables', $this->context)
 | 
					        $_variables = array_key_exists('variables', $this->context)
 | 
				
			||||||
            ? $this->context['variables']
 | 
					            ? $this->context['variables']
 | 
				
			||||||
            : ['values' => ['$entity.public_notes' => $this->entity->public_notes, '$entity.terms' => $this->entity->terms, '$entity_footer' => $this->entity->footer], 'labels' => []];
 | 
					            : ['values' => ['$entity.public_notes' => $this->entity->public_notes, '$entity.terms' => $this->entity->terms, '$entity_footer' => $this->entity->footer], 'labels' => []];
 | 
				
			||||||
@ -596,7 +592,7 @@ class Design extends BaseDesign
 | 
				
			|||||||
            ['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []],
 | 
					            ['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []],
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->type == self::DELIVERY_NOTE) {
 | 
					        if ($this->type == self::DELIVERY_NOTE  || $this->type == self::STATEMENT) {
 | 
				
			||||||
            return $elements;
 | 
					            return $elements;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user