break;
                            }
                        }
                        if (!is_null($etes)) {
                            if ($po->orders_id == '0') {
                                $po->suppliers_id = $supid;
                                $po->createNew($etes['price_currency'], $session_userinfo['username']);
                                $po_list[] = $po->orders_id;
                            }
                            $el_list[] = $eid;
                            $po->addItem($eid, $etes['elements_suppliers_id'], $eqty, $etes['price_quantity_type'], $etes['pieces_per_qty_type'], $etes['elements_price'], $etes['price_currency'], $session_userinfo['username']);
                        }
                    }
                }
            }
            $preorder->updateConnection(null, null, null, null, $po_list);
            $ajaxResult['po'] = count($po_list);
            $ajaxResult['elements'] = count($el_list);
        }
        ajaxReturn($ajaxResult);
        exit;
    }
}
if (count($preorder->elements_orders) > 0) {
    $content .= '<h3>PO is already created for this Preorder:</h3>';
    $content .= '<div class="draw-table">';
    $content .= '<table border="0" cellpadding="0" cellspacing="0">';
    $content .= '<thead><tr>';
    $content .= '<th>PO Number</th>';
    $content .= '<th>Suppliers</th>';
    $content .= '<th>Receive Status</th>';
             $total_rows_manual_cancel++;
             $logger->write('Order qty 0 / manual cancel');
         }
         #END foreach $orders
     }
     if ($total_orders_created > 0) {
         $total_files_with_imported_orders_yes++;
         if (!is_null($preorder->id)) {
             if (count($preorder_items_real) > 0) {
                 foreach ($preorder_items_real as $pid => $articles) {
                     foreach ($articles as $aid => $qty) {
                         $preorder->updateItemRealQuantity($pid, $aid, $qty);
                     }
                 }
             }
             $preorder->updateConnection(null, null, null, $orders_id_collection);
             $preorder->setAsClosed();
         }
         $logger->write("{$total_orders_created} ORDERS CREATED");
         if (!is_null($preorder->id)) {
             $preorder->updateItemRealQuantity($o['products_id'], $o['articles_id'], $o['order_quantity']);
         }
     } else {
         $total_files_with_imported_orders_no++;
         $logger->write('All orders are already imported before');
     }
     $class_jd->updateDownloadImported($file['jng_sp_download_id']);
     #END $total_orders > 0
 } else {
     $total_files_unprocessed++;
     $logger->write("No order found");