info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->delivery = array(); $this->query($order_id); } function query($order_id) { // -> TVAINT // -> VDNUMCLI $order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_tva_intracom, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, orders_comments, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); // VD : ajout du numéro de client - fin // <- VDNUMCLI // <- TVAINT $order = tep_db_fetch_array($order_query); $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); while ($totals = tep_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']); } $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified'], 'orders_comments' => $order['orders_comments']); // echo "oname=" . $order['customers_name'] . "dname=" . $order['delivery_name'] . "\n"; $this->customer = array('name' => $order['customers_name'], // -> VDNUMCLI 'id' => $order['customers_id'], // <- VDNUMCLI 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], // -> TVAINT 'tva_intracom' => $order['billing_tva_intracom'], // <- TVAINT 'street_address' => $order['billing_street_address'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; // -> OSC-1: gestion des quantité envoyées dans les commandes // -> VDSTCMD : affichage du stock courant dans les commandes admin $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price,products_cost, products_tax, products_quantity, qty_sent, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); // <- VDSTCMD while ($orders_products = tep_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], // -> VDSTCMD : affichage du stock courant dans les commandes admin 'qty_sent' => $orders_products['qty_sent'], 'id' => $orders_products['products_id'], // <- VDSTCMD 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], // -> MARP256 'cost' => $orders_products['products_cost'], // <- MARP256 'final_price' => $orders_products['final_price']); // <- OSC-1 $subindex = 0; $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $index++; } } // -> VDSTCMD : affichage du stock courant dans les commandes admin function update_stock() { $this->stock = array(); if (sizeof($this->products)) { $stock_sql = "SELECT products_quantity,products_id FROM " . TABLE_PRODUCTS . " WHERE products_id = 1"; for ($i=0; $iproducts); $i++) { $stock_sql .= " or products_id = " . $this->products[$i]['id']; } $stock_query = tep_db_query($stock_sql); while ($s = tep_db_fetch_array($stock_query)) { $this->stock[$s['products_id']] = $s['products_quantity']; } // var_dump($this->stock); } } function get_text_stock($id) { $txt = ""; if (array_key_exists($id, $this->stock)) { $txt .= "
("; if ($this->stock[$id] > 0) { $txt .= "+"; } $txt .= $this->stock[$id]; $txt .= ")
"; } return $txt; } // <- VDSTCMD // -> OSC-14: gestion des emplacements /** * Sort array by field. * * @param array to sort. * @param string $on Name of field. * @param string $order (ASC|DESC) */ function sort_on_field(&$objects, $on, $order = 'ASC') { if ( $on != "location" ) { $comparer = ($order === 'DESC') ? "return -strcmp(\$a[$on],\$b[$on]);" : "return strcmp(\$a[$on],\$b[$on]);"; usort($objects, create_function('$a,$b', $comparer)); } else { // le location est de type : zzr où zz est un nombre sur 1 ou 2 caractère qui définit une zone et r est un rayonnage en alpha numérique // on doit trier d'abord sur la zone en numérique puis sur le rayon en alphanumérique // ex: 1D,5D,12X,4D,20F,10A devient trié 1D,5D,4D,10A,12X,20F // dans le cas du champ location, il faut donc décomposer le code en 2 parties et comparer ces 2 parties individuellement function cmp_location($a,$b) { preg_match("/(\d+)(.*)/", $a['location'], $a_zone_rayon); preg_match("/(\d+)(.*)/", $b['location'], $b_zone_rayon); // echo "aloc=" . $a['location'] . "zr=" . sizeof($a_zone_rayon) . "\n"; // echo "bloc=" . $b['location'] . "zr=" . sizeof($b_zone_rayon) . "\n"; if ( sizeof($a_zone_rayon) == 0 || sizeof($b_zone_rayon) == 0 ) { $res = strcmp($a['location'], $b['location']); } else if ( intval($a_zone_rayon[1]) > intval($b_zone_rayon[1]) ) { $res = 1; } else if ( intval($a_zone_rayon[1]) < intval($b_zone_rayon[1]) ) { $res = -1; } else { $res = strcmp($a_zone_rayon[2], $b_zone_rayon[2]); } return $res; } function cmp_location_ASC($a,$b) { return cmp_location($a,$b); } function cmp_location_DESC($a,$b) { return - cmp_location($a,$b); } usort($objects, ($order === 'DESC') ? "cmp_location_DESC" : "cmp_location_ASC" ); } } function set_location_and_sort_products_by_location($order = 'ASC') { if (sizeof($this->products)) { for ($i=0; $iproducts); $i++) { $location_query = tep_db_query("SELECT products_location FROM " . TABLE_PRODUCTS . " WHERE products_id = " . $this->products[$i]['id']); $location = tep_db_fetch_array($location_query); $this->products[$i]['location'] = $location['products_location']; } // tri du tableau par le champ emplacement $this->sort_on_field($this->products, "location", $order); } } // <- OSC-14 } ?>