From d180a1af54cd340a88a476c779f02e06c5f5c872 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 3 Aug 2024 13:33:58 +0200 Subject: [PATCH 1/7] module_creator echo $sql --- tools/module_creator/module_creator_php_template.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/module_creator/module_creator_php_template.txt b/tools/module_creator/module_creator_php_template.txt index e0806214..6bdb7f6d 100644 --- a/tools/module_creator/module_creator_php_template.txt +++ b/tools/module_creator/module_creator_php_template.txt @@ -36,7 +36,7 @@ class PLACEHOLDER_MODULECLASSNAME { // columns that are aligned right (numbers etc) // $alignright = array(4,5,6,7,8); - $findcols = array('PLACEHOLDER_ID_COLUMN','PLACEHOLDER_ID_COLUMN',PLACEHOLDER_SQL_COLUMNS); + $findcols = array('PLACEHOLDER_ID_COLUMN','PLACEHOLDER_ID_COLUMN',PLACEHOLDER_SQL_COLUMNS); // use 'null' for non-searchable columns $searchsql = array(PLACEHOLDER_SQL_COLUMNS); $defaultorder = 1; @@ -60,6 +60,8 @@ class PLACEHOLDER_MODULECLASSNAME { $count = "SELECT count(DISTINCT id) FROM PLACEHOLDER_MODULENAME WHERE $where"; // $groupby = ""; +// echo($sql." WHERE ".$where." ".$groupby); + break; } From 94f3fb0261426125c47b8fd93670f782110275c7 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 3 Aug 2024 14:28:05 +0200 Subject: [PATCH 2/7] cronjobs/cleaner.php removed shopimport_amazon_fees --- cronjobs/cleaner.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/cronjobs/cleaner.php b/cronjobs/cleaner.php index 4c0759e0..85c4a1ff 100644 --- a/cronjobs/cleaner.php +++ b/cronjobs/cleaner.php @@ -148,8 +148,7 @@ $tables = [ 'templatemessage', 'shopimport_auftraege', 'versandzentrum_log', - 'api_request_response_log', - 'shopimport_amazon_fees', + 'api_request_response_log' ]; $minMemoryMb = 1; $minMemory = $minMemoryMb * 1024 * 1024; @@ -623,34 +622,11 @@ if($shopExportLogCleanerActive && $tage > 0) { $shopExportLogCleanerActive = $app->erp->Firmendaten('cleaner_shopexportlog'); $tage = (int)$app->erp->Firmendaten('cleaner_shopexportlog_tage'); -$isToDelete = !empty($tableSchemaByTables['shopimport_amazon_fees']) - && !empty($tableSchemaByTables['shopimport_amazon_fees']['todelete']); -if((!$shopExportLogCleanerActive || $tage <= 0 || $tage > 30) && $isToDelete) { - $shopExportLogCleanerActive = true; - if($tage <= 0 || $tage > 30) { - $tage = 30; - } -} + if($shopExportLogCleanerActive && $tage > 0) { if($tage < 30) { $tage = 30; } - $app->DB->Delete( - sprintf( - "DELETE FROM `shopimport_amazon_fees` - WHERE DATE_SUB(NOW(), INTERVAL %d DAY) >= `zeitstempel` OR `zeitstempel` = '0000-00-00 00:00:00'", - $tage - ) - ); - $affectedRows = $app->DB->affected_rows(); - if(!empty($tableSchemaByTables['shopimport_amazon_fees']) - && ($tableSchemaByTables['shopimport_amazon_fees']['todelete'] > 0)) { - $tableSchemaByTables['shopimport_amazon_fees']['todelete'] -= $affectedRows; - } - if($affectedRows > 0 && !empty($optimize['shopimport_amazon_fees'])) { - $app->DB->Query('OPTIMIZE TABLE `shopimport_amazon_fees`'); - unset($optimize['shopimport_amazon_fees']); - } $app->DB->Update( "UPDATE prozessstarter SET letzteausfuerhung=NOW(),mutex=1,mutexcounter=0 WHERE parameter = 'cleaner' AND aktiv = 1" ); From 5ad57e2fc813b4c2e3b6885252263a6638e94804 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 11 Aug 2024 12:46:41 +0200 Subject: [PATCH 3/7] bugfix TOTP, additional database entries needed: login_password_check_otp (hook), TOTPCheckLogin (hook_register) --- .../Modules/TOTPLogin/TOTPLoginService.php | 2 +- phpwf/plugins/class.templateparser.php | 2 +- www/pages/totp.php | 261 +++++++++--------- 3 files changed, 132 insertions(+), 133 deletions(-) diff --git a/classes/Modules/TOTPLogin/TOTPLoginService.php b/classes/Modules/TOTPLogin/TOTPLoginService.php index ecfe97ab..09f20803 100644 --- a/classes/Modules/TOTPLogin/TOTPLoginService.php +++ b/classes/Modules/TOTPLogin/TOTPLoginService.php @@ -270,7 +270,7 @@ class TOTPLoginService $secret = $this->getTOTPSecret($userId); } - $query = "otpauth://totp/{$label}?secret=" . $secret . '&issuer=Xentral&algorithm=SHA1&digits=6&period=30'; + $query = "otpauth://totp/{$label}?secret=" . $secret . '&issuer=OpenXE&algorithm=SHA1&digits=6&period=30'; return $this->barcodeService->createQrCode($query); } diff --git a/phpwf/plugins/class.templateparser.php b/phpwf/plugins/class.templateparser.php index 09854989..c7e55f3d 100644 --- a/phpwf/plugins/class.templateparser.php +++ b/phpwf/plugins/class.templateparser.php @@ -616,7 +616,7 @@ class TemplateParser { } } - if(count($this->VARARRAY)>0) + if(!empty($this->VARARRAY)) foreach($this->VARARRAY as $key=>$value) { if($key!="") diff --git a/www/pages/totp.php b/www/pages/totp.php index 8d382bd2..420238e5 100644 --- a/www/pages/totp.php +++ b/www/pages/totp.php @@ -1,134 +1,133 @@ -app = $app; - - if($intern) return; - - $app->ActionHandlerInit($this); - - $app->ActionHandler('generate', 'TOTPGenerateSecretJSON'); - $app->ActionHandler('enable', 'TOTPEnable'); - $app->ActionHandler('disable', 'TOTPDisable'); - - $app->ActionHandlerListen($app); - } - - public function Install() - { - $tableName = 'user_totp'; - $this->app->erp->CheckTable($tableName); - $this->app->erp->CheckColumn('id', 'UNSIGNED INT', $tableName, 'NOT NULL AUTO_INCREMENT'); - $this->app->erp->CheckColumn('user_id', 'INT', $tableName, 'UNSIGNED NOT NULL'); - $this->app->erp->CheckColumn('active', 'TINYINT(1)', $tableName, 'UNSIGNED DEFAULT 0'); - $this->app->erp->CheckColumn('secret', 'VARCHAR(100)', $tableName, 'NOT NULL'); - $this->app->erp->CheckColumn('created_at', 'TIMESTAMP', $tableName, 'DEFAULT NOW()'); - $this->app->erp->CheckColumn('modified_at', 'TIMESTAMP', $tableName); - $this->app->erp->CheckIndex($tableName, 'user_id', true); - - $this->app->erp->RegisterHook('login_password_check_otp', 'totp', 'TOTPCheckLogin', 1, false, null, 3); - } - - function TOTPDisable(){ - $action = $this->app->Secure->GetPOST('action'); - - if($action !== 'disable'){ - return new JsonResponse(['status' => 'error', 'msg' => 'muss POST sein'], 400); - } - - /** @var TOTPLoginService $totpLoginService */ - $totpLoginService = $this->app->Container->get('TOTPLoginService'); - - $userId = $this->app->User->GetID(); - - $totpLoginService->disableTotp($userId); - - return new JsonResponse(['status' => 'success']); - } - - function TOTPEnable(){ - $secret = $this->app->Secure->GetPOST('secret'); - - if(empty($secret)){ - return new JsonResponse(['status' => 'error', 'msg' => 'Secret Empty'], 400); - } - - /** @var TOTPLoginService $totpLoginService */ - $totpLoginService = $this->app->Container->get('TOTPLoginService'); - - $userId = $this->app->User->GetID(); - - $totpLoginService->enableTotp($userId); - $totpLoginService->setUserSecret($userId, $secret); - - return new JsonResponse(['status' => 'success']); - } - - /** - * @param $userID - * @param $token - * @param $passwordValid - * - * @throws Exception - */ - public function TOTPCheckLogin($userID, $token, &$passwordValid) - { - /** @var TOTPLoginService $totpLoginService */ - $totpLoginService = $this->app->Container->get('TOTPLoginService'); - - if(!$totpLoginService->isTOTPEnabled($userID)){ - return; - } - $passwordValid = $totpLoginService->isTokenValid($userID, $token); - } - - public function TOTPGenerateSecretJSON(){ - /** @var TOTPLoginService $totpLoginService */ - $totpLoginService = $this->app->Container->get('TOTPLoginService'); - - /** @var \Xentral\Components\Token\TOTPTokenManager $tokenManager */ - $tokenManager = $this->app->Container->get('TOTPTokenManager'); - - $secret = $tokenManager->generateBase32Secret(); - - $label = 'Xentral' . ' | ' . $this->app->erp->GetFirmaName(); - - $qr = $totpLoginService->generatePairingQrCode($this->app->User->GetID(), $label, $secret); - - return new JsonResponse( - [ - 'secret' => $secret, - 'qr' => $qr->toHtml(4, 4) - ] - ); - } -} +app = $app; + + if($intern) return; + + $app->ActionHandlerInit($this); + + $app->ActionHandler('generate', 'TOTPGenerateSecretJSON'); + $app->ActionHandler('enable', 'TOTPEnable'); + $app->ActionHandler('disable', 'TOTPDisable'); + + $app->ActionHandlerListen($app); + } + + public function Install() + { + $tableName = 'user_totp'; + $this->app->erp->CheckTable($tableName); + $this->app->erp->CheckColumn('id', 'UNSIGNED INT', $tableName, 'NOT NULL AUTO_INCREMENT'); + $this->app->erp->CheckColumn('user_id', 'INT', $tableName, 'UNSIGNED NOT NULL'); + $this->app->erp->CheckColumn('active', 'TINYINT(1)', $tableName, 'UNSIGNED DEFAULT 0'); + $this->app->erp->CheckColumn('secret', 'VARCHAR(100)', $tableName, 'NOT NULL'); + $this->app->erp->CheckColumn('created_at', 'TIMESTAMP', $tableName, 'DEFAULT NOW()'); + $this->app->erp->CheckColumn('modified_at', 'TIMESTAMP', $tableName); + $this->app->erp->CheckIndex($tableName, 'user_id', true); + + $this->app->erp->RegisterHook('login_password_check_otp', 'totp', 'TOTPCheckLogin', 1, false, null, 3); + } + + function TOTPDisable(){ + $action = $this->app->Secure->GetPOST('action'); + + if($action !== 'disable'){ + return new JsonResponse(['status' => 'error', 'msg' => 'muss POST sein'], 400); + } + + /** @var TOTPLoginService $totpLoginService */ + $totpLoginService = $this->app->Container->get('TOTPLoginService'); + + $userId = $this->app->User->GetID(); + + $totpLoginService->disableTotp($userId); + + return new JsonResponse(['status' => 'success']); + } + + function TOTPEnable(){ + $secret = $this->app->Secure->GetPOST('secret'); + + if(empty($secret)){ + return new JsonResponse(['status' => 'error', 'msg' => 'Secret Empty'], 400); + } + + /** @var TOTPLoginService $totpLoginService */ + $totpLoginService = $this->app->Container->get('TOTPLoginService'); + + $userId = $this->app->User->GetID(); + + $totpLoginService->enableTotp($userId); + $totpLoginService->setUserSecret($userId, $secret); + + return new JsonResponse(['status' => 'success']); + } + + /** + * @param $userID + * @param $token + * @param $passwordValid + * + * @throws Exception + */ + public function TOTPCheckLogin($userID, $token, &$passwordValid) + { + /** @var TOTPLoginService $totpLoginService */ + $totpLoginService = $this->app->Container->get('TOTPLoginService'); + if(!$totpLoginService->isTOTPEnabled($userID)){ + return; + } + $passwordValid = $totpLoginService->isTokenValid($userID, $token); + } + + public function TOTPGenerateSecretJSON(){ + /** @var TOTPLoginService $totpLoginService */ + $totpLoginService = $this->app->Container->get('TOTPLoginService'); + + /** @var \Xentral\Components\Token\TOTPTokenManager $tokenManager */ + $tokenManager = $this->app->Container->get('TOTPTokenManager'); + + $secret = $tokenManager->generateBase32Secret(); + + $label = 'OpenXE' . ':' . $this->app->User->Getname(); + + $qr = $totpLoginService->generatePairingQrCode($this->app->User->GetID(), $label, $secret); + + return new JsonResponse( + [ + 'secret' => $secret, + 'qr' => $qr->toHtml(4, 4) + ] + ); + } +} From 7e2155f586db0ac879fb0a5404c7403263eae084 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 11 Aug 2024 13:10:35 +0200 Subject: [PATCH 4/7] TOTP, additional database entries for fresh install --- database/struktur.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/database/struktur.sql b/database/struktur.sql index 8f70631f..272dd39c 100755 --- a/database/struktur.sql +++ b/database/struktur.sql @@ -17873,6 +17873,15 @@ INSERT INTO `hook_register` (`hook_action`, `function`, `aktiv`, `position`, `ho ; /* OpenXE 2024-02-03 für belegvorlagen */ +/* OpenXE 2024-08-11 für TOTP */ +INSERT INTO `hook`(`name`, `aktiv`, `parametercount`, `alias`, `description`) VALUES +('login_password_check_otp', 1, 3, '', ''); + +INSERT INTO `hook_register`( + `hook_action`, `function`, `aktiv`, `position`, `hook`, `module`, `module_parameter`) VALUES + ( 0, 'TOTPCheckLogin', 1, 1, (SELECT id FROM hook WHERE NAME = 'login_password_check_otp' LIMIT 1), 'totp', 0); +/* OpenXE 2024-08-11 für TOTP */ + /* BelegPositionenButtons From 23b9fa781b3c7c0b8d62070b18f08c3d34960600 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 11 Aug 2024 13:19:53 +0200 Subject: [PATCH 5/7] Smarty shopimport, additional database entries for fresh install --- database/struktur.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/database/struktur.sql b/database/struktur.sql index 272dd39c..2b0475e9 100755 --- a/database/struktur.sql +++ b/database/struktur.sql @@ -17882,6 +17882,14 @@ INSERT INTO `hook_register`( ( 0, 'TOTPCheckLogin', 1, 1, (SELECT id FROM hook WHERE NAME = 'login_password_check_otp' LIMIT 1), 'totp', 0); /* OpenXE 2024-08-11 für TOTP */ +/* OpenXE 2024-08-11 für Smarty shopimport */ +INSERT INTO `hook` (`name`, `aktiv`, `parametercount`, `alias`, `description`) VALUES +('ImportAuftragBefore', 1, 4, '', ''); + +INSERT INTO `hook_register` (`hook_action`, `function`, `aktiv`, `position`, `hook`, `module`, `module_parameter`) VALUES +(0, 'ImportAuftragBeforeHook', 1, 1, (SELECT id FROM hook WHERE name = 'ImportAuftragBefore' LIMIT 1), 'onlineshops', 0); +/* OpenXE 2024-08-11 für Smarty shopimport */ + /* BelegPositionenButtons From 50d8646d70381cceb41faa2a4d070370a0b57e75 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 25 Aug 2024 14:32:56 +0200 Subject: [PATCH 6/7] verbindlichkeit date assistant --- www/pages/content/verbindlichkeit_edit.tpl | 6 +- www/pages/verbindlichkeit.php | 581 +++++++++++---------- 2 files changed, 302 insertions(+), 285 deletions(-) diff --git a/www/pages/content/verbindlichkeit_edit.tpl b/www/pages/content/verbindlichkeit_edit.tpl index 319ca0c1..83a20a37 100644 --- a/www/pages/content/verbindlichkeit_edit.tpl +++ b/www/pages/content/verbindlichkeit_edit.tpl @@ -62,7 +62,7 @@ {|Rechnungsdatum|}: - + @@ -103,7 +103,7 @@ {|Zahlbar bis|}: - +   Tage @@ -119,7 +119,7 @@ {|Skonto bis|}: - +   Tage diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php index 45a559e0..3eda30d8 100644 --- a/www/pages/verbindlichkeit.php +++ b/www/pages/verbindlichkeit.php @@ -15,7 +15,7 @@ class Verbindlichkeit { return; $this->app->ActionHandlerInit($this); - $this->app->ActionHandler("list", "verbindlichkeit_list"); + $this->app->ActionHandler("list", "verbindlichkeit_list"); $this->app->ActionHandler("create", "verbindlichkeit_edit"); // This automatically adds a "New" button $this->app->ActionHandler("edit", "verbindlichkeit_edit"); $this->app->ActionHandler("positionen", "verbindlichkeit_positionen"); @@ -28,10 +28,10 @@ class Verbindlichkeit { $this->app->ActionHandler("freigabe", "verbindlichkeit_freigabe"); $this->app->ActionHandler("freigabeeinkauf", "verbindlichkeit_freigabeeinkauf"); $this->app->ActionHandler("freigabebuchhaltung", "verbindlichkeit_freigabebuchhaltung"); - $this->app->ActionHandler("freigabebezahlt", "verbindlichkeit_freigabebezahlt"); + $this->app->ActionHandler("freigabebezahlt", "verbindlichkeit_freigabebezahlt"); $this->app->ActionHandler("ruecksetzeneinkauf", "verbindlichkeit_ruecksetzeneinkauf"); $this->app->ActionHandler("ruecksetzenbuchhaltung", "verbindlichkeit_ruecksetzenbuchhaltung"); - $this->app->ActionHandler("ruecksetzenbezahlt", "verbindlichkeit_ruecksetzenbezahlt"); + $this->app->ActionHandler("ruecksetzenbezahlt", "verbindlichkeit_ruecksetzenbezahlt"); $this->app->ActionHandler("minidetail", "verbindlichkeit_minidetail"); $this->app->DefaultActionHandler("list"); @@ -50,14 +50,14 @@ class Verbindlichkeit { $width = array('1%','1%','10%'); // Fill out manually later // columns that are aligned right (numbers etc) - // $alignright = array(4,5,6,7,8); + // $alignright = array(4,5,6,7,8); $findcols = array( 'v.id', 'v.id', 'v.belegnr', 'a.name', - 'a.lieferantennummer', + 'a.lieferantennummer', 'v.rechnung', 'v.rechnungsdatum', 'v.betrag', @@ -70,10 +70,10 @@ class Verbindlichkeit { 'v.status_beleg', 'v.id' ); - - $searchsql = array( + + $searchsql = array( 'a.name', - 'a.lieferantennummer', + 'a.lieferantennummer', 'v.rechnung', 'v.internebemerkung' ); @@ -91,7 +91,7 @@ class Verbindlichkeit { $menu = "
" . "Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"> " . "Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">" . "
"; - $sql = "SELECT SQL_CALC_FOUND_ROWS + $sql = "SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, v.belegnr, @@ -103,8 +103,8 @@ class Verbindlichkeit { v.waehrung, if(v.bezahlt,'bezahlt','offen'), ".$app->erp->FormatDate("v.zahlbarbis").", - IF(v.skonto <> 0,".$app->erp->FormatDate("v.skontobis").",''), - IF(v.skonto <> 0,CONCAT(".$app->erp->FormatMenge('v.skonto',0).",'%'),''), + IF(v.skonto <> 0,".$app->erp->FormatDate("v.skontobis").",''), + IF(v.skonto <> 0,CONCAT(".$app->erp->FormatMenge('v.skonto',0).",'%'),''), v.status, ".$app->YUI->IconsSQLVerbindlichkeit().", v.id FROM verbindlichkeit v @@ -134,9 +134,9 @@ class Verbindlichkeit { else oMoreData' . $r . $name . ' = 1; - $(\'#' . $name . '\').dataTable().fnFilter( + $(\'#' . $name . '\').dataTable().fnFilter( \'\', - i, + i, 0,0 ); } @@ -145,7 +145,7 @@ class Verbindlichkeit { $more_data1 = $this->app->Secure->GetGET("more_data1"); if ($more_data1 == 1) { - $where .= " AND datei_anzahl IS NULL"; + $where .= " AND datei_anzahl IS NULL"; } else { } @@ -154,36 +154,36 @@ class Verbindlichkeit { $where .= " AND v.freigabe <> '1'"; } else { - } + } $more_data3 = $this->app->Secure->GetGET("more_data3"); if ($more_data3 == 1) { $where .= " AND v.rechnungsfreigabe <> '1'"; } - else { - } - + else { + } + $more_data4 = $this->app->Secure->GetGET("more_data4"); if ($more_data4 == 1) { - $where .= " AND v.bezahlt <> 1"; + $where .= " AND v.bezahlt <> 1"; + } + else { } - else { - } $more_data5 = $this->app->Secure->GetGET("more_data5"); if ($more_data5 == 1) { } - else { - $where .= " AND v.status <> 'storniert'"; - } + else { + $where .= " AND v.status <> 'storniert'"; + } $more_data6 = $this->app->Secure->GetGET("more_data6"); if ($more_data6 == 1) { } - else { - $where .= " AND v.status <> 'abgeschlossen'"; - } - + else { + $where .= " AND v.status <> 'abgeschlossen'"; + } + $this->app->YUI->DatePicker('zahlbarbis'); $filterzahlbarbis = $this->app->YUI->TableSearchFilter($name, 7,'zahlbarbis'); if (!empty($filterzahlbarbis)) { @@ -204,7 +204,7 @@ class Verbindlichkeit { break; case 'verbindlichkeit_paketdistribution_list': - $allowed['verbindlichkeit_paketdistribution_list'] = array('list'); + $allowed['verbindlichkeit_paketdistribution_list'] = array('list'); $id = $app->Secure->GetGET('id'); if (empty($id)) { @@ -212,13 +212,13 @@ class Verbindlichkeit { } $verbindlichkeit = $app->DB->SelectArr("SELECT v.adresse, v.rechnung, b.belegnr FROM verbindlichkeit v LEFT JOIN bestellung b ON b.id = v.bestellung WHERE v.id = ".$id)[0]; - + $lieferant = $verbindlichkeit['adresse']; $bestellnummer = $verbindlichkeit['belegnr']; $rechnung = $verbindlichkeit['rechnung']; - + $heading = array('', 'Paket-Nr.','Paket-Pos.', 'Bestellung', 'Lieferschein', 'Rechnung', 'Artikel-Nr.','Artikel','Bemerkung','Menge','Menge offen','Eingabe','Preis','Steuer','Sachkonto',''); - $width = array( '1%','1%', '1%', '5%', '5%', '5%', '5%', '20%', '20%', '2%', '1%', '1%', '1%', '1%', '1%', '1%'); + $width = array( '1%','1%', '1%', '5%', '5%', '5%', '5%', '20%', '20%', '2%', '1%', '1%', '1%', '1%', '1%', '1%'); $findcols = array('id','pa','id','belegnr','lsnr','renr','artikelnummer','name_de','bemerkung','menge','offen_menge','offen_menge','preis','steuer','sachkonto','pa'); $searchsql = array('p.nummer', 'p.name', 'p.bemerkung'); @@ -226,7 +226,7 @@ class Verbindlichkeit { $alignright = array(9,10); $defaultorder = 1; - $defaultorderdesc = 0; + $defaultorderdesc = 0; $offen_menge = "TRIM(IF( pd.menge > COALESCE(vp.menge,0), @@ -235,10 +235,10 @@ class Verbindlichkeit { ))+0"; $auswahl = array ( - ' 'pd.id'], '"/>' - ); + ); $werte = array ( ' $offen_menge], '"/>' - ); + ); $preise = array ( '' - ); - + ); + $artikellink = array ( '', + '">', ['sql' => 'art.nummer'], '' ); @@ -267,16 +267,16 @@ class Verbindlichkeit { $paketlink = array ( '', + '">', ['sql' => 'pa.id'], '' ); - + $where = "offen_menge > 0"; // Toggle filters $this->app->Tpl->Add('JQUERYREADY', "$('#passende').click( function() { fnFilterColumn1( 0 ); } );"); - + for ($r = 1;$r <= 1;$r++) { $this->app->Tpl->Add('JAVASCRIPT', ' function fnFilterColumn' . $r . ' ( i ) @@ -286,9 +286,9 @@ class Verbindlichkeit { else oMoreData' . $r . $name . ' = 1; - $(\'#' . $name . '\').dataTable().fnFilter( + $(\'#' . $name . '\').dataTable().fnFilter( \'\', - i, + i, 0,0 ); } @@ -299,12 +299,12 @@ class Verbindlichkeit { if ($more_data1 == 1) { $innerwhere .= " AND ((b.belegnr LIKE '%".$bestellnummer."%' AND '".$bestellnummer."' <> '') OR (pa.renr LIKE '%".$rechnung."%' AND pa.renr <> ''))"; } else { - } - // END Toggle filters + } + // END Toggle filters $sql = " SELECT SQL_CALC_FOUND_ROWS * FROM ( - SELECT + SELECT pa.id pa_id, ".$this->app->erp->ConcatSQL($auswahl)." AS auswahl, ".$this->app->erp->ConcatSQL($paketlink)." pa, @@ -326,7 +326,7 @@ class Verbindlichkeit { if(art.umsatzsteuer = '',art.steuersatz,art.umsatzsteuer) steuer, if (skart.id <> 0, CONCAT(skart.sachkonto,' ',skart.beschriftung), - CONCAT(skadr.sachkonto,' ',skadr.beschriftung) + CONCAT(skadr.sachkonto,' ',skadr.beschriftung) ) AS sachkonto FROM paketannahme pa @@ -339,7 +339,7 @@ class Verbindlichkeit { LEFT JOIN bestellung_position bp ON bp.id = pd.bestellung_position LEFT JOIN bestellung b ON - b.id = bp.bestellung + b.id = bp.bestellung LEFT JOIN( SELECT paketdistribution, @@ -350,11 +350,11 @@ class Verbindlichkeit { paketdistribution ) vp ON - vp.paketdistribution = pd.id - LEFT JOIN + vp.paketdistribution = pd.id + LEFT JOIN kontorahmen skart ON skart.id = art.kontorahmen - LEFT JOIN - kontorahmen skadr ON skadr.id = adr.kontorahmen + LEFT JOIN + kontorahmen skadr ON skadr.id = adr.kontorahmen WHERE pa.adresse = ".$lieferant." AND pd.vorlaeufig IS NULL".$innerwhere." ) temp "; @@ -365,24 +365,24 @@ class Verbindlichkeit { break; case 'verbindlichkeit_positionen': - $allowed['verbindlichkeit_positionen'] = array('list'); + $allowed['verbindlichkeit_positionen'] = array('list'); $id = $app->Secure->GetGET('id'); $freigabe = $app->DB->Select("SELECT freigabe FROM verbindlichkeit WHERE id = '".$id."'"); $rechnungsfreigabe = $app->DB->Select("SELECT rechnungsfreigabe FROM verbindlichkeit WHERE id = '".$id."'"); $heading = array('', 'Paket-Nr.','Paket-Pos.', 'Bestellung', 'Artikel-Nr.','Artikel','Bemerkung','Menge','Preis','Steuersatz','Sachkonto'); - $width = array( '1%','1%', '1%' , '2%', '2%', '20%', '20%', '1%', '1%', '3%', '1%', '1%'); + $width = array( '1%','1%', '1%' , '2%', '2%', '20%', '20%', '1%', '1%', '3%', '1%', '1%'); $findcols = array('vp.id','pd.paketannahme','pd.id','b.belegnr','art.nummer','art.name_de','pd.bemerkung','vp.menge','vp.preis','vp.steuersatz',"CONCAT(skv.sachkonto,' ',skv.beschriftung)",'vp.id'); $searchsql = array('p.nummer', 'p.name', 'p.bemerkung'); - $alignright = array(8,9,10); + $alignright = array(8,9,10); $defaultorder = 1; - $defaultorderdesc = 0; + $defaultorderdesc = 0; - if (empty($freigabe)) { + if (empty($freigabe)) { $menu="
"."Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"> "."Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">"."
"; } else if (empty($rechnungsfreigabe)) { $menu="
"."Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">"."
"; @@ -390,20 +390,20 @@ class Verbindlichkeit { else { $deletepos = array(''); } - $heading[] = ''; - + $heading[] = ''; + $box = "CONCAT('') AS `auswahl`"; $paketlink = array ( '', + '">', ['sql' => 'pd.paketannahme'], '' ); $sql = " - SELECT SQL_CALC_FOUND_ROWS + SELECT SQL_CALC_FOUND_ROWS vp.id, $box, ".$this->app->erp->ConcatSQL($paketlink)." pa, @@ -429,7 +429,7 @@ class Verbindlichkeit { adr.id = v.adresse LEFT JOIN bestellung_position bp ON pd.bestellung_position = bp.id LEFT JOIN bestellung b ON b.id = bp.bestellung - LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen + LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen "; $where = "vp.verbindlichkeit = ".$id; @@ -448,26 +448,26 @@ class Verbindlichkeit { } return $erg; } - + function verbindlichkeit_list() { // Process multi action $submit = $this->app->Secure->GetPOST('submit'); switch($submit) { case 'status_berechnen': - + $sql = "SELECT id FROM verbindlichkeit WHERE status <> 'abgeschlossen' AND status <> 'storniert'"; $ids = $this->app->DB->SelectArr($sql); - + foreach ($ids as $verbindlichkeit) { $this->verbindlichkeit_abschliessen($verbindlichkeit['id']); } - + break; case 'ausfuehren': $auswahl = $this->app->Secure->GetPOST('auswahl'); $aktion = $this->app->Secure->GetPOST('sel_aktion'); - + $selectedIds = []; if(!empty($auswahl)) { foreach($auswahl as $selectedId) { @@ -475,7 +475,7 @@ class Verbindlichkeit { if($selectedId > 0) { $selectedIds[] = $selectedId; } - } + } switch ($aktion) { case 'freigabeeinkauf': @@ -487,7 +487,7 @@ class Verbindlichkeit { } break; case 'freigabebuchhaltung': - foreach ($selectedIds as $id) { + foreach ($selectedIds as $id) { $result = $this->verbindlichkeit_freigabebuchhaltung($id); if ($result !== true) { $this->app->YUI->Message('warning',$result); @@ -502,9 +502,9 @@ class Verbindlichkeit { } } break; - } - } - break; + } + } + break; } $this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht"); @@ -531,51 +531,51 @@ class Verbindlichkeit { $this->app->User->SetParameter('table_verbindlichkeit_list_skontobis', ''); $this->app->Tpl->Parse('PAGE', "verbindlichkeit_list.tpl"); - } + } public function verbindlichkeit_delete() { $id = (int) $this->app->Secure->GetGET('id'); - - $this->app->DB->Delete("UPDATE `verbindlichkeit` SET status='storniert' WHERE `id` = '{$id}'"); - $this->app->Tpl->Set('MESSAGE', "
Der Eintrag wurde storniert.
"); + + $this->app->DB->Delete("UPDATE `verbindlichkeit` SET status='storniert' WHERE `id` = '{$id}'"); + $this->app->Tpl->Set('MESSAGE', "
Der Eintrag wurde storniert.
"); $this->verbindlichkeit_list(); - } + } public function verbindlichkeit_deletepos() { $posid = (int) $this->app->Secure->GetGET('posid'); - $id = (int) $this->app->Secure->GetGET('id'); + $id = (int) $this->app->Secure->GetGET('id'); $verbindlichkeit = $this->app->DB->Select("SELECT verbindlichkeit FROM verbindlichkeit_position WHERE id ='{$posid}'"); - $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id = '{$posid}' AND v.freigabe <> 1"); + $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id = '{$posid}' AND v.freigabe <> 1"); header("Location: index.php?module=verbindlichkeit&action=edit&id=$id#tabs-2"); - } + } /* * Edit verbindlichkeit item * If id is empty, create a new one */ - + function verbindlichkeit_edit($einkauf_automatik_aus = false) { $id = $this->app->Secure->GetGET('id'); - + // Check if other users are editing this id if($this->app->erp->DisableModul('verbindlichkeit',$id)) { return; - } - + } + $this->app->Tpl->Set('ID', $id); $this->verbindlichkeit_menu($id); $input = $this->GetInput(); $submit = $this->app->Secure->GetPOST('submit'); - + if (empty($id)) { // New item $id = 'NULL'; $input['status'] = 'angelegt'; - } + } if (!empty($submit)) { $einkauf_automatik_aus = false; @@ -584,7 +584,7 @@ class Verbindlichkeit { switch($submit) { case 'speichern': - // Write to database + // Write to database // Add checks here $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; @@ -597,21 +597,36 @@ class Verbindlichkeit { $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$projekt,true); $input['kostenstelle'] = $this->app->DB->Select("SELECT id FROM kostenstellen WHERE nummer = '".$kostenstelle."'"); } else { - $input['adresse'] = $this->app->erp->ReplaceLieferantennummer(true,$input['adresse'],true); // Parameters: Target db?, value, from form? + $input['rechnungsdatum'] = $this->app->erp->ReplaceDatum(true,$input['rechnungsdatum'],true); // Parameters: Target db?, value, from form? $input['eingangsdatum'] = $this->app->erp->ReplaceDatum(true,$input['eingangsdatum'],true); // Parameters: Target db?, value, from form? $input['skontobis'] = $this->app->erp->ReplaceDatum(true,$input['skontobis'],true); // Parameters: Target db?, value, from form? $input['zahlbarbis'] = $this->app->erp->ReplaceDatum(true,$input['zahlbarbis'],true); // Parameters: Target db?, value, from form? + + if(!empty($input['zahlbarbis_tage'])) { + $zahlbarbis = date_create_from_format('Y-m-d', $input['rechnungsdatum']); + date_add($zahlbarbis,date_interval_create_from_date_string($input['zahlbarbis_tage']." days")); + $input['zahlbarbis'] = date_format($zahlbarbis, 'Y-m-d'); + } + unset($input['zahlbarbis_tage']); + if(!empty($input['skontobis_tage'])) { + $skontobis = date_create_from_format('Y-m-d', $input['rechnungsdatum']); + date_add($skontobis,date_interval_create_from_date_string($input['skontobis_tage']." days")); + $input['skontobis'] = date_format($skontobis, 'Y-m-d'); + } + unset($input['skontobis_tage']); + + $input['adresse'] = $this->app->erp->ReplaceLieferantennummer(true,$input['adresse'],true); // Parameters: Target db?, value, from form? $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],true); $input['kostenstelle'] = $this->app->DB->Select("SELECT id FROM kostenstellen WHERE nummer = '".$input['kostenstelle']."'"); $input['bestellung'] = $this->app->erp->ReplaceBestellung(true,$input['bestellung'],true); if(empty($input['projekt']) && !empty($input['adresse'])) { - $input['projekt'] = $this->app->erp->GetCreateProjekt($input['adresse']); + $input['projekt'] = $this->app->erp->GetCreateProjekt($input['adresse']); } if (!empty($input['adresse'])) { $adressdaten = $this->app->DB->SelectRow(" - SELECT + SELECT zahlungszieltagelieferant, zahlungszieltageskontolieferant, zahlungszielskontolieferant, @@ -619,7 +634,7 @@ class Verbindlichkeit { FROM adresse WHERE id = ".$input['adresse'] ); - + if ($input['zahlbarbis'] == '0000-00-00' && $input['rechnungsdatum'] != '0000-00-00' && !empty($adressdaten['zahlungszieltagelieferant'])) { $input['zahlbarbis'] = date('Y-m-d',strtotime($input['rechnungsdatum']." + ".$adressdaten['zahlungszieltagelieferant']." days")); } @@ -630,12 +645,12 @@ class Verbindlichkeit { } - } + } $columns = "id, "; $values = "$id, "; $update = ""; - + $fix = ""; foreach ($input as $key => $value) { @@ -662,7 +677,7 @@ class Verbindlichkeit { header("Location: index.php?module=verbindlichkeit&action=edit&id=$id&msg=$msg"); } else { $this->app->Tpl->Set('MESSAGE', "
Die Einstellungen wurden erfolgreich übernommen.
"); - } + } break; case 'positionen_hinzufuegen': @@ -676,7 +691,7 @@ class Verbindlichkeit { $werte = $this->app->Secure->GetPOST('werte'); $preise = $this->app->Secure->GetPOST('preise'); - $bruttoeingabe = $this->app->Secure->GetPOST('bruttoeingabe'); + $bruttoeingabe = $this->app->Secure->GetPOST('bruttoeingabe'); foreach ($ids as $key => $paketdistribution) { $menge = $werte[$key]; @@ -687,13 +702,13 @@ class Verbindlichkeit { // Check available number $sql = " - SELECT + SELECT IF( pd.menge > COALESCE(vp.menge,0), pd.menge - COALESCE(vp.menge,0), 0 ) offen_menge - FROM + FROM paketdistribution pd LEFT JOIN( SELECT @@ -705,7 +720,7 @@ class Verbindlichkeit { paketdistribution ) vp ON - vp.paketdistribution = pd.id + vp.paketdistribution = pd.id WHERE pd.id = ".$paketdistribution." "; $offen_menge = $this->app->DB->Select($sql); @@ -719,27 +734,27 @@ class Verbindlichkeit { } $preis = $preise[$key]; - $sql = "SELECT + $sql = "SELECT a.id, a.umsatzsteuer, a.steuersatz, COALESCE(if (skart.id <> 0,skart.id,skadr.id),0) AS kontorahmen - FROM - paketdistribution pd + FROM + paketdistribution pd INNER JOIN paketannahme pa ON pa.id = pd.paketannahme - INNER JOIN + INNER JOIN artikel a ON a.id = pd.artikel - INNER JOIN + INNER JOIN adresse adr ON pa.adresse = adr.id - LEFT JOIN + LEFT JOIN kontorahmen skart ON skart.id = a.kontorahmen - LEFT JOIN - kontorahmen skadr ON skadr.id = adr.kontorahmen + LEFT JOIN + kontorahmen skadr ON skadr.id = adr.kontorahmen WHERE pd.id =".$paketdistribution; $artikel = $this->app->DB->SelectRow($sql); - + $einartikel = $artikel['id']; $umsatzsteuer = $artikel['umsatzsteuer']; $kontorahmen = $artikel['kontorahmen']; @@ -752,13 +767,13 @@ class Verbindlichkeit { if ($bruttoeingabe) { $preis = $preis / (1+($steuersatz/100)); - } + } $sql = "INSERT INTO verbindlichkeit_position (verbindlichkeit,paketdistribution, menge, preis, steuersatz, artikel, kontorahmen) VALUES ($id, $paketdistribution, $menge, $preis, $steuersatz, $einartikel, $kontorahmen)"; $this->app->DB->Insert($sql); } - break; - case 'positionen_entfernen': + break; + case 'positionen_entfernen': $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; if ($freigabe['rechnungsfreigabe'] || $freigabe['freigabe']) { @@ -769,10 +784,10 @@ class Verbindlichkeit { if (!is_array($ids)) { break; } - $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id IN (".implode(',',$ids).") AND v.freigabe <> 1"); + $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id IN (".implode(',',$ids).") AND v.freigabe <> 1"); - break; - case 'positionen_steuersatz_zu_netto': + break; + case 'positionen_steuersatz_zu_netto': $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; if ($freigabe['rechnungsfreigabe'] || $freigabe['freigabe']) { @@ -792,12 +807,12 @@ class Verbindlichkeit { $faktor = 1+($tmpsteuersatz/100); - $sql = "UPDATE verbindlichkeit_position SET preis = preis / ".$faktor." WHERE id = $posid"; + $sql = "UPDATE verbindlichkeit_position SET preis = preis / ".$faktor." WHERE id = $posid"; $this->app->DB->Update($sql); - } + } break; - case 'positionen_kontorahmen_setzen': + case 'positionen_kontorahmen_setzen': $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; if ($freigabe['rechnungsfreigabe']) { break; @@ -811,14 +826,14 @@ class Verbindlichkeit { $positionen_sachkonto = $this->app->Secure->GetPOST('positionen_sachkonto'); $positionen_kontorahmen = $this->app->erp->ReplaceKontorahmen(true,$positionen_sachkonto,false); - foreach ($ids as $posid) { - $sql = "UPDATE verbindlichkeit_position SET kontorahmen = '".$positionen_kontorahmen."' WHERE id =".$posid; + foreach ($ids as $posid) { + $sql = "UPDATE verbindlichkeit_position SET kontorahmen = '".$positionen_kontorahmen."' WHERE id =".$posid; $this->app->DB->Update($sql); - } + } break; } - + // Load values again from database $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, @@ -851,7 +866,7 @@ class Verbindlichkeit { v.bezahlt, v.kontoauszuege, v.firma, - v.logdatei, + v.logdatei, v.waehrung, v.zahlungsweise, v.eingangsdatum, @@ -896,40 +911,40 @@ class Verbindlichkeit { a.name AS adresse_name FROM verbindlichkeit v LEFT JOIN adresse a ON a.id = v.adresse"." WHERE v.id=$id"); foreach ($result[0] as $key => $value) { - $this->app->Tpl->Set(strtoupper($key), $value); + $this->app->Tpl->Set(strtoupper($key), $value); } if (!empty($result[0])) { $verbindlichkeit_from_db = $result[0]; } - // Check positions - $pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']); - + // Check positions + $pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']); + $this->app->Tpl->Set('BETRAGNETTO', $pos_check['betrag_netto']); $this->app->Tpl->Set('BETRAGBRUTTOPOS', $pos_check['betrag_brutto']); - + if (empty($pos_check['rundungsdifferenz'])) { - $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden'); + $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden'); } else { - $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']); + $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']); } - if ($pos_check['pos_ok']) { + if ($pos_check['pos_ok']) { if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) { if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) { $this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)"); $verbindlichkeit_from_db['freigabe'] = 1; } else { - $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen'); + $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen'); } - } - $this->app->Tpl->Set('POSITIONENMESSAGE', '
Positionen vollständig
'); - + } + $this->app->Tpl->Set('POSITIONENMESSAGE', '
Positionen vollständig
'); + if ($verbindlichkeit_from_db['status'] != 'abgeschlossen' && $verbindlichkeit_from_db['status'] != 'storniert') { - $this->verbindlichkeit_abschliessen($id); - } - + $this->verbindlichkeit_abschliessen($id); + } + } else { $this->app->Tpl->Set(' POSITIONENMESSAGE', '
Positionen nicht vollständig. Bruttobetrag '. @@ -939,30 +954,30 @@ class Verbindlichkeit { ', Differenz '. round($pos_check['betrag_brutto']-$verbindlichkeit_from_db['betrag'],2). '
' - ); + ); if ($verbindlichkeit_from_db['freigabe']) { $this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id); $verbindlichkeit_from_db['freigabe'] = 0; - $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)"); + $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)"); } - } - + } + /* * Add displayed items later - * + * $this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email); $this->app->Tpl->Add('EMAIL', $email); - $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername); + $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername); $this->app->YUI->AutoComplete("artikel", "artikelnummer"); */ - $this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); // prevent manual setting + $this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); // prevent manual setting if (empty($verbindlichkeit_from_db['adresse']) || $verbindlichkeit_from_db['status'] == 'angelegt') { - $this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden'); - $this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden'); + $this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden'); + $this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden'); $this->app->Tpl->Set('POSITIONHINZUFUEGENHIDDEN','hidden'); $this->app->Tpl->Set('POSITIONENHIDDEN','hidden'); } @@ -980,19 +995,19 @@ class Verbindlichkeit { if (!empty($positionen)) { $this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); } - + if ($verbindlichkeit_from_db['rechnungsfreigabe']) { $this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden'); $this->app->Tpl->Set('RUECKSETZENEINKAUFHIDDEN','hidden'); - $this->app->Tpl->Set('SACHKONTOCHANGEHIDDEN','hidden'); + $this->app->Tpl->Set('SACHKONTOCHANGEHIDDEN','hidden'); } else { $this->app->Tpl->Set('RUECKSETZENBUCHHALTUNGHIDDEN','hidden'); - } + } if ($verbindlichkeit_from_db['bezahlt'] == '1') { $this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden'); } else { $this->app->Tpl->Set('RUECKSETZENBEZAHLTHIDDEN','hidden'); - } + } $this->app->Tpl->Set('WARENEINGANGCHECKED', $verbindlichkeit_from_db['freigabe']==1?"checked":""); $this->app->Tpl->Set('RECHNUNGSFREIGABECHECKED', $verbindlichkeit_from_db['rechnungsfreigabe']==1?"checked":""); @@ -1007,9 +1022,9 @@ class Verbindlichkeit { $this->app->Tpl->Set('ZAHLBARBIS',$this->app->erp->ReplaceDatum(false,$verbindlichkeit_from_db['zahlbarbis'],false)); $this->app->YUI->DatePicker("zahlbarbis"); - $sql = "SELECT - ".$this->app->YUI->IconsSQLVerbindlichkeit() . " AS `icons` - FROM verbindlichkeit v + $sql = "SELECT + ".$this->app->YUI->IconsSQLVerbindlichkeit() . " AS `icons` + FROM verbindlichkeit v LEFT JOIN ( SELECT ds.parameter, COUNT(ds.objekt) datei_anzahl FROM datei_stichwoerter ds INNER JOIN datei d ON d.id = ds.datei WHERE ds.objekt='verbindlichkeit' AND d.geloescht <> 1 GROUP BY ds.parameter ) d ON d.parameter = v.id @@ -1017,7 +1032,7 @@ class Verbindlichkeit { $icons = $this->app->DB->SelectArr($sql); $this->app->Tpl->Add('STATUSICONS', $icons[0]['icons']); - $this->app->YUI->AutoComplete("adresse", "lieferant"); + $this->app->YUI->AutoComplete("adresse", "lieferant"); $this->app->YUI->AutoComplete("projekt", "projektname", 1); $this->app->Tpl->Set('PROJEKT',$this->app->erp->ReplaceProjekt(false,$verbindlichkeit_from_db['projekt'],false)); $this->app->YUI->AutoComplete("kostenstelle", "kostenstelle", 1); @@ -1028,16 +1043,16 @@ class Verbindlichkeit { $this->app->Tpl->Set('ADRESSE_ID', $verbindlichkeit_from_db['adresse']); - $this->app->Tpl->Set('ADRESSE', $this->app->erp->ReplaceLieferantennummer(false,$verbindlichkeit_from_db['adresse'],false)); // Convert ID to form display + $this->app->Tpl->Set('ADRESSE', $this->app->erp->ReplaceLieferantennummer(false,$verbindlichkeit_from_db['adresse'],false)); // Convert ID to form display $this->app->Tpl->Set('BESTELLUNG',$this->app->erp->ReplaceBestellung(false,$verbindlichkeit_from_db['bestellung'],false)); - $this->app->YUI->AutoComplete("bestellung", "lieferantenbestellung",0,"&adresse=".$verbindlichkeit_from_db['adresse']); + $this->app->YUI->AutoComplete("bestellung", "lieferantenbestellung",0,"&adresse=".$verbindlichkeit_from_db['adresse']); $this->app->YUI->CkEditor("internebemerkung"); $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id); if ($anzahldateien > 0) { - $file = urlencode("../../../../index.php?module=verbindlichkeit&action=inlinepdf&id=$id"); + $file = urlencode("../../../../index.php?module=verbindlichkeit&action=inlinepdf&id=$id"); $iframe = ""; $this->app->Tpl->Set('INLINEPDF', $iframe); } else { @@ -1047,7 +1062,7 @@ class Verbindlichkeit { if (empty($verbindlichkeit_from_db['freigabe'])) { $this->app->YUI->TableSearch('PAKETDISTRIBUTION', 'verbindlichkeit_paketdistribution_list', "show", "", "", basename(__FILE__), __CLASS__); } - + // -- POSITIONEN $this->app->YUI->AutoComplete("positionen_sachkonto", "sachkonto", 1); $this->app->YUI->TableSearch('POSITIONEN', 'verbindlichkeit_positionen', "show", "", "", basename(__FILE__), __CLASS__); @@ -1061,15 +1076,15 @@ class Verbindlichkeit { function verbindlichkeit_editpos() { $id = $this->app->Secure->GetGET('id'); - $posid = $this->app->Secure->GetGET('posid'); - + $posid = $this->app->Secure->GetGET('posid'); + $this->app->Tpl->Set('ID', $id); $this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=edit&id=$id#tabs-2", "Zurück"); $sachkonto = $this->app->Secure->GetPOST('sachkonto'); - $menge = $this->app->Secure->GetPOST('menge'); - $preis = $this->app->Secure->GetPOST('preis'); - $steuersatz = $this->app->Secure->GetPOST('steuersatz'); + $menge = $this->app->Secure->GetPOST('menge'); + $preis = $this->app->Secure->GetPOST('preis'); + $steuersatz = $this->app->Secure->GetPOST('steuersatz'); $kontorahmen = $this->app->erp->ReplaceKontorahmen(true,$sachkonto,false); if ($menge < 0) { @@ -1081,20 +1096,20 @@ class Verbindlichkeit { if ($steuersatz < 0) { $steuersatz = 0; } - $submit = $this->app->Secure->GetPOST('submit'); + $submit = $this->app->Secure->GetPOST('submit'); - $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; + $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0]; if ($freigabe['rechnungsfreigabe'] && $freigabe['freigabe']) { $this->app->Tpl->Set('SAVEDISABLED','disabled'); $this->app->Tpl->Set('SACHKONTOSAVEDISABLED','disabled'); } else if ($freigabe['freigabe']) { - $this->app->Tpl->Set('SAVEDISABLED','disabled'); + $this->app->Tpl->Set('SAVEDISABLED','disabled'); if ($submit != '') - { + { $sql = " - UPDATE verbindlichkeit_position SET + UPDATE verbindlichkeit_position SET kontorahmen = '$kontorahmen' - WHERE id = ".$posid." + WHERE id = ".$posid." "; $this->app->DB->Update($sql); $this->app->Tpl->Set('MESSAGE', "
Die Einstellungen wurden erfolgreich übernommen.
"); @@ -1102,14 +1117,14 @@ class Verbindlichkeit { } } else { if ($submit != '') - { + { $sql = " - UPDATE verbindlichkeit_position SET + UPDATE verbindlichkeit_position SET menge = '$menge', preis = '$preis', steuersatz = '$steuersatz', kontorahmen = '$kontorahmen' - WHERE id = ".$posid." + WHERE id = ".$posid." "; $this->app->DB->Update($sql); @@ -1117,13 +1132,13 @@ class Verbindlichkeit { header("Location: index.php?module=verbindlichkeit&action=edit&id=$id&msg=$msg#tabs-2"); } } - + // Load values again from database $dropnbox = "'' AS `open`, CONCAT('') AS `auswahl`"; - $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, v.steuersatz, v.preis, v.menge, v.kontorahmen, v.id FROM verbindlichkeit_position v"." WHERE id=$posid"); + $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, v.steuersatz, v.preis, v.menge, v.kontorahmen, v.id FROM verbindlichkeit_position v"." WHERE id=$posid"); foreach ($result[0] as $key => $value) { - $this->app->Tpl->Set(strtoupper($key), $value); + $this->app->Tpl->Set(strtoupper($key), $value); } if (!empty($result)) { @@ -1131,14 +1146,14 @@ class Verbindlichkeit { } else { return; } - + /* * Add displayed items later - * + * $this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email); $this->app->Tpl->Add('EMAIL', $email); - $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername); + $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername); $this->app->YUI->AutoComplete("artikel", "artikelnummer"); @@ -1159,10 +1174,12 @@ class Verbindlichkeit { $input['adresse'] = $this->app->Secure->GetPOST('adresse'); $input['rechnung'] = $this->app->Secure->GetPOST('rechnung'); $input['zahlbarbis'] = $this->app->Secure->GetPOST('zahlbarbis'); + $input['zahlbarbis_tage'] = $this->app->Secure->GetPOST('zahlbarbis_tage'); $input['betrag'] = $this->app->Secure->GetPOST('betrag'); $input['waehrung'] = $this->app->Secure->GetPOST('waehrung'); $input['skonto'] = $this->app->Secure->GetPOST('skonto'); $input['skontobis'] = $this->app->Secure->GetPOST('skontobis'); + $input['skontobis_tage'] = $this->app->Secure->GetPOST('skontobis_tage'); $input['projekt'] = $this->app->Secure->GetPOST('projekt'); $input['zahlungsweise'] = $this->app->Secure->GetPOST('zahlungsweise'); $input['eingangsdatum'] = $this->app->Secure->GetPOST('eingangsdatum'); @@ -1173,14 +1190,14 @@ class Verbindlichkeit { return $input; } - function verbindlichkeit_menu($id) { + function verbindlichkeit_menu($id) { $this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=edit&id=$id", "Details"); $this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Zurück zur Übersicht"); $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id); if ($anzahldateien > 0) { - $anzahldateien = " (".$anzahldateien.")"; + $anzahldateien = " (".$anzahldateien.")"; } else { $anzahldateien=""; } @@ -1199,7 +1216,7 @@ class Verbindlichkeit { if ($invoiceArr['status'] === 'angelegt' || empty($invoiceArr['status'])) { $this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=freigabe&id=$id",'Freigabe'); - } + } } function verbindlichkeit_dateien() @@ -1211,9 +1228,9 @@ class Verbindlichkeit { } function verbindlichkeit_inlinepdf() { - $id = $this->app->Secure->GetGET('id'); + $id = $this->app->Secure->GetGET('id'); - $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','verbindlichkeit',$id); + $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','verbindlichkeit',$id); if (!empty($file_attachments)) { @@ -1242,14 +1259,14 @@ class Verbindlichkeit { echo($file_contents); $this->app->ExitXentral(); } - } - } - } + } + } + } $this->app->ExitXentral(); } - + function verbindlichkeit_freigabe() - { + { $id = $this->app->Secure->GetGET('id'); $this->app->erp->BelegFreigabe('verbindlichkeit',$id); $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben"); @@ -1258,7 +1275,7 @@ class Verbindlichkeit { // Returns true or error message function verbindlichkeit_freigabeeinkauf($id = null, $text = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; @@ -1266,35 +1283,35 @@ class Verbindlichkeit { $error = false; - if (!$this->verbindlichkeit_is_freigegeben($id)) { + if (!$this->verbindlichkeit_is_freigegeben($id)) { if ($gotoedit) { - $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben'); + $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben'); $error = true; } else { return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id)); - } - } + } + } - // Check wareneingang status - $sql = "SELECT - pa.id - FROM verbindlichkeit_position vp + // Check wareneingang status + $sql = "SELECT + pa.id + FROM verbindlichkeit_position vp INNER JOIN paketdistribution pd ON pd.id = vp.paketdistribution - INNER JOIN paketannahme pa ON pa.id = pd.paketannahme + INNER JOIN paketannahme pa ON pa.id = pd.paketannahme WHERE - verbindlichkeit='$id' + verbindlichkeit='$id' AND - pa.status = 'abgeschlossen' + pa.status = 'abgeschlossen' "; - $check = $this->app->DB->SelectArr($sql); + $check = $this->app->DB->SelectArr($sql); if (empty($check)) { if ($gotoedit) { - $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen'); + $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen'); } else { return('Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen '.$this->verbindlichkeit_get_belegnr($id)); - } + } } else { $sql = "UPDATE verbindlichkeit SET freigabe = 1 WHERE id=".$id; $this->app->DB->Update($sql); @@ -1309,57 +1326,57 @@ class Verbindlichkeit { } else { return(true); - } + } } // Returns true or error message function verbindlichkeit_freigabebuchhaltung($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; - } + } $error = false; - if (!$this->verbindlichkeit_is_freigegeben($id)) { + if (!$this->verbindlichkeit_is_freigegeben($id)) { if ($gotoedit) { $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben'); $error = true; } else { return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id)); - } + } } if (!$error) { // Check accounting $sql = " - SELECT + SELECT vp.id, - v.belegnr - FROM verbindlichkeit_position vp + v.belegnr + FROM verbindlichkeit_position vp LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit - WHERE + WHERE verbindlichkeit='$id' AND vp.kontorahmen = 0 "; - $check = $this->app->DB->SelectArr($sql); + $check = $this->app->DB->SelectArr($sql); - if (!empty($check)) { + if (!empty($check)) { if ($gotoedit) { - $this->app->YUI->Message('warning','Kontierung unvollständig'); + $this->app->YUI->Message('warning','Kontierung unvollständig'); $error = true; } else { return('Kontierung unvollständig '.$this->verbindlichkeit_get_belegnr($id)); } } } - - if (!$error) { + + if (!$error) { $sql = "UPDATE verbindlichkeit SET rechnungsfreigabe = 1 WHERE freigabe = 1 AND id=".$id; $this->app->DB->Update($sql); - $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)"); + $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)"); } if ($gotoedit) { @@ -1371,21 +1388,21 @@ class Verbindlichkeit { // Returns true or error message function verbindlichkeit_freigabebezahlt($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; } - if (!$this->verbindlichkeit_is_freigegeben($id)) { + if (!$this->verbindlichkeit_is_freigegeben($id)) { if ($gotoedit) { - $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben'); + $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben'); $error = true; } else { return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id)); - } + } } - + if (!$error) { $sql = "UPDATE verbindlichkeit SET bezahlt = 1 WHERE id=".$id; $this->app->DB->Update($sql); @@ -1394,20 +1411,20 @@ class Verbindlichkeit { $this->verbindlichkeit_edit(); } else { return(true); - } + } } - } - + } + function verbindlichkeit_abschliessen($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; } - - $sql = "SELECT freigabe, rechnungsfreigabe, bezahlt, betrag FROM verbindlichkeit WHERE id =".$id; + + $sql = "SELECT freigabe, rechnungsfreigabe, bezahlt, betrag FROM verbindlichkeit WHERE id =".$id; $verbindlichkeit = $this->app->DB->SelectRow($sql); - + if ($verbindlichkeit['freigabe'] != 1) { $einkauf_check = $this->check_positions($id,$verbindlichkeit['betrag']); if ($einkauf_check['pos_ok']) { @@ -1415,20 +1432,20 @@ class Verbindlichkeit { $verbindlichkeit['freigabe'] = 1; } } - - $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id); + + $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id); if (!empty($anzahldateien) && $verbindlichkeit['freigabe'] && $verbindlichkeit['rechnungsfreigabe'] && $verbindlichkeit['bezahlt']) { $sql = "UPDATE verbindlichkeit SET status = 'abgeschlossen' WHERE id=".$id; $this->app->DB->Update($sql); - $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit abgeschlossen"); + $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit abgeschlossen"); if ($gotoedit) { $this->verbindlichkeit_edit(); - } - } - } + } + } + } function verbindlichkeit_ruecksetzeneinkauf($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; @@ -1442,7 +1459,7 @@ class Verbindlichkeit { } function verbindlichkeit_ruecksetzenbuchhaltung($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; @@ -1456,7 +1473,7 @@ class Verbindlichkeit { } function verbindlichkeit_ruecksetzenbezahlt($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; @@ -1466,11 +1483,11 @@ class Verbindlichkeit { $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit bezahlt rückgesetzt"); if ($gotoedit) { $this->verbindlichkeit_edit(); - } - } - + } + } + /* function verbindlichkeit_schreibschutz($id = null) - { + { if (empty($id)) { $id = $this->app->Secure->GetGET('id'); $gotoedit = true; @@ -1480,14 +1497,14 @@ class Verbindlichkeit { $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit Schreibschutz entfernt"); if ($gotoedit) { $this->verbindlichkeit_edit(); - } + } } */ public function verbindlichkeit_minidetail($parsetarget='',$menu=true) { - $id = $this->app->Secure->GetGET('id'); + $id = $this->app->Secure->GetGET('id'); - $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS + $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, v.belegnr, v.status_beleg, @@ -1542,14 +1559,14 @@ class Verbindlichkeit { v.sprache, v.id, CONCAT(a.lieferantennummer,' ',a.name) AS adresse - FROM verbindlichkeit v + FROM verbindlichkeit v LEFT JOIN adresse a ON a.id = v.adresse LEFT JOIN projekt p ON a.projekt = p.id LEFT JOIN kostenstellen k ON v.kostenstelle = k.id - WHERE v.id='$id'"); + WHERE v.id='$id'"); foreach ($result[0] as $key => $value) { - $this->app->Tpl->Set(strtoupper($key), $value); + $this->app->Tpl->Set(strtoupper($key), $value); } if (!empty($result[0])) { @@ -1564,11 +1581,11 @@ class Verbindlichkeit { vp.preis, vp.steuersatz, CONCAT(skv.sachkonto,' ',skv.beschriftung) AS sachkonto, - '' - FROM verbindlichkeit_position vp - INNER JOIN artikel art ON art.id = vp.artikel + '' + FROM verbindlichkeit_position vp + INNER JOIN artikel art ON art.id = vp.artikel LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit - LEFT JOIN adresse adr ON adr.id = v.adresse + LEFT JOIN adresse adr ON adr.id = v.adresse LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen WHERE verbindlichkeit='$id' ORDER by vp.sort ASC"); @@ -1612,7 +1629,7 @@ class Verbindlichkeit { '', '', 'Betrag Positionen netto', - 'Betrag Positionen brutto' + 'Betrag Positionen brutto' ); $tmp->AddRow($row); $row = array( @@ -1639,20 +1656,20 @@ class Verbindlichkeit { } function verbindlichkeit_is_freigegeben($id) { - $sql = "SELECT - belegnr - FROM + $sql = "SELECT + belegnr + FROM verbindlichkeit WHERE - id='$id' + id='$id' AND - status IN ('freigegeben') + status IN ('freigegeben') "; - $check = $this->app->DB->SelectArr($sql); + $check = $this->app->DB->SelectArr($sql); if (empty($check)) { return(false); - } else + } else { return(true); } @@ -1663,7 +1680,7 @@ class Verbindlichkeit { } /* Calculate steuersatz - Get from + Get from Check address first, if foreign, then steuersatz = 0 if not foreign there are three cases: befreit = 0, ermaessigt, normal if not befreit, get from projekt or firmendaten @@ -1676,19 +1693,19 @@ class Verbindlichkeit { if ($umsatzsteuer == 'befreit') { return(0); } - + $adresse = $this->app->DB->Select("SELECT adresse FROM verbindlichkeit WHERE id=".$verbindlichkeit); $umsatzsteuer_lieferant = $this->app->DB->Select("SELECT umsatzsteuer_lieferant FROM adresse WHERE id=".$adresse); /* inland, eu-lieferung, import*/ if (in_array($umsatzsteuer_lieferant,array('import','eulieferung'))) { return(0); } - + $projekt = $this->app->DB->Select("SELECT projekt FROM verbindlichkeit WHERE id=".$verbindlichkeit); $steuersatz_projekt = $this->app->DB->SelectRow("SELECT steuersatz_normal, steuersatz_ermaessigt FROM projekt WHERE id ='".$projekt."'"); $steuersatz_normal_projekt = $steuersatz_projekt['steuer_normal']; $steuersatz_ermaessigt_projekt = $steuersatz_projekt['steuer_ermaessigt']; - + $steuersatz_normal = $this->app->erp->Firmendaten('steuersatz_normal'); $steuersatz_ermaessigt = $this->app->erp->Firmendaten('steuersatz_ermaessigt'); @@ -1698,22 +1715,22 @@ class Verbindlichkeit { return($steuersatz_normal_projekt); } else { return($steuersatz_normal); - } + } break; case 'ermaessigt': if (!empty($steuersatz_ermaessigt_projekt)) { return($steuersatz_ermaessigt_projekt); } else { return($steuersatz_ermaessigt); - } + } break; - default: + default: return(0); break; } } - + // Check positions and return status and values function check_positions($id, $bruttobetrag_verbindlichkeit) : array { @@ -1723,7 +1740,7 @@ class Verbindlichkeit { "betrag_brutto" => 0, "rundungsdifferenz" => 0, "bruttobetrag_verbindlichkeit" => $bruttobetrag_verbindlichkeit - ); + ); if (empty($id)) { return($result); @@ -1731,7 +1748,7 @@ class Verbindlichkeit { // Summarize positions $sql = "SELECT * FROM verbindlichkeit_position WHERE verbindlichkeit = ".$id; - $positionen = $this->app->DB->SelectArr($sql); + $positionen = $this->app->DB->SelectArr($sql); if (!empty($positionen)) { $betrag_netto = 0; @@ -1740,7 +1757,7 @@ class Verbindlichkeit { $steuer_normal = 0; $steuer_ermaessigt = 0; - /* + /* Normal: umsatzsteuer leer, steuersatz = leer Ermäßigt: umsatzsteuer ermaessigt, steuersatz = -1 Befreit: umsatzsteuer befreit, steursatz = -1 @@ -1757,27 +1774,27 @@ class Verbindlichkeit { $position['steuersatz_berechnet'] = $tmpsteuersatz; $position['steuertext_berechnet'] = $tmpsteuertext; $position['steuererloes_berechnet'] = $erloes; - + $betrag_netto += ($position['menge']*$position['preis']); $betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)); $betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2); } - + $result['betrag_netto'] = round($betrag_netto,2); $result['betrag_brutto'] = round($betrag_brutto,2); - + if ($bruttobetrag_verbindlichkeit == round($betrag_brutto,2)) { - $result['pos_ok'] = true; + $result['pos_ok'] = true; } else if (round($bruttobetrag_verbindlichkeit,2) == round($betrag_brutto_pos_summe,2)) { - $result['pos_ok'] = true; + $result['pos_ok'] = true; if (round($bruttobetrag_verbindlichkeit,2) != round($betrag_brutto_pos_summe,2)) { $result['rundungsdifferenz'] = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2); - } - } - } - + } + } + } + return($result); } } From 19ac3415e36527d743662457dcada45ce1cce830 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 25 Aug 2024 20:15:43 +0200 Subject: [PATCH 7/7] verbindlichkeit bugfix netto positions rounded --- www/pages/verbindlichkeit.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php index 3eda30d8..110b3462 100644 --- a/www/pages/verbindlichkeit.php +++ b/www/pages/verbindlichkeit.php @@ -1756,6 +1756,7 @@ class Verbindlichkeit { $betrag_brutto_pos_summe = 0; $steuer_normal = 0; $steuer_ermaessigt = 0; + $betrag_brutto_alternativ = 0; /* Normal: umsatzsteuer leer, steuersatz = leer @@ -1763,6 +1764,9 @@ class Verbindlichkeit { Befreit: umsatzsteuer befreit, steursatz = -1 Individuell: umsatzsteuer leer, steuersatz = wert */ + + $betrag_brutto_pro_steuersatz = array(); + foreach ($positionen as $position) { $tmpsteuersatz = null; @@ -1775,23 +1779,31 @@ class Verbindlichkeit { $position['steuertext_berechnet'] = $tmpsteuertext; $position['steuererloes_berechnet'] = $erloes; - $betrag_netto += ($position['menge']*$position['preis']); - $betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)); - $betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2); + $betrag_netto_pos = ($position['menge']*$position['preis']); + $betrag_netto += $betrag_netto_pos; + $betrag_brutto_pos = ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)); + $betrag_brutto += $betrag_brutto_pos; + $betrag_brutto_pos_summe += round($betrag_brutto_pos,2); + $betrag_netto_pro_steuersatz[$tmpsteuersatz] += round($betrag_netto_pos,2); } $result['betrag_netto'] = round($betrag_netto,2); $result['betrag_brutto'] = round($betrag_brutto,2); + foreach ($betrag_netto_pro_steuersatz as $steuersatz => $betrag_netto) { + $betrag_brutto_alternativ += round($betrag_netto*(1+($steuersatz/100)),2); + } + if ($bruttobetrag_verbindlichkeit == round($betrag_brutto,2)) { $result['pos_ok'] = true; } else if (round($bruttobetrag_verbindlichkeit,2) == round($betrag_brutto_pos_summe,2)) { $result['pos_ok'] = true; - if (round($bruttobetrag_verbindlichkeit,2) != round($betrag_brutto_pos_summe,2)) { - $result['rundungsdifferenz'] = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2); - } + $result['rundungsdifferenz'] = round($bruttobetrag_verbindlichkeit-$result['betrag_brutto'],2); + } else if (round($bruttobetrag_verbindlichkeit,2) == $betrag_brutto_alternativ) { + $result['pos_ok'] = true; + $result['rundungsdifferenz'] = round($bruttobetrag_verbindlichkeit-$result['betrag_brutto'],2); } }