app=$app;
if($intern) {
return;
}
$this->app->ActionHandlerInit($this);
$this->app->ActionHandler("create","EinstellungenCreate");
$this->app->ActionHandler("edit","EinstellungenEdit");
$this->app->ActionHandler("list","EinstellungenList");
$this->app->ActionHandler("betaprogram", "EinstellungenBetaProgram");
$this->app->ActionHandler("category","SettingsCategoryApps");
$this->app->ActionHandlerListen($app);
$this->app->Tpl->Set('UEBERSCHRIFT',"Einstellungen");
$this->app->Tpl->Set('FARBE',"[FARBE5]");
}
/**
* @param bool $parameter
*
* @return null|string
*/
protected function sendBeta($parameter)
{
$setBeta = $parameter;
$updateResultStatus = null;
include_once dirname(__DIR__, 2).'/upgradesystemclient2_includekey.php';
return $updateResultStatus;
}
/**
* @param bool $betaStatus
*/
public function tryChangeBetaStatusAndLocateToSite(bool $betaStatus): void
{
$updateServerResult = $this->sendBeta($betaStatus);
if($updateServerResult === 'OK') {
$this->app->User->SetParameter('updatekey', 1);
$this->app->User->SetParameter('einstellungen_beta_activated', $betaStatus ? '1' : '');
/** @var Appstore $appStore */
$appStore = $this->app->loadModule('appstore');
$appStore->resetBuyListCache();
$appStore->resetBuyInfoCache();
$this->app->Location->execute('index.php?module=einstellungen&action=betaprogram&cmd=updatekey');
}
if($betaStatus) {
$msg = $this->app->erp->base64_url_encode(
'
Das Beta-Programm konnte nicht aktiviert werden
'
);
}
else {
$msg = $this->app->erp->base64_url_encode(
'Das Beta-Programm konnte nicht beendet werden
'
);
}
$this->app->Location->execute('index.php?module=einstellungen&action=betaprogram&msg='.$msg);
}
/**
* @return void
*/
public function EinstellungenBetaProgram()
{
$cmd = $this->app->Secure->GetGET('cmd');
if($cmd === 'updatekey') {
include dirname(dirname(__DIR__)).'/version.php';
$this->app->User->SetParameter('updatekey','');
include_once dirname(dirname(__DIR__)).'/upgradesystemclient2_includekey.php';
$this->app->Location->execute('index.php?module=einstellungen&action=betaprogram');
}
if($this->app->Secure->GetPOST('deactivate')) {
$this->tryChangeBetaStatusAndLocateToSite(false);
}
if($this->app->Secure->GetPOST('beta-agreement')) {
$this->tryChangeBetaStatusAndLocateToSite(true);
}
$openPopup = !empty($this->app->User->GetParameter('einstellungen_beta_activated'));
if($openPopup) {
$this->app->User->SetParameter('einstellungen_beta_activated', '');
$this->app->Tpl->Set('BETAOPEN', '1');
}
else {
$this->app->Tpl->Set('BETAOPEN', '');
}
$this->app->erp->MenuEintrag('index.php?module=einstellungen&action=betaprogram', 'Beta Programm');
if(false) {
$this->app->Tpl->Set('BEFORESHOWIFBETADEACTIVATED', '');
}
else {
$this->app->Tpl->Set('BEFORESHOWIFBETAACTIVATED', '');
}
$this->app->erp->Headlines('Beta Programm');
$this->app->Tpl->Parse('PAGE', 'einstellungen_betaprogram.tpl');
}
/**
* @return string[][][]
*/
public function getModulesByCategory()
{
return [
'System' => [
'firmendaten' => [
'name' => 'Grundeinstellungen',
'icon' => 'Icons_dunkel_1.gif',
'link' => 'index.php?module=firmendaten&action=edit',
],
'benutzer' => [
'name' => 'Benutzer',
'icon' => 'Icons_dunkel_2.gif',
'link' => 'index.php?module=benutzer&action=list',
],
'geschaeftsbrief_vorlagen' => [
'name' => 'Geschäftsbrief Vorlagen',
'icon' => 'Icons_dunkel_3.gif',
'link' => 'index.php?module=geschaeftsbrief_vorlagen&action=list',
],
'emailbackup' => [
'name' => 'E-Mail Accounts',
'icon' => 'Icons_dunkel_4.gif',
'link' => 'index.php?module=emailbackup&action=list',
],
'ticket_vorlage' => [
'name' => 'Ticket Vorlagen',
'icon' => 'Icons_dunkel_5.gif',
'link' => 'index.php?module=ticket_vorlage&action=list',
],
'warteschlangen' => [
'name' => 'Warteschlangen',
'icon' => 'Icons_dunkel_6.gif',
'link' => 'index.php?module=warteschlangen&action=list',
],
'artikelkategorien' => [
'name' => 'Artikel Kategorien',
'icon' => 'Icons_dunkel_15.gif',
'link' => 'index.php?module=artikelkategorien&action=list',
],
'artikeleinheit' => [
'name' => 'Artikel Einheiten',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=artikeleinheit&action=list',
],
'gruppen' => [
'name' => 'Gruppen',
'icon' => 'Icons_dunkel_2.gif',
'link' => 'index.php?module=gruppen&action=list',
],
'uservorlage' => [
'name' => 'Benutzer Vorlage',
'icon' => 'Icons_dunkel_2.gif',
'link' => 'index.php?module=uservorlage&action=list',
],
'laender' => [
'name' => 'Länderliste',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=laender&action=list',
],
'kalender' => [
'name' => 'Kalender Gruppen',
'icon' => 'Icons_dunkel_2.gif',
'link' => 'index.php?module=kalender&action=gruppenlist',
],
'prozessstarter' => [
'name' => 'Prozessstarter',
'icon' => 'Icons_dunkel_22.gif',
'link' => 'index.php?module=prozessstarter&action=list',
],
'welcome' => [
'name' => 'Lizenz',
'icon' => 'Icons_dunkel_23.gif',
'link' => 'index.php?module=welcome&action=info',
],
'drucker' => [
'name' => 'Drucker',
'icon' => 'Icons_dunkel_24.gif',
'link' => 'index.php?module=drucker&action=list',
],
'adapterbox' => [
'name' => 'Adapterbox',
'icon' => 'Icons_dunkel_25.gif',
'link' => 'index.php?module=adapterbox&action=list',
],
'protokoll' => [
'name' => 'Protokoll',
'icon' => 'Icons_dunkel_22.gif',
'link' => 'index.php?module=protokoll&action=list',
],
'etiketten' => [
'name' => 'Etiketten',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=etiketten&action=list',
],
'uebersetzung' => [
'name' => 'Übersetzungen',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=uebersetzung&action=list',
],
'arbeitsfreietage' => [
'name' => 'Arbeitsfreie Tage',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=arbeitsfreietage&action=list',
],
'support' => [
'name' => 'Support',
'icon' => 'Icons_dunkel_23.gif',
'link' => 'index.php?module=support&action=list',
],
'api_account' => [
'name' => 'API-Account',
'icon' => 'Icons_dunkel_25.gif',
'link' => 'index.php?module=api_account&action=list',
],
],
'Lager und Logistik' => [
'zolltarifnummer' => [
'name' => 'Zolltarifnummer',
'icon' => 'Icons_dunkel_16.gif',
'link' => 'index.php?module=zolltarifnummer&action=list',
],
'versandarten' => [
'name' => 'Versandarten',
'icon' => 'Icons_dunkel_16.gif',
'link' => 'index.php?module=versandarten&action=list',
],
'lieferbedingungen' => [
'name' => 'Lieferbedingungen',
'icon' => 'Icons_dunkel_16.gif',
'link' => 'index.php?module=lieferbedingungen&action=list',
],
],
'Shop Schnittstelle' => [
'onlineshops' => [
'name' => 'Online-Shops',
'icon' => 'Icons_dunkel_20.gif',
'link' => 'index.php?module=onlineshops&action=list',
],
],
'Mitarbeiter Verwaltung' => [
'stechuhrdevice' => [
'name' => 'Mitarbeiterzeiterfassung Geräteeinstellungen',
'icon' => 'Icons_dunkel_14.gif',
'link' => 'index.php?module=stechuhrdevice&action=list',
],
],
];
}
function EinstellungenCreate()
{
$this->app->Tpl->Add('TABS',
"Zurück zur Übersicht");
}
/**
* @return array
*/
public function getTestModules()
{
/** @var Appstore $appstore */
$ret = [];
$appstore = $this->app->erp->LoadModul('appstore');
$modules = $appstore->GetApps();
if(!empty($modules['installiert'])) {
foreach($modules['installiert'] as $k => $modul) {
if(!empty($modul['ablaufdatum']) || ($modul['key'] === 'stechuhrdevice' && $this->app->erp->RechteVorhanden('stechuhrdevice','list'))) {
if(!empty($modul['ablaufdatum']) && strtotime($modul['ablaufdatum']) < strtotime(date('Y-m-d'))) {
continue;
}
$ret[] = [
'Icon' => $modul['Icon'],
'ablaufdatum' => !empty($modul['ablaufdatum'])?$this->app->String->Convert($modul['ablaufdatum'], '%1-%2-%3', '%3.%2.%1'):null,
'key' => $modul['key'],
'Link' => $modul['Link'],
'Bezeichnung' => strip_tags($modul['Bezeichnung'])
];
}
}
}
return $ret;
}
/**
* @param array $array
* @param int $countPerRow
*
* @return array
*/
public function groupArray($array, $countPerRow = 0)
{
$ret = [];
if($countPerRow === 0) {
foreach($array as $key => $element) {
$ret[] = [$key => $element];
}
return $ret;
}
$i = 0;
$row = [];
foreach($array as $key => $elements) {
$i++;
$row[$key] = $elements;
if($i % $countPerRow === 0) {
$ret[] = $row;
$row = [];
}
}
if(!empty($row)) {
$ret[] = $row;
}
return $ret;
}
/**
* @return array
*/
public function getAppsWithSettings()
{
/** @var Appstore $appstore */
$appstore = $this->app->loadModule('appstore');
$apps = $appstore->GetApps();
$kauf = empty($apps['kauf'])?[]:$apps['kauf'];
$apps = empty($apps['installiert'])?[]:$apps['installiert'];
if(!empty($kauf)) {
foreach($kauf as $module) {
if($this->app->erp->ModulVorhanden($module['key'])) {
$apps[] = $module;
}
}
}
$appsWithSettings = [];
$modulesWithSettings = [];
/** @var Benutzer $userModule */
$userModule = $this->app->loadModule('benutzer');
$enc = $userModule->ScanModules();
if(!empty($enc)) {
foreach($enc as $module => $actions) {
$module = strtolower($module);
if(in_array('settings', $actions)) {
$modulesWithSettings[$module] = 'settings';
continue;
}
if(in_array('einstellungen', $actions)) {
$modulesWithSettings[$module] = 'einstellungen';
continue;
}
if(in_array('einstellung', $actions)) {
$modulesWithSettings[$module] = 'einstellung';
continue;
}
}
}
$sprachen = array('german','english');
if(method_exists($this->app->User,'GetSprachen')) {
$sprachen = $this->app->User->GetSprachen();
if (in_array('deutsch', $sprachen, true) && !in_array('german', $sprachen, true)) {
$sprachen[] = 'german';
}
}
$inline = [];
if(is_array($sprachen)) {
$sprachen = array_reverse($sprachen);
foreach($sprachen as $sprache) {
if(preg_match_all('/[a-zA-Z0-9\-]/', $sprache, $erg)) {
if(is_file(dirname(dirname(__DIR__)).'/languages/'.$sprache.'/inline.php')) {
include dirname(dirname(__DIR__)).'/languages/'.$sprache.'/inline.php';
}
}
}
}
foreach($apps as $app) {
$showInSettings = isset($app['settings']) && $app['settings']==true;
if(empty($modulesWithSettings[$app['key']]) && !$showInSettings) {
continue;
}
if(!$this->app->erp->RechteVorhanden($app['key'], $modulesWithSettings[$app['key']]) && !$showInSettings) {
continue;
}
if(!empty($inline[$app['key']]['default']['kategorie'])) {
$app['kategorie'] = $inline[$app['key']]['default']['kategorie'];
}
$category = empty($app['kategorie'])?'{|System|}':$app['kategorie'];
if($showInSettings){
$link = $app['Link'];
}else{
$link = 'index.php?module='.$app['key'].'&action='. $modulesWithSettings[$app['key']];
}
$icon = [
'name' => $app['Bezeichnung'],
'icon' => $app['Icon'],
'link' => $link,
'key' => $app['key'],
];
$appsWithSettings[$category][$app['Bezeichnung']] = $icon;
}
ksort($appsWithSettings);
$return = [];
foreach($appsWithSettings as $category => $apps) {
ksort($apps);
$return[$category] = [];
foreach($apps as $app) {
$return[$category][$app['key']] = $app;
}
}
return $return;
}
public function SettingsCategoryApps()
{
$categoryFromParam = $this->app->Secure->GetGET('category', null, '', true);
$iconSearchString = $categoryFromParam;
if(strstr($categoryFromParam,'{|') === false){
$iconSearchString = '{|'.$categoryFromParam.'|}';
}
/** @var Appstore $appstore */
$appstore = $this->app->erp->LoadModul('appstore');
$iconTag = $appstore->GetAppIconTagByCategory($iconSearchString);
$html = '';
$appList = $appstore->GetApps();
$this->app->erp->Headlines(' ');
$overviewTile = $appstore->getOverViewFromCategory($categoryFromParam);
$this->app->Tpl->Set(
'CURRENTHEADLINES',
'Einstellungen / '. $categoryFromParam .''
);
$this->app->Tpl->Set('CATEGORY', $categoryFromParam);
if($overviewTile !== null) {
$html .= $this->createIconHtmlForCategory($overviewTile, $categoryFromParam, $iconTag);
}
foreach ($appList['installiert'] as $modul) {
$cleanCategory = str_replace(array('{|','|}'), '', $modul['kategorie']);
if ($categoryFromParam === $cleanCategory) {
$html .= $this->createIconHtmlForCategory($modul, $categoryFromParam, $iconTag);
}
}
$this->app->Tpl->Set('HTML', $html);
$this->app->Tpl->Parse('STANDARDMODULE', 'einstellungen_apptile.tpl');
$this->app->Tpl->Parse('TAB1', 'einstellungen_categorysite.tpl');
$this->app->Tpl->Parse('PAGE','tabview.tpl');
}
/**
* @param array $modul
* @param string $categoryFromParam
* @param string $iconTag
*
* @return string
*/
public function createIconHtmlForCategory($modul, $categoryFromParam, $iconTag)
{
$link = 'index.php?module='. $modul['key'] .'&action=list';
if(!empty($modul['Link'])) {
$link = $modul['Link'];
}
return ''.
''.
'' .
'' .
strip_tags($modul['Bezeichnung'])
.'
' .
(!empty($modul['ablaufdatum'])
? '{|Ablauf am|} '
. $this->app->String->Convert($modul['ablaufdatum'], '%1-%2-%3', '%3.%2.%1') . ''
: '')
. (!empty($modul['beta'])?' BETA':'')
. (!empty($modul['legacy']) && $modul['legacy']?' LEGACY':'')
. (!empty($modul['special']) && $modul['special']?' SPECIAL':'')
. (!empty($modul['project_sensitive']) && $modul['project_sensitive']?' PROJEKT':'')
. '
'
. '';
}
/**
* @param string $category
*
* @return string
*/
public function getCategoryLinkByCategory(string $category): string
{
switch($category) {
case '{|Versandarten|}':
return 'index.php?module=versandarten&action=list&overviewpage=einstellungen&overviewpageaction=list&backlinkparameter=einstellungen&backlinkparameter=list';
case '{|Zahlungsweisen|}':
return 'index.php?module=zahlungsweisen&action=list&overviewpage=einstellungen&overviewpageaction=list&backlinkmodule=einstellungen&backlinkparameter=list';
case '{|Shop Schnittstelle|}':
return 'index.php?module=onlineshops&action=list&overviewpage=einstellungen&overviewpageaction=list&backlinkmodule=einstellungen&backlinkparameter=list';
}
return 'index.php?module=einstellungen&action=category&category=' . str_replace(['{|', '|}'], '', $category);
}
public function EinstellungenList()
{
$this->app->erp->Headlines(' ');
$this->app->Tpl->Set('EMAILBACKUPLINK', 'href="index.php?module=emailbackup&action=list"');
if(!$this->app->erp->ModulVorhanden('emailbackup')){
$this->app->Tpl->Set('EMAILBACKUPLINK', '');
$this->app->Tpl->Set('GREYEMAILBACKUP','');
}
$this->app->Tpl->Set('TICKETVORLAGENLINK', 'href="index.php?module=ticket_vorlage&action=list"');
if(!$this->app->erp->ModulVorhanden('ticket_vorlage')){
$this->app->Tpl->Set('TICKETVORLAGENLINK', '');
$this->app->Tpl->Set('GREYTICKETVORLAGEN','');
}
$this->app->Tpl->Set('UEBERSETZUNGENLINK', 'href="index.php?module=uebersetzung&action=list"');
if(!$this->app->erp->ModulVorhanden('uebersetzung')){
$this->app->Tpl->Set('UEBERSETZUNGENLINK', '');
$this->app->Tpl->Set('GREYUEBERSETZUNGEN','');
}
$this->app->Tpl->Set('KOSTENSTELLENLINK', 'href="index.php?module=kostenstellen&action=list"');
if(!$this->app->erp->ModulVorhanden('kostenstellen')){
$this->app->Tpl->Set('KOSTENSTELLENLINK', '');
$this->app->Tpl->Set('GREYKOSTENSTELLEN','');
}
$this->app->Tpl->Set('ZOLLTARIFNUMMERLINK', 'href="index.php?module=zolltarifnummer&action=list"');
if(!$this->app->erp->ModulVorhanden('zolltarifnummer')){
$this->app->Tpl->Set('ZOLLTARIFNUMMERLINK', '');
$this->app->Tpl->Set('GREYZOLLTARIFNUMMER','');
}
$this->app->Tpl->Set('WARTESCHLANGENLINK', 'href="index.php?module=warteschlangen&action=list"');
if(!$this->app->erp->ModulVorhanden('warteschlangen')){
$this->app->Tpl->Set('WARTESCHLANGENLINK', '');
$this->app->Tpl->Set('GREYWARTESCHLANGEN','');
}
$this->app->Tpl->Set('GREYVERRECHNUNGSART','');
$this->app->Tpl->Set('GRUPPENLINK', 'href="index.php?module=gruppen&action=list"');
if(!$this->app->erp->ModulVorhanden('gruppen')){
$this->app->Tpl->Set('GRUPPENLINK', '');
$this->app->Tpl->Set('GREYGRUPPEN','');
}
$this->app->Tpl->Set('ARTIKELKATEGORIENLINK', 'href="index.php?module=artikelkategorien&action=list"');
if(!$this->app->erp->ModulVorhanden('artikelkategorien')){
$this->app->Tpl->Set('ARTIKELKATEGORIENLINK', '');
$this->app->Tpl->Set('GREYARTIKELKATEGORIEN','');
}
$this->app->Tpl->Set('USERVORLAGELINK', 'href="index.php?module=uservorlage&action=list"');
if(!$this->app->erp->ModulVorhanden('uservorlage')){
$this->app->Tpl->Set('USERVORLAGELINK', '');
$this->app->Tpl->Set('GREYUSERVORLAGE','');
}
$this->app->Tpl->Set('KONTENLINK', 'href="index.php?module=konten&action=list"');
if(!$this->app->erp->ModulVorhanden('konten')){
$this->app->Tpl->Set('KONTENLINK', '');
$this->app->Tpl->Set('GREYKONTEN','');
}
$this->app->Tpl->Set('KONTORAHMENLINK', 'href="index.php?module=kontorahmen&action=list"');
if(!$this->app->erp->ModulVorhanden('kontorahmen')){
$this->app->Tpl->Set('KONTORAHMENLINK', '');
$this->app->Tpl->Set('GREYKONTORAHMEN','');
}
$this->app->Tpl->Set('LIEFERBEDINGUNGENLINK', 'href="index.php?module=lieferbedingungen&action=list"');
if(!$this->app->erp->ModulVorhanden('lieferbedingungen')){
$this->app->Tpl->Set('LIEFERBEDINGUNGENLINK', '');
$this->app->Tpl->Set('GREYLIEFERBEDINGUNGEN','');
}
$this->app->Tpl->Set('ARBEITSFREIETAGELINK', 'href="index.php?module=arbeitsfreietage&action=list"');
if(!$this->app->erp->ModulVorhanden('arbeitsfreietage')){
$this->app->Tpl->Set('ARBEITSFREIETAGELINK', '');
$this->app->Tpl->Set('GREYARBEITSFREIETAGE','');
}
$this->app->Tpl->Parse('TAB1',"einstellungen.tpl");
//$this->app->Tpl->Set(TABTEXT,"Einstellungen");
$this->app->Tpl->Parse('PAGE',"tabview.tpl");
}
function EinstellungenMenu()
{
$id = $this->app->Secure->GetGET("id");
$this->app->Tpl->Add('TABS',"Einstellungen ");
$this->app->Tpl->Add('TABS',"Stückliste ");
$this->app->Tpl->Add('TABS',"Verkauf ");
$this->app->Tpl->Add('TABS',"Einkauf ");
$this->app->Tpl->Add('TABS',"Projekte ");
$this->app->Tpl->Add('TABS',"Lager ");
$this->app->Tpl->Add('TABS',"Dateien ");
$this->app->Tpl->Add('TABS',"Provisionen ");
$this->app->Tpl->Add('TABS',"Etiketten ");
//$this->app->Tpl->Add('TABS',"Gesamtkalkulation ");
$this->app->Tpl->Add('TABS',"Zurück zur Übersicht ");
}
function EinstellungenEdit()
{
$this->EinstellungenMenu();
$this->app->Tpl->Set('TABLE_ADRESSE_KONTAKTHISTORIE',"TDB");
$this->app->Tpl->Set('TABLE_ADRESSE_ROLLEN',"TDB");
$this->app->Tpl->Set('TABLE_ADRESSE_USTID',"TDB");
}
/**
* @param string $overviewPageAction
*
* @return string|null
*/
public function getOverViewLink($overviewPageAction): ?string
{
if(!in_array($overviewPageAction, ['', 'list'])) {
return null;
}
return 'index.php?module=einstellungen&action=list';
}
/**
* @param string $backlinkParameter
*
* @return string|null
*/
public function getBackLink($backlinkParameter): ?string
{
if($backlinkParameter === 'list') {
return 'index.php?module=einstellungen&action=list';
}
$appstore = $this->app->loadModule('appstore', false);
$appList = $appstore->GetApps();
foreach ($appList['installiert'] as $modul) {
$cleanCategory = str_replace(array('{|', '|}'), '', $modul['kategorie']);
if($cleanCategory === $backlinkParameter) {
return 'index.php?module=einstellungen&action=category&category='.urlencode($backlinkParameter);
}
}
return null;
}
}