');
$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;iUser->GetName();
$usernameArray = explode(' ', $username);
$usernameWordsLength = count($usernameArray);
// Replace the last part of the username by it's abbreviation; example "Sepp Maier" => "Sepp M."
if($usernameWordsLength > 1){
$lastName = array_pop($usernameArray);
$lastName = mb_substr($lastName, 0, 1) . '.';
$username = implode(' ', $usernameArray) . ' ' . $lastName;
}
return $username;
}
public function calledWhenAuth($type)
{
if(!WithGUI()){
return;
}
$id = $this->Secure->GetGET('id');
$lid = $this->Secure->GetGET('lid');
$module = $this->Secure->GetGET('module');
$action = $this->Secure->GetGET('action');
// Check Timeout Users
$this->DB->Update('UPDATE useronline SET login=0 WHERE DATE_ADD(time,INTERVAL '.(int)$this->Conf->WFconf['logintimeout'].' second) < NOW() AND login=1');
if($this->DB->affected_rows() > 0) {
$this->User->createCache();
}
// userd edit ajax call
$poll = true;
if($poll) {
$this->addPollJs($module, $action, $id);
}
/** @var Ajax $ajax */
$ajax = $this->loadModule('ajax');
$this->Tpl->Set('PROFILEPICTURE', $ajax->getProfileHtml($this->User->GetID(), 'Profilbild', null, 38));
$this->Tpl->SetText('USERID',$this->User->GetID());
$this->Tpl->SetText('USERNAME_SHORTENED',$this->getShortenedUsername());
$this->Tpl->SetText('BENUTZER',$this->User->GetName());
$this->Tpl->Set('CALENDERWEEK',date('W'));
$this->Tpl->Set('CALENDERWEEKMAX',date('W', date(mktime(0, 0, 0, 1, 1, date('Y')+1) - 4*86400)));
$this->Tpl->Set('VERSIONUNDSTATUS','Server: '.$_SERVER['SERVER_NAME'].' | Client: '.$_SERVER [ 'REMOTE_ADDR' ].' | User: '.$this->User->GetDescription());
$this->Tpl->Set('SERVERDATE','Serverzeit: '.date('d.m.Y H:i').' Uhr');
$this->Tpl->SetText('MODUL',ucfirst($module));
$this->Tpl->Set('HTMLTITLE','{|[MODUL]|} | Xenomporio ');
switch($module)
{
case 'artikel':
switch($action) {
case 'einkaufeditpopup':
$artikeltmpid = $this->DB->Select("SELECT artikel FROM einkaufspreise WHERE id='$id' LIMIT 1");
break;
case 'verkaufeditpopup':
$artikeltmpid = $this->DB->Select("SELECT artikel FROM verkaufspreise WHERE id='$id' LIMIT 1");
break;
default: $artikeltmpid = $id;
}
if (!empty($artikeltmpid)) {
$this->Tpl->AddText('HTMLTITLE','| '.$this->DB->Select("SELECT CONCAT(nummer,' ',name_de) FROM artikel WHERE id='$artikeltmpid' LIMIT 1"));
}
break;
case 'angebot':
case 'auftrag':
case 'rechnung':
case 'lieferschein':
case 'gutschrift':
case 'bestellung':
case 'anfrage':
if (!empty($id)) {
$this->Tpl->AddText('HTMLTITLE','| '.$this->DB->Select("SELECT CONCAT(if(belegnr!='',belegnr,'ENTWURF'),' ',name) FROM $module WHERE id='$id' lIMIT 1"));
}
break;
}
$firmenname = $this->erp->Firmendaten('name');
$firmenfarbe = $this->erp->Firmendaten('firmenfarbe');
$this->Tpl->SetText('FIRMENNAME',$firmenname);
$this->Tpl->Set('NBBREITE','275');
$this->Tpl->Set('NBPROZ','25');
$class = '';
$checkkommen = $this->DB->Select("SELECT kommen FROM stechuhr WHERE adresse='".$this->User->GetAdresse()."' ORDER by datum DESC LIMIT 1");
if($checkkommen!=0)
{
$kommen = ' Arbeit ';
}
else
{
$class = 'red';
$kommen = ' Pause';
}
$this->Tpl->Set('STECHUHRCLASS', $class);
$this->Tpl->Set('STECHUHR',$kommen);
$tmpfirmendatenfkt = 'Firmendaten';
if(method_exists($this->erp,'TplFirmendaten')){
$tmpfirmendatenfkt = 'TplFirmendaten';
}
$firmenfarbe = $this->erp->$tmpfirmendatenfkt('firmenfarbe');
if($firmenfarbe ==''){
$firmenfarbe = '#48494b';
}
$firmenfarbehell = $this->erp->$tmpfirmendatenfkt('firmenfarbehell');
if($firmenfarbehell ==''){
$firmenfarbehell = '#c2e3ea';
}
$firmenfarbedunkel = $this->erp->$tmpfirmendatenfkt('firmenfarbedunkel');
if($firmenfarbedunkel ==''){
$firmenfarbedunkel = '#53bed0';
}
$firmenfarbeganzdunkel = $this->erp->$tmpfirmendatenfkt('firmenfarbeganzdunkel');
if($firmenfarbeganzdunkel ==''){
$firmenfarbeganzdunkel = '#018fa3';
}
$navigationfarbeschrift = $this->erp->$tmpfirmendatenfkt('navigationfarbeschrift');
if($navigationfarbeschrift ==''){
$navigationfarbeschrift = '#c9c9cb';
}
$navigationfarbe = $this->erp->$tmpfirmendatenfkt('navigationfarbe');
if($navigationfarbe ==''){
$navigationfarbe = $firmenfarbe;
}
$navigationfarbeschrift2 = $this->erp->$tmpfirmendatenfkt('navigationfarbeschrift2');
if($navigationfarbeschrift2 =='')
{
$navigationfarbeschrift2 = $navigationfarbe;
}
$navigationfarbe2 = $this->erp->$tmpfirmendatenfkt('navigationfarbe2');
if($navigationfarbe2 ==''){
$navigationfarbe2 = $navigationfarbeschrift;
}
$this->Tpl->Set('COLORCSS','--color1: '.$firmenfarbehell.';'."\r\n");
$this->Tpl->Add('COLORCSS','--color2: '.$firmenfarbedunkel.';');
if($this->erp->Firmendaten('firmenhoherformularkontrast'))
{
$this->Tpl->Add('COLORCSS','--textfield-border: #666;');
}else{
$this->Tpl->Add('COLORCSS','--textfield-border: #d9d9d9;');
}
$this->Tpl->Set('COLORCSSFILE','color3.css');
if(($module!=='welcome' && $action!=='start') && is_file('./themes/new/css/grid_cache.css')){
$this->Tpl->Add('CSSLINKS', '');
}
else{
$this->Tpl->Add('CSSLINKS', '');
}
if(($module!=='welcome' && $action!=='start') && ($module!=='kalender' && $action!=='list') && is_file('./themes/new/css/style_cache.css')){
$this->Tpl->Add('CSSLINKS', '');
}
else{
$this->Tpl->Add('CSSLINKS', '');
}
if(($module!=='welcome' && $action!=='start') && ($module!=='kalender' && $action!=='list') && is_file('./themes/new/css/popup_cache.css')){
$this->Tpl->Set('CSSLINKSPOPUP', '');
}
else{
$this->Tpl->Set('CSSLINKSPOPUP', '');
}
if(is_file('./themes/new/css/custom.css')){
$this->Tpl->Set('FINALCSSLINKS', '');
}
if(is_file('./js/custom.js')){
$this->Tpl->Add('CSSLINKS', '');
}
if(is_file('./themes/new/css/custom_popup.css')){
$this->Tpl->Set('FINALCSSLINKSPOPUP', '');
}
if(!empty($this->Conf->WFtestmode) && $this->Conf->WFtestmode==true)
{
$this->Tpl->Set('TPLLOGOFIRMA','./themes/new/images/xentral_logo_testmode.png');
} elseif(is_file('./themes/new/images/logo_cache.png')){
$this->Tpl->Set('TPLLOGOFIRMA', './themes/new/images/logo_cache.png');
}elseif($this->erp->Firmendaten('firmenlogoaktiv')!='1')
{
$this->Tpl->Set('TPLLOGOFIRMA', './themes/new/images/xentral_logo.svg');
}else{
$this->Tpl->Set('TPLLOGOFIRMA', './index.php?module=welcome&action=logo');
}
if($this->erp->Firmendaten('iconset_dunkel')!='1')
{
$this->Tpl->Set('HAMBURGERICON','menue_hgr.png');
$this->Tpl->Set('HAMBURGERICONALT','menue_gr.png');
}else{
$this->Tpl->Set('HAMBURGERICON','menue_gr.png');
$this->Tpl->Set('HAMBURGERICONALT','menue_gr.png');
}
$this->Tpl->Set('TPLNAVIGATIONFARBE',$navigationfarbe);
$this->Tpl->Set('TPLNAVIGATIONFARBE2',$navigationfarbe2);
$this->Tpl->Set('TPLNAVIGATIONFARBESCHRIFT',$navigationfarbeschrift);
$this->Tpl->Set('TPLNAVIGATIONFARBESCHRIFT2',$navigationfarbeschrift2);
$this->Tpl->Set('TPLUNTERNAVIGATIONFARBE',$this->erp->$tmpfirmendatenfkt('unternavigationfarbe'));
$this->Tpl->Set('TPLUNTERNAVIGATIONFARBESCHRIFT',$this->erp->$tmpfirmendatenfkt('unternavigationfarbeschrift'));
$bordertabnav = 0;
if($this->erp->Firmendaten('bordertabnav')){
$bordertabnav = 1;
}
$this->Tpl->Set('TPLBORDERTABNAV',$bordertabnav);
}
/**
* Draw Warning and Info-Boxes
*/
public function HeaderBoxen()
{
$themeheader = '';
if($this->User->GetType() === 'admin') {
if(method_exists($this->erp,'setSystemHealth')) {
$letzteraufruf = $this->erp->GetKonfiguration('prozessstarter_letzteraufruf');
$diff = time() - strtotime($letzteraufruf);
$lastRunning = date('d.m.Y H:i:s', strtotime($letzteraufruf));
if($diff > 60 * 5 + 1) // mit sicherheitsabstand :-)
{
$status = 'warning';
}
else{
$status = 'ok';
}
$this->erp->setSystemHealth(
'cronjobs', 'lastrunning', $status, 'Letzte Ausführung: ' . $lastRunning
);
}
if($this->erp->GetKonfiguration('eproosystem_skipcheckuserdata') != '1') {
$time = microtime(true);
$this->CheckUserdata();
if(microtime(true) - $time > 5) {
$this->erp->SetKonfigurationValue('eproosystem_skipcheckuserdata', '1');
}
}
if(!$this->erp->ServerOK()) {
$serverlist = $this->erp->GetIoncubeServerList();
if(method_exists($this->erp, 'setSystemHealth')) {
$this->erp->setSystemHealth(
'server',
'ioncube',
'error',
'Die Ioncube-Lizenz ist nur gültig für folgene'.
(count($serverlist) == 1?'n':'').' Server: '.implode(', ',$serverlist)
);
}
}
else {
$expDays = erpAPI::Ioncube_ExpireInDays();
$testLicence = erpAPI::Ioncube_Property('testlizenz');
if(!$testLicence && $expDays !== false && $expDays < 14) {
$this->erp->setSystemHealth(
'server',
'ioncube',
'error',
sprintf(
'Die Lizenz am %s aus.',
erpAPI::Ioncube_ExpireDate()
)
);
}
else{
$this->erp->setSystemHealth(
'server',
'ioncube',
'ok',
''
);
}
}
if ($this->ModuleScriptCache->IsCacheDirWritable() === false) {
$this->erp->setSystemHealth(
'server',
'cache',
'error',
'Cache-Verzeichnis ist nicht beschreibbar! Bitte /www/cache/ beschreibbar machen.'
);
}
else {
$this->erp->setSystemHealth(
'server',
'cache',
'ok',
'Cache-Verzeichnis ist beschreibbar.'
);
}
}
$this->Tpl->Add('THEMEHEADER', $themeheader);
$doppeltenummerncheckCronjob = $this->DB->Select(
"SELECT id FROM prozessstarter WHERE parameter = 'doppeltenummerncheck' AND aktiv = 1 LIMIT 1"
);
if(!$doppeltenummerncheckCronjob
&& $this->erp->RechteVorhanden('mhdwarning','list') && $this->erp->Firmendaten('modul_mhd')=='1') {
$checkmhd = $this->DB->SelectArrCache(
'SELECT ROUND(SUM(menge),0)
FROM lager_mindesthaltbarkeitsdatum
WHERE DATEDIFF(NOW(),mhddatum) > 0',
$doppeltenummerncheckCronjob?86400:300,
'mhdwarning'
);
if(!empty($checkmhd)) {
$checkmhd = reset($checkmhd);
if(!empty($checkmhd)) {
$checkmhd = reset($checkmhd);
}
}
$checkmhd = round($checkmhd);
$checkmhdwarnung = $this->DB->SelectArrCache(
'SELECT ROUND(SUM(menge),0)
FROM lager_mindesthaltbarkeitsdatum
WHERE DATEDIFF(NOW(),mhddatum) + '.($this->erp->Firmendaten('mhd_warnung_tage')+1).' > 0',
$doppeltenummerncheckCronjob?86400:3600,
'mhdwarning'
);
if(!empty($checkmhdwarnung)) {
$checkmhdwarnung = reset($checkmhdwarnung);
if(!empty($checkmhdwarnung)) {
$checkmhdwarnung = reset($checkmhdwarnung);
}
}
$checkmhdwarnung = round($checkmhdwarnung);
$checkmhdwarnung -= $checkmhd;
if($checkmhd > 0 || $checkmhdwarnung > 0) {
$this->erp->SetKonfigurationValue('eproosystem_mhdwarning', 1);
$module = $this->Secure->GetGET('module');
if(!$doppeltenummerncheckCronjob) {
if($module === 'lager' || $module === 'mhdwarning' || $module === 'lagermobil'){
if($this->erp->GetKonfiguration('eproosystem_mhdwarning')){
$this->erp->ClearSqlCache('mhdwarning', 120);
}else{
$this->erp->ClearSqlCache('mhdwarning', 600);
}
}
}
if($checkmhd <=0) {
$checkmhd=0;
}
if($checkmhd==1) {
$ist = 'ist';
}
else {
$ist='sind';
}
$type = 'warning';
$link = 'Prüfen';
if($checkmhdwarnung) {
$text="$checkmhdwarnung Artikel laufen bald ab.";
}
if($checkmhd) {
$type = 'error';
$text2="$checkmhd Artikel $ist abgelaufen!";
}
if(!empty($text) && !empty($text2)) {
$text_out = $text.' '.$text2.' '.$link;
}
elseif(!empty($text) && empty($text2)) {
$text_out = $text.' '.$link;
}
else {
$text_out = $text2.' '.$link;
}
if(method_exists($this->erp,'setSystemHealth')){
$this->erp->setSystemHealth(
'bestbeforebatchsn', 'bestbefore', $type,
'Mindesthaltbarkeitsdatum: ' . $text_out
);
}
}
else {
if(method_exists($this->erp,'setSystemHealth')) {
$this->erp->setSystemHealth('bestbeforebatchsn', 'bestbefore', 'ok');
}
$this->erp->SetKonfigurationValue('eproosystem_mhdwarning', 0);
}
}
if($this->erp->Firmendaten('warnung_doppelte_nummern')=='1') {
if(method_exists($this->erp, 'ClearSqlCache')
&& $this->Secure->GetGET('action') === 'edit'
&& !$doppeltenummerncheckCronjob
) {
$module = $this->Secure->GetGET('module');
switch($module) {
case 'artikel':
case 'rechnung':
case 'gutschrift':
case 'adresse':
if($this->erp->GetKonfiguration('eproosystem_'.$module)) {
$this->erp->ClearSqlCache($module, 60);
}
else {
$this->erp->ClearSqlCache($module, 120);
}
break;
}
}
$link = '';
$belege = '';
$gutschrift_check = 0;
$rechnung_check = 0;
$kundennummer_check = 0;
if(!$doppeltenummerncheckCronjob){
$check_double_doppeltekundennummer = $this->DB->SelectArrCache(
"SELECT adr.kundennummer,count(adr.id) as NumOccurrences
FROM adresse adr
LEFT JOIN projekt pr ON adr.projekt = pr.id
WHERE adr.geloescht = 0 AND (adr.projekt = 0 OR pr.eigenernummernkreis = 0) AND adr.kundennummer <> ''
GROUP BY adr.kundennummer
HAVING COUNT(adr.kundennummer) > 1
LIMIT 100",
$doppeltenummerncheckCronjob ? 86400 : 300,
'adresse'
);
if($check_double_doppeltekundennummer && count($check_double_doppeltekundennummer)>0) {
$this->erp->SetKonfigurationValue('eproosystem_adresse', 1);
$ccheck_double_doppeltekundennummer = count($check_double_doppeltekundennummer);
for($icheck=0;$icheck<$ccheck_double_doppeltekundennummer;$icheck++) {
$belege .= ' ' . $check_double_doppeltekundennummer[$icheck]['kundennummer'];
}
$gesamt_gutschrift= count($check_double_doppeltekundennummer);
if(method_exists($this->erp,'setSystemHealth')) {
$this->erp->setSystemHealth('masterdata', 'double_customernumber', 'error',
$link.'Achtung: Doppelte Kundennummern! (Gesamt '.
$gesamt_gutschrift.') *'.
($link?'':'')
);
}
$kundennummer_check=1;
}
else {
$this->erp->SetKonfigurationValue('eproosystem_adresse', 0);
if(method_exists($this->erp,'setSystemHealth')) {
$this->erp->setSystemHealth('masterdata', 'double_customernumber', 'ok');
}
}
}
if(!$doppeltenummerncheckCronjob){
$check_double_gutschrift = $this->DB->SelectArrCache(
"SELECT b.belegnr, COUNT(b.belegnr) AS NumOccurrences
FROM gutschrift b
LEFT JOIN projekt pr ON b.projekt = pr.id
WHERE b.status!='angelegt' AND b.belegnr <> ''
GROUP BY b.belegnr, if(ifnull(pr.eigenernummernkreis,0) = 0,0,pr.id)
HAVING ( COUNT(b.belegnr) > 1 )",
$doppeltenummerncheckCronjob ? 86400 : 600,
'gutschrift'
);
if($check_double_gutschrift && count($check_double_gutschrift) > 0){
$this->erp->SetKonfigurationValue('eproosystem_gutschrift', 1);
$ccheck_double_gutschrift = count($check_double_gutschrift);
for ($icheck = 0; $icheck < $ccheck_double_gutschrift; $icheck++) {
$belege .= ' ' . $check_double_gutschrift[$icheck]['belegnr'];
}
if(trim($belege) == ''){
$belege = 'ohne Nummer';
}
$gesamt_gutschrift = count($check_double_gutschrift);
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth(
'masterdata', 'double_return_order', 'error',
$link . 'Achtung: Doppelte Gutschriftsnummern! (Gesamt ' .
$gesamt_gutschrift . ') *' .
($link ? '' : '')
);
}
$gutschrift_check = 1;
}else{
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'double_return_order', 'ok', '');
}
$this->erp->SetKonfigurationValue('eproosystem_gutschrift', 0);
}
$check_double_gutschrift = null;
$check_double_rechnungen = $this->DB->SelectArrCache(
"SELECT b.belegnr, COUNT(b.belegnr) AS NumOccurrences
FROM rechnung b
LEFT JOIN projekt pr ON b.projekt = pr.id WHERE b.status!='angelegt' AND b.belegnr <> ''
GROUP BY b.belegnr, if(ifnull(pr.eigenernummernkreis,0) = 0,0,pr.id)
HAVING ( COUNT(b.belegnr) > 1 )",
$doppeltenummerncheckCronjob ? 86400 : 120,
'rechnung'
);
if($check_double_rechnungen && count($check_double_rechnungen) > 0){
$this->erp->SetKonfigurationValue('eproosystem_rechnung', 1);
$gesamt_rechnungen = count($check_double_rechnungen);
for ($icheck = 0; $icheck < $gesamt_rechnungen; $icheck++) {
$belege .= ' ' . $check_double_rechnungen[$icheck]['belegnr'];
}
if(trim($belege) === ''){
$belege = 'ohne Nummer';
}
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth(
'masterdata', 'double_invoice', 'error',
$link . 'Achtung: Doppelte Rechnungsnummern! (Gesamt ' .
$gesamt_rechnungen . ') *' .
($link ? '' : '')
);
}
$rechnung_check = 1;
}else{
$this->erp->SetKonfigurationValue('eproosystem_rechnung', 0);
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'double_invoice', 'ok', '');
}
}
$check_double_rechnungen = null;
if($this->DB->SelectArrCache("SELECT id FROM artikel WHERE nummer = '' AND ifnull(geloescht,0) = 0 LIMIT 1", 120, 'artikel')){
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'empty_articlenumber', 'error', 'Achtung Es existieren Artikel ohne Artikelnummer');
}
}else{
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'empty_articlenumber', 'ok', '');
}
}
$check_double_artikel = $this->DB->SelectArrCache(
"SELECT art.nummer, count(art.nummer) as NumOccurrences
FROM artikel art
LEFT JOIN projekt pr ON art.projekt = pr.id
WHERE art.geloescht <> '1' AND art.nummer <> '' AND art.nummer <> 'DEL'
GROUP BY art.nummer,if(ifnull(pr.eigenernummernkreis,0) = 0,0,pr.id)
HAVING (COUNT(art.nummer) > 1)
LIMIT 101",
$doppeltenummerncheckCronjob ? 86400 : 600,
'artikel'
);
if(!empty($check_double_artikel) && count($check_double_artikel) > 0){
$this->erp->SetKonfigurationValue('eproosystem_artikel', 1);
$gesamt_artikel = count($check_double_artikel);
$gcount = $gesamt_artikel;
if($gcount > 10){
$gcount = 10;
}
for ($icheck = 0; $icheck < $gcount; $icheck++) {
$belege .= ' ' . $check_double_artikel[$icheck]['nummer'];
}
if($gesamt_artikel > $gcount){
$belege .= ' ...';
}
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'double_articlenumber', 'error',
$link . 'Achtung: Doppelte Artikelnummern! (Gesamt ' .
$gesamt_artikel . ') *' .
($link ? '' : '')
);
}
}else{
$this->erp->SetKonfigurationValue('eproosystem_artikel', 0);
if(method_exists($this->erp, 'setSystemHealth')){
$this->erp->setSystemHealth('masterdata', 'double_articlenumber', 'ok', '');
}
}
}
}
if(!$doppeltenummerncheckCronjob && $this->erp->Firmendaten('warnung_doppelte_seriennummern')=='1') {
$sql = "SELECT art.id,art.nummer,
s.seriennummer, s.anzahl
FROM artikel art INNER JOIN (
(
SELECT artikel, seriennummer, count(id) as anzahl, 0 as lieferschein, '' as belegnr FROM lager_seriennummern WHERE seriennummer <> ''
GROUP BY seriennummer, artikel HAVING count(id) > 1
)
UNION ALL
(
SELECT t3.artikel, t3.wert, sum(t3.anzahl) ,max(t3.lieferschein), max(t3.belegnr) FROM
(
(
SELECT lp.artikel, s.wert , count(s.id) as anzahl, max(l.id) as lieferschein, max(l.belegnr) as belegnr
FROM `beleg_chargesnmhd` s
INNER JOIN lieferschein_position lp ON s.doctype = 'lieferschein' AND s.pos = lp.id AND s.type = 'sn' AND s.wert <> ''
INNER JOIN lieferschein l ON lp.lieferschein = l.id AND l.status <> 'storniert'
WHERE l.id NOT IN (SELECT lieferscheinid FROM retoure LIMIT 1)
GROUP BY s.wert, lp.artikel
)
UNION ALL (
SELECT lp.artikel, s.seriennummer as wert , count(s.id) as anzahl, max(l.id) as lieferschein, max(l.belegnr) as belegnr
FROM `seriennummern` s
INNER JOIN lieferschein_position lp ON s.lieferscheinpos = lp.id
INNER JOIN lieferschein l ON lp.lieferschein = l.id WHERE s.seriennummer <> '' AND l.id NOT IN (SELECT lieferscheinid FROM retoure LIMIT 1)
GROUP BY s.seriennummer, lp.artikel
)) t3 GROUP BY t3.artikel, t3.wert HAVING sum(t3.anzahl) > 1
)
) s ON art.id = s.artikel GROUP BY art.id, s.seriennummer HAVING max(anzahl) > 1 ";
$doppeltebelege = $this->DB->SelectArrCache($sql,$doppeltenummerncheckCronjob?86400:300,'artikel');
if(!empty($doppeltebelege)) {
$this->erp->SetKonfigurationValue('eproosystem_artikel', 1);
$gesamt_artikel = 0;
$gcount = 0;
$gesamt_artikel2 = count($doppeltebelege);
if($gcount < 10) {
$gcount2 = $gesamt_artikel2;
if($gesamt_artikel2 + $gcount > 10){
$gcount2 = 10 - $gcount;
}
for($icheck=0;$icheck<$gcount2;$icheck++) {
if(!isset($arts)){
$arts = '';
}
$arts .=' '.$doppeltebelege[$icheck]['nummer'].':'.$doppeltebelege[$icheck]['seriennummer'];
}
}
$link = '';
if($this->erp->RechteVorhanden('doppelte_nummern','list')) {
$link = '';
}
if(method_exists($this->erp,'setSystemHealth')){
$this->erp->setSystemHealth(
'bestbeforebatchsn', 'sn', 'error',
$link.'Achtung: Doppelte Seriennummern! (Gesamt '.
($gesamt_artikel+$gesamt_artikel2).')'.($link?'':'')
);
}
}
else {
if(method_exists($this->erp,'setSystemHealth')){
$this->erp->setSystemHealth('bestbeforebatchsn', 'sn', 'ok', '');
}
}
}
if($this->erp instanceof erpAPICustom
&& $this->User->GetType() === 'admin'
&& method_exists('erpAPICustom', 'AllowedVersion')) {
try {
$allowedmethod = new ReflectionMethod('erpAPICustom', 'AllowedVersion');
if($allowedmethod->isStatic()){
$allowed = erpAPICustom::AllowedVersion();
$version_revision = null;
include dirname(__DIR__) . '/version.php';
if(isset($version_revision) && ((isset($allowed['max']) && ((float)$allowed['max'] < (float)$version_revision))
||
(isset($allowed['versionen']) && (
(is_array($allowed['versionen']) && !in_array($version_revision, $allowed['versionen']))
|| (!is_array($allowed['versionen']) && $allowed['versionen'] != $version_revision)
))
)){
$this->Tpl->Add('THEMEHEADER', '
Die Datei class.erpapi_custom.php auf Ihrem System, ist nicht für Ihre Version geeignet
');
}
}
}
catch (Exception $e) {
}
}
if($this->Secure->GetPOST('deactivate_maintenance')) {
$tags = json_encode('update');
$this->DB->Delete("DELETE FROM notification_message WHERE tags = '$tags'");
$this->erp->SetKonfigurationValue('update_maintenance',0);
}
$anznachrichtenboxen = 0;
$this->erp->RunHook('eproosystem_iconboxes_start', 1, $anznachrichtenboxen);
if($this->erp->ModulVorhanden('chat') && $this->erp->RechteVorhanden('chat','list')) {
$userId = $this->User->GetID();
$registrierDatum = $this->DB->Select("SELECT u.logdatei FROM `user` AS u WHERE u.id='".$userId."'");
$ungelesenOeffentlich = (int)$this->DB->Select(
"SELECT COUNT(c.id)
FROM chat AS c
LEFT JOIN chat_gelesen AS g ON c.id = g.message AND (g.user = '".$userId."' OR g.user = 0)
WHERE c.user_to='0' AND c.zeitstempel > '".$registrierDatum."'
AND g.id IS NULL"
);
$ungelesenPrivat = (int)$this->DB->Select(
"SELECT COUNT(c.id)
FROM chat AS c
INNER JOIN `user` AS u ON c.user_from = u.id
LEFT JOIN chat_gelesen AS g ON c.id = g.message
WHERE u.activ = 1 AND c.user_to='".$userId."'
AND g.id IS NULL"
);
$anzchat = $ungelesenOeffentlich + $ungelesenPrivat;
$this->Tpl->Set('CHATNACHRICHTENBOXCOUNTER',$anzchat > 0?$anzchat:'');
if($this->DB->Select("SELECT chat_popup FROM `user` WHERE id = '".$userId."' LIMIT 1")) {
$this->Tpl->Set('CHATLINK','href="index.php?module=chat&action=list" target="_blank" ');
}
else {
$this->Tpl->Set('CHATLINK','href="index.php?module=chat&action=list"');
}
}
else {
$this->Tpl->Set('VORCHATNACHRICHTENBOX','');
}
if(!empty(erpAPI::Ioncube_Property('testlizenz'))){
$upgradeButton = '