adresse XML-Rechnung Smarty Template zuordnen

This commit is contained in:
OpenXE 2024-11-01 12:28:40 +01:00
parent 5079b32ea9
commit 1bae56a574
8 changed files with 73 additions and 13 deletions

View File

@ -3682,6 +3682,17 @@
"Extra": "",
"Privileges": "select,insert,update,references",
"Comment": ""
},
{
"Field": "rechnung_smarty_template",
"Type": "int(11)",
"Collation": null,
"Null": "NO",
"Key": "",
"Default": "0",
"Extra": "",
"Privileges": "select,insert,update,references",
"Comment": ""
}
],
"keys": [

View File

@ -13824,6 +13824,18 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
}
}
function ReplaceSmartyTemplate($db,$value,$fromform = null) {
$value = $this->app->DB->real_escape_string($value);
if ($db) {
$smarty_template = explode(' ',$value)[0];
return($smarty_template);
} else {
$smarty_template = $this->app->DB->Select("SELECT CONCAT(id,' ',name) FROM smarty_templates WHERE id = '$value' LIMIT 1");
return($smarty_template);
}
}
// @refactor FormHelper Komponente
function ReplaceLieferant($db,$value,$fromform)

File diff suppressed because one or more lines are too long

View File

@ -4195,6 +4195,14 @@ select a.kundennummer, (SELECT name FROM adresse a2 WHERE a2.kundennummer = a.ku
);
break;
case "smarty_template":
$newarr = $this->app->DB->SelectFirstCols(
sprintf(
"SELECT CONCAT(`id`,' ',`name`) FROM `smarty_templates` WHERE (`name` LIKE '%%%s%%')",
$term
)
);
break;
default:
$newarr = null;
$this->app->erp->RunHook('ajax_filter_hook1', 5,$filtername,$newarr, $term, $term2, $term3);

View File

@ -1296,17 +1296,24 @@ class Rechnung extends GenRechnung
header('Content-Disposition: attachment;filename='.$filename.'.json');
echo(json_encode($result,JSON_PRETTY_PRINT));
} else {
$template = $this->app->DB->Select("SELECT template from smarty_templates LIMIT 1");
$smarty = new Smarty;
$directory = $this->app->erp->GetTMP().'/smarty/templates';
$smarty->setCompileDir($directory);
$smarty->assign('rechnung', $result);
$html = $smarty->fetch('string:'.$template);
header('Content-type:application/xml');
header('Content-Disposition: attachment;filename='.$filename.'.xml');
echo($html);
}
$template = $this->app->DB->Select("SELECT template from smarty_templates WHERE id = '".$adresse[0]['rechnung_smarty_template']."' LIMIT 1");
if(empty($template)) {
header('Content-type:text/plain');
header('Content-Disposition: attachment;filename='.$filename.'.xml');
echo('Kein Smarty Template in der Adresse hinterlegt.');
} else {
$smarty = new Smarty;
$directory = $this->app->erp->GetTMP().'/smarty/templates';
$smarty->setCompileDir($directory);
$smarty->assign('rechnung', $result);
$html = $smarty->fetch('string:'.$template);
header('Content-type:application/xml');
header('Content-Disposition: attachment;filename='.$filename.'.xml');
echo($html);
}
}
$this->app->ExitXentral();
}

View File

@ -279,6 +279,9 @@ class WidgetGenadresse
$field->AddOption('{|nur Rechnung erstellen|}','rechnung');
$this->form->NewField($field);
$field = new HTMLInput("rechnung_smarty_template","text","","","","","","","","","","0","","");
$this->form->NewField($field);
$field = new HTMLInput("kommissionskonsignationslager","text","","","","","","","","","","0","","");
$this->form->NewField($field);

View File

@ -478,6 +478,10 @@ function abweichend(cmd) {
<tr>
<td>{|Belege im Auto-Versand erstellen|}:</td>
<td>[ART][MSGART]</td>
</tr>
<tr>
<td>{|Smarty Template für XML-Rechnung|}:</td>
<td>[RECHNUNG_SMARTY_TEMPLATE][MSGRECHNUNG_SMARTY_TEMPLATE]</td>
</tr> [VORKOMMISSIONIERLAGER]
<tr>
<td>{|Kommissions-/Konsignationslager|}:</td>

View File

@ -35,7 +35,9 @@ class WidgetAdresse extends WidgetGenAdresse
$this->form->ReplaceFunction("kreditlimiteinmalig",$this,"ReplaceBetrag");
$this->app->YUI->AutoComplete("sachkonto","sachkonto",1);
$this->form->ReplaceFunction("sachkonto",$this,"ReplaceKontorahmen");
$this->form->ReplaceFunction("sachkonto",$this,"ReplaceKontorahmen");
$this->form->ReplaceFunction("rechnung_smarty_template",$this,"ReplaceSmartyTemplate");
$this->form->ReplaceFunction("lat",$this,"ReplaceBetrag");
$this->form->ReplaceFunction("lng",$this,"ReplaceBetrag");
@ -48,6 +50,8 @@ class WidgetAdresse extends WidgetGenAdresse
$this->app->YUI->AutoComplete("lieferbedingung","lieferbedingungen");
$this->app->YUI->AutoComplete("rechnung_smarty_template","smarty_template",1);
$this->app->YUI->AutoComplete("kassiererprojekt","projektname",1);
$this->form->ReplaceFunction("kassiererprojekt",$this,"ReplaceProjekt");
@ -485,6 +489,11 @@ class WidgetAdresse extends WidgetGenAdresse
{
return $this->app->erp->ReplaceKontorahmen($db,$value,$fromform);
}
function ReplaceSmartyTemplate($db,$value,$fromform)
{
return $this->app->erp->ReplaceSmartyTemplate($db,$value,$fromform);
}
/**
* @param int|bool $db