// PDF override

This commit is contained in:
fBrignoli
2012-03-28 15:28:29 +00:00
parent 20d848e74b
commit a20e175495
7 changed files with 45 additions and 49 deletions
+18 -8
View File
@@ -260,16 +260,26 @@ class AdminInvoicesControllerCore extends AdminController
'name' => 'invoice'
)
);
$d = dir(_PS_THEME_DIR_.'/pdf/');
while (false !== ($entry = $d->read()))
$templates_override = $this->getInvoicesModelsFromDir(_PS_THEME_DIR_.'pdf/');
$templates_default = $this->getInvoicesModelsFromDir(_PS_PDF_DIR_);
foreach (array_merge($templates_default, $templates_override) as $template)
{
if (preg_match('`^(invoice-[a-z0-9]+)\.tpl$`', $entry, $matches))
$models[] = array(
'value' => $matches[1],
'name' => $matches[1]
);
$template_name = basename($template, '.tpl');
$models[] = array('value' => $template_name, 'name' => $template_name);
}
$d->close();
return $models;
}
protected function getInvoicesModelsFromDir($directory)
{
$templates = array();
if (is_dir($directory))
$templates = glob($directory.'invoice-*.tpl');
return $templates;
}
}