Refactor and improve Versandarten settings

This commit is contained in:
Andreas Palm 2022-10-27 13:17:19 +02:00
parent cd93d643f8
commit 1ddee4350c
6 changed files with 172 additions and 227 deletions

View File

@ -1,4 +1,4 @@
<?php <?php
/* /*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
* *
@ -10,8 +10,8 @@
* to obtain the text of the corresponding license version. * to obtain the text of the corresponding license version.
* *
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** **** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*/ */
?> ?>
<?php <?php
/**************************************************************************** /****************************************************************************
@ -163,28 +163,17 @@ class TemplateParser {
public function addMessage($class, $text, $html = false, $_var = 'MESSAGE') public function addMessage($class, $text, $html = false, $_var = 'MESSAGE')
{ {
$ret = ''; if(!in_array($class, ['error', 'warning', 'info', 'success']))
switch($class) $class = 'info';
{
case 'error':
case 'warning':
case 'info':
break;
default:
$class = 'info';
break;
}
if(!$html) if(!$html)
{ {
$text = $this->htmlspecialchars($text); $text = $this->htmlspecialchars($text);
} }
$ret .= '<div class="'.$class.'">'.$text.'</div>'; $ret = sprintf('<div class="%s">%s</div>', $class, $text);
if($_var === 'return') if($_var === 'return')
{
return $ret; return $ret;
}
return $this->app->Tpl->Add($_var, $ret); $this->app->Tpl->Add($_var, $ret);
} }
public function addSelect($_var, $id, $name, $options, $selected = '', $class = '') public function addSelect($_var, $id, $name, $options, $selected = '', $class = '')

View File

@ -1,9 +1,31 @@
<?php <?php
abstract class Versanddienstleister { abstract class Versanddienstleister {
/** @var int $id */ protected int $id;
public $id; protected Application $app;
/** @var Application $app */ protected string $type;
public $app; protected int $projectId;
protected ?int $labelPrinterId;
protected ?int $documentPrinterId;
protected bool $shippingMail;
protected ?int $businessLetterTemplateId;
protected object $settings;
public function __construct(Application $app, ?int $id)
{
$this->app = $app;
if ($id === null || $id === 0)
return;
$this->id = $id;
$row = $this->app->DB->SelectRow("SELECT * FROM versandarten WHERE id=$this->id");
$this->type = $row['type'];
$this->projectId = $row['projekt'];
$this->labelPrinterId = $row['paketmarke_drucker'];
$this->documentPrinterId = $row['export_drucker'];
$this->shippingMail = $row['versandmail'];
$this->businessLetterTemplateId = $row['geschaeftsbrief_vorlage'];
$this->settings = json_decode($row['einstellungen_json']);
}
public function isEtikettenDrucker(): bool { public function isEtikettenDrucker(): bool {
return false; return false;
@ -147,18 +169,32 @@ abstract class Versanddienstleister {
} }
/** /**
* @param string $target * Returns an array of additional field definitions to be stored for this module:
* [
* 'field_name' => [
* 'typ' => text(default)|textarea|checkbox|select
* 'default' => default value
* 'optionen' => just for selects [key=>value]
* 'size' => size attribute for text fields
* 'placeholder' => placeholder attribute for text fields
* ]
* ]
* *
* @return string * @return array
*/ */
public function Einstellungen($target = 'return') public function AdditionalSettings(): array {
return [];
}
/**
* Renders all additional settings as fields into $target
* @param string $target template placeholder for rendered output
* @param array $form data for form values (from database or form submit)
* @return void
*/
public function RenderAdditionalSettings(string $target, array $form): void
{ {
if(!$this->id) $fields = $this->AdditionalSettings();
{
return '';
}
//$id = $this->id;
$struktur = $this->EinstellungenStruktur();
if($this->app->Secure->GetPOST('speichern')) if($this->app->Secure->GetPOST('speichern'))
{ {
$json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '".$this->id."' LIMIT 1"); $json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '".$this->id."' LIMIT 1");
@ -168,7 +204,7 @@ abstract class Versanddienstleister {
$json = @json_decode($json, true); $json = @json_decode($json, true);
}else{ }else{
$json = array(); $json = array();
foreach($struktur as $name => $val) foreach($fields as $name => $val)
{ {
if(isset($val['default'])) if(isset($val['default']))
{ {
@ -180,7 +216,7 @@ abstract class Versanddienstleister {
{ {
$json = null; $json = null;
} }
foreach($struktur as $name => $val) foreach($fields as $name => $val)
{ {
if($modul === $this->app->Secure->GetPOST('modul_name')) if($modul === $this->app->Secure->GetPOST('modul_name'))
@ -201,101 +237,53 @@ abstract class Versanddienstleister {
$json_str = $this->app->DB->real_escape_string(json_encode($json)); $json_str = $this->app->DB->real_escape_string(json_encode($json));
$this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1"); $this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1");
} }
$id = $this->id;
$html = ''; $html = '';
$json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '$id' LIMIT 1"); foreach($fields as $name => $val) // set missing default values
if($json)
{ {
$json = json_decode($json, true); if(isset($val['default']) && !isset($form[$name]))
}else{
$json = null;
}
$changed = false;
foreach($struktur as $name => $val)
{
if(isset($val['default']) && !isset($json[$name]))
{ {
$changed = true; $form[$name] = $val['default'];
$json[$name] = $val['default'];
} }
} }
if($changed) foreach($fields as $name => $val)
{
$json_str = $this->app->DB->real_escape_string(json_encode($json));
$this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1");
}
$first = true;
foreach($struktur as $name => $val)
{ {
if(isset($val['heading'])) if(isset($val['heading']))
{
$html .= '<tr><td colspan="2"><b>'.html_entity_decode($val['heading']).'</b></td></tr>'; $html .= '<tr><td colspan="2"><b>'.html_entity_decode($val['heading']).'</b></td></tr>';
}
$html .= '<tr><td>'.($first?'<input type="hidden" name="modul_name" value="'.$this->app->DB->Select("SELECT modul FROM versandarten WHERE id = '$id' LIMIT 1").'" />':'').(empty($val['bezeichnung'])?$name:$val['bezeichnung']).'</td><td>'; $html .= '<tr><td>'.($val['bezeichnung'] ?? $name).'</td><td>';
$typ = 'text';
if(!empty($val['typ']))
{
$typ = $val['typ'];
}
if(isset($val['replace'])) if(isset($val['replace']))
{ {
switch($val['replace']) switch($val['replace'])
{ {
case 'lieferantennummer': case 'lieferantennummer':
$json[$name] = $this->app->erp->ReplaceLieferantennummer(0,$json[$name],0); $form[$name] = $this->app->erp->ReplaceLieferantennummer(0,$form[$name],0);
if($target !== 'return') $this->app->YUI->AutoComplete($name, 'lieferant', 1);
{ break;
$this->app->YUI->AutoComplete($name, 'lieferant', 1);
}
break;
case 'shop': case 'shop':
$json[$name] .= ($json[$name]?' '.$this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '".(int)$json[$name]."'"):''); $form[$name] .= ($form[$name]?' '.$this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '".(int)$form[$name]."'"):'');
if($target !== 'return') $this->app->YUI->AutoComplete($name, 'shopnameid');
{ break;
$this->app->YUI->AutoComplete($name, 'shopnameid');
}
break;
case 'etiketten': case 'etiketten':
//$json[$name] = $this->app->erp->ReplaceLieferantennummer(0,$json[$name],0); $this->app->YUI->AutoComplete($name, 'etiketten');
if($target !== 'return') break;
{
$this->app->YUI->AutoComplete($name, 'etiketten');
}
break;
} }
} }
/*if(!isset($json[$name]) && isset($val['default'])) switch($val['typ'] ?? 'text')
{
$json[$name] = $val['default'];
}*/
switch($typ)
{ {
case 'textarea': case 'textarea':
$html .= '<textarea name="'.$name.'" id="'.$name.'">'.(!isset($json[$name])?'':$json[$name]).'</textarea>'; $html .= '<textarea name="'.$name.'" id="'.$name.'">'.($form[$name] ?? '').'</textarea>';
break; break;
case 'checkbox': case 'checkbox':
$html .= '<input type="checkbox" name="'.$name.'" id="'.$name.'" value="1" '.((isset($json[$name]) && $json[$name])?' checked="checked" ':'').' />'; $html .= '<input type="checkbox" name="'.$name.'" id="'.$name.'" value="1" '.($form[$name] ?? false ? ' checked="checked" ':'').' />';
break; break;
case 'select': case 'select':
$html .= '<select name="'.$name.'">'; $html .= $this->app->Tpl->addSelect('return', $name, $name, $val['optionen'], $form[$name]);
if(isset($val['optionen']) && is_array($val['optionen'])) break;
{
foreach($val['optionen'] as $k => $v)
{
$html .= '<option value="'.$k.'"'.($k == (isset($json[$name])?$json[$name]:'')?' selected="selected" ':'').'>'.$v.'</option>';
}
}
$html .= '</select>';
break;
case 'submit': case 'submit':
if(isset($val['text'])) if(isset($val['text']))
{
$html .= '<form method="POST"><input type="submit" name="'.$name.'" value="'.$val['text'].'"></form>'; $html .= '<form method="POST"><input type="submit" name="'.$name.'" value="'.$val['text'].'"></form>';
} break;
break;
case 'custom': case 'custom':
if(isset($val['function'])) if(isset($val['function']))
{ {
@ -305,35 +293,31 @@ abstract class Versanddienstleister {
$html .= $this->$tmpfunction(); $html .= $this->$tmpfunction();
} }
} }
break; break;
default: default:
$html .= '<input type="text"'
$html .= '<input type="text" '.(!empty($val['size'])?' size="'.$val['size'].'" ':'').' '.(!empty($val['placeholder'])?' placeholder="'.$val['placeholder'].'" ':'').' name="'.$name.'" id="'.$name.'" value="'.(!isset($json[$name])?'':htmlspecialchars($json[$name])).'" />'; .(!empty($val['size'])?' size="'.$val['size'].'"':'')
.(!empty($val['placeholder'])?' placeholder="'.$val['placeholder'].'"':'')
.' name="'.$name.'" id="'.$name.'" value="'.(isset($form[$name])?htmlspecialchars($form[$name]):'').'" />';
break; break;
} }
if(isset($val['info']) && $val['info'])$html .= ' <i>'.$val['info'].'</i>'; if(isset($val['info']) && $val['info'])
$html .= ' <i>'.$val['info'].'</i>';
$html .= '</td></tr>'; $html .= '</td></tr>';
$first = false;
}
if($target === 'return') {
return $html;
} }
$this->app->Tpl->Add($target, $html); $this->app->Tpl->Add($target, $html);
return '';
} }
protected abstract function EinstellungenStruktur(); /**
* Validate form data for this module
/** * Form data is passed by reference so replacements (id instead of text) can be performed here as well
* @param string $target * @param array $form submitted form data
* * @return array
* @return bool */
*/ public function CheckInputParameters(array &$form): array
public function checkInputParameters(string $target = ''): bool
{ {
return true; return [];
} }

View File

@ -99,7 +99,7 @@ class Versandart_intraship extends Versanddienstleister{
return 'DHL Instrahship'; return 'DHL Instrahship';
} }
function EinstellungenStruktur() function AdditionalSettings()
{ {
return array( return array(

View File

@ -12,32 +12,14 @@ require_once dirname(__DIR__) . '/class.versanddienstleister.php';
class Versandart_sendcloud extends Versanddienstleister class Versandart_sendcloud extends Versanddienstleister
{ {
protected SendCloudApi $api;
protected array $options;
/* @var SendCloudApi $api */ public function __construct(Application $app, ?int $id)
protected $api;
/* @var array $settings */
protected $settings;
protected $options;
/**
* Versandart_sendcloud constructor.
*
* @param ApplicationCore $app
* @param int $id
*/
public function __construct($app, $id)
{ {
$this->app = $app; parent::__construct($app, $id);
$this->id = $id; if (!isset($this->id))
return;
//TODO move to better place
$res = $this->app->DB->SelectRow("SELECT * FROM versandarten WHERE id=$this->id");
$this->settings = json_decode($res['einstellungen_json']);
$this->type = $res['type'];
$this->paketmarke_drucker = $res['paketmarke_drucker'];
$this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key); $this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key);
} }
@ -59,10 +41,10 @@ class Versandart_sendcloud extends Versanddienstleister
$this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []);
$this->options['products'][0] = ''; $this->options['products'][0] = '';
$this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product]; $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product];
asort($this->options['products']); natcasesort($this->options['products']);
} }
protected function EinstellungenStruktur() public function AdditionalSettings(): array
{ {
$this->FetchOptionsFromApi(); $this->FetchOptionsFromApi();
return [ return [

View File

@ -14,15 +14,13 @@
<td>{|Bezeichnung|}:</td> <td>{|Bezeichnung|}:</td>
<td> <td>
<input type="text" name="bezeichnung" value="[BEZEICHNUNG]" size="40" <input type="text" name="bezeichnung" value="[BEZEICHNUNG]" size="40"
data-lang="versandart_bezeichnung_[ID]"> data-lang="versandart_bezeichnung_[ID]" required>
<span style="color:red">[MSGBEZEICHNUNG]</span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{|Typ|}:</td> <td>{|Typ|}:</td>
<td> <td>
<input type="text" name="typ" value="[TYP]" size="40"> <input type="text" name="type" value="[TYPE]" size="40" required>
<span style="color:red">[MSGTYP]</span>
<i>{|z.B. dhl,ups,etc.|}</i> <i>{|z.B. dhl,ups,etc.|}</i>
</td> </td>
</tr> </tr>
@ -64,7 +62,7 @@
<td>{|Textvorlage|}:</td> <td>{|Textvorlage|}:</td>
<td>[SELGESCHAEFTSBRIEF_VORLAGE]</td> <td>[SELGESCHAEFTSBRIEF_VORLAGE]</td>
</tr> </tr>
[JSON] [MODULESETTINGS]
</table> </table>
</fieldset> </fieldset>
<input type="submit" name="speichern" value="{|Speichern|}" id="speichern" style="float:right"/> <input type="submit" name="speichern" value="{|Speichern|}" id="speichern" style="float:right"/>

View File

@ -149,7 +149,7 @@ class Versandarten {
public function VersandartenEdit(): void public function VersandartenEdit(): void
{ {
$id = (int)$this->app->Secure->GetGET('id'); $id = (int)$this->app->Secure->GetGET('id');
$save = $this->app->Secure->GetPOST('speichern'); $submit = $this->app->Secure->GetPOST('speichern');
if (!$id) if (!$id)
return; return;
@ -157,62 +157,59 @@ class Versandarten {
$this->app->erp->MenuEintrag('index.php?module=versandarten&action=edit&id='.$id,'Details'); $this->app->erp->MenuEintrag('index.php?module=versandarten&action=edit&id='.$id,'Details');
$this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Zur&uuml;ck zur &Uuml;bersicht'); $this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Zur&uuml;ck zur &Uuml;bersicht');
$input = $this->GetInput();
$error = []; $error = [];
if($save != ''){ if($submit != '') { // handle form submit
$moduleObject = $this->loadModule($input['selmodul'], $id); $form = $this->GetInput();
if ($moduleObject === null) $obj = $this->loadModule($form['modul'], $id);
$error[] = sprintf('Versandart "%s" existiert nicht.', $input['selmodul']); if ($obj === null)
$error[] = sprintf('Versandart "%s" existiert nicht.', $form['selmodul']);
if(trim($input['bezeichnung']) == '') { if(trim($form['bezeichnung']) == '')
$error[] = 'Bitte alle Pflichtfelder ausfüllen!'; $error[] = 'Bitte eine Bezeichnung angeben!';
$this->app->Tpl->Set('MSGBEZEICHNUNG','Pflichtfeld!');
}
if(trim($input['typ']) == '')
{
$error[] = 'Bitte alle Pflichtfelder ausfüllen!';
$this->app->Tpl->Set('MSGTYP','Pflichtfeld!');
}
$projektid = 0; if(trim($form['type']) == '')
if(!empty($input['projekt'])){ $error[] = 'Bitte einen Typ angeben!';
$projektid = $this->app->DB->Select(
"SELECT `id` FROM `projekt` WHERE `abkuerzung` = '{$input['projekt']}' LIMIT 1" $projektId = 0;
if(!empty($form['projekt'])){
$projektId = $this->app->DB->Select(
"SELECT `id` FROM `projekt` WHERE `abkuerzung` = '{$form['projekt']}' LIMIT 1"
); );
} }
if ($this->app->DB->Select( if ($this->app->DB->Select(
"SELECT `id` FROM `versandarten` WHERE `type` = '{$input['typ']}' AND `id` <> $id LIMIT 1" "SELECT `id` FROM `versandarten` WHERE `type` = '{$form['type']}' AND `id` <> $id LIMIT 1"
)) { ))
$error[] = 'Typ ist bereits für eine andere Versandart vergeben'; $error[] = 'Typ ist bereits für eine andere Versandart vergeben';
foreach ($obj->AdditionalSettings() as $k => $v) {
$form[$k] = $this->app->Secure->GetPOST($k);
} }
$error = array_merge($error, $obj->CheckInputParameters($form));
foreach ($obj->AdditionalSettings() as $k => $v) {
$json[$k] = $form[$k];
}
$json = json_encode($json ?? null);
foreach ($error as $e) { foreach ($error as $e) {
$this->app->Tpl->addMessage('error', $e); $this->app->Tpl->addMessage('error', $e);
} }
$inputCheckResult = $moduleObject->checkInputParameters('MESSAGE'); if (empty($error)) {
if (empty($error) && $inputCheckResult) {
$this->app->DB->Update( $this->app->DB->Update(
"UPDATE `versandarten` "UPDATE `versandarten`
SET `bezeichnung`='{$input['bezeichnung']}', `type` ='{$input['typ']}', SET `bezeichnung`='{$form['bezeichnung']}', `type` ='{$form['type']}',
`projekt`=$projektid, `aktiv`={$input['aktiv']}, `modul`='{$input['selmodul']}', `projekt`=$projektId, `aktiv`={$form['aktiv']}, `modul`='{$form['modul']}',
`export_drucker` = {$input['export_drucker']}, `export_drucker` = {$form['export_drucker']},
`paketmarke_drucker` = {$input['paketmarke_drucker']}, `paketmarke_drucker` = {$form['paketmarke_drucker']},
`ausprojekt` = {$input['ausprojekt']}, `versandmail` = {$input['versandmail']}, `ausprojekt` = {$form['ausprojekt']}, `versandmail` = {$form['versandmail']},
`geschaeftsbrief_vorlage` = {$input['geschaeftsbrief_vorlage']}, `geschaeftsbrief_vorlage` = {$form['geschaeftsbrief_vorlage']},
`keinportocheck`={$input['keinportocheck']} `keinportocheck`={$form['keinportocheck']},
einstellungen_json='$json'
WHERE `id` = $id LIMIT 1" WHERE `id` = $id LIMIT 1"
); );
if($input['aktiv'] == 1){ $this->app->Tpl->addMessage('success', "Die Daten wurden erfolgreich gespeichert!");
$this->app->Tpl->Set('AKTIV', "checked");
}
if($input['keinportocheck'] == 1){
$this->app->Tpl->Set('KEINPORTOCHECK', "checked");
}
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Daten wurden erfolgreich gespeichert!</div>");
} }
} }
$daten = $this->app->DB->SelectRow("SELECT * FROM `versandarten` WHERE `id` = $id LIMIT 1"); $daten = $this->app->DB->SelectRow("SELECT * FROM `versandarten` WHERE `id` = $id LIMIT 1");
@ -222,28 +219,34 @@ class Versandarten {
$this->app->erp->Headlines('', $daten['bezeichnung']); $this->app->erp->Headlines('', $daten['bezeichnung']);
$this->app->Tpl->Set('AKTMODUL', $daten['modul']); $this->app->Tpl->Set('AKTMODUL', $daten['modul']);
$obj = $this->loadModule($daten['modul'], $daten['id']); $obj = $this->loadModule($daten['modul'], $daten['id']);
$bezeichnung = $daten['bezeichnung'];
$typ = $daten['type']; if (empty($error) || !isset($form)) { //overwrite form data from database if no validation error is present
$projekt = $daten['projekt']; $form = json_decode($daten['einstellungen_json'],true);
$aktiv = $daten['aktiv']; $form['bezeichnung'] = $daten['bezeichnung'];
$keinportocheck = $daten['keinportocheck']; $form['type'] = $daten['type'];
$projektname = $this->app->erp->Projektdaten($projekt, 'abkuerzung'); $form['projekt'] = $this->app->erp->Projektdaten($daten['projekt'], 'abkuerzung');
$obj->Einstellungen('JSON'); $form['aktiv'] = $daten['aktiv'];
$etikettendrucker = $obj->isEtikettenDrucker(); $form['keinportocheck'] = $daten['keinportocheck'];
$form['modul'] = $daten['modul'];
$form['export_drucker'] = $daten['export_drucker'];
$form['paketmarke_drucker'] = $daten['paketmarke_drucker'];
}
$obj->RenderAdditionalSettings('MODULESETTINGS', $form);
$drucker_export = $this->app->erp->GetDrucker(); $drucker_export = $this->app->erp->GetDrucker();
$drucker_export[0] = ''; $drucker_export[0] = '';
asort($drucker_export); natcasesort($drucker_export);
$this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker',
$drucker_export, $daten['export_drucker']); $drucker_export, $form['export_drucker']);
$drucker_paketmarke = $this->app->erp->GetDrucker(); $drucker_paketmarke = $this->app->erp->GetDrucker();
if($etikettendrucker) if($obj->isEtikettenDrucker())
$drucker_paketmarke = array_merge($drucker_paketmarke, $this->app->erp->GetEtikettendrucker()); $drucker_paketmarke = array_merge($drucker_paketmarke, $this->app->erp->GetEtikettendrucker());
$drucker_paketmarke[0] = ''; $drucker_paketmarke[0] = '';
asort($drucker_paketmarke); natcasesort($drucker_paketmarke);
$this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker', $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker',
$drucker_paketmarke, $daten['paketmarke_drucker']); $drucker_paketmarke, $form['paketmarke_drucker']);
$this->app->YUI->HideFormular('versandmail', array('0'=>'versandbetreff','1'=>'dummy')); $this->app->YUI->HideFormular('versandmail', array('0'=>'versandbetreff','1'=>'dummy'));
$this->app->Tpl->addSelect('SELVERSANDMAIL', 'versandmail', 'versandmail', [ $this->app->Tpl->addSelect('SELVERSANDMAIL', 'versandmail', 'versandmail', [
@ -258,30 +261,19 @@ class Versandarten {
LEFT JOIN `projekt` AS `p` ON gv.projekt = p.id LEFT JOIN `projekt` AS `p` ON gv.projekt = p.id
ORDER by gv.subjekt" ORDER by gv.subjekt"
); );
$this->app->Tpl->addSelect('SELGESCHAEFTSBRIEF_VORLAGE', 'geschaeftsbrief_vorlage', $this->app->Tpl->addSelect('SELGESCHAEFTSBRIEF_VORLAGE', 'geschaeftsbrief_vorlage',
'geschaeftsbrief_vorlage', $geschaeftsbrief_vorlagen, $daten['geschaeftsbrief_vorlage']); 'geschaeftsbrief_vorlage', $geschaeftsbrief_vorlagen, $daten['geschaeftsbrief_vorlage']);
if(empty($error)){ $this->app->Tpl->addSelect('SELMODUL', 'modul', 'modul',
$selectedModule = $daten['modul'] ?? ''; $this->VersandartenSelModul(), $form['modul']);
} $this->app->Tpl->Set('BEZEICHNUNG', $form['bezeichnung']);
else { $this->app->Tpl->Set('TYPE', $form['type']);
$selectedModule = $input['selmodul']; $this->app->Tpl->Set('PROJEKT', $form['projekt']);
}
$this->app->Tpl->addSelect('SELMODUL', 'selmodul', 'selmodul',
$this->VersandartenSelModul(), $selectedModule);
$this->app->Tpl->Set('BEZEICHNUNG', empty($error)?$bezeichnung:$input['bezeichnung']);
$this->app->Tpl->Set('TYP', empty($error)?$typ:$input['typ']);
$this->app->Tpl->Set('PROJEKT', empty($error)?$projektname:$input['projekt']);
if((empty($error) && $aktiv == 1) || (!empty($error) && $input['aktiv'])){
$this->app->Tpl->Set('AKTIV', 'checked');
}
if((empty($error) && $keinportocheck == 1) || (!empty($error) && $input['keinportocheck'])){
$this->app->Tpl->Set('KEINPORTOCHECK', 'checked');
}
$this->app->YUI->AutoComplete('projekt', 'projektname', 1); $this->app->YUI->AutoComplete('projekt', 'projektname', 1);
if($form['aktiv']) $this->app->Tpl->Set('AKTIV', 'checked');
if($form['keinportocheck']) $this->app->Tpl->Set('KEINPORTOCHECK', 'checked');
if ($obj->Beta ?? false) if ($obj->Beta ?? false)
$this->app->Tpl->Add('MESSAGE','<div class="info">Dieses Modul ist noch im Beta Stadium.</div>'); $this->app->Tpl->addMessage('warning','Dieses Modul ist noch im Beta Stadium');
$this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl'); $this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl');
} }
@ -747,9 +739,9 @@ class Versandarten {
{ {
$input = []; $input = [];
$input['bezeichnung'] = $this->app->Secure->GetPOST('bezeichnung'); $input['bezeichnung'] = $this->app->Secure->GetPOST('bezeichnung');
$input['typ'] = $this->app->Secure->GetPOST('typ'); $input['type'] = $this->app->Secure->GetPOST('type');
$input['projekt'] = $this->app->Secure->GetPOST('projekt'); $input['projekt'] = $this->app->Secure->GetPOST('projekt');
$input['selmodul'] = $this->app->Secure->GetPOST('selmodul'); $input['modul'] = $this->app->Secure->GetPOST('modul');
$input['aktiv'] = (int)$this->app->Secure->GetPOST('aktiv'); $input['aktiv'] = (int)$this->app->Secure->GetPOST('aktiv');
$input['keinportocheck'] = (int)$this->app->Secure->GetPOST('keinportocheck'); $input['keinportocheck'] = (int)$this->app->Secure->GetPOST('keinportocheck');
$input['ausprojekt'] = (int)$this->app->Secure->GetPOST('ausprojekt'); $input['ausprojekt'] = (int)$this->app->Secure->GetPOST('ausprojekt');