mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
Bestellvorschlag now working
This commit is contained in:
parent
3c7e189acb
commit
f76400e248
@ -321,6 +321,86 @@ FROM
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'bestellungen_erzeugen':
|
||||
|
||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||
$selectedIds = [];
|
||||
|
||||
if(empty($auswahl)) {
|
||||
$msg = '<div class="error">Bitte Artikel auswählen.</div>';
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($auswahl)) {
|
||||
foreach ($auswahl as $selectedId) {
|
||||
$selectedId = (int) $selectedId;
|
||||
if ($selectedId > 0) {
|
||||
$selectedIds[] = $selectedId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$menge_input = $this->app->Secure->GetPOSTArray();
|
||||
$mengen = array();
|
||||
|
||||
foreach ($selectedIds as $artikel_id) {
|
||||
foreach ($menge_input as $key => $menge) {
|
||||
if ((strpos($key,'menge_') === 0) && ($menge !== '')) {
|
||||
$artikel = substr($key,'6');
|
||||
if ($menge > 0 && $artikel == $artikel_id) {
|
||||
$mengen[] = array('id' => $artikel,'menge' => $menge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mengen_pro_adresse = array();
|
||||
foreach ($mengen as $menge) {
|
||||
$sql = "SELECT adresse FROM artikel WHERE id = ".$menge['id'];
|
||||
$adresse = $this->app->DB->Select($sql);
|
||||
if (!empty($adresse)) {
|
||||
$index = array_search($adresse, array_column($mengen_pro_adresse,'adresse'));
|
||||
if ($index !== false) {
|
||||
$mengen_pro_adresse[$index]['positionen'][] = $menge;
|
||||
} else {
|
||||
$mengen_pro_adresse[] = array('adresse' => $adresse,'positionen' => array($menge));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$angelegt = 0;
|
||||
|
||||
foreach ($mengen_pro_adresse as $bestelladresse) {
|
||||
$bestellid = $this->app->erp->CreateBestellung($bestelladresse);
|
||||
if (!empty($bestellid)) {
|
||||
|
||||
$angelegt++;
|
||||
|
||||
$this->app->erp->LoadBestellungStandardwerte($bestellid,$bestelladresse['adresse']);
|
||||
$this->app->erp->BestellungProtokoll($bestellid,"Bestellung angelegt");
|
||||
foreach ($bestelladresse['positionen'] as $position) {
|
||||
$preisid = $this->app->erp->Einkaufspreis($position['id'], $position['menge'], $bestelladresse['adresse']);
|
||||
|
||||
if ($preisid == null) {
|
||||
$artikelohnepreis = $position['id'];
|
||||
} else {
|
||||
$artikelohnepreis = null;
|
||||
}
|
||||
|
||||
$this->app->erp->AddBestellungPosition(
|
||||
$bestellid,
|
||||
$preisid,
|
||||
$position['menge'],
|
||||
$datum,
|
||||
'',
|
||||
$artikelohnepreis
|
||||
);
|
||||
}
|
||||
$this->app->erp->BestellungNeuberechnen($bestellid);
|
||||
}
|
||||
}
|
||||
$msg .= "<div class=\"success\">Es wurden $angelegt Bestellungen angelegt.</div>";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=bestellvorschlag&action=list", "Übersicht");
|
||||
@ -331,6 +411,8 @@ FROM
|
||||
$this->app->Tpl->Set('MONATE_ABSATZ',$monate_absatz);
|
||||
$this->app->Tpl->Set('MONATE_VORAUS',$monate_voraus);
|
||||
|
||||
$this->app->Tpl->Set('MESSAGE',$msg);
|
||||
|
||||
$this->app->YUI->TableSearch('TAB1', 'bestellvorschlag_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
$this->app->Tpl->Parse('PAGE', "bestellvorschlag_list.tpl");
|
||||
}
|
||||
|
@ -1,80 +1,82 @@
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-4 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>{|Einstellungen|}</legend>
|
||||
<div id="tabs">
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<form action="" method="post">
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-4 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>{|Einstellungen|}</legend>
|
||||
|
||||
<td>{|Absatz berücksichtigen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_absatz" id="monate_absatz" value="[MONATE_ABSATZ]" size="20""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{|Vorausplanen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_voraus" id="monate_voraus" value="[MONATE_VORAUS]" size="20""></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-8 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-2 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>Aktionen</legend>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="loeschen">{|Zurücksetzen|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="speichern">{|Speichern|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name"submit" class="ui-button-icon" style="width:100%;" value="bestellungen_erzeugen">{|Bestellungen erzeugen|}</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-6 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
[TAB1]
|
||||
<fieldset>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" value="1" id="autoalle" /> alle markieren
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
[TAB1NEXT]
|
||||
<td>{|Absatz berücksichtigen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_absatz" id="monate_absatz" value="[MONATE_ABSATZ]" size="20""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{|Vorausplanen (Monate)|}:</td>
|
||||
<td><input type="number" min="0" name="monate_voraus" id="monate_voraus" value="[MONATE_VORAUS]" size="20""></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-8 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-14 col-md-2 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<table width="100%" border="0" class="mkTableFormular">
|
||||
<legend>Aktionen</legend>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="loeschen">{|Zurücksetzen|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="speichern">{|Speichern|}</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="bestellungen_erzeugen">{|Bestellungen erzeugen|}</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-14 col-md-6 col-md-height">
|
||||
<div class="inside inside-full-height">
|
||||
[TAB1]
|
||||
<fieldset>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" value="1" id="autoalle" /> alle markieren
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
[TAB1NEXT]
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
|
||||
$('#autoalle').on('change',function(){
|
||||
var wert = $(this).prop('checked');
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').prop('checked',wert);
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').first().trigger('change');
|
||||
});
|
||||
$('#autoalle').on('change',function(){
|
||||
var wert = $(this).prop('checked');
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').prop('checked',wert);
|
||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').first().trigger('change');
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user