mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Seriennummern initial
This commit is contained in:
parent
29cdae87ee
commit
ea1d578ffa
@ -91519,6 +91519,15 @@
|
||||
"id"
|
||||
],
|
||||
"Non_unique": ""
|
||||
},
|
||||
{
|
||||
"Key_name": "seriennummer_artikel",
|
||||
"Index_type": "BTREE",
|
||||
"columns": [
|
||||
"seriennummer",
|
||||
"artikel"
|
||||
],
|
||||
"Non_unique": "UNIQUE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -2608,6 +2608,16 @@ select a.kundennummer, (SELECT name FROM adresse a2 WHERE a2.kundennummer = a.ku
|
||||
$newarr[] = $arr[$i]['name'];
|
||||
}
|
||||
break;
|
||||
case "seriennummerverfuegbar":
|
||||
$artikel = (int)$this->app->Secure->GetGET('artikel');
|
||||
$arr = $this->app->DB->SelectArr("SELECT seriennummer FROM seriennummern WHERE lieferschein = 0 AND seriennummer LIKE '%$term%' AND artikel = '$artikel' LIMIT 20");
|
||||
$carr = !empty($arr)?count($arr):0;
|
||||
for($i = 0; $i < $carr; $i++) {
|
||||
$newarr[] = $arr[$i]['seriennummer'];
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
case "artikelmengeinbeleg":
|
||||
$beleg = $this->app->Secure->GetGet('beleg');
|
||||
$belegid = $this->app->Secure->GetGet('id');
|
||||
|
215
www/pages/content/seriennummern_edit.tpl
Normal file
215
www/pages/content/seriennummern_edit.tpl
Normal file
@ -0,0 +1,215 @@
|
||||
<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>-->seriennummern|}</legend><i>Info like this.</i>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
{|Seriennummer|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="seriennummer" id="seriennummer" value="[SERIENNUMMER]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Adresse|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="adresse" id="adresse" value="[ADRESSE]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Artikel|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="artikel" id="artikel" value="[ARTIKEL]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Beschreibung|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="beschreibung" id="beschreibung" value="[BESCHREIBUNG]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferung|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferung" id="lieferung" value="[LIEFERUNG]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferschein|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferschein" id="lieferschein" value="[LIEFERSCHEIN]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferscheinpos|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferscheinpos" id="lieferscheinpos" value="[LIEFERSCHEINPOS]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Bearbeiter|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="bearbeiter" id="bearbeiter" value="[BEARBEITER]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Logdatei|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="logdatei" id="logdatei" value="[LOGDATEI]" size="20">
|
||||
</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>
|
||||
{|Seriennummer|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="seriennummer" id="seriennummer" value="[SERIENNUMMER]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Adresse|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="adresse" id="adresse" value="[ADRESSE]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Artikel|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="artikel" id="artikel" value="[ARTIKEL]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Beschreibung|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="beschreibung" id="beschreibung" value="[BESCHREIBUNG]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferung|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferung" id="lieferung" value="[LIEFERUNG]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferschein|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferschein" id="lieferschein" value="[LIEFERSCHEIN]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Lieferscheinpos|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="lieferscheinpos" id="lieferscheinpos" value="[LIEFERSCHEINPOS]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Bearbeiter|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="bearbeiter" id="bearbeiter" value="[BEARBEITER]" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Logdatei|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="logdatei" id="logdatei" value="[LOGDATEI]" 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>
|
||||
|
167
www/pages/content/seriennummern_enter.tpl
Normal file
167
www/pages/content/seriennummern_enter.tpl
Normal file
@ -0,0 +1,167 @@
|
||||
<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-14 col-md-6 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Seriennummern erfassen Artikel [ARTIKELNUMMER] [ARTIKEL]|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
{|Lagermenge|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="[ANZLAGER]" size="40" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Seriennummern verfügbar|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="[ANZVORHANDEN]" size="40" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Seriennummern fehlen|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value="[ANZFEHLT]" size="40" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Seriennummer scannen|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="eingabeneu" id="eingabeneu" value="[EINGABENEU]" size="40" autofocus>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-6 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Seriennummernassistent|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
{|Letzte Seriennummer|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="muster" id="muster" value="[LETZTE]" size="40" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Präfix|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="praefix" id="praefix" value="[PRAEFIX]" size="40">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Start|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" name="start" id="start" value="[START]" size="40">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Postfix|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="postfix" id="postfix" value="[POSTFIX]" size="40">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{|Anzahl|}:
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" name="anzahl" id="anzahl" value="[ANZAHL]" size="40">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-2 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|<!--Legend for this form area goes here>-->Aktionen|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
<button name="submit" value="hinzufuegen" class="ui-button-icon" style="width:100%;">Hinzufügen</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button name="submit" value="assistent" class="ui-button-icon" style="width:100%;">Assistent ausführen</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-12 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|Gewählte Seriennummern|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
{|Seriennummern|}:
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="seriennummern" id="seriennummern" rows="20" style="width:100%;">[SERIENNUMMERN]</textarea>
|
||||
<i>Liste der Seriennummern, 1 pro Zeile</i>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-2 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend>{|<!--Legend for this form area goes here>-->Aktionen|}</legend>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<tr>
|
||||
<td>
|
||||
<button name="submit" value="speichern" class="ui-button-icon" style="width:100%;">Speichern</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
16
www/pages/content/seriennummern_list.tpl
Normal file
16
www/pages/content/seriennummern_list.tpl
Normal file
@ -0,0 +1,16 @@
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1">Artikel</a></li>
|
||||
<li><a href="#tabs-2">Seriennummern</a></li>
|
||||
</ul>
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
[TAB1]
|
||||
[TAB1NEXT]
|
||||
</div>
|
||||
<div id="tabs-2">
|
||||
[MESSAGE]
|
||||
[TAB2]
|
||||
[TAB2NEXT]
|
||||
</div>
|
||||
</div>
|
447
www/pages/seriennummern.php
Normal file
447
www/pages/seriennummern.php
Normal file
@ -0,0 +1,447 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 OpenXE project
|
||||
*/
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
use Xentral\Modules\SystemNotification\Service\NotificationMessageData;
|
||||
use Xentral\Modules\SystemNotification\Service\NotificationService;
|
||||
|
||||
class Seriennummern {
|
||||
|
||||
function __construct($app, $intern = false) {
|
||||
$this->app = $app;
|
||||
if ($intern)
|
||||
return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
$this->app->ActionHandler("list", "seriennummern_list");
|
||||
$this->app->ActionHandler("enter", "seriennummern_enter");
|
||||
$this->app->ActionHandler("delete", "seriennummern_delete");
|
||||
$this->app->DefaultActionHandler("list");
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
public function Install() {
|
||||
/* Fill out manually later */
|
||||
}
|
||||
|
||||
static function TableSearch(&$app, $name, $erlaubtevars) {
|
||||
switch ($name) {
|
||||
case "seriennummern_list":
|
||||
$allowed['seriennummern_list'] = array('list');
|
||||
$heading = array('','','Artikel', 'Seriennummer','Adresse','Lieferschein','Lieferdatum', 'Menü');
|
||||
$width = array('1%','1%','10%'); // Fill out manually later
|
||||
|
||||
// columns that are aligned right (numbers etc)
|
||||
// $alignright = array(4,5,6,7,8);
|
||||
|
||||
$findcols = array('s.id','s.id','a.nummer', 's.seriennummer','ad.name','l.belegnr','l.datum','s.id');
|
||||
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
$aligncenter = array();
|
||||
$alignright = array();
|
||||
$numbercols = array();
|
||||
$sumcol = array();
|
||||
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',s.id,'\" />') AS `auswahl`";
|
||||
|
||||
// $moreinfo = true; // Allow drop down details
|
||||
// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
|
||||
// $menucol = 11; // Set id col for moredata/menu
|
||||
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"#\" onclick=DeleteDialog(\"index.php?module=seriennummern&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
|
||||
$sql = "
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
s.id,
|
||||
$dropnbox,
|
||||
a.nummer,
|
||||
s.seriennummer,
|
||||
ad.name,
|
||||
l.belegnr,
|
||||
".$app->erp->FormatDate("l.datum").",
|
||||
s.id
|
||||
FROM
|
||||
seriennummern s
|
||||
INNER JOIN
|
||||
artikel a ON s.artikel = a.id
|
||||
LEFT JOIN
|
||||
lieferschein_position lp ON lp.id = s.lieferscheinpos
|
||||
LEFT JOIN
|
||||
lieferschein l ON l.id = lp.lieferschein
|
||||
LEFT JOIN
|
||||
adresse ad ON ad.id = l.adresse
|
||||
";
|
||||
|
||||
$where = "1";
|
||||
$count = "SELECT count(DISTINCT id) FROM seriennummern WHERE $where";
|
||||
// $groupby = "";
|
||||
|
||||
break;
|
||||
case "seriennummern_artikel_list":
|
||||
$allowed['seriennummern_artikel_list'] = array('list');
|
||||
$heading = array('','', 'Nummer', 'Artikel', 'Lagermenge', 'Nummern verfügbar', 'Nummern ausgeliefert', 'Nummern gesamt', 'Menü','');
|
||||
$width = array('1%','1%','10%'); // Fill out manually later
|
||||
|
||||
// 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' );
|
||||
$searchsql = array('a.name_de', 'a.nummer');
|
||||
|
||||
$menucol = 1;
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
$aligncenter = array();
|
||||
$alignright = array();
|
||||
$numbercols = array();
|
||||
$sumcol = array();
|
||||
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',a.id,'\" />') AS `auswahl`";
|
||||
|
||||
// $moreinfo = true; // Allow drop down details
|
||||
// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
|
||||
// $menucol = 11; // Set id col for moredata/menu
|
||||
|
||||
$menu_link = array(
|
||||
'<a href="index.php?module=seriennummern&action=enter&artikel=',
|
||||
['sql' => 'a.id'],
|
||||
'">',
|
||||
'<img src="./themes/'.$app->Conf->WFconf['defaulttheme'].'/images/add.png" alt="Erfassen" border="0">',
|
||||
'</a>'
|
||||
);
|
||||
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||
a.id,
|
||||
$dropnbox,
|
||||
CONCAT('<a href=\"index.php?module=artikel&action=edit&id=',a.id,'\">',a.nummer,'</a>') as nummer,
|
||||
a.name_de,
|
||||
auf_lager.anzahl,
|
||||
SUM(if(s.id IS NULL,0,1))-SUM(if(s.lieferscheinpos <> 0,1,0)),
|
||||
SUM(if(s.lieferscheinpos <> 0,1,0)),
|
||||
SUM(if(s.id IS NULL,0,1)),
|
||||
".$app->erp->ConcatSQL($menu_link).",
|
||||
a.id
|
||||
FROM
|
||||
artikel a
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
a.id,
|
||||
a.nummer,
|
||||
a.name_de name,
|
||||
SUM(lpi.menge) anzahl
|
||||
FROM
|
||||
artikel a
|
||||
INNER JOIN lager_platz_inhalt lpi ON
|
||||
a.id = lpi.artikel
|
||||
WHERE
|
||||
a.seriennummern <> 'keine' AND a.seriennummern <> ''
|
||||
GROUP BY
|
||||
a.id
|
||||
) auf_lager ON auf_lager.id = a.id
|
||||
LEFT JOIN
|
||||
seriennummern s ON s.artikel = a.id
|
||||
";
|
||||
|
||||
$where = "a.seriennummern <> 'keine' AND a.seriennummern <> ''";
|
||||
$count = "SELECT count(DISTINCT a.id) FROM artikel a WHERE $where";
|
||||
$groupby = "GROUP BY a.id";
|
||||
|
||||
break;
|
||||
case "seriennummern_lieferscheine_list":
|
||||
$allowed['seriennummern_artikel_list'] = array('list');
|
||||
$heading = array('','', 'Nummer', 'Artikel', 'Lagermenge', 'Nummern verfügbar', 'Nummern ausgeliefert', 'Nummern gesamt', 'Menü');
|
||||
$width = array('1%','1%','10%'); // Fill out manually later
|
||||
|
||||
// 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' );
|
||||
$searchsql = array('a.name_de', 'a.nummer');
|
||||
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
$aligncenter = array();
|
||||
$alignright = array();
|
||||
$numbercols = array();
|
||||
$sumcol = array();
|
||||
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',a.id,'\" />') AS `auswahl`";
|
||||
|
||||
// $moreinfo = true; // Allow drop down details
|
||||
// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
|
||||
// $menucol = 11; // Set id col for moredata/menu
|
||||
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=seriennummern&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=seriennummern&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||
a.id,
|
||||
$dropnbox,
|
||||
CONCAT('<a href=\"index.php?module=artikel&action=edit&id=',a.id,'\">',a.nummer,'</a>') as nummer,
|
||||
a.name_de,
|
||||
auf_lager.anzahl,
|
||||
SUM(if(s.id IS NULL,0,1))-SUM(if(s.lieferscheinpos <> 0,1,0)),
|
||||
SUM(if(s.lieferscheinpos <> 0,1,0)),
|
||||
SUM(if(s.id IS NULL,0,1))
|
||||
FROM
|
||||
artikel a
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
a.id,
|
||||
a.nummer,
|
||||
a.name_de name,
|
||||
SUM(lpi.menge) anzahl
|
||||
FROM
|
||||
artikel a
|
||||
INNER JOIN lager_platz_inhalt lpi ON
|
||||
a.id = lpi.artikel
|
||||
WHERE
|
||||
a.seriennummern <> 'keine' AND a.seriennummern <> ''
|
||||
GROUP BY
|
||||
a.id
|
||||
) auf_lager ON auf_lager.id = a.id
|
||||
LEFT JOIN
|
||||
seriennummern s ON s.artikel = a.id
|
||||
";
|
||||
|
||||
$where = "a.seriennummern <> 'keine' AND a.seriennummern <> ''";
|
||||
$count = "SELECT count(DISTINCT a.id) FROM artikel a WHERE $where";
|
||||
$groupby = "GROUP BY a.id";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$erg = false;
|
||||
|
||||
foreach ($erlaubtevars as $k => $v) {
|
||||
if (isset($$v)) {
|
||||
$erg[$v] = $$v;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
|
||||
function seriennummern_list() {
|
||||
$this->app->erp->MenuEintrag("index.php?module=seriennummern&action=list", "Übersicht");
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php", "Zurück");
|
||||
|
||||
$this->app->YUI->TableSearch('TAB1', 'seriennummern_artikel_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
$this->app->YUI->TableSearch('TAB2', 'seriennummern_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
|
||||
$check_seriennummern = $this->seriennummern_check_serials();
|
||||
|
||||
if (!empty($check_seriennummern)) {
|
||||
$artikel_id_links = array();
|
||||
foreach ($check_seriennummern as $artikel_id) {
|
||||
if ($artikel_id['menge_nummern'] < $artikel_id['menge_auf_lager']) {
|
||||
$artikel_id_links[] = '<a href="index.php?module=seriennummern&action=enter&artikel='.$artikel_id['id'].'">'.$artikel_id['nummer'].'</a>';
|
||||
}
|
||||
}
|
||||
if (!empty($artikel_id_links)) {
|
||||
$this->app->YUI->Message('warning','Seriennummern fehlen für Artikel: '.implode(', ',$artikel_id_links));
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->Tpl->Parse('PAGE', "seriennummern_list.tpl");
|
||||
}
|
||||
|
||||
public function seriennummern_delete() {
|
||||
$id = (int) $this->app->Secure->GetGET('id');
|
||||
|
||||
if ($this->app->DB->Select("SELECT id FROM `seriennummern` WHERE `id` = '{$id}' AND `lieferscheinpos` = 0")) {
|
||||
$this->app->DB->Delete("DELETE FROM `seriennummern` WHERE `id` = '{$id}' AND `lieferscheinpos` = 0");
|
||||
$this->app->Tpl->addMessage('error', 'Der Eintrag wurde gelöscht');
|
||||
} else {
|
||||
$this->app->Tpl->addMessage('error', 'Der Eintrag kann nicht gelöscht werden!');
|
||||
}
|
||||
$this->seriennummern_list();
|
||||
}
|
||||
|
||||
function seriennummern_enter() {
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=seriennummern&action=list", "Zurück zur Übersicht");
|
||||
$artikel_id = (int) $this->app->Secure->GetGET('artikel');
|
||||
|
||||
$artikel = $this->app->DB->SelectRow("SELECT name_de, nummer FROM artikel WHERE id ='".$artikel_id."'");
|
||||
|
||||
$this->app->Tpl->SetText('KURZUEBERSCHRIFT1','Erfassen');
|
||||
$this->app->Tpl->SetText('KURZUEBERSCHRIFT2',$artikel['name_de']." (Artikel ".$artikel['nummer'].")");
|
||||
|
||||
$submit = $this->app->Secure->GetPOST('submit');
|
||||
$seriennummern = array();
|
||||
|
||||
$seriennummern_text = $this->app->Secure->GetPOST('seriennummern');
|
||||
$seriennummern = explode('\n',str_replace(['\r'],'',$seriennummern_text));
|
||||
|
||||
switch ($submit) {
|
||||
case 'hinzufuegen':
|
||||
$eingabe = $this->app->Secure->GetPOST('eingabeneu');
|
||||
if (!empty($eingabe)) {
|
||||
$seriennummern[] = $eingabe;
|
||||
}
|
||||
break;
|
||||
case 'speichern':
|
||||
$seriennummern_not_written = array();
|
||||
foreach ($seriennummern as $seriennummer) {
|
||||
|
||||
$seriennummer = trim($seriennummer);
|
||||
|
||||
if (empty($seriennummer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO seriennummern (seriennummer, artikel) VALUES ('".$this->app->DB->real_escape_string($seriennummer)."', '".$artikel_id."')";
|
||||
try {
|
||||
$this->app->DB->Insert($sql);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
$error = true;
|
||||
$seriennummern_not_written[] = $seriennummer;
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
$this->app->Tpl->addMessage('error', 'Einige Seriennummern konnten nicht gespeichert werden.');
|
||||
}
|
||||
$seriennummern = $seriennummern_not_written;
|
||||
break;
|
||||
case 'assistent':
|
||||
$praefix = $this->app->Secure->GetPOST('praefix');
|
||||
$start = $this->app->Secure->GetPOST('start');
|
||||
$postfix = $this->app->Secure->GetPOST('postfix');
|
||||
$anzahl = (int) $this->app->Secure->GetPOST('anzahl');
|
||||
|
||||
while ($anzahl) {
|
||||
$seriennummern[] = $praefix.$start.$postfix;
|
||||
$anzahl--;
|
||||
$start++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$seriennummern = array_unique($seriennummern);
|
||||
|
||||
$check_seriennummern = $this->seriennummern_check_serials($artikel_id);
|
||||
if (empty($check_seriennummern)) {
|
||||
$this->app->Tpl->addMessage('success', 'Seriennummern vollständig.');
|
||||
}
|
||||
|
||||
$check_seriennummern = $check_seriennummern[0];
|
||||
|
||||
$anzahl_fehlt = $check_seriennummern['menge_auf_lager']-$check_seriennummern['menge_nummern'];
|
||||
|
||||
if ($anzahl_fehlt < 0) {
|
||||
$anzahl_fehlt = 0;
|
||||
}
|
||||
|
||||
$letzte_seriennummer = (string) $this->app->DB->Select("SELECT seriennummer FROM seriennummern WHERE artikel = '".$artikel_id."' ORDER BY id DESC LIMIT 1");
|
||||
$regex_result = array(preg_match('/(.*?)(\d+)(?!.*\d)(.*)/', $letzte_seriennummer, $matches));
|
||||
|
||||
$this->app->Tpl->Set('LETZTE', $letzte_seriennummer);
|
||||
|
||||
$this->app->Tpl->Set('PRAEFIX', $matches[1]);
|
||||
$this->app->Tpl->Set('START', $matches[2]+1);
|
||||
$this->app->Tpl->Set('POSTFIX', $matches[3]);
|
||||
|
||||
$this->app->Tpl->Set('ANZAHL', $anzahl_fehlt);
|
||||
|
||||
$this->app->Tpl->Set('ARTIKELNUMMER', '<a href="index.php?module=artikel&action=edit&id='.$check_seriennummern['id'].'">'.$check_seriennummern['nummer'].'</a>');
|
||||
$this->app->Tpl->Set('ARTIKEL', $check_seriennummern['name']);
|
||||
$this->app->Tpl->Set('ANZLAGER', $check_seriennummern['menge_auf_lager']);
|
||||
$this->app->Tpl->Set('ANZVORHANDEN', $check_seriennummern['menge_nummern']);
|
||||
$this->app->Tpl->Set('ANZFEHLT', $anzahl_fehlt);
|
||||
$this->app->Tpl->Set('SERIENNUMMERN', implode("\n",$seriennummern));
|
||||
|
||||
$this->app->YUI->AutoComplete("eingabe", "seriennummerverfuegbar",0,"&artikel=$artikel_id");
|
||||
$this->app->Tpl->Parse('PAGE', "seriennummern_enter.tpl");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if all serial numbers are given
|
||||
* Return array of article ids
|
||||
*/
|
||||
public function seriennummern_check_serials($artikel_id = null) : array {
|
||||
$sql = "
|
||||
SELECT
|
||||
auf_lager.id,
|
||||
nummer,
|
||||
name,
|
||||
auf_lager.anzahl menge_auf_lager,
|
||||
COALESCE(nummern_verfuegbar.anzahl,0) menge_nummern
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a.id,
|
||||
a.nummer,
|
||||
a.name_de name,
|
||||
SUM(lpi.menge) anzahl
|
||||
FROM
|
||||
artikel a
|
||||
INNER JOIN lager_platz_inhalt lpi ON
|
||||
a.id = lpi.artikel
|
||||
WHERE
|
||||
a.seriennummern <> 'keine' AND a.seriennummern <> '' AND (a.id = '".$artikel_id."' OR '".$artikel_id."' = '')
|
||||
GROUP BY
|
||||
a.id
|
||||
) auf_lager
|
||||
LEFT JOIN(
|
||||
SELECT
|
||||
artikel,
|
||||
COUNT(id) anzahl
|
||||
FROM
|
||||
seriennummern
|
||||
WHERE
|
||||
lieferscheinpos = 0
|
||||
GROUP BY
|
||||
artikel
|
||||
) nummern_verfuegbar
|
||||
ON
|
||||
auf_lager.id = nummern_verfuegbar.artikel
|
||||
GROUP BY
|
||||
auf_lager.id
|
||||
HAVING
|
||||
menge_nummern <> menge_auf_lager
|
||||
";
|
||||
|
||||
$result = $this->app->DB->SelectArr($sql);
|
||||
return(empty($result)?array():$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $printerId
|
||||
* @param string $filename
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function seriennummern_create_notification($article)
|
||||
{
|
||||
// Notification erstellen
|
||||
$message = new NotificationMessageData('default', 'Seriennummern check problem alter');
|
||||
$message->setMessage('Nicht genug Seriendinges');
|
||||
$message->addTags(['seriennummern']);
|
||||
$message->setOption('id', $article);
|
||||
$message->setPriority(true);
|
||||
|
||||
$messageButtons = [
|
||||
[
|
||||
'text' => 'Seriennummern pflegen',
|
||||
'link' => sprintf('index.php?module=seriennummern&action=edit&article=%s', $article),
|
||||
],
|
||||
[
|
||||
'text' => 'Zum Spooler',
|
||||
'link' => '#'
|
||||
]
|
||||
];
|
||||
$message->setOption('buttons', $messageButtons);
|
||||
|
||||
/** @var NotificationService $notification */
|
||||
$notification = $this->app->Container->get('NotificationService');
|
||||
$notification->createFromData($this->app->User->GetID(), $message);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user