assets/s2dicoupon.php /// Art: Shop Business Logic /// Inhalt: Klasse couopon /// Beschreibung: Business Logic für Gutscheine /// Benötigt: config.php, db.php /// CCML-Parsing: nein /// ////////////////////////////////////////////////////////////////////////////////////////// /// /// Letzte Änderungen: /// ////////////////////////////////////////////////////////////////////////////////////////// ///<29.07.2008/6.0.2.29/> if (!defined('SHOP_TO_DATE')) die('Forbidden'); // Klasse Gutschein class coupon extends db { var $coupon_id = 0; var $coupondef_id = 0; var $client_email = null; var $client_id = null; var $order_id = null; var $save = 0; var $mode = 0; // Konstruktor, öffnet ggf. Datensatz function coupon($id = null, $client_id = null) { $this->db(TABLE_COUPONS); if ($id) { $this->coupon_id = $id; $this->db_selectobject(array('coupon_id' => $this->coupon_id)); } else if ($client_id) $this->db_selectobject(array('order_id' => null, 'client_id' => $client_id)); } // Speichert Coupon function store($mode = null) { if ($mode === true) $this->db_insertobject(); else $this->db_updateobject(); } // Gutschein löschen function delete() { $this->db_delete(array('coupon_id' => $this->coupon_id)); } } // Klasse Gutscheinart class coupondef extends db { var $coupondef_id = null; var $item_price = null; // Falls bestimmter Artikel var $item_uid = null; // Falls bestimmter Artikel var $rebate_absolute = 0; // Komplette Bestellung Abzug Betrag var $rebate_amount = 0; // Betrag ist absolut oder prozentual? var $date_from = null; // Bestimmter Zeitraum Anfang var $date_until = null; // Bestimmter Zeitraum Ende var $subtotal = null; // Bestimmter Mindestbestellwert var $caption = null; // Bezeichnung der Gutscheinart function coupondef($id = null) { $this->db(TABLE_COUPONDEFS); $this->db_selectobject(array('coupondef_id' => $id)); format::to_abs($this, array('rebate_absolute')); format::to_float($this, array('rebate_amount', 'subtotal', 'item_price'), 2); } // Speichern function store($mode = null) { if ($mode === true) return $this->db_insertobject(); else $this->db_updateobject(); } // Gutscheindefinition löschen function delete() { $this->db_delete(array('coupondef_id' => $this->coupondef_id)); // Gutschein mitlöschen $coupon = new coupon(); $coupon->db_delete(array('coupondef_id' => $this->coupondef_id)); } } ?>