<?php

use_class('minierp_logistic');
$class_ml = new minierp_logistic();
$left_window_size = 360;
$last_logistic_id_without_cogs = 1169;
//AJAX ACTION
if (isset($_POST['me_action'])) {
    foreach ($_POST as $key => $value) {
        $_POST[$key] = utf8_decode($value);
    }
    if ($_POST['me_action'] == 'LOADPACKAGES') {
        $logistic_id = tep_db_prepare_input($_POST['logistic_id']);
        $use_cogs = $logistic_id > $last_logistic_id_without_cogs;
        $log_data = $class_ml->retrieveDetail($logistic_id);
        $result = '';
        if ($logistic_id == '') {
            $result .= '<div>&nbsp;</div>';
            $result .= '<div class="ui-corner-all red" style="margin-top:20px;background:#efefef;padding:10px;">' . 'Save first to add J&G / SP Package here</div>';
            $log_total = '0';
            $ptb_price = '0';
        } else {
            use_class('minierp_packages');
            $class_mp = new minierp_packages();
            use_class('jng_sp_packages');
            $class_jp = new jng_sp_packages();
            use_class('depot_orders');
            $class_do = new depot_orders();
            $po_list = array();
            $po_list_sp = $class_jp->getPackagesByDate($log_data['logistic_date']);
            $po_list_jg = $class_mp->getPackagesByDate($log_data['logistic_date']);
<?php

use_class('minierp_logistic');
$class_ml = new minierp_logistic();
$page = 1;
if (isset($_GET['page'])) {
    $page = $_GET['page'];
}
//START TEMPLATE
$content = $class_ml->manageLogisticList(ROWPERPAGE, $page);
$javascript = '
			var url = "index.php?open=packages-logistic-list";
			var zoomSpeed = 300;
			var fadeSpeed = 1000;
			$("#newlogpack").click(function() {
				$(this).siblings("a").click();
			});
			$("#fancy_close").click(function() {
				var is_iframe = ($(this).parent().find("iframe").attr("src")!=undefined);
				if(is_iframe) location.reload();
			});
';
$title = "List of Logistic Packages";
} else {
    if (isset($_GET['day']) && $_GET['day'] != '') {
        $day = tep_db_prepare_input($_GET['day']);
        $start_date = "{$year}-{$month}-{$day}";
        $end_date = $start_date;
    } else {
        $start_date = "{$year}-{$month}-01";
        $end_date = date('Y-m-t', strtotime($start_date));
    }
}
set_time_limit(0);
use_class('minierp_logistic');
use_class('product');
use_class('product_cogs');
use_class('products_minierp');
$class_ml = new minierp_logistic();
$class_pm = new products_minierp();
$bgst = $class_pm->retrieveBestGoodSettings();
$q = tep_db_query("SELECT * FROM minierp_logistic ml WHERE ml.logistic_date>='{$start_date}' AND ml.logistic_date<='{$end_date}'");
$total = array();
$total['Quantity'] = 0;
$total['Material Expense'] = 0;
$total['Indirect Material Expense'] = 0;
$total['Cost based on Complexity'] = 0;
$total['Varialbe Cost'] = 0;
$total['Fixed Cost'] = 0;
$total['Handling Cost'] = 0;
$total['COGS'] = 0;
$day_counter = 0;
echo '<div style="margin-top:20px;">Calculating';
while ($row = tep_db_fetch_array($q)) {
<?php

set_time_limit(0);
global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
require_once DIR_WS_FUNCTIONS . 'html_output.php';
tep_db_connect();
$bcids = explode(',', tep_db_prepare_input($_GET['bcid']));
$logistic_id = tep_db_prepare_input($_GET['logid']);
$log_partner = tep_db_prepare_input($_GET['logp']);
$new_status = tep_db_prepare_input($_GET['newstatus']);
if (count($bcids) > 0 && $logistic_id > 0 && $log_partner != '' && $new_status > 0) {
    use_class('minierp_logistic');
    $class_ml = new minierp_logistic();
    foreach ($bcids as $bcid) {
        $class_ml->removeFromPackage($logistic_id, $log_partner, $bcid, $new_status, 'manual');
        echo "Order {$bcid} removed from package \n";
    }
} else {
    echo "Input data not complete!";
}
tep_db_close();
<?php

global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
require_once '../functions-xml.php';
tep_db_connect();
define('FPDF_IMGPATH', DIR_WS_IMAGES . 'pdf/');
define('FPDF_FONTPATH', FPDF_IMGPATH . 'fonts/');
use_class('fpdf', DIR_WS_CLASSES);
use_class('minierp_logistic');
$class_ml = new minierp_logistic();
//if(isset($_GET['id']) && $_GET['id']!='') {
//$logistic_id = tep_db_prepare_input($_GET['id']);
if (isset($_POST['logistic_id']) && $_POST['logistic_id'] != '') {
    $logistic_id = tep_db_prepare_input($_POST['logistic_id']);
    $log_data = $class_ml->retrieveDetail($logistic_id);
    $log_header = $class_ml->retrieveData($logistic_id);
    $log_contents = $class_ml->retrieveContents($logistic_id);
    $log_date = strtotime($log_data['logistic_date']);
} else {
    exit;
}
class PDF extends FPDF
{
    var $left_margin;
    var $page_width;
    var $page_height;
    var $font_size;
    //Page header
<?php

global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
require_once '../functions-xml.php';
tep_db_connect();
define('FPDF_IMGPATH', DIR_WS_IMAGES . 'pdf/');
define('FPDF_FONTPATH', FPDF_IMGPATH . 'fonts/');
use_class('fpdf', DIR_WS_CLASSES);
use_class('minierp_logistic');
$class_ml = new minierp_logistic();
if (isset($_GET['logistic_id']) && $_GET['logistic_id'] != '') {
    $logistic_id = tep_db_prepare_input($_GET['logistic_id']);
    $use_cogs = isset($_GET['use_cogs']);
    $log_data = $class_ml->retrieveDetail($logistic_id);
    $log_date = strtotime($log_data['logistic_date']);
    $class_ml->PTBRetrieveContents($logistic_id, $use_cogs);
    //    $class_ml->PTBcalcContents($logistic_id);
    $cat_total = $class_ml->ptb_cat_total;
    $products = $class_ml->ptb_products;
} else {
    exit;
}
class PDF extends FPDF
{
    var $left_margin;
    var $top_margin;
    var $page_width;
    var $page_height;