mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-01-12 06:41:14 +01:00
Bestellvorschlag now working
This commit is contained in:
parent
3c7e189acb
commit
f76400e248
@ -321,6 +321,86 @@ FROM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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");
|
$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_ABSATZ',$monate_absatz);
|
||||||
$this->app->Tpl->Set('MONATE_VORAUS',$monate_voraus);
|
$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->YUI->TableSearch('TAB1', 'bestellvorschlag_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||||
$this->app->Tpl->Parse('PAGE', "bestellvorschlag_list.tpl");
|
$this->app->Tpl->Parse('PAGE', "bestellvorschlag_list.tpl");
|
||||||
}
|
}
|
||||||
|
@ -1,81 +1,83 @@
|
|||||||
<div id="tabs-1">
|
<div id="tabs">
|
||||||
[MESSAGE]
|
<div id="tabs-1">
|
||||||
<form action="" method="post">
|
[MESSAGE]
|
||||||
<div class="row">
|
<form action="" method="post">
|
||||||
<div class="row-height">
|
<div class="row">
|
||||||
<div class="col-xs-14 col-md-4 col-md-height">
|
<div class="row-height">
|
||||||
<div class="inside inside-full-height">
|
<div class="col-xs-14 col-md-4 col-md-height">
|
||||||
<fieldset>
|
<div class="inside inside-full-height">
|
||||||
<table width="100%" border="0" class="mkTableFormular">
|
<fieldset>
|
||||||
<legend>{|Einstellungen|}</legend>
|
<table width="100%" border="0" class="mkTableFormular">
|
||||||
|
<legend>{|Einstellungen|}</legend>
|
||||||
|
|
||||||
<td>{|Absatz berücksichtigen (Monate)|}:</td>
|
<td>{|Absatz berücksichtigen (Monate)|}:</td>
|
||||||
<td><input type="number" min="0" name="monate_absatz" id="monate_absatz" value="[MONATE_ABSATZ]" size="20""></td>
|
<td><input type="number" min="0" name="monate_absatz" id="monate_absatz" value="[MONATE_ABSATZ]" size="20""></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{|Vorausplanen (Monate)|}:</td>
|
<td>{|Vorausplanen (Monate)|}:</td>
|
||||||
<td><input type="number" min="0" name="monate_voraus" id="monate_voraus" value="[MONATE_VORAUS]" size="20""></td>
|
<td><input type="number" min="0" name="monate_voraus" id="monate_voraus" value="[MONATE_VORAUS]" size="20""></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-14 col-md-8 col-md-height">
|
<div class="col-xs-14 col-md-8 col-md-height">
|
||||||
<div class="inside inside-full-height">
|
<div class="inside inside-full-height">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-14 col-md-2 col-md-height">
|
<div class="col-xs-14 col-md-2 col-md-height">
|
||||||
<div class="inside inside-full-height">
|
<div class="inside inside-full-height">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<table width="100%" border="0" class="mkTableFormular">
|
<table width="100%" border="0" class="mkTableFormular">
|
||||||
<legend>Aktionen</legend>
|
<legend>Aktionen</legend>
|
||||||
<tr>
|
<tr>
|
||||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="loeschen">{|Zurücksetzen|}</button></td>
|
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="loeschen">{|Zurücksetzen|}</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="speichern">{|Speichern|}</button></td>
|
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="speichern">{|Speichern|}</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><button name"submit" class="ui-button-icon" style="width:100%;" value="bestellungen_erzeugen">{|Bestellungen erzeugen|}</button></td>
|
<td><button name="submit" class="ui-button-icon" style="width:100%;" value="bestellungen_erzeugen">{|Bestellungen erzeugen|}</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row-height">
|
<div class="row-height">
|
||||||
<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">
|
||||||
[TAB1]
|
[TAB1]
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" value="1" id="autoalle" /> alle markieren
|
<input type="checkbox" value="1" id="autoalle" /> alle markieren
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
[TAB1NEXT]
|
[TAB1NEXT]
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$('#autoalle').on('change',function(){
|
$('#autoalle').on('change',function(){
|
||||||
var wert = $(this).prop('checked');
|
var wert = $(this).prop('checked');
|
||||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').prop('checked',wert);
|
$('#bestellvorschlag_list').find('input[type="checkbox"]').prop('checked',wert);
|
||||||
$('#bestellvorschlag_list').find('input[type="checkbox"]').first().trigger('change');
|
$('#bestellvorschlag_list').find('input[type="checkbox"]').first().trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user