mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
This commit is contained in:
@@ -37,7 +37,9 @@ class wawi_aufteilung extends basis_db
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // char
|
||||
public $updateamum; // timestamp
|
||||
public $upatevon; // char
|
||||
public $updatevon; // char
|
||||
|
||||
public $bestellung_id;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -167,18 +169,57 @@ class wawi_aufteilung extends basis_db
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* return true wenn es den Aufteilungseintrag schon gibt, false wenn es ihn noch nicht gibt
|
||||
* Gibt alle Aufteilungen zurück die einer Bestellung zugeordnet sind
|
||||
* @param $bestellung_id
|
||||
*/
|
||||
public function getAufteilungFromBestellung($bestellung_id)
|
||||
{
|
||||
|
||||
$qry = "SELECT * from wawi.tbl_aufteilung where bestellung_id = ".$bestellung_id.";";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$aufteilung = new wawi_aufteilung();
|
||||
|
||||
$aufteilung->aufteilung_id = $row->aufteilung_id;
|
||||
$aufteilung->bestellung_id = $row->bestellung_id;
|
||||
$aufteilung->oe_kurzbz = $row->oe_kurzbz;
|
||||
$aufteilung->anteil = $row->anteil;
|
||||
$aufteilung->insertamum = $row->insertamum;
|
||||
$aufteilung->insertvon = $row->insertvon;
|
||||
$aufteilung->updateamum = $row->updateamum;
|
||||
$aufteilung->updatevon = $row->updatevon;
|
||||
|
||||
$this->result[] = $aufteilung;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = "Fehler bei der Abfrage.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* return true wenn es den Aufteilungseintrag in tbl_aufteilung schon gibt, false wenn es ihn noch nicht gibt
|
||||
*/
|
||||
public function AufteilungExists()
|
||||
{
|
||||
$qry = "SELECT * from wawi.tbl_aufteilung where bestellung_id = ".$this->addslashes($this->bestellung_id)." and oe_kurzbz = ".$this->addslashes($this->oe_kurzbz).";";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
return true;
|
||||
{
|
||||
$this->aufteilung_id = $row->aufteilung_id;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -192,8 +233,9 @@ class wawi_aufteilung extends basis_db
|
||||
*/
|
||||
public function saveAufteilung()
|
||||
{
|
||||
|
||||
if($this->new = true)
|
||||
$this->anteil = mb_str_replace(",",".",$this->anteil);
|
||||
$this->anteil = number_format($this->anteil,2,".",",");
|
||||
if($this->new == true)
|
||||
{
|
||||
// insert
|
||||
$qry= "Insert into wawi.tbl_aufteilung (bestellung_id, oe_kurzbz, anteil, updateamum, updatevon, insertamum, insertvon) values ("
|
||||
@@ -208,13 +250,19 @@ class wawi_aufteilung extends basis_db
|
||||
else
|
||||
{
|
||||
// update
|
||||
$qry = "Update wawi.tbl_aufteilung set
|
||||
bestellung_id = ".$this->addslashes($this->bestellung_id).",
|
||||
oe_kurzbz = ".$this->addslashes($this->oe_kurzbz).",
|
||||
anteil = ".$this->addslashes($this->anteil).",
|
||||
updateamum = ".$this->addslashes($this->updateamum).",
|
||||
updatevon = ".$this->addslashes($this->updatevon)."
|
||||
where aufteilung_id = ".$this->addslashes($this->aufteilung_id).";";
|
||||
}
|
||||
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@
|
||||
* Klasse WaWi Bestellung
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
require_once (dirname(__FILE__).'/wawi_bestelldetails.class.php');
|
||||
require_once (dirname(__FILE__).'/wawi_aufteilung.class.php');
|
||||
|
||||
class wawi_bestellung extends basis_db
|
||||
{
|
||||
@@ -453,4 +455,86 @@ class wawi_bestellung extends basis_db
|
||||
}
|
||||
}
|
||||
|
||||
function copyBestellung($bestellung_id)
|
||||
{
|
||||
$error = false;
|
||||
|
||||
// Bestellung kopieren
|
||||
$qry_bestellung = "BEGIN; INSERT INTO wawi.tbl_bestellung (besteller_uid, kostenstelle_id, konto_id, firma_id, lieferadresse, rechnungsadresse, freigegeben, bestell_nr,
|
||||
titel, bemerkung, liefertermin, updateamum, updatevon, insertamum, insertvon, ext_id) SELECT besteller_uid, kostenstelle_id, konto_id, firma_id, lieferadresse,
|
||||
rechnungsadresse, freigegeben, bestell_nr, titel, bemerkung, liefertermin, updateamum, updatevon, insertamum, insertvon, ext_id FROM wawi.tbl_bestellung WHERE
|
||||
bestellung_id = ".$bestellung_id.";";
|
||||
|
||||
if(!$this->db_query($qry_bestellung))
|
||||
$error = true;
|
||||
|
||||
// neue Bestellid abfragen
|
||||
$qry_currval = "SELECT currval('wawi.seq_bestellung_bestellung_id') as id;";
|
||||
if($this->db_query($qry_currval))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$newBestellung_id = $row->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$bestelldetail = new wawi_bestelldetail();
|
||||
$bestelldetail->getAllDetailsFromBestellung($bestellung_id);
|
||||
|
||||
// Bestelldetails kopieren
|
||||
foreach ($bestelldetail->result as $detail)
|
||||
{
|
||||
$qry_detail ="INSERT INTO wawi.tbl_bestelldetail (bestellung_id, position, menge, verpackungseinheit, beschreibung, artikelnummer, preisprove, mwst, erhalten, sort,
|
||||
text, insertamum, insertvon, updateamum, updatevon) SELECT $newBestellung_id, position, menge, verpackungseinheit, beschreibung, artikelnummer, preisprove, mwst, erhalten, sort,
|
||||
text, insertamum, insertvon, updateamum, updatevon FROM wawi.tbl_bestelldetail
|
||||
WHERE bestelldetail_id = ".$detail->bestelldetail_id.";";
|
||||
if (!$this->db_query($qry_detail))
|
||||
$error = true;
|
||||
|
||||
// neue Bestelldetail id abfragen
|
||||
$qry_currval = "SELECT currval('wawi.seq_bestelldetail_bestelldetail_id') as id;";
|
||||
if($this->db_query($qry_currval))
|
||||
{
|
||||
if($row = $this->db_fetch_object())
|
||||
{
|
||||
$newBestellDetail_id = $row->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
}
|
||||
|
||||
// zugehörigen TAG kopieren
|
||||
$qry_detailtag = "INSERT INTO wawi.tbl_bestelldetailtag (tag, bestelldetail_id, insertamum, insertvon)
|
||||
SELECT tag, ".$this->addslashes($newBestellDetail_id).", insertamum, insertvon FROM wawi.tbl_bestelldetailtag
|
||||
WHERE bestelldetail_id = ".$this->addslashes($detail->bestelldetail_id).";";
|
||||
|
||||
if (!$this->db_query($qry_detailtag))
|
||||
$error = true;
|
||||
|
||||
}
|
||||
|
||||
$qry_aufteilung = "INSERT INTO wawi.tbl_aufteilung (bestellung_id, oe_kurzbz, anteil, updateamum, updatevon, insertamum, insertvon)
|
||||
SELECT ".$this->addslashes($newBestellung_id)." , oe_kurzbz, anteil, updateamum, updatevon, insertamum, insertvon FROM wawi.tbl_aufteilung WHERE bestellung_id = ".$bestellung_id.";";
|
||||
if (!$this->db_query($qry_aufteilung))
|
||||
$error = true;
|
||||
|
||||
if(!$error)
|
||||
{
|
||||
echo "Erfolgreich kopiert.";
|
||||
$this->db_query('COMMIT');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Fehler beim kopieren aufgetreten.";
|
||||
$this->db_query('ROLLBACK');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user