stueckliste import moved to importvorlage

This commit is contained in:
OpenXE 2023-04-28 12:45:06 +02:00
parent b497d65d81
commit cd3c0f2113
6 changed files with 162 additions and 13 deletions

View File

@ -6090,7 +6090,7 @@ class Artikel extends GenArtikel {
$stueck = $this->app->erp->ArtikelAnzahlLagerStueckliste($id);
$this->ArtikelStuecklisteImport('TAB3');
// $this->ArtikelStuecklisteImport('TAB3');
$url = 'index.php?module=artikel&action=stueckliste&cmd=getbaum&id='.$id;
$this->app->Tpl->Set('URL',$url);
$this->app->Tpl->Add('TAB1',"<center>");
@ -6255,8 +6255,8 @@ class Artikel extends GenArtikel {
{
$id = $this->app->Secure->GetGET('id');
if($id > 0){
$result = $this->app->DB->SelectArr("SELECT a.nummer, a.name_de, a.hersteller,a.herstellernummer, REPLACE(TRIM(s.menge)+0,'.',',') as menge, s.referenz, s.place, s.layer, s.wert, s.bauform, s.zachse,s.xpos, s.ypos, s.art FROM stueckliste s
LEFT JOIN artikel a ON a.id=s.artikel WHERE s.stuecklistevonartikel='$id'");
$sql = "SELECT avon.nummer as stuecklistevon, a.nummer, a.name_de, a.hersteller,a.herstellernummer, REPLACE(TRIM(s.menge)+0,'.',',') as menge, s.referenz, s.place, s.layer, s.wert, s.bauform, s.zachse,s.xpos, s.ypos, s.art FROM stueckliste s LEFT JOIN artikel a ON a.id=s.artikel LEFT JOIN artikel avon ON avon.id=s.stuecklistevonartikel WHERE s.stuecklistevonartikel='$id'";
$result = $this->app->DB->SelectArr($sql);
}
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename=file.csv');

View File

@ -8,6 +8,7 @@
<li><a href="#tabs-5">{|Notizen|}</a></li>
<li><a href="#tabs-6">{|Kontenrahmen|}</a></li>
<li><a href="#tabs-7">{|Kontoauszug|}</a></li>
<li><a href="#tabs-8">{|St&uuml;ckliste|}</a></li>
</ul>
<div id="tabs-1">
@ -614,4 +615,81 @@
</div>
</div>
</div>
<div id="tabs-8">
<div class="row">
<div class="col-xs-12 col-sm-1 col-sm-height">
<div class="inside inside-full-height">
<fieldset><legend>{|St&uuml;ckliste|}</legend>
<table class="mkTable">
<tr>
<th>Variable</th>
<th>Beschreibung</th>
<th>Kommentar</th>
</tr>
<tr>
<td>stuecklistevonartikel</td>
<td>Hauptartikel (muss eine St&uuml;ckliste sein)</td>
<td>Artikelnummer</td>
</tr>
<tr>
<td>artikel</td>
<td></td>
<td>Artikelnummer</td>
</tr>
<tr>
<td>menge</td>
<td>Zahl</td>
<td></td>
</tr>
<tr>
<td>referenz</td>
<td>Text</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>place</td>
<td>Leer oder 'DNP' = Nicht platzieren</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>layer</td>
<td>"top" oder "bottom"</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>wert</td>
<td>Text</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>bauform</td>
<td>Text</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>zachse</td>
<td>Zahl</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>xpos</td>
<td>Zahl</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>ypos</td>
<td>Zahl</td>
<td>F&uuml;r Best&uuml;ckungen</td>
</tr>
<tr>
<td>art</td>
<td>Einkaufsteil "et",Informationsteil "it" oder Beistellung "bt"</td>
<td>Alternativposition?</td>
</tr>
</table>
</fieldset>
</div>
</div>
</div>
</div>
</div>

View File

@ -3,12 +3,6 @@
<div id="tabs">
<ul>
<li><a href="#tabs-1">&Uuml;bersicht</a></li>
<!--<li><a href="#tabs-2">neue Position anlegen</a></li>-->
<li><a href="#tabs-3">St&uuml;ckliste importieren</a></li>
</ul>
<!-- erstes tab -->
<div id="tabs-1">
[MESSAGE]

View File

@ -5,7 +5,7 @@
<ul>
<li><a href="#tabs-1">&Uuml;bersicht</a></li>
<li><a href="#tabs-2">neue Position anlegen</a></li>
<li><a href="#tabs-3">St&uuml;ckliste importieren</a></li>
<!-- DEPRECATED moved to importvorlage <li><a href="#tabs-3">St&uuml;ckliste importieren</a></li> -->
</ul>
<!-- erstes tab -->

View File

@ -5084,7 +5084,6 @@ class Importvorlage extends GenImportvorlage {
$allowed_fields = array('konto','buchung','betrag','betrag2','waehrung','buchungstext','buchungstext2','buchungstext3','buchungstext4');
$error = false;
// Create a row dataset (without checked and cmd)
$update_sql = "";
$row = array();
@ -5165,6 +5164,60 @@ class Importvorlage extends GenImportvorlage {
}
break;
case 'stueckliste':
$allowed_fields = array('stuecklistevonartikel','artikel','menge','art','referenz','layer','wert','bauform','xpos','ypos','zachse','place');
// Create a row dataset (without checked and cmd)
$row = array();
$error_text = "";
$error = $this->create_row_set($tmp, $i, $allowed_fields, $row, $error_text);
if ($error !== false) {
$sql = "SELECT id FROM artikel WHERE stueckliste = 1 AND nummer = '".$row['stuecklistevonartikel']."'";
$von_id = $this->app->DB->SelectArr($sql);
if (empty($von_id)) {
$msg .= "Fehlerhafter 'Stueckliste von'-Artikel \"".$row['stuecklistevonartikel']."\"<br>";
break;
}
$row['stuecklistevonartikel'] = $von_id[0]['id'];
$sql = "SELECT id FROM artikel WHERE nummer = '".$row['artikel']."'";
$artikel_id = $this->app->DB->SelectArr($sql);
if (empty($artikel_id)) {
$msg .= "Fehlerhafter Artikel \"".$row['artikel']."\"<br>";
break;
}
$row['artikel'] = $artikel_id[0]['id'];
if(empty($row['menge'])) {
$row['menge'] = 1;
}
if(empty($row['art'])) {
$row['art'] = 'et';
}
if(empty($row['place']) || $row['place'] == 'DNP') {
$row['place'] = 'DNP';
} else {
$row['place'] = 'DP';
}
$sql = "INSERT INTO stueckliste (".
implode(", ",array_keys($row)).
") VALUES ('".
implode("', '",array_values($row)).
"')";
$result = $this->app->DB->Update($sql);
} else if(!$first_checked) {
$first_checked = true;
$msg .= $error_text;
}
break;
}
// HERE END OF PROCESSING THE ROWS switch($ziel);
@ -6252,5 +6305,28 @@ class Importvorlage extends GenImportvorlage {
return $normalizedDate;
}
/*
* Create a cleaned row set
* Return true if ok, else see error_message
*/
private function create_row_set(array $tmp, $pos, array $allowed_fields, array &$result_row, string &$error_message) : bool {
$result_ok = true;
$result_row = array();
$error_message = "";
foreach ($tmp as $key => $value) {
if ($key != 'cmd' && $key != 'checked') {
if (in_array($key,$allowed_fields)) {
$result_row[$key] = $value[$pos];
} else {
$error_message .= "Feld nicht korrekt: ".$key.".<br>";
$result_ok = false;
}
}
}
return($result_ok);
}
}

View File

@ -80,6 +80,7 @@ class WidgetGenimportvorlage
$field->AddOption('Notizen (min. Angabe: datum,kundennummer,mitarbeiternummer,betreff)','notizen');
$field->AddOption('Kontenrahmen (min. Angabe: sachkonto,beschriftung,art)','kontorahmen');
$field->AddOption('Kontoauszug','kontoauszug');
$field->AddOption('St&uuml;ckliste','stueckliste');
$this->form->NewField($field);
$field = new HTMLInput("importerstezeilenummer","text","","15","","","","","","","","0","","");