mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 14:10:28 +01:00
bestellvorschlag with subselect only > 0 WIP
This commit is contained in:
parent
67d7a63898
commit
aa3dea0277
@ -30,20 +30,20 @@ class Bestellvorschlag {
|
|||||||
switch ($name) {
|
switch ($name) {
|
||||||
case "bestellvorschlag_list":
|
case "bestellvorschlag_list":
|
||||||
$allowed['bestellvorschlag_list'] = array('list');
|
$allowed['bestellvorschlag_list'] = array('list');
|
||||||
$heading = array('', '', 'Nr.', 'Artikel','Lieferant','Lager','Mindestlager','Vorschlag','Eingabe','');
|
$heading = array('', '', 'Nr.', 'Artikel','Lieferant','Mindestlager','Lager','Bestellt','Vorschlag','Eingabe','');
|
||||||
$width = array('1%','1%','1%', '20%', '10%', '1%', '1%', '1%', '5%', '1%');
|
$width = array('1%','1%','1%', '20%', '10%', '1%', '1%', '1%', '1%', '5%', '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('a.id','a.id','l.name','a.nummer','a.name_de','lager','mindestlager','vorschlag');
|
$findcols = array('a.id','a.id','a.nummer','a.name_de','l.name','mindestlager','lager','bestellt','vorschlag');
|
||||||
$searchsql = array('a.name_de');
|
$searchsql = array('a.name_de');
|
||||||
|
|
||||||
$defaultorder = 1;
|
$defaultorder = 1;
|
||||||
$defaultorderdesc = 0;
|
$defaultorderdesc = 0;
|
||||||
$numbercols = array(6,7,8);
|
$numbercols = array(6,7,8,9);
|
||||||
// $sumcol = array(6);
|
// $sumcol = array(6);
|
||||||
$alignright = array(6,7,8);
|
$alignright = array(6,7,8,9);
|
||||||
|
|
||||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',a.id,'\" />') AS `auswahl`";
|
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',a.id,'\" />') AS `auswahl`";
|
||||||
|
|
||||||
@ -54,27 +54,57 @@ class Bestellvorschlag {
|
|||||||
' name=\"menge_',
|
' name=\"menge_',
|
||||||
a.id,
|
a.id,
|
||||||
'\" value=\"',
|
'\" value=\"',
|
||||||
(SELECT vorschlag),
|
(SELECT mengen.vorschlag),
|
||||||
'\">',
|
'\" style=\"text-align:right\">',
|
||||||
'</input>'
|
'</input>'
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
$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_ber,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COALESCE(SUM(menge-geliefert))
|
||||||
|
FROM
|
||||||
|
bestellung_position bp INNER JOIN bestellung b ON bp.bestellung = b.id
|
||||||
|
WHERE bp.artikel = a.id AND b.status IN ('versendet','freigegeben')
|
||||||
|
) AS bestellt_ber,
|
||||||
|
a.mindestlager - (SELECT lager_ber) - COALESCE((SELECT bestellt_ber),0) as vorschlag_ber,
|
||||||
|
FORMAT (a.mindestlager,0,'de_DE') as mindestlager,
|
||||||
|
FORMAT((SELECT lager_ber),0,'de_DE') as lager,
|
||||||
|
FORMAT(COALESCE((SELECT bestellt_ber),0),0,'de_DE') as bestellt,
|
||||||
|
if ((SELECT vorschlag_ber) > 0,FORMAT((SELECT vorschlag_ber),'0','de_DE'),0) as vorschlag
|
||||||
|
FROM
|
||||||
|
artikel a
|
||||||
|
";
|
||||||
|
|
||||||
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
$sql = "SELECT SQL_CALC_FOUND_ROWS
|
||||||
a.id,
|
a.id,
|
||||||
$dropnbox,
|
$dropnbox,
|
||||||
a.nummer,
|
a.nummer,
|
||||||
a.name_de,
|
a.name_de,
|
||||||
l.name,
|
l.name,
|
||||||
(SELECT
|
mengen.mindestlager,
|
||||||
SUM(menge)
|
mengen.lager,
|
||||||
FROM
|
mengen.bestellt,
|
||||||
lager_platz_inhalt lpi INNER JOIN lager_platz lp ON lp.id = lpi.lager_platz
|
mengen.vorschlag,"
|
||||||
WHERE lpi.artikel = a.id AND lp.sperrlager = 0
|
|
||||||
) as lager,
|
|
||||||
a.mindestlager as mindestlager,
|
|
||||||
if (a.mindestlager - (SELECT lager) > 0,(a.mindestlager - (SELECT lager)),0) as vorschlag,"
|
|
||||||
.$input_for_menge
|
.$input_for_menge
|
||||||
."FROM artikel a INNER JOIN adresse l ON l.id = a.adresse ";
|
."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";
|
$where = "a.adresse != '' AND a.geloescht != 1 AND a.inaktiv != 1";
|
||||||
$count = "SELECT count(DISTINCT a.id) FROM artikel a WHERE $where";
|
$count = "SELECT count(DISTINCT a.id) FROM artikel a WHERE $where";
|
||||||
|
Loading…
Reference in New Issue
Block a user