RETROTEC-AG/OpenXE#18 Number parser implementieren
This commit is contained in:
parent
23d61dd5f4
commit
bd4ca4675b
|
|
@ -41,13 +41,14 @@ class FormatterService
|
|||
* Factory for FormatterInterface objects. There will be a FormatterInterface object for every data type
|
||||
* necessary.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $type
|
||||
* @param FormatterMode $strictness
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*/
|
||||
public function factory(string $type): FormatterInterface
|
||||
public function factory(string $type, FormatterMode $strictness = FormatterMode::MODE_STRICT): FormatterInterface
|
||||
{
|
||||
return new $type($this->locale);
|
||||
return new $type($this->locale, $strictness);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -55,13 +56,14 @@ class FormatterService
|
|||
/**
|
||||
* Shortcut function for creating a FloatFormatter and parsing a user input.
|
||||
*
|
||||
* @param string $input
|
||||
* @param string $input
|
||||
* @param FormatterMode $strictness
|
||||
*
|
||||
* @return FloatFormatter
|
||||
*/
|
||||
public function floatFromUserInput(string $input): FloatFormatter
|
||||
public function floatFromUserInput(string $input, FormatterMode $strictness=FormatterMode::MODE_NULL): FloatFormatter
|
||||
{
|
||||
$formatter = new FloatFormatter($this->locale);
|
||||
$formatter = new FloatFormatter($this->locale, $strictness);
|
||||
$formatter->parseUserInput($input);
|
||||
return $formatter;
|
||||
}
|
||||
|
|
@ -71,13 +73,14 @@ class FormatterService
|
|||
/**
|
||||
* Shortcut function for creating a FloatFormatter and setting a PHP value.
|
||||
*
|
||||
* @param float $input
|
||||
* @param string|float|null $input
|
||||
* @param FormatterMode $strictness
|
||||
*
|
||||
* @return FloatFormatter
|
||||
*/
|
||||
public function floatFromPhpVal(float $input): FloatFormatter
|
||||
public function floatFromPhpVal(string|null|float $input, FormatterMode $strictness=FormatterMode::MODE_NULL): FloatFormatter
|
||||
{
|
||||
$formatter = $this->factory(FloatFormatter::class);
|
||||
$formatter = $this->factory(FloatFormatter::class, $strictness);
|
||||
$formatter->setPhpVal($input);
|
||||
return $formatter;
|
||||
}
|
||||
|
|
@ -248,4 +251,69 @@ class FormatterService
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Format a quantity value for output.
|
||||
*
|
||||
* @param mixed $menge
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatMenge(mixed $menge): string
|
||||
{
|
||||
$formatter = new FloatFormatter($this->locale, FormatterMode::MODE_EMPTY);
|
||||
$formatter->setPhpVal(floatval($menge));
|
||||
return $formatter->formatForUser();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse a quantity from a form and parse for database input.
|
||||
*
|
||||
* @param mixed $string
|
||||
*
|
||||
* @return string|float|null
|
||||
*/
|
||||
public function parseMenge(mixed $string): string|null|float
|
||||
{
|
||||
$formatter = new FloatFormatter($this->locale, FormatterMode::MODE_EMPTY);
|
||||
$formatter->parseUserInput(strval($string));
|
||||
return $formatter->getPhpVal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format a price value for output.
|
||||
*
|
||||
* @param mixed $menge
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatPreis(mixed $menge): string
|
||||
{
|
||||
$formatter = new FloatFormatter($this->locale, FormatterMode::MODE_EMPTY);
|
||||
$formatter->setMinDigits(2);
|
||||
$formatter->setPhpVal(floatval($menge));
|
||||
return $formatter->formatForUser();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse a price from a form and parse for database input.
|
||||
*
|
||||
* @param mixed $string
|
||||
*
|
||||
* @return string|float|null
|
||||
*/
|
||||
public function parsePreis(mixed $string): string|null|float
|
||||
{
|
||||
$formatter = new FloatFormatter($this->locale, FormatterMode::MODE_EMPTY);
|
||||
$formatter->setMinDigits(2);
|
||||
$formatter->parseUserInput(strval($string));
|
||||
return $formatter->getPhpVal();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -449,12 +449,6 @@ class YUI {
|
|||
break;
|
||||
case 2: // Betrag
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
$this->app->DB->Update("UPDATE $table SET betrag='$value' WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->FormatPreis('betrag')." FROM $table WHERE id='$id' LIMIT 1");
|
||||
break;
|
||||
|
|
@ -476,19 +470,12 @@ class YUI {
|
|||
|
||||
case 2: // Menge
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
$value = str_replace(",", ".", $value);
|
||||
$this->app->DB->Update("UPDATE $table SET menge='$value' WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->app->erp->FormatMenge("menge")." FROM $table WHERE id='$id' LIMIT 1");
|
||||
break;
|
||||
|
||||
case 3: // Betrag
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
$this->app->DB->Update("UPDATE $table SET betrag='$value' WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->FormatPreis('betrag')." FROM $table WHERE id='$id' LIMIT 1");
|
||||
break;
|
||||
|
|
@ -519,12 +506,6 @@ class YUI {
|
|||
break;
|
||||
case 4: // preis
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
$this->app->DB->Update("UPDATE $table SET preis='$value' WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->FormatPreis('preis')." FROM $table WHERE id='$id' LIMIT 1");
|
||||
break;
|
||||
|
|
@ -544,7 +525,6 @@ class YUI {
|
|||
break;
|
||||
case 4: // Menge
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
$value = str_replace(',', '.', $value);
|
||||
if($value < 0 ) {
|
||||
$value=1;
|
||||
}
|
||||
|
|
@ -650,12 +630,6 @@ class YUI {
|
|||
break;
|
||||
case 5: //preis
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
$join = "";
|
||||
$preiscell = 'b.preis';
|
||||
if($module == 'auftrag' || $module == 'rechnung' || $module == 'gutschrift' || $module == 'angebot' || $module == 'proformarechnung')
|
||||
|
|
@ -718,12 +692,6 @@ class YUI {
|
|||
if($module == 'auftrag' || $module == 'rechnung' || $module == 'angebot' || $module == 'gutschrift' || $module == 'proformarechnung')
|
||||
{
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
if($value == '')$value = '0';
|
||||
$this->app->DB->Update("UPDATE $table SET rabatt='$value',keinrabatterlaubt=1 WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->FormatPreis('rabatt')." FROM $table WHERE id='$id' LIMIT 1");
|
||||
|
|
@ -741,13 +709,6 @@ class YUI {
|
|||
if($module == 'auftrag' || $module == 'rechnung' || $module == 'angebot' || $module == 'gutschrift' )
|
||||
{
|
||||
$value = $this->app->erp->FromFormatZahlToDB($value);
|
||||
if(strpos($value,','))
|
||||
{
|
||||
$value = str_replace(",", ".",str_replace('.','', $value));
|
||||
}else{
|
||||
$value = str_replace(",", ".", $value);
|
||||
}
|
||||
if($value == '')$value = '0';
|
||||
$this->app->DB->Update("UPDATE $table SET einkaufspreis='$value' WHERE id='$id' LIMIT 1");
|
||||
$result = $this->app->DB->Select("SELECT ".$this->FormatPreis('einkaufspreis')." FROM $table WHERE id='$id' LIMIT 1");
|
||||
}
|
||||
|
|
@ -1552,30 +1513,22 @@ class YUI {
|
|||
$module, $id, implode(', ', array_unique($positionsIds))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs=$this->app->Container->get('FormatterService');
|
||||
|
||||
if(!empty($positions)) {
|
||||
foreach($positions as $position) {
|
||||
$positionId = $position['id'];
|
||||
if(isset($idToPrice[$positionId])
|
||||
&& $position['preis'] != $idToPrice[$positionId]
|
||||
) {
|
||||
$price = rtrim(number_format($position['preis'], 8, ',', '.'), '0');
|
||||
$priceSplit = explode(',', $price);
|
||||
if(strlen($priceSplit[(empty($priceSplit)?0:count($priceSplit))-1]) < 2) {
|
||||
$price .= str_repeat('0',2-strlen($priceSplit[(empty($priceSplit)?0:count($priceSplit))-1]));
|
||||
}
|
||||
$ret[] = ['elid' => $arr[$positionId]['price_id'], 'value' => $price];
|
||||
$ret[] = ['elid' => $arr[$positionId]['price_id'], 'value' => $fs->formatPreis($position['preis'])];
|
||||
}
|
||||
if(isset($idToQuantity[$positionId])
|
||||
&& $position['menge'] != $idToQuantity[$positionId]
|
||||
) {
|
||||
$quantity = rtrim(number_format($position['menge'], 8, ',', ''), '0');
|
||||
$quantitySplit = explode(',', $quantity);
|
||||
if(isset($quantitySplit[1]) && $quantitySplit[1] === '') {
|
||||
$quantity = $quantitySplit[0];
|
||||
}
|
||||
|
||||
$ret[] = ['elid'=> $arr[$positionId]['quantity_id'], 'value' => $quantity];
|
||||
$ret[] = ['elid'=> $arr[$positionId]['quantity_id'], 'value' => $fs->formatMenge($position['menge'])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1781,9 +1734,7 @@ class YUI {
|
|||
$preis = $this->app->Secure->GetPOST("preis");
|
||||
$preis = $this->app->erp->FromFormatZahlToDB($preis);
|
||||
$menge = $this->app->Secure->GetPOST("menge");
|
||||
//$menge = str_replace(',', '.', $menge);
|
||||
$menge= $this->app->erp->FromFormatZahlToDB($menge);
|
||||
|
||||
if($menge < 0) $menge = 1;
|
||||
|
||||
$ort = $this->app->Secure->GetPOST("ort");
|
||||
|
|
@ -1791,8 +1742,7 @@ class YUI {
|
|||
$lieferdatum = $this->app->String->Convert($lieferdatum, "%1.%2.%3", "%3-%2-%1");
|
||||
$datum = $this->app->Secure->GetPOST("datum");
|
||||
$datum = $this->app->String->Convert($datum, "%1.%2.%3", "%3-%2-%1");
|
||||
$rabatt = $this->app->Secure->GetPOST("rabatt");
|
||||
$rabatt = str_replace(',', '.', $rabatt);
|
||||
$rabatt = $this->app->erp->FromFormatZahlToDB($this->app->Secure->GetPOST("rabatt"));
|
||||
if($rabatt > 0 || $rabatt=="0") $keinrabatterlaubt=1; else $keinrabatterlaubt=0;
|
||||
|
||||
if ($lieferdatum == "") $lieferdatum = "00.00.0000";
|
||||
|
|
@ -1970,8 +1920,7 @@ class YUI {
|
|||
$artikel = $this->app->Secure->GetPOST("artikel");
|
||||
$stueckliste = $this->app->Secure->GetPOST("stueckliste");
|
||||
$beschreibung = $this->app->Secure->GetPOST("beschreibung");
|
||||
$betrag = $this->app->Secure->GetPOST("betrag");
|
||||
$betrag = str_replace(',', '.', $betrag);
|
||||
$betrag = $this->app->erp->FromFormatZahlToDB($this->app->Secure->GetPOST("betrag"));
|
||||
$kalkulationart = $this->app->Secure->GetPOST("kalkulationart");
|
||||
|
||||
//$projekt = $this->app->DB->Select("SELECT projekt FROM kalkulation WHERE mitarbeiternummer='$adresse' LIMIT 1");
|
||||
|
|
@ -2004,8 +1953,7 @@ class YUI {
|
|||
|
||||
if ($module == "reisekosten") {
|
||||
$bezeichnung = $this->app->Secure->GetPOST("bezeichnung");
|
||||
$betrag = $this->app->Secure->GetPOST("betrag");
|
||||
$betrag = str_replace(',', '.', $betrag);
|
||||
$betrag = $this->app->erp->FromFormatZahlToDB($this->app->Secure->GetPOST("betrag"));
|
||||
$reisekostenart = $this->app->Secure->GetPOST("reisekostenart");
|
||||
$abrechnen = $this->app->Secure->GetPOST("abrechnen");
|
||||
$keineust = $this->app->Secure->GetPOST("keineust");
|
||||
|
|
@ -2023,8 +1971,7 @@ class YUI {
|
|||
} else
|
||||
if ($module == "inventur" && $artikel_id > 0) {
|
||||
$bezeichnung = $this->app->Secure->GetPOST("artikel");
|
||||
$preis = $this->app->Secure->GetPOST("preis");
|
||||
$preis = str_replace(',', '.', $preis);
|
||||
$preis = $this->app->erp->FromFormatZahlToDB($this->app->Secure->GetPOST("preis"));
|
||||
$nummer = $this->app->Secure->GetPOST("nummer");
|
||||
|
||||
/*adresse = $this->app->Secure->GetPOST("adresse");
|
||||
|
|
@ -2046,8 +1993,7 @@ class YUI {
|
|||
|
||||
/*
|
||||
$bezeichnung = $this->app->Secure->GetPOST("artikel");
|
||||
$preis = $this->app->Secure->GetPOST("preis");
|
||||
$preis = str_replace(',','.',$preis);
|
||||
$preis = $this->app->erp->FromFormatZahlToDB($this->app->Secure->GetPOST("preis"));
|
||||
$nummer = $this->app->Secure->GetPOST("nummer");
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1452,30 +1452,24 @@ public function NavigationHooks(&$menu)
|
|||
if(is_null($stellen))return "if(trim(round( $spalte *100))+0 <> trim($spalte*100)+0, format($spalte, length( trim($spalte)+0)-length(round($spalte))-1 ".($punkt?"":" ,'de_DE'")."),format($spalte,2".($punkt?"":" ,'de_DE'")."))";
|
||||
return "format($spalte,$stellen".($punkt?"":" ,'de_DE'").")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Wandelt eine Formatierte Zahl in das Format für die Datenbank um.
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return mixed
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
function FromFormatZahlToDB($value)
|
||||
{
|
||||
$poskomma = strrpos($value, ',');
|
||||
$pospunkt = strrpos($value, '.');
|
||||
if($poskomma === false) {
|
||||
return $value;
|
||||
}
|
||||
if($pospunkt === false) {
|
||||
return str_replace(',','.', $value);
|
||||
}
|
||||
|
||||
if($poskomma > $pospunkt) {
|
||||
return str_replace(['.', ','], ['', '.'], $value);
|
||||
}
|
||||
|
||||
return str_replace(',','', $value);
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
$number = $fs->floatFromUserInput(strval($value));
|
||||
return $number->getPhpVal();
|
||||
}
|
||||
|
||||
// @refactor Formater Komponente
|
||||
|
|
@ -1508,13 +1502,28 @@ public function NavigationHooks(&$menu)
|
|||
}
|
||||
return $prefix.'.'.'belegnr';
|
||||
}
|
||||
|
||||
// @refactor DbHelper Komponente
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Erstelle die lokalisierten Formatierungsanweisungen für das SQL-Query.
|
||||
* Wird and folgenden Stellen benutzt:
|
||||
* -\Artikel::TableSearch()
|
||||
*
|
||||
* @param $spalte
|
||||
* @param $decimals
|
||||
*
|
||||
* @return mixed
|
||||
* @deprecated Es wäre besser, die Formatierung in PHP zu machen
|
||||
*
|
||||
*/
|
||||
|
||||
function FormatMenge($spalte, $decimals = 0)
|
||||
{
|
||||
return ('FORMAT('.$spalte.','.$decimals.',\'de_DE\')');
|
||||
|
||||
// return "replace(trim($spalte)+0,'.',',')";
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fn */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
$number = $fs->factory(\Xentral\Components\I18n\Formatter\FloatFormatter::class);
|
||||
return $number->setMinDigits($decimals)->formatForUserWithSqlStatement($spalte);
|
||||
}
|
||||
|
||||
function FormatUCfirst($spalte)
|
||||
|
|
@ -12131,14 +12140,14 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
$this->app->Tpl->Add($target, $html);
|
||||
}
|
||||
|
||||
/**@deprecated**/
|
||||
/**@deprected**/
|
||||
function HelpIcon()
|
||||
{
|
||||
$module = $this->app->Secure->GetGET("module");
|
||||
$action = $this->app->Secure->GetGET("action");
|
||||
}
|
||||
|
||||
/**@deprecated**/
|
||||
/**@deprected**/
|
||||
function PrinterIcon()
|
||||
{
|
||||
// $this->app->Tpl->Add('TABSPRINT'," <a style=\"color:white;font-size:9pt\" href=\"#\" onclick=\"wawisionPrint();\"><img src=\"./themes/new/images/icons_druck.png\" height=\"18\"></a>");
|
||||
|
|
@ -12769,12 +12778,21 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
return $obj->LieferscheinCheck($lieferschein);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @refactor Formater Komponente
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formatiert den $betrag als Währungs-Ausgabe-String.
|
||||
*
|
||||
* @param $betrag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function EUR($betrag)
|
||||
{
|
||||
return number_format($betrag,2,',','.');
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
return $fs->formatPreis($betrag);
|
||||
}
|
||||
|
||||
// @refactor Adresse Modul
|
||||
|
|
@ -12795,36 +12813,30 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
|
||||
return $kreditlimit >= ($rechnungen+$auftraege);
|
||||
}
|
||||
|
||||
// @refactor FormHelper Komponente
|
||||
public function ReplaceBetrag($db,$value,$fromform = null)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formatiert bzw. parst einen Geldbetrag für die Ausgabe im Formular oder die Speicherung in der DB.
|
||||
*
|
||||
* @param $db Richtung (true=Speichern in DB, false=Ausgabe im Formular)
|
||||
* @param $value
|
||||
* @param $fromform
|
||||
*
|
||||
* @return float|mixed|string
|
||||
*/
|
||||
public function ReplaceBetrag($db, $value, $fromform = null)
|
||||
{
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
|
||||
// wenn ziel datenbank
|
||||
if($db)
|
||||
{
|
||||
// wenn . und , vorhanden dann entferne punkt
|
||||
$pos_punkt = strrpos($value, '.');
|
||||
$pos_komma = strrpos($value, ',');
|
||||
if(($pos_punkt !== false) && ($pos_komma !== false)){
|
||||
if($pos_punkt < $pos_komma){
|
||||
$value = str_replace('.', '', $value);
|
||||
}else{
|
||||
$value = str_replace(',', '', $value);
|
||||
}
|
||||
}
|
||||
return str_replace(',','.',$value);
|
||||
if ($db) {
|
||||
return $fs->parsePreis($value);
|
||||
}
|
||||
|
||||
// wenn ziel formular
|
||||
|
||||
if ($value != "") {
|
||||
//return $abkuerzung;
|
||||
|
||||
if($value == round((float) $value, 2)) {
|
||||
return number_format((float)$value,2,',','');
|
||||
}
|
||||
}
|
||||
|
||||
return rtrim(str_replace('.',',',$value),'0');
|
||||
return $fs->formatPreis($value);
|
||||
}
|
||||
|
||||
// @refactor FormHelper Komponente
|
||||
|
|
@ -13052,83 +13064,63 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
// @refactor FormHelper Komponente
|
||||
function ReplaceMenge($db,$value,$fromform)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formatiert bzw. parst eine Menge für die Ausgabe im Formular oder die Speicherung in der DB.
|
||||
*
|
||||
* @param $db Richtung (true=Speichern in DB, false=Ausgabe im Formular)
|
||||
* @param $value
|
||||
* @param $fromform
|
||||
*
|
||||
* @return float|mixed|string
|
||||
*/
|
||||
function ReplaceMenge($db, $value, $fromform)
|
||||
{
|
||||
$tcheck = str_replace(',','.',$value);
|
||||
if($tcheck < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
$dbformat = 0;
|
||||
if(strpos($value,'.') > 0) {
|
||||
$dbformat = 1;
|
||||
}
|
||||
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
|
||||
// wenn ziel datenbank
|
||||
if($db)
|
||||
{
|
||||
if($dbformat) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if($value!=''){
|
||||
return str_replace(',', '.', $value);
|
||||
}
|
||||
|
||||
return '';
|
||||
if ($db) {
|
||||
return $fs->parseMenge($value);
|
||||
}
|
||||
|
||||
// wenn ziel formular
|
||||
if(strpos($value,'.') !== false)
|
||||
{
|
||||
$value = rtrim(rtrim($value,'0'),'.');
|
||||
if($value[0] === '.') {
|
||||
$value = '0'.$value;
|
||||
}
|
||||
}
|
||||
if($dbformat) {
|
||||
if($value!='') {
|
||||
return str_replace('.',',',$value);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $fs->formatMenge($value);
|
||||
}
|
||||
|
||||
// @refactor FormHelper Komponente
|
||||
function ReplaceDecimal($db,$value,$fromform)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formatiert bzw. parst eine Zahl für die Ausgabe im Formular oder die Speicherung in der DB.
|
||||
*
|
||||
* @param $db Richtung (true=Speichern in DB, false=Ausgabe im Formular)
|
||||
* @param $value
|
||||
* @param $fromform
|
||||
*
|
||||
* @return array|mixed|string|string[]
|
||||
*/
|
||||
function ReplaceDecimal($db, $value, $fromform)
|
||||
{
|
||||
//value muss hier vom format ueberprueft werden
|
||||
$dbformat = 0;
|
||||
if(strpos($value,'.') > 0) {
|
||||
$dbformat = 1;
|
||||
}
|
||||
|
||||
/** @var \Xentral\Components\I18n\FormatterService $fs */
|
||||
$fs = $this->app->Container->get('FormatterService');
|
||||
|
||||
// wenn ziel datenbank
|
||||
if($db)
|
||||
{
|
||||
if($dbformat) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if($value!=''){
|
||||
return str_replace(',', '.', $value);
|
||||
}
|
||||
return '';
|
||||
if ($db) {
|
||||
$floatFormatter = $fs->floatFromUserInput(strval($value));
|
||||
return $floatFormatter->getPhpVal();
|
||||
}
|
||||
|
||||
// wenn ziel formular
|
||||
|
||||
if($dbformat) {
|
||||
if($value!='') {
|
||||
return $value;
|
||||
}
|
||||
return '';
|
||||
if (is_numeric($value)) {
|
||||
$floatFormatter = $fs->floatFromPhpVal(floatval($value));
|
||||
return $floatFormatter->formatForUser();
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
// Soweit sollte es gar nicht kommen
|
||||
// TODO: soll hier eine Exception geworfen werden?
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -13856,7 +13848,7 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
}
|
||||
}
|
||||
|
||||
/**@deprecated */
|
||||
/**@depreacated */
|
||||
function CheckSamePage()
|
||||
{
|
||||
$id = $this->app->Secure->GetGET("id");
|
||||
|
|
@ -13868,7 +13860,7 @@ function SendPaypalFromAuftrag($auftrag, $test = false)
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @depreacated
|
||||
* @refactor Artikel Modul
|
||||
*/
|
||||
function SeitenSperrAuswahl($ueberschrift,$meldung)
|
||||
|
|
@ -13911,7 +13903,7 @@ $( this ).dialog( "close" );
|
|||
');
|
||||
}
|
||||
|
||||
/**@deprecated */
|
||||
/**@depreacated */
|
||||
function SeitenSperrInfo($meldung)
|
||||
{
|
||||
$this->app->Tpl->Set('SPERRMELDUNG', '$("a#inline").fancybox({
|
||||
|
|
@ -24944,7 +24936,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
|
|||
}
|
||||
$ansprechpartner = str_replace('<','<',$ansprechpartner);
|
||||
$ansprechpartner = str_replace('>','>',$ansprechpartner);
|
||||
list($name, $email) = explode('<', trim($ansprechpartner,'>'));
|
||||
[$name, $email] = explode('<', trim($ansprechpartner,'>'));
|
||||
|
||||
$betreff = str_replace('\"','"',$betreff);
|
||||
$betreff = str_replace("\'","'",$betreff);
|
||||
|
|
@ -27759,7 +27751,7 @@ function Firmendaten($field,$projekt="")
|
|||
return $ret;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
/** @depracated */
|
||||
function GetPrioTicketSelect($prio)
|
||||
{
|
||||
$prios = array('4'=>'niedrig','3'=>'normal','2'=>'hoch');
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ include '_gen/artikel.php';
|
|||
class Artikel extends GenArtikel {
|
||||
/** @var Application $app */
|
||||
var $app;
|
||||
protected \Xentral\Components\I18n\FormatterService $formatterService;
|
||||
const MODULE_NAME = 'Article';
|
||||
|
||||
public function TableSearch($app, $name, $erlaubtevars)
|
||||
|
|
@ -938,10 +939,10 @@ class Artikel extends GenArtikel {
|
|||
IF(s.art='it','<br><i style=color:#999>- Informationsteil/Dienstleistung</i>',''),IF(s.art='bt','<br><i style=color:#999>- Beistellung</i>',''), COALESCE((SELECT GROUP_CONCAT('<br><i style=color:#999>- ', art.nummer, ' ', art.name_de, ' (', alt.reason, ')', '</i>' SEPARATOR '') FROM parts_list_alternative AS alt INNER JOIN artikel AS art ON art.id = alt.alternative_article_id WHERE alt.parts_list_id = s.id), '')) as artikel,
|
||||
CONCAT('<a href=\"index.php?module=artikel&action=edit&id=',a.id,'\" target=\"_blank\">',a.nummer,'</a>') as nummer,
|
||||
s.referenz,
|
||||
trim(s.menge)+0 as menge, a.einheit,
|
||||
".$this->app->erp->FormatMenge('ifnull(lag.menge,0)').' as lager,
|
||||
{$this->app->erp->FormatMenge('s.menge')} as menge, a.einheit,
|
||||
{$this->app->erp->FormatMenge('ifnull(lag.menge,0)')} as lager,
|
||||
CASE WHEN (SELECT SUM(lr.menge) FROM lager_reserviert lr WHERE lr.artikel=a.id) > 0
|
||||
THEN (SELECT '.$this->app->erp->FormatMenge('SUM(lr.menge)')." FROM lager_reserviert lr WHERE lr.artikel=a.id)
|
||||
THEN (SELECT {$this->app->erp->FormatMenge('SUM(lr.menge)')} FROM lager_reserviert lr WHERE lr.artikel=a.id)
|
||||
ELSE 0
|
||||
END as reserviert,
|
||||
s.id as menu
|
||||
|
|
@ -952,7 +953,7 @@ class Artikel extends GenArtikel {
|
|||
INNER JOIN (
|
||||
SELECT artikel
|
||||
FROM stueckliste
|
||||
WHERE stuecklistevonartikel='$id' GROUP BY artikel
|
||||
WHERE stuecklistevonartikel='{$id}' GROUP BY artikel
|
||||
) AS s2 ON lpi.artikel = s2.artikel
|
||||
INNER JOIN lager_platz AS lp ON lpi.lager_platz = lp.id AND ifnull(lp.sperrlager,0) = 0
|
||||
GROUP BY lpi.artikel) AS lag ON a.id = lag.artikel
|
||||
|
|
@ -1871,6 +1872,9 @@ class Artikel extends GenArtikel {
|
|||
public function __construct($app, $intern = false) {
|
||||
//parent::GenArtikel($app);
|
||||
$this->app=$app;
|
||||
|
||||
$this->formatterService = $this->app->Container->get('FormatterService');
|
||||
|
||||
if($intern){
|
||||
return;
|
||||
}
|
||||
|
|
@ -6003,7 +6007,8 @@ class Artikel extends GenArtikel {
|
|||
$name = 'node'.$k;
|
||||
$$name = new stdClass();
|
||||
$$name->id = $v['id'];
|
||||
$$name->label = ' '.$v['menge'].' x <a target="_blank" href="index.php?module=artikel&action=edit&id='.$v['artikel'].'">'.$v['nummer'].' '.(strlen($v['name_de']) < 30?$v['name_de']:(mb_substr($v['name_de'],0,27).'...')).'</a>';
|
||||
$$name->label = " {$this->formatterService->formatMenge($v['menge'])} x "
|
||||
. '<a target="_blank" href="index.php?module=artikel&action=edit&id='.$v['artikel'].'">'.$v['nummer'].' '.(strlen($v['name_de']) < 30?$v['name_de']:(mb_substr($v['name_de'],0,27).'...')).'</a>';
|
||||
$$name->checkbox = false;
|
||||
$$name->inode = false;
|
||||
$$name->radio = false;
|
||||
|
|
@ -6035,7 +6040,8 @@ class Artikel extends GenArtikel {
|
|||
$name = 'node'.$k;
|
||||
$$name = new stdClass();
|
||||
$$name->id = $v['id'];
|
||||
$$name->label = ' '.$v['menge'].' x <a target="_blank" href="index.php?module=artikel&action=edit&id='.$v['artikel'].'">'.$v['nummer'].' '.(strlen($v['name_de']) < 30?$v['name_de']:(mb_substr($v['name_de'],0,27).'...')).'</a>';
|
||||
$$name->label = " {$this->formatterService->formatMenge($v['menge'])} x "
|
||||
. '<a target="_blank" href="index.php?module=artikel&action=edit&id='.$v['artikel'].'">'.$v['nummer'].' '.(strlen($v['name_de']) < 30?$v['name_de']:(mb_substr($v['name_de'],0,27).'...')).'</a>';
|
||||
$$name->checkbox = false;
|
||||
$$name->inode = false;
|
||||
$$name->radio = false;
|
||||
|
|
@ -6321,7 +6327,7 @@ class Artikel extends GenArtikel {
|
|||
|
||||
$id = (int)$this->app->Secure->GetPOST('id');
|
||||
|
||||
$data = $this->app->DB->SelectRow("SELECT s.id, s.artikel, trim(s.menge)+0 as menge, s.art, s.referenz, s.layer, s.place, s.wert, s.bauform, s.zachse, s.xpos, s.ypos FROM stueckliste s WHERE s.id = '$id' LIMIT 1");
|
||||
$data = $this->app->DB->SelectRow("SELECT s.id, s.artikel, s.menge, s.art, s.referenz, s.layer, s.place, s.wert, s.bauform, s.zachse, s.xpos, s.ypos FROM stueckliste s WHERE s.id = '{$id}' LIMIT 1");
|
||||
|
||||
if($data){
|
||||
if($data['artikel'] == 0){
|
||||
|
|
@ -6349,7 +6355,8 @@ class Artikel extends GenArtikel {
|
|||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
$data['menge'] = $this->formatterService->formatMenge($data['menge']);
|
||||
|
||||
}else{
|
||||
$data['id'] = 0;
|
||||
|
|
@ -6378,7 +6385,7 @@ class Artikel extends GenArtikel {
|
|||
$id = (int)$this->app->Secure->GetPOST('eid');
|
||||
$startikelid = (int)$this->app->Secure->GetPOST('estartikelid');
|
||||
$artikel = trim($this->app->Secure->GetPOST('eartikel'));
|
||||
$menge = str_replace(',','.',trim($this->app->Secure->GetPOST('emenge')));
|
||||
$menge = $this->formatterService->parseMenge($this->app->Secure->GetPOST('emenge'));
|
||||
$art = trim($this->app->Secure->GetPOST('eart'));
|
||||
//$alternative = trim($this->app->Secure->GetPOST('ealternative'));
|
||||
$referenz = trim($this->app->Secure->GetPOST('ereferenz'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue