mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Produktion teilen, leeren
This commit is contained in:
parent
3b804ef745
commit
8c67d97728
@ -150,8 +150,26 @@
|
|||||||
<tr [AKTION_PLANEN_VISIBLE]><td><input type="text" name="artikel_planen" id="artikel_planen" value="[ARTIKEL_PLANEN]" size="20"></td></tr>
|
<tr [AKTION_PLANEN_VISIBLE]><td><input type="text" name="artikel_planen" id="artikel_planen" value="[ARTIKEL_PLANEN]" size="20"></td></tr>
|
||||||
<tr [AKTION_PLANEN_VISIBLE]><td>{|Planmenge|}:</td></tr>
|
<tr [AKTION_PLANEN_VISIBLE]><td>{|Planmenge|}:</td></tr>
|
||||||
<tr [AKTION_PLANEN_VISIBLE]><td><input type="text" name="artikel_planen_menge" id="artikel_planen_menge" value="[ARTIKEL_PLANEN_MENGE]" size="20"></td></tr>
|
<tr [AKTION_PLANEN_VISIBLE]><td><input type="text" name="artikel_planen_menge" id="artikel_planen_menge" value="[ARTIKEL_PLANEN_MENGE]" size="20"></td></tr>
|
||||||
<tr [ARTIKEL_MENGE_VISIBLE]><td>{|Menge geplant|}:</td><td>{|Menge erfolgreich|}:</td><td>{|Ausschuss|}:</td><td>{|Offen|}</td></tr>
|
<tr [ARTIKEL_MENGE_VISIBLE]>
|
||||||
<tr [ARTIKEL_MENGE_VISIBLE]><td>[MENGE_GEPLANT]</td><td>[MENGEERFOLGREICH]</td><td>[MENGEAUSSCHUSS]</td><td>[MENGE_OFFEN]</td></tr>
|
<td>{|Menge geplant|}:</td>
|
||||||
|
<td>{|Menge produziert|}:</td>
|
||||||
|
<td>{|Menge erfolgreich|}:</td>
|
||||||
|
</tr>
|
||||||
|
<tr [ARTIKEL_MENGE_VISIBLE]>
|
||||||
|
<td>[MENGE_GEPLANT]</td>
|
||||||
|
<td>[MENGE_PRODUZIERT]</td>
|
||||||
|
<td>[MENGEERFOLGREICH]</td>
|
||||||
|
</tr>
|
||||||
|
<tr [ARTIKEL_MENGE_VISIBLE]>
|
||||||
|
<td>{|Ausschuss|}:</td>
|
||||||
|
<td>{|Offen:|}</td>
|
||||||
|
<td>{|Produzierbar:|}</td>
|
||||||
|
</tr>
|
||||||
|
<tr [ARTIKEL_MENGE_VISIBLE]>
|
||||||
|
<td>[MENGEAUSSCHUSS]</td>
|
||||||
|
<td>[MENGE_OFFEN]</td>
|
||||||
|
<td>[MENGE_PRODUZIERBAR]</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
@ -159,9 +177,9 @@
|
|||||||
<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 [AKTION_PRODUZIEREN_VISIBLE]>{|Produktion durchführen|}</legend>
|
<legend [AKTION_PRODUZIEREN_VISIBLE]>{|Parameter|}</legend>
|
||||||
<table width="100%" border="0" class="mkTableFormular">
|
<table width="100%" border="0" class="mkTableFormular">
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td>{|Menge (max. [MENGE_PRODUZIERBAR])|}:</td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td>{|Menge|}:</td></tr>
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><input type="text" name="menge_produzieren" id="menge_produzieren" value="[MENGE_PRODUZIEREN]" size="20" style="width:100%;"></td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><input type="text" name="menge_produzieren" id="menge_produzieren" value="[MENGE_PRODUZIEREN]" size="20" style="width:100%;"></td></tr>
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td>{|Ausschuss|}:</td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td>{|Ausschuss|}:</td></tr>
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><input type="text" name="menge_ausschuss" id="menge_ausschuss" value="[MENGE_AUSSCHUSS]" size="20" style="width:100%;"></td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><input type="text" name="menge_ausschuss" id="menge_ausschuss" value="[MENGE_AUSSCHUSS]" size="20" style="width:100%;"></td></tr>
|
||||||
@ -177,8 +195,9 @@
|
|||||||
<tr [AKTION_PLANEN_VISIBLE]><td><button name="submit" value="planen" class="ui-button-icon" style="width:100%;">Planen</button></td></tr>
|
<tr [AKTION_PLANEN_VISIBLE]><td><button name="submit" value="planen" class="ui-button-icon" style="width:100%;">Planen</button></td></tr>
|
||||||
<tr [AKTION_FREIGEBEN_VISIBLE]><td><button name="submit" value="freigeben" class="ui-button-icon" style="width:100%;">Freigeben</button></td></tr>
|
<tr [AKTION_FREIGEBEN_VISIBLE]><td><button name="submit" value="freigeben" class="ui-button-icon" style="width:100%;">Freigeben</button></td></tr>
|
||||||
<tr [AKTION_RESERVIEREN_VISIBLE]><td><button name="submit" value="reservieren" class="ui-button-icon" style="width:100%;">Reservieren</button></td></tr>
|
<tr [AKTION_RESERVIEREN_VISIBLE]><td><button name="submit" value="reservieren" class="ui-button-icon" style="width:100%;">Reservieren</button></td></tr>
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><button name="submit" value="produzieren" class="ui-button-icon" style="width:100%;">Produzieren</button></td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><button name="submit" value="produzieren" class="ui-button-icon" style="width:100%;">Produzieren</button></td></tr>
|
||||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><button name="submit" value="teilen" class="ui-button-icon" style="width:100%;">Teilproduktion erstellen</button></td></tr>
|
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><button name="submit" value="teilen" class="ui-button-icon" style="width:100%;">Teilproduktion erstellen</button></td></tr>
|
||||||
|
<tr [AKTION_LEEREN_VISIBLE]><td><button name="submit" value="leeren" class="ui-button-icon" style="width:100%;">Leeren</button></td></tr>
|
||||||
<tr [AKTION_ABSCHLIESSEN_VISIBLE]><td><button name="submit" value="abschliessen" class="ui-button-icon" style="width:100%;">Abschliessen</button></td></tr>
|
<tr [AKTION_ABSCHLIESSEN_VISIBLE]><td><button name="submit" value="abschliessen" class="ui-button-icon" style="width:100%;">Abschliessen</button></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -269,6 +269,7 @@ class Produktion {
|
|||||||
|
|
||||||
$sql = "SELECT status, belegnr, projekt, standardlager FROM produktion WHERE id = '$id'";
|
$sql = "SELECT status, belegnr, projekt, standardlager FROM produktion WHERE id = '$id'";
|
||||||
$from_db = $this->app->DB->SelectArr($sql)[0];
|
$from_db = $this->app->DB->SelectArr($sql)[0];
|
||||||
|
$global_status = $from_db['status'];
|
||||||
$global_produktionsnummer = $from_db['belegnr'];
|
$global_produktionsnummer = $from_db['belegnr'];
|
||||||
$global_projekt = $from_db['projekt'];
|
$global_projekt = $from_db['projekt'];
|
||||||
$global_standardlager = $from_db['standardlager'];
|
$global_standardlager = $from_db['standardlager'];
|
||||||
@ -327,10 +328,10 @@ class Produktion {
|
|||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
if ($id == 'NULL') {
|
if ($id == 'NULL') {
|
||||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
$msg .= $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
||||||
header("Location: index.php?module=produktion&action=list&msg=$msg");
|
header("Location: index.php?module=produktion&action=list&msg=$msg");
|
||||||
} else {
|
} else {
|
||||||
$msg = "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>";
|
$msg .= "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'planen':
|
case 'planen':
|
||||||
@ -341,7 +342,7 @@ class Produktion {
|
|||||||
$produktionsartikel = $this->app->DB->SelectArr($sql);
|
$produktionsartikel = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
if (!empty($produktionsartikel)) {
|
if (!empty($produktionsartikel)) {
|
||||||
$msg = "<div class=\"success\">Bereits geplant.</div>";
|
$msg .= "<div class=\"success\">Bereits geplant.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,12 +350,12 @@ class Produktion {
|
|||||||
$artikel_planen_menge = $this->app->Secure->GetPOST('artikel_planen_menge');
|
$artikel_planen_menge = $this->app->Secure->GetPOST('artikel_planen_menge');
|
||||||
|
|
||||||
if (!$artikel_planen_id) {
|
if (!$artikel_planen_id) {
|
||||||
$msg = "<div class=\"error\">Artikel ist keine Stückliste.</div>";
|
$msg .= "<div class=\"error\">Artikel ist keine Stückliste.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($artikel_planen_menge < 1) {
|
if ($artikel_planen_menge < 1) {
|
||||||
$msg = "<div class=\"error\">Ungültige Planmenge.</div>";
|
$msg .= "<div class=\"error\">Ungültige Planmenge.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +367,7 @@ class Produktion {
|
|||||||
$stueckliste = $this->app->DB->SelectArr($sql);
|
$stueckliste = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
if (empty($stueckliste)) {
|
if (empty($stueckliste)) {
|
||||||
$msg = "<div class=\"error\">Stückliste ist leer.</div>";
|
$msg .= "<div class=\"error\">Stückliste ist leer.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +379,7 @@ class Produktion {
|
|||||||
$sql = "INSERT INTO produktion_position (produktion, artikel, menge, stuecklistestufe, projekt) VALUES ( $id, $artikel_planen_id, $artikel_planen_menge, 1, '$global_projekt'), ".implode(',',$position_values);
|
$sql = "INSERT INTO produktion_position (produktion, artikel, menge, stuecklistestufe, projekt) VALUES ( $id, $artikel_planen_id, $artikel_planen_menge, 1, '$global_projekt'), ".implode(',',$position_values);
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
$msg = "<div class=\"success\">Planung angelegt.</div>";
|
$msg .= "<div class=\"success\">Planung angelegt.</div>";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'freigeben':
|
case 'freigeben':
|
||||||
@ -389,7 +390,7 @@ class Produktion {
|
|||||||
// Check quantities and reserve for every position
|
// Check quantities and reserve for every position
|
||||||
|
|
||||||
if($global_standardlager == 0) {
|
if($global_standardlager == 0) {
|
||||||
$msg = "<div class=\"error\">Kein Lager ausgewählt.</div>";
|
$msg .= "<div class=\"error\">Kein Lager ausgewählt.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +400,7 @@ class Produktion {
|
|||||||
// Try to reserve material
|
// Try to reserve material
|
||||||
$reservierung_durchgefuehrt = false;
|
$reservierung_durchgefuehrt = false;
|
||||||
foreach ($materialbedarf as $materialbedarf_position) {
|
foreach ($materialbedarf as $materialbedarf_position) {
|
||||||
$result = $this->ArtikelReservieren($materialbedarf_position['artikel'], $global_standardlager, $materialbedarf_position['menge'], 'produktion', $id, $materialbedarf_position['id'],"Produktion $global_produktionsnummer");
|
$result = $this->ArtikelReservieren($materialbedarf_position['artikel'], $global_standardlager, $materialbedarf_position['menge']-$materialbedarf_position['geliefert_menge'], 0, 'produktion', $id, $materialbedarf_position['id'],"Produktion $global_produktionsnummer");
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$reservierung_durchgefuehrt = true;
|
$reservierung_durchgefuehrt = true;
|
||||||
}
|
}
|
||||||
@ -407,23 +408,21 @@ class Produktion {
|
|||||||
|
|
||||||
// Message output
|
// Message output
|
||||||
if ($reservierung_durchgefuehrt) {
|
if ($reservierung_durchgefuehrt) {
|
||||||
$msg = "<div class=\"info\">Reservierung durchgeführt.</div>";
|
$msg .= "<div class=\"info\">Reservierung durchgeführt.</div>";
|
||||||
} else {
|
} else {
|
||||||
$msg = "<div class=\"error\">Keine Reservierung durchgeführt!</div>";
|
$msg .= "<div class=\"error\">Keine Reservierung durchgeführt!</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'produzieren':
|
case 'produzieren':
|
||||||
|
|
||||||
// Check quanitites -> all must be reserved before production
|
// Check quanitites -> all must be reserved before production
|
||||||
|
// Parse positions
|
||||||
// Parse positions
|
|
||||||
$sql = "SELECT artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=1";
|
$sql = "SELECT artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=1";
|
||||||
$produktionsartikel_position = $this->app->DB->SelectArr($sql)[0];
|
$produktionsartikel_position = $this->app->DB->SelectArr($sql)[0];
|
||||||
|
|
||||||
if (empty($produktionsartikel_position)) {
|
if (empty($produktionsartikel_position)) {
|
||||||
$msg = "<div class=\"error\">Keine Planung vorhanden.</div>";
|
$msg .= "<div class=\"error\">Keine Planung vorhanden.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$menge_produzieren = $this->app->Secure->GetPOST('menge_produzieren');
|
$menge_produzieren = $this->app->Secure->GetPOST('menge_produzieren');
|
||||||
@ -441,47 +440,49 @@ class Produktion {
|
|||||||
$menge_auslagern = $menge_produzieren+$menge_ausschuss;
|
$menge_auslagern = $menge_produzieren+$menge_ausschuss;
|
||||||
|
|
||||||
if ($menge_auslagern < 1) {
|
if ($menge_auslagern < 1) {
|
||||||
$msg = "<div class=\"error\">Ungültige Menge.</div>";
|
$msg .= "<div class=\"error\">Ungültige Menge.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$menge_moeglich = $this->LagerCheckProduktion($id, $global_standardlager);
|
$menge_moeglich = $this->LagerCheckProduktion($id, $global_standardlager);
|
||||||
|
|
||||||
if ($menge_auslagern > $menge_moeglich) {
|
if ($menge_auslagern > $menge_moeglich) {
|
||||||
$msg = "<div class=\"error\">Lagermenge nicht ausreichend. ($menge_auslagern > $menge_moeglich)</div>";
|
$msg .= "<div class=\"error\">Lagermenge nicht ausreichend. ($menge_auslagern > $menge_moeglich)</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE produktion SET status = 'gestartet' WHERE id=$id";
|
$sql = "UPDATE produktion SET status = 'gestartet' WHERE id=$id";
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
$sql = "SELECT id, artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=0";
|
$sql = "SELECT id, artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge, stuecklistestufe FROM produktion_position pp WHERE produktion=$id";
|
||||||
$material = $this->app->DB->SelectArr($sql);
|
$material = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
foreach ($material as $material_position) {
|
foreach ($material as $material_position) {
|
||||||
|
|
||||||
// Calculate quantity to be removed
|
// Calculate quantity to be removed
|
||||||
$menge_artikel_auslagern = $material_position['menge']/$produktionsartikel_position['menge']*$menge_auslagern;
|
$menge_artikel_auslagern = $material_position['menge']/$produktionsartikel_position['menge']*$menge_auslagern;
|
||||||
|
|
||||||
// Remove material from stock
|
// Remove material from stock
|
||||||
$result = $this->app->erp->LagerAuslagernRegal($material_position['artikel'],$global_standardlager,$menge_artikel_auslagern,$global_projekt,'Produktion '.$produktion_belegnr);
|
$result = $this->app->erp->LagerAuslagernRegal($material_position['artikel'],$global_standardlager,$menge_artikel_auslagern,$global_projekt,'Produktion '.$produktion_belegnr);
|
||||||
if ($result != 1) {
|
if ($result != 1) {
|
||||||
$msg = "error\">Kritischer Fehler beim Ausbuchen! (Position ".$material_position['id'].", Menge ".$menge_artikel_auslagern.").</div>";
|
$msg .= "error\">Kritischer Fehler beim Ausbuchen! (Position ".$material_position['id'].", Menge ".$menge_artikel_auslagern.").</div>";
|
||||||
$error = true;
|
$error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust reservation
|
// Adjust reservation
|
||||||
$result = $this->ArtikelReservieren($material_position['artikel'],$global_standardlager,-$menge_artikel_auslagern,'produktion',$id,$material_position['id'],"Produktion $global_produktionsnummer");
|
if ($material_position['stuecklistestufe'] == 0) {
|
||||||
|
$result = $this->ArtikelReservieren($material_position['artikel'],$global_standardlager,-$menge_artikel_auslagern,0,'produktion',$id,$material_position['id'],"Produktion $global_produktionsnummer");
|
||||||
|
}
|
||||||
|
|
||||||
// Update position
|
// Update position
|
||||||
$sql = "UPDATE produktion_position SET geliefert_menge = geliefert_menge + $menge_artikel_auslagern WHERE id = ".$material_position['id'];
|
$sql = "UPDATE produktion_position SET geliefert_menge = geliefert_menge + $menge_artikel_auslagern WHERE id = ".$material_position['id'];
|
||||||
// echo($sql);
|
// echo($sql);
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert produced parts into stock
|
// Insert produced parts into stock
|
||||||
@ -493,7 +494,7 @@ class Produktion {
|
|||||||
$sql = "UPDATE produktion SET mengeerfolgreich = mengeerfolgreich + $menge_produzieren, mengeausschuss = mengeausschuss + $menge_ausschuss WHERE id = $id";
|
$sql = "UPDATE produktion SET mengeerfolgreich = mengeerfolgreich + $menge_produzieren, mengeausschuss = mengeausschuss + $menge_ausschuss WHERE id = $id";
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
$msg = "<div class=\"info\">Produktion durchgeführt.</div>";
|
$msg .= "<div class=\"info\">Produktion durchgeführt.</div>";
|
||||||
break;
|
break;
|
||||||
case 'teilen':
|
case 'teilen':
|
||||||
|
|
||||||
@ -508,8 +509,11 @@ class Produktion {
|
|||||||
|
|
||||||
$menge_abteilen = $this->app->Secure->GetPOST('menge_produzieren');
|
$menge_abteilen = $this->app->Secure->GetPOST('menge_produzieren');
|
||||||
|
|
||||||
if ($menge_abteilen < 1) {
|
$sql = "SELECT menge,geliefert_menge FROM produktion_position WHERE produktion = $id AND stuecklistestufe = 1";
|
||||||
$msg = "<div class=\"error\">Ungültige Teilmenge.</div>";
|
$produktionsmengen_alt = $this->app->DB->SelectArr($sql)[0];
|
||||||
|
|
||||||
|
if ($menge_abteilen < 1 || $menge_abteilen > ($produktionsmengen_alt['menge']-$produktionsmengen_alt['geliefert_menge'])) {
|
||||||
|
$msg .= "<div class=\"error\">Ungültige Teilmenge.</div>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,43 +573,78 @@ class Produktion {
|
|||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
$produktion_neu_id = $this->app->DB->GetInsertID();
|
$produktion_neu_id = $this->app->DB->GetInsertID();
|
||||||
|
|
||||||
$sql = "SELECT menge FROM produktion_position WHERE produktion = $id AND stuecklistestufe = 1";
|
|
||||||
$planmenge_alt = $this->app->DB->SelectArr($sql)[0];
|
|
||||||
|
|
||||||
// Now add the positions
|
// Now add the positions
|
||||||
$sql = "SELECT * FROM produktion_position WHERE produktion = $id";
|
$sql = "SELECT * FROM produktion_position WHERE produktion = $id";
|
||||||
$positionen = $this->app->DB->SelectArr($sql);
|
$positionen = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
foreach ($positionen as $position) {
|
foreach ($positionen as $position) {
|
||||||
$position['id'] = 'NULL';
|
|
||||||
$position['geliefert_menge'] = 0;
|
|
||||||
$position['menge'] = $menge_abteilen*($position['menge']/$planmenge_alt['menge']);
|
|
||||||
$position['produktion'] = $produktion_neu_id;
|
|
||||||
|
|
||||||
$columns = "";
|
$columns = "";
|
||||||
$values = "";
|
|
||||||
$update = "";
|
|
||||||
$fix = "";
|
|
||||||
|
|
||||||
|
// Preserve these values
|
||||||
|
$pos_id = $position['id'];
|
||||||
|
$geliefert_menge = ['geliefert_menge'];
|
||||||
|
$menge = $position['menge'];
|
||||||
|
$produktion_alt_id = $position['produktion'];
|
||||||
|
|
||||||
|
// For the new positions
|
||||||
|
$position['id'] = 'NULL';
|
||||||
|
$position['geliefert_menge'] = 0;
|
||||||
|
$position['menge'] = $menge_abteilen*($position['menge']/$produktionsmengen_alt['menge']);
|
||||||
|
$position['produktion'] = $produktion_neu_id;
|
||||||
|
|
||||||
|
$values = "";
|
||||||
|
$fix = "";
|
||||||
foreach ($position as $key => $value) {
|
foreach ($position as $key => $value) {
|
||||||
$columns = $columns.$fix.$key;
|
$columns = $columns.$fix.$key;
|
||||||
$values = $values.$fix."'".$value."'";
|
$values = $values.$fix."'".$value."'";
|
||||||
$update = $update.$fix.$key." = '$value'";
|
|
||||||
$fix = ", ";
|
$fix = ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO produktion_position (".$columns.") VALUES (".$values.")";
|
$sql = "INSERT INTO produktion_position (".$columns.") VALUES (".$values.")";
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
|
// For the old positions
|
||||||
|
// Reduce positions in old production
|
||||||
|
$position['id'] = $pos_id;
|
||||||
|
$position['geliefert_menge'] = $geliefert_menge;
|
||||||
|
$position['menge'] = $menge - $position['menge']; // old - part
|
||||||
|
$position['produktion'] = $produktion_alt_id;
|
||||||
|
|
||||||
|
$fix = "";
|
||||||
|
$update = "";
|
||||||
|
foreach ($position as $key => $value) {
|
||||||
|
$update = $update.$fix.$key." = '".($value)."'";
|
||||||
|
$fix = ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE produktion_position SET $update WHERE id = $pos_id";
|
||||||
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
|
// Free surplus reservations
|
||||||
|
$result = $this->ArtikelReservieren($position['artikel'],$global_standardlager,0,$position['menge'],'produktion',$id,$position['id'],"Produktion $global_produktionsnummer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce positions in old production TODO
|
$msg .= $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
||||||
|
|
||||||
// Correct reservations in old production TODO
|
|
||||||
|
|
||||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
|
||||||
header("Location: index.php?module=produktion&action=list&msg=$msg");
|
header("Location: index.php?module=produktion&action=list&msg=$msg");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'leeren':
|
||||||
|
|
||||||
|
if ($global_status == 'angelegt' || $global_status == 'freigegeben') {
|
||||||
|
$sql = "SELECT id, artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=0";
|
||||||
|
$material = $this->app->DB->SelectArr($sql);
|
||||||
|
foreach ($material as $material_position) {
|
||||||
|
// Remove reservation
|
||||||
|
$result = $this->ArtikelReservieren($material_position['artikel'],$global_standardlager,0,0,'produktion',$id,$material_position['id'],"Produktion $global_produktionsnummer");
|
||||||
|
}
|
||||||
|
$sql = "DELETE FROM produktion_position WHERE produktion = $id";
|
||||||
|
$this->app->DB->Update($sql);
|
||||||
|
$msg .= "<div class=\"warning\">Planung geleert.</div>";
|
||||||
|
} else {
|
||||||
|
$msg .= "<div class=\"error\">Planung kann nicht geleert werden.</div>";
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'abschliessen':
|
case 'abschliessen':
|
||||||
$sql = "UPDATE produktion SET status = 'abgeschlossen' WHERE id=$id";
|
$sql = "UPDATE produktion SET status = 'abgeschlossen' WHERE id=$id";
|
||||||
@ -616,8 +655,7 @@ class Produktion {
|
|||||||
|
|
||||||
foreach ($material as $material_position) {
|
foreach ($material as $material_position) {
|
||||||
// Remove reservation
|
// Remove reservation
|
||||||
|
$result = $this->ArtikelReservieren($material_position['artikel'],$global_standardlager,0,0,'produktion',$id,$material_position['id'],"Produktion $global_produktionsnummer");
|
||||||
$result = $this->ArtikelReservieren($material_position['artikel'],$global_standardlager,0,'produktion',$id,$material_position['id'],"Produktion $global_produktionsnummer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -811,7 +849,7 @@ class Produktion {
|
|||||||
$teilproduktionen = $this->app->DB->SelectArr($sql);
|
$teilproduktionen = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
if (!empty($teilproduktionen)) {
|
if (!empty($teilproduktionen)) {
|
||||||
$this->app->Tpl->Set('TEILPRODUKTIONINFO',"Zu dieser Produktion gehören diese Teilproduktionen: ".implode(', ',array_column($teilproduktionen,'belegnr')));
|
$this->app->Tpl->Set('TEILPRODUKTIONINFO',"Zu dieser Produktion gehören die Teilproduktionen: ".implode(', ',array_column($teilproduktionen,'belegnr')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
|
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
|
||||||
@ -854,12 +892,16 @@ class Produktion {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Reparse positions
|
// Reparse positions
|
||||||
$sql = "SELECT id,artikel, FORMAT(menge,0) as menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=1";
|
$sql = "SELECT id,artikel, FORMAT(menge,0) as menge, FORMAT(geliefert_menge,0) as geliefert_menge FROM produktion_position pp WHERE produktion=$id AND stuecklistestufe=1";
|
||||||
$produktionsartikel_position = $this->app->DB->SelectArr($sql)[0];
|
$produktionsartikel_position = $this->app->DB->SelectArr($sql)[0];
|
||||||
|
|
||||||
if (empty($produktionsartikel_position)) {
|
if (empty($produktionsartikel_position)) {
|
||||||
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
||||||
$this->app->Tpl->Set('ARTIKEL_MENGE_VISIBLE','hidden');
|
$this->app->Tpl->Set('ARTIKEL_MENGE_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_PRODUZIEREN_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_LEEREN_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_RESERVIEREN_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_TEILEN_VISIBLE','hidden');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->app->Tpl->Set('MENGE_GEPLANT',$produktionsartikel_position['menge']);
|
$this->app->Tpl->Set('MENGE_GEPLANT',$produktionsartikel_position['menge']);
|
||||||
@ -867,9 +909,11 @@ class Produktion {
|
|||||||
$menge_offen = $produktionsartikel_position['menge']-$produktion_from_db['mengeerfolgreich'];
|
$menge_offen = $produktionsartikel_position['menge']-$produktion_from_db['mengeerfolgreich'];
|
||||||
if ($menge_offen < 0) {
|
if ($menge_offen < 0) {
|
||||||
$menge_offen = 0;
|
$menge_offen = 0;
|
||||||
$msg = "<div class=\"info\">Planmenge überschritten.</div>";
|
$msg .= "<div class=\"info\">Planmenge überschritten.</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->app->Tpl->Set('MENGE_PRODUZIERT',$produktionsartikel_position['geliefert_menge']);
|
||||||
|
|
||||||
$this->app->Tpl->Set('MENGE_OFFEN',$menge_offen);
|
$this->app->Tpl->Set('MENGE_OFFEN',$menge_offen);
|
||||||
|
|
||||||
$this->app->Tpl->Set('MENGE_PRODUZIERBAR',$this->LagerCheckProduktion($id, $produktion_from_db['standardlager']));
|
$this->app->Tpl->Set('MENGE_PRODUZIERBAR',$this->LagerCheckProduktion($id, $produktion_from_db['standardlager']));
|
||||||
@ -903,11 +947,11 @@ class Produktion {
|
|||||||
break;
|
break;
|
||||||
case 'freigegeben':
|
case 'freigegeben':
|
||||||
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
||||||
$this->app->Tpl->Set('AKTION_PLANEN_VISIBLE','hidden');
|
|
||||||
break;
|
break;
|
||||||
case 'gestartet':
|
case 'gestartet':
|
||||||
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_FREIGEBEN_VISIBLE','hidden');
|
||||||
$this->app->Tpl->Set('AKTION_PLANEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_PLANEN_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_LEEREN_VISIBLE','hidden');
|
||||||
break;
|
break;
|
||||||
case 'abgeschlossen':
|
case 'abgeschlossen':
|
||||||
case 'storniert':
|
case 'storniert':
|
||||||
@ -918,6 +962,7 @@ class Produktion {
|
|||||||
$this->app->Tpl->Set('AKTION_PRODUZIEREN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_PRODUZIEREN_VISIBLE','hidden');
|
||||||
$this->app->Tpl->Set('AKTION_TEILEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_TEILEN_VISIBLE','hidden');
|
||||||
$this->app->Tpl->Set('AKTION_ABSCHLIESSEN_VISIBLE','hidden');
|
$this->app->Tpl->Set('AKTION_ABSCHLIESSEN_VISIBLE','hidden');
|
||||||
|
$this->app->Tpl->Set('AKTION_LEEREN_VISIBLE','hidden');
|
||||||
break;
|
break;
|
||||||
default: // new item
|
default: // new item
|
||||||
$this->app->Tpl->Set('POSITIONEN_TAB_VISIBLE','hidden="hidden"');
|
$this->app->Tpl->Set('POSITIONEN_TAB_VISIBLE','hidden="hidden"');
|
||||||
@ -1020,9 +1065,10 @@ class Produktion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modify or add reservation
|
// Modify or add reservation
|
||||||
// If amount is negative, the existing reservation will be reduced
|
// If quantity is negative, the existing reservation will be reduced
|
||||||
|
// If current quantity is higher as menge_reservieren_limit, current quantity will be reduced
|
||||||
// Returns amount that is reserved
|
// Returns amount that is reserved
|
||||||
function ArtikelReservieren(int $artikel, $lager, int $menge_reservieren, string $objekt, int $objekt_id, int $position_id, string $text) : int {
|
function ArtikelReservieren(int $artikel, $lager, int $menge_reservieren, int $menge_reservieren_limit, string $objekt, int $objekt_id, int $position_id, string $text) : int {
|
||||||
|
|
||||||
if($lager <= 0 || $artikel <= 0 || $position_id <= 0) {
|
if($lager <= 0 || $artikel <= 0 || $position_id <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1054,7 +1100,7 @@ class Produktion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($menge_reservieren == 0) {
|
if (($menge_reservieren == 0) && ($menge_reservieren_limit <= 0)) {
|
||||||
$sql = "DELETE FROM lager_reserviert WHERE objekt = '$objekt' AND parameter = $objekt_id AND artikel = $artikel AND posid = $position_id";
|
$sql = "DELETE FROM lager_reserviert WHERE objekt = '$objekt' AND parameter = $objekt_id AND artikel = $artikel AND posid = $position_id";
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
return(0);
|
return(0);
|
||||||
@ -1062,6 +1108,15 @@ class Produktion {
|
|||||||
|
|
||||||
$menge_lager_reservierbar = $menge_lager - $menge_reserviert_lager_platz + $menge_reserviert_diese;
|
$menge_lager_reservierbar = $menge_lager - $menge_reserviert_lager_platz + $menge_reserviert_diese;
|
||||||
|
|
||||||
|
if ($menge_reservieren_limit > 0) {
|
||||||
|
if ($menge_reserviert_diese > $menge_reservieren_limit) {
|
||||||
|
$menge_reservieren = $menge_reservieren_limit;
|
||||||
|
} else {
|
||||||
|
// Nothing to do
|
||||||
|
return($menge_reserviert_diese);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($menge_lager_reservierbar > 0) {
|
if ($menge_lager_reservierbar > 0) {
|
||||||
if ($menge_reserviert_diese > 0) {
|
if ($menge_reserviert_diese > 0) {
|
||||||
// Modify given entry
|
// Modify given entry
|
||||||
|
Loading…
Reference in New Issue
Block a user