Set Default PDF Variables (#3409)

This commit is contained in:
David Bomba 2020-03-02 22:03:40 +11:00 committed by GitHub
parent db88d6a50d
commit cf345b1932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -515,7 +515,16 @@ class CompanySettings extends BaseSettings {
'credit_balance', 'credit_balance',
'credit_amount', 'credit_amount',
], ],
'table_columns' => [ 'product_columns' => [
'product_key',
'notes',
'cost',
'quantity',
'discount',
'tax_name1',
'line_total'
],
'task_columns' => [
'product_key', 'product_key',
'notes', 'notes',
'cost', 'cost',

View File

@ -81,8 +81,8 @@ class Designer {
public function getTable($entity):string public function getTable($entity):string
{ {
$table_header = $entity->table_header($this->input_variables['table_columns'], $this->design->table_styles()); $table_header = $entity->table_header($this->input_variables['product_columns'], $this->design->table_styles());
$table_body = $entity->table_body($this->input_variables['table_columns'], $this->design->table_styles()); $table_body = $entity->table_body($this->input_variables['product_columns'], $this->design->table_styles());
$data = str_replace('$table_header', $table_header, $this->getSection('table')); $data = str_replace('$table_header', $table_header, $this->getSection('table'));
$data = str_replace('$table_body', $table_body, $data); $data = str_replace('$table_body', $table_body, $data);

View File

@ -45,4 +45,17 @@ class StoreCompanyRequest extends Request
return $rules; return $rules;
} }
protected function prepareForValidation()
{
$input = $this->all();
if(array_key_exists('settings', $input) && property_exists($input['settings'], 'pdf_variables') && empty((array) $input['settings']->pdf_variables))
{
$input['settings']['pdf_variables'] = CompanySettings::getEntityVariableDefaults();
}
$this->replace($input);
}
} }