/**
 * Handle file upload from Manobo Client.
 * All umlauts in filename will be automatically removed.
 * @param String $upload_path Final upload target path
 * @param Boolean $add_yearly_path Add yearly path based on upload date
 * @param Boolean $add_monthly_path Add monthly path based on upload date
 * @param String $new_filename Set manually a new filename for uploaded file
 */
function uploadFileMCHandler($upload_path, $overwrite_filename = '')
{
    global $result;
    $file_name = convertGermanChar($overwrite_filename != '' ? $overwrite_filename : utf8_decode($_FILES['fileFromMC']['name']));
    $file_path = $upload_path . $file_name;
    $upload = move_uploaded_file($_FILES['fileFromMC']['tmp_name'], $file_path);
    $result['upload_status'] = $upload ? '1' : '0';
    return $file_path;
}
         $address_addition = $order['billing_street_address'];
     }
     $request['customerid'] = 'JG-' . $order['customers_id'];
     //$request['userid'] = '';
     //                    $request['salutation'] = $order['customer_billing_title'];
     //$request['title'] = '';
     list($request['firstname']) = split(" ", $order['billing_name']);
     $request['lastname'] = trim(substr($order['billing_name'], strlen($request['firstname']), strlen($order['billing_name']) - strlen($request['firstname'])));
     //$request['company'] = '';
     $request['street'] = $address_street;
     $request['addressaddition'] = $address_addition;
     $request['zip'] = $order['billing_postcode'];
     $request['city'] = $order['billing_city'];
     $request['country'] = getISO3166CountryCode($order['billing_country']);
     //ISO-3166
     $request['email'] = convertGermanChar($order['customers_email_address']);
     $request['telephonenumber'] = $order['customers_telephone'];
     //$request['birthday'] = ''; //YYYYMMDD
     //$request['language'] = ''; //ISO639
     //$request['vatid'] = '';
     //$request['ip'] = '';
 }
 //--SHIPPING INFO
 if ($is_sp) {
     $shipping_address = $order['customer_shipping_address'];
     if ($order['customer_shipping_address2'] != '') {
         if (strpos($order['customer_shipping_address2'], 'Postfilial') !== false) {
             $shipping_address = $order['customer_shipping_address2'] . ', ' . $shipping_address;
         } else {
             $shipping_address .= ', ' . $order['customer_shipping_address2'];
         }
$sp_type =  trim(tep_db_prepare_input($_GET['sp_type']));
*
*/
$order_id = trim(tep_db_prepare_input($_POST['order_id']));
$sp_type = trim(tep_db_prepare_input($_POST['sp_type']));
use_class('jng_sp_orders');
use_class('orders');
$class_jo = new jng_sp_orders();
$class_o = new orders();
$result = array();
if ($order_id != '' && $sp_type != '') {
    $result_data = getReturnedProducts($sp_type, $order_id);
}
if (isset($result_data) && is_array($result_data)) {
    foreach ($result_data as $key => $val) {
        $result[$key] = convertGermanChar($val);
    }
}
//echo '<pre>';var_dump($result);
function getReturnedProducts($sp_type, $order_id)
{
    $result = array();
    $returns = array();
    if (strtolower($sp_type) == 's') {
        //        $ret_query  = "SELECT joi.jng_sp_orders_items_id AS order_product_id, p.products_id, p.products_image, p.products_model, p.products_ean, pd.products_name";
        //        $ret_query .= " FROM jng_sp_orders jo";
        //        $ret_query .= " LEFT JOIN jng_sp sp ON sp.jng_sp_id=jo.jng_sp_id";
        //        $ret_query .= " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id";
        //        $ret_query .= " LEFT JOIN products p ON p.products_id=joi.products_id";
        //        $ret_query .= " LEFT JOIN products_description pd ON pd.products_id = p.products_id";
        //        $ret_query .= " WHERE jo.jng_sp_orders_id = $order_id AND joi.status IN (9,11) AND pd.language_id = 2";