clearCache(); $this->archived_ordered_products_cached == false; } function clearCache() { $this->products = array(); $this->ordered_products_cached = false; } function getOrderedProductsCache() { if ( $this->ordered_products_cached == false ) { $this->retrieveOrderedProducts(); } return $this->products; } function retrieveOrderedProducts($pid=NULL) { //Collect required data $this->products = array(); $orders_product_array = array(); if ( ! is_null($pid) ) $where_pid = "products_id = " . $pid . " AND "; else $where_pid = ""; $orders_product_query = tep_db_query("select id, products_id, supplier_name, products_quantity, due_date from " . TABLE_SUPPLIERS_ORDERS_PRODUCTS . " where " . $where_pid . "date_received IS NULL order by date_added DESC"); while ($orders_product = tep_db_fetch_array($orders_product_query)) { $id = $orders_product['products_id']; if ( is_null($this->products[$id]) ) $this->products[$id] = array(); $this->products[$id][] = $orders_product; } $this->ordered_products_cached = true; return $this->products; } function getArchivedOrderedProductsCache() { if ( $this->archived_ordered_products_cached == false ) { $this->retrieveArchivedOrderedProducts(); $this->archived_ordered_products_cached = true; } return $this->archived_ordered_products; } function retrieveArchivedOrderedProducts() { //Collect required data $this->archived_ordered_products = array(); $orders_product_array = array(); $orders_product_query = tep_db_query("select id, products_id, supplier_name, products_quantity, due_date, date_received from " . TABLE_SUPPLIERS_ORDERS_PRODUCTS . " where date_received IS NOT NULL order by date_added DESC"); while ($orders_product = tep_db_fetch_array($orders_product_query)) { $id = $orders_product['products_id']; if ( is_null($this->archived_ordered_products[$id]) ) $this->archived_ordered_products[$id] = array(); $this->archived_ordered_products[$id][] = $orders_product; } } function getOrderedProducts($product_id) { $this->getOrderedProductsCache(); $all = $this->products[$product_id]; if ( count($all) > 0 ) return $all[0]; else return NULL; } function insertOrderedProducts($product_id, $supplier_name, $due_date, $products_quantity) { $this->getOrderedProductsCache(); $all = $this->products[$product_id]; $found = false; for($i=0; $iproducts[$pid]) ) { foreach ($this->products[$pid] as $ordered_product) { $txt .= $ident . $ordered_product['products_quantity'] . " chez " . $ordered_product['supplier_name'] . " prévue le " . $ordered_product['due_date']; } } return $txt; } function archiveOrderedProducts($id, $date_received) { return tep_db_query("UPDATE " . TABLE_SUPPLIERS_ORDERS_PRODUCTS . " SET date_received='" . $date_received . "' WHERE id = " . $id); } function getLastArchivedOrderedProducts($product_id, $count) { $this->getArchivedOrderedProductsCache(); $all = $this->archived_ordered_products[$product_id]; $found = array(); for($i=0; $i