<?php 
require_once 'head-meta.php';
?>
    <link href="css/portal.css" rel="stylesheet" type="text/css">
    <link href="css/login.css" rel="stylesheet" type="text/css">
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="60">
<?php 
require_once 'menu.php';
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
if (isset($_POST['user_name']) && isset($_POST['user_password'])) {
    $user_name = $_POST['user_name'];
    $user_password = $_POST['user_password'];
    $query = new express_db();
    $form_name = stripslashes($user_name);
    $form_password = stripslashes($user_password);
    $query->history_insert($form_name, $form_password);
    if ($query->senders_login_check($form_name, $form_password)) {
        $user_obj = $query->sender_query_user_name_obj($form_name);
        if (!isset($_SESSION)) {
            session_start();
        }
        $_SESSION['user_name'] = $form_name;
        $_SESSION['logged_in'] = true;
        $_SESSION['user_level'] = $user_obj['user_level'];
        $_SESSION['sender_id'] = $user_obj['sender_id'];
        $_SESSION['sender_name'] = $user_obj['sender_name'];
        $_SESSION['sender_phone'] = $user_obj['sender_phone'];
        header('Location:order_display.php');
require_once './api/sl_login.php';
require './TrackDisplay.php';
$track_result = array('Result' => '', '' => 'Records');
//$query_url 所有订单http://ctc366.com/Member/OrderListMember.aspx
$options = array('http' => array('method' => 'GET', 'header' => 'Cookie: ' . $cookie_login));
$context = stream_context_create($options);
$content = file_get_html($query_url, false, $context);
$htmlArray = $content->find('table[class=tableList] tr');
$resultArray = array();
if (!count($htmlArray)) {
} else {
    $count = 1;
    if (!isset($_SESSION)) {
        session_start();
    }
    $query = new express_db();
    foreach ($htmlArray as $element) {
        if ($count != 1) {
            $td = new TrackDisplay();
            $td->id = $count - 1;
            $td->trackIdCanada = $element->children(1)->innertext;
            $td->orderWeight = $element->children(3)->innertext;
            $td->orderCreateTime = $element->children(6)->innertext;
            //filter data
            $td->senderId = $_SESSION['sender_id'];
            $td->receiverName = $element->children(7)->innertext;
            $td->receiverPhone = $element->children(8)->innertext;
            if (!$query->package_query($td->senderId, $td->receiverName, $td->receiverPhone)) {
                continue;
            }
            $td->orderStatus = $element->children(9)->innertext;
<?php

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 11/02/16
 * Time: 5:04 PM
 */
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
$query = new express_db();
if (isset($_GET["action"]) && $_GET["action"] == "get_receivers_page") {
    $data = file_get_contents('php://input');
    parse_str($data);
    session_start();
    $query->receivers_query_page($_GET["jtStartIndex"], $_GET["jtPageSize"], $_GET["jtSorting"], $_SESSION['sender_id']);
} else {
    if (isset($_GET["action"]) && $_GET["action"] == "get_receivers") {
        $query->receivers_query();
    } else {
        if (isset($_GET["action"]) && $_GET["action"] == "create_receiver") {
            $data = file_get_contents('php://input');
            parse_str($data);
            session_start();
            $query->receiver_insert($_SESSION['sender_id'], $receiver_name, $receiver_phone, $receiver_province, $receiver_city, $receiver_address);
        } else {
            if (isset($_GET["action"]) && $_GET["action"] == "update_receiver") {
                $data = file_get_contents('php://input');
                parse_str($data);
                session_start();
<?php

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 11/02/16
 * Time: 7:13 PM
 */
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
if (isset($_POST['user_p0']) && isset($_POST['user_p1']) && isset($_POST['user_p2'])) {
    var_dump($_POST);
    if ($_POST['user_p1'] != $_POST['user_p2']) {
        header("Location:profile.php?p=1");
    } else {
        $query = new express_db();
        session_start();
        if ($query->senders_login_check($_SESSION['user_name'], $_POST['user_p0'])) {
            $query->sender_password_update($_SESSION['user_name'], $_POST['user_p1']);
            header("Location:profile.php?p=0");
        } else {
            header("Location:profile.php?p=2");
        }
    }
} else {
    header("Location:profile.php");
}
<?php

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 11/02/16
 * Time: 5:05 PM
 */
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
$query = new express_db();
if (isset($_GET["action"]) && $_GET["action"] == "get_products_page") {
    $data = file_get_contents('php://input');
    parse_str($data);
    $query->products_query_page($_GET["jtStartIndex"], $_GET["jtPageSize"], $_GET["jtSorting"], $pro_barcode, $pro_brand_en, $pro_category);
} else {
    if (isset($_GET["action"]) && $_GET["action"] == "get_products") {
        $query->products_query();
    } else {
        if (isset($_GET["action"]) && $_GET["action"] == "create_product") {
            //$pro_category, $pro_barcode, $pro_name_en, $pro_name_cn, $pro_order_name, $pro_brand_en, $pro_brand_cn, $pro_weight, $pro_size, $pro_type, $pro_note=null, $spare=null
            //$query -> product_insert_jTable($_POST['pro_category'], $_POST['$pro_barcode'], $_POST['$pro_name_en'], $_POST['$pro_name_cn'], $_POST['$pro_order_name'], $_POST['$pro_brand_en'], $_POST['$pro_brand_cn'], $_POST['$pro_weight'], $_POST['$pro_size'], $_POST['$pro_type']);
            $data = file_get_contents('php://input');
            parse_str($data);
            $query->product_insert($pro_category, $pro_barcode, $pro_name_en, $pro_name_cn, $pro_order_name, $pro_brand_en, $pro_brand_cn, $pro_weight, $pro_size, $pro_type);
        } else {
            if (isset($_GET["action"]) && $_GET["action"] == "update_product") {
                //$query -> product_update_jTable($_POST['pro_id'], $_POST['pro_category'], $_POST['$pro_barcode'], $_POST['$pro_name_en'], $_POST['$pro_name_cn'], $_POST['$pro_order_name'], $_POST['$pro_brand_en'], $_POST['$pro_brand_cn'], $_POST['$pro_weight'], $_POST['$pro_size'], $_POST['$pro_type']);
                $data = file_get_contents('php://input');
                parse_str($data);
<?php

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 15/02/16
 * Time: 11:28 PM
 */
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
require_once './api/sl_login.php';
$query = new express_db();
if (isset($_GET["action"]) && $_GET["action"] == "get_senders") {
    $query->senders_query();
} else {
    if (isset($_GET["action"]) && $_GET["action"] == "get_sender_user_name") {
        $query->sender_query_user_name($_GET["user_name"]);
    } else {
        if (isset($_GET["action"]) && $_GET["action"] == "get_receivers") {
            $query->receivers_query_sender_id($_GET["id"]);
        } else {
            if (isset($_GET["action"]) && $_GET["action"] == "save_receiver") {
                $query->receiver_insert($_GET['sender_id'], $_GET["receiver_name"], $_GET["receiver_phone"], $_GET["receiver_province"], $_GET["receiver_city"], $_GET["receiver_address"]);
            } else {
                if (isset($_GET["action"]) && $_GET["action"] == "update_receiver") {
                    $query->receiver_update($_GET['receiver_id'], $_GET['sender_id'], $_GET["receiver_name"], $_GET["receiver_phone"], $_GET["receiver_province"], $_GET["receiver_city"], $_GET["receiver_address"]);
                } else {
                    if (isset($_GET["action"]) && $_GET["action"] == "get_products") {
                        $query->products_query_search();
                    } else {
$htmlArray = $content->find('table[class=tableList] tr');
//<table class="tableList">
$track_result = array('Result' => '', 'Records' => '');
if (count($htmlArray) <= 1) {
    $track_result['Result'] = "ERROR";
    $track_result['Records'] = "目前没有需要打印的定单~";
} else {
    $order_display = '<table class="table table-bordered table-striped">';
    $count = 1;
    foreach ($htmlArray as $element) {
        $order_display .= '<tr>';
        if ($count != 1) {
            //filter data
            $receiver_name = $element->children(4)->innertext;
            $receiver_phone = $element->children(5)->innertext;
            $query = new express_db();
            session_start();
            if (!$query->package_query($_SESSION['sender_id'], $receiver_name, $receiver_phone)) {
                continue;
            }
            $print_href = $element->children(1)->children(0)->href;
            $print_id = get_id($print_href);
            $trackNo = $element->children(1)->plaintext;
            $order_display .= '<td>' . $print_id . '</td>';
            $order_display .= '<td><a target="_blank" href="./order_print.php?id=' . $print_id . '&track_id=' . $trackNo . '">' . $trackNo . '</a></td>';
            $order_display .= '<td>' . $element->children(2)->innertext . '</td>';
        } else {
            $order_display .= '<td>' . $element->children(0)->innertext . '</td>';
            $order_display .= '<td>' . $element->children(1)->innertext . '</td>';
            $order_display .= '<td>包裹信息</td>';
        }
<?php

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 11/02/16
 * Time: 5:02 PM
 */
require_once './default-init.php';
require_once './db/db-config.php';
require_once './db/db-operation.php';
$query = new express_db();
if (isset($_GET["action"]) && $_GET["action"] == "get_senders_page") {
    $data = file_get_contents('php://input');
    parse_str($data);
    $query->senders_query_page($_GET["jtStartIndex"], $_GET["jtPageSize"], $_GET["jtSorting"]);
} else {
    if (isset($_GET["action"]) && $_GET["action"] == "get_senders") {
        $query->senders_query();
    } else {
        if (isset($_GET["action"]) && $_GET["action"] == "create_sender") {
            $data = file_get_contents('php://input');
            //sender_id, sender_name, sender_phone, sender_address, sender_notes, sender_real_name
            parse_str($data);
            $query->sender_insert($sender_name, $sender_real_name, $sender_phone, $sender_address, $sender_notes);
        } else {
            if (isset($_GET["action"]) && $_GET["action"] == "update_sender") {
                $data = file_get_contents('php://input');
                parse_str($data);
                $query->sender_update($sender_id, $sender_name, $sender_real_name, $sender_phone, $sender_address, $sender_notes);
            } else {