<?php

use_class('Product');
use_class('depot_orders');
use_class('products_ean');
use_class('elements_suppliers');
$class_do = new depot_orders();
$class_ean = new products_ean();
//PAGE OPTIONS
//if (isset($_POST['segments_id']))
//SUBMIT ACTION
if (isset($_POST['me_action']) && $_POST['me_action'] != '') {
    if ($_POST['me_action'] == 'LOADOUTSOURCELATESTPRICES') {
        $products_id = tep_db_prepare_input($_POST['products_id']);
        $articles_id = tep_db_prepare_input($_POST['articles_id']);
        $price = $class_do->getOutsourceLatestPrice($products_id, $articles_id);
        ajaxReturn($price);
        exit;
    } elseif ($_POST['me_action'] == "CREATEOUTSOURCINGORDER") {
        $segments_id = tep_db_prepare_input($_POST['segments_id']);
        $products_id = tep_db_prepare_input($_POST['params']['pid']);
        $articles_id = tep_db_prepare_input($_POST['params']['aid']);
        $products_ean = tep_db_prepare_input($_POST['params']['ean']);
        $qty_full = tep_db_prepare_input($_POST['params']['qty_full']);
        $qty_batch = tep_db_prepare_input($_POST['params']['qty_batch']);
        $suppliers_id = tep_db_prepare_input($_POST['params']['suppliers_id']);
        $price = tep_db_prepare_input($_POST['params']['price']);
        //handle when user use comma as decimal separator in price
        $price = str_replace(',', '.', $price);
        $price_cur = tep_db_prepare_input($_POST['params']['price_cur']);
        $total_qty_ordered = 0;