ExecuteS(' SELECT o.`id_order` FROM `'._DB_PREFIX_.'orders` o, `'._DB_PREFIX_.'order_detail` d, `'._DB_PREFIX_.'customer` c WHERE (o.valid = 1 OR ( o.valid = 0 AND ( (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) = 6 OR (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) = 7 OR (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) = 11 ) )) AND c.id_customer = o.id_customer AND d.id_order = o.id_order AND o.date_add >= DATE_FORMAT("'.$now.'" - INTERVAL 2 MONTH, \'%Y-%m-01 00:00:00\') AND o.date_add <= DATE_FORMAT(LAST_DAY("'.$now.'" - INTERVAL 2 MONTH), \'%Y-%m-%d 23:59:59\') GROUP BY o.id_order '); foreach($orders as $o) { $order = Db::getInstance()->ExecuteS(' SELECT c.*, o.* FROM `'._DB_PREFIX_.'orders` o, `'._DB_PREFIX_.'customer` c WHERE o.id_order = '.$o['id_order'].' AND c.`id_customer` = o.`id_customer` '); $order = $order[0]; $address = Db::getInstance()->ExecuteS(' SELECT a.*, c.`id_zone` FROM `'._DB_PREFIX_.'address` a, `'._DB_PREFIX_.'country` c WHERE a.`id_address` = '.$order['id_address_delivery'].' AND a.`id_country` = c.`id_country` '); $address = $address[0]; $order_details = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` d WHERE d.id_order = '.$o['id_order'] ); $total_products_wo_taxes_210 = array(); $total_taxes_210 = array(); $total_products_wo_taxes_200 = array(); $total_taxes_200 = array(); $total_products_wo_taxes_196 = array(); $total_taxes_196 = array(); $total_products_wo_taxes_100 = array(); $total_taxes_100 = array(); $total_products_wo_taxes_55 = array(); $total_taxes_55 = array(); $total_products_wo_taxes_21 = array(); $total_taxes_21 = array(); $total_products_wo_taxes_60= array(); $total_taxes_60= array(); $total_products_wo_taxes_40 = array(); $total_taxes_40 = array(); $total_products_wo_taxes_export = array(); // calcul prix d'achat de la commande $wholesale_price = Db::getInstance()->ExecuteS(' SELECT `wholesale_price`, p.`id_product` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'order_detail` o ON o.`product_id` = p.`id_product` WHERE o.`id_order` = '. (int) $order['id_order'] ); $prix_achat = array(); foreach ($wholesale_price as $key => $price) { $prix_achat[$price['id_product']] = $price['wholesale_price']; } $total_achat = 0; $ldetails = array(); foreach($order_details as $detail) { $total_achat += $detail['product_quantity'] * $prix_achat[$detail['product_id']]; $ldetails[$detail['id_order_detail']] = $detail; if($address['id_country'] != 19) { if($detail['tax_rate'] == '20.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_200[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_200[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.2); } else { $total_products_wo_taxes_200[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_200[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.2); } } elseif($detail['tax_rate'] == '21.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_210[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_210[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.21); } else { $total_products_wo_taxes_210[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_210[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.21); } } elseif($detail['tax_rate'] == '19.600') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_196[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_196[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.196); } else { $total_products_wo_taxes_196[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_196[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.196); } } elseif($detail['tax_rate'] == '10.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_100[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_100[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.100); } else { $total_products_wo_taxes_100[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_100[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.100); } } elseif($detail['tax_rate'] == '5.500') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_55[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_55[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.055); } else { $total_products_wo_taxes_55[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_55[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.055); } } elseif($detail['tax_rate'] == '2.100') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_21[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_21[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.021); } else { $total_products_wo_taxes_21[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_21[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.021); } } elseif($detail['tax_rate'] == '6.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_60[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_60[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.060); } else { $total_products_wo_taxes_60[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_60[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.060); } } elseif($detail['tax_rate'] == '4.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_40[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); $total_taxes_40[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity'] * 0.040); } else { $total_products_wo_taxes_40[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); $total_taxes_40[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity'] * 0.040); } } else { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_export[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); } else { $total_products_wo_taxes_export[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); } } } else { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_export[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity']); } else { $total_products_wo_taxes_export[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity']); } } } $total_tax_210 = 0.0; foreach($total_products_wo_taxes_210 as $value) { $total_tax_210 += $value; } $_total_taxes_210 = 0.0; foreach($total_taxes_210 as $value) { $_total_taxes_210 += $value; } $total_tax_200 = 0.0; foreach($total_products_wo_taxes_200 as $value) { $total_tax_200 += $value; } $_total_taxes_200 = 0.0; foreach($total_taxes_200 as $value) { $_total_taxes_200 += $value; } $total_tax_196 = 0.0; foreach($total_products_wo_taxes_196 as $value) { $total_tax_196 += $value; } $_total_taxes_196 = 0.0; foreach($total_taxes_196 as $value) { $_total_taxes_196 += $value; } $total_tax_100 = 0.0; foreach($total_products_wo_taxes_100 as $value) { $total_tax_100 += $value; } $_total_taxes_100 = 0.0; foreach($total_taxes_100 as $value) { $_total_taxes_100 += $value; } $total_tax_55 = 0.0; foreach($total_products_wo_taxes_55 as $value) { $total_tax_55 += $value; } $_total_taxes_55 = 0.0; foreach($total_taxes_55 as $value) { $_total_taxes_55 += $value; } $total_tax_21 = 0.0; foreach($total_products_wo_taxes_21 as $value) { $total_tax_21 += $value; } $_total_taxes_21 = 0.0; foreach($total_taxes_21 as $value) { $_total_taxes_21 += $value; } $total_tax_60 = 0.0; foreach($total_products_wo_taxes_60 as $value) { $total_tax_60 += $value; } $_total_taxes_60 = 0.0; foreach($total_taxes_60 as $value) { $_total_taxes_60 += $value; } $total_tax_40 = 0.0; foreach($total_products_wo_taxes_40 as $value) { $total_tax_40 += $value; } $_total_taxes_40 = 0.0; foreach($total_taxes_40 as $value) { $_total_taxes_40 += $value; } $total_tax_export = 0.0; foreach($total_products_wo_taxes_export as $value) { $total_tax_export += $value; } $tabs = array( // fr 8 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // be 3 => array('tax_210' => 0,'tax_60' => 0,'port' => 0,'discount' => 0), // es 6 => array('tax_210' => 0,'tax_40' => 0,'port' => 0,'discount' => 0), // it 10 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // de 1 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // gb 17 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // lu 12 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // pt 15 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // nl 13 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), ); switch ($address['id_country']) { case '8': $tabs[8] = array( 'tax_200' => $total_tax_200, 'tax_55' => $total_tax_55, 'tax_21' => $total_tax_21, 'port' => (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196), 'discount' => $order['total_discounts'] ); break; case '3': $tabs[3] = array( 'tax_210' => $total_tax_210, 'tax_60' => $total_tax_60, 'port' => (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196), 'discount' => $order['total_discounts'] ); break; case '6': $tabs[6] = array( 'tax_210' => $total_tax_210, 'tax_40' => $total_tax_40, 'port' => (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196), 'discount' => $order['total_discounts'] ); break; case '10': case '1': case '12': case '13': case '15': case '17': $tabs[(int)$address['id_country']] = array( 'tax_200' => $total_tax_200, 'tax_55' => $total_tax_55, 'tax_21' => $total_tax_21, 'port' => (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196), 'discount' => $order['total_discounts'] ); break; default: break; } fwrite($f, implode(';', array( ($order['payment'] == 'Paybox'?1:0), ($order['payment'] == 'PayPal'?1:0), 0, $tabs[8]['tax_200'], $tabs[8]['tax_55'], $tabs[8]['tax_21'], $tabs[8]['port'], $tabs[8]['discount'], $tabs[3]['tax_210'], $tabs[3]['tax_60'], $tabs[3]['port'], $tabs[3]['discount'], $tabs[6]['tax_210'], $tabs[6]['tax_40'], $tabs[6]['port'], $tabs[6]['discount'], $tabs[10]['tax_200'], $tabs[10]['tax_55'], $tabs[10]['tax_21'], $tabs[10]['port'], $tabs[10]['discount'], $tabs[1]['tax_200'], $tabs[1]['tax_55'], $tabs[1]['tax_21'], $tabs[1]['port'], $tabs[1]['discount'], $tabs[17]['tax_200'], $tabs[17]['tax_55'], $tabs[17]['tax_21'], $tabs[17]['port'], $tabs[17]['discount'], $tabs[12]['tax_200'], $tabs[12]['tax_55'], $tabs[12]['tax_21'], $tabs[12]['port'], $tabs[12]['discount'], $tabs[15]['tax_200'], $tabs[15]['tax_55'], $tabs[15]['tax_21'], $tabs[15]['port'], $tabs[15]['discount'], $tabs[13]['tax_200'], $tabs[13]['tax_55'], $tabs[13]['tax_21'], $tabs[13]['port'], $tabs[13]['discount'], ))."\n"); } // REFUND $slips = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'order_slip` os WHERE os.date_add >= DATE_FORMAT("'.$now.'" - INTERVAL 1 MONTH, \'%Y-%m-01 00:00:00\') AND os.date_add <= DATE_FORMAT(LAST_DAY("'.$now.'" - INTERVAL 1 MONTH), \'%Y-%m-%d 23:59:59\') '); if(count($slips) > 0) { foreach($slips as $slip) { $order = Db::getInstance()->getRow(' SELECT o.*, c.* FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer` WHERE o.id_order = '.$slip['id_order'].' '); $address = Db::getInstance()->ExecuteS(' SELECT a.*, c.`id_zone` FROM `'._DB_PREFIX_.'address` a, `'._DB_PREFIX_.'country` c WHERE a.`id_address` = '.$order['id_address_delivery'].' AND a.`id_country` = c.`id_country` '); $address = $address[0]; $order_details = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'order_detail` d WHERE d.id_order = '.(int) $slip['id_order'].' AND d.`id_order_detail` IN ( SELECT `id_order_detail` FROM `'._DB_PREFIX_.'order_slip_detail` WHERE `id_order_slip` = '.(int) $slip['id_order_slip'].' ) '); $ldetails = array(); $total_products_wo_taxes_210 = array(); $total_taxes_210 = array(); $total_products_wo_taxes_200 = array(); $total_taxes_200 = array(); $total_products_wo_taxes_196 = array(); $total_taxes_196 = array(); $total_products_wo_taxes_100 = array(); $total_taxes_100 = array(); $total_products_wo_taxes_55 = array(); $total_taxes_55 = array(); $total_products_wo_taxes_21 = array(); $total_taxes_21 = array(); $total_products_wo_taxes_60 = array(); $total_taxes_60 = array(); $total_products_wo_taxes_40 = array(); $total_taxes_40 = array(); $total_products_wo_taxes_export = array(); foreach($order_details as $detail) { $ldetails[$detail['id_order_detail']] = $detail; if($address['id_country'] != 19) { if($detail['tax_rate'] == '19.600') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_196[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_196[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.196); } else { $total_products_wo_taxes_196[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_196[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.196); } } elseif($detail['tax_rate'] == '21.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_210[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_210[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.21); } else { $total_products_wo_taxes_210[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_210[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.21); } } elseif($detail['tax_rate'] == '10.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_100[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_100[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.100); } else { $total_products_wo_taxes_100[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_100[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.100); } } elseif($detail['tax_rate'] == '5.500') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_55[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_55[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.055); } else { $total_products_wo_taxes_55[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_55[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.055); } } elseif($detail['tax_rate'] == '2.100') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_21[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_21[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.021); } else { $total_products_wo_taxes_21[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_21[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.021); } } elseif($detail['tax_rate'] == '20.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_200[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_200[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.2); } else { $total_products_wo_taxes_200[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_200[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.2); } } elseif($detail['tax_rate'] == '6.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_60[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_60[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.06); } else { $total_products_wo_taxes_60[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_60[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.06); } } elseif($detail['tax_rate'] == '4.000') { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_40[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); $total_taxes_40[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded'] * 0.04); } else { $total_products_wo_taxes_40[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); $total_taxes_40[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded'] * 0.04); } } else { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_export[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); } else { $total_products_wo_taxes_export[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); } } } else { if((float) $detail['reduction_percent'] != 0.0) { $total_products_wo_taxes_export[] = (float) ($detail['product_price'] * (1 - (float) $detail['reduction_percent'] / 100) * $detail['product_quantity_refunded']); } else { $total_products_wo_taxes_export[] = (float) (($detail['product_price'] - (float) $detail['reduction_amount']) * $detail['product_quantity_refunded']); } } } $total_tax_210 = 0.0; foreach($total_products_wo_taxes_210 as $value) { $total_tax_210 += $value; } $_total_taxes_210 = 0.0; foreach($total_taxes_210 as $value) { $_total_taxes_210 += $value; } $total_tax_200 = 0.0; foreach($total_products_wo_taxes_200 as $value) { $total_tax_200 += $value; } $_total_taxes_200 = 0.0; foreach($total_taxes_200 as $value) { $_total_taxes_200 += $value; } $total_tax_196 = 0.0; foreach($total_products_wo_taxes_196 as $value) { $total_tax_196 += $value; } $_total_taxes_196 = 0.0; foreach($total_taxes_196 as $value) { $_total_taxes_196 += $value; } $total_tax_100 = 0.0; foreach($total_products_wo_taxes_100 as $value) { $total_tax_100 += $value; } $_total_taxes_100 = 0.0; foreach($total_taxes_100 as $value) { $_total_taxes_100 += $value; } $total_tax_55 = 0.0; foreach($total_products_wo_taxes_55 as $value) { $total_tax_55 += $value; } $_total_taxes_55 = 0.0; foreach($total_taxes_55 as $value) { $_total_taxes_55 += $value; } $total_tax_21 = 0.0; foreach($total_products_wo_taxes_21 as $value) { $total_tax_21 += $value; } $_total_taxes_21 = 0.0; foreach($total_taxes_21 as $value) { $_total_taxes_21 += $value; } $total_tax_60 = 0.0; foreach($total_products_wo_taxes_60 as $value) { $total_tax_60 += $value; } $_total_taxes_60 = 0.0; foreach($total_taxes_60 as $value) { $_total_taxes_60 += $value; } $total_tax_40 = 0.0; foreach($total_products_wo_taxes_40 as $value) { $total_tax_40 += $value; } $_total_taxes_40 = 0.0; foreach($total_taxes_40 as $value) { $_total_taxes_40 += $value; } $total_tax_export = 0.0; foreach($total_products_wo_taxes_export as $value) { $total_tax_export += $value; } $tabs = array( // fr 8 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // be 3 => array('tax_210' => 0,'tax_60' => 0,'port' => 0,'discount' => 0), // es 6 => array('tax_210' => 0,'tax_40' => 0,'port' => 0,'discount' => 0), // it 10 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // de 1 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // gb 17 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // lu 12 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // pt 15 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), // nl 13 => array('tax_200' => 0,'tax_55' => 0,'tax_21' => 0,'port' => 0,'discount' => 0), ); switch ($address['id_country']) { case '8': $tabs[8] = array( 'tax_200' => $total_tax_200, 'tax_55' => $total_tax_55, 'tax_21' => $total_tax_21, 'port' => ($slip['shipping_cost'] == 1? (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196): 0.0), 'discount' => 0.0 ); break; case '3': $tabs[3] = array( 'tax_210' => $total_tax_210, 'tax_60' => $total_tax_60, 'port' => ($slip['shipping_cost'] == 1? (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196): 0.0), 'discount' => 0.0 ); break; case '6': $tabs[6] = array( 'tax_210' => $total_tax_210, 'tax_40' => $total_tax_40, 'port' => ($slip['shipping_cost'] == 1? (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196): 0.0), 'discount' => 0.0 ); break; case '10': case '1': case '12': case '13': case '15': case '17': $tabs[(int)$address['id_country']] = array( 'tax_200' => $total_tax_200, 'tax_55' => $total_tax_55, 'tax_21' => $total_tax_21, 'port' => ($slip['shipping_cost'] == 1? (float) $order['total_shipping'] / (strtotime($order['date_add']) >= mktime(0, 0, 0, 1, 1, 2014)? 1.2: 1.196): 0.0), 'discount' => 0.0 ); break; default: break; } fwrite($f, implode(';', array( ($order['payment'] == 'Paybox'?1:0), ($order['payment'] == 'PayPal'?1:0), 0, '-'.$tabs[8]['tax_200'], '-'.$tabs[8]['tax_55'], '-'.$tabs[8]['tax_21'], '-'.$tabs[8]['port'], '-'.$tabs[8]['discount'], '-'.$tabs[3]['tax_210'], '-'.$tabs[3]['tax_60'], '-'.$tabs[3]['port'], '-'.$tabs[3]['discount'], '-'.$tabs[6]['tax_210'], '-'.$tabs[6]['tax_40'], '-'.$tabs[6]['port'], '-'.$tabs[6]['discount'], '-'.$tabs[10]['tax_200'], '-'.$tabs[10]['tax_55'], '-'.$tabs[10]['tax_21'], '-'.$tabs[10]['port'], '-'.$tabs[10]['discount'], '-'.$tabs[1]['tax_200'], '-'.$tabs[1]['tax_55'], '-'.$tabs[1]['tax_21'], '-'.$tabs[1]['port'], '-'.$tabs[1]['discount'], '-'.$tabs[17]['tax_200'], '-'.$tabs[17]['tax_55'], '-'.$tabs[17]['tax_21'], '-'.$tabs[17]['port'], '-'.$tabs[17]['discount'], '-'.$tabs[12]['tax_200'], '-'.$tabs[12]['tax_55'], '-'.$tabs[12]['tax_21'], '-'.$tabs[12]['port'], '-'.$tabs[12]['discount'], '-'.$tabs[15]['tax_200'], '-'.$tabs[15]['tax_55'], '-'.$tabs[15]['tax_21'], '-'.$tabs[15]['port'], '-'.$tabs[15]['discount'], '-'.$tabs[13]['tax_200'], '-'.$tabs[13]['tax_55'], '-'.$tabs[13]['tax_21'], '-'.$tabs[13]['port'], '-'.$tabs[13]['discount'], ))."\n"); } } fclose($f); exit;