Example #1
0
<?php

include_once 'config.php';
try {
    if (isset($_GET['movID']) && $_GET['movID'] !== '') {
        $movID = $_GET['movID'];
        $link = new PDO($db_url, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
        // En la condiciĆ³n solo se toma en cuenta el Mov y MovID. Se omitiĆ³ la empresa porque actualmente el MovID es diferente en cada empresa.
        $handle = $link->prepare('SELECT id, movID, almacenDestino office, estatus status FROM ' . $table_inventory . ' WHERE Mov = :mov AND MovID = :movID');
        /*$handle = $link->prepare('SELECT '.$table_inventory.'.id, '.$table_inventory.'.mov, '.$table_inventory.'.movID, '.$table_article.'.fabricante, '.$table_inventory_detail.'.articulo code, '.$table_inventory_detail.'.cantidad requestQuantity, '.$table_inventory_existence.'.inventario inventoryQuantity, '.$table_inventory.'.empresa company, '.$table_inventory.'.almacen warehouse, '.$table_inventory.'.almacenDestino office, '.$table_inventory_detail.'.renglon row FROM '.$table_inventory.' JOIN '.$table_inventory_detail.' ON '.$table_inventory.'.ID = '.$table_inventory_detail.'.ID JOIN '.$table_article.' ON '.$table_inventory_detail.'.Articulo = '.$table_article.'.Articulo JOIN '.$table_inventory_existence.' ON '.$table_inventory_detail.'.Articulo = '.$table_inventory_existence.'.Articulo AND '.$table_inventory_existence.'.Almacen = '.$table_inventory_detail.'.Almacen WHERE '.$table_inventory_detail.'.SECCION IS NULL AND '.$table_inventory_existence.'.Inventario > 0 AND '.$table_inventory.'.Mov = :mov AND '.$table_inventory.'.MovID = :movID ORDER BY '.$table_article.'.Fabricante, '.$table_inventory_detail.'.Articulo, '.$table_inventory_detail.'.ID');*/
        $mov = 'Orden Traspaso';
        $handle->bindParam(':mov', $mov);
        $handle->bindParam(':movID', $movID);
        $handle->execute();
        if ($order = $handle->fetchObject()) {
            $order->products = getOrderDetail($link, $order);
            $order->totalProducts = getTotalProducts($link, $order);
            echo json_encode($order);
        } else {
            echo json_encode(false);
        }
    }
} catch (PDOException $ex) {
    error_log($ex->getMessage());
    print $ex->getMessage();
}
//@return: false. Fallo en la consulta.
function getOrderDetail($link, $order)
{
    include 'config.php';
    $handle = $link->prepare('SELECT invD.articulo code, invD.cantidad requestQuantity, invD.renglon row, invExistence.inventario inventoryQuantity FROM ' . $table_inventory_detail . ' invD JOIN ' . $table_article . ' art ON invD.articulo = art.articulo JOIN ' . $table_inventory_existence . ' invExistence ON invD.Articulo=invExistence.Articulo AND invExistence.Almacen=invD.Almacen WHERE invD.id = :id AND invD.seccion IS NULL AND invExistence.inventario > 0 ORDER BY art.fabricante, invD.articulo');
global $db;
require_once('../../confy.php');
require_once('../../functions.php');
require_once('../../functions-2.php');
tep_db_connect();

$process_type = trim(tep_db_prepare_input($_GET['process_type']));
$barcode = trim(tep_db_prepare_input($_GET['barcode']));
$idcode_ret = trim(tep_db_prepare_input($_GET['idcode_ret']));
*
*/
$process_type = trim(tep_db_prepare_input($_POST['process_type']));
$barcode = trim(tep_db_prepare_input($_POST['barcode']));
$idcode_ret = trim(tep_db_prepare_input($_POST['idcode_ret']));
if ($process_type == 'PHPSCANRETURNCODE') {
    $result_data = getOrderDetail($barcode, $idcode_ret);
}
if (isset($result_data) && is_array($result_data)) {
    foreach ($result_data as $key => $val) {
        $result[$key] = $val;
    }
}
//echo "<pre>";var_dump($result);
function getOrderDetail($barcode = '', $idcode_ret = '')
{
    //die("$barcode | $idcode_ret");
    $result = array();
    $result['status'] = 'MCORDERNOTFOUND';
    use_class('jng_sp');
    use_class('jng_sp_orders');
    if ($barcode != '') {