mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Produktion menge anpassen
This commit is contained in:
parent
1bf8f567b4
commit
3d37049ea1
@ -151,9 +151,9 @@
|
||||
<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 [ARTIKEL_MENGE_VISIBLE]>
|
||||
<td>{|Menge geplant|}:</td>
|
||||
<td>{|Menge produziert|}:</td>
|
||||
<td>{|Menge erfolgreich|}:</td>
|
||||
<td>{|Geplant|}:</td>
|
||||
<td>{|Produziert|}:</td>
|
||||
<td>{|Erfolgreich|}:</td>
|
||||
</tr>
|
||||
<tr [ARTIKEL_MENGE_VISIBLE]>
|
||||
<td>[MENGE_GEPLANT]</td>
|
||||
@ -197,6 +197,7 @@
|
||||
<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="teilen" class="ui-button-icon" style="width:100%;">Teilproduktion erstellen</button></td></tr>
|
||||
<tr [AKTION_PRODUZIEREN_VISIBLE]><td><button name="submit" value="anpassen" class="ui-button-icon" style="width:100%;">Anpassen</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>
|
||||
</table>
|
||||
|
@ -355,7 +355,7 @@ class Produktion {
|
||||
}
|
||||
|
||||
if ($artikel_planen_menge < 1) {
|
||||
$msg .= "<div class=\"error\">Ungültige Planmenge.</div>";
|
||||
$msg .= "<div class=\"error\">Ungültige Planmenge.</div>";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -390,7 +390,6 @@ class Produktion {
|
||||
// Check quantities and reserve for every position
|
||||
|
||||
if($global_standardlager == 0) {
|
||||
$msg .= "<div class=\"error\">Kein Lager ausgewählt.</div>";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -643,6 +642,27 @@ class Produktion {
|
||||
$msg .= "<div class=\"error\">Planung kann nicht geleert werden.</div>";
|
||||
}
|
||||
|
||||
break;
|
||||
case 'anpassen':
|
||||
|
||||
if ($global_status == 'angelegt' || $global_status == 'freigegeben' || $global_status == 'gestartet') {
|
||||
|
||||
$menge_anpassen = $this->app->Secure->GetPOST('menge_produzieren');
|
||||
|
||||
if (empty($menge_anpassen)) {
|
||||
$msg .= "<div class=\"error\">Ungültige Planmenge.</div>";
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $this->MengeAnpassen($id,$menge_anpassen,$global_standardlager);
|
||||
|
||||
if ($result == -1) {
|
||||
$msg .= "<div class=\"error\">Ungültige Planmenge.</div>";
|
||||
} else {
|
||||
$msg .= "<div class=\"info\">Planmenge angepasst.</div>";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'abschliessen':
|
||||
$sql = "UPDATE produktion SET status = 'abgeschlossen' WHERE id=$id";
|
||||
@ -850,6 +870,10 @@ class Produktion {
|
||||
$this->app->Tpl->Set('TEILPRODUKTIONINFO',"Zu dieser Produktion gehören die Teilproduktionen: ".implode(', ',array_column($teilproduktionen,'belegnr')));
|
||||
}
|
||||
|
||||
if($produktion_from_db['standardlager'] == 0) {
|
||||
$msg .= "<div class=\"error\">Kein Lager ausgewählt.</div>";
|
||||
}
|
||||
|
||||
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
|
||||
$this->app->YUI->AutoComplete("kundennummer", "kunde", 1);
|
||||
$this->app->YUI->AutoComplete("auftragid", "auftrag", 1);
|
||||
@ -1147,4 +1171,39 @@ class Produktion {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Adjust the planned quantity of a produktion
|
||||
Lower limit is the already produced quantity
|
||||
Return -1 if not possible, else 1
|
||||
*/
|
||||
function MengeAnpassen(int $produktion_id, int $menge_neu, int $lager) : int {
|
||||
|
||||
$sql = "SELECT menge,geliefert_menge FROM produktion_position WHERE produktion = $produktion_id AND stuecklistestufe = 1";
|
||||
$produktionsmengen_alt = $this->app->DB->SelectArr($sql)[0];
|
||||
|
||||
if (empty($produktionsmengen_alt)) {
|
||||
return(-1);
|
||||
}
|
||||
if ($menge_neu <= $produktionsmengen_alt['geliefert_menge']) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
$sql = "SELECT * from produktion WHERE id = $produktion_id";
|
||||
$produktion_alt = $this->app->DB->SelectArr($sql)[0];
|
||||
|
||||
// Process positions
|
||||
$sql = "SELECT * FROM produktion_position WHERE produktion = $produktion_id";
|
||||
$positionen = $this->app->DB->SelectArr($sql);
|
||||
|
||||
foreach ($positionen as $position) {
|
||||
$position_menge_neu = $menge_neu*($position['menge']/$produktionsmengen_alt['menge']);
|
||||
$sql = "UPDATE produktion_position SET menge=".$position_menge_neu." WHERE id =".$position['id'];
|
||||
$this->app->DB->Update($sql);
|
||||
// Free surplus reservations
|
||||
$result = $this->ArtikelReservieren($position['artikel'],$lager,0,$position_menge_neu-$position['geliefert_menge'],'produktion',$produktion_id,$position['id'],"Produktion ".$produktion_alt['belegnr']);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user