2013 * * Hier werden alle Plugins, Widgets usw instanziert die * fuer die Anwendung benoetigt werden. * Diese Klasse ist von class.application.php abgleitet. * Das hat den Vorteil, dass man dort bereits einiges starten kann, * was man eh in jeder Anwendung braucht. * - DB Verbindung * - Template Parser * - Sicherheitsmodul * - String Plugin * - usw.... */ date_default_timezone_set('Europe/Berlin'); ini_set('default_charset', 'UTF-8'); ini_set('display_errors', 'on'); ini_set('magic_quotes_runtime', 0); require_once dirname(__DIR__).'/phpwf/class.application.php'; if( WithGUI(true)) { define('FPDF_FONTPATH',__DIR__.'/lib/pdf/font/'); if(file_exists(__DIR__."/lib/dokumente/class.briefpapier_custom.php")) { require_once __DIR__.'/lib/dokumente/class.briefpapier_custom.php'; }else{ require_once __DIR__.'/lib/dokumente/class.briefpapier.php'; } } include __DIR__.'/function_exists.php'; class erpooSystem extends Application { public $obj; public $starttime; public $endtime; protected $laendercache; protected $uselaendercache; /** @var erpAPI $erp * @var Config $Conf */ public function __construct($config,$group='') { $this->uselaendercache = false; parent::__construct($config, $group); if(WithGUI()){ $module = $this->Secure->GetGET('module'); $action = $this->Secure->GetGET('action'); $this->Tpl->Set('DASHBOARDLINK', 'index.php?module=welcome&action=start'); $this->help = new Help($this); $companyletter = strtoupper(substr($this->erp->Firmendaten('name'), 0, 1)); $this->Tpl->Set('COMPANYLETTER', ($companyletter != '' ? $companyletter : 'W')); if($this->erp->Firmendaten('modul_mlm') != '1'){ $this->Tpl->Set('STARTDISABLEMLM', ''); } if($this->erp->Firmendaten('modul_verband') != '1'){ $this->Tpl->Set('STARTDISABLEVERBAND', ''); } if($this->erp->Version() === 'stock'){ $this->Tpl->Set('DISABLEOPENSTOCK', ''); } $icons = array('adresse', 'artikel', 'angebot', 'auftrag', 'lieferschein', 'rechnung'); foreach ($icons as $icon) { if(!$this->erp->RechteVorhanden($icon, 'list')){ $this->Tpl->Set('ICON' . strtoupper($icon) . 'START', ''); } } $this->Tpl->Set(strtoupper($module) . 'ACTIVE', 'active'); if(is_file('js/' . $module . '.js')){ $md5 = md5_file('js/' . $module . '.js'); if(!is_file('js/' . $module . $md5 . '.js')) { @copy('js/' . $module . '.js', 'js/' . $module . $md5 . '.js'); } if(is_file('js/' . $module . $md5 . '.js')){ $this->Tpl->Set('JSSCRIPTS', ''); }else{ $this->Tpl->Set('JSSCRIPTS', ''); } } $this->erp->PrinterIcon(); $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/widgets/templates/_gen/'); $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/widgets/templates/'); $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/themes/' . $this->Conf->WFconf['defaulttheme'] . '/templates/'); $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/pages/content/_gen/'); $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/pages/content/'); if(is_dir(__DIR__ . '/lib/versandarten/content')) { $this->Tpl->ReadTemplatesFromPath(__DIR__ . '/lib/versandarten/content/'); } if(method_exists($this->erp, 'VersionsInfos')){ $ver = $this->erp->VersionsInfos(); if(stripos($ver['Info'], 'Beta') !== false || stripos($ver['Info'], 'Alpha') !== false || stripos($ver['Info'], 'DEV') !== false ) $this->Tpl->Set('VERSIONINFO', strtoupper($ver['Info'])); } $this->Tpl->Set('ID', $this->Secure->GetGET('id')); $this->Tpl->Set('POPUPWIDTH', '1200'); $this->Tpl->Set('POPUPHEIGHT', '800'); $this->Tpl->Set('YEAR', date('Y')); $this->Tpl->Set('COMMONREADONLYINPUT', ''); $this->Tpl->Set('COMMONREADONLYSELECT', ''); // templates laden //statisch überladen $this->Conf->WFconf['defaulttheme'] = 'new'; if(!empty($this->Conf->WFtestmode) && $this->Conf->WFtestmode == true) $this->Tpl->Set('BODYSTYLE', 'style=background-color:red'); } if(WithGUI(true)){ $benutzername = $this->erp->Firmendaten('benutzername'); $passwort = $this->erp->Firmendaten('passwort'); $host = $this->erp->Firmendaten('host'); $port = $this->erp->Firmendaten('port'); $mailssl = $this->erp->Firmendaten('mailssl'); $mailanstellesmtp = $this->erp->Firmendaten('mailanstellesmtp'); $noauth = $this->erp->Firmendaten('noauth'); $overviewpage = $this->Secure->GetGET('overviewpage'); $overviewpageAction = $this->Secure->GetGET('overviewpageaction'); $backlinkmodule = $this->Secure->GetGET('backlinkmodule'); $backlinkParameter = $this->Secure->GetGET('backlinkparameter'); // templates } if(WithGUI()){ $this->createSidebarNavigation(); $layout_iconbar = $this->erp->Firmendaten('layout_iconbar'); if($this->erp->Version() === 'stock'){ $this->Tpl->Set('STOCKOPEN', ''); } //nur wenn leiste nicht deaktiviert ist if($layout_iconbar != 1){ if($this->erp->Firmendaten('iconset_dunkel') == '1'){ $this->Tpl->Parse('ICONBAR', 'iconbar_dunkel.tpl'); } else{ $this->Tpl->Parse('ICONBAR', 'iconbar.tpl'); } }else{ $this->Tpl->Parse('ICONBAR', 'iconbar_empty.tpl'); } if($module !== 'kalender' && ($module !== 'welcome' && $action !== 'start')){ $this->Tpl->Add('YUICSS', '.ui-widget-content {}'); } $overviewLink = null; if(!empty($overviewpage)) { $obj = $this->loadModule($overviewpage, false); if($obj !== null && method_exists($obj, 'getOverViewLink')) { $overviewLink = $obj->getOverViewLink($overviewpageAction); } } $backlink = null; if(!empty($backlinkmodule)) { $obj = $this->loadModule($backlinkmodule, false); if($obj !== null && method_exists($obj, 'getBackLink')) { $backlink = $obj->getBackLink($backlinkParameter); } } // back to overview for case apps/einstellungen if($overviewLink !== null){ $this->Tpl->Set('BACKTOOVERVIEW', ''); } $this->Tpl->Set('MODULE', $module); $this->Tpl->Set('ACTION', $action); $this->Tpl->Set('THEME', $this->Conf->WFconf['defaulttheme']); $doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www $path = preg_replace("!^{$doc_root}!", '', __DIR__); $this->Tpl->Set('WEBPATH', $path); if(isset($backlink) && strpos($backlink,"index.php?module=") !== false && strpos($backlink, "&action=") !== false){ $this->Tpl->Set('TABSBACK', $backlink); } else { if($action === 'list' || $action == ''){ $this->Tpl->Set('TABSBACK', 'index.php'); } else{ $this->Tpl->Set('TABSBACK', "index.php?module=$module&action=list"); } } $this->Tpl->Set('SAVEBUTTON', ''); $this->help->Run(); $this->Tpl->Set('TMPSCRIPT', ''); $msg2 = $this->Secure->GetGET('msg'); $msgid = (int)$this->Secure->GetGET('msgid'); if($msgid && method_exists($this->erp, 'GetTmpMessageOut')){ $msg3 = $this->erp->GetTmpMessageOut($msgid); $this->Tpl->Set('MESSAGE', $msg3); }elseif($msg2 != ''){ $msg2 = $this->erp->base64_url_decode($msg2); $this->Tpl->Set('MESSAGE', $msg2); } unset($msg3); $module = $this->Secure->GetGET('module'); $this->Tpl->Set('MODULE', $module); if($module == ''){ $module = 'welcome'; } $this->Tpl->Set('ICON', $module); $id = $this->Secure->GetGET('id'); $this->Tpl->Set('KID', $id); // pruefe welche version vorliegt include dirname(__DIR__).'/version.php'; $this->Tpl->Set('REVISION', $this->erp->Revision() . ' (' . $this->erp->Branch() . ')'); $this->Tpl->Set('REVISIONID', $this->erp->RevisionPlain()); $this->Tpl->Set('BRANCH', $this->erp->Branch()); $this->Tpl->Set('LIZENZHINWEIS', '| Lizenzhinweis'); if($this->erp->Version() === 'OSS'){ $this->Tpl->Set('WAWIVERSION', 'Open-Source Lizenz AGPLv3.0'); } else if($this->erp->Version() === 'ENT'){ $this->Tpl->Set('WAWIVERSION', 'Enterprise Version'); } else if($this->erp->Version() === 'PRO'){ $this->Tpl->Set('WAWIVERSION', 'Professional Version'); } else if($this->erp->Version() === 'PRE'){ $this->Tpl->Set('WAWIVERSION', 'Premium Version'); } else{ $this->Tpl->Set('WAWIVERSION', 'Nutzungsbedingungen'); } $this->Tpl->Set('TIMESTAMP', time()); $this->Tpl->Set('THEME', $this->Conf->WFconf['defaulttheme']); $this->Tpl->Set('AKTIV_GEN_TAB1', 'selected'); if(file_exists(__DIR__ . '/pages/textvorlagen.php') && $this->Secure->GetGET('cmd') !== 'open'){ $showing = true; if($action === 'edit' && in_array($module, array('auftrag', 'angebot', 'rechnung', 'bestellung', 'lieferschein'))){ $id = (int)$this->Secure->GetGET('id'); if($id && $this->DB->Select("SELECT count(id) FROM " . $module . "_position WHERE $module = '$id'") > 100) { $showing = false; } } if($showing && $this->erp->RechteVorhanden('textvorlagen', 'show')){ /** @var \Xentral\Widgets\DataTable\Service\DataTableService $service */ $service = $this->Container->get('DataTableService'); $buildConfig = new \Xentral\Widgets\DataTable\DataTableBuildConfig( 'texttemplates', \Xentral\Modules\TextTemplate\DataTable\TextTemplateDataTable::class, 'index.php?module=textvorlagen&action=show&cmd=table', false ); $htmlData = $service->renderHtml($buildConfig); $this->Tpl->Add('TABTEXTVORLAGEN', $htmlData); $this->Tpl->Add('TVFILTERHEADER', '
Textvorlage suchen und einfügen
'); $this->YUI->AutoComplete('textvorlageprojekt', 'projektname', 1); $this->YUI->CkEditor('textvorlagetext', 'belege'); $this->Tpl->Add('JSSCRIPTS', $this->Tpl->OutputAsString('textvorlagen.tpl')); } } $isTestlizenz = !empty(erpAPI::Ioncube_Property('testlizenz')); $isCloud = erpAPI::Ioncube_Property('iscloud'); $isDemo = $isTestlizenz && $isCloud; $activateDoubleClick = false; /** @var Dataprotection $dataProtectionModule */ $dataProtectionModule = $this->loadModule('dataprotection'); if($isCloud && $dataProtectionModule !== null && $dataProtectionModule->isGoogleAnalyticsActive() ){ $activateDoubleClick = true; $this->Tpl->Add( 'SCRIPTJAVASCRIPT', ' '); $this->Tpl->Add('ADDITIONALCSPHEADER', ' www.googletagmanager.com www.google-analytics.com ssl.google-analytics.com stats.g.doubleclick.net '); } if($dataProtectionModule !== null && $dataProtectionModule->isHubspotActive()) { $activateDoubleClick = true; $this->Tpl->Add( 'SCRIPTJAVASCRIPT', '' ); $this->Tpl->Add( 'ADDITIONALCSPHEADER', ' js.hs-scripts.com js.hscollectedforms.net js.hsleadflows.net js.hs-banner.com js.hs-analytics.net api.hubapi.com js.hsadspixel.net ' ); $this->Tpl->Add( 'ADDITIONALCSPHEADER', 'forms.hubspot.com forms.hsforms.com track.hubspot.com www.google.com www.google.de ' ); } if($activateDoubleClick) { $this->Tpl->Add('ADDITIONALCSPHEADER', ' googleads.g.doubleclick.net ' ); } $hooktpl = 'JSSCRIPTS'; $this->erp->RunHook('eproosystem_ende', 1, $hooktpl); } } /** * @param {String} $path * @param {String} $category * * @return String */ public function getSVG($path, $filename){ $filename = str_replace(' ', '', strtolower($filename)); $iconPath = $path . $filename . '.svg'; return file_get_contents($iconPath); } protected function getCounterFor(string $type) { } /** * creates and appends sidebar navigation */ public function createSidebarNavigation(){ include dirname(__DIR__).'/version.php'; $appstore = $this->loadModule('appstore'); $svgPath = 'themes/new/images/sidebar/'; $activeModule = $this->Secure->GetGET('module'); $activeAction = $this->Secure->GetGET('action'); $navigation = $this->Page->CreateNavigation($this->erp->Navigation(), true, $activeModule, $activeAction); $activeCategory = $appstore->GetCategoryByModule($activeModule, $this->Secure->GetGET('id')); $appointmentCount = (int)$this->DB->Select( sprintf( "SELECT COUNT(ke.id) FROM kalender_event AS ke LEFT JOIN kalender_user AS ku ON ku.event=ke.id WHERE DATE_FORMAT(ke.von,'%%Y-%%m-%%d')=DATE_FORMAT(NOW(),'%%Y-%%m-%%d') AND ( ke.adresse=%d OR ke.adresseintern=%d OR ku.userid=%d )", $this->User->GetAdresse(),$this->User->GetAdresse(), $this->User->GetID() ) ); if($appointmentCount <=0) { $appointmentCount=0; } if($this->erp->ModulVorhanden('wiedervorlage') && $this->erp->RechteVorhanden('wiedervorlage','list')) { $resubmissionCount = (int)$this->DB->Select( sprintf( "SELECT count(*) FROM `wiedervorlage` AS `w` LEFT JOIN `adresse` AS `a` ON w.adresse = a.id LEFT JOIN `projekt` AS `p` on p.id = a.projekt WHERE w.abgeschlossen = 0 AND TIMESTAMP(concat(w.datum_erinnerung,' ',w.zeit_erinnerung)) < TIMESTAMP(now()) AND (w.adresse_mitarbeiter = %d OR (w.adresse_mitarbeiter=0 AND w.bearbeiter=%d)) ", $this->User->getAdresse(),$this->User->getAdresse() ).$this->erp->ProjektRechte('w.projekt') ); } // Creates user specific items $possibleUserItems = [ 'Tickets' => [ 'link' => 'index.php?module=ticket&action=list', 'counter' => $this->erp->AnzahlOffeneTickets() ], 'Aufgaben' => [ 'link' => 'index.php?module=aufgaben&action=list', 'counter' => $this->erp->AnzahlOffeneAufgaben() ], /* 'Wiedervorlage' => [ 'link' => 'index.php?module=wiedervorlage&action=list', 'counter' => $resubmissionCount, ],*/ 'Kalender' => [ 'link' => 'index.php?module=kalender&action=list', 'counter' => $appointmentCount ] ]; /* $possibleUserItems['Apps'] = [ 'link'=> 'index.php?module=appstore&action=list&cmd=allapps' ];*/ if(!empty(erpAPI::Ioncube_Property('testlizenz')) && $this->User->GetType() === 'admin'){ $possibleUserItems['Starte hier!'] = [ 'link' => 'index.php?module=learningdashboard&action=list', 'type' => 'cta' ]; } $userItems = ''; // Creates main navigation steps $naviHtml = ''; /** @var Dataprotection $obj */ $obj = $this->loadModule('dataprotection'); $showChat = method_exists('erpAPI','Ioncube_Property') && !empty(erpAPI::Ioncube_Property('chatactive')) && !empty(erpAPI::Ioncube_Property('chat')) && $obj !== null && method_exists($obj, 'isZenDeskActive') && $obj->isZenDeskActive(); $possibleFixedItems = []; if(!$showChat) { $possibleFixedItems['Hilfe'] = 'id="showinlinehelplink"'; } // Creates fixed bottom navigation items // $possibleFixedItems['Datenschutz'] = 'index.php?module=dataprotection&action=list'; $fixedItems = ''; $version = ''; if(isset($version_revision) && $version_revision != '') { $version .= ''; } if($userId = $this->User->GetID()){ /** @var \Xentral\Modules\User\Service\UserConfigService $userConfig */ $userConfig = $this->Container->get('UserConfigService'); $sidebarCollapsed = $userConfig->tryGet('sidebar_collapsed', $userId); $sidebarClasses = $sidebarCollapsed === true ? 'class="collapsed"' : ''; }else{ $sidebarClasses = ''; } // set generated HTML to template $this->Tpl->Set('USERITEMS', $userItems); $this->Tpl->Set('NAVIGATIONITEMS', $naviHtml); $this->Tpl->Set('FIXEDITEMS', $fixedItems); $this->Tpl->Set('XENTRALVERSION', $version); $this->Tpl->Set('SIDEBAR_CLASSES', $sidebarClasses); $isDevelopmentVersion = method_exists('erpAPI','Ioncube_Property') && !empty(erpAPI::Ioncube_Property('isdevelopmentversion')); if($isDevelopmentVersion) { $this->Tpl->Add( 'SIDEBARLOGO', @file_get_contents(__DIR__ . '/themes/new/templates/sidebar_development_version_logo.svg') ); $this->Tpl->Add( 'SIDEBARLOGO', 'logo' ); } else{ // $this->Tpl->Add('SIDEBARLOGO', @file_get_contents(__DIR__ . '/themes/new/templates/sidebar_logo.svg')); $this->Tpl->Add('SIDEBARLOGO',''); $this->Tpl->Add('SIDEBARLOGO',''); } $this->Tpl->Parse('SIDEBAR', 'sidebar.tpl'); $this->Tpl->Parse('PROFILE_MENU', 'profile_menu.tpl'); } /** * @return string */ public function CheckUserdata() { $isSecure = false; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { $isSecure = true; } elseif ((!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')) { $isSecure = true; } $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http'; if(!empty($_SERVER['SCRIPT_URI'])) { $weburl = $_SERVER['SCRIPT_URI']; }elseif(!empty($_SERVER['REQUEST_URI']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']!=='::1' && (empty($_SERVER['SERVER_SOFTWARE']) || strpos($_SERVER['SERVER_SOFTWARE'],'nginx')===false)) { $weburl = (isset($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR']?$REQUEST_PROTOCOL.'://'.$_SERVER['SERVER_ADDR'].(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443?':'.$_SERVER['SERVER_PORT']:''):'').$_SERVER['REQUEST_URI']; } elseif(!empty($_SERVER['SERVER_NAME'])) //MAMP auf macos { $weburl = str_replace(array('setup/setup.php?step=5','setup/setup.php'),'',$REQUEST_PROTOCOL.'://'.$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'].$_SERVER['SCRIPT_NAME']); }else{ $weburl = ''; } $userdatadir = $this->Conf->WFuserdata; $tmpfile = md5(microtime(true)).'.html'; $ret = ''; if(!file_put_contents(rtrim($userdatadir,'/').'/'.$tmpfile,'TEST')){ $ret = 'Das Verzeichnis userdata ist nicht schreibbar (Rechte) oder die Festplatte ist voll'; } if(!empty($weburl) && stripos($weburl, 'http') !== 0) { if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){ unlink(rtrim($userdatadir,'/').'/'.$tmpfile); } if(method_exists($this->erp, 'setSystemHealth')) { $this->erp->setSystemHealth('server', 'userdata_writeable',!empty($ret)?'warning':'ok', $ret); } return $ret; } $pos = strpos($weburl,'index.php'); if($pos){ $weburl = rtrim(substr($weburl, 0 , $pos),'/'); } $thisfoldera = explode('/',__DIR__); $userdataa = explode('/',$this->Conf->WFuserdata); foreach($thisfoldera as $k => $v) { if(isset($userdataa[$k]) && $userdataa[$k] == $v) { unset($userdataa[$k], $thisfoldera[$k]); } } $userdata = trim(implode('/', $userdataa),'/'); $thisfolder = trim(implode('/', $thisfoldera),'/'); if(substr($weburl, - strlen($thisfolder)) == $thisfolder) { $userdata = substr($weburl , 0, strlen($weburl) - strlen($thisfolder)).$userdata.'/'; }else { if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){ unlink(rtrim($userdatadir,'/').'/'.$tmpfile); } if(method_exists($this->erp, 'setSystemHealth')) { $this->erp->setSystemHealth('server', 'userdata_writeable', 'ok'); } return $ret; } if(is_dir($userdatadir)) { $content = @file_get_contents($userdata); if($content != '') { if(is_file(rtrim($userdatadir, '/') . '/' . $tmpfile)){ unlink(rtrim($userdatadir, '/') . '/' . $tmpfile); } $ret = 'Sicherheitswarnung: Verzeichnis userdata ist von extern einsehbar' . ($ret === '' ? '' : ' und nicht beschreibbar') . '!'; if(method_exists($this->erp, 'setSystemHealth')){ $this->erp->setSystemHealth('server', 'userdata_writeable', 'error', $ret); } return $ret; } if(file_put_contents(rtrim($userdatadir,'/').'/'.$tmpfile,'TEST')) { if(@file_get_contents($userdata . $tmpfile) === 'TEST') { unlink(rtrim($userdatadir, '/') . '/' . $tmpfile); $ret = 'Sicherheitswarnung: Verzeichnis userdata ist von extern einsehbar' . ($ret === '' ? '' : ' und nicht beschreibbar') . '!'; if(method_exists($this->erp, 'setSystemHealth')){ $this->erp->setSystemHealth('server', 'userdata_writeable', 'error', $ret); } return $ret; } unlink(rtrim($userdatadir,'/').'/'.$tmpfile); if(method_exists($this->erp, 'setSystemHealth')) { $this->erp->setSystemHealth('server', 'userdata_writeable', 'ok'); } return ''; } } if(is_file(rtrim($userdatadir,'/').'/'.$tmpfile)){ unlink(rtrim($userdatadir,'/').'/'.$tmpfile); } $this->erp->setSystemHealth('server', 'userdata_writeable', 'ok'); return $ret; } public function calledBeforeFinish() { } public function Laender($module, $action, $id, $lid) { /*********** select field for projekt ***************/ $selectid = $this->Secure->GetPOST('projekt'); if($selectid=='' && $module !== 'projekt') { /* Removed because of module tables that have no projekt id if(!empty($this->Conf->WFdbType) && $this->Conf->WFdbType==='postgre') { //POSTGRE --> dringend bei statements wo es die tabelle gibt machen! $selectid = $this->DB->Select("SELECT projekt FROM `$module` WHERE id='$id' LIMIT 1"); } else { $selectid = $id > 0?$this->DB->Select("SELECT projekt FROM `$module` WHERE id='$id' LIMIT 1"):NULL; }*/ } $color_selected = ''; $options = $this->erp->GetProjektSelect($selectid,''); $this->Tpl->Set('EPROO_SELECT_PROJEKT',""); $this->Tpl->Set('EPROO_SELECT_UNTERPROJEKT','
'); $this->Tpl->Set('LESEZEICHEN','Angebotssuche '); $this->Tpl->Add('LESEZEICHEN','Auftragssuche '); $this->Tpl->Add('LESEZEICHEN','Rechnungssuche '); $this->Tpl->Add('LESEZEICHEN','Adressensuche '); $this->Tpl->Add('LESEZEICHEN','Paket Annahme'); $this->Tpl->Set('KURZUEBERSCHRIFT',$module); if($action==='edit'){ $this->Tpl->Add('KURZUEBERSCHRIFT1', 'BEARBEITEN'); } $this->Tpl->Set('KURZUEBERSCHRIFTFIRSTUPPER',ucfirst($module)); /*********** select field for projekt ***************/ if($this->Secure->GetPOST('land')=='' && $this->Secure->GetGET('land')=='') { if(in_array($module, array('adresse', 'adresse_import', 'anfrage', 'angebot', 'ansprechpartner', 'arbeitsnachweis', 'auftrag', 'belege', 'belegegesamt', 'belegeregs', 'bestellung', 'bundesstaaten', 'dokumente', 'gutschrift', 'inventur', 'laendersteuersaetze', 'lieferadressen', 'lieferschein', 'preisanfrage', 'produktion', 'proformarechnung', 'projekt', 'rechnung', 'retoure', 'serviceauftrag', 'shopexport_sprachen', 'shopexport_versandarten', 'spedition', 'spedition_packstuecke', 'steuertexte', 'ustprf', 'verpackungen_details'))) { $countryField = 'land'; if ($module === 'retoure') { $countryField = 'lieferland'; } $sqlCountry = sprintf('SELECT %s FROM `%s` WHERE id = %d LIMIT 1', $countryField, $module, $id); $selectid = $id ? $this->DB->Select($sqlCountry) : ''; }else{ $selectid = ''; } if(empty($selectid)) { $selectid = $lid?$this->DB->Select("SELECT land FROM `lieferadressen` WHERE id='$lid' LIMIT 1"):''; } } else if($this->Secure->GetGET('land')!=''){ $selectid = $this->Secure->GetGET('land'); } else{ $selectid = $this->Secure->GetPOST('land'); } /*********** select field for projekt ***************/ if($module==='adresse' && $this->Secure->GetPOST('rechnung_land')=='' && $this->Secure->GetGET('rechnung_land')=='') { $selectidrechnung = $id?$this->DB->Select("SELECT rechnung_land FROM adresse WHERE id='$id' LIMIT 1"):''; } else{ $selectidrechnung = $this->Secure->GetPOST('rechnung_land'); } /*********** select field for projekt ***************/ $lid = $this->Secure->GetGET('lid'); if($module==='adresse' && $this->Secure->GetPOST('ansprechpartner_land')=='' && $this->Secure->GetGET('ansprechpartner_land')=='') { $selectidansprechpartner = $lid?$this->DB->Select("SELECT ansprechpartner_land FROM ansprechpartner WHERE id='$lid' LIMIT 1"):''; if(empty($selectidansprechpartner)) { $selectidansprechpartner = $this->DB->Select("SELECT land FROM adresse WHERE id='$id' LIMIT 1"); } //if($selectid<=0 && $module=="lieferadressepopup") $this->DB->Select("SELECT land FROM `lieferadressen` WHERE id='$id' LIMIT 1"); } else{ $selectidansprechpartner = $this->Secure->GetPOST('ansprechpartner_land'); } if($module==='adresse' && $this->Secure->GetPOST('land')=='' && $this->Secure->GetGET('land')=='') { $selectidlieferadresse = $lid?$this->DB->Select("SELECT land FROM lieferadressen WHERE id='$lid' LIMIT 1"):''; if($selectidlieferadresse =='') { $selectidlieferadresse = $this->DB->Select("SELECT land FROM adresse WHERE id='$id' LIMIT 1"); } } else{ $selectidlieferadresse = $this->Secure->GetPOST('land'); } if($module==='proformarechnung' && $this->Secure->GetPOST('verzollungland')=='' && $this->Secure->GetGET('verzollungland')=='') { $selectidverzollung = $this->DB->Select("SELECT verzollungland FROM proformarechnung WHERE id='$id' LIMIT 1"); } else{ $selectidverzollung = $this->Secure->GetPOST('land'); } $this->uselaendercache = true; $this->Tpl->Set('EPROO_SELECT_LAND',""); $this->Tpl->Set('EPROO_SELECT_LIEFERLAND',""); $this->Tpl->Set('EPROO_SELECT_LAND_RECHNUNG',""); $this->Tpl->Set('EPROO_SELECT_LAND_ANSPRECHPARTNER',""); $this->Tpl->Set('EPROO_SELECT_LAND_LIEFERADRESSEN',""); $this->Tpl->Set('EPROO_SELECT_LAND_VERZOLLUNG',""); $this->uselaendercache = false; if($this->Secure->GetPOST('lieferland')=='') { if(in_array($module,array('amazon_inboundshipmentplan', 'angebot', 'auftrag', 'bestellung', 'produktion', 'proformarechnung', 'retoure', 'serviceauftrag', 'spedition'))) { $selectid = $id?$this->DB->Select("SELECT lieferland FROM `$module` WHERE id='$id' LIMIT 1"):''; }else { $selectid = ''; } } else{ $selectid = $this->Secure->GetPOST('lieferland'); } $this->Tpl->Set('EPROO_SELECT_LIEFERLAND',''); $this->Tpl->Set('VORGAENGELINK',"*"); if($module==='adresse' || $module==='artikel' || $module==='angebot' || $module==='rechnung' || $module==='auftrag' || $module==='gutschrift' || $module==='lieferschein' || $module==='onlineshops' || $module==='geschaeftsbrief_vorlagen' || $module==='emailbackup' || $module==='ticket_vorlage') { // module auf richtige tabellen mappen if($module==='onlineshops') { $this->erp->Standardprojekt('shopexport',$id); } else { $this->erp->Standardprojekt($module,$id); } $bezeichnungaktionscodes = $this->erp->Firmendaten('bezeichnungaktionscodes'); if((String)$bezeichnungaktionscodes === ''){ $bezeichnungaktionscodes = 'Aktionscode'; } $this->Tpl->Set('BEZEICHNUNGAKTIONSCODE', $bezeichnungaktionscodes); } } /** * @param string $module * @param string $action * @param int $id */ public function addPollJs($module, $action, $id) { $noTimeoutUserEdit = 0; $startTime = 3000; $repeatTime = 5000; $firmendaten_repeattime = 1000*(int)$this->erp->Firmendaten('poll_repeattime'); if($firmendaten_repeattime > $repeatTime) { $repeatTime = $firmendaten_repeattime; if($repeatTime > 25000) { $repeatTime = 25000; } } $invisibleTime = 25000; if(empty($id) || ( in_array($module, ['auftrag','rechnung','gutschrift','angebot','lieferschein'], false) && $this->DB->Select( sprintf( 'SELECT schreibschutz FROM `%s` WHERE id = %d', $module, $id ) ) ) ) { $noTimeoutUserEdit = 1; } if($action !== 'positionen'){ $pollUid = sha1(uniqid('poll', true)); $this->Tpl->Add('JAVASCRIPT', " var logErrorCount = 0; var hidden, visibilityChange; if (typeof document.hidden !== \"undefined\") { // Opera 12.10 and Firefox 18 and later support hidden = \"hidden\"; visibilityChange = \"visibilitychange\"; } else if (typeof document.msHidden !== \"undefined\") { hidden = \"msHidden\"; visibilityChange = \"msvisibilitychange\"; } else if (typeof document.webkitHidden !== \"undefined\") { hidden = \"webkitHidden\"; visibilityChange = \"webkitvisibilitychange\"; } function showLockScreen(errorMsg) { logErrorCount++; if (typeof errorMsg !== 'undefined' && errorMsg !== null) { console.error('Polling error: ' + errorMsg); } if (typeof LockScreen === 'undefined') { return; } if(logErrorCount <= 2) { return; } LockScreen.show(); } function hideLockScreen() { if (typeof LockScreen === 'undefined') { return; } LockScreen.hide(); } // Benutzer hat Sperrbildschirm per Button geschlossen // => Sperrbildschirm schliessen und Counter zurücksetzen function resetLockScreen() { if (typeof LockScreen === 'undefined') { return; } LockScreen.hide(); logErrorCount = 0; } var isloggedin = true; function executeQuery() { if(typeof generate == 'undefined'){ return; } $.ajax({ url: 'index.php?module=welcome&action=poll&smodule=$module&cmd=messages&saction=$action&sid=$id&user=" . $this->User->GetID().(!empty($noTimeoutUserEdit)?'&nousertimeout=1':'') . "&uid=".$pollUid."', type: 'POST', data:{ invisible : typeof document.hidden != 'undefined'? (document.hidden?1:0): (typeof document.msHidden !== 'undefined'? (document.msHidden?1:0):(typeof document.webkitHidden != 'undefined'?(document.webkitHidden?1:0):2)) }, success: function(data) { if (data === '') { showLockScreen('Polling result is empty.'); return; } // do something with the return value here if you like try { var meinelist = JSON.parse(data); } catch (err) { showLockScreen('JSON parse error (' + err + ')'); return; } logErrorCount = 0; // Hide lock screen on successful request hideLockScreen(); for(var i=0;i