versandpakete improvements

This commit is contained in:
OpenXE 2023-10-20 15:47:37 +02:00
parent e899b1c389
commit a35ab21f7c
5 changed files with 361 additions and 177 deletions

View File

@ -3650,8 +3650,8 @@ class YUI {
$paketmarke = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/portogo.png\" style=\"margin-right:1px\" title=\"Paketmarke\" border=\"0\">"; $paketmarke = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/portogo.png\" style=\"margin-right:1px\" title=\"Paketmarke\" border=\"0\">";
$paketmarke_keine = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/portostop.png\" style=\"margin-right:1px\" title=\"Keine Paketmarke\" border=\"0\">"; $paketmarke_keine = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/portostop.png\" style=\"margin-right:1px\" title=\"Keine Paketmarke\" border=\"0\">";
$ausgeliefert = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/grey.png\" style=\"margin-right:1px\" title=\"Ausgeliefert\" border=\"0\">"; $ausgeliefert = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/delivery_ok.png\" style=\"margin-right:1px\" title=\"Ausgeliefert\" border=\"0\">";
$ausgeliefert_nicht = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/nicht_eingelagert.png\" style=\"margin-right:1px\" title=\"Nicht ausgeliefert\" border=\"0\">"; $ausgeliefert_nicht = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/delivery.png\" style=\"margin-right:1px\" title=\"Nicht ausgeliefert\" border=\"0\">";
$storno = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/storno.png\" style=\"margin-right:1px\" title=\"Storniert\" border=\"0\">"; $storno = "<img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/storno.png\" style=\"margin-right:1px\" title=\"Storniert\" border=\"0\">";
@ -3662,12 +3662,12 @@ class YUI {
return "CONCAT('<table><tr><td nowrap>', return "CONCAT('<table><tr><td nowrap>',
CASE CASE
WHEN v.status = 'abgeschlossen' THEN '$abgeschlossen' WHEN status = 'storniert' THEN '$storniert'
WHEN v.status = 'storniert' THEN '$storniert'
ELSE CONCAT( ELSE CONCAT(
CASE CASE
WHEN lieferschein_ohne_pos <> '' THEN '$lieferschein_ohne_pos' WHEN lieferschein_ohne_pos <> '' THEN '$lieferschein_ohne_pos'
WHEN lieferschein <> '' THEN '$lieferschein_voll' WHEN lieferscheine <> '' AND vmenge = lmenge THEN '$lieferschein_voll'
WHEN lieferscheine <> '' THEN '$lieferschein_teil'
ELSE ELSE
'$lieferschein_kein' '$lieferschein_kein'
END, END,
@ -3677,11 +3677,16 @@ class YUI {
'$paketmarke_keine' '$paketmarke_keine'
END, END,
CASE CASE
WHEN v.status = 'versendet' THEN '$versendet' WHEN status = 'versendet' THEN '$versendet'
WHEN status = 'abgeschlossen' THEN '$versendet'
ELSE ELSE
'$versendet_nicht' '$versendet_nicht'
END, END,
'$ausgeliefert_nicht' CASE
WHEN status = 'abgeschlossen' THEN '$ausgeliefert'
ELSE
'$ausgeliefert_nicht'
END
) )
END, END,
'</td></tr></table>')"; '</td></tr></table>')";

View File

@ -112967,9 +112967,9 @@
"Field": "lieferschein_ohne_pos", "Field": "lieferschein_ohne_pos",
"Type": "int(11)", "Type": "int(11)",
"Collation": null, "Collation": null,
"Null": "NO", "Null": "YES",
"Key": "", "Key": "",
"Default": "0", "Default": null,
"Extra": "", "Extra": "",
"Privileges": "select,insert,update,references", "Privileges": "select,insert,update,references",
"Comment": "" "Comment": ""

View File

@ -370,7 +370,7 @@ abstract class Versanddienstleister
return true; return true;
} }
public function Paketmarke(string $target, string $docType, int $docId): void public function Paketmarke(string $target, string $docType, int $docId, $versandpaket = null): void
{ {
$address = $this->GetAdressdaten($docId, $docType); $address = $this->GetAdressdaten($docId, $docType);
if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) { if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) {
@ -379,59 +379,65 @@ abstract class Versanddienstleister
if ($json->submit == 'print') { if ($json->submit == 'print') {
$result = $this->CreateShipment($json, $address); $result = $this->CreateShipment($json, $address);
if ($result->Success) { if ($result->Success) {
/* $sql = "INSERT INTO versand if (empty($versandpaket)) {
( $sql = "INSERT INTO versandpakete
adresse, (
lieferschein, lieferschein_ohne_pos,
versandunternehmen, gewicht,
gewicht, tracking,
tracking, tracking_link,
tracking_link, status,
anzahlpakete versandart,
) versender
VALUES )
( VALUES
{$address['addressId']}, (
{$address['lieferscheinId']}, {$address['lieferscheinId']},
'$this->type', '$json->weight',
'$json->weight', '$result->TrackingNumber',
'$result->TrackingNumber', '$result->TrackingUrl',
'$result->TrackingUrl', 'neu',
1 '$this->type',
)";*/ '".$this->app->User->GetName()."'
$sql = "INSERT INTO versandpakete )";
( $this->app->DB->Insert($sql);
lieferschein_ohne_pos, $versandpaket = $this->app->DB->GetInsertID();
gewicht, }
tracking, else {
tracking_link, $sql = "UPDATE versandpakete SET
status, gewicht = '".$json->weight."',
versandart tracking = '".$result->TrackingNumber."',
) tracking_link = '".$result->TrackingUrl."'
VALUES WHERE id = '".$versandpaket."'
( ";
{$address['lieferscheinId']}, $this->app->DB->Update($sql);
'$json->weight', }
'$result->TrackingNumber',
'$result->TrackingUrl',
'versendet',
'$this->type'
)";
$this->app->DB->Insert($sql); $filename = join('_', [$this->type, 'Label', $result->TrackingNumber]) . '.pdf';
$filefullpath = $this->app->erp->GetTMP() . $filename;
file_put_contents($filefullpath, $result->Label);
$this->app->erp->CreateDateiWithStichwort(
$filename,
'Paketmarke '.$this->type.' '.$result->TrackingNumber,
'Paketmarke Versandpaket Nr. '.$versandpaket,
'',
$filefullpath,
$this->app->User->GetName(),
'paketmarke',
'versandpaket',
$versandpaket
);
$filename = $this->app->erp->GetTMP() . join('_', [$this->type, 'Label', $result->TrackingNumber]) . '.pdf'; $this->app->printer->Drucken($this->labelPrinterId, $filefullpath);
file_put_contents($filename, $result->Label);
$this->app->printer->Drucken($this->labelPrinterId, $filename);
if (isset($result->ExportDocuments)) { if (isset($result->ExportDocuments)) {
$filename = $this->app->erp->GetTMP() . join('_', [$this->type, 'ExportDoc', $result->TrackingNumber]) . '.pdf'; $filefullpath = $this->app->erp->GetTMP() . join('_', [$this->type, 'ExportDoc', $result->TrackingNumber]) . '.pdf';
file_put_contents($filename, $result->ExportDocuments); file_put_contents($filefullpath, $result->ExportDocuments);
$this->app->printer->Drucken($this->documentPrinterId, $filename); $this->app->printer->Drucken($this->documentPrinterId, $filefullpath);
} }
$ret['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; $ret['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"];
} else { } else {
$ret['messages'] = array_map(fn(string $item) => ['class' => 'error', 'text' => $item], array_unique($result->Errors)); $ret['messages'] = array_map(fn(string $item) => ['class' => 'error', 'text' => $item], array_unique($result->Errors));
} }
} }
header('Content-Type: application/json'); header('Content-Type: application/json');

View File

@ -11,7 +11,10 @@
<div class="col-xs-14 col-md-6 col-md-height"> <div class="col-xs-14 col-md-6 col-md-height">
<div class="inside inside-full-height"> <div class="inside inside-full-height">
<fieldset> <fieldset>
<legend>{|Versandpaket <b>Nr. [ID]</b> vom [DATUM] f&uuml;r Adresse '[ADRESSE]'|}</legend> <legend>
{|<b>Versandpaket Nr. [ID]</b> vom [DATUM]<span [NO_ADDRESS_HIDDEN]> f&uuml;r Adresse '[ADRESSE]'|}</span>
</legend>
[ICONS]
<table width="100%" border="0" class="mkTableFormular"> <table width="100%" border="0" class="mkTableFormular">
<tr> <tr>
<td> <td>
@ -42,7 +45,13 @@
{|Tracking|}: {|Tracking|}:
</td> </td>
<td> <td>
<input type="text" name="" id="" value="[TRACKING]" size="40" disabled><a href="[TRACKING_LINK]"><img src="themes/new/images/forward.svg" border="0" style="top:6px; position:relative"></a> <input type="text" name="" id="" value="[TRACKING]" size="40" disabled>
<a href="[PAKETMARKE_LINK]" [PAKETMARKE_HIDDEN]>
<img src="themes/new/images/portogo.png" border="0" style="top:6px; position:relative">
</a>
<a href="[TRACKING_LINK]" [PAKETMARKE_HIDDEN]>
<img src="themes/new/images/forward.svg" border="0" style="top:6px; position:relative">
</a>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -67,33 +76,28 @@
</div> </div>
<div class="col-xs-14 col-md-6 col-md-height"> <div class="col-xs-14 col-md-6 col-md-height">
<div class="inside inside-full-height"> <div class="inside inside-full-height">
<fieldset [LIEFERSCHEIN_ADD_POS_HIDDEN]> <fieldset >
<legend>{|Artikel aus Lieferschein hinzuf&uuml;gen|}</legend>
<table width="100%" border="0" class="mkTableFormular">
<tr>
<td>
{|Lieferschein|}:
</td>
<td>
<input form="add" type="text" name="lieferschein" id="lieferschein" value="[LIEFERSCHEIN]" autofocus style="width:99%;">
</td>
</tr>
</table>
</fieldset>
<fieldset [LIEFERSCHEIN_OHNE_POS_HIDDEN]>
<legend>{|Lieferschein|}</legend> <legend>{|Lieferschein|}</legend>
<table width="100%" border="0" class="mkTableFormular"> <table width="100%" border="0" class="mkTableFormular">
<tr> <tr [LIEFERSCHEIN_OHNE_POS_HIDDEN]>
<td> <td>
{|Lieferschein|}: {|Lieferschein ohne Positionen|}:
</td> </td>
<td> <td>
<input form="add" type="text" name="" id="" value="[LIEFERSCHEIN_OHNE_POS]" size="40" disabled> <input form="add" type="text" name="" id="" value="[LIEFERSCHEIN_OHNE_POS]" size="40" disabled>
<a href="index.php?module=lieferschein&action=edit&id=[LIEFERSCHEIN_OHNE_POS_ID]"><img src="themes/new/images/forward.svg" border="0" style="top:6px; position:relative"></a> <a href="index.php?module=lieferschein&action=edit&id=[LIEFERSCHEIN_OHNE_POS_ID]"><img src="themes/new/images/forward.svg" border="0" style="top:6px; position:relative"></a>
</td> </td>
</tr> </tr>
<tr [LIEFERSCHEIN_ADD_POS_HIDDEN]>
<td>
{|Lieferschein|}:
</td>
<td>
<input form="add" type="text" name="lieferschein" id="lieferschein" value="[LIEFERSCHEIN]" autofocus size="40">
</td>
</tr>
</table> </table>
</fieldset> </fieldset>
</div> </div>
</div> </div>
<div class="col-xs-14 col-md-2 col-md-height"> <div class="col-xs-14 col-md-2 col-md-height">
@ -104,7 +108,9 @@
<tr><td><button form="save" name="submit" value="speichern" class="ui-button-icon" style="width:100%;">Speichern</button></td></tr> <tr><td><button form="save" name="submit" value="speichern" class="ui-button-icon" style="width:100%;">Speichern</button></td></tr>
<tr [LIEFERSCHEIN_ADD_POS_HIDDEN]><td><button form="add" name="submit" value="lieferschein_hinzufuegen" class="ui-button-icon" style="width:100%;">Artikel hinzuf&uuml;gen</button></td></tr> <tr [LIEFERSCHEIN_ADD_POS_HIDDEN]><td><button form="add" name="submit" value="lieferschein_hinzufuegen" class="ui-button-icon" style="width:100%;">Artikel hinzuf&uuml;gen</button></td></tr>
<tr [LIEFERSCHEIN_ADD_POS_HIDDEN]><td><button form="add" name="submit" value="lieferschein_komplett_hinzufuegen" class="ui-button-icon" style="width:100%;">Kompletten Lieferschein hinzuf&uuml;gen</button></td></tr> <tr [LIEFERSCHEIN_ADD_POS_HIDDEN]><td><button form="add" name="submit" value="lieferschein_komplett_hinzufuegen" class="ui-button-icon" style="width:100%;">Kompletten Lieferschein hinzuf&uuml;gen</button></td></tr>
<tr [PAKETMARKE_HIDDEN]><td><button form="paketmarke" name="submit" value="paketmarke" class="ui-button-icon" style="width:100%;">Parketmarke drucken und absenden</button></td></tr> <tr [PAKETMARKE_ADD_HIDDEN]><td><button form="paketmarke" name="submit" value="paketmarke" class="ui-button-icon" style="width:100%;">Paketmarke drucken</button></td></tr>
<tr [ABSENDEN_HIDDEN]><td><button name="submit" value="absenden" class="ui-button-icon" style="width:100%;">Absenden</button></td></tr>
<tr [ABSCHLIESSEN_HIDDEN]><td><button name="submit" value="abschliessen" class="ui-button-icon" style="width:100%;">Abschlie&szlig;en</button></td></tr>
</table> </table>
</fieldset> </fieldset>
</div> </div>

View File

@ -42,7 +42,9 @@ class Versandpakete {
$this->app->ActionHandler("stapelverarbeitung", "versandpakete_stapelverarbeitung"); $this->app->ActionHandler("stapelverarbeitung", "versandpakete_stapelverarbeitung");
$this->app->ActionHandler("paketmarke", "versandpakete_paketmarke"); $this->app->ActionHandler("paketmarke", "versandpakete_paketmarke");
$this->app->ActionHandler("delete", "versandpakete_delete"); $this->app->ActionHandler("delete", "versandpakete_delete");
$this->app->ActionHandler("deletepos", "versandpakete_deletepos");
$this->app->ActionHandler("minidetail", "versandpakete_minidetail"); $this->app->ActionHandler("minidetail", "versandpakete_minidetail");
$this->app->ActionHandler("minidetaillieferschein", "versandpakete_minidetaillieferschein");
$this->app->DefaultActionHandler("list"); $this->app->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app); $this->app->ActionHandlerListen($app);
} }
@ -55,22 +57,22 @@ class Versandpakete {
switch ($name) { switch ($name) {
case "versandpakete_list": case "versandpakete_list":
$allowed['versandpakete_list'] = array('list'); $allowed['versandpakete_list'] = array('list');
$heading = array('','', 'Paket-Nr.','Datum','Adresse', 'Lieferschein', 'Versandart', 'Tracking', 'Gewicht','Versender', 'Bemerkung', 'Status', 'Monitor', 'Men&uuml;'); $heading = array('', '', 'Paket-Nr.','Datum','Adresse', 'Lieferschein', 'Versandart', 'Tracking', 'Menge auf Lieferscheinen', 'Menge', 'Gewicht','Versender', 'Bemerkung', 'Status', 'Monitor', 'Men&uuml;');
$width = array('1%','1%','1%'); // Fill out manually later $width = array( '1%','1%','1%', '1%', '10%', '1%', '2%', '2%', '1%', '1%', '1%', '2%', '10%', '1%', '1%', '1%');
// columns that are aligned right (numbers etc) // columns that are aligned right (numbers etc)
// $alignright = array(4,5,6,7,8); // $alignright = array(4,5,6,7,8);
$findcols = array('v.id','v.id','v.id','a.name','l.belegnr','v.tracking', 'v.versender', 'v.gewicht', 'v.bemerkung', 'v.status'); $findcols = array('id','id','id','datum');
$searchsql = array('v.versand', 'v.nr', 'v.tracking', 'v.versender', 'v.gewicht', 'v.bemerkung', 'v.status'); $searchsql = array('v.versand', 'v.nr', 'v.tracking', 'v.versender', 'v.gewicht', 'v.bemerkung', 'v.status');
$defaultorder = 1; $defaultorder = 1;
$defaultorderdesc = 0; $defaultorderdesc = 0;
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',v.id,'\" />') AS `auswahl`"; $dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',id,'\" />') AS `auswahl`";
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=versandpakete&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a>&nbsp;<a href=\"#\" onclick=DeleteDialog(\"index.php?module=versandpakete&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>"; $menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=versandpakete&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a>&nbsp;<a href=\"#\" onclick=DeleteDialog(\"index.php?module=versandpakete&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
$menucol = 12; $menucol = 1;
$moreinfo = true; // Allow drop down details $moreinfo = true; // Allow drop down details
$lieferschein_link = array( $lieferschein_link = array(
@ -81,6 +83,14 @@ class Versandpakete {
'</a>' '</a>'
); );
$lieferschein_ohne_pos_link = array(
'<a href="index.php?module=lieferschein&action=edit&id=',
['sql' => 'lop.id'],
'">',
['sql' => 'lop.belegnr'],
'</a>'
);
$tracking_link = array( $tracking_link = array(
'<a href="', '<a href="',
['sql' => 'v.tracking_link'], ['sql' => 'v.tracking_link'],
@ -89,33 +99,61 @@ class Versandpakete {
'</a>' '</a>'
); );
$sql = "SELECT SQL_CALC_FOUND_ROWS $sql = "SELECT SQL_CALC_FOUND_ROWS
v.id, id,
$dropnbox, $dropnbox,
v.id, id,
".$app->erp->FormatDateTimeShort('v.datum').", datum,
a.name, if (lieferscheine IS NULL,alop_name,name),
GROUP_CONCAT(DISTINCT ".$app->erp->ConcatSQL($lieferschein_link)." SEPARATOR ', ') as lieferschein, if (lieferscheine IS NULL, lieferscheine_ohne_pos, lieferscheine),
".$app->erp->FormatUCfirst('v.versandart')." as versandart, versandart,
".$app->erp->ConcatSQL($tracking_link)." as tracking_link, tracking_link,
v.gewicht, lmenge,
v.versender, vmenge,
v.bemerkung, gewicht,
v.status, versender,
".$app->YUI->IconsSQL_versandpaket().", bemerkung,
v.id status,
FROM ".$app->YUI->IconsSQL_versandpaket().",
versandpakete v id
LEFT JOIN FROM
(".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") vl ON v.id = vl.versandpaket (
LEFT JOIN SELECT
lieferschein l on vl.lieferschein = l.id v.id,
LEFT JOIN ".$app->erp->FormatDateTimeShort('v.datum')." AS datum,
adresse a on a.id = l.adresse a.name,
alop.name alop_name,
GROUP_CONCAT(DISTINCT ".$app->erp->ConcatSQL($lieferschein_link)." SEPARATOR ', ') as lieferscheine,
v.lieferschein_ohne_pos,
GROUP_CONCAT(DISTINCT ".$app->erp->ConcatSQL($lieferschein_ohne_pos_link)." SEPARATOR ', ') as lieferscheine_ohne_pos,
".$app->erp->FormatUCfirst('v.versandart')." as versandart,
".$app->erp->ConcatSQL($tracking_link)." as tracking_link,
tracking,
".$app->erp->FormatMenge('SUM(lp.menge)')." as lmenge,
".$app->erp->FormatMenge('SUM(vlp.menge)')." AS vmenge,
v.gewicht,
v.versender,
v.bemerkung,
v.status
FROM
versandpakete v
LEFT JOIN
versandpaket_lieferschein_position vlp ON vlp.versandpaket = v.id
LEFT JOIN
lieferschein_position lp ON vlp.lieferschein_position = lp.id
LEFT JOIN
lieferschein l ON lp.lieferschein = l.id
LEFT JOIN
adresse a ON a.id = l.adresse
LEFT JOIN
lieferschein lop ON v.lieferschein_ohne_pos = lop.id
LEFT JOIN
adresse alop ON lop.adresse = alop.id
GROUP BY v.id
) temp
"; ";
$where = "v.status IN ('neu', 'versendet')"; $where = "status IN ('neu', 'versendet')";
// Toggle filters // Toggle filters
$app->Tpl->Add('JQUERYREADY', "$('#geschlossene').click( function() { fnFilterColumn1( 0 ); } );"); $app->Tpl->Add('JQUERYREADY', "$('#geschlossene').click( function() { fnFilterColumn1( 0 ); } );");
$app->Tpl->Add('JQUERYREADY', "$('#stornierte').click( function() { fnFilterColumn2( 0 ); } );"); $app->Tpl->Add('JQUERYREADY', "$('#stornierte').click( function() { fnFilterColumn2( 0 ); } );");
@ -141,28 +179,28 @@ class Versandpakete {
$more_data1 = $app->Secure->GetGET("more_data1"); $more_data1 = $app->Secure->GetGET("more_data1");
if ($more_data1 == 1) { if ($more_data1 == 1) {
$where .= " OR v.status IN ('abgeschlossen')"; $where .= " OR status IN ('abgeschlossen')";
} else { } else {
} }
$more_data2 = $app->Secure->GetGET("more_data2"); $more_data2 = $app->Secure->GetGET("more_data2");
if ($more_data2 == 1) { if ($more_data2 == 1) {
$where .= " OR v.status IN ('storniert')"; $where .= " OR status IN ('storniert')";
} }
else { else {
} }
// END Toggle filters // END Toggle filters
// $count = "SELECT count(DISTINCT id) FROM versandpakete v WHERE $where"; $count = "SELECT count(DISTINCT id) FROM versandpakete v";
$groupby = "GROUP BY v.id";
$groupby = "";
break; break;
case "versandpakete_lieferscheine": case "versandpakete_lieferscheine":
$allowed['versandpakete_lieferscheine'] = array('lieferscheine'); $allowed['versandpakete_lieferscheine'] = array('lieferscheine');
$heading = array( 'Lieferschein', 'Adresse','Menge','Menge in Versandpaketen','Paket-Nr.', 'Paket erstellen'); $heading = array('','', 'Lieferschein', 'Adresse','Menge','Menge in Versandpaketen', 'Paket erstellen');
$width = array( '10%', '10%', '10%', '10%' ,'10%', '1%'); // Fill out manually later $width = array('1%','1%', '10%', '10%', '10%', '10%' ,'10%', '1%'); // Fill out manually later
// columns that are aligned right (numbers etc) // columns that are aligned right (numbers etc)
// $alignright = array(4,5,6,7,8); // $alignright = array(4,5,6,7,8);
@ -172,26 +210,22 @@ class Versandpakete {
$defaultorder = 1; $defaultorder = 1;
$defaultorderdesc = 0; $defaultorderdesc = 0;
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',id,'\" />') AS `auswahl`";
$menucol = 1;
$moreinfoaction = "lieferschein";
$moreinfo = true; // Allow drop down details
$menu = "<a href=\"index.php?module=versandpakete&action=add&lieferschein=%value%\"><img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/forward.svg\" border=\"0\"></a>"; $menu = "<a href=\"index.php?module=versandpakete&action=add&lieferschein=%value%\"><img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/forward.svg\" border=\"0\"></a>";
$menucol = 5;
$paket_link = array(
'<a href="index.php?module=versandpakete&action=edit&id=',
['sql' => 'versandpaket'],
'">',
['sql' => 'versandpaket'],
'</a>'
);
$sql = " $sql = "
SELECT SELECT SQL_CALC_FOUND_ROWS
id, id,
".$dropnbox.",
CONCAT('<a href=\"index.php?module=lieferschein&action=edit&id=',id,'\">',belegnr,'</a>'), CONCAT('<a href=\"index.php?module=lieferschein&action=edit&id=',id,'\">',belegnr,'</a>'),
name, name,
".$app->erp->FormatMenge("SUM(lmenge)")." as lmenge, ".$app->erp->FormatMenge("SUM(lmenge)")." as lmenge,
".$app->erp->FormatMenge("SUM(vmenge)")." as vmenge, ".$app->erp->FormatMenge("SUM(vmenge)")." as vmenge,
pakete,
id id
FROM FROM
( (
@ -200,15 +234,14 @@ class Versandpakete {
l.belegnr, l.belegnr,
l.name, l.name,
lp.menge lmenge, lp.menge lmenge,
SUM(vlp.menge) vmenge, SUM(vlp.menge) vmenge
GROUP_CONCAT(".$app->erp->ConcatSQL($paket_link)." SEPARATOR ', ') as pakete
FROM FROM
lieferschein l lieferschein l
INNER JOIN lieferschein_position lp ON lp.lieferschein = l.id INNER JOIN lieferschein_position lp ON lp.lieferschein = l.id
LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.lieferschein_position = lp.id LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.lieferschein_position = lp.id
LEFT JOIN versandpakete v ON vlp.versandpaket = v.id LEFT JOIN versandpakete v ON vlp.versandpaket = v.id
WHERE WHERE
l.belegnr <> '' AND l.versendet <> 1 AND (v.status IS NULL OR v.status != 'storniert') l.belegnr <> '' AND l.versendet <> 1 AND (v.status IS NULL OR (v.status != 'storniert' AND v.status <> 'abgeschlossen'))
GROUP BY lp.id GROUP BY lp.id
) l_mengen ) l_mengen
"; ";
@ -223,7 +256,7 @@ class Versandpakete {
$id = (int) $app->Secure->GetGET('id'); $id = (int) $app->Secure->GetGET('id');
$allowed['versandpakete_paketinhalt_list'] = array('list'); $allowed['versandpakete_paketinhalt_list'] = array('list');
$heading = array('Lieferschein','Pos', 'Artikel', 'Artikel-Nr.','Menge Lieferschein', 'Menge Paket', 'Men&uuml;'); $heading = array('Lieferschein','Pos', 'Artikel', 'Artikel-Nr.','Menge Lieferschein', 'Menge Paket', 'Men&uuml;','');
$width = array('10%','10%','10%'); // Fill out manually later $width = array('10%','10%','10%'); // Fill out manually later
// columns that are aligned right (numbers etc) // columns that are aligned right (numbers etc)
@ -235,7 +268,16 @@ class Versandpakete {
$defaultorder = 1; $defaultorder = 1;
$defaultorderdesc = 0; $defaultorderdesc = 0;
$menu = "<a href=\"index.php?module=versandpakete&action=deletepos&pos=%value%\"><img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>"; $paket_link = array(
'<a href="index.php?module=versandpakete&action=edit&id=',
['sql' => 'vlp.versandpaket'],
'">',
['sql' => 'vlp.versandpaket'],
'</a>'
);
// $menu = "<a href=\"index.php?module=versandpakete&action=deletepos&pos=%value%\"><img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>";
$menu = "";
$menucol = 6; $menucol = 6;
$lieferschein_link = array( $lieferschein_link = array(
@ -246,6 +288,16 @@ class Versandpakete {
'</a>' '</a>'
); );
$delete_link = array(
'<a href="index.php?module=versandpakete&action=deletepos&id=',
['sql' => 'v.id'],
'&pos=',
['sql' => 'vlp.id'],
'">',
"<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">",
'</a>'
);
$sql = "SELECT SQL_CALC_FOUND_ROWS $sql = "SELECT SQL_CALC_FOUND_ROWS
lp.id, lp.id,
".$app->erp->ConcatSQL($lieferschein_link)." as lieferschein, ".$app->erp->ConcatSQL($lieferschein_link)." as lieferschein,
@ -254,6 +306,7 @@ class Versandpakete {
a.nummer, a.nummer,
".$app->erp->FormatMenge('lp.menge')." as l_menge, ".$app->erp->FormatMenge('lp.menge')." as l_menge,
".$app->erp->FormatMenge('SUM(vlp.menge)')." as v_menge, ".$app->erp->FormatMenge('SUM(vlp.menge)')." as v_menge,
".$app->erp->ConcatSQL($delete_link)." as delete_link,
vlp.id vlp.id
FROM FROM
versandpakete v versandpakete v
@ -306,7 +359,7 @@ class Versandpakete {
a.nummer, a.nummer,
".$app->erp->FormatMenge('lp.menge')." as l_menge, ".$app->erp->FormatMenge('lp.menge')." as l_menge,
".$app->erp->FormatMenge('SUM(vlp.menge)')." as v_menge, ".$app->erp->FormatMenge('SUM(vlp.menge)')." as v_menge,
".$app->erp->ConcatSQL($paket_link).", GROUP_CONCAT(".$app->erp->ConcatSQL($paket_link)." SEPARATOR ', ') as pakete,
vlp.id vlp.id
FROM lieferschein l FROM lieferschein l
INNER JOIN lieferschein_position lp ON INNER JOIN lieferschein_position lp ON
@ -337,7 +390,6 @@ class Versandpakete {
$this->app->erp->MenuEintrag("index.php?module=versandpakete&action=list", "&Uuml;bersicht"); $this->app->erp->MenuEintrag("index.php?module=versandpakete&action=list", "&Uuml;bersicht");
$this->app->erp->MenuEintrag("index.php?module=versandpakete&action=lieferscheine", "Offene Lieferscheine"); $this->app->erp->MenuEintrag("index.php?module=versandpakete&action=lieferscheine", "Offene Lieferscheine");
$this->app->erp->MenuEintrag("index.php?module=versandpakete&action=create", "Neu anlegen"); $this->app->erp->MenuEintrag("index.php?module=versandpakete&action=create", "Neu anlegen");
$this->app->erp->MenuEintrag("index.php", "Zur&uuml;ck");
} }
function versandpakete_list() { function versandpakete_list() {
@ -383,12 +435,22 @@ class Versandpakete {
public function versandpakete_delete() { public function versandpakete_delete() {
$id = (int) $this->app->Secure->GetGET('id'); $id = (int) $this->app->Secure->GetGET('id');
$this->app->DB->Delete("UPDATE `versandpakete` SET status='storniert' WHERE `id` = '{$id}'"); $this->app->DB->Delete("UPDATE `versandpakete` SET status='storniert' WHERE `id` = '{$id}' AND `status` IN ('neu', 'versendet')");
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde storniert.</div>"); $this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde storniert.</div>");
$this->versandpakete_list(); $this->versandpakete_list();
} }
public function versandpakete_deletepos() {
$id = (int) $this->app->Secure->GetGET('id');
$pos = (int) $this->app->Secure->GetGET('pos');
$sql = "DELETE vlp FROM `versandpaket_lieferschein_position` vlp INNER JOIN versandpakete v ON vlp.versandpaket = v.id WHERE vlp.`id` = '{$pos}' AND v.status = 'neu'";
$this->app->DB->Delete($sql);
header("Location: index.php?module=versandpakete&action=edit&id=".$id);
}
/* /*
* Edit versandpakete item * Edit versandpakete item
* If id is empty, create a new one * If id is empty, create a new one
@ -414,14 +476,30 @@ class Versandpakete {
// New item // New item
$new_item = true; $new_item = true;
$id = 'NULL'; $id = 'NULL';
$input['status'] = 'neu'; $sql = "INSERT INTO versandpakete (status, versender) VALUES ('neu','".$this->app->User->GetName()."')";
$input['versender'] = $this->app->User->GetName(); $this->app->DB->Insert($sql);
$id = $this->app->DB->GetInsertId();
header("Location: index.php?module=versandpakete&action=edit&id=".$id);
} }
// Check versandart
if (empty($input['versandart'])) {
$sql = "UPDATE versandpakete SET versandart = (SELECT versandart FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE versandpaket = ".$id." LIMIT 1)";
$this->app->DB->Update($sql);
}
switch ($submit) { switch ($submit) {
case 'speichern': case 'speichern':
// Write to database // Write to database
// Add checks here // Add checks here
$sql = "SELECT status FROM versandpakete WHERE id = ".$id;
$input['status'] = $this->app->DB->SelectArr($sql)[0]['status'];
if ($input['status'] != 'neu') {
$input = Array('bemerkung' => $input['bemerkung']);
}
$columns = "id, "; $columns = "id, ";
$values = "$id, "; $values = "$id, ";
$update = ""; $update = "";
@ -435,24 +513,26 @@ class Versandpakete {
} }
$sql = "INSERT INTO versandpakete (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update; $sql = "INSERT INTO versandpakete (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
$this->app->DB->Insert($sql); $this->app->DB->Insert($sql);
$id = $this->app->DB->GetInsertId(); $this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
if ($id == 'NULL') {
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
header("Location: index.php?module=versandpakete&action=edit&id=".$id."&msg=$msg");
} else {
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
}
break; break;
case 'absenden':
$sql = "UPDATE versandpakete SET status = 'versendet' WHERE id = ".$id;
$this->app->DB->Update($sql);
break;
case 'abschliessen':
$sql = "UPDATE versandpakete SET status = 'abgeschlossen' WHERE id = ".$id;
$this->app->DB->Update($sql);
break;
} }
// Load values again from database // 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=\"',v.id,'\" />') AS `auswahl`"; $dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',v.id,'\" />') AS `auswahl`";
$result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, ".$this->app->erp->FormatDate('datum')." as datum, v.versand, ".$this->app->erp->FormatUCfirst('v.versandart')." as versandart, v.nr, v.tracking, v.tracking_link, v.versender, v.gewicht, v.bemerkung, v.status, v.id FROM versandpakete v"." WHERE id=$id"); $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, ".$this->app->erp->FormatDate('datum')." as datum, v.versand, v.versandart, v.nr, v.tracking, v.tracking_link, v.versender, v.gewicht, v.bemerkung, v.status, v.id FROM versandpakete v"." WHERE id=$id");
foreach ($result[0] as $key => $value) { foreach ($result[0] as $key => $value) {
$this->app->Tpl->Set(strtoupper($key), $value); $this->app->Tpl->Set(strtoupper($key), $value);
} }
// Check for only one delivery adress // Check for only one delivery adress
$this->app->YUI->AutoComplete("lieferschein", "lieferschein"); $this->app->YUI->AutoComplete("lieferschein", "lieferschein");
$sql = "SELECT DISTINCT a.name, l.adresse FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") vpl INNER JOIN lieferschein l ON vpl.lieferschein = l.id INNER JOIN adresse a ON l.adresse = a.id WHERE vpl.versandpaket = ".$id; $sql = "SELECT DISTINCT a.name, l.adresse FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") vpl INNER JOIN lieferschein l ON vpl.lieferschein = l.id INNER JOIN adresse a ON l.adresse = a.id WHERE vpl.versandpaket = ".$id;
@ -468,25 +548,79 @@ class Versandpakete {
if ($new_item) { if ($new_item) {
$this->app->Tpl->Set('LIEFERSCHEIN_POS_HIDDEN', 'hidden'); $this->app->Tpl->Set('LIEFERSCHEIN_POS_HIDDEN', 'hidden');
} }
$sql = "SELECT lieferschein_ohne_pos, belegnr FROM versandpakete v INNER JOIN lieferschein l ON v.lieferschein_ohne_pos = l.id WHERE v.id = ".$id; $sql = "SELECT
$lieferschein_ohne_pos = $this->app->DB->SelectArr($sql); lieferschein_ohne_pos,
if (!empty($lieferschein_ohne_pos[0]['lieferschein_ohne_pos'])) { belegnr,
$this->app->Tpl->Set('LIEFERSCHEIN_ADD_POS_HIDDEN', 'hidden'); lieferschein_position,
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS', $lieferschein_ohne_pos[0]['belegnr']); l.versandart
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS_ID', $lieferschein_ohne_pos[0]['lieferschein_ohne_pos']); FROM versandpakete v
$this->app->Tpl->Set('LIEFERSCHEIN_POS_HIDDEN', 'hidden'); LEFT JOIN lieferschein l ON v.lieferschein_ohne_pos = l.id
} else { LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.versandpaket = v.id
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS_HIDDEN', 'hidden'); WHERE v.id = ".$id;
$lieferschein_check = $this->app->DB->SelectArr($sql);
if (empty($lieferschein_check[0]['lieferschein_position']) && empty($lieferschein_check[0]['lieferschein_ohne_pos'])) {
$this->app->Tpl->Set('NO_ADDRESS_HIDDEN', 'hidden');
$this->app->Tpl->Set('PAKETMARKE_ADD_HIDDEN', 'hidden');
} }
if (empty($lieferschein_check[0]['lieferschein_ohne_pos'])) {
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS_HIDDEN', 'hidden');
} else {
$this->app->Tpl->Set('LIEFERSCHEIN_ADD_POS_HIDDEN', 'hidden');
}
if (empty($lieferschein_check[0]['lieferschein_position'])) {
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS', $lieferschein_check[0]['belegnr']);
$this->app->Tpl->Set('LIEFERSCHEIN_OHNE_POS_ID', $lieferschein_check[0]['lieferschein_ohne_pos']);
$this->app->Tpl->Set('LIEFERSCHEIN_POS_HIDDEN', 'hidden');
}
if ($result[0]['status'] != 'neu') { if ($result[0]['status'] != 'neu') {
$this->app->Tpl->Set('LIEFERSCHEIN_ADD_POS_HIDDEN', 'hidden'); $this->app->Tpl->Set('LIEFERSCHEIN_ADD_POS_HIDDEN', 'hidden');
$this->app->Tpl->Set('LIEFERSCHEIN_GEWICHT_DISABLED', 'disabled'); $this->app->Tpl->Set('LIEFERSCHEIN_GEWICHT_DISABLED', 'disabled');
$this->app->Tpl->Set('PAKETMARKE_HIDDEN', 'hidden'); $this->app->Tpl->Set('PAKETMARKE_ADD_HIDDEN', 'hidden');
}
if ($result[0]['status'] != 'versendet') {
$this->app->Tpl->Set('ABSCHLIESSEN_HIDDEN', 'hidden');
} else {
$this->app->Tpl->Set('ABSENDEN_HIDDEN', 'hidden');
} }
if (!empty($result[0]['tracking'])) { if (!empty($result[0]['tracking'])) {
$this->app->Tpl->Set('PAKETMARKE_ADD_HIDDEN', 'hidden');
} else {
$this->app->Tpl->Set('PAKETMARKE_HIDDEN', 'hidden'); $this->app->Tpl->Set('PAKETMARKE_HIDDEN', 'hidden');
$this->app->Tpl->Set('ABSENDEN_HIDDEN', 'hidden');
} }
$file_attachments = $this->app->erp->GetDateiSubjektObjekt('paketmarke','versandpaket',$id);
if (!empty($file_attachments)) {
foreach ($file_attachments as $file_attachment) {
$this->app->Tpl->Add('PAKETMARKE_LINK', "index.php?module=dateien&action=send&id=".$file_attachment);
}
}
$sql = "SELECT SQL_CALC_FOUND_ROWS
".$this->app->YUI->IconsSQL_versandpaket()." icons
FROM
(
SELECT
".$this->app->erp->FormatMenge('SUM(lp.menge)')." as lmenge,
".$this->app->erp->FormatMenge('SUM(vlp.menge)')." AS vmenge,
v.status,
v.lieferschein_ohne_pos,
GROUP_CONCAT(DISTINCT lieferschein SEPARATOR ', ') as lieferscheine,
tracking
FROM
versandpakete v
LEFT JOIN
versandpaket_lieferschein_position vlp ON vlp.versandpaket = v.id
LEFT JOIN
lieferschein_position lp ON vlp.lieferschein_position = lp.id
WHERE v.id = ".$id."
GROUP BY v.id
) temp
";
$icons = $this->app->DB->SelectArr($sql);
$this->app->Tpl->Set('ICONS', $icons[0]['icons']);
$this->app->YUI->TableSearch('PAKETINHALT', 'versandpakete_paketinhalt_list', "show", "", "", basename(__FILE__), __CLASS__); $this->app->YUI->TableSearch('PAKETINHALT', 'versandpakete_paketinhalt_list', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE', "versandpakete_edit.tpl"); $this->app->Tpl->Parse('PAGE', "versandpakete_edit.tpl");
} }
@ -502,7 +636,7 @@ class Versandpakete {
} else { } else {
$lieferschein_belegnr = $this->app->erp->ReplaceLieferschein(false, $lieferschein, false); // Parameters: Target db?, value, from form? $lieferschein_belegnr = $this->app->erp->ReplaceLieferschein(false, $lieferschein, false); // Parameters: Target db?, value, from form?
/* Create new paket and add the given lieferschein */ /* Create new paket and add the given lieferschein */
$sql = "INSERT INTO versandpakete (status) VALUES ('neu')"; $sql = "INSERT INTO versandpakete (status, versender) VALUES ('neu','".$this->app->User->GetName()."')";
$this->app->DB->Insert($sql); $this->app->DB->Insert($sql);
$id = $this->app->DB->GetInsertId(); $id = $this->app->DB->GetInsertId();
} }
@ -565,26 +699,34 @@ class Versandpakete {
break; break;
} }
$buchmenge_gesamt = 0; $buchmenge_gesamt = 0;
$buchmenge = 0;
foreach($lieferschein_positionen as $lieferschein_position) { foreach($lieferschein_positionen as $lieferschein_position) {
$restmenge = $lieferschein_position['lp_menge']-$lieferschein_position['v_menge']; $restmenge = $lieferschein_position['lp_menge']-$lieferschein_position['v_menge'];
$buchmenge = $menge;
if ($restmenge <= 0) { if ($restmenge <= 0) {
continue; continue;
} }
if ($menge > $restmenge) { if ($menge > $restmenge) {
$buchmenge = $restmenge; $buchmenge = $restmenge;
$menge -= $buchmenge; } else {
$buchmenge = $menge;
}
$buchmenge_gesamt += $buchmenge;
$menge -= $buchmenge;
$sql = "INSERT INTO versandpaket_lieferschein_position (versandpaket, lieferschein_position, menge) VALUES (".$id.",".$lieferschein_position['lp_id'].",".$buchmenge.") ON DUPLICATE KEY UPDATE menge = menge+".$buchmenge."";
$this->app->DB->Insert($sql);
if ($menge <= 0) {
break;
} }
$sql = "INSERT INTO versandpaket_lieferschein_position (versandpaket, lieferschein_position, menge) VALUES (".$id.",".$lieferschein_position['lp_id'].",".$buchmenge.") ON DUPLICATE KEY UPDATE menge = '".$buchmenge."'";
$this->app->DB->Insert($sql);
$buchmenge_gesamt += $buchmenge;
} }
if ($menge != $buchmenge_gesamt) { if ($menge > 0) {
$msg = "<div class=\"error\">Menge wurde angepasst auf ".$buchmenge_gesamt.".</div>"; $msg = "<div class=\"error\">Menge wurde angepasst auf ".$buchmenge_gesamt.".</div>";
} }
@ -609,9 +751,11 @@ class Versandpakete {
foreach($lieferschein_positionen as $lieferschein_position) { foreach($lieferschein_positionen as $lieferschein_position) {
$buchmenge = $lieferschein_position['lp_menge']-$lieferschein_position['v_menge']; $buchmenge = $lieferschein_position['lp_menge']-$lieferschein_position['v_menge'];
$sql = "INSERT INTO versandpaket_lieferschein_position (versandpaket, lieferschein_position, menge) VALUES (".$id.",".$lieferschein_position['lp_id'].",".$buchmenge.") ON DUPLICATE KEY UPDATE menge = '".$buchmenge."'"; $sql = "INSERT INTO versandpaket_lieferschein_position (versandpaket, lieferschein_position, menge) VALUES (".$id.",".$lieferschein_position['lp_id'].",".$buchmenge.") ON DUPLICATE KEY UPDATE menge = menge+'".$buchmenge."'";
$this->app->DB->Insert($sql); $this->app->DB->Insert($sql);
} }
$msg = $this->app->erp->base64_url_encode("<div class=\"info\">Lieferschein hinzugef&uuml;gt.</div>");
header("Location: index.php?module=versandpakete&action=edit&id=".$id."&msg=$msg");
break; break;
} }
@ -662,24 +806,55 @@ class Versandpakete {
$this->app->ExitXentral(); $this->app->ExitXentral();
} }
function versandpakete_minidetaillieferschein() {
$id = $this->app->Secure->GetGET('id');
$table = new EasyTable($this->app);
$paket_link = array(
'<a href="index.php?module=versandpakete&action=edit&id=',
['sql' => 'versandpaket'],
'">',
['sql' => 'versandpaket'],
'</a>'
);
$table->Query("
SELECT
lp.sort AS Pos,
lp.bezeichnung,
".$this->app->erp->FormatMenge('lp.menge')." AS 'Menge',
".$this->app->erp->FormatMenge('SUM(vlp.menge)')." AS 'Menge in Versandpaketen',
GROUP_CONCAT(DISTINCT ".$this->app->erp->ConcatSQL($paket_link)." SEPARATOR ', ')
FROM
lieferschein l
INNER JOIN lieferschein_position lp ON lp.lieferschein = l.id
INNER JOIN versandpaket_lieferschein_position vlp ON vlp.lieferschein_position = lp.id
WHERE l.id = ".$id."
GROUP BY lp.id"
);
$table->DisplayNew('TABLE', 'Paket', 'noAction');
$this->app->Tpl->Output('table.tpl');
$this->app->ExitXentral();
}
function versandpakete_paketmarke() function versandpakete_paketmarke()
{ {
$this->versandpakete_menu(); $this->versandpakete_menu();
$id = $this->app->Secure->GetGET('id'); $id = $this->app->Secure->GetGET('id');
$this->app->erp->MenuEintrag("index.php?module=versandpakete&action=edit&id=".$id, "Zur&uuml;ck");
$this->app->Tpl->Set('TABTEXT',"Paketmarke"); $this->app->Tpl->Set('TABTEXT',"Paketmarke");
$result = $this->app->DB->SelectRow("SELECT va.id, va.modul FROM versandpakete vp INNER JOIN versandarten va ON vp.versandart = va.type LIMIT 1"); $result = $this->app->DB->SelectRow("SELECT va.id, va.modul FROM versandpakete vp INNER JOIN versandarten va ON vp.versandart = va.type LIMIT 1");
print_r($result);
if (empty($result['modul']) || empty($result['id'])) { if (empty($result['modul']) || empty($result['id'])) {
$this->app->Tpl->addMessage('error', 'Bitte zuerst eine gültige Versandart auswählen', false, 'PAGE'); $this->app->Tpl->addMessage('error', 'Bitte zuerst eine gültige Versandart auswählen', false, 'PAGE');
return; return;
} }
$lieferschein = $this->app->DB->SelectRow("SELECT * FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") temp WHERE versandpaket = ".$id." LIMIT 1"); $lieferschein = $this->app->DB->SelectRow("SELECT * FROM (".self::SQL_VERSANDPAKETE_LIEFERSCHEIN.") temp WHERE versandpaket = ".$id." LIMIT 1");
$versandmodul = $this->app->erp->LoadVersandModul($result['modul'], $result['id']); $versandmodul = $this->app->erp->LoadVersandModul($result['modul'], $result['id']);
$versandmodul->Paketmarke('TAB1', 'lieferschein', $lieferschein['lieferschein']); $versandmodul->Paketmarke('TAB1', 'lieferschein', $lieferschein['lieferschein'], $id);
$this->app->Tpl->Parse('PAGE',"tabview.tpl"); $this->app->Tpl->Parse('PAGE',"tabview.tpl");
} }
@ -688,16 +863,8 @@ class Versandpakete {
*/ */
public function GetInput(): array { public function GetInput(): array {
$input = array(); $input = array();
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
$input['versand'] = $this->app->Secure->GetPOST('versand');
$input['nr'] = $this->app->Secure->GetPOST('nr');
$input['tracking'] = $this->app->Secure->GetPOST('tracking');
$input['versender'] = $this->app->Secure->GetPOST('versender');
$input['gewicht'] = $this->app->Secure->GetPOST('gewicht'); $input['gewicht'] = $this->app->Secure->GetPOST('gewicht');
$input['bemerkung'] = $this->app->Secure->GetPOST('bemerkung'); $input['bemerkung'] = $this->app->Secure->GetPOST('bemerkung');
$input['status'] = $this->app->Secure->GetPOST('status');
return $input; return $input;
} }