product = new Product(); $this->customer = new Customer(); $this->product = new Product(); $this->price = new Price(); $this->priceset = new Priceset(); $this->customer_template = new Customer_Template(); $this->product_id_array = $param_product_id_array; $this->product_amount_array = $param_product_amount_array; $this->product_hint_array = $param_product_hint_array; $this->customer_id = $param_customer_id; if(count($this->product_id_array) > count($this->product_amount_array)) echo "
Fehler in Session, bitte neu anmelden

\n"; $this->priceset_id = 0; $customer_data = $this->customer->get($param_customer_id); if(count($customer_data) > 0) $this->priceset_id = $customer_data[0][11]; $tmp_priceset = $this->priceset->get($this->priceset_id); $this->netto = 0; if(count($tmp_priceset) > 0) $this->netto = $tmp_priceset[0][2]; } function getItemCount() { return count($this->product_id_array); } function getPriceSum() { $ret = 0; for($i = 0; $i < count($this->product_id_array); $i++) { $price = $this->price->getPriceTax($this->priceset_id, $this->product_id_array[$i], $this->netto); $ret += $price * $this->product_amount_array[$i]; } return $ret; } function addProduct($param_product_id, $param_amount, $param_hint = "") { $product_data = $this->product->get($param_product_id); if(count($product_data) == 0) { echo "ShoppingCart::addProduct()", $param_product_id; echo "
Fehler in Session, bitte neu anmelden

\n"; return; } /* check if product already in cart */ for($i = 0; $i < count($this->product_id_array); $i++) { if($this->product_id_array[$i] == $param_product_id) { $this->product_amount_array[$i] += $param_amount; $this->saveShoppingCartSession(); return; } } /* new product in cart */ $this->product_id_array []= $param_product_id; $this->product_amount_array []= $param_amount; $this->product_hint_array []= $param_hint; $this->saveShoppingCartSession(); } function removeProduct($param_product_id) { $tmp_id_array = array(); $tmp_amount_array = array(); $tmp_hint_array = array(); for($i = 0; $i < count($this->product_id_array); $i++) { if($this->product_id_array[$i] != $param_product_id) { $tmp_id_array []= $this->product_id_array[$i]; $tmp_amount_array []= $this->product_amount_array[$i]; $tmp_hint_array []= $this->product_hint_array[$i]; } } $this->product_id_array = $tmp_id_array; $this->product_amount_array = $tmp_amount_array; $this->product_hint_array = $tmp_hint_array; $this->saveShoppingCartSession(); } function editProduct($param_product_id, $param_amount, $param_hint = "") { for($i = 0; $i < count($this->product_id_array); $i++) { if($this->product_id_array[$i] == $param_product_id) { $this->product_amount_array[$i] = $param_amount; $this->product_hint_array[$i] = $param_hint; } } $this->saveShoppingCartSession(); } function saveShoppingCartSession() { $_SESSION["cart_product_id_array"] = $this->product_id_array; $_SESSION["cart_product_amount_array"] = $this->product_amount_array; $_SESSION["cart_product_hint_array"] = $this->product_hint_array; } function clearShoppingCart() { unset($_SESSION["cart_product_id_array"]); unset($_SESSION["cart_product_amount_array"]); unset($_SESSION["cart_product_hint_array"]); } function saveShoppingCartDatabase() { } function saveTemplate() { $this->customer_template->clear($this->customer_id); $list = $this->getItems(); for($i = 0; $i < count($list); $i++) $this->customer_template->set($this->customer_id, $list[$i][0], $list[$i][2], $list[$i][5]); } function loadTemplate() { $list = $this->customer_template->get($this->customer_id); for($i = 0; $i < count($list); $i++) $this->addProduct($list[$i][1], $list[$i][2], $list[$i][3]); $this->saveShoppingCartSession(); } function getItems() { $ret = array(); for($i = 0; $i < count($this->product_id_array); $i++) { $tmp_product = $this->product->get($this->product_id_array[$i]); if(count($tmp_product) == 0) { echo "
Fehler in Session, bitte neu anmelden

\n"; return -1; } $price = $this->price->getPriceTax($this->priceset_id, $this->product_id_array[$i], $this->netto); $ret []= array($this->product_id_array[$i], $tmp_product[0][1], $this->product_amount_array[$i], $price, $tmp_product[0][2], $this->product_hint_array[$i]); } return $ret; } function createBill() { $bill = new Bill(); $customer = new Customer(); $tour = new Tour(); $bill_product = new Bill_Product(); $customer_data = $customer->get($this->customer_id); if(count($customer_data) == 0) { echo "
Fehler in Session, bitte neu anmelden

\n"; return -1; } $tour_data = $tour->getByAssistant($customer_data[0][12]); $bill_id = $bill->create("", array($this->customer_id, $customer_data[0][12], "", $tour_data[0][2], -2, time())); $list = $this->getItems(); for($i = 0; $i < count($list); $i++) { if ($list[$i][2] > 0) { $bill_product->create(array($bill_id, $list[$i][0], $list[$i][2], $list[$i][5], "", 0, 0, time())); } } return 0; } } ?>