mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Waehrumgumrechnung module restored
This commit is contained in:
parent
3d8c7a13e3
commit
aff5eef945
@ -1503,9 +1503,11 @@ public function NavigationHooks(&$menu)
|
||||
}
|
||||
|
||||
// @refactor DbHelper Komponente
|
||||
function FormatMenge($spalte)
|
||||
function FormatMenge($spalte, $decimals = 8)
|
||||
{
|
||||
return "replace(trim($spalte)+0,'.',',')";
|
||||
return ('FORMAT('.$spalte.','.$decimals.',\'de_DE\')');
|
||||
|
||||
// return "replace(trim($spalte)+0,'.',',')";
|
||||
}
|
||||
|
||||
static function add_alias(string $text, $alias = false) {
|
||||
@ -7131,6 +7133,7 @@ title: 'Abschicken',
|
||||
}
|
||||
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Import/Export Zentrale','importvorlage','uebersicht');
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Währungen','waehrungumrechnung','list');
|
||||
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Seriennummern','seriennummern','list');
|
||||
$navarray['menu']['admin'][$menu]['sec'][] = array('Chargen','chargen','list');
|
||||
@ -28853,12 +28856,6 @@ function Firmendaten($field,$projekt="")
|
||||
{
|
||||
return $obj->GetWaehrungUmrechnungskurs($von,$nach,$onlytable);
|
||||
}
|
||||
if ($von === 'EUR' && $nach === 'USD') {
|
||||
return 1.20;
|
||||
}
|
||||
if ($von==='EUR' && $nach==='CHF') {
|
||||
return 1.06;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,11 @@
|
||||
<fieldset><legend>{|Umrechnung|}</legend>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td>
|
||||
<table align="center" border="0" cellspacing="0" cellpadding="3">
|
||||
<tr><td>Währung von</td><td><input type="text" name="waehrung_von" value="[WAEHRUNG_VON]" /></td></tr>
|
||||
<tr><td>Währung nach</td><td><input type="text" name="waehrung_nach" value="[WAEHRUNG_NACH]" /></td></tr>
|
||||
<tr><td>Kurs:</td><td><input type="text" name="kurs" value="[KURS]" /></td></tr>
|
||||
<tr><td>Währung von</td><td><select name="waehrung_von">[WAEHRUNG_VON]</select></td></tr>
|
||||
<tr><td>Währung nach</td><td><select name="waehrung_nach">[WAEHRUNG_NACH]</select></td></tr>
|
||||
<tr><td>Kurs:</td><td><input type="number" lang="de_DE" step="0.0001" name="kurs" value="[KURS]" /></td></tr>
|
||||
<tr><td>gültig bis</td><td><input type="text" name="gueltig_bis" id="gueltig_bis" value="[GUELTIG_BIS]" /></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Speichern" name="speichern" /></td></tr>
|
||||
<tr><td></td><td><input type="submit" value="Speichern" name="submit" /></td></tr>
|
||||
</table>
|
||||
</tr></td></table>
|
||||
</fieldset>
|
||||
@ -27,3 +27,6 @@
|
||||
<!-- tab view schließen -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
[MESSAGE]
|
||||
[TAB1]
|
||||
[TAB1NEXT]
|
||||
<!--
|
||||
<form method="post">
|
||||
<table width="100%"><tr><td width="100%" align="center">
|
||||
<input type="submit" name="abgleich" value="Nur angelegte Kurse von der ECB holen" />
|
||||
@ -17,6 +18,7 @@
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<!-- tab view schließen -->
|
||||
|
223
www/pages/waehrungumrechnung.php
Normal file
223
www/pages/waehrungumrechnung.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 OpenXE project
|
||||
*/
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
|
||||
class Waehrungumrechnung {
|
||||
|
||||
function __construct($app, $intern = false) {
|
||||
$this->app = $app;
|
||||
if ($intern)
|
||||
return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
$this->app->ActionHandler("list", "waehrung_umrechnung_list");
|
||||
$this->app->ActionHandler("create", "waehrung_umrechnung_edit"); // This automatically adds a "New" button
|
||||
$this->app->ActionHandler("edit", "waehrung_umrechnung_edit");
|
||||
$this->app->ActionHandler("delete", "waehrung_umrechnung_delete");
|
||||
$this->app->DefaultActionHandler("list");
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
public function Install() {
|
||||
/* Fill out manually later */
|
||||
}
|
||||
|
||||
static function TableSearch(&$app, $name, $erlaubtevars) {
|
||||
switch ($name) {
|
||||
case "waehrung_umrechnung_list":
|
||||
$allowed['waehrung_umrechnung_list'] = array('list');
|
||||
$heading = array('','','Währung von', 'Währung nach', 'Kurs', 'Gültig bis', 'Geändert am', 'Bearbeiter', 'Kommentar', 'Menü');
|
||||
$width = array('1%','1%','10%'); // Fill out manually later
|
||||
|
||||
// columns that are aligned right (numbers etc)
|
||||
// $alignright = array(4,5,6,7,8);
|
||||
|
||||
$findcols = array('w.waehrung_von', 'w.waehrung_nach', 'w.kurs', 'w.gueltig_bis', 'w.zeitstempel', 'w.bearbeiter', 'w.kommentar');
|
||||
$searchsql = array('w.waehrung_von', 'w.waehrung_nach', 'w.kurs', 'w.gueltig_bis', 'w.zeitstempel', 'w.bearbeiter', 'w.kommentar');
|
||||
|
||||
$defaultorder = 1;
|
||||
$defaultorderdesc = 0;
|
||||
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',w.id,'\" />') AS `auswahl`";
|
||||
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=waehrungumrechnung&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=waehrungumrechnung&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
||||
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS w.id, $dropnbox, w.waehrung_von, w.waehrung_nach, ".$app->erp->FormatMenge('w.kurs',4).", ".$app->erp->FormatDate("w.gueltig_bis").", ".$app->erp->FormatDateTime('w.zeitstempel').", w.bearbeiter, w.kommentar, w.id FROM waehrung_umrechnung w";
|
||||
|
||||
$where = "1";
|
||||
$count = "SELECT count(DISTINCT id) FROM waehrung_umrechnung WHERE $where";
|
||||
// $groupby = "";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$erg = false;
|
||||
|
||||
foreach ($erlaubtevars as $k => $v) {
|
||||
if (isset($$v)) {
|
||||
$erg[$v] = $$v;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
|
||||
function waehrung_umrechnung_list() {
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=waehrungumrechnung&action=list", "Übersicht");
|
||||
$this->app->erp->MenuEintrag("index.php?module=waehrungumrechnung&action=create", "Neu anlegen");
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php", "Zurück");
|
||||
|
||||
$this->app->YUI->TableSearch('TAB1', 'waehrung_umrechnung_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||
$this->app->Tpl->Parse('PAGE', "waehrungumrechnung_list.tpl");
|
||||
}
|
||||
|
||||
public function waehrung_umrechnung_delete() {
|
||||
$id = (int) $this->app->Secure->GetGET('id');
|
||||
|
||||
$this->app->DB->Delete("DELETE FROM `waehrung_umrechnung` WHERE `id` = '{$id}'");
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gelöscht.</div>");
|
||||
|
||||
$this->waehrung_umrechnung_list();
|
||||
}
|
||||
|
||||
/*
|
||||
* Edit waehrung_umrechnung item
|
||||
* If id is empty, create a new one
|
||||
*/
|
||||
|
||||
function waehrung_umrechnung_edit() {
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
|
||||
// Check if other users are editing this id
|
||||
if($this->app->erp->DisableModul('artikel',$id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('ID', $id);
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=waehrungumrechnung&action=edit&id=$id", "Details");
|
||||
$this->app->erp->MenuEintrag("index.php?module=waehrungumrechnung&action=list", "Zurück zur Übersicht");
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$input = $this->GetInput();
|
||||
$submit = $this->app->Secure->GetPOST('submit');
|
||||
|
||||
$input['gueltig_bis'] = $this->app->erp->ReplaceDatum(true,$input['gueltig_bis'],true);
|
||||
|
||||
if (empty($id)) {
|
||||
// New item
|
||||
$id = 'NULL';
|
||||
}
|
||||
|
||||
if ($submit != '')
|
||||
{
|
||||
|
||||
// Write to database
|
||||
|
||||
// Add checks here
|
||||
|
||||
$input['bearbeiter'] = $this->app->DB->real_escape_string($this->app->User->GetName());
|
||||
$input['zeitstempel'] = date('Y-m-d H:m:s');
|
||||
|
||||
$columns = "id, ";
|
||||
$values = "$id, ";
|
||||
$update = "";
|
||||
|
||||
$fix = "";
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
$columns = $columns.$fix.$key;
|
||||
$values = $values.$fix."'".$value."'";
|
||||
$update = $update.$fix.$key." = '$value'";
|
||||
|
||||
$fix = ", ";
|
||||
}
|
||||
|
||||
// echo($columns."<br>");
|
||||
// echo($values."<br>");
|
||||
// echo($update."<br>");
|
||||
|
||||
$sql = "INSERT INTO waehrung_umrechnung (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
|
||||
|
||||
// echo($sql);
|
||||
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
if ($id == 'NULL') {
|
||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
|
||||
header("Location: index.php?module=waehrungumrechnung&action=list&msg=$msg");
|
||||
} else {
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load values again from database
|
||||
$dropnbox = "'<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type=\"checkbox\" name=\"auswahl[]\" value=\"',w.id,'\" />') AS `auswahl`";
|
||||
$result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS w.id, $dropnbox, w.waehrung_von, w.waehrung_nach, w.kurs, w.gueltig_bis, w.zeitstempel, w.bearbeiter, w.kommentar, w.id FROM waehrung_umrechnung w"." WHERE id=$id");
|
||||
|
||||
foreach ($result[0] as $key => $value) {
|
||||
$this->app->Tpl->Set(strtoupper($key), $value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add displayed items later
|
||||
*
|
||||
|
||||
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
|
||||
$this->app->Tpl->Add('EMAIL', $email);
|
||||
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
||||
*/
|
||||
|
||||
// $this->SetInput($input);
|
||||
|
||||
$this->app->YUI->DatePicker("gueltig_bis");
|
||||
$this->app->Tpl->Set('GUELTIG_BIS',$this->app->erp->ReplaceDatum(false,$result[0]['gueltig_bis'],true));
|
||||
|
||||
$this->app->Tpl->Set('WAEHRUNG_VON',$this->app->erp->getSelectAsso($this->app->erp->GetWaehrung(), $result[0]['waehrung_von']));
|
||||
$this->app->Tpl->Set('WAEHRUNG_NACH',$this->app->erp->getSelectAsso($this->app->erp->GetWaehrung(), $result[0]['waehrung_nach']));
|
||||
|
||||
$this->app->Tpl->Parse('PAGE', "waehrungumrechnung_edit.tpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all paramters from html form and save into $input
|
||||
*/
|
||||
public function GetInput(): array {
|
||||
$input = array();
|
||||
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
|
||||
|
||||
$input['waehrung_von'] = $this->app->Secure->GetPOST('waehrung_von');
|
||||
$input['waehrung_nach'] = $this->app->Secure->GetPOST('waehrung_nach');
|
||||
$input['kurs'] = $this->app->Secure->GetPOST('kurs');
|
||||
$input['gueltig_bis'] = $this->app->Secure->GetPOST('gueltig_bis');
|
||||
$input['zeitstempel'] = $this->app->Secure->GetPOST('zeitstempel');
|
||||
$input['bearbeiter'] = $this->app->Secure->GetPOST('bearbeiter');
|
||||
$input['kommentar'] = $this->app->Secure->GetPOST('kommentar');
|
||||
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set all fields in the page corresponding to $input
|
||||
*/
|
||||
function SetInput($input) {
|
||||
// $this->app->Tpl->Set('EMAIL', $input['email']);
|
||||
|
||||
$this->app->Tpl->Set('WAEHRUNG_VON', $input['waehrung_von']);
|
||||
$this->app->Tpl->Set('WAEHRUNG_NACH', $input['waehrung_nach']);
|
||||
$this->app->Tpl->Set('KURS', $input['kurs']);
|
||||
$this->app->Tpl->Set('GUELTIG_BIS', $input['gueltig_bis']);
|
||||
$this->app->Tpl->Set('ZEITSTEMPEL', $input['zeitstempel']);
|
||||
$this->app->Tpl->Set('BEARBEITER', $input['bearbeiter']);
|
||||
$this->app->Tpl->Set('KOMMENTAR', $input['kommentar']);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user