114 |
114 |
$this->queryItemCnt = "SELECT o.orders_id, op.products_id as pid, op.orders_products_id, op.products_name as pname,op.products_model as pmodel, round(sum(op.products_quantity),0) as pquant, if(o.currency_value>0,sum(op.final_price/o.currency_value),sum(op.final_price)) as psum, op.products_tax as ptax FROM " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op WHERE o.orders_id = op.orders_id";
|
115 |
115 |
|
116 |
116 |
// query for attributes
|
117 |
|
$this->queryAttr = "SELECT count(*) as attr_cnt, o.orders_id, opa.orders_products_id, opa.products_options, opa.products_options_values, opa.options_values_price, opa.price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op WHERE o.orders_id = opa.orders_id AND op.orders_products_id = opa.orders_products_id";
|
|
117 |
$this->queryAttr = "SELECT count(*) as attr_cnt2, op.products_quantity, o.orders_id, opa.orders_products_id, opa.products_options, opa.products_options_values, opa.options_values_price, opa.price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " opa, " . TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op WHERE o.orders_id = opa.orders_id AND op.orders_products_id = opa.orders_products_id";
|
118 |
118 |
|
119 |
119 |
// query for shipping
|
120 |
120 |
$this->queryShipping = "SELECT if(o.currency_value>0,sum(ot.value/o.currency_value),sum(ot.value)) as shipping FROM " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot WHERE ot.orders_id = o.orders_id AND ot.class = 'ot_shipping'";
|
... | ... | |
215 |
215 |
|
216 |
216 |
// products_attributes
|
217 |
217 |
// are there any attributes for this order_id ?
|
218 |
|
$rqAttr = xtc_db_query($this->queryAttr . " AND o.date_purchased >= '" . xtc_db_input(date("Y-m-d\TH:i:s", $sd)) . "' AND o.date_purchased < '" . xtc_db_input(date("Y-m-d\TH:i:s", $ed)) . "' AND op.products_id = " . $resp[$cnt]['pid'] . $filterString . " group by products_options_values order by orders_products_id");
|
|
218 |
$rqAttr = xtc_db_query("SELECT *, round(sum(products_quantity * attr_cnt2),0) as attr_cnt FROM (".$this->queryAttr . " AND o.date_purchased >= '" . xtc_db_input(date("Y-m-d\TH:i:s", $sd)) . "' AND o.date_purchased < '" . xtc_db_input(date("Y-m-d\TH:i:s", $ed)) . "' AND op.products_id = " . $resp[$cnt]['pid'] . $filterString . " group by orders_products_id order by orders_products_id) as count group by products_options_values");
|
219 |
219 |
$i = 0;
|
220 |
220 |
while ($attr[$i] = xtc_db_fetch_array($rqAttr)) {
|
221 |
221 |
$i++;
|