Example #1
0
?>

<?php 
if (isset($_POST['small_bar'])) {
    //here we need to provide an interface to detect barcode number in set so what is not empty is reall one processed
    $small_bar = $_POST['dbs0'];
    print "ADDING a cross reference to ";
    print $small_bar;
    $barcode = $small_bar;
    $item_id = $_POST['item_id'];
    $buyer_id = $_POST['buyer_id'];
    echo $item_id;
    echo $buyer_id;
    $added = insert_six_barcode_sells($item_id, $buyer_id, $barcode, $conn);
    //here we pick up the error messages
    $id_barcode = get_barcode_id($barcode);
    //This means if barcode is actually tested or not
    $TESTED = check_barcode_test($id_barcode);
    if ($TESTED == 1) {
        echo "tested";
    } else {
        echo "Not tested";
    }
    if ($added == 1) {
        echo $added;
        $MESG = "Item " . $barcode . " Sold.";
    } else {
        if ($added == 0) {
            $MESG = "Item failed to be sold.";
        }
    }
Example #2
0
function insert_six_barcode_sells($itemid, $buyerid, $barcode, $conn)
{
    connect_db();
    // $row = sqlsrv_fetch_array($stmt);
    //echo "User login: "******"</br>";
    $result = sqlsrv_query($conn, "select distinct Items.ItemID, Items.Title, Inventory.SKU, Orders.BuyerID, \r\nSales.SaleDate, Orders.StatusID, Shipments.TrackingNumber, Addresses.FirstName, Addresses.LastName,\r\nAddresses.AddressLine1,Addresses.AddressLine2,Addresses.AddressLine3,Addresses.City,\r\nAddresses.State,Addresses.PostalCode, Addresses.Country, Sales.eCommerceID, Sales.TransactionID, Orders.ExternalOrderID, Sales.SalePrice\r\nfrom Orders \r\nleft join Shipments on Shipments.OrderID=Orders.OrderID \r\nleft join Sales on Sales.ShipmentID = Shipments.ShipmentID \r\nINNER JOIN SalesPurchases ON SalesPurchases.SaleID=Sales.SaleID \r\nINNER JOIN Purchases ON Purchases.PurchaseID = SalesPurchases.PurchaseID  \r\nInner Join Inventory ON Inventory.InventoryID = Purchases.InventoryID\r\nINNER Join Addresses ON Addresses.AddressID=Shipments.ShippingAddressID\r\nINNER JOIN Items ON Items.ItemID = Inventory.ItemID where Orders.StatusID='100000' AND Items.ItemID='{$itemid}' AND Orders.BuyerID='{$buyerid}'");
    //Sales.SaleDate > '2013-11-29' AND Shipments.TrackingNumber='' AND
    if (!$result) {
        die('Query failed.');
    }
    $i = 0;
    echo "<table border='2'>";
    while ($row = sqlsrv_fetch_array($result)) {
        //echo "<td> ".$row[0]."</td><td> ".$row[1]."</td> <td>".$row[2]."</td><td> ".$row[3]."</td><td> ".$row[5]."</td><td> ".$row[6]."</td><td> ".$row[7]."</BR>".$row[8]."</td><td> ".$row[9]."</BR>".$row[10]."</BR> ".$row[11]."</td><td> ".$row[12]."</td><td> ".$row[13]."</td><td> ".$row[14]."</BR> ".$row[15]." </br>";
        $u_barcode = swap_back($row[2]);
        //this a stoc number in reality
        $ebaid = $row[16];
        $ebairef = $row[17];
        $tracking_number = $row[6];
        $user = 1;
        $date = $row[4];
        $item_id = $row[0];
        $itemid;
        $firstname = str_replace("'", "a", $row[7]);
        $lastname = str_replace("'", "a", $row[8]);
        //echo $itemid;
        echo $lastname;
        $unique = swap_back($_POST['un_barcode']);
        echo $unique;
        echo $firstname;
        $address1 = str_replace("'", "a", $row[9]);
        $address2 = str_replace("'", "a", $row[10]);
        $address3 = str_replace("'", "a", $row[11]);
        echo $address1;
        echo $address2;
        echo $address3;
        $city = $row[12];
        $state = $row[13];
        $postalcode = $row[14];
        $country = $row[15];
        $ebaysales = $row[18];
        $date_s = $row[4]->format('Y-m-d');
        $price = $row[19];
        //$date_s=$row[4];
        echo $date_s;
        $id_barcode = get_barcode_id($barcode);
        echo $id_Barcode;
        $FLAG_RDT_TO_GO = 0;
        global $BARCODE_COMM;
        if (empty($id_barcode)) {
            //empty barcode id. Means barcode does not exists in barcode table, Though does not exist
            $BARCODE_COMM = " Empty Barcode";
        } else {
            $FLAG_RDT_TO_GO = 1;
        }
        //checking ebay. Already sold
        //check if tested and passed test
        $test_result = check_barcode_test($id_barcode);
        if ($test_result == 1) {
            $FLAG_RDT_TO_GO = 1;
            echo "Tested it";
        } else {
            $FLAG_RDT_TO_GO = 0;
        }
        if ($FLAG_RDT_TO_GO == 1) {
            $result_ebay = check_barcode_ebay($barcode);
            if ($result_ebay == 1) {
                $FLAG_RDT_TO_GO = 1;
            } else {
                $FLAG_RDT_TO_GO = 0;
            }
        }
        //here we consider a case that needs current day to help tracking how many disposed that day
        $date_disposed = date("Y-m-d");
        //echo "</BR>ass ".$address1=explode(',',preg_replace('/^\[(.*)\]$/','$1',$address1));
        //here we take care of special characters conversion
        echo "first: " . $firstname;
        echo "last:" . $lastname;
        echo $lastname = str_replace(")", "", $lastname);
        //here is a problem (EMPA NW LTD)) No string compatibel
        echo $lastname = mysql_real_escape_string($lastname);
        $address1 = mysql_real_escape_string($address1);
        $address2 = mysql_real_escape_string($address2);
        $address3 = mysql_real_escape_string($address3);
        $city = mysql_real_escape_string($city);
        $state - mysql_real_escape_string($state);
        echo $insert = "INSERT INTO six_barcode(u_barcode, barcode_id_Barcode,ebayid, ebayref, tracking_num, parceler" . ",stock_number,date_ship,item_id,name,surname,address1,address2,address3,city,state,postalcode, country, ebaysales,price,date_disposed) VALUES('{$barcode}','{$id_barcode}','{$ebaid}','{$ebairef}','{$tracking_number}','{$id_user}','{$u_barcode}','{$date_s}','{$item_id}','{$firstname}','{$lastname}','{$address1}','{$address2}','{$address3}','{$city}','{$state}','{$postalcode}','{$country}','{$ebaysales}','{$price}','{$date_disposed}')";
        //echo $insert;
        if ($FLAG_RDT_TO_GO == 1) {
            $result = mysql_query($insert) or die(mysql_error());
        }
        echo $BARCODE_COMM;
        if ($result and $FLAG_RDT_TO_GO == 1) {
            return 1;
        } else {
            return 0;
        }
    }
}