mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
Merge remote-tracking branch 'upstream/master' into subscriptioncycle
This commit is contained in:
commit
fe7d4332c8
@ -62,33 +62,90 @@ class MailAttachmentData implements MailAttachmentInterface
|
||||
{
|
||||
$encodingHeader = $part->getHeader('content-transfer-encoding');
|
||||
if ($encodingHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Transfer-Encoding"');
|
||||
// Assume this is no error (?) throw new InvalidArgumentException('missing header: "Content-Transfer-Encoding"');
|
||||
$encoding = '';
|
||||
} else {
|
||||
$encoding = $encodingHeader->getValue();
|
||||
}
|
||||
$encoding = $encodingHeader->getValue();
|
||||
$dispositionHeader = $part->getHeader('content-disposition');
|
||||
if ($dispositionHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Disposition"');
|
||||
}
|
||||
$disposition = $dispositionHeader->getValue();
|
||||
$disposition = $dispositionHeader->getValue();
|
||||
|
||||
if (!preg_match('/(.+);\s*filename="([^"]+)".*$/m', $disposition, $matches)) {
|
||||
/*
|
||||
Content-Disposition: inline
|
||||
Content-Disposition: attachment
|
||||
Content-Disposition: attachment; filename="filename.jpg"
|
||||
|
||||
This is not correctly implemented -> only the first string is evaluated
|
||||
Content-Disposition: attachment; filename*0="filename_that_is_"
|
||||
Content-Disposition: attachment; filename*1="very_long.jpg"
|
||||
|
||||
*/
|
||||
|
||||
if (preg_match('/(.+);\s*filename(?:\*[0-9]){0,1}="([^"]+)".*$/m', $disposition, $matches)) {
|
||||
$isInline = strtolower($matches[1]) === 'inline';
|
||||
$filename = $matches[2];
|
||||
}
|
||||
else if ($disposition == 'attachment') {
|
||||
// Filename is given in Content-Type e.g.
|
||||
/* Content-Type: application/pdf; name="Filename.pdf"
|
||||
Content-Transfer-Encoding: base64
|
||||
Content-Disposition: attachment
|
||||
*/
|
||||
|
||||
$contenttypeHeader = $part->getHeader('content-type');
|
||||
if ($contenttypeHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Type"');
|
||||
}
|
||||
$contenttype = $contenttypeHeader->getValue();
|
||||
|
||||
if (preg_match('/(.+);\s*name(?:\*[0-9]){0,1}="([^"]+)".*$/m', $contenttype, $matches)) {
|
||||
$isInline = strtolower($matches[1]) === 'inline';
|
||||
$filename = $matches[2];
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('missing filename in header value "Content-Type" = "%s"', $contenttype)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if ($disposition == 'inline') {
|
||||
$isInline = true;
|
||||
$filename = ""; // This is questionable
|
||||
}
|
||||
else if (strpos($disposition,'attachment;\n') == 0) { // No filename, check for content type message/rfc822
|
||||
|
||||
$contenttypeHeader = $part->getHeader('content-type');
|
||||
if ($contenttypeHeader === null) {
|
||||
throw new InvalidArgumentException('missing header: "Content-Type"');
|
||||
}
|
||||
$contenttype = $contenttypeHeader->getValue();
|
||||
|
||||
if ($contenttype == 'message/rfc822') {
|
||||
$isInline = false;
|
||||
$filename = 'ForwardedMessage.eml';
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('unexpected header value "Content-Disposition" = "%s"', $disposition)
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('unexpected header value "Content-Disposition" = %s', $disposition)
|
||||
sprintf('unexpected header value "Content-Disposition" = "%s", not message/rfc822', $disposition)
|
||||
);
|
||||
}
|
||||
$isInline = strtolower($matches[1]) === 'inline';
|
||||
$filename = $matches[2];
|
||||
|
||||
// Thunderbird UTF URL-Format
|
||||
$UTF_pos = strpos($filename,'UTF-8\'\'');
|
||||
if ($UTF_pos !== false) {
|
||||
|
||||
if ($UTF_pos !== false) {
|
||||
$wasUTF = "JA";
|
||||
|
||||
$filename = substr($filename,$UTF_pos);
|
||||
$filename = rawurldecode($filename);
|
||||
}
|
||||
|
||||
|
||||
$cid = null;
|
||||
$contentIdHeader = $part->getHeader('content-id');
|
||||
if ($contentIdHeader !== null) {
|
||||
|
@ -308,10 +308,7 @@ final class MailMessageData implements MailMessageInterface, JsonSerializable
|
||||
if ($date === null) {
|
||||
return null;
|
||||
}
|
||||
$dateTime = DateTime::createFromFormat(DateTimeInterface::RFC2822, $date->getValue());
|
||||
if ($dateTime === false) {
|
||||
$dateTime = DateTime::createFromFormat(DateTimeInterface::RFC822, $date->getValue());
|
||||
}
|
||||
$dateTime = date_create($date->getValue());
|
||||
if ($dateTime === false) {
|
||||
return null;
|
||||
}
|
||||
|
@ -22,12 +22,22 @@ class TicketFormatter
|
||||
*/
|
||||
public function encodeToUtf8(string $string): string
|
||||
{
|
||||
$encoding = mb_detect_encoding($string, 'UTF-8, ISO-8859-1, ISO-8859-15', true);
|
||||
|
||||
return mb_convert_encoding(
|
||||
$converted = mb_convert_encoding(
|
||||
$string,
|
||||
'UTF-8',
|
||||
$encoding
|
||||
'auto'
|
||||
);
|
||||
|
||||
// Fallback
|
||||
if ($converted === false) {
|
||||
$converted = mb_convert_encoding(
|
||||
$string,
|
||||
'UTF-8',
|
||||
'iso-8859-1'
|
||||
);
|
||||
}
|
||||
|
||||
return ($converted);
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ class TicketImportHelper
|
||||
if (!empty($queue_id)) {
|
||||
$queue_label = $this->db->Select("SELECT label FROM warteschlangen WHERE id = ".$queue_id." LIMIT 1");
|
||||
}
|
||||
|
||||
|
||||
$insertTicket = "INSERT INTO `ticket` (
|
||||
`schluessel`, `zeit`, `projekt`, `quelle`, `status`, `kunde`,
|
||||
`mailadresse`, `prio`, `betreff`,`warteschlange`,`adresse`
|
||||
@ -347,10 +347,10 @@ class TicketImportHelper
|
||||
'".$projectId."',
|
||||
'".$this->mailAccount->getEmailAddress()."',
|
||||
'".$status."',
|
||||
'".$senderName."',
|
||||
'".$senderAddress."',
|
||||
'".$this->db->real_escape_string($senderName)."',
|
||||
'".$this->db->real_escape_string($senderAddress)."',
|
||||
'".'3'."',
|
||||
'".$subject."',
|
||||
'".$this->db->real_escape_string($subject)."',
|
||||
'".$queue_label."',
|
||||
'".$AddressId."');";
|
||||
|
||||
@ -383,14 +383,14 @@ class TicketImportHelper
|
||||
) VALUES (
|
||||
'".$ticketNumber."',
|
||||
'".date('Y-m-d H:i:s', $timestamp)."',
|
||||
'".$message."',
|
||||
'".$subject."',
|
||||
'".$this->db->real_escape_string($message)."',
|
||||
'".$this->db->real_escape_string($subject)."',
|
||||
'".'email'."',
|
||||
'".$senderName."',
|
||||
'".$senderAddress."',
|
||||
'".$this->db->real_escape_string($senderName)."',
|
||||
'".$this->db->real_escape_string($senderAddress)."',
|
||||
'".$status."',
|
||||
'".$replyToName."',
|
||||
'".$replyToAddress."');";
|
||||
'".$this->db->real_escape_string($replyToName)."',
|
||||
'".$this->db->real_escape_string($replyToAddress)."');";
|
||||
|
||||
$this->logger->debug('database insert',['query' => $sql]);
|
||||
$this->db->Insert($sql);
|
||||
@ -491,7 +491,7 @@ class TicketImportHelper
|
||||
}
|
||||
try {
|
||||
|
||||
$this->logger->debug('Start import', ['message' => $message->getSubject()]);
|
||||
$this->logger->debug('Start import', ['message' => $message]);
|
||||
|
||||
$result = $this->importMessage($message);
|
||||
|
||||
@ -545,18 +545,33 @@ class TicketImportHelper
|
||||
$htmlBody = $message->getHtmlBody();
|
||||
if ($htmlBody === null) {
|
||||
$htmlBody = '';
|
||||
}
|
||||
|
||||
if ($plainTextBody == '' && $htmlBody == '') {
|
||||
$simple_content = $message->getContent();
|
||||
if (empty($simple_content)) {
|
||||
$this->logger->debug('Empty mail',['message' => $message]);
|
||||
} else {
|
||||
$plainTextBody = $simple_content;
|
||||
$htmlBody = nl2br(htmlentities($simple_content));
|
||||
}
|
||||
}
|
||||
|
||||
$this->logger->debug('Text',['plain' => $plainTextBody, 'html' => $htmlBody, 'simple_content' => $simple_content]);
|
||||
|
||||
$action = $this->formatter->encodeToUtf8($plainTextBody);
|
||||
$action_html = $this->formatter->encodeToUtf8($htmlBody);
|
||||
if (strlen($action_html) < strlen($action)) {
|
||||
$action_html = nl2br($action);
|
||||
}
|
||||
|
||||
$this->logger->debug('Text (converted)',['plain' => $action, 'html' => $action_html]);
|
||||
|
||||
// Import database emailbackup
|
||||
$date = $message->getDate();
|
||||
if (is_null($date)) { // This should not be happening -> Todo check getDate function
|
||||
$this->logger->debug('Null date',['subject' => $message->getSubject()]);
|
||||
$frommd5 = md5($from . $subject);
|
||||
$this->logger->debug('Null date',['subject' => $message->getSubject(), $message->getHeader('date')->getValue()]);
|
||||
return(false);
|
||||
} else {
|
||||
$timestamp = $date->getTimestamp();
|
||||
$frommd5 = md5($from . $subject . $timestamp);
|
||||
@ -576,7 +591,7 @@ class TicketImportHelper
|
||||
|
||||
if ($result == 0) {
|
||||
|
||||
$this->logger->debug('Importing message',['']);
|
||||
$this->logger->debug('Importing message',['message' => $message]);
|
||||
|
||||
$attachments = $message->getAttachments();
|
||||
$anhang = count($attachments) > 0 ? 1 : 0;
|
||||
|
@ -1083,9 +1083,9 @@ $tooltip['produktionszentrum']['abschluss']['#auftragmengenanpassen']="Die Menge
|
||||
|
||||
$tooltip['produktion']['abschluss']['#mengeerfolgreich'] = 'Höhere Mengen als die geplante Menge können nur mit der deaktivierten (kein Haken setzen) Systemeinstellung "Produktionskorrektur nicht verwenden" verbucht werden. ';
|
||||
$tooltip['produktion']['edit']['#mengeerfolgreich'] = $tooltip['produktion']['abschluss']['#mengeerfolgreich'];
|
||||
$tooltip['produktion']['create']['#standardlager'] = "Lager, aus dem die Artikel für die Produktion ausgelagert werden sollen.Hier können alle Lager ausgewählt werden, in denen sich mindestens ein Lagerplatz befindet, aus dem Produktionen ausgelagert werden dürfen (Einstellung auf Regalebene unter Lager => Lagerverwaltung).";
|
||||
$tooltip['produktion']['create']['#standardlager'] = "Lager, aus dem die Artikel für die Produktion ausgelagert werden sollen. Hier können alle Lager ausgewählt werden, in denen sich mindestens ein Lagerplatz befindet, aus dem Produktionen ausgelagert werden dürfen (Einstellung auf Regalebene unter Lager => Lagerverwaltung).";
|
||||
$tooltip['produktion']['edit']['#standardlager'] = $tooltip['produktion']['create']['#standardlager'];
|
||||
|
||||
$tooltip['produktion']['edit']['#ziellager'] = "Wenn kein Ziellager angegenen ist, wird in das Standard-Lager des Artikels gebucht, wenn es das nicht gibt, in das Materiallager der Produktion.";
|
||||
|
||||
/* PROJEKT */
|
||||
|
||||
@ -1460,4 +1460,4 @@ $tooltip['coppersurcharge']['list']['surcharge-invoice'] = '(Pflichtfeld) Welche
|
||||
$tooltip['coppersurcharge']['list']['surcharge-delivery-costs'] = '(Pflichtfeld) Bezugskosten sind eine Grundlage der Berechnungsformel (in %): Kupferzuschlag EUR/km = (Kupfergewicht (kg/km) * (DEL + Bezugskosten)) - Kupferbasis / 100. Der Standard sind derzeit 1%';
|
||||
$tooltip['coppersurcharge']['list']['surcharge-copper-base-standard'] = '(Pflichtfeld) Die Kupferbasis ist eine Grundlage der Berechnungsformel: Kupferzuschlag EUR/km = (Kupfergewicht (kg/km) * (DEL + Bezugskosten)) - Kupferbasis / 100. Der Standard sind derzeit 150 EUR pro 100kg';
|
||||
$tooltip['coppersurcharge']['list']['surcharge-copper-base'] = 'Falls ein Artikel eine abweichende Kupferbasis haben soll kann diese in einem Freifeld gepflegt werden. Dieses kann hier ausgewählt werden.';
|
||||
$tooltip['coppersurcharge']['list']['surcharge-copper-number'] = '(Pflichtfeld) In diesem Freifeld kann die artikelspezifische Kupferzahl (km/kg) gepflegt werden. Sie ist Grundlage der Berechnung: Kupferzuschlag EUR/km = (Kupfergewicht (kg/km) * (DEL + Bezugskosten)) - Kupferbasis / 100.';
|
||||
$tooltip['coppersurcharge']['list']['surcharge-copper-number'] = '(Pflichtfeld) In diesem Freifeld kann die artikelspezifische Kupferzahl (km/kg) gepflegt werden. Sie ist Grundlage der Berechnung: Kupferzuschlag EUR/km = (Kupfergewicht (kg/km) * (DEL + Bezugskosten)) - Kupferbasis / 100.';
|
||||
|
@ -197,7 +197,7 @@ class Acl
|
||||
break;
|
||||
case 'dateien':
|
||||
|
||||
$sql = "SELECT objekt FROM datei_stichwoerter WHERE datei = %s";
|
||||
$sql = "SELECT objekt FROM datei_stichwoerter WHERE datei = %s LIMIT 1";
|
||||
$dateiModul = strtolower($this->app->DB->Select(sprintf($sql,$id)));
|
||||
|
||||
//TODO datei_stichwoerter.objekt ist nicht zuverlässig für alle Datentypen. Deswegen nur zur Absicherung der bekannten Fälle #604706
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"host": "localhost",
|
||||
"database": "openxe",
|
||||
"user": "openxe",
|
||||
"passwd": "openxe"
|
||||
}
|
@ -1,343 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Helper to compare database structures from files vs. database
|
||||
*
|
||||
* Copyright (c) 2022 OpenXE project
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
MariaDB [openxe]> SHOW FULL db_def;
|
||||
+----------------------------------------------+------------+
|
||||
| Tables_in_openxe | Table_type |
|
||||
+----------------------------------------------+------------+
|
||||
| abrechnungsartikel | BASE TABLE |
|
||||
| abrechnungsartikel_gruppe | BASE TABLE |
|
||||
| abschlagsrechnung_rechnung | BASE TABLE |
|
||||
| accordion | BASE TABLE |
|
||||
| adapterbox | BASE TABLE |
|
||||
| adapterbox_log | BASE TABLE |
|
||||
| adapterbox_request_log | BASE TABLE |
|
||||
| adresse | BASE TABLE |
|
||||
| adresse_abosammelrechnungen | BASE TABLE |
|
||||
| adresse_accounts | BASE TABLE |
|
||||
| adresse_filter | BASE TABLE |
|
||||
| adresse_filter_gruppen | BASE TABLE |
|
||||
...
|
||||
|
||||
|
||||
MariaDB [openxe]> SHOW FULL COLUMNS FROM wiki;
|
||||
+-------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
|
||||
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
|
||||
+-------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
|
||||
| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
|
||||
| name | varchar(255) | utf8mb3_general_ci | YES | MUL | NULL | | select,insert,update,references | |
|
||||
| content | longtext | utf8mb3_general_ci | NO | | NULL | | select,insert,update,references | |
|
||||
| lastcontent | longtext | utf8mb3_general_ci | NO | | NULL | | select,insert,update,references | |
|
||||
| wiki_workspace_id | int(11) | NULL | NO | | 0 | | select,insert,update,references | |
|
||||
| parent_id | int(11) | NULL | NO | | 0 | | select,insert,update,references | |
|
||||
| language | varchar(32) | utf8mb3_general_ci | NO | | | | select,insert,update,references | |
|
||||
+-------------------+--------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
|
||||
|
||||
MariaDB [openxe]> show keys from wiki;
|
||||
+-------+------------+----------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
||||
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
|
||||
+-------+------------+----------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
||||
| wiki | 0 | PRIMARY | 1 | id | A | 244 | NULL | NULL | | BTREE | | | NO |
|
||||
| wiki | 0 | suche | 1 | name | A | 244 | NULL | NULL | YES | BTREE | | | NO |
|
||||
| wiki | 0 | suche | 2 | wiki_workspace_id | A | 244 | NULL | NULL | | BTREE | | | NO |
|
||||
| wiki | 1 | name | 1 | name | A | 244 | NULL | NULL | YES | BTREE | | | NO |
|
||||
+-------+------------+----------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
|
||||
|
||||
*/
|
||||
|
||||
require('mustal_mysql_upgrade_tool.php');
|
||||
|
||||
$connection_info_file_name = "connection_info.json";
|
||||
$target_folder = ".";
|
||||
$tables_file_name_wo_folder = "db_schema.json";
|
||||
$tables_file_name_w_folder = $target_folder."/".$tables_file_name_wo_folder;
|
||||
$delimiter = ";";
|
||||
$quote = '"';
|
||||
|
||||
$sql_file_name = "upgrade.sql";
|
||||
|
||||
$color_red = "\033[31m";
|
||||
$color_green = "\033[32m";
|
||||
$color_yellow = "\033[33m";
|
||||
$color_default = "\033[39m";
|
||||
|
||||
// -------------------------------- START
|
||||
|
||||
echo("\n");
|
||||
|
||||
if ($argc > 1) {
|
||||
|
||||
if (in_array('-v', $argv)) {
|
||||
$verbose = true;
|
||||
} else {
|
||||
$verbose = false;
|
||||
}
|
||||
|
||||
if (in_array('-f', $argv)) {
|
||||
$force = true;
|
||||
} else {
|
||||
$force = false;
|
||||
}
|
||||
|
||||
if (in_array('-e', $argv)) {
|
||||
$export = true;
|
||||
} else {
|
||||
$export = false;
|
||||
}
|
||||
|
||||
if (in_array('-c', $argv)) {
|
||||
$compare = true;
|
||||
} else {
|
||||
$compare = false;
|
||||
}
|
||||
|
||||
if (in_array('-i', $argv)) {
|
||||
$onlytables = true;
|
||||
} else {
|
||||
$onlytables = false;
|
||||
}
|
||||
|
||||
if (in_array('-upgrade', $argv)) {
|
||||
$upgrade = true;
|
||||
} else {
|
||||
$upgrade = false;
|
||||
}
|
||||
|
||||
if (in_array('-do', $argv)) {
|
||||
$doupgrade = true;
|
||||
} else {
|
||||
$doupgrade = false;
|
||||
}
|
||||
|
||||
if (in_array('-clean', $argv)) {
|
||||
$clean = true;
|
||||
} else {
|
||||
$clean = false;
|
||||
}
|
||||
|
||||
if (in_array('-utf8fix', $argv)) {
|
||||
$utf8fix = true;
|
||||
} else {
|
||||
$utf8fix = false;
|
||||
}
|
||||
|
||||
$connection_info_contents = file_get_contents($connection_info_file_name);
|
||||
if (!$connection_info_contents) {
|
||||
echo("Unable to load $connection_info_file_name\n");
|
||||
exit;
|
||||
}
|
||||
$connection_info = json_decode($connection_info_contents, true);
|
||||
|
||||
$host = $connection_info['host'];
|
||||
$user = $connection_info['user'];
|
||||
$passwd = $connection_info['passwd'];
|
||||
$schema = $connection_info['database'];
|
||||
|
||||
echo("--------------- Loading from database '$schema@$host'... ---------------\n");
|
||||
$db_def = mustal_load_tables_from_db($host, $schema, $user, $passwd, $mustal_replacers);
|
||||
|
||||
if (empty($db_def)) {
|
||||
echo ("Could not load from $schema@$host\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo("--------------- Loading from database '$schema@$host' complete. ---------------\n");
|
||||
|
||||
if ($export) {
|
||||
|
||||
echo("--------------- Export to JSON... ---------------\n");
|
||||
// $result = save_tables_to_csv($db_def, $target_folder, $tables_file_name_wo_folder, $delimiter, $quote, $keys_postfix, $force);
|
||||
$result = mustal_save_tables_to_json($db_def, $target_folder, $tables_file_name_wo_folder, $force);
|
||||
|
||||
if ($result != 0) {
|
||||
|
||||
$result_texts = array("ok","key postfix error","table list file error","table file error","key file error");
|
||||
|
||||
echo ("Could not save to JSON (".$result_texts[$result]."). To overwrite, use -f.\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo("Exported ".count($db_def['tables'])." tables.\n");
|
||||
echo("--------------- Export to JSON ($tables_file_name_w_folder) complete. ---------------\n");
|
||||
}
|
||||
|
||||
if ($compare || $upgrade) {
|
||||
|
||||
// Results here as ['text'] ['diff']
|
||||
$compare_differences = array();
|
||||
|
||||
echo("--------------- Loading from JSON... ---------------\n");
|
||||
$compare_def = mustal_load_tables_from_json($target_folder, $tables_file_name_wo_folder);
|
||||
|
||||
if (empty($compare_def)) {
|
||||
echo ("Could not load from JSON $tables_file_name_w_folder\n");
|
||||
exit;
|
||||
}
|
||||
echo("--------------- Loading from JSON complete. ---------------\n");
|
||||
|
||||
// Do the comparison
|
||||
/*
|
||||
echo("--------------- Comparing JSON '".$compare_def['database']."@".$compare_def['host']."' vs. database '$schema@$host' ---------------\n");
|
||||
|
||||
echo(count($compare_def['tables'])." tables in JSON, ".count($db_def['tables'])." tables in database.\n");
|
||||
$compare_differences = compare_table_array($db_def,"in DB",$compare_def,"in JSON",false);
|
||||
echo("Comparison found ".(empty($compare_differences)?0:count($compare_differences))." differences.\n");
|
||||
|
||||
if ($verbose) {
|
||||
foreach ($compare_differences as $compare_difference) {
|
||||
$comma = "";
|
||||
foreach ($compare_difference as $key => $value) {
|
||||
echo($comma."$key => '$value'");
|
||||
$comma = ", ";
|
||||
}
|
||||
echo("\n");
|
||||
}
|
||||
}*/
|
||||
|
||||
echo("--------------- Comparing database '$schema@$host' vs. JSON '".$compare_def['database']."@".$compare_def['host']."' ---------------\n");
|
||||
|
||||
if($utf8fix) {
|
||||
$column_collation_aliases = array(
|
||||
['utf8mb3_general_ci','utf8_general_ci']
|
||||
);
|
||||
} else {
|
||||
$column_collation_aliases = array();
|
||||
}
|
||||
|
||||
$compare_differences = mustal_compare_table_array($compare_def,"in JSON",$db_def,"in DB",true,$column_collation_aliases);
|
||||
echo((empty($compare_differences)?0:count($compare_differences))." differences.\n");
|
||||
|
||||
if ($verbose) {
|
||||
foreach ($compare_differences as $compare_difference) {
|
||||
$comma = "";
|
||||
foreach ($compare_difference as $key => $value) {
|
||||
echo($comma."$key => [$value]");
|
||||
$comma = ", ";
|
||||
}
|
||||
echo("\n");
|
||||
}
|
||||
}
|
||||
echo("--------------- Comparison complete. ---------------\n");
|
||||
}
|
||||
|
||||
if ($upgrade) {
|
||||
// First create all db_def that are missing in the db
|
||||
echo("--------------- Calculating database upgrade for '$schema@$host'... ---------------\n");
|
||||
|
||||
$upgrade_sql = array();
|
||||
|
||||
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers);
|
||||
|
||||
if ($result != 0) {
|
||||
echo("Error: $result\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
echo(count($result)." errors.\n");
|
||||
if ($verbose) {
|
||||
foreach($result as $error) {
|
||||
echo("Code: ".$error[0]." '".$error[1]."'.");
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
echo("--------------- Database upgrade for '$schema@$host'... ---------------\n");
|
||||
if ($verbose) {
|
||||
foreach($upgrade_sql as $statement) {
|
||||
echo($statement."\n");
|
||||
}
|
||||
}
|
||||
|
||||
echo(count($upgrade_sql)." upgrade statements\n");
|
||||
echo("--------------- Database upgrade calculated for '$schema@$host' (show SQL with -v). ---------------\n");
|
||||
|
||||
if ($doupgrade) {
|
||||
echo("--------------- Executing database upgrade for '$schema@$host' database will be written! ---------------\n");
|
||||
|
||||
// First get the contents of the database table structure
|
||||
$mysqli = mysqli_connect($host, $user, $passwd, $schema);
|
||||
|
||||
/* Check if the connection succeeded */
|
||||
if (!$mysqli) {
|
||||
echo ("Failed to connect!\n");
|
||||
} else {
|
||||
|
||||
$counter = 0;
|
||||
$error_counter = 0;
|
||||
$number_of_statements = count($upgrade_sql);
|
||||
|
||||
foreach ($upgrade_sql as $sql) {
|
||||
|
||||
$counter++;
|
||||
echo("\rUpgrade step $counter of $number_of_statements... ");
|
||||
|
||||
if ($verbose) {
|
||||
echo("(".substr($sql,0,100)."...) ");
|
||||
}
|
||||
|
||||
$query_result = mysqli_query($mysqli, $sql);
|
||||
if (!$query_result) {
|
||||
$error = " not ok: ". mysqli_error($mysqli)."\n";
|
||||
echo($error);
|
||||
file_put_contents("./errors.txt",$error.$sql."\n",FILE_APPEND);
|
||||
$error_counter++;
|
||||
} else {
|
||||
echo("ok.\r");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo("--------------- Executing database upgrade for '$schema@$host' executed. ---------------\n");
|
||||
echo("$error_counter errors.\n");
|
||||
echo("--------------- Executing database upgrade for '$schema@$host' done. ---------------\n");
|
||||
|
||||
echo("--------------- Checking database upgrade for '$schema@$host'... ---------------\n");
|
||||
$db_def = mustal_load_tables_from_db($host, $schema, $user, $passwd, $mustal_replacers);
|
||||
|
||||
echo("--------------- Comparing database '$schema@$host' vs. JSON '".$compare_def['database']."@".$compare_def['host']."' ---------------\n");
|
||||
$compare_differences = mustal_compare_table_array($compare_def,"in JSON",$db_def,"in DB",true);
|
||||
echo((empty($compare_differences)?0:count($compare_differences))." differences.\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // upgrade
|
||||
|
||||
echo("--------------- Done. ---------------\n");
|
||||
|
||||
echo("\n");
|
||||
|
||||
} else {
|
||||
info();
|
||||
exit;
|
||||
}
|
||||
|
||||
function info() {
|
||||
echo("OpenXE database compare\n");
|
||||
echo("Copyright 2022 (c) OpenXE project\n");
|
||||
echo("\n");
|
||||
echo("Export database structures in a defined format for database comparison / upgrade\n");
|
||||
echo("Options:\n");
|
||||
echo("\t-v: verbose output\n");
|
||||
echo("\t-f: force override of existing files\n");
|
||||
echo("\t-e: export database structure to files\n");
|
||||
echo("\t-c: compare content of files with database structure\n");
|
||||
echo("\t-i: ignore column definitions\n");
|
||||
echo("\t-utf8fix: apply fix for 'utf8' != 'utf8mb3'\n");
|
||||
echo("\t-upgrade: Create the needed SQL to upgrade the database to match the JSON\n");
|
||||
echo("\t-do: Execute the SQL to upgrade the database to match the JSON (risky!)\n");
|
||||
echo("\t-clean: (not yet implemented) Create the needed SQL to remove items from the database not in the JSON\n");
|
||||
echo("\n");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,661 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
MUSTAL Mysql Upgrade Schema Tool by Alex Ledis
|
||||
Helper to compare database structures from JSON files vs. database and upgrade database
|
||||
Copyright (c) 2022 Alex Ledis
|
||||
Licensed under AGPL v3
|
||||
|
||||
Version 1.0
|
||||
|
||||
function mustal_load_tables_from_db(string $host, string $schema, string $user, string $passwd, $replacers) : array
|
||||
Load structure from db connection to an array.
|
||||
|
||||
function mustal_save_tables_to_json(array $db_def, string $path, string $tables_file_name, bool $force) : int
|
||||
Save structure from array to a JSON file.
|
||||
|
||||
function mustal_load_tables_from_json(string $path, string $tables_file_name) : array
|
||||
Load structure from JSON file into array.
|
||||
|
||||
function mustal_compare_table_array(array $nominal, string $nominal_name, array $actual, string $actual_name, bool $check_column_definitions) : array
|
||||
Compare two database structures
|
||||
Returns a structured array containing information on all the differences.
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql) : int
|
||||
Generate the SQL needed to upgrade the database to match the definition, based on a comparison.
|
||||
|
||||
Data structure in Array and JSON
|
||||
{
|
||||
"host": "hostname",
|
||||
"database": "schemaname",
|
||||
"user": "username",
|
||||
"tables": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "",
|
||||
"columns": [
|
||||
{
|
||||
"Field": "",
|
||||
"Type": "",
|
||||
"Collation": "",
|
||||
"Null": "",
|
||||
"Key": "",
|
||||
"Default": "",
|
||||
"Extra": "",
|
||||
"Privileges": "",
|
||||
"Comment": ""
|
||||
}
|
||||
],
|
||||
"keys": [
|
||||
{
|
||||
"Key_name": "",
|
||||
"columns": [
|
||||
"",
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// These default values will not be in quotes, converted to lowercase and be replaced by the second entry
|
||||
$mustal_replacers = [
|
||||
['current_timestamp','current_timestamp()'],
|
||||
['on update current_timestamp','on update current_timestamp()']
|
||||
];
|
||||
|
||||
// Load all db_def from a DB connection into a db_def array
|
||||
function mustal_load_tables_from_db(string $host, string $schema, string $user, string $passwd, $replacers) : array {
|
||||
|
||||
// First get the contents of the database table structure
|
||||
$mysqli = mysqli_connect($host, $user, $passwd, $schema);
|
||||
|
||||
/* Check if the connection succeeded */
|
||||
if (!$mysqli) {
|
||||
return(array());
|
||||
}
|
||||
|
||||
// Get db_def and views
|
||||
|
||||
$sql = "SHOW FULL tables";
|
||||
$query_result = mysqli_query($mysqli, $sql);
|
||||
if (!$query_result) {
|
||||
return(array());
|
||||
}
|
||||
while ($row = mysqli_fetch_assoc($query_result)) {
|
||||
$table = array();
|
||||
$table['name'] = $row['Tables_in_'.$schema];
|
||||
$table['type'] = $row['Table_type'];
|
||||
$tables[] = $table; // Add table to list of tables
|
||||
}
|
||||
|
||||
// Get and add columns of the table
|
||||
foreach ($tables as &$table) {
|
||||
$sql = "SHOW FULL COLUMNS FROM ".$table['name'];
|
||||
$query_result = mysqli_query($mysqli, $sql);
|
||||
|
||||
if (!$query_result) {
|
||||
return(array());
|
||||
}
|
||||
|
||||
$columns = array();
|
||||
while ($column = mysqli_fetch_assoc($query_result)) {
|
||||
// Do some harmonization
|
||||
|
||||
if ($column['Default'] !== NULL) {
|
||||
mustal_sql_replace_reserved_functions($column,$replacers);
|
||||
$column['Default'] = mustal_mysql_put_text_type_in_quotes($column['Type'],$column['Default']);
|
||||
}
|
||||
|
||||
$columns[] = $column; // Add column to list of columns
|
||||
}
|
||||
$table['columns'] = $columns;
|
||||
|
||||
$sql = "SHOW KEYS FROM ".$table['name'];
|
||||
$query_result = mysqli_query($mysqli, $sql);
|
||||
if (!$query_result) {
|
||||
return(array());
|
||||
}
|
||||
$keys = array();
|
||||
while ($key = mysqli_fetch_assoc($query_result)) {
|
||||
$keys[] = $key; // Add key to list of keys
|
||||
}
|
||||
// Compose comparable format for keys
|
||||
$composed_keys = array();
|
||||
foreach ($keys as $key) {
|
||||
|
||||
// Check if this key exists already
|
||||
|
||||
$key_pos = array_search($key['Key_name'],array_column($composed_keys,'Key_name'));
|
||||
|
||||
if ($key_pos == false) {
|
||||
// New key
|
||||
$composed_key = array();
|
||||
$composed_key['Key_name'] = $key['Key_name'];
|
||||
$composed_key['Index_type'] = $key['Index_type'];
|
||||
$composed_key['columns'][] = $key['Column_name'];
|
||||
$composed_keys[] = $composed_key;
|
||||
} else {
|
||||
// Given key, add column
|
||||
$composed_keys[$key_pos]['columns'][] .= $key['Column_name'];
|
||||
}
|
||||
}
|
||||
unset($key);
|
||||
$table['keys'] = $composed_keys;
|
||||
unset($composed_keys);
|
||||
}
|
||||
unset($table);
|
||||
|
||||
$result = array();
|
||||
$result['host'] = $host;
|
||||
$result['database'] = $schema;
|
||||
$result['user'] = $user;
|
||||
$result['tables'] = $tables;
|
||||
return($result);
|
||||
}
|
||||
|
||||
function mustal_save_tables_to_json(array $db_def, string $path, string $tables_file_name, bool $force) : int {
|
||||
|
||||
// Prepare db_def file
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
if (!$force && file_exists($path."/".$tables_file_name)) {
|
||||
return(2);
|
||||
}
|
||||
|
||||
$tables_file = fopen($path."/".$tables_file_name, "w");
|
||||
if (empty($tables_file)) {
|
||||
return(2);
|
||||
}
|
||||
|
||||
fwrite($tables_file, json_encode($db_def,JSON_PRETTY_PRINT));
|
||||
|
||||
fclose($tables_file);
|
||||
return(0);
|
||||
}
|
||||
|
||||
// Load all db_def from JSON file
|
||||
function mustal_load_tables_from_json(string $path, string $tables_file_name) : array {
|
||||
|
||||
$db_def = array();
|
||||
|
||||
$contents = file_get_contents($path."/".$tables_file_name);
|
||||
|
||||
if (!$contents) {
|
||||
return(array());
|
||||
}
|
||||
|
||||
$db_def = json_decode($contents, true);
|
||||
|
||||
if (!$db_def) {
|
||||
return(array());
|
||||
}
|
||||
|
||||
return($db_def);
|
||||
}
|
||||
|
||||
// Compare two definitions
|
||||
// Report based on the first array
|
||||
// Return Array
|
||||
// $column_collation_aliases may contain synonyms for collations e.g. utf8mb3_general_ci vs utf8_general_ci
|
||||
function mustal_compare_table_array(array $nominal, string $nominal_name, array $actual, string $actual_name, bool $check_column_definitions, array $column_collation_aliases = array()) : array {
|
||||
|
||||
$compare_differences = array();
|
||||
|
||||
if (count($nominal['tables']) != count($actual['tables'])) {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Table count";
|
||||
$compare_difference[$nominal_name] = count($nominal['tables']);
|
||||
$compare_difference[$actual_name] = count($actual['tables']);
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
|
||||
foreach ($nominal['tables'] as $database_table) {
|
||||
|
||||
$found_table = array();
|
||||
foreach ($actual['tables'] as $compare_table) {
|
||||
if ($database_table['name'] == $compare_table['name']) {
|
||||
$found_table = $compare_table;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($compare_table);
|
||||
|
||||
if ($found_table) {
|
||||
|
||||
// Check type table vs view
|
||||
|
||||
if ($database_table['type'] != $found_table['type']) {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Table type";
|
||||
$compare_difference['table'] = $database_table['name'];
|
||||
$compare_difference[$nominal_name] = $database_table['type'];
|
||||
$compare_difference[$actual_name] = $found_table['type'];
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
|
||||
// Only BASE TABLE supported now
|
||||
if ($found_table['type'] != 'BASE TABLE') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check columns
|
||||
$compare_table_columns = array_column($found_table['columns'],'Field');
|
||||
foreach ($database_table['columns'] as $column) {
|
||||
|
||||
$column_name_to_find = $column['Field'];
|
||||
$column_key = array_search($column_name_to_find,$compare_table_columns,true);
|
||||
if ($column_key !== false) {
|
||||
|
||||
// Compare the properties of the columns
|
||||
if ($check_column_definitions) {
|
||||
$found_column = $found_table['columns'][$column_key];
|
||||
foreach ($column as $key => $value) {
|
||||
|
||||
// Apply aliases
|
||||
if (!empty($column_collation_aliases)) {
|
||||
foreach($column_collation_aliases as $column_collation_alias) {
|
||||
if ($value == $column_collation_alias[0]) {
|
||||
$value = $column_collation_alias[1];
|
||||
}
|
||||
if ($found_column[$key] == $column_collation_alias[0]) {
|
||||
$found_column[$key] = $column_collation_alias[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($found_column[$key] != $value) {
|
||||
if ($key != 'Key') { // Keys will be handled separately
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Column definition";
|
||||
$compare_difference['table'] = $database_table['name'];
|
||||
$compare_difference['column'] = $column['Field'];
|
||||
$compare_difference['property'] = $key;
|
||||
$compare_difference[$nominal_name] = $value;
|
||||
$compare_difference[$actual_name] = $found_column[$key];
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
} // $check_column_definitions
|
||||
} else {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Column existence";
|
||||
$compare_difference['table'] = $database_table['name'];
|
||||
$compare_difference[$nominal_name] = $column['Field'];
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
}
|
||||
unset($column);
|
||||
|
||||
|
||||
// Check keys
|
||||
$compare_table_sql_indexs = array_column($found_table['keys'],'Key_name');
|
||||
foreach ($database_table['keys'] as $sql_index) {
|
||||
|
||||
$sql_index_name_to_find = $sql_index['Key_name'];
|
||||
$sql_index_key = array_search($sql_index_name_to_find,$compare_table_sql_indexs,true);
|
||||
if ($sql_index_key !== false) {
|
||||
|
||||
// Compare the properties of the sql_indexs
|
||||
if ($check_column_definitions) {
|
||||
$found_sql_index = $found_table['keys'][$sql_index_key];
|
||||
foreach ($sql_index as $key => $value) {
|
||||
if ($found_sql_index[$key] != $value) {
|
||||
|
||||
// if ($key != 'permissions') {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Key definition";
|
||||
$compare_difference['table'] = $database_table['name'];
|
||||
$compare_difference['key'] = $sql_index['Key_name'];
|
||||
$compare_difference['property'] = $key;
|
||||
$compare_difference[$nominal_name] = implode(',',$value);
|
||||
$compare_difference[$actual_name] = implode(',',$found_sql_index[$key]);
|
||||
$compare_differences[] = $compare_difference;
|
||||
// }
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
} // $check_sql_index_definitions
|
||||
} else {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Key existence";
|
||||
$compare_difference['table'] = $database_table['name'];
|
||||
$compare_difference[$nominal_name] = $sql_index['Key_name'];
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
}
|
||||
unset($sql_index);
|
||||
|
||||
|
||||
} else {
|
||||
$compare_difference = array();
|
||||
$compare_difference['type'] = "Table existence";
|
||||
$compare_difference[$nominal_name] = $database_table['name'];
|
||||
$compare_differences[] = $compare_difference;
|
||||
}
|
||||
}
|
||||
unset($database_table);
|
||||
|
||||
return($compare_differences);
|
||||
}
|
||||
|
||||
|
||||
// Generate SQL to create or modify column
|
||||
function mustal_column_sql_definition(string $table_name, array $column, array $reserved_words_without_quote) : string {
|
||||
|
||||
foreach($column as $key => &$value) {
|
||||
$value = (string) $value;
|
||||
$value = mustal_column_sql_create_property_definition($key,$value,$reserved_words_without_quote);
|
||||
}
|
||||
|
||||
// Default handling here
|
||||
if ($column['Default'] == " DEFAULT ''") {
|
||||
$column['Default'] = "";
|
||||
}
|
||||
|
||||
$sql =
|
||||
$column['Type'].
|
||||
$column['Null'].
|
||||
$column['Default'].
|
||||
$column['Extra'].
|
||||
$column['Collation'];
|
||||
|
||||
return($sql);
|
||||
}
|
||||
|
||||
// Generate SQL to modify a single column property
|
||||
function mustal_column_sql_create_property_definition(string $property, string $property_value, array $reserved_words_without_quote) : string {
|
||||
|
||||
switch ($property) {
|
||||
case 'Type':
|
||||
break;
|
||||
case 'Null':
|
||||
if ($property_value == "NO") {
|
||||
$property_value = " NOT NULL"; // Idiotic...
|
||||
}
|
||||
if ($property_value == "YES") {
|
||||
$property_value = " NULL"; // Also Idiotic...
|
||||
}
|
||||
break;
|
||||
case 'Default':
|
||||
// Check for MYSQL function mustal_call as default
|
||||
|
||||
if (in_array(strtolower($property_value),$reserved_words_without_quote)) {
|
||||
$quote = "";
|
||||
} else {
|
||||
// Remove quotes if there are
|
||||
$property_value = trim($property_value,"'");
|
||||
$quote = "'";
|
||||
}
|
||||
$property_value = " DEFAULT $quote".$property_value."$quote";
|
||||
break;
|
||||
case 'Extra':
|
||||
if ($property_value != '') {
|
||||
$property_value = " ".$property_value;
|
||||
}
|
||||
break;
|
||||
case 'Collation':
|
||||
if ($property_value != '') {
|
||||
$property_value = " COLLATE ".$property_value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$property_value = "";
|
||||
break;
|
||||
}
|
||||
|
||||
return($property_value);
|
||||
}
|
||||
|
||||
// Replaces different variants of the same function mustal_to allow comparison
|
||||
function mustal_sql_replace_reserved_functions(array &$column, array $replacers) {
|
||||
|
||||
$result = strtolower($column['Default']);
|
||||
foreach ($replacers as $replace) {
|
||||
if ($result == $replace[0]) {
|
||||
$result = $replace[1];
|
||||
}
|
||||
}
|
||||
$column['Default'] = $result;
|
||||
|
||||
$result = strtolower($column['Extra']);
|
||||
foreach ($replacers as $replace) {
|
||||
if ($result == $replace[0]) {
|
||||
$result = $replace[1];
|
||||
}
|
||||
}
|
||||
$column['Extra'] = $result;
|
||||
}
|
||||
|
||||
// Is it a text type? -> Use quotes then
|
||||
function mustal_mysql_put_text_type_in_quotes(string $checktype, string $value) : string {
|
||||
$types = array('char','varchar','tinytext','text','mediumtext','longtext');
|
||||
|
||||
foreach($types as $type) {
|
||||
if (stripos($checktype, $type) !== false) {
|
||||
return("'".$value."'");
|
||||
}
|
||||
}
|
||||
return($value);
|
||||
}
|
||||
|
||||
function mustal_implode_with_quote(string $quote, string $delimiter, array $array_to_implode) : string {
|
||||
return($quote.implode($quote.$delimiter.$quote, $array_to_implode).$quote);
|
||||
}
|
||||
|
||||
|
||||
// Calculate the sql neccessary to update the database
|
||||
// returns array(code,text)
|
||||
// Error codes:
|
||||
// 0 ok
|
||||
// 1 Upgrade type of table not supported
|
||||
// 2 Error on table upgrade
|
||||
// 3 Error on column existence upgrade
|
||||
// 4 Error on column existence upgrade
|
||||
// 5 Error on column definition upgrade
|
||||
// 6 Error on column definition upgrade
|
||||
// 7 Error on key existence upgrade
|
||||
// 8 Error on key existence upgrade
|
||||
// 9 Error on key definition upgrade
|
||||
// 10 Error on key definition upgrade
|
||||
// 11 Table type upgrade not supported
|
||||
// 12 Upgrade type not supported
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers) : array {
|
||||
|
||||
$result = array();
|
||||
$upgrade_sql = array();
|
||||
|
||||
$compare_differences = mustal_compare_table_array($compare_def,"in JSON",$db_def,"in DB",true);
|
||||
if (count($compare_differences) > 0) {
|
||||
$upgrade_sql[] = ("SET SQL_MODE='ALLOW_INVALID_DATES';");
|
||||
$upgrade_sql[] = ("SET SESSION innodb_strict_mode=OFF;");
|
||||
}
|
||||
|
||||
foreach ($compare_differences as $compare_difference) {
|
||||
switch ($compare_difference['type']) {
|
||||
case 'Table existence':
|
||||
|
||||
// Get table definition from JSON
|
||||
|
||||
$table_name = $compare_difference['in JSON'];
|
||||
|
||||
$table_key = array_search($table_name,array_column($compare_def['tables'],'name'));
|
||||
|
||||
if ($table_key !== false) {
|
||||
$table = $compare_def['tables'][$table_key];
|
||||
|
||||
switch ($table['type']) {
|
||||
case 'BASE TABLE':
|
||||
|
||||
// Create table in DB
|
||||
$sql = "";
|
||||
$sql = "CREATE TABLE `".$table['name']."` (";
|
||||
$comma = "";
|
||||
|
||||
foreach ($table['columns'] as $column) {
|
||||
$sql .= $comma."`".$column['Field']."` ".mustal_column_sql_definition($table_name, $column,array_column($replacers,1));
|
||||
$comma = ", ";
|
||||
}
|
||||
|
||||
// Add keys
|
||||
$comma = ", ";
|
||||
foreach ($table['keys'] as $key) {
|
||||
if ($key['Key_name'] == 'PRIMARY') {
|
||||
$keystring = "PRIMARY KEY ";
|
||||
} else {
|
||||
|
||||
if(array_key_exists('Index_type', $key)) {
|
||||
$index_type = $key['Index_type'];
|
||||
} else {
|
||||
$index_type = "";
|
||||
}
|
||||
|
||||
$keystring = $index_type." KEY `".$key['Key_name']."` ";
|
||||
}
|
||||
$sql .= $comma.$keystring."(`".implode("`,`",$key['columns'])."`) ";
|
||||
}
|
||||
$sql .= ")";
|
||||
$upgrade_sql[] = $sql;
|
||||
break;
|
||||
default:
|
||||
$result[] = array(1,"Upgrade type '".$table['type']."' on table '".$table['name']."' not supported.");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$result[] = array(2,"Error table_key while creating upgrade for table existence `$table_name`.");
|
||||
}
|
||||
|
||||
break;
|
||||
case 'Column existence':
|
||||
$table_name = $compare_difference['table'];
|
||||
$column_name = $compare_difference['in JSON'];
|
||||
$table_key = array_search($table_name,array_column($compare_def['tables'],'name'));
|
||||
if ($table_key !== false) {
|
||||
$table = $compare_def['tables'][$table_key];
|
||||
$columns = $table['columns'];
|
||||
$column_key = array_search($column_name,array_column($columns,'Field'));
|
||||
if ($column_key !== false) {
|
||||
$column = $table['columns'][$column_key];
|
||||
$sql = "ALTER TABLE `$table_name` ADD COLUMN `".$column_name."` ";
|
||||
$sql .= mustal_column_sql_definition($table_name, $column, array_column($replacers,1));
|
||||
$sql .= ";";
|
||||
$upgrade_sql[] = $sql;
|
||||
}
|
||||
else {
|
||||
$result[] = array(3,"Error column_key while creating column '$column_name' in table '".$table['name']."'.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = array(4,"Error table_key while creating upgrade for column existence '$column_name' in table '$table_name'.");
|
||||
}
|
||||
// Add Column in DB
|
||||
break;
|
||||
case 'Column definition':
|
||||
$table_name = $compare_difference['table'];
|
||||
$column_name = $compare_difference['column'];
|
||||
$table_key = array_search($table_name,array_column($compare_def['tables'],'name'));
|
||||
if ($table_key !== false) {
|
||||
$table = $compare_def['tables'][$table_key];
|
||||
$columns = $table['columns'];
|
||||
|
||||
$column_names = array_column($columns,'Field');
|
||||
$column_key = array_search($column_name,$column_names);
|
||||
|
||||
if ($column_key !== false) {
|
||||
$column = $table['columns'][$column_key];
|
||||
|
||||
$sql = "ALTER TABLE `$table_name` MODIFY COLUMN `".$column_name."` ";
|
||||
$sql .= mustal_column_sql_definition($table_name, $column,array_column($replacers,1));
|
||||
$sql .= ";";
|
||||
$upgrade_sql[] = $sql;
|
||||
}
|
||||
else {
|
||||
$result[] = array(5,"Error column_key while modifying column '$column_name' in table '".$table['name']."'.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = array(6,"Error table_key while modifying column '$column_name' in table '$table_name'.");
|
||||
return(6);
|
||||
}
|
||||
// Modify Column in DB
|
||||
break;
|
||||
case 'Key existence':
|
||||
|
||||
$table_name = $compare_difference['table'];
|
||||
$key_name = $compare_difference['in JSON'];
|
||||
$table_key = array_search($table_name,array_column($compare_def['tables'],'name'));
|
||||
if ($table_key !== false) {
|
||||
$table = $compare_def['tables'][$table_key];
|
||||
$keys = $table['keys'];
|
||||
|
||||
$key_names = array_column($keys,'Key_name');
|
||||
$key_key = array_search($key_name,$key_names);
|
||||
|
||||
if ($key_key !== false) {
|
||||
$key = $table['keys'][$key_key];
|
||||
|
||||
$sql = "ALTER TABLE `$table_name` ADD KEY `".$key_name."` ";
|
||||
$sql .= "(`".implode("`,`",$key['columns'])."`)";
|
||||
$sql .= ";";
|
||||
$upgrade_sql[] = $sql;
|
||||
}
|
||||
else {
|
||||
$result[] = array(7,"Error key_key while adding key '$key_name' in table '".$table['name']."'.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = array(8,"Error table_key while adding key '$key_name' in table '$table_name'.");
|
||||
}
|
||||
break;
|
||||
case "Key definition":
|
||||
$table_name = $compare_difference['table'];
|
||||
$key_name = $compare_difference['key'];
|
||||
$table_key = array_search($table_name,array_column($compare_def['tables'],'name'));
|
||||
if ($table_key !== false) {
|
||||
$table = $compare_def['tables'][$table_key];
|
||||
$keys = $table['keys'];
|
||||
|
||||
$key_names = array_column($keys,'Key_name');
|
||||
$key_key = array_search($key_name,$key_names);
|
||||
|
||||
if ($key_key !== false) {
|
||||
$key = $table['keys'][$key_key];
|
||||
|
||||
$sql = "ALTER TABLE `$table_name` DROP KEY `".$key_name."`;";
|
||||
$upgrade_sql[] = $sql;
|
||||
|
||||
$sql = "ALTER TABLE `$table_name` ADD KEY `".$key_name."` ";
|
||||
$sql .= "(`".implode("`,`",$key['columns'])."`)";
|
||||
$sql .= ";";
|
||||
$upgrade_sql[] = $sql;
|
||||
}
|
||||
else {
|
||||
$result[] = array(9, "Error key_key while changing key '$key_name' in table '".$table['name']."'.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = array(10,"Error table_key while changing key '$key_name' in table '$table_name'.");
|
||||
}
|
||||
break;
|
||||
case 'Table count':
|
||||
// Nothing to do
|
||||
break;
|
||||
case 'Table type':
|
||||
$result[] = array(11,"Upgrade type '".$compare_difference['type']."' on table '".$compare_difference['table']."' not supported.");
|
||||
break;
|
||||
default:
|
||||
$result[] = array(12,"Upgrade type '".$compare_difference['type']."' not supported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$upgrade_sql = array_unique($upgrade_sql);
|
||||
|
||||
return($result);
|
||||
}
|
@ -28444,6 +28444,55 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bestellvorschlag",
|
||||
"type": "BASE TABLE",
|
||||
"columns": [
|
||||
{
|
||||
"Field": "user",
|
||||
"Type": "int(11)",
|
||||
"Collation": null,
|
||||
"Null": "NO",
|
||||
"Key": "PRI",
|
||||
"Default": null,
|
||||
"Extra": "",
|
||||
"Privileges": "select,insert,update,references",
|
||||
"Comment": ""
|
||||
},
|
||||
{
|
||||
"Field": "artikel",
|
||||
"Type": "int(11)",
|
||||
"Collation": null,
|
||||
"Null": "NO",
|
||||
"Key": "PRI",
|
||||
"Default": null,
|
||||
"Extra": "",
|
||||
"Privileges": "select,insert,update,references",
|
||||
"Comment": ""
|
||||
},
|
||||
{
|
||||
"Field": "menge",
|
||||
"Type": "int(11)",
|
||||
"Collation": null,
|
||||
"Null": "NO",
|
||||
"Key": "",
|
||||
"Default": null,
|
||||
"Extra": "",
|
||||
"Privileges": "select,insert,update,references",
|
||||
"Comment": ""
|
||||
}
|
||||
],
|
||||
"keys": [
|
||||
{
|
||||
"Key_name": "PRIMARY",
|
||||
"Index_type": "BTREE",
|
||||
"columns": [
|
||||
"artikel",
|
||||
"user"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bestellvorschlag_app",
|
||||
"type": "BASE TABLE",
|
||||
|
3
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
3
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
@ -127,10 +127,9 @@ function mustal_load_tables_from_db(string $host, string $schema, string $user,
|
||||
foreach ($keys as $key) {
|
||||
|
||||
// Check if this key exists already
|
||||
|
||||
$key_pos = array_search($key['Key_name'],array_column($composed_keys,'Key_name'));
|
||||
|
||||
if ($key_pos == false) {
|
||||
if ($key_pos === false) {
|
||||
// New key
|
||||
$composed_key = array();
|
||||
$composed_key['Key_name'] = $key['Key_name'];
|
||||
|
@ -7018,7 +7018,7 @@ title: 'Abschicken',
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Preisanfrage','preisanfrage','list');
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Bestellung','bestellung','list');
|
||||
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Bestellvorschlag','bestellvorschlag','ausgehend');
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Bestellvorschlag','bestellvorschlag','list');
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Erweiterter Bestellvorschlag','bestellvorschlagapp','list');
|
||||
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Produktion','produktion','list');
|
||||
@ -27451,8 +27451,13 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
|
||||
|
||||
function BeschriftungSprache($sprache='')
|
||||
{
|
||||
$sprache = strtolower(trim($sprache));
|
||||
$this->beschriftung_sprache='deutsch';
|
||||
|
||||
if ($sprache === '') {
|
||||
$this->beschriftung_sprache='deutsch';
|
||||
} else {
|
||||
$this->beschriftung_sprache=strtolower(trim($sprache));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function BeschriftungStandardwerte($field,$sprache="deutsch",$getvars=false)
|
||||
@ -27644,10 +27649,10 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
|
||||
|
||||
function getUebersetzung($field, $sprache, $id = true)
|
||||
{
|
||||
$sprach = strtolower($sprache);
|
||||
$sprache = strtolower($sprache);
|
||||
if(empty($this->uebersetzungId))
|
||||
{
|
||||
$arr = $this->app->DB->SelectArr('SELECT id, label, sprache, beschriftung
|
||||
$arr = $this->app->DB->SelectArr('SELECT id, label, sprache, beschriftung, original
|
||||
FROM uebersetzung
|
||||
WHERE sprache <> "" AND label <> ""');
|
||||
if(!empty($arr))
|
||||
@ -27655,7 +27660,12 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
|
||||
foreach($arr as $row)
|
||||
{
|
||||
$this->uebersetzungId[$row['label']][strtolower($row['sprache'])] = $row['id'];
|
||||
$this->uebersetzungBeschriftung[$row['label']][strtolower($row['sprache'])] = $row['beschriftung'];
|
||||
|
||||
if ($row['beschriftung'] != '') {
|
||||
$this->uebersetzungBeschriftung[$row['label']][strtolower($row['sprache'])] = $row['beschriftung'];
|
||||
} else {
|
||||
$this->uebersetzungBeschriftung[$row['label']][strtolower($row['sprache'])] = $row['original'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27675,13 +27685,14 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
|
||||
|
||||
function Beschriftung($field,$sprache='')
|
||||
{
|
||||
if($sprache!='') {
|
||||
|
||||
if($sprache!='') {
|
||||
$this->BeschriftungSprache($sprache);
|
||||
}
|
||||
|
||||
if($this->beschriftung_sprache==''){
|
||||
$this->beschriftung_sprache = 'deutsch';
|
||||
}
|
||||
}
|
||||
|
||||
// wenn feld mit artikel_freifeld beginnt dann freifeld draus machen
|
||||
//$field = str_replace('artikel_freifeld','freifeld',$field);
|
||||
@ -27715,9 +27726,7 @@ function MailSendFinal($from,$from_name,$to,$to_name,$betreff,$text,$files="",$p
|
||||
{
|
||||
return $wert;
|
||||
}
|
||||
//1. deutsches wort als standard
|
||||
$wert = $this->BeschriftungDeutschesWort($field);
|
||||
return $wert;
|
||||
return $field; // Not found!
|
||||
}
|
||||
|
||||
|
||||
@ -36277,7 +36286,7 @@ function Firmendaten($field,$projekt="")
|
||||
$tatsaechlicheslieferdatum = $orderRow['tatsaechlicheslieferdatum'];
|
||||
$projekt = $orderRow['projekt'];
|
||||
$differenztage = $this->Projektdaten($projekt,'differenz_auslieferung_tage');
|
||||
if($differenztage<0) {
|
||||
if($differenztage<0 || empty($differenztage)) {
|
||||
$differenztage=2;
|
||||
}
|
||||
$lieferdatum = $orderRow['lieferdatum'];
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@ class AuftragPDF extends BriefpapierCustom {
|
||||
{
|
||||
// pruefe ob es mehr als ein steuersatz gibt // wenn ja dann darf man sie nicht ausblenden
|
||||
$check = $this->app->erp->SteuerAusBeleg($this->doctype,$id);
|
||||
if(count($check)>1)$this->ust_spalteausblende=false;
|
||||
if(!empty($check)?count($check):0>1)$this->ust_spalteausblende=false;
|
||||
else $this->ust_spalteausblende=true;
|
||||
}
|
||||
|
||||
|
@ -1,491 +1,491 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
if(!class_exists('BriefpapierCustom'))
|
||||
{
|
||||
class BriefpapierCustom extends Briefpapier
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class GutschriftPDF extends BriefpapierCustom {
|
||||
public $doctype;
|
||||
|
||||
function __construct($app,$projekt="")
|
||||
{
|
||||
$this->app=$app;
|
||||
//parent::Briefpapier();
|
||||
$this->doctype="gutschrift";
|
||||
$this->doctypeOrig="Gutschrift";
|
||||
parent::__construct($this->app,$projekt);
|
||||
}
|
||||
|
||||
|
||||
function GetGutschrift($id)
|
||||
{
|
||||
$this->doctypeid = $id;
|
||||
|
||||
if($this->app->erp->Firmendaten("steuerspalteausblenden")=="1")
|
||||
{
|
||||
// pruefe ob es mehr als ein steuersatz gibt // wenn ja dann darf man sie nicht ausblenden
|
||||
$check = $this->app->erp->SteuerAusBeleg($this->doctype,$id);
|
||||
if(count($check)>1)$this->ust_spalteausblende=false;
|
||||
else $this->ust_spalteausblende=true;
|
||||
}
|
||||
|
||||
$briefpapier_bearbeiter_ausblenden = $this->app->erp->Firmendaten('briefpapier_bearbeiter_ausblenden');
|
||||
$briefpapier_vertrieb_ausblenden = $this->app->erp->Firmendaten('briefpapier_vertrieb_ausblenden');
|
||||
//$this->setRecipientDB($adresse);
|
||||
$this->setRecipientLieferadresse($id,"gutschrift");
|
||||
|
||||
$data = $this->app->DB->SelectRow(
|
||||
"SELECT adresse,kundennummer, sprache, rechnungid, buchhaltung, bearbeiter, vertrieb,
|
||||
lieferschein AS lieferscheinid, DATE_FORMAT(datum,'%d.%m.%Y') AS datum,
|
||||
DATE_FORMAT(lieferdatum,'%d.%m.%Y') AS lieferdatum, belegnr, freitext, ustid, ust_befreit,
|
||||
stornorechnung, keinsteuersatz, land, typ, zahlungsweise, zahlungsstatus, zahlungszieltage,
|
||||
zahlungszielskonto, projekt, waehrung, bodyzusatz,
|
||||
DATE_FORMAT(DATE_ADD(datum, INTERVAL zahlungszieltage DAY),'%d.%m.%Y') AS zahlungsdatum,
|
||||
ohne_briefpapier, ihrebestellnummer,DATE_FORMAT(datum,'%Y%m%d') as datum2, email, telefon
|
||||
FROM gutschrift WHERE id='$id' LIMIT 1"
|
||||
);
|
||||
extract($data,EXTR_OVERWRITE);
|
||||
$adresse = $data['adresse'];
|
||||
$kundennummer = $data['kundennummer'];
|
||||
$sprache = $data['sprache'];
|
||||
$rechnungid = $data['rechnungid'];
|
||||
$buchhaltung = $data['buchhaltung'];
|
||||
$email = $data['email'];
|
||||
$telefon = $data['telefon'];
|
||||
$bearbeiter = $data['bearbeiter'];
|
||||
$vertrieb = $data['vertrieb'];
|
||||
$lieferscheinid = $data['lieferscheinid'];
|
||||
$datum = $data['datum'];
|
||||
$lieferdatum = $data['lieferdatum'];
|
||||
$belegnr = $data['belegnr'];
|
||||
$freitext = $data['freitext'];
|
||||
$ustid = $data['ustid'];
|
||||
$ust_befreit = $data['ust_befreit'];
|
||||
$stornorechnung = $data['stornorechnung'];
|
||||
$keinsteuersatz = $data['keinsteuersatz'];
|
||||
$land = $data['land'];
|
||||
$typ = $data['typ'];
|
||||
$zahlungsweise = $data['zahlungsweise'];
|
||||
$zahlungszieltage = $data['zahlungszieltage'];
|
||||
|
||||
$zahlungszielskonto = $data['zahlungszielskonto'];
|
||||
$projekt = $data['projekt'];
|
||||
$waehrung = $data['waehrung'];
|
||||
$bodyzusatz = $data['bodyzusatz'];
|
||||
$zahlungsdatum = $data['zahlungsdatum'];
|
||||
$ohne_briefpapier = $data['ohne_briefpapier'];
|
||||
$ihrebestellnummer = $data['ihrebestellnummer'];
|
||||
$datum2 = $data['datum2'];
|
||||
$projektabkuerzung = $this->app->DB->Select(sprintf('SELECT abkuerzung FROM projekt WHERE id = %d', $projekt));
|
||||
$kundennummer = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE id='$adresse' LIMIT 1");
|
||||
if(empty($sprache)){
|
||||
$sprache = $this->app->DB->Select("SELECT sprache FROM adresse WHERE id='$adresse' LIMIT 1");
|
||||
}
|
||||
$lieferschein = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferscheinid' LIMIT 1");
|
||||
$lieferscheindatum = $this->app->DB->Select("SELECT DATE_FORMAT(datum, '%d.%m.%Y') AS datum FROM lieferschein WHERE id = '$lieferscheinid' LIMIT 1");
|
||||
$rechnung = $this->app->DB->Select("SELECT belegnr FROM rechnung WHERE id='$rechnungid' LIMIT 1");
|
||||
$rechnungsdatum = $this->app->DB->Select("SELECT DATE_FORMAT(datum, '%d.%m.%Y') AS datum FROM rechnung WHERE id = '$rechnungid' LIMIT 1");
|
||||
$auftrag = $this->app->DB->Select("SELECT auftrag FROM rechnung WHERE id = '$rechnungid' LIMIT 1");
|
||||
|
||||
$ihrebestellnummer = $this->app->erp->ReadyForPDF($ihrebestellnummer);
|
||||
$bearbeiter = $this->app->erp->ReadyForPDF($bearbeiter);
|
||||
$vertrieb = $this->app->erp->ReadyForPDF($vertrieb);
|
||||
|
||||
$this->app->erp->BeschriftungSprache($sprache);
|
||||
if($waehrung)$this->waehrung = $waehrung;
|
||||
$this->sprache = $sprache;
|
||||
$this->projekt = $projekt;
|
||||
$this->anrede = $typ;
|
||||
|
||||
if($vertrieb==$bearbeiter && (!$briefpapier_bearbeiter_ausblenden && !$briefpapier_vertrieb_ausblenden)) $vertrieb="";
|
||||
|
||||
if($ohne_briefpapier=="1")
|
||||
{
|
||||
$this->logofile = "";
|
||||
$this->briefpapier="";
|
||||
$this->briefpapier2="";
|
||||
}
|
||||
|
||||
// $zahlungsweise = strtolower($zahlungsweise);
|
||||
|
||||
if($zahlungsweise=="lastschrift" || $zahlungsweise=="einzugsermaechtigung")
|
||||
{
|
||||
$zahlungsweisetext = "\n".$this->app->erp->Beschriftung("dokument_offene_lastschriften");
|
||||
}
|
||||
|
||||
//if($zahlungszielskonto>0) $zahlungsweisetext .= "\n".$this->app->erp->Beschriftung("dokument_skonto")." $zahlungszielskonto% ".$this->app->erp->Beschriftung("dokument_auszahlungskonditionen");
|
||||
|
||||
if($zahlungszielskonto!=0)
|
||||
$zahlungsweisetext .="\r\n".$this->app->erp->Beschriftung("dokument_skontoanderezahlungsweisen");
|
||||
|
||||
$zahlungsweisetext = str_replace('{ZAHLUNGSZIELSKONTO}',number_format($zahlungszielskonto,2,',','.'),$zahlungsweisetext);
|
||||
|
||||
if($belegnr=="" || $belegnr=="0") $belegnr = "- ".$this->app->erp->Beschriftung("dokument_entwurf");
|
||||
|
||||
|
||||
if($stornorechnung)
|
||||
$this->doctypeOrig=$this->app->erp->Beschriftung("bezeichnungstornorechnung")." $belegnr";
|
||||
else
|
||||
$this->doctypeOrig=$this->app->erp->Beschriftung("dokument_gutschrift")." $belegnr";
|
||||
|
||||
if($gutschrift=="") $gutschrift = "-";
|
||||
if($kundennummer=="") $kundennummer= "-";
|
||||
|
||||
if($auftrag=="0") $auftrag = "-";
|
||||
if($lieferschein=="0") $lieferschein= "-";
|
||||
|
||||
$bearbeiteremail = $this->app->DB->Select("SELECT b.email FROM gutschrift g LEFT JOIN adresse b ON b.id=g.bearbeiterid WHERE g.id='$id' LIMIT 1");
|
||||
$bearbeitertelefon = $this->app->DB->Select("SELECT b.telefon FROM gutschrift g LEFT JOIN adresse b ON b.id=g.bearbeiterid WHERE g.id='$id' LIMIT 1");
|
||||
|
||||
/** @var \Xentral\Modules\Company\Service\DocumentCustomizationService $service */
|
||||
$service = $this->app->Container->get('DocumentCustomizationService');
|
||||
if($block = $service->findActiveBlock('corr', 'credit_note', $projekt)) {
|
||||
$sCD = $service->parseBlockAsArray($this->getLanguageCodeFrom($this->sprache),'corr', 'credit_note',[
|
||||
'GUTSCHRIFTSNUMMER' => $belegnr,
|
||||
'DATUM' => $datum,
|
||||
'RECHNUNGSNUMMER' => $rechnung,
|
||||
'RECHNUNGSDATUM' => $rechnungsdatum,
|
||||
'KUNDENNUMMER' => $kundennummer,
|
||||
'BEARBEITER' => $bearbeiter,
|
||||
'BEARBEITEREMAIL' => $bearbeiteremail,
|
||||
'BEARBEITERTELEFON' => $bearbeitertelefon,
|
||||
'VERTRIEB' => $vertrieb,
|
||||
'PROJEKT' => $projektabkuerzung,
|
||||
'AUFTRAGSNUMMER' => $auftrag,
|
||||
'LIEFERSCHEINNUMMER' => $lieferschein,
|
||||
'LIEFERSCHEINDATUM' => $lieferscheindatum,
|
||||
'EMAIL' => $email,
|
||||
'TELEFON' => $telefon
|
||||
|
||||
|
||||
|
||||
], $projekt);
|
||||
if(!empty($sCD)) {
|
||||
switch($block['fontstyle']) {
|
||||
case 'f':
|
||||
$this->setBoldCorrDetails($sCD);
|
||||
break;
|
||||
case 'i':
|
||||
$this->setItalicCorrDetails($sCD);
|
||||
break;
|
||||
case 'fi':
|
||||
$this->setItalicBoldCorrDetails($sCD);
|
||||
break;
|
||||
default:
|
||||
$this->setCorrDetails($sCD, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
//$this->setCorrDetails(array("Auftrag"=>$auftrag,"Datum"=>$datum,"Ihre Kunden-Nr."=>$kundennummer,"Lieferschein"=>$lieferschein,"Buchhaltung"=>$buchhaltung));
|
||||
if($briefpapier_bearbeiter_ausblenden || $briefpapier_vertrieb_ausblenden){
|
||||
if($rechnung != ""){
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_rechnung") => $rechnung, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer);
|
||||
}else{
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer);
|
||||
//$this->setCorrDetails(array($this->app->erp->Beschriftung("dokument_datum")=>$datum,$this->app->erp->Beschriftung("bezeichnungkundennummer")=>$kundennummer,$this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer")=>$ihrebestellnummer));
|
||||
}
|
||||
if(!$briefpapier_bearbeiter_ausblenden){
|
||||
if($bearbeiter) $sCD[$this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter")] = $bearbeiter;
|
||||
}elseif(!$briefpapier_vertrieb_ausblenden){
|
||||
if($vertrieb) $sCD[$this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb")] = $vertrieb;
|
||||
}
|
||||
|
||||
}else{
|
||||
if($rechnung != "")
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_rechnung") => $rechnung, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter") => $bearbeiter, $this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb") => $vertrieb);
|
||||
else
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter") => $bearbeiter, $this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb") => $vertrieb);
|
||||
}
|
||||
|
||||
if($lieferdatum != "00.00.0000")
|
||||
$sCD[$this->app->erp->Beschriftung("dokument_lieferdatum")] = $lieferdatum;
|
||||
|
||||
|
||||
$this->setCorrDetails($sCD);
|
||||
}
|
||||
|
||||
if($keinsteuersatz!="1")
|
||||
{
|
||||
|
||||
if($ust_befreit==2)//$this->app->erp->Export($land))
|
||||
$steuer = $this->app->erp->Beschriftung("export_lieferung_vermerk");
|
||||
else {
|
||||
if($ust_befreit==1 && $ustid!="")//$this->app->erp->IstEU($land))
|
||||
$steuer = $this->app->erp->Beschriftung("eu_lieferung_vermerk");
|
||||
}
|
||||
$steuer = str_replace('{USTID}',$ustid,$steuer);
|
||||
$steuer = str_replace('{LAND}',$land,$steuer);
|
||||
}
|
||||
|
||||
$gutschrift_header=$this->app->erp->Beschriftung("gutschrift_header");
|
||||
if($bodyzusatz!="") $gutschrift_header=$gutschrift_header."\r\n".$bodyzusatz;
|
||||
|
||||
if($stornorechnung)
|
||||
{
|
||||
$gutschrift_header = str_replace('{ART}',$this->app->erp->Beschriftung("bezeichnungstornorechnung"),$gutschrift_header);
|
||||
} else {
|
||||
$gutschrift_header = str_replace('{ART}',$this->app->erp->Beschriftung("dokument_gutschrift"),$gutschrift_header);
|
||||
}
|
||||
|
||||
$gutschrift_header = $this->app->erp->ParseUserVars("gutschrift",$id,$gutschrift_header);
|
||||
|
||||
|
||||
if($this->app->erp->Firmendaten("footer_reihenfolge_gutschrift_aktivieren")=="1") {
|
||||
$footervorlage = $this->app->erp->Firmendaten("footer_reihenfolge_gutschrift");
|
||||
if($footervorlage=="")
|
||||
$footervorlage = "{FOOTERFREITEXT}\r\n{FOOTERTEXTVORLAGEGUTSCHRIFT}\r\n{FOOTERSTEUER}\r\n{FOOTERZAHLUNGSWEISETEXT}";
|
||||
|
||||
$footervorlage = str_replace('{FOOTERFREITEXT}',$freitext,$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERTEXTVORLAGEGUTSCHRIFT}',$this->app->erp->Beschriftung("gutschrift_footer"),$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERSTEUER}',$steuer,$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERZAHLUNGSWEISETEXT}',$zahlungsweisetext,$footervorlage);
|
||||
$footervorlage = $this->app->erp->ParseUserVars("gutschrift",$id,$footervorlage);
|
||||
$footer = $footervorlage;
|
||||
} else {
|
||||
$footer = "$freitext"."\r\n".$this->app->erp->ParseUserVars("gutschrift",$id,$this->app->erp->Beschriftung("gutschrift_footer"))."\r\n$zahlungsweisetext\r\n$steuer";
|
||||
}
|
||||
|
||||
|
||||
$this->setTextDetails(array(
|
||||
"body"=>$gutschrift_header,
|
||||
"footer"=>$footer));
|
||||
|
||||
$artikel = $this->app->DB->SelectArr("SELECT * FROM gutschrift_position WHERE gutschrift='$id' ORDER By sort");
|
||||
|
||||
if(!$this->app->erp->GutschriftMitUmsatzeuer($id)) $this->ust_befreit=true;
|
||||
|
||||
$summe_rabatt = $this->app->DB->Select("SELECT SUM(rabatt) FROM gutschrift_position WHERE gutschrift='$id'");
|
||||
if($summe_rabatt <> 0) $this->rabatt=1;
|
||||
|
||||
if($this->app->erp->Firmendaten("modul_verband")=="1") $this->rabatt=1;
|
||||
|
||||
//$waehrung = $this->app->DB->Select("SELECT waehrung FROM gutschrift_position WHERE gutschrift='$id' LIMIT 1");
|
||||
$steuersatzV = $this->app->erp->GetSteuersatzNormal(false,$id,"gutschrift");
|
||||
$steuersatzR = $this->app->erp->GetSteuersatzErmaessigt(false,$id,"gutschrift");
|
||||
$gesamtsteuern = 0;
|
||||
$mitumsatzsteuer = $this->app->erp->GutschriftMitUmsatzeuer($id);
|
||||
$belege_subpositionenstuecklisten = $this->app->erp->Firmendaten('belege_subpositionenstuecklisten');
|
||||
$belege_stuecklisteneinrueckenmm = $this->app->erp->Firmendaten('belege_stuecklisteneinrueckenmm');
|
||||
//$positionenkaufmaenischrunden = $this->app->erp->Firmendaten('positionenkaufmaenischrunden');
|
||||
$positionenkaufmaenischrunden = $this->app->erp->Projektdaten($projekt,"preisberechnung");
|
||||
$viernachkommastellen_belege = $this->app->erp->Firmendaten('viernachkommastellen_belege');
|
||||
foreach($artikel as $key=>$value)
|
||||
{
|
||||
if($value['umsatzsteuer'] != "ermaessigt" && $value['umsatzsteuer'] != "befreit") $value['umsatzsteuer'] = "normal";
|
||||
$tmpsteuersatz = null;
|
||||
$tmpsteuertext = null;
|
||||
$this->app->erp->GetSteuerPosition('gutschrift', $value['id'],$tmpsteuersatz, $tmpsteuertext);
|
||||
if(is_null($value['steuersatz']) || $value['steuersatz'] < 0)
|
||||
{
|
||||
if($value['umsatzsteuer'] == "ermaessigt")
|
||||
{
|
||||
$value['steuersatz'] = $steuersatzR;
|
||||
}elseif($value['umsatzsteuer'] == "befreit")
|
||||
{
|
||||
$value['steuersatz'] = $steuersatzR;
|
||||
}else{
|
||||
$value['steuersatz'] = $steuersatzV;
|
||||
}
|
||||
if(!is_null($tmpsteuersatz))$value['steuersatz'] = $tmpsteuersatz;
|
||||
}
|
||||
if($tmpsteuertext && !$value['steuertext'])$value['steuertext'] = $tmpsteuertext;
|
||||
if(!$mitumsatzsteuer)$value['steuersatz'] = 0;
|
||||
// negative Darstellung bei Stornorechnung
|
||||
if($stornorechnung) $value['preis'] = $value['preis'] *-1;
|
||||
|
||||
if(!$this->app->erp->Export($land))
|
||||
{
|
||||
$value['zolltarifnummer']="";
|
||||
$value['herkunftsland']="";
|
||||
}
|
||||
|
||||
$value = $this->CheckPosition($value,"gutschrift",$this->doctypeid,$value['id']);
|
||||
|
||||
$value['menge'] = floatval($value['menge']);
|
||||
|
||||
if($value['explodiert_parent_artikel'] > 0)
|
||||
{
|
||||
if($belege_subpositionenstuecklisten || $belege_stuecklisteneinrueckenmm)$value['bezeichnung'] = ltrim(ltrim($value['bezeichnung'],'*'));
|
||||
if(isset($lvl) && isset($lvl[$value['explodiert_parent_artikel']]))
|
||||
{
|
||||
$value['lvl'] = $lvl[$value['explodiert_parent_artikel']] + 1;
|
||||
}else{
|
||||
$value['lvl'] = 1;
|
||||
}
|
||||
$lvl[$value['artikel']] = $value['lvl'];
|
||||
$check_ausblenden = $this->app->DB->Select("SELECT keineeinzelartikelanzeigen FROM artikel WHERE id='".$value['explodiert_parent_artikel']."' LIMIT 1");
|
||||
if(!$check_ausblenden && isset($ausblenden) && in_array($value['explodiert_parent_artikel'], $ausblenden))
|
||||
{
|
||||
$check_ausblenden = true;
|
||||
}
|
||||
if($check_ausblenden)
|
||||
{
|
||||
$ausblenden[] = $value['artikel'];
|
||||
}
|
||||
} else
|
||||
{
|
||||
$check_ausblenden=0;
|
||||
$lvl[$value['artikel']] = 0;
|
||||
$value['lvl'] = 0;
|
||||
}
|
||||
|
||||
if($value['ausblenden_im_pdf']) $check_ausblenden=1;
|
||||
|
||||
$ohne_artikeltext = $this->app->DB->Select("SELECT ohne_artikeltext FROM ".$this->table." WHERE id='".$this->id."' LIMIT 1");
|
||||
if($ohne_artikeltext=="1") $value['beschreibung']="";
|
||||
|
||||
if($check_ausblenden!=1)
|
||||
{
|
||||
$this->addItem(array('currency'=>$value['waehrung'],'lvl'=>isset($value['lvl'])?$value['lvl']:0,
|
||||
'amount'=>$value['menge'],
|
||||
'price'=>$value['preis'],
|
||||
'tax'=>$value['umsatzsteuer'],
|
||||
'steuersatz'=>$value['steuersatz'],
|
||||
'steuertext'=>$value['steuertext'],
|
||||
'itemno'=>$value['nummer'],
|
||||
'artikel'=>$value['artikel'],
|
||||
'unit'=>$value['einheit'],
|
||||
'desc'=>$value['beschreibung'],
|
||||
"name"=>ltrim($value['bezeichnung']),
|
||||
'artikelnummerkunde'=>$value['artikelnummerkunde'],
|
||||
'lieferdatum'=>$value['lieferdatum'],
|
||||
'lieferdatumkw'=>$value['lieferdatumkw'],
|
||||
'zolltarifnummer'=>$value['zolltarifnummer'],
|
||||
'herkunftsland'=>$value['herkunftsland'],
|
||||
'ohnepreis'=>$value['ohnepreis'],
|
||||
'grundrabatt'=>$value['grundrabatt'],
|
||||
'rabatt1'=>$value['rabatt1'],
|
||||
'rabatt2'=>$value['rabatt2'],
|
||||
'rabatt3'=>$value['rabatt3'],
|
||||
'rabatt4'=>$value['rabatt4'],
|
||||
'rabatt5'=>$value['rabatt5'],
|
||||
'freifeld1'=>$value['freifeld1'],
|
||||
'freifeld2'=>$value['freifeld2'],
|
||||
'freifeld3'=>$value['freifeld3'],
|
||||
'freifeld4'=>$value['freifeld4'],
|
||||
'freifeld5'=>$value['freifeld5'],
|
||||
'freifeld6'=>$value['freifeld6'],
|
||||
'freifeld7'=>$value['freifeld7'],
|
||||
'freifeld8'=>$value['freifeld8'],
|
||||
'freifeld9'=>$value['freifeld9'],
|
||||
'freifeld10'=>$value['freifeld10'],
|
||||
'freifeld11'=>$value['freifeld11'],
|
||||
'freifeld12'=>$value['freifeld12'],
|
||||
'freifeld13'=>$value['freifeld13'],
|
||||
'freifeld14'=>$value['freifeld14'],
|
||||
'freifeld15'=>$value['freifeld15'],
|
||||
'freifeld16'=>$value['freifeld16'],
|
||||
'freifeld17'=>$value['freifeld17'],
|
||||
'freifeld18'=>$value['freifeld18'],
|
||||
'freifeld19'=>$value['freifeld19'],
|
||||
'freifeld20'=>$value['freifeld20'],
|
||||
'freifeld21'=>$value['freifeld21'],
|
||||
'freifeld22'=>$value['freifeld22'],
|
||||
'freifeld23'=>$value['freifeld23'],
|
||||
'freifeld24'=>$value['freifeld24'],
|
||||
'freifeld25'=>$value['freifeld25'],
|
||||
'freifeld26'=>$value['freifeld26'],
|
||||
'freifeld27'=>$value['freifeld27'],
|
||||
'freifeld28'=>$value['freifeld28'],
|
||||
'freifeld29'=>$value['freifeld29'],
|
||||
'freifeld30'=>$value['freifeld30'],
|
||||
'freifeld31'=>$value['freifeld31'],
|
||||
'freifeld32'=>$value['freifeld32'],
|
||||
'freifeld33'=>$value['freifeld33'],
|
||||
'freifeld34'=>$value['freifeld34'],
|
||||
'freifeld35'=>$value['freifeld35'],
|
||||
'freifeld36'=>$value['freifeld36'],
|
||||
'freifeld37'=>$value['freifeld37'],
|
||||
'freifeld38'=>$value['freifeld38'],
|
||||
'freifeld39'=>$value['freifeld39'],
|
||||
'freifeld40'=>$value['freifeld40'],
|
||||
"keinrabatterlaubt"=>$value['keinrabatterlaubt'],
|
||||
"rabatt"=>$value['rabatt']));
|
||||
}
|
||||
if($positionenkaufmaenischrunden == 3){
|
||||
$netto_gesamt = $value['menge'] * round($value['preis'] - ($value['preis'] / 100 * $value['rabatt']),2);
|
||||
}else{
|
||||
$netto_gesamt = $value['menge'] * ($value['preis'] - ($value['preis'] / 100 * $value['rabatt']));
|
||||
}
|
||||
if($positionenkaufmaenischrunden)
|
||||
{
|
||||
$netto_gesamt = round($netto_gesamt, 2);
|
||||
}
|
||||
$summe = $summe + $netto_gesamt;
|
||||
if(!isset($summen[$value['steuersatz']]))$summen[$value['steuersatz']] = 0;
|
||||
$summen[$value['steuersatz']] += ($netto_gesamt/100)*$value['steuersatz'];
|
||||
$gesamtsteuern +=($netto_gesamt/100)*$value['steuersatz'];
|
||||
/*
|
||||
if($value['umsatzsteuer']=="" || $value['umsatzsteuer']=="normal")
|
||||
{
|
||||
$summeV = $summeV + (($netto_gesamt/100)*$this->app->erp->GetSteuersatzNormal(false,$id,"gutschrift"));
|
||||
}
|
||||
else {
|
||||
$summeR = $summeR + (($netto_gesamt/100)*$this->app->erp->GetSteuersatzErmaessigt(false,$id,"gutschrift"));
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
if($positionenkaufmaenischrunden && isset($summen) && is_array($summen))
|
||||
{
|
||||
$gesamtsteuern = 0;
|
||||
foreach($summen as $k => $v)
|
||||
{
|
||||
$summen[$k] = round($v, 2);
|
||||
$gesamtsteuern += round($v, 2);
|
||||
}
|
||||
}
|
||||
if($positionenkaufmaenischrunden)
|
||||
{
|
||||
list($summe,$gesamtsumme, $summen) = $this->app->erp->steuerAusBelegPDF($this->table, $this->id);
|
||||
$gesamtsteuern = $gesamtsumme - $summe;
|
||||
}
|
||||
|
||||
/*
|
||||
$summe = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id'");
|
||||
|
||||
$summeV = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id' AND (umsatzsteuer='normal' or umsatzsteuer='')")/100 * 19;
|
||||
$summeR = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id' AND umsatzsteuer='ermaessigt'")/100 * 7;
|
||||
*/
|
||||
if($this->app->erp->GutschriftMitUmsatzeuer($id))
|
||||
{
|
||||
$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe + $gesamtsteuern,"summen"=>$summen,"totalTaxV"=>0,"totalTaxR"=>0));
|
||||
//$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe + $summeV + $summeR,"totalTaxV"=>$summeV,"totalTaxR"=>$summeR));
|
||||
} else
|
||||
$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe));
|
||||
|
||||
/* Dateiname */
|
||||
$tmp_name = str_replace(' ','',trim($this->recipient['enterprise']));
|
||||
$tmp_name = str_replace('.','',$tmp_name);
|
||||
|
||||
if($stornorechnung)
|
||||
$this->filename = $datum2."_STORNO_".$belegnr.".pdf";
|
||||
else
|
||||
$this->filename = $datum2."_GS".$belegnr.".pdf";
|
||||
|
||||
$this->setBarcode($belegnr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
<?php
|
||||
if(!class_exists('BriefpapierCustom'))
|
||||
{
|
||||
class BriefpapierCustom extends Briefpapier
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class GutschriftPDF extends BriefpapierCustom {
|
||||
public $doctype;
|
||||
|
||||
function __construct($app,$projekt="")
|
||||
{
|
||||
$this->app=$app;
|
||||
//parent::Briefpapier();
|
||||
$this->doctype="gutschrift";
|
||||
$this->doctypeOrig="Gutschrift";
|
||||
parent::__construct($this->app,$projekt);
|
||||
}
|
||||
|
||||
|
||||
function GetGutschrift($id)
|
||||
{
|
||||
$this->doctypeid = $id;
|
||||
|
||||
if($this->app->erp->Firmendaten("steuerspalteausblenden")=="1")
|
||||
{
|
||||
// pruefe ob es mehr als ein steuersatz gibt // wenn ja dann darf man sie nicht ausblenden
|
||||
$check = $this->app->erp->SteuerAusBeleg($this->doctype,$id);
|
||||
if(!empty($check)?count($check):0>1)$this->ust_spalteausblende=false;
|
||||
else $this->ust_spalteausblende=true;
|
||||
}
|
||||
|
||||
$briefpapier_bearbeiter_ausblenden = $this->app->erp->Firmendaten('briefpapier_bearbeiter_ausblenden');
|
||||
$briefpapier_vertrieb_ausblenden = $this->app->erp->Firmendaten('briefpapier_vertrieb_ausblenden');
|
||||
//$this->setRecipientDB($adresse);
|
||||
$this->setRecipientLieferadresse($id,"gutschrift");
|
||||
|
||||
$data = $this->app->DB->SelectRow(
|
||||
"SELECT adresse,kundennummer, sprache, rechnungid, buchhaltung, bearbeiter, vertrieb,
|
||||
lieferschein AS lieferscheinid, DATE_FORMAT(datum,'%d.%m.%Y') AS datum,
|
||||
DATE_FORMAT(lieferdatum,'%d.%m.%Y') AS lieferdatum, belegnr, freitext, ustid, ust_befreit,
|
||||
stornorechnung, keinsteuersatz, land, typ, zahlungsweise, zahlungsstatus, zahlungszieltage,
|
||||
zahlungszielskonto, projekt, waehrung, bodyzusatz,
|
||||
DATE_FORMAT(DATE_ADD(datum, INTERVAL zahlungszieltage DAY),'%d.%m.%Y') AS zahlungsdatum,
|
||||
ohne_briefpapier, ihrebestellnummer,DATE_FORMAT(datum,'%Y%m%d') as datum2, email, telefon
|
||||
FROM gutschrift WHERE id='$id' LIMIT 1"
|
||||
);
|
||||
extract($data,EXTR_OVERWRITE);
|
||||
$adresse = $data['adresse'];
|
||||
$kundennummer = $data['kundennummer'];
|
||||
$sprache = $data['sprache'];
|
||||
$rechnungid = $data['rechnungid'];
|
||||
$buchhaltung = $data['buchhaltung'];
|
||||
$email = $data['email'];
|
||||
$telefon = $data['telefon'];
|
||||
$bearbeiter = $data['bearbeiter'];
|
||||
$vertrieb = $data['vertrieb'];
|
||||
$lieferscheinid = $data['lieferscheinid'];
|
||||
$datum = $data['datum'];
|
||||
$lieferdatum = $data['lieferdatum'];
|
||||
$belegnr = $data['belegnr'];
|
||||
$freitext = $data['freitext'];
|
||||
$ustid = $data['ustid'];
|
||||
$ust_befreit = $data['ust_befreit'];
|
||||
$stornorechnung = $data['stornorechnung'];
|
||||
$keinsteuersatz = $data['keinsteuersatz'];
|
||||
$land = $data['land'];
|
||||
$typ = $data['typ'];
|
||||
$zahlungsweise = $data['zahlungsweise'];
|
||||
$zahlungszieltage = $data['zahlungszieltage'];
|
||||
|
||||
$zahlungszielskonto = $data['zahlungszielskonto'];
|
||||
$projekt = $data['projekt'];
|
||||
$waehrung = $data['waehrung'];
|
||||
$bodyzusatz = $data['bodyzusatz'];
|
||||
$zahlungsdatum = $data['zahlungsdatum'];
|
||||
$ohne_briefpapier = $data['ohne_briefpapier'];
|
||||
$ihrebestellnummer = $data['ihrebestellnummer'];
|
||||
$datum2 = $data['datum2'];
|
||||
$projektabkuerzung = $this->app->DB->Select(sprintf('SELECT abkuerzung FROM projekt WHERE id = %d', $projekt));
|
||||
$kundennummer = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE id='$adresse' LIMIT 1");
|
||||
if(empty($sprache)){
|
||||
$sprache = $this->app->DB->Select("SELECT sprache FROM adresse WHERE id='$adresse' LIMIT 1");
|
||||
}
|
||||
$lieferschein = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferscheinid' LIMIT 1");
|
||||
$lieferscheindatum = $this->app->DB->Select("SELECT DATE_FORMAT(datum, '%d.%m.%Y') AS datum FROM lieferschein WHERE id = '$lieferscheinid' LIMIT 1");
|
||||
$rechnung = $this->app->DB->Select("SELECT belegnr FROM rechnung WHERE id='$rechnungid' LIMIT 1");
|
||||
$rechnungsdatum = $this->app->DB->Select("SELECT DATE_FORMAT(datum, '%d.%m.%Y') AS datum FROM rechnung WHERE id = '$rechnungid' LIMIT 1");
|
||||
$auftrag = $this->app->DB->Select("SELECT auftrag FROM rechnung WHERE id = '$rechnungid' LIMIT 1");
|
||||
|
||||
$ihrebestellnummer = $this->app->erp->ReadyForPDF($ihrebestellnummer);
|
||||
$bearbeiter = $this->app->erp->ReadyForPDF($bearbeiter);
|
||||
$vertrieb = $this->app->erp->ReadyForPDF($vertrieb);
|
||||
|
||||
$this->app->erp->BeschriftungSprache($sprache);
|
||||
if($waehrung)$this->waehrung = $waehrung;
|
||||
$this->sprache = $sprache;
|
||||
$this->projekt = $projekt;
|
||||
$this->anrede = $typ;
|
||||
|
||||
if($vertrieb==$bearbeiter && (!$briefpapier_bearbeiter_ausblenden && !$briefpapier_vertrieb_ausblenden)) $vertrieb="";
|
||||
|
||||
if($ohne_briefpapier=="1")
|
||||
{
|
||||
$this->logofile = "";
|
||||
$this->briefpapier="";
|
||||
$this->briefpapier2="";
|
||||
}
|
||||
|
||||
// $zahlungsweise = strtolower($zahlungsweise);
|
||||
|
||||
if($zahlungsweise=="lastschrift" || $zahlungsweise=="einzugsermaechtigung")
|
||||
{
|
||||
$zahlungsweisetext = "\n".$this->app->erp->Beschriftung("dokument_offene_lastschriften");
|
||||
}
|
||||
|
||||
//if($zahlungszielskonto>0) $zahlungsweisetext .= "\n".$this->app->erp->Beschriftung("dokument_skonto")." $zahlungszielskonto% ".$this->app->erp->Beschriftung("dokument_auszahlungskonditionen");
|
||||
|
||||
if($zahlungszielskonto!=0)
|
||||
$zahlungsweisetext .="\r\n".$this->app->erp->Beschriftung("dokument_skontoanderezahlungsweisen");
|
||||
|
||||
$zahlungsweisetext = str_replace('{ZAHLUNGSZIELSKONTO}',number_format($zahlungszielskonto,2,',','.'),$zahlungsweisetext);
|
||||
|
||||
if($belegnr=="" || $belegnr=="0") $belegnr = "- ".$this->app->erp->Beschriftung("dokument_entwurf");
|
||||
|
||||
|
||||
if($stornorechnung)
|
||||
$this->doctypeOrig=$this->app->erp->Beschriftung("bezeichnungstornorechnung")." $belegnr";
|
||||
else
|
||||
$this->doctypeOrig=$this->app->erp->Beschriftung("dokument_gutschrift")." $belegnr";
|
||||
|
||||
if($gutschrift=="") $gutschrift = "-";
|
||||
if($kundennummer=="") $kundennummer= "-";
|
||||
|
||||
if($auftrag=="0") $auftrag = "-";
|
||||
if($lieferschein=="0") $lieferschein= "-";
|
||||
|
||||
$bearbeiteremail = $this->app->DB->Select("SELECT b.email FROM gutschrift g LEFT JOIN adresse b ON b.id=g.bearbeiterid WHERE g.id='$id' LIMIT 1");
|
||||
$bearbeitertelefon = $this->app->DB->Select("SELECT b.telefon FROM gutschrift g LEFT JOIN adresse b ON b.id=g.bearbeiterid WHERE g.id='$id' LIMIT 1");
|
||||
|
||||
/** @var \Xentral\Modules\Company\Service\DocumentCustomizationService $service */
|
||||
$service = $this->app->Container->get('DocumentCustomizationService');
|
||||
if($block = $service->findActiveBlock('corr', 'credit_note', $projekt)) {
|
||||
$sCD = $service->parseBlockAsArray($this->getLanguageCodeFrom($this->sprache),'corr', 'credit_note',[
|
||||
'GUTSCHRIFTSNUMMER' => $belegnr,
|
||||
'DATUM' => $datum,
|
||||
'RECHNUNGSNUMMER' => $rechnung,
|
||||
'RECHNUNGSDATUM' => $rechnungsdatum,
|
||||
'KUNDENNUMMER' => $kundennummer,
|
||||
'BEARBEITER' => $bearbeiter,
|
||||
'BEARBEITEREMAIL' => $bearbeiteremail,
|
||||
'BEARBEITERTELEFON' => $bearbeitertelefon,
|
||||
'VERTRIEB' => $vertrieb,
|
||||
'PROJEKT' => $projektabkuerzung,
|
||||
'AUFTRAGSNUMMER' => $auftrag,
|
||||
'LIEFERSCHEINNUMMER' => $lieferschein,
|
||||
'LIEFERSCHEINDATUM' => $lieferscheindatum,
|
||||
'EMAIL' => $email,
|
||||
'TELEFON' => $telefon
|
||||
|
||||
|
||||
|
||||
], $projekt);
|
||||
if(!empty($sCD)) {
|
||||
switch($block['fontstyle']) {
|
||||
case 'f':
|
||||
$this->setBoldCorrDetails($sCD);
|
||||
break;
|
||||
case 'i':
|
||||
$this->setItalicCorrDetails($sCD);
|
||||
break;
|
||||
case 'fi':
|
||||
$this->setItalicBoldCorrDetails($sCD);
|
||||
break;
|
||||
default:
|
||||
$this->setCorrDetails($sCD, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
//$this->setCorrDetails(array("Auftrag"=>$auftrag,"Datum"=>$datum,"Ihre Kunden-Nr."=>$kundennummer,"Lieferschein"=>$lieferschein,"Buchhaltung"=>$buchhaltung));
|
||||
if($briefpapier_bearbeiter_ausblenden || $briefpapier_vertrieb_ausblenden){
|
||||
if($rechnung != ""){
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_rechnung") => $rechnung, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer);
|
||||
}else{
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer);
|
||||
//$this->setCorrDetails(array($this->app->erp->Beschriftung("dokument_datum")=>$datum,$this->app->erp->Beschriftung("bezeichnungkundennummer")=>$kundennummer,$this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer")=>$ihrebestellnummer));
|
||||
}
|
||||
if(!$briefpapier_bearbeiter_ausblenden){
|
||||
if($bearbeiter) $sCD[$this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter")] = $bearbeiter;
|
||||
}elseif(!$briefpapier_vertrieb_ausblenden){
|
||||
if($vertrieb) $sCD[$this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb")] = $vertrieb;
|
||||
}
|
||||
|
||||
}else{
|
||||
if($rechnung != "")
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_rechnung") => $rechnung, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter") => $bearbeiter, $this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb") => $vertrieb);
|
||||
else
|
||||
$sCD = array($this->app->erp->Beschriftung("dokument_datum") => $datum, $this->app->erp->Beschriftung("bezeichnungkundennummer") => $kundennummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bestellnummer") => $ihrebestellnummer, $this->app->erp->Beschriftung("auftrag_bezeichnung_bearbeiter") => $bearbeiter, $this->app->erp->Beschriftung("auftrag_bezeichnung_vertrieb") => $vertrieb);
|
||||
}
|
||||
|
||||
if($lieferdatum != "00.00.0000")
|
||||
$sCD[$this->app->erp->Beschriftung("dokument_lieferdatum")] = $lieferdatum;
|
||||
|
||||
|
||||
$this->setCorrDetails($sCD);
|
||||
}
|
||||
|
||||
if($keinsteuersatz!="1")
|
||||
{
|
||||
|
||||
if($ust_befreit==2)//$this->app->erp->Export($land))
|
||||
$steuer = $this->app->erp->Beschriftung("export_lieferung_vermerk");
|
||||
else {
|
||||
if($ust_befreit==1 && $ustid!="")//$this->app->erp->IstEU($land))
|
||||
$steuer = $this->app->erp->Beschriftung("eu_lieferung_vermerk");
|
||||
}
|
||||
$steuer = str_replace('{USTID}',$ustid,$steuer);
|
||||
$steuer = str_replace('{LAND}',$land,$steuer);
|
||||
}
|
||||
|
||||
$gutschrift_header=$this->app->erp->Beschriftung("gutschrift_header");
|
||||
if($bodyzusatz!="") $gutschrift_header=$gutschrift_header."\r\n".$bodyzusatz;
|
||||
|
||||
if($stornorechnung)
|
||||
{
|
||||
$gutschrift_header = str_replace('{ART}',$this->app->erp->Beschriftung("bezeichnungstornorechnung"),$gutschrift_header);
|
||||
} else {
|
||||
$gutschrift_header = str_replace('{ART}',$this->app->erp->Beschriftung("dokument_gutschrift"),$gutschrift_header);
|
||||
}
|
||||
|
||||
$gutschrift_header = $this->app->erp->ParseUserVars("gutschrift",$id,$gutschrift_header);
|
||||
|
||||
|
||||
if($this->app->erp->Firmendaten("footer_reihenfolge_gutschrift_aktivieren")=="1") {
|
||||
$footervorlage = $this->app->erp->Firmendaten("footer_reihenfolge_gutschrift");
|
||||
if($footervorlage=="")
|
||||
$footervorlage = "{FOOTERFREITEXT}\r\n{FOOTERTEXTVORLAGEGUTSCHRIFT}\r\n{FOOTERSTEUER}\r\n{FOOTERZAHLUNGSWEISETEXT}";
|
||||
|
||||
$footervorlage = str_replace('{FOOTERFREITEXT}',$freitext,$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERTEXTVORLAGEGUTSCHRIFT}',$this->app->erp->Beschriftung("gutschrift_footer"),$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERSTEUER}',$steuer,$footervorlage);
|
||||
$footervorlage = str_replace('{FOOTERZAHLUNGSWEISETEXT}',$zahlungsweisetext,$footervorlage);
|
||||
$footervorlage = $this->app->erp->ParseUserVars("gutschrift",$id,$footervorlage);
|
||||
$footer = $footervorlage;
|
||||
} else {
|
||||
$footer = "$freitext"."\r\n".$this->app->erp->ParseUserVars("gutschrift",$id,$this->app->erp->Beschriftung("gutschrift_footer"))."\r\n$zahlungsweisetext\r\n$steuer";
|
||||
}
|
||||
|
||||
|
||||
$this->setTextDetails(array(
|
||||
"body"=>$gutschrift_header,
|
||||
"footer"=>$footer));
|
||||
|
||||
$artikel = $this->app->DB->SelectArr("SELECT * FROM gutschrift_position WHERE gutschrift='$id' ORDER By sort");
|
||||
|
||||
if(!$this->app->erp->GutschriftMitUmsatzeuer($id)) $this->ust_befreit=true;
|
||||
|
||||
$summe_rabatt = $this->app->DB->Select("SELECT SUM(rabatt) FROM gutschrift_position WHERE gutschrift='$id'");
|
||||
if($summe_rabatt <> 0) $this->rabatt=1;
|
||||
|
||||
if($this->app->erp->Firmendaten("modul_verband")=="1") $this->rabatt=1;
|
||||
|
||||
//$waehrung = $this->app->DB->Select("SELECT waehrung FROM gutschrift_position WHERE gutschrift='$id' LIMIT 1");
|
||||
$steuersatzV = $this->app->erp->GetSteuersatzNormal(false,$id,"gutschrift");
|
||||
$steuersatzR = $this->app->erp->GetSteuersatzErmaessigt(false,$id,"gutschrift");
|
||||
$gesamtsteuern = 0;
|
||||
$mitumsatzsteuer = $this->app->erp->GutschriftMitUmsatzeuer($id);
|
||||
$belege_subpositionenstuecklisten = $this->app->erp->Firmendaten('belege_subpositionenstuecklisten');
|
||||
$belege_stuecklisteneinrueckenmm = $this->app->erp->Firmendaten('belege_stuecklisteneinrueckenmm');
|
||||
//$positionenkaufmaenischrunden = $this->app->erp->Firmendaten('positionenkaufmaenischrunden');
|
||||
$positionenkaufmaenischrunden = $this->app->erp->Projektdaten($projekt,"preisberechnung");
|
||||
$viernachkommastellen_belege = $this->app->erp->Firmendaten('viernachkommastellen_belege');
|
||||
foreach($artikel as $key=>$value)
|
||||
{
|
||||
if($value['umsatzsteuer'] != "ermaessigt" && $value['umsatzsteuer'] != "befreit") $value['umsatzsteuer'] = "normal";
|
||||
$tmpsteuersatz = null;
|
||||
$tmpsteuertext = null;
|
||||
$this->app->erp->GetSteuerPosition('gutschrift', $value['id'],$tmpsteuersatz, $tmpsteuertext);
|
||||
if(is_null($value['steuersatz']) || $value['steuersatz'] < 0)
|
||||
{
|
||||
if($value['umsatzsteuer'] == "ermaessigt")
|
||||
{
|
||||
$value['steuersatz'] = $steuersatzR;
|
||||
}elseif($value['umsatzsteuer'] == "befreit")
|
||||
{
|
||||
$value['steuersatz'] = $steuersatzR;
|
||||
}else{
|
||||
$value['steuersatz'] = $steuersatzV;
|
||||
}
|
||||
if(!is_null($tmpsteuersatz))$value['steuersatz'] = $tmpsteuersatz;
|
||||
}
|
||||
if($tmpsteuertext && !$value['steuertext'])$value['steuertext'] = $tmpsteuertext;
|
||||
if(!$mitumsatzsteuer)$value['steuersatz'] = 0;
|
||||
// negative Darstellung bei Stornorechnung
|
||||
if($stornorechnung) $value['preis'] = $value['preis'] *-1;
|
||||
|
||||
if(!$this->app->erp->Export($land))
|
||||
{
|
||||
$value['zolltarifnummer']="";
|
||||
$value['herkunftsland']="";
|
||||
}
|
||||
|
||||
$value = $this->CheckPosition($value,"gutschrift",$this->doctypeid,$value['id']);
|
||||
|
||||
$value['menge'] = floatval($value['menge']);
|
||||
|
||||
if($value['explodiert_parent_artikel'] > 0)
|
||||
{
|
||||
if($belege_subpositionenstuecklisten || $belege_stuecklisteneinrueckenmm)$value['bezeichnung'] = ltrim(ltrim($value['bezeichnung'],'*'));
|
||||
if(isset($lvl) && isset($lvl[$value['explodiert_parent_artikel']]))
|
||||
{
|
||||
$value['lvl'] = $lvl[$value['explodiert_parent_artikel']] + 1;
|
||||
}else{
|
||||
$value['lvl'] = 1;
|
||||
}
|
||||
$lvl[$value['artikel']] = $value['lvl'];
|
||||
$check_ausblenden = $this->app->DB->Select("SELECT keineeinzelartikelanzeigen FROM artikel WHERE id='".$value['explodiert_parent_artikel']."' LIMIT 1");
|
||||
if(!$check_ausblenden && isset($ausblenden) && in_array($value['explodiert_parent_artikel'], $ausblenden))
|
||||
{
|
||||
$check_ausblenden = true;
|
||||
}
|
||||
if($check_ausblenden)
|
||||
{
|
||||
$ausblenden[] = $value['artikel'];
|
||||
}
|
||||
} else
|
||||
{
|
||||
$check_ausblenden=0;
|
||||
$lvl[$value['artikel']] = 0;
|
||||
$value['lvl'] = 0;
|
||||
}
|
||||
|
||||
if($value['ausblenden_im_pdf']) $check_ausblenden=1;
|
||||
|
||||
$ohne_artikeltext = $this->app->DB->Select("SELECT ohne_artikeltext FROM ".$this->table." WHERE id='".$this->id."' LIMIT 1");
|
||||
if($ohne_artikeltext=="1") $value['beschreibung']="";
|
||||
|
||||
if($check_ausblenden!=1)
|
||||
{
|
||||
$this->addItem(array('currency'=>$value['waehrung'],'lvl'=>isset($value['lvl'])?$value['lvl']:0,
|
||||
'amount'=>$value['menge'],
|
||||
'price'=>$value['preis'],
|
||||
'tax'=>$value['umsatzsteuer'],
|
||||
'steuersatz'=>$value['steuersatz'],
|
||||
'steuertext'=>$value['steuertext'],
|
||||
'itemno'=>$value['nummer'],
|
||||
'artikel'=>$value['artikel'],
|
||||
'unit'=>$value['einheit'],
|
||||
'desc'=>$value['beschreibung'],
|
||||
"name"=>ltrim($value['bezeichnung']),
|
||||
'artikelnummerkunde'=>$value['artikelnummerkunde'],
|
||||
'lieferdatum'=>$value['lieferdatum'],
|
||||
'lieferdatumkw'=>$value['lieferdatumkw'],
|
||||
'zolltarifnummer'=>$value['zolltarifnummer'],
|
||||
'herkunftsland'=>$value['herkunftsland'],
|
||||
'ohnepreis'=>$value['ohnepreis'],
|
||||
'grundrabatt'=>$value['grundrabatt'],
|
||||
'rabatt1'=>$value['rabatt1'],
|
||||
'rabatt2'=>$value['rabatt2'],
|
||||
'rabatt3'=>$value['rabatt3'],
|
||||
'rabatt4'=>$value['rabatt4'],
|
||||
'rabatt5'=>$value['rabatt5'],
|
||||
'freifeld1'=>$value['freifeld1'],
|
||||
'freifeld2'=>$value['freifeld2'],
|
||||
'freifeld3'=>$value['freifeld3'],
|
||||
'freifeld4'=>$value['freifeld4'],
|
||||
'freifeld5'=>$value['freifeld5'],
|
||||
'freifeld6'=>$value['freifeld6'],
|
||||
'freifeld7'=>$value['freifeld7'],
|
||||
'freifeld8'=>$value['freifeld8'],
|
||||
'freifeld9'=>$value['freifeld9'],
|
||||
'freifeld10'=>$value['freifeld10'],
|
||||
'freifeld11'=>$value['freifeld11'],
|
||||
'freifeld12'=>$value['freifeld12'],
|
||||
'freifeld13'=>$value['freifeld13'],
|
||||
'freifeld14'=>$value['freifeld14'],
|
||||
'freifeld15'=>$value['freifeld15'],
|
||||
'freifeld16'=>$value['freifeld16'],
|
||||
'freifeld17'=>$value['freifeld17'],
|
||||
'freifeld18'=>$value['freifeld18'],
|
||||
'freifeld19'=>$value['freifeld19'],
|
||||
'freifeld20'=>$value['freifeld20'],
|
||||
'freifeld21'=>$value['freifeld21'],
|
||||
'freifeld22'=>$value['freifeld22'],
|
||||
'freifeld23'=>$value['freifeld23'],
|
||||
'freifeld24'=>$value['freifeld24'],
|
||||
'freifeld25'=>$value['freifeld25'],
|
||||
'freifeld26'=>$value['freifeld26'],
|
||||
'freifeld27'=>$value['freifeld27'],
|
||||
'freifeld28'=>$value['freifeld28'],
|
||||
'freifeld29'=>$value['freifeld29'],
|
||||
'freifeld30'=>$value['freifeld30'],
|
||||
'freifeld31'=>$value['freifeld31'],
|
||||
'freifeld32'=>$value['freifeld32'],
|
||||
'freifeld33'=>$value['freifeld33'],
|
||||
'freifeld34'=>$value['freifeld34'],
|
||||
'freifeld35'=>$value['freifeld35'],
|
||||
'freifeld36'=>$value['freifeld36'],
|
||||
'freifeld37'=>$value['freifeld37'],
|
||||
'freifeld38'=>$value['freifeld38'],
|
||||
'freifeld39'=>$value['freifeld39'],
|
||||
'freifeld40'=>$value['freifeld40'],
|
||||
"keinrabatterlaubt"=>$value['keinrabatterlaubt'],
|
||||
"rabatt"=>$value['rabatt']));
|
||||
}
|
||||
if($positionenkaufmaenischrunden == 3){
|
||||
$netto_gesamt = $value['menge'] * round($value['preis'] - ($value['preis'] / 100 * $value['rabatt']),2);
|
||||
}else{
|
||||
$netto_gesamt = $value['menge'] * ($value['preis'] - ($value['preis'] / 100 * $value['rabatt']));
|
||||
}
|
||||
if($positionenkaufmaenischrunden)
|
||||
{
|
||||
$netto_gesamt = round($netto_gesamt, 2);
|
||||
}
|
||||
$summe = $summe + $netto_gesamt;
|
||||
if(!isset($summen[$value['steuersatz']]))$summen[$value['steuersatz']] = 0;
|
||||
$summen[$value['steuersatz']] += ($netto_gesamt/100)*$value['steuersatz'];
|
||||
$gesamtsteuern +=($netto_gesamt/100)*$value['steuersatz'];
|
||||
/*
|
||||
if($value['umsatzsteuer']=="" || $value['umsatzsteuer']=="normal")
|
||||
{
|
||||
$summeV = $summeV + (($netto_gesamt/100)*$this->app->erp->GetSteuersatzNormal(false,$id,"gutschrift"));
|
||||
}
|
||||
else {
|
||||
$summeR = $summeR + (($netto_gesamt/100)*$this->app->erp->GetSteuersatzErmaessigt(false,$id,"gutschrift"));
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
if($positionenkaufmaenischrunden && isset($summen) && is_array($summen))
|
||||
{
|
||||
$gesamtsteuern = 0;
|
||||
foreach($summen as $k => $v)
|
||||
{
|
||||
$summen[$k] = round($v, 2);
|
||||
$gesamtsteuern += round($v, 2);
|
||||
}
|
||||
}
|
||||
if($positionenkaufmaenischrunden)
|
||||
{
|
||||
list($summe,$gesamtsumme, $summen) = $this->app->erp->steuerAusBelegPDF($this->table, $this->id);
|
||||
$gesamtsteuern = $gesamtsumme - $summe;
|
||||
}
|
||||
|
||||
/*
|
||||
$summe = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id'");
|
||||
|
||||
$summeV = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id' AND (umsatzsteuer='normal' or umsatzsteuer='')")/100 * 19;
|
||||
$summeR = $this->app->DB->Select("SELECT SUM(menge*preis) FROM gutschrift_position WHERE gutschrift='$id' AND umsatzsteuer='ermaessigt'")/100 * 7;
|
||||
*/
|
||||
if($this->app->erp->GutschriftMitUmsatzeuer($id))
|
||||
{
|
||||
$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe + $gesamtsteuern,"summen"=>$summen,"totalTaxV"=>0,"totalTaxR"=>0));
|
||||
//$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe + $summeV + $summeR,"totalTaxV"=>$summeV,"totalTaxR"=>$summeR));
|
||||
} else
|
||||
$this->setTotals(array("totalArticles"=>$summe,"total"=>$summe));
|
||||
|
||||
/* Dateiname */
|
||||
$tmp_name = str_replace(' ','',trim($this->recipient['enterprise']));
|
||||
$tmp_name = str_replace('.','',$tmp_name);
|
||||
|
||||
if($stornorechnung)
|
||||
$this->filename = $datum2."_STORNO_".$belegnr.".pdf";
|
||||
else
|
||||
$this->filename = $datum2."_GS".$belegnr.".pdf";
|
||||
|
||||
$this->setBarcode($belegnr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ class RechnungPDF extends BriefpapierCustom {
|
||||
{
|
||||
// pruefe ob es mehr als ein steuersatz gibt // wenn ja dann darf man sie nicht ausblenden
|
||||
$check = $this->app->erp->SteuerAusBeleg($this->doctype,$id);
|
||||
if(count($check)>1)$this->ust_spalteausblende=false;
|
||||
if(!empty($check)?count($check):0>1)$this->ust_spalteausblende=false;
|
||||
else $this->ust_spalteausblende=true;
|
||||
}
|
||||
$lvl = null;
|
||||
|
544
www/pages/bestellvorschlag.php
Normal file
544
www/pages/bestellvorschlag.php
Normal file
@ -0,0 +1,544 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 OpenXE project
|
||||
*/
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
|
||||
class Bestellvorschlag {
|
||||
|
||||
function __construct($app, $intern = false) {
|
||||
$this->app = $app;
|
||||
if ($intern)
|
||||
return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
$this->app->ActionHandler("list", "bestellvorschlag_list");
|
||||
// $this->app->ActionHandler("create", "bestellvorschlag_edit"); // This automatically adds a "New" button
|
||||
// $this->app->ActionHandler("edit", "bestellvorschlag_edit");
|
||||
// $this->app->ActionHandler("delete", "bestellvorschlag_delete");
|
||||
$this->app->DefaultActionHandler("list");
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
public function Install() {
|
||||
/* Fill out manually later */
|
||||
}
|
||||
|
||||
public function TableSearch(&$app, $name, $erlaubtevars) {
|
||||
switch ($name) {
|
||||
case "bestellvorschlag_list":
|
||||
$allowed['bestellvorschlag_list'] = array('list');
|
||||
|
||||
$monate_absatz = $this->app->User->GetParameter('bestellvorschlag_monate_absatz');
|
||||
if (empty($monate_absatz)) {
|
||||
$monate_absatz = 0;
|
||||
}
|
||||
$monate_voraus = $this->app->User->GetParameter('bestellvorschlag_monate_voraus');
|
||||
if (empty($monate_voraus)) {
|
||||
$monate_voraus = 0;
|
||||
}
|
||||
|
||||
$heading = array('', '', 'Nr.', 'Artikel','Lieferant','Mindestlager','Lager','Bestellt','Auftrag','Absatz','Voraus','Vorschlag','Eingabe','');
|
||||
$width = array('1%','1%','1%', '20%', '10%', '1%', '1%', '1%', '1%', '1%', '1%', '1%', '1%', '1%');
|
||||
|
||||
// columns that are aligned right (numbers etc)
|
||||
// $alignright = array(4,5,6,7,8);
|
||||
|
||||
$findcols = array('a.id','a.id','a.nummer','a.name_de','l.name','mindestlager','lager','bestellt','auftrag','absatz','voraus','vorschlag');
|
||||
$searchsql = array('a.name_de');
|
||||
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
$numbercols = array(6,7,8,9,10,11,12);
|
||||
// $sumcol = array(6);
|
||||
$alignright = array(6,7,8,9,10,11,12);
|
||||
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',a.id,'\" />') AS `auswahl`";
|
||||
|
||||
// $menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=bestellvorschlag&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=bestellvorschlag&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
|
||||
$input_for_menge = "CONCAT(
|
||||
'<input type = \"number\" min=\"0\"',
|
||||
' name=\"menge_',
|
||||
a.id,
|
||||
'\" value=\"',
|
||||
ROUND((SELECT mengen.vorschlag)),
|
||||
'\" style=\"text-align:right; width:100%\">',
|
||||
'</input>'
|
||||
)";
|
||||
|
||||
$user = $app->User->GetID();
|
||||
|
||||
$sql_artikel_mengen = "
|
||||
SELECT
|
||||
a.id,
|
||||
(
|
||||
SELECT
|
||||
COALESCE(SUM(menge),0)
|
||||
FROM
|
||||
lager_platz_inhalt lpi
|
||||
INNER JOIN lager_platz lp ON
|
||||
lp.id = lpi.lager_platz
|
||||
WHERE
|
||||
lpi.artikel = a.id AND lp.sperrlager = 0
|
||||
) AS lager,
|
||||
(
|
||||
SELECT
|
||||
COALESCE(SUM(menge - geliefert),0)
|
||||
FROM
|
||||
bestellung_position bp
|
||||
INNER JOIN bestellung b ON
|
||||
bp.bestellung = b.id
|
||||
WHERE
|
||||
bp.artikel = a.id AND b.status IN(
|
||||
'versendet',
|
||||
'freigegeben',
|
||||
'angelegt'
|
||||
)
|
||||
) AS bestellt,
|
||||
(
|
||||
SELECT
|
||||
COALESCE(SUM(menge - geliefert),0)
|
||||
FROM
|
||||
auftrag_position aufp
|
||||
INNER JOIN auftrag auf ON
|
||||
aufp.auftrag = auf.id
|
||||
WHERE
|
||||
aufp.artikel = a.id AND auf.status IN(
|
||||
'versendet',
|
||||
'freigegeben',
|
||||
'angelegt'
|
||||
)
|
||||
) AS auftrag,
|
||||
(
|
||||
SELECT
|
||||
COALESCE(SUM(menge),0)
|
||||
FROM
|
||||
rechnung_position rp
|
||||
INNER JOIN rechnung r ON
|
||||
rp.rechnung = r.id
|
||||
WHERE
|
||||
rp.artikel = a.id AND r.status IN(
|
||||
'versendet',
|
||||
'freigegeben'
|
||||
) AND r.datum > LAST_DAY(CURDATE() - INTERVAL ('$monate_absatz'+1) MONTH) AND r.datum <= LAST_DAY(CURDATE() - INTERVAL 1 MONTH)
|
||||
) AS absatz,
|
||||
ROUND (
|
||||
(
|
||||
select absatz
|
||||
) / '$monate_absatz' * '$monate_voraus') AS voraus,
|
||||
(
|
||||
SELECT
|
||||
COALESCE(menge,0)
|
||||
FROM
|
||||
bestellvorschlag bv
|
||||
WHERE
|
||||
bv.artikel = a.id AND bv.user = '$user'
|
||||
) AS vorschlag_save,
|
||||
a.mindestlager -(
|
||||
SELECT
|
||||
lager
|
||||
) - COALESCE((
|
||||
SELECT
|
||||
bestellt
|
||||
),
|
||||
0)
|
||||
+ COALESCE((
|
||||
SELECT
|
||||
auftrag
|
||||
),
|
||||
0)
|
||||
+ COALESCE((
|
||||
SELECT
|
||||
voraus
|
||||
),
|
||||
0)
|
||||
AS vorschlag_ber_raw,
|
||||
IF(
|
||||
(
|
||||
SELECT
|
||||
vorschlag_ber_raw
|
||||
) > 0,
|
||||
(
|
||||
SELECT
|
||||
vorschlag_ber_raw
|
||||
),
|
||||
0
|
||||
) AS vorschlag_ber,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT
|
||||
vorschlag_save
|
||||
),
|
||||
(
|
||||
SELECT
|
||||
vorschlag_ber
|
||||
)
|
||||
) AS vorschlag,
|
||||
FORMAT(a.mindestlager, 0, 'de_DE') AS mindestlager_form,
|
||||
FORMAT((
|
||||
SELECT
|
||||
lager
|
||||
),
|
||||
0,
|
||||
'de_DE') AS lager_form,
|
||||
FORMAT(
|
||||
COALESCE((
|
||||
SELECT
|
||||
bestellt
|
||||
),
|
||||
0),
|
||||
0,
|
||||
'de_DE'
|
||||
) AS bestellt_form,
|
||||
FORMAT(
|
||||
COALESCE((
|
||||
SELECT
|
||||
auftrag
|
||||
),
|
||||
0),
|
||||
0,
|
||||
'de_DE'
|
||||
) AS auftrag_form,
|
||||
FORMAT(
|
||||
COALESCE((
|
||||
SELECT
|
||||
absatz
|
||||
),
|
||||
0),
|
||||
0,
|
||||
'de_DE'
|
||||
) AS absatz_form,
|
||||
FORMAT(
|
||||
COALESCE((
|
||||
SELECT
|
||||
voraus
|
||||
),
|
||||
0),
|
||||
0,
|
||||
'de_DE'
|
||||
) AS voraus_form,
|
||||
FORMAT(
|
||||
(
|
||||
SELECT
|
||||
vorschlag_ber
|
||||
),
|
||||
'0',
|
||||
'de_DE'
|
||||
) AS vorschlag_ber_form
|
||||
,
|
||||
FORMAT(
|
||||
(
|
||||
SELECT
|
||||
vorschlag
|
||||
),
|
||||
'0',
|
||||
'de_DE'
|
||||
) AS vorschlag_form
|
||||
FROM
|
||||
artikel a
|
||||
";
|
||||
|
||||
|
||||
//echo($sql_artikel_mengen);
|
||||
|
||||
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||
a.id,
|
||||
$dropnbox,
|
||||
a.nummer,
|
||||
a.name_de,
|
||||
l.name,
|
||||
mengen.mindestlager_form,
|
||||
mengen.lager_form,
|
||||
mengen.bestellt_form,
|
||||
mengen.auftrag_form,
|
||||
mengen.absatz_form,
|
||||
mengen.voraus_form,
|
||||
mengen.vorschlag_ber_form,"
|
||||
.$input_for_menge
|
||||
."FROM
|
||||
artikel a
|
||||
INNER JOIN
|
||||
adresse l ON l.id = a.adresse
|
||||
INNER JOIN
|
||||
(SELECT * FROM ($sql_artikel_mengen) mengen_inner WHERE mengen_inner.vorschlag > 0) as mengen ON mengen.id = a.id";
|
||||
|
||||
$where = "a.adresse != '' AND a.geloescht != 1 AND a.inaktiv != 1";
|
||||
$count = "SELECT count(DISTINCT a.id) FROM artikel a WHERE $where";
|
||||
// $groupby = "";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$erg = false;
|
||||
|
||||
foreach ($erlaubtevars as $k => $v) {
|
||||
if (isset($$v)) {
|
||||
$erg[$v] = $$v;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
|
||||
function bestellvorschlag_list() {
|
||||
|
||||
|
||||
$submit = $this->app->Secure->GetPOST('submit');
|
||||
$user = $this->app->User->GetID();
|
||||
|
||||
$monate_absatz = $this->app->Secure->GetPOST('monate_absatz');
|
||||
if (empty($monate_absatz)) {
|
||||
$monate_absatz = 0;
|
||||
}
|
||||
$monate_voraus = $this->app->Secure->GetPOST('monate_voraus');
|
||||
if (empty($monate_voraus)) {
|
||||
$monate_voraus = 0;
|
||||
}
|
||||
|
||||
// For transfer to tablesearch
|
||||
$this->app->User->SetParameter('bestellvorschlag_monate_absatz', $monate_absatz);
|
||||
$this->app->User->SetParameter('bestellvorschlag_monate_voraus', $monate_voraus);
|
||||
|
||||
switch ($submit) {
|
||||
case 'loeschen':
|
||||
$sql = "DELETE FROM bestellvorschlag where user = $user";
|
||||
$this->app->DB->Delete($sql);
|
||||
break;
|
||||
case 'speichern':
|
||||
|
||||
$menge_input = $this->app->Secure->GetPOSTArray();
|
||||
$mengen = array();
|
||||
foreach ($menge_input as $key => $menge) {
|
||||
if ((strpos($key,'menge_') === 0) && ($menge !== '')) {
|
||||
$artikel = substr($key,'6');
|
||||
if ($menge > 0) {
|
||||
$sql = "INSERT INTO bestellvorschlag (artikel, user, menge) VALUES($artikel,$user,$menge) ON DUPLICATE KEY UPDATE menge = $menge";
|
||||
$this->app->DB->Insert($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'bestellungen_erzeugen':
|
||||
|
||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||
$selectedIds = [];
|
||||
|
||||
if(empty($auswahl)) {
|
||||
$msg = '<div class="error">Bitte Artikel auswählen.</div>';
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($auswahl)) {
|
||||
foreach ($auswahl as $selectedId) {
|
||||
$selectedId = (int) $selectedId;
|
||||
if ($selectedId > 0) {
|
||||
$selectedIds[] = $selectedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menge_input = $this->app->Secure->GetPOSTArray();
|
||||
$mengen = array();
|
||||
|
||||
foreach ($selectedIds as $artikel_id) {
|
||||
foreach ($menge_input as $key => $menge) {
|
||||
if ((strpos($key,'menge_') === 0) && ($menge !== '')) {
|
||||
$artikel = substr($key,'6');
|
||||
if ($menge > 0 && $artikel == $artikel_id) {
|
||||
$mengen[] = array('id' => $artikel,'menge' => $menge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mengen_pro_adresse = array();
|
||||
foreach ($mengen as $menge) {
|
||||
$sql = "SELECT adresse FROM artikel WHERE id = ".$menge['id'];
|
||||
$adresse = $this->app->DB->Select($sql);
|
||||
if (!empty($adresse)) {
|
||||
$index = array_search($adresse, array_column($mengen_pro_adresse,'adresse'));
|
||||
if ($index !== false) {
|
||||
$mengen_pro_adresse[$index]['positionen'][] = $menge;
|
||||
} else {
|
||||
$mengen_pro_adresse[] = array('adresse' => $adresse,'positionen' => array($menge));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$angelegt = 0;
|
||||
|
||||
foreach ($mengen_pro_adresse as $bestelladresse) {
|
||||
$bestellid = $this->app->erp->CreateBestellung($bestelladresse);
|
||||
if (!empty($bestellid)) {
|
||||
|
||||
$angelegt++;
|
||||
|
||||
$this->app->erp->LoadBestellungStandardwerte($bestellid,$bestelladresse['adresse']);
|
||||
$this->app->erp->BestellungProtokoll($bestellid,"Bestellung angelegt");
|
||||
foreach ($bestelladresse['positionen'] as $position) {
|
||||
$preisid = $this->app->erp->Einkaufspreis($position['id'], $position['menge'], $bestelladresse['adresse']);
|
||||
|
||||
if ($preisid == null) {
|
||||
$artikelohnepreis = $position['id'];
|
||||
} else {
|
||||
$artikelohnepreis = null;
|
||||
}
|
||||
|
||||
$this->app->erp->AddBestellungPosition(
|
||||
$bestellid,
|
||||
$preisid,
|
||||
$position['menge'],
|
||||
$datum,
|
||||
'',
|
||||
$artikelohnepreis
|
||||
);
|
||||
}
|
||||
$this->app->erp->BestellungNeuberechnen($bestellid);
|
||||
}
|
||||
}
|
||||
$msg .= "<div class=\"success\">Es wurden $angelegt Bestellungen angelegt.</div>";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=bestellvorschlag&action=list", "Übersicht");
|
||||
$this->app->erp->MenuEintrag("index.php?module=bestellvorschlag&action=create", "Neu anlegen");
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php", "Zurück");
|
||||
|
||||
$this->app->Tpl->Set('MONATE_ABSATZ',$monate_absatz);
|
||||
$this->app->Tpl->Set('MONATE_VORAUS',$monate_voraus);
|
||||
|
||||
$this->app->Tpl->Set('MESSAGE',$msg);
|
||||
|
||||
$this->app->YUI->TableSearch('TAB1', 'bestellvorschlag_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
$this->app->Tpl->Parse('PAGE', "bestellvorschlag_list.tpl");
|
||||
}
|
||||
|
||||
public function bestellvorschlag_delete() {
|
||||
$id = (int) $this->app->Secure->GetGET('id');
|
||||
|
||||
$this->app->DB->Delete("DELETE FROM `bestellvorschlag` WHERE `id` = '{$id}'");
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gelöscht.</div>");
|
||||
|
||||
$this->bestellvorschlag_list();
|
||||
}
|
||||
|
||||
/*
|
||||
* Edit bestellvorschlag item
|
||||
* If id is empty, create a new one
|
||||
*/
|
||||
|
||||
function bestellvorschlag_edit() {
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
|
||||
// Check if other users are editing this id
|
||||
if($this->app->erp->DisableModul('artikel',$id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('ID', $id);
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=bestellvorschlag&action=edit&id=$id", "Details");
|
||||
$this->app->erp->MenuEintrag("index.php?module=bestellvorschlag&action=list", "Zurück zur Übersicht");
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$input = $this->GetInput();
|
||||
$submit = $this->app->Secure->GetPOST('submit');
|
||||
|
||||
if (empty($id)) {
|
||||
// New item
|
||||
$id = 'NULL';
|
||||
}
|
||||
|
||||
if ($submit != '')
|
||||
{
|
||||
|
||||
// Write to database
|
||||
|
||||
// Add checks here
|
||||
|
||||
$columns = "id, ";
|
||||
$values = "$id, ";
|
||||
$update = "";
|
||||
|
||||
$fix = "";
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
$columns = $columns.$fix.$key;
|
||||
$values = $values.$fix."'".$value."'";
|
||||
$update = $update.$fix.$key." = '$value'";
|
||||
|
||||
$fix = ", ";
|
||||
}
|
||||
|
||||
// echo($columns."<br>");
|
||||
// echo($values."<br>");
|
||||
// echo($update."<br>");
|
||||
|
||||
$sql = "INSERT INTO bestellvorschlag (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
|
||||
|
||||
// echo($sql);
|
||||
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
if ($id == 'NULL') {
|
||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
||||
header("Location: index.php?module=bestellvorschlag&action=list&msg=$msg");
|
||||
} else {
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load values again from database
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',b.id,'\" />') AS `auswahl`";
|
||||
$result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS b.id, $dropnbox, b.artikel, b.adresse, b.lager, b.id FROM bestellvorschlag b"." WHERE id=$id");
|
||||
|
||||
foreach ($result[0] as $key => $value) {
|
||||
$this->app->Tpl->Set(strtoupper($key), $value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add displayed items later
|
||||
*
|
||||
|
||||
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
|
||||
$this->app->Tpl->Add('EMAIL', $email);
|
||||
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
||||
*/
|
||||
|
||||
// $this->SetInput($input);
|
||||
$this->app->Tpl->Parse('PAGE', "bestellvorschlag_edit.tpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all paramters from html form and save into $input
|
||||
*/
|
||||
public function GetInput(): array {
|
||||
$input = array();
|
||||
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
|
||||
|
||||
$input['artikel'] = $this->app->Secure->GetPOST('artikel');
|
||||
$input['adresse'] = $this->app->Secure->GetPOST('adresse');
|
||||
$input['lager'] = $this->app->Secure->GetPOST('lager');
|
||||
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set all fields in the page corresponding to $input
|
||||
*/
|
||||
function SetInput($input) {
|
||||
// $this->app->Tpl->Set('EMAIL', $input['email']);
|
||||
|
||||
$this->app->Tpl->Set('ARTIKEL', $input['artikel']);
|
||||
$this->app->Tpl->Set('ADRESSE', $input['adresse']);
|
||||
$this->app->Tpl->Set('LAGER', $input['lager']);
|
||||
|
||||
}
|
||||
|
||||
}
|
83
www/pages/content/bestellvorschlag_list.tpl
Normal file
83
www/pages/content/bestellvorschlag_list.tpl
Normal file
@ -0,0 +1,83 @@
|
||||
<div id="tabs">
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-4 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>{|Einstellungen|}</legend>
|
||||
|
||||
<td>{|Absatz berücksichtigen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_absatz" id="monate_absatz" value="[MONATE_ABSATZ]" size="20""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{|Vorausplanen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_voraus" id="monate_voraus" value="[MONATE_VORAUS]" size="20""></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-8 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-2 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>Aktionen</legend>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="loeschen">{|Zurücksetzen|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="speichern">{|Speichern|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="bestellungen_erzeugen">{|Bestellungen erzeugen|}</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-6 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
[TAB1]
|
||||
<fieldset>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" value="1" id="autoalle" /> alle markieren
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
[TAB1NEXT]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$('#autoalle').on('change',function(){
|
||||
var wert = $(this).prop('checked');
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').prop('checked',wert);
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').first().trigger('change');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
@ -191,7 +191,7 @@
|
||||
<td><input type="number" min="0" name="menge_ausschuss_produzieren" id="menge_ausschuss_produzieren" value="[MENGE_AUSSCHUSS_PRODUZIEREN]" size="20"></td>
|
||||
</tr>
|
||||
<tr [AKTION_PRODUZIEREN_VISIBLE]>
|
||||
<td>{|Ziellager|}:</td>
|
||||
<td>{|Ziellager|}:</td><i>Info like this.</i>
|
||||
<td><input type="text" name="ziellager" id="ziellager" value="[ZIELLAGER]" size="20"></td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -243,15 +243,24 @@
|
||||
</div>
|
||||
<div id="tabs-3">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
<form action="index.php?module=produktion_position&action=edit&produktion=[PRODUKTION_ID]" method="post">
|
||||
[FORMHANDLEREVENT]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Positionen|}</legend>
|
||||
[PRODUKTION_POSITION_SOURCE_POSITION_TABELLE]
|
||||
<legend>{|Positionen|}</legend>
|
||||
[PRODUKTION_POSITION_SOURCE_POSITION_TABELLE]
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr [AKTION_FREIGEBEN]>
|
||||
<td>{|Artikel|}:</td>
|
||||
<td><input type="text" name="artikel" id="artikel" size="20"></td>
|
||||
<td>{|Menge|}:</td>
|
||||
<td><input type="number" min="0" name="menge" id="menge" size="20"></td>
|
||||
<td><button name="submit" value="hinzufuegen" class="ui-button-icon" style="width:100%;">Hinzufügen</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
90
www/pages/content/uebersetzung_edit.tpl
Normal file
90
www/pages/content/uebersetzung_edit.tpl
Normal file
@ -0,0 +1,90 @@
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1"></a></li>
|
||||
</ul>
|
||||
<!-- Example for multiple tabs
|
||||
<ul hidden">
|
||||
<li><a href="#tabs-1">First Tab</a></li>
|
||||
<li><a href="#tabs-2">Second Tab</a></li>
|
||||
</ul>
|
||||
-->
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
[FORMHANDLEREVENT]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|<!--Legend for this form area goes here>-->uebersetzung|}</legend><i>Info like this.</i>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr><td>{|Label|}:</td><td><input type="text" name="label" id="label" value="[LABEL]" size="20"></td></tr>
|
||||
<!---
|
||||
<tr>
|
||||
<td>{|Sprache|}:</td>
|
||||
<td>
|
||||
<select name="sprache" size="0" tabindex="1" id="sprache" class="" onchange="">
|
||||
[SPRACHENSELECT]
|
||||
</select>
|
||||
</td>
|
||||
--!>
|
||||
<tr><td>{|Sprache|}:</td><td><input type="text" name="sprache" id="sprache" value="[SPRACHE]" size="20"></td></tr>
|
||||
</tr>
|
||||
<tr><td>{|Übersetzung|}:</td><td><textarea name="beschriftung" id="beschriftung" rows="6" style="width:100%;">[BESCHRIFTUNG]</textarea></td></tr>
|
||||
<tr><td>{|Original|}:</td><td><textarea name="original" id="original" rows="6" style="width:100%;">[ORIGINAL]</textarea></td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Example for 2nd row
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Another legend|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr><td>{|Label|}:</td><td><input type="text" name="label" id="label" value="[LABEL]" size="20"></td></tr>
|
||||
<tr><td>{|Beschriftung|}:</td><td><input type="text" name="beschriftung" id="beschriftung" value="[BESCHRIFTUNG]" size="20"></td></tr>
|
||||
<tr><td>{|Sprache|}:</td><td><input type="text" name="sprache" id="sprache" value="[SPRACHE]" size="20"></td></tr>
|
||||
<tr><td>{|Original|}:</td><td><input type="text" name="original" id="original" value="[ORIGINAL]" size="20"></td></tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Example for 2nd tab
|
||||
<div id="tabs-2">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
[FORMHANDLEREVENT]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|...|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
...
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" name="submit" value="Speichern" style="float:right"/>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
10
www/pages/content/uebersetzung_list.tpl
Normal file
10
www/pages/content/uebersetzung_list.tpl
Normal file
@ -0,0 +1,10 @@
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1">[TABTEXT1]</a></li>
|
||||
</ul>
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
[TAB1]
|
||||
[TAB1NEXT]
|
||||
</div>
|
||||
</div>
|
@ -3739,7 +3739,7 @@ class Importvorlage extends GenImportvorlage {
|
||||
}
|
||||
|
||||
$altervk = $this->app->DB->Select("SELECT preis FROM verkaufspreise WHERE artikel='$artikelid' AND ab_menge='".$tmp['verkaufspreis'.$verkaufspreisanzahl.'menge'][$i]."'
|
||||
AND (gueltig_bis='0000-00-00' OR gueltig_bis >=NOW() ) AND adresse <='$_kundenid' ".($gruppe?" AND gruppe = '".$gruppe."'":" AND (is_null(gruppe) or gruppe = '') ")." LIMIT 1");
|
||||
AND (gueltig_bis='0000-00-00' OR gueltig_bis >=NOW() ) AND adresse <='$_kundenid' ".($gruppe?" AND gruppe = '".$gruppe."'":" AND ((gruppe IS NULL) or gruppe = '') ")." LIMIT 1");
|
||||
|
||||
if($altervk != str_replace(',','.',$tmp['verkaufspreis'.$verkaufspreisanzahl.'netto'][$i]) && str_replace(',','.',$tmp['verkaufspreis'.$verkaufspreisanzahl.'netto'][$i]))
|
||||
{
|
||||
@ -3755,7 +3755,7 @@ class Importvorlage extends GenImportvorlage {
|
||||
//verkaufspreis3internerkommentar'][$i]
|
||||
|
||||
$this->app->DB->Update("UPDATE verkaufspreise SET gueltig_bis=DATE_SUB(NOW(),INTERVAL 1 DAY)
|
||||
WHERE artikel='".$artikelid."' AND adresse='$_kundenid' ".($gruppe?" AND gruppe = '".$gruppe."'":" AND (is_null(gruppe) or gruppe = '') ")."
|
||||
WHERE artikel='".$artikelid."' AND adresse='$_kundenid' ".($gruppe?" AND gruppe = '".$gruppe."'":" AND ((gruppe IS NULL) or gruppe = '') ")."
|
||||
AND ab_menge='".$tmp['verkaufspreis'.$verkaufspreisanzahl.'menge'][$i]."' LIMIT 1");
|
||||
|
||||
$verkaufspreis1stueckdivisor = 1;
|
||||
|
@ -176,11 +176,11 @@ class Produktion {
|
||||
|
||||
if (in_array($status,array('angelegt','freigegeben'))) {
|
||||
$heading = array('','','Nummer', 'Artikel', 'Projekt', 'Planmenge pro Stück', 'Lager alle (verfügbar)', 'Lager (verfügbar)', 'Reserviert', 'Planmenge', 'Verbraucht', 'Menü');
|
||||
$width = array('1%','1%', '5%','30%', '5%', '1%', '1%', '1%' , '1%', '1%', '1%' ,'1%');
|
||||
$width = array( '1%','1%','5%', '30%', '5%', '1%', '1%', '1%' , '1%', '1%', '1%' ,'1%');
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=produktion_position&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=produktion_position&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
} else {
|
||||
$heading = array('','','Nummer', 'Artikel', 'Projekt','Planmenge pro Stück', 'Lager (verfügbar)', 'Reserviert','Planmenge', 'Verbraucht','');
|
||||
$width = array('1%','1%', '5%','30%', '5%', '1%', '1%', '1%' , '1%' ,'1%' ,'1%');
|
||||
$heading = array('','','Nummer', 'Artikel', 'Projekt','Planmenge pro Stück', 'Lager alle (verfügbar)', 'Lager (verfügbar)', 'Reserviert', 'Planmenge', 'Verbraucht', '');
|
||||
$width = array( '1%','1%','5%', '30%', '5%', '1%', '1%', '1%' , '1%', '1%', '1%' ,'1%');
|
||||
$menu = "";
|
||||
}
|
||||
|
||||
@ -201,6 +201,7 @@ class Produktion {
|
||||
(SELECT a.name_de FROM artikel a WHERE a.id = p.artikel LIMIT 1) as name,
|
||||
(SELECT projekt.abkuerzung FROM projekt INNER JOIN artikel a WHERE a.projekt = projekt.id AND a.id = p.artikel LIMIT 1) as projekt,
|
||||
FORMAT(p.menge/$produktionsmenge,0,'de_DE') as stueckmenge,
|
||||
IF ((SELECT lagerartikel FROM artikel a WHERE a.id = p.artikel LIMIT 1) != 0,
|
||||
CONCAT (
|
||||
FORMAT (IFNULL((SELECT SUM(menge) FROM lager_platz_inhalt lpi WHERE lpi.artikel = p.artikel),0),0,'de_DE'),
|
||||
' (',
|
||||
@ -211,8 +212,8 @@ class Produktion {
|
||||
'de_DE'
|
||||
),
|
||||
')'
|
||||
) as lageralle,
|
||||
if ('$standardlager' = '0','-',
|
||||
),'') as lageralle,
|
||||
if (('$standardlager' != '0') && ((SELECT lagerartikel FROM artikel a WHERE a.id = p.artikel LIMIT 1) != 0),
|
||||
CONCAT (
|
||||
FORMAT (IFNULL((SELECT SUM(menge) FROM lager_platz_inhalt lpi WHERE lpi.lager_platz = $standardlager AND lpi.artikel = p.artikel),0),0,'de_DE'),
|
||||
' (',
|
||||
@ -224,6 +225,7 @@ class Produktion {
|
||||
),
|
||||
')'
|
||||
)
|
||||
,''
|
||||
) as lager,
|
||||
FORMAT ((SELECT SUM(menge) FROM lager_reserviert r WHERE r.lager_platz = $standardlager AND r.artikel = p.artikel AND r.objekt = 'produktion' AND r.parameter = $id AND r.posid = p.id),0,'de_DE') as Reserviert,
|
||||
FORMAT(p.menge,0,'de_DE'),
|
||||
@ -268,6 +270,7 @@ class Produktion {
|
||||
(SELECT a.name_de FROM artikel a WHERE a.id = p.artikel LIMIT 1) as name,
|
||||
(SELECT projekt.abkuerzung FROM projekt INNER JOIN artikel a WHERE a.projekt = projekt.id AND a.id = p.artikel LIMIT 1) as projekt,
|
||||
FORMAT(SUM(p.menge)/$produktionsmenge,0,'de_DE') as stueckmenge,
|
||||
IF ((SELECT lagerartikel FROM artikel a WHERE a.id = p.artikel LIMIT 1) != 0,
|
||||
CONCAT (
|
||||
FORMAT (IFNULL((SELECT SUM(menge) FROM lager_platz_inhalt lpi WHERE lpi.artikel = p.artikel),0),0,'de_DE'),
|
||||
' (',
|
||||
@ -278,8 +281,8 @@ class Produktion {
|
||||
'de_DE'
|
||||
),
|
||||
')'
|
||||
) as lageralle,
|
||||
if ('$standardlager' = '0','-',
|
||||
),'') as lageralle,
|
||||
if (('$standardlager' != '0') && ((SELECT lagerartikel FROM artikel a WHERE a.id = p.artikel LIMIT 1) != 0),
|
||||
CONCAT (
|
||||
FORMAT (IFNULL((SELECT SUM(menge) FROM lager_platz_inhalt lpi WHERE lpi.lager_platz = $standardlager AND lpi.artikel = p.artikel),0),0,'de_DE'),
|
||||
' (',
|
||||
@ -291,6 +294,7 @@ class Produktion {
|
||||
),
|
||||
')'
|
||||
)
|
||||
,''
|
||||
) as lager,
|
||||
FORMAT ((SELECT SUM(menge) FROM lager_reserviert r WHERE r.lager_platz = $standardlager AND r.artikel = p.artikel AND r.objekt = 'produktion' AND r.parameter = $id),0,'de_DE') as reserviert,
|
||||
FORMAT(SUM(p.menge),0,'de_DE') as menge,
|
||||
@ -579,7 +583,7 @@ class Produktion {
|
||||
$sql = "UPDATE produktion SET status = 'gestartet' WHERE id=$id";
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
$sql = "SELECT id, artikel, menge, geliefert_menge, stuecklistestufe FROM produktion_position pp WHERE produktion=$id";
|
||||
$sql = "SELECT pp.id, pp.artikel, pp.menge, pp.geliefert_menge, pp.stuecklistestufe, a.lagerartikel FROM produktion_position pp INNER JOIN artikel a ON a.id = pp.artikel WHERE pp.produktion=$id";
|
||||
$material = $this->app->DB->SelectArr($sql);
|
||||
|
||||
foreach ($material as $material_position) {
|
||||
@ -588,7 +592,7 @@ class Produktion {
|
||||
$menge_artikel_auslagern = $material_position['menge']/$produktionsartikel_position['menge']*$menge_auslagern;
|
||||
|
||||
// Remove material from stock
|
||||
if ($material_position['stuecklistestufe'] == 0) {
|
||||
if ($material_position['stuecklistestufe'] == 0 && $material_position['lagerartikel']) {
|
||||
$result = $this->app->erp->LagerAuslagernRegal($material_position['artikel'],$global_standardlager,$menge_artikel_auslagern,$global_projekt,'Produktion '.$produktion_belegnr);
|
||||
if ($result != 1) {
|
||||
$msg .= "<div class=\"error\">Kritischer Fehler beim Ausbuchen! (Position ".$material_position['id'].", Menge ".$menge_artikel_auslagern.").</div>".
|
||||
@ -834,7 +838,7 @@ class Produktion {
|
||||
|
||||
$this->ProtokollSchreiben($id,"Menge angepasst auf ".$this->FormatMenge($menge_anpassen));
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'abschliessen':
|
||||
$sql = "UPDATE produktion SET status = 'abgeschlossen' WHERE id=$id";
|
||||
$this->app->DB->Update($sql);
|
||||
@ -1046,7 +1050,7 @@ class Produktion {
|
||||
}
|
||||
|
||||
if($produktion_from_db['standardlager'] == 0) {
|
||||
$msg .= "<div class=\"error\">Kein Lager ausgewählt.</div>";
|
||||
$msg .= "<div class=\"error\">Kein Materiallager ausgewählt.</div>";
|
||||
}
|
||||
|
||||
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
|
||||
@ -1054,10 +1058,13 @@ class Produktion {
|
||||
$this->app->YUI->AutoComplete("auftragid", "auftrag", 1);
|
||||
|
||||
$this->app->YUI->AutoComplete("artikel_planen", "stuecklistenartikel");
|
||||
$this->app->YUI->AutoComplete("artikel_hinzu", "artikelnummer");
|
||||
|
||||
$this->app->YUI->AutoComplete("standardlager", "lagerplatz");
|
||||
$this->app->YUI->AutoComplete("ziellager", "lagerplatz");
|
||||
|
||||
$this->app->YUI->AutoComplete("artikel", "artikelnummer");
|
||||
|
||||
$this->app->Tpl->Set('STANDARDLAGER', $this->app->erp->ReplaceLagerPlatz(false,$produktion_from_db['standardlager'],false)); // Convert ID to form display
|
||||
|
||||
$this->app->YUI->DatePicker("datum");
|
||||
@ -1172,6 +1179,8 @@ class Produktion {
|
||||
break;
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('PRODUKTION_ID',$id);
|
||||
|
||||
$this->app->Tpl->Set('MESSAGE', $msg);
|
||||
$this->produktion_minidetail('MINIDETAILINEDIT');
|
||||
$this->app->Tpl->Parse('PAGE', "produktion_edit.tpl");
|
||||
@ -1267,7 +1276,7 @@ class Produktion {
|
||||
|
||||
$menge_moeglich = PHP_INT_MAX;
|
||||
|
||||
$sql = "SELECT id, artikel, SUM(menge) as menge, geliefert_menge FROM produktion_position pp WHERE produktion=$produktion_id AND stuecklistestufe=0 GROUP BY artikel";
|
||||
$sql = "SELECT pp.id, artikel, SUM(menge) as menge, geliefert_menge FROM produktion_position pp INNER JOIN artikel a ON pp.artikel = a.id WHERE pp.produktion=$produktion_id AND pp.stuecklistestufe=0 AND a.lagerartikel != 0 GROUP BY artikel";
|
||||
$materialbedarf_gesamt = $this->app->DB->SelectArr($sql);
|
||||
|
||||
$sql = "SELECT id, artikel, SUM(menge) as menge, geliefert_menge as geliefert_menge FROM produktion_position pp WHERE produktion=$produktion_id AND stuecklistestufe=1 GROUP BY artikel";
|
||||
|
@ -86,7 +86,6 @@ class Produktion_position {
|
||||
}
|
||||
|
||||
if ($go_to_production) {
|
||||
|
||||
if ($pid == 0) {
|
||||
$id = (int) $this->app->Secure->GetGET('id');
|
||||
$sql = "SELECT p.status, p.id from produktion p INNER JOIN produktion_position pp ON pp.produktion = p.id WHERE pp.id = $id";
|
||||
@ -138,17 +137,27 @@ class Produktion_position {
|
||||
if (empty($id)) {
|
||||
// New item
|
||||
$id = 'NULL';
|
||||
}
|
||||
$produktion_id = $this->app->Secure->GetGET('produktion');
|
||||
$sql = "SELECT p.status from produktion p WHERE p.id = $produktion_id";
|
||||
$result = $this->app->DB->SelectArr($sql)[0];
|
||||
$status = $result['status'];
|
||||
} else {
|
||||
$sql = "SELECT p.status, p.id from produktion p INNER JOIN produktion_position pp ON pp.produktion = p.id WHERE pp.id = $id";
|
||||
$result = $this->app->DB->SelectArr($sql)[0];
|
||||
$status = $result['status'];
|
||||
$produktion_id = $result['id'];
|
||||
}
|
||||
|
||||
$sql = "SELECT p.status, p.id from produktion p INNER JOIN produktion_position pp ON pp.produktion = p.id WHERE pp.id = $id";
|
||||
$result = $this->app->DB->SelectArr($sql)[0];
|
||||
$status = $result['status'];
|
||||
$produktion_id = $result['id'];
|
||||
$input['produktion'] = $produktion_id;
|
||||
|
||||
$sql = "SELECT FORMAT(menge,0) as menge FROM produktion_position WHERE produktion = $produktion_id AND stuecklistestufe = 1";
|
||||
$result = $this->app->DB->SelectArr($sql)[0];
|
||||
$planmenge = $result['menge'];
|
||||
|
||||
if ($planmenge == 0) {
|
||||
$this->produktion_position_edit_end("Keine Planung vorhanden.",true, true, $produktion_id);
|
||||
}
|
||||
|
||||
if ($submit != '')
|
||||
{
|
||||
|
||||
@ -168,7 +177,7 @@ class Produktion_position {
|
||||
|
||||
// Only allow quantities that are a multiple of the target quantity
|
||||
if ($input['menge'] % $planmenge != 0) {
|
||||
$this->produktion_position_edit_end("Positionsmenge muss Vielfaches von $planmenge sein.",true, true);
|
||||
$this->produktion_position_edit_end("Positionsmenge muss Vielfaches von $planmenge sein.",true, true, $produktion_id);
|
||||
}
|
||||
|
||||
$columns = "id, ";
|
||||
@ -200,7 +209,7 @@ class Produktion_position {
|
||||
} else {
|
||||
$msg = "Die Einstellungen wurden erfolgreich übernommen.";
|
||||
}
|
||||
$this->produktion_position_edit_end($msg,false,true);
|
||||
$this->produktion_position_edit_end($msg,false,true,$produktion_id);
|
||||
|
||||
}
|
||||
|
||||
@ -222,8 +231,8 @@ class Produktion_position {
|
||||
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
||||
*/
|
||||
|
||||
//$this->app->YUI->AutoComplete("artikel", "artikelnummer");
|
||||
$this->app->YUI->AutoComplete("artikel", "lagerartikelnummer");
|
||||
$this->app->YUI->AutoComplete("artikel", "artikelnummer");
|
||||
//$this->app->YUI->AutoComplete("artikel", "lagerartikelnummer");
|
||||
$this->app->Tpl->Set('ARTIKEL',$this->app->erp->ReplaceArtikel(false, $result[0]['artikel'], false)); // Convert from form to db
|
||||
|
||||
$this->app->Tpl->Set('PRODUKTIONID',$result[0]['produktion']);
|
||||
|
@ -351,7 +351,7 @@ class Ticket {
|
||||
$this->app->Tpl->Set("NACHRICHT_RECIPIENTS",htmlentities($message['quelle']));
|
||||
}
|
||||
$this->app->Tpl->Set("NACHRICHT_CC_RECIPIENTS",htmlentities($message['mail_cc_recipients']));
|
||||
$this->app->Tpl->Set("NACHRICHT_BETREFF",'<a href="index.php?module=ticket&action=text&mid='.$message['id'].'" target="_blank">'.htmlentities($message['betreff']).'</a>');
|
||||
$this->app->Tpl->Set("NACHRICHT_BETREFF",'<a href="index.php?module=ticket&action=text&mid='.$message['id'].'&insecure=1" target="_blank">'.htmlentities($message['betreff']).'</a>');
|
||||
$this->app->Tpl->Set("NACHRICHT_FLOAT","left");
|
||||
$this->app->Tpl->Set("META_FLOAT","right");
|
||||
$this->app->Tpl->Set("NACHRICHT_ZEIT",$message['zeit']);
|
||||
@ -368,9 +368,21 @@ class Ticket {
|
||||
}
|
||||
}
|
||||
|
||||
function ticket_text() {
|
||||
|
||||
$secure_html_tags = array(
|
||||
'<br>',
|
||||
'<p>',
|
||||
'<strong>',
|
||||
'<b>',
|
||||
'<table>',
|
||||
'<tr>',
|
||||
'<td>',
|
||||
'<style>'
|
||||
);
|
||||
|
||||
function ticket_text() {
|
||||
$mid = $this->app->Secure->GetGET('mid');
|
||||
$insecure = $this->app->Secure->GetGET('insecure');
|
||||
|
||||
if (empty($mid)) {
|
||||
return;
|
||||
@ -381,7 +393,18 @@ class Ticket {
|
||||
if (empty($messages)) {
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set("TEXT",$messages[0]['text']);
|
||||
if ($insecure) {
|
||||
$this->app->Tpl->Set("TEXT",$messages[0]['text']);
|
||||
} else {
|
||||
|
||||
$secure_text = strip_tags($messages[0]['text'],$secure_html_tags);
|
||||
|
||||
if (strlen($secure_text) != strlen($messages[0]['text'])) {
|
||||
// $secure_text = "<p style=\"all: initial;border-bottom-color:black;border-bottom-style:solid;border-bottom-width:1px;display:block;font-size:small;\">Einige Elemente wurden durch OpenXE blockiert.</p>".$secure_text;
|
||||
$secure_text = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/icon-invisible.svg\" alt=\"Einige Elemente wurden durch OpenXE blockiert.\" title=\"Einige Elemente wurden durch OpenXE blockiert.\" border=\"0\" style=\"all: initial;display:block;float:right;font-size:small;\">".$secure_text;
|
||||
}
|
||||
$this->app->Tpl->Set("TEXT",$secure_text);
|
||||
}
|
||||
$this->app->Tpl->Output('ticket_text.tpl');
|
||||
$this->app->ExitXentral();
|
||||
}
|
||||
@ -694,9 +717,11 @@ class Ticket {
|
||||
$anschreiben = $this->app->DB->Select("SELECT anschreiben FROM adresse WHERE id='".$ticket_from_db['adresse']."' LIMIT 1");
|
||||
if($anschreiben=="")
|
||||
{
|
||||
$anschreiben = $this->app->erp->Beschriftung("dokument_anschreiben").",\n".$this->app->erp->Grussformel($projekt,$sprache);
|
||||
$anschreiben = $this->app->erp->Beschriftung("dokument_anschreiben");
|
||||
}
|
||||
|
||||
$anschreiben = $anschreiben.",<br>".$this->app->erp->Grussformel($projekt,$sprache);
|
||||
|
||||
$sql = "INSERT INTO `ticket_nachricht` (
|
||||
`ticket`, `zeit`, `text`, `betreff`, `medium`, `versendet`,
|
||||
`verfasser`, `mail`,`status`, `verfasser_replyto`, `mail_replyto`,`mail_cc`
|
||||
@ -724,7 +749,7 @@ class Ticket {
|
||||
$citation_info =$recv_messages[0]['zeit']." ".$recv_messages[0]['verfasser']." <".$recv_messages[0]['mail'].">";
|
||||
$text = $drafted_messages[0]['text'].$nl.$nl.$citation_info.":".$nl."<blockquote type=\"cite\">".$recv_messages[0]['text']."</blockquote>";
|
||||
|
||||
$sql = "UPDATE ticket_nachricht SET text='".$text."' WHERE id=".$drafted_messages[0]['id'];
|
||||
$sql = "UPDATE ticket_nachricht SET text='".$this->app->DB->real_escape_string($text)."' WHERE id=".$drafted_messages[0]['id'];
|
||||
$this->app->DB->Update($sql);
|
||||
header("Location: index.php?module=ticket&action=edit&id=$id");
|
||||
$this->app->ExitXentral();
|
||||
|
238
www/pages/uebersetzung.php
Normal file
238
www/pages/uebersetzung.php
Normal file
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 OpenXE project
|
||||
*/
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
|
||||
class Uebersetzung {
|
||||
|
||||
function __construct($app, $intern = false) {
|
||||
$this->app = $app;
|
||||
if ($intern)
|
||||
return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
$this->app->ActionHandler("list", "uebersetzung_list");
|
||||
$this->app->ActionHandler("create", "uebersetzung_edit"); // This automatically adds a "New" button
|
||||
$this->app->ActionHandler("edit", "uebersetzung_edit");
|
||||
$this->app->ActionHandler("delete", "uebersetzung_delete");
|
||||
$this->app->DefaultActionHandler("list");
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
public function Install() {
|
||||
/* Fill out manually later */
|
||||
}
|
||||
|
||||
public function TableSearch(&$app, $name, $erlaubtevars) {
|
||||
switch ($name) {
|
||||
case "uebersetzung_list":
|
||||
$allowed['uebersetzung_list'] = array('list');
|
||||
|
||||
// Transfer a parameter from form -> see below for setting of parameter
|
||||
// $parameter = $this->app->User->GetParameter('parameter');
|
||||
|
||||
$heading = array('','Label', 'Sprache','Übersetzung', 'Original', 'Menü');
|
||||
$width = array('1%','5%','5%','20%','20%','1%'); // Fill out manually later
|
||||
|
||||
// columns that are aligned right (numbers etc)
|
||||
// $alignright = array(4,5,6,7,8);
|
||||
|
||||
$findcols = array('id','u.label', 'u.sprache', 'u.beschriftung', 'u.original');
|
||||
$searchsql = array('u.label', 'u.beschriftung', 'u.sprache', 'u.original');
|
||||
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
|
||||
// Some options for the columns:
|
||||
// $numbercols = array(1,2);
|
||||
// $sumcol = array(1,2);
|
||||
// $alignright = array(1,2);
|
||||
|
||||
$dropnbox = "CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',u.id,'\" />') AS `auswahl`";
|
||||
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=uebersetzung&action=edit&id=%value%\"><img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=uebersetzung&action=delete&id=%value%\");>" . "<img src=\"themes/{$this->app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||
u.id,
|
||||
$dropnbox,
|
||||
u.label,
|
||||
u.sprache,
|
||||
if( CHAR_LENGTH(u.beschriftung) > 100,
|
||||
CONCAT('<span style=\"word-wrap:anywhere;\">',u.beschriftung,'</span>'),
|
||||
u.beschriftung)
|
||||
as beschriftung,
|
||||
if( CHAR_LENGTH(u.original) > 100,
|
||||
CONCAT('<span style=\"word-wrap:anywhere;\">',u.original,'</span>'),
|
||||
u.original)
|
||||
as original,
|
||||
u.id FROM uebersetzung u";
|
||||
|
||||
$where = "1";
|
||||
$count = "SELECT count(DISTINCT id) FROM uebersetzung WHERE $where";
|
||||
// $groupby = "";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$erg = false;
|
||||
|
||||
foreach ($erlaubtevars as $k => $v) {
|
||||
if (isset($$v)) {
|
||||
$erg[$v] = $$v;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
|
||||
function uebersetzung_list() {
|
||||
|
||||
// For transfer of form parameter to tablesearch
|
||||
// $parameter = $this->app->Secure->GetPOST('parameter');
|
||||
// $this->app->User->SetParameter('parameter', $parameter);
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=uebersetzung&action=list", "Übersicht");
|
||||
$this->app->erp->MenuEintrag("index.php?module=uebersetzung&action=create", "Neu anlegen");
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php", "Zurück");
|
||||
|
||||
$this->app->YUI->TableSearch('TAB1', 'uebersetzung_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
$this->app->Tpl->Parse('PAGE', "uebersetzung_list.tpl");
|
||||
}
|
||||
|
||||
public function uebersetzung_delete() {
|
||||
$id = (int) $this->app->Secure->GetGET('id');
|
||||
|
||||
$this->app->DB->Delete("DELETE FROM `uebersetzung` WHERE `id` = '{$id}'");
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gelöscht.</div>");
|
||||
|
||||
$this->uebersetzung_list();
|
||||
}
|
||||
|
||||
/*
|
||||
* Edit uebersetzung item
|
||||
* If id is empty, create a new one
|
||||
*/
|
||||
|
||||
function uebersetzung_edit() {
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
|
||||
// Check if other users are editing this id
|
||||
if($this->app->erp->DisableModul('artikel',$id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('ID', $id);
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=uebersetzung&action=edit&id=$id", "Details");
|
||||
$this->app->erp->MenuEintrag("index.php?module=uebersetzung&action=list", "Zurück zur Übersicht");
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$input = $this->GetInput();
|
||||
$submit = $this->app->Secure->GetPOST('submit');
|
||||
|
||||
if (empty($id)) {
|
||||
// New item
|
||||
$id = 'NULL';
|
||||
}
|
||||
|
||||
if ($submit != '')
|
||||
{
|
||||
|
||||
// Write to database
|
||||
|
||||
// Add checks here
|
||||
|
||||
$columns = "id, ";
|
||||
$values = "$id, ";
|
||||
$update = "";
|
||||
|
||||
$fix = "";
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
$columns = $columns.$fix.$key;
|
||||
$values = $values.$fix."'".$value."'";
|
||||
$update = $update.$fix.$key." = '$value'";
|
||||
|
||||
$fix = ", ";
|
||||
}
|
||||
|
||||
// echo($columns."<br>");
|
||||
// echo($values."<br>");
|
||||
// echo($update."<br>");
|
||||
|
||||
$sql = "INSERT INTO uebersetzung (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
|
||||
|
||||
// echo($sql);
|
||||
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
if ($id == 'NULL') {
|
||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
||||
header("Location: index.php?module=uebersetzung&action=list&msg=$msg");
|
||||
} else {
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load values again from database
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',u.id,'\" />') AS `auswahl`";
|
||||
$result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS u.id, $dropnbox, u.label, u.beschriftung, u.sprache, u.original, u.id FROM uebersetzung u"." WHERE id=$id");
|
||||
|
||||
foreach ($result[0] as $key => $value) {
|
||||
$this->app->Tpl->Set(strtoupper($key), $value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add displayed items later
|
||||
*
|
||||
|
||||
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
|
||||
$this->app->Tpl->Add('EMAIL', $email);
|
||||
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
||||
|
||||
*/
|
||||
|
||||
$sprachen = $this->app->erp->GetSprachenSelect();
|
||||
|
||||
foreach ($sprachen as $key => $value) {
|
||||
$this->app->Tpl->Add('SPRACHENSELECT', "<option value='".$key."'>".$value."</option>");
|
||||
}
|
||||
|
||||
// $this->SetInput($input);
|
||||
$this->app->Tpl->Parse('PAGE', "uebersetzung_edit.tpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all paramters from html form and save into $input
|
||||
*/
|
||||
public function GetInput(): array {
|
||||
$input = array();
|
||||
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
|
||||
|
||||
$input['label'] = $this->app->Secure->GetPOST('label');
|
||||
$input['beschriftung'] = $this->app->Secure->GetPOST('beschriftung');
|
||||
$input['sprache'] = $this->app->Secure->GetPOST('sprache');
|
||||
$input['original'] = $this->app->Secure->GetPOST('original');
|
||||
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set all fields in the page corresponding to $input
|
||||
*/
|
||||
function SetInput($input) {
|
||||
// $this->app->Tpl->Set('EMAIL', $input['email']);
|
||||
|
||||
$this->app->Tpl->Set('LABEL', $input['label']);
|
||||
$this->app->Tpl->Set('BESCHRIFTUNG', $input['beschriftung']);
|
||||
$this->app->Tpl->Set('SPRACHE', $input['sprache']);
|
||||
$this->app->Tpl->Set('ORIGINAL', $input['original']);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -3710,10 +3710,10 @@ span.red, b.red {
|
||||
}
|
||||
|
||||
.dataTables_wrapper .dataTables_processing {
|
||||
background: url('../images/loading.gif') no-repeat;
|
||||
background-position: 50% 0;
|
||||
background-size: 150px;
|
||||
padding-top: 90px;
|
||||
background: url('../images/loading.gif') no-repeat !important;
|
||||
background-position: 50% 0 !important;
|
||||
background-size: 150px !important;
|
||||
padding-top: 90px !important;
|
||||
}
|
||||
|
||||
a.ui-tabs-anchor:hover {
|
||||
|
Loading…
Reference in New Issue
Block a user