mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Merge pull request #135 from exciler/followups_versandpakete
Followups versandpakete
This commit is contained in:
commit
61d2e11bf1
@ -377,11 +377,13 @@ class ShopimportController
|
|||||||
|
|
||||||
$stats['packages_yesterday'] = $verkaufszahlen->getPackages(
|
$stats['packages_yesterday'] = $verkaufszahlen->getPackages(
|
||||||
" v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d') '",
|
" v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d') '",
|
||||||
sprintf('INNER JOIN `auftrag` AS `a` ON l.auftragid = a.id AND a.shop = %d', $shopId)
|
sprintf('INNER JOIN `auftrag` AS `a` ON l.auftragid = a.id AND a.shop = %d', $shopId),
|
||||||
|
false
|
||||||
);
|
);
|
||||||
$stats['packages_today'] = $verkaufszahlen->getPackages(
|
$stats['packages_today'] = $verkaufszahlen->getPackages(
|
||||||
" v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d') '",
|
" v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d') '",
|
||||||
sprintf('INNER JOIN `auftrag` AS `a` ON l.auftragid = a.id AND a.shop = %d', $shopId)
|
sprintf('INNER JOIN `auftrag` AS `a` ON l.auftragid = a.id AND a.shop = %d', $shopId),
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -57,12 +57,6 @@ abstract class Versanddienstleister
|
|||||||
if ($rechnungId <= 0)
|
if ($rechnungId <= 0)
|
||||||
$rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1");
|
$rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1");
|
||||||
}
|
}
|
||||||
if ($sid === 'versand') {
|
|
||||||
$versandId = $id;
|
|
||||||
$lieferscheinId = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$versandId' LIMIT 1");
|
|
||||||
$rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$versandId' LIMIT 1");
|
|
||||||
$sid = 'lieferschein';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($auftragId <= 0 && $rechnungId > 0)
|
if ($auftragId <= 0 && $rechnungId > 0)
|
||||||
$auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1");
|
$auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1");
|
||||||
|
@ -159,28 +159,13 @@ class Verkaufszahlen {
|
|||||||
$this->app->Tpl->Set('BELEGTYP', 'Aufträge');
|
$this->app->Tpl->Set('BELEGTYP', 'Aufträge');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pkgsubwhere = "DATE(v.datum)=CURDATE()";
|
||||||
if($subwherea)
|
if($subwherea)
|
||||||
{
|
{
|
||||||
$pakete = $this->getPackages(
|
$projectIds = implode(',', $subwherea);
|
||||||
" v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d')
|
$pkgsubwhere .= " AND l.projekt in ($projectIds)";
|
||||||
AND l.projekt in (".implode(', ', $subwherea).") ".$this->app->erp->ProjektRechte('l.projekt')
|
|
||||||
);
|
|
||||||
$this->app->Tpl->Set(
|
|
||||||
'PAKETE',
|
|
||||||
$pakete
|
|
||||||
//$this->app->DB->Select("SELECT COUNT(v.id) FROM versand v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d') AND l.projekt in (".implode(', ', $subwherea).") ".$this->app->erp->ProjektRechte('l.projekt')."")
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
$pakete = $this->getPackages(
|
|
||||||
" v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d')
|
|
||||||
".$this->app->erp->ProjektRechte('l.projekt')
|
|
||||||
);
|
|
||||||
$this->app->Tpl->Set(
|
|
||||||
'PAKETE',
|
|
||||||
$pakete
|
|
||||||
//$this->app->DB->Select("SELECT COUNT(v.id) FROM versand INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d') ".$this->app->erp->ProjektRechte('l.projekt')."")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$this->app->Tpl->Set('PAKETE', $this->getPackages($pkgsubwhere));
|
||||||
|
|
||||||
if($daten['regs'])
|
if($daten['regs'])
|
||||||
{
|
{
|
||||||
@ -226,28 +211,13 @@ class Verkaufszahlen {
|
|||||||
$this->app->Tpl->Parse('STATISTIKHEUTE','verkaufszahlen_statistik.tpl');
|
$this->app->Tpl->Parse('STATISTIKHEUTE','verkaufszahlen_statistik.tpl');
|
||||||
|
|
||||||
//gestern
|
//gestern
|
||||||
|
$pkgsubwhere = "DATE(v.datum)=CURDATE()-1";
|
||||||
if($subwherea)
|
if($subwherea)
|
||||||
{
|
{
|
||||||
$pakete = $this->getPackages(
|
$projectIds = implode(',', $subwherea);
|
||||||
" v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d')
|
$pkgsubwhere .= " AND l.projekt in ($projectIds)";
|
||||||
AND l.projekt in (".implode(', ', $subwherea).") ".$this->app->erp->ProjektRechte('l.projekt')
|
|
||||||
);
|
|
||||||
$this->app->Tpl->Set(
|
|
||||||
'PAKETE',
|
|
||||||
$pakete
|
|
||||||
//$this->app->DB->Select("SELECT COUNT(v.id) FROM versand v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d') AND l.projekt in (".implode(', ', $subwherea).") ".$this->app->erp->ProjektRechte('l.projekt')."")
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
$pakete = $this->getPackages(
|
|
||||||
" v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d')
|
|
||||||
AND l.projekt in (".implode(', ', $subwherea).") ".$this->app->erp->ProjektRechte('l.projekt')
|
|
||||||
);
|
|
||||||
$this->app->Tpl->Set(
|
|
||||||
'PAKETE',
|
|
||||||
$pakete
|
|
||||||
//$this->app->DB->Select("SELECT COUNT(v.id) FROM versand v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d') ".$this->app->erp->ProjektRechte('l.projekt')."")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$this->app->Tpl->Set('PAKETE', $this->getPackages($pkgsubwhere));
|
||||||
|
|
||||||
if($daten['regs'])
|
if($daten['regs'])
|
||||||
{
|
{
|
||||||
@ -343,21 +313,19 @@ class Verkaufszahlen {
|
|||||||
return [(float)$einnahmen_auftrag, (float)$deckungsbeitrag, (float)$deckungsbeitragprozent];
|
return [(float)$einnahmen_auftrag, (float)$deckungsbeitrag, (float)$deckungsbeitragprozent];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getPackages(string $subwhere, string $join = '', bool $applyProjectRights = true) : int
|
||||||
* @param string $subwhere
|
|
||||||
* @param string $join
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getPackages($subwhere, $join = '')
|
|
||||||
{
|
{
|
||||||
return (int)$this->app->DB->Select(
|
$sqlpackages = "
|
||||||
"SELECT COUNT(v.id)
|
SELECT count(distinct v.id)
|
||||||
FROM versand v
|
FROM versandpakete v
|
||||||
INNER JOIN lieferschein l ON v.lieferschein = l.id
|
LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.versandpaket = v.id
|
||||||
$join
|
LEFT JOIN lieferschein_position lp ON vlp.lieferschein_position = lp.id
|
||||||
WHERE ".$subwhere
|
INNER JOIN lieferschein l ON l.id IN (lp.lieferschein, v.lieferschein_ohne_pos)
|
||||||
);
|
$join
|
||||||
|
WHERE $subwhere ";
|
||||||
|
if ($applyProjectRights)
|
||||||
|
$sqlpackages .= $this->app->erp->ProjektRechte('l.projekt');
|
||||||
|
return $this->app->DB->Select($sqlpackages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -689,8 +657,7 @@ class Verkaufszahlen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//heute
|
//heute
|
||||||
|
$this->app->Tpl->Set('PAKETE',$this->getPackages("DATE(v.datum)=CURDATE()"));
|
||||||
$this->app->Tpl->Set('PAKETE',$this->app->DB->Select("SELECT COUNT(v.id) FROM versand v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(NOW(),'%Y-%m-%d') ".$this->app->erp->ProjektRechte('l.projekt').""));
|
|
||||||
$data = $this->app->DB->SelectArr("SELECT ifnull(SUM(umsatz_netto),0) as umsatz_netto2,ifnull(SUM(erloes_netto),0) as erloes_netto2 FROM `auftrag`
|
$data = $this->app->DB->SelectArr("SELECT ifnull(SUM(umsatz_netto),0) as umsatz_netto2,ifnull(SUM(erloes_netto),0) as erloes_netto2 FROM `auftrag`
|
||||||
WHERE datum=DATE_FORMAT(NOW(),'%Y-%m-%d') AND ( status='abgeschlossen' OR status='freigegeben') ".
|
WHERE datum=DATE_FORMAT(NOW(),'%Y-%m-%d') AND ( status='abgeschlossen' OR status='freigegeben') ".
|
||||||
$this->app->erp->ProjektRechte('projekt').
|
$this->app->erp->ProjektRechte('projekt').
|
||||||
@ -716,7 +683,7 @@ class Verkaufszahlen {
|
|||||||
|
|
||||||
//gestern
|
//gestern
|
||||||
|
|
||||||
$this->app->Tpl->Set('PAKETE',$this->app->DB->Select("SELECT COUNT(v.id) FROM versand v INNER JOIN lieferschein l ON v.lieferschein = l.id WHERE v.versendet_am=DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 day),'%Y-%m-%d') ".$this->app->erp->ProjektRechte('l.projekt').""));
|
$this->app->Tpl->Set('PAKETE',$this->getPackages("DATE(v.datum)=CURDATE()-1"));
|
||||||
|
|
||||||
$data = $this->app->DB->SelectArr("SELECT
|
$data = $this->app->DB->SelectArr("SELECT
|
||||||
ifnull(SUM(umsatz_netto),0) as umsatz_netto2,ifnull(SUM(erloes_netto),0) as erloes_netto2 FROM `auftrag`
|
ifnull(SUM(umsatz_netto),0) as umsatz_netto2,ifnull(SUM(erloes_netto),0) as erloes_netto2 FROM `auftrag`
|
||||||
@ -772,11 +739,13 @@ class Verkaufszahlen {
|
|||||||
{
|
{
|
||||||
switch(strtoupper($type)) {
|
switch(strtoupper($type)) {
|
||||||
case 'TAGESUEBERSICHTPAKETE':
|
case 'TAGESUEBERSICHTPAKETE':
|
||||||
return $this->app->DB->SelectArrCache("SELECT DATE_FORMAT(v.versendet_am,'%d.%m.%Y') as datum,
|
return $this->app->DB->SelectArrCache("SELECT DATE_FORMAT(v.datum,'%d.%m.%Y') as datum,
|
||||||
count(v.id) as pakete
|
count(distinct v.id) as pakete
|
||||||
from versand v
|
FROM versandpakete v
|
||||||
INNER JOIN lieferschein l ON v.lieferschein = l.id
|
LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.versandpaket = v.id
|
||||||
WHERE 1 ".$this->app->erp->ProjektRechte('l.projekt').' group by v.versendet_am',
|
LEFT JOIN lieferschein_position lp ON vlp.lieferschein_position = lp.id
|
||||||
|
INNER JOIN lieferschein l ON l.id IN (lp.lieferschein, v.lieferschein_ohne_pos)
|
||||||
|
WHERE 1 ".$this->app->erp->ProjektRechte('l.projekt').' group by DATE(v.datum)',
|
||||||
$seconds, 'verkaufszahlen'
|
$seconds, 'verkaufszahlen'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user