-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from BernhardK91/1.0.0
Version 1.0.0
- Loading branch information
Showing
54 changed files
with
1,473 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Bios2000\Models; | ||
|
||
use Eloquent; | ||
|
||
/** | ||
* Class Adresse | ||
* @mixin Eloquent | ||
* @package Bios2000\Models | ||
*/ | ||
class Adresse extends Bios2000Master | ||
{ | ||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'ADRESSEN'; | ||
|
||
/** | ||
* Primary Key | ||
* | ||
* @var string | ||
*/ | ||
protected $primaryKey = 'KUNU'; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = ['ANLAGE_DATUM', 'AENDERUNG_DATUM']; | ||
|
||
/** | ||
* Returns contact persons relationship. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function ansprechpartner() | ||
{ | ||
return $this->hasMany(Ansprechpartner::class, 'KUNU', 'KUNU'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Bios2000\Models; | ||
|
||
use Bios2000\Models\Bios2000Master; | ||
use Bios2000\Traits\HasCompositePrimaryKey; | ||
use Eloquent; | ||
|
||
/** | ||
* Class Ansprechpartner | ||
* @mixin Eloquent | ||
* @package Bios2000\Models | ||
*/ | ||
class Ansprechpartner extends Bios2000Master | ||
{ | ||
use HasCompositePrimaryKey; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'ANSPRECHPARTNER'; | ||
|
||
/** | ||
* Primary Keys | ||
* | ||
* @var array | ||
*/ | ||
protected $primaryKey = ['NUMMER', 'KUERZEL']; | ||
|
||
public $incrementing = false; | ||
|
||
/** | ||
* Returns customer/supplier (address) relationship. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function adresse() | ||
{ | ||
return $this->belongsTo(Adresse::class, 'KUNU', 'KUNU'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
|
||
namespace Bios2000\Models; | ||
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\DB; | ||
use Exception; | ||
use Illuminate\Support\Facades\Schema; | ||
use function foo\func; | ||
|
||
/* | ||
* TODO: This should be optimized. | ||
*/ | ||
|
||
/** | ||
* Class Archiv | ||
* @package Bios2000\Models | ||
*/ | ||
class Archiv | ||
{ | ||
|
||
/** | ||
* Returns meta data of a single delivery note | ||
* | ||
* @param int $number | ||
* @return mixed | ||
*/ | ||
public static function deliverynote(int $number) | ||
{ | ||
$filter = [ | ||
'ART' => 'LS', | ||
'BELEG' => $number, | ||
]; | ||
|
||
/* | ||
* Return only first Result | ||
*/ | ||
return (new Archiv)->aw($filter)[0][0]; | ||
} | ||
|
||
/** | ||
* Returns meta data of a single delivery note | ||
* | ||
* @param int $number | ||
* @return mixed | ||
*/ | ||
public static function deliverynotePosten(int $number) | ||
{ | ||
$filter = [ | ||
'ART' => 'LS', | ||
'BELEG' => $number, | ||
]; | ||
|
||
/* | ||
* Return only first Result | ||
*/ | ||
return (new Archiv)->aw($filter, false)[0]; | ||
} | ||
|
||
/** | ||
* Returns result filtered by $arguments of "Auftragswesen" (AW) | ||
* | ||
* @param array $arguments | ||
* @param bool $kopf | ||
* @return Collection | ||
*/ | ||
private function aw(array $arguments, bool $kopf = true) | ||
{ | ||
return $this->archive('AW', $arguments, $kopf); | ||
} | ||
|
||
/** | ||
* Returns result of all archives filtered by $arguments, selected by $archive | ||
* | ||
* @param string $archive | ||
* @param array $arguments | ||
* @param bool $kopf (default: true) true = _KOPF, false = _POSTEN | ||
* @return Collection | ||
*/ | ||
private function archive(string $archive, array $arguments, bool $kopf = true) | ||
{ | ||
$year = date('Y'); | ||
|
||
$result = new Collection(); | ||
|
||
while (1) { | ||
if ($kopf) { | ||
$tableName = config('database.connections.bios2000.dba') . '.dbo.' . $archive . '_ARCHIV_' . $year . '_KOPF'; | ||
} else { | ||
$tableName = config('database.connections.bios2000.dba') . '.dbo.' . $archive . '_ARCHIV_' . $year . '_POSTEN'; | ||
} | ||
|
||
try { | ||
DB::connection('bios2000')->table($tableName)->select('ART')->first(); | ||
} catch (Exception $e) { | ||
if ($year == date('Y')) continue; | ||
break; | ||
} | ||
|
||
if ($kopf) { | ||
if (DB::connection('bios2000')->table($tableName) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc') | ||
->count() != 0) { | ||
|
||
if ($year < date('Y')) { | ||
$dbResult = Cache::rememberForever('bios2000_archive_' . $archive . '_' . $year . '_kopf_' . implode('-', $arguments), | ||
function () use ($tableName, $arguments) { | ||
return DB::connection('bios2000')->table($tableName) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc')->get()->all(); | ||
}); | ||
} else { | ||
$dbResult = DB::connection('bios2000')->table($tableName) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc')->get()->all(); | ||
} | ||
|
||
$result->push($dbResult); | ||
} | ||
|
||
} else { | ||
if (DB::connection('bios2000')->table($tableName) | ||
->where('POSITIONS_NR', '!=', null) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc') | ||
->count() != 0) { | ||
|
||
if ($year < date('Y')) { | ||
$dbResult = Cache::rememberForever('bios2000_archive_' . $archive . '_' . $year . '_posten_' . implode('-', $arguments), | ||
function () use ($tableName, $arguments) { | ||
return DB::connection('bios2000')->table($tableName) | ||
->where('POSITIONS_NR', '!=', null) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc')->get()->all(); | ||
}); | ||
|
||
} else { | ||
$dbResult = DB::connection('bios2000')->table($tableName) | ||
->where('POSITIONS_NR', '!=', null) | ||
->where($arguments) | ||
->orderBy('VERSION', 'desc')->get()->all(); | ||
} | ||
|
||
$result->push($dbResult); | ||
|
||
} | ||
} | ||
|
||
$year--; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace Bios2000\Models; | ||
|
||
use Bios2000\Models\Bios2000Master; | ||
use Eloquent; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
/** | ||
* Class Artikel | ||
* @mixin Eloquent | ||
* @package Bios2000\Models | ||
*/ | ||
class Artikel extends Bios2000Master | ||
{ | ||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'ARTIKEL_STAMM'; | ||
|
||
/** | ||
* Primary Key | ||
* | ||
* @var string | ||
*/ | ||
protected $primaryKey = 'ARTNR'; | ||
|
||
public $incrementing = false; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = ['ANLAGE_DATUM', 'AENDERUNG_DATUM']; | ||
|
||
/** | ||
* Return chaotic warehouse relationship. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function chaotLager() | ||
{ | ||
return $this->hasMany(ChaotLager::class, 'ARTNR', 'ARTNR'); | ||
} | ||
|
||
/** | ||
* Returns additional texts relationship. | ||
* | ||
* @param int $lang Language number (optional, default is german) | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function zusatztexte($lang = 0) | ||
{ | ||
return $this->hasMany(ArtikelZusatztext::class, 'ARTNR', 'ARTNR') | ||
->where('SPRACHE', $lang); | ||
} | ||
|
||
/** | ||
* Return warehouses relationship. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function lager() | ||
{ | ||
return $this->hasMany(ArtikelLager::class, 'ARTNR', 'ARTNR'); | ||
} | ||
|
||
public function bestand() | ||
{ | ||
return DB::connection($this->connection)->table('ARTIKEL_LAGER') | ||
->select(DB::raw("sum(BESTAND)-(SELECT ISNULL(sum(d.BESTAND), 0.00) FROM ARTIKEL_LAGER d (NOLOCK) WHERE | ||
(d.ARTNR = '" . $this->ARTNR . "' AND d.LAGER = -1)) -(SELECT ISNULL(sum(d.BESTAND), 0.00) FROM | ||
ARTIKEL_LAGER d (NOLOCK) WHERE (d.ARTNR = '" . $this->ARTNR . "' AND d.LAGER IN (SELECT y.NUMMER FROM | ||
SCHLUESSEL y WHERE y.ART = 'LG' AND y.EU_KZ = 'J' ))) as SUM_BESTAND")) | ||
->addSelect(DB::raw("sum(BESTELLT) as SUM_BESTELLT")) | ||
->addSelect(DB::raw("sum(RUECKSTAND) as SUM_RUECKSTAND")) | ||
->addSelect(DB::raw("sum(MIBEST) as SUM_MIBEST")) | ||
->addSelect(DB::raw("sum(SOLLBEST) as SUM_SOLLBEST")) | ||
->addSelect(DB::raw("sum(BBK) as SUM_BBK")) | ||
->addSelect(DB::raw("(SELECT ISNULL(sum(a.GELIEFERT), 0.00) FROM AUFTRAG_POSTEN a (NOLOCK) WHERE (a.ART = 'A' AND a.ZEILEN_ART = 'L' AND a.ARTNR = '" . $this->ARTNR . "')) | ||
+(SELECT ISNULL(sum(d.BESTAND), 0.00) FROM ARTIKEL_LAGER d (NOLOCK) WHERE (d.ARTNR = '" . $this->ARTNR . "' AND d.LAGER = -1)) | ||
+(SELECT ISNULL(sum(p.ABRUFMENGE), 0.00) FROM VDA_ABRUF_POSTEN p (NOLOCK) | ||
LEFT OUTER JOIN VDA_ABRUF_KOPF k (NOLOCK) ON (p.NUMMER = k.NUMMER) | ||
WHERE (k.ARTNR = '" . $this->ARTNR . "') AND (k.TESTKENNZEICHEN = 0) AND (p.GELIEFERT_FLAG = 'J')) | ||
+(SELECT ISNULL(sum(g.GELIEFERT),0.00) FROM PACKMITTEL_ARTNR_GELIEFERT g (NOLOCK) WHERE (g.ARTNR = '" . $this->ARTNR . "')) as SUM_RESERVIERT")) | ||
->where('ARTNR', '=', $this->ARTNR) | ||
->where('LAGER', '!=', '6')// 6 = Sperrlager | ||
->first(); | ||
} | ||
} |
Oops, something went wrong.