Ejemplo n.º 1
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     if (FormLib::get_form_value('deptStart', False) !== false) {
         $start = FormLib::get_form_value('deptStart');
         $end = FormLib::get_form_value('deptEnd');
         $pageID = FormLib::get_form_value('sID', 0);
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $prodP = $dbc->prepare_statement("\n                SELECT p.upc\n                FROM products AS p\n                WHERE p.department BETWEEN ? AND ?\n            ");
         $prodR = $dbc->exec_statement($prodP, array($start, $end));
         $tag = new ShelftagsModel($dbc);
         $product = new ProductsModel($dbc);
         while ($row = $dbc->fetch_row($prodR)) {
             $product->upc($row['upc']);
             $info = $product->getTagData();
             $tag->id($pageID);
             $tag->upc($row['upc']);
             $tag->setData($info);
             $tag->save();
         }
         $this->msgs = sprintf('<em>Created tags for departments #%d through #%d</em>
                 <br /><a href="ShelfTagIndex.php">Home</a>', $start, $end);
     }
     return true;
 }
Ejemplo n.º 2
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $this->title = _("Fannie") . ' : ' . _("Manufacturer Shelf Tags");
     $this->header = _("Manufacturer Shelf Tags");
     if (FormLib::get_form_value('manufacturer', False) !== false) {
         $manu = FormLib::get_form_value('manufacturer');
         $pageID = FormLib::get_form_value('sID', 0);
         $cond = "";
         if (is_numeric($_REQUEST['manufacturer'])) {
             $cond = " p.upc LIKE ? ";
         } else {
             $cond = " p.brand LIKE ? ";
         }
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $prodP = $dbc->prepare_statement("\n                SELECT\n                    p.upc\n                FROM\n                    products AS p\n                WHERE {$cond}\n            ");
         $prodR = $dbc->exec_statement($prodP, array('%' . $manu . '%'));
         $tag = new ShelftagsModel($dbc);
         $product = new ProductsModel($dbc);
         while ($prodW = $dbc->fetch_row($prodR)) {
             $product->upc($prodW['upc']);
             $info = $product->getTagData();
             $tag->id($pageID);
             $tag->upc($prodW['upc']);
             $tag->setData($info);
             $tag->save();
         }
         $this->msgs = '<em>Created tags for manufacturer</em>
                 <br /><a href="ShelfTagIndex.php">Home</a>';
     }
     return true;
 }
Ejemplo n.º 3
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $id = FormLib::get_form_value('id', 0);
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $tags = new ShelftagsModel($dbc);
     $tags->id($id);
     $current_set = $tags->find();
     if (count($current_set) == 0) {
         $this->messages = '<div class="alert alert-info">
             Barcode table is already empty. <a href="ShelfTagIndex.php">Click here to continue</a>
             </div>';
         return true;
     }
     if (FormLib::get('submit', false) === '1') {
         /**
           Shelftags are not actually delete immediately
           Instead, the id field is negated so they disappear
           from view but can be manually retreived by IT if 
           someone comes complaining that they accidentally
           delete their tags (not that such a thing would
           ever occur). They're properly deleted by the 
           nightly.clipboard cron job.
         
           If the same user deletes the same UPC from tags
           multiple times in a day, the above procedure creates
           a primary key conflict. So any negative-id records
           that will create conflicts must be removed first.
         */
         $new_id = -1 * $id;
         if ($id == 0) {
             $new_id = -999;
         }
         $clear = new ShelftagsModel($dbc);
         $clear->id($new_id);
         foreach ($current_set as $tag) {
             // delete existing negative id tag for upc
             $clear->upc($tag->upc());
             $clear->delete();
             // save tag as negative id
             $old_id = $tag->id();
             $tag->id($new_id);
             $tag->save();
             $tag->id($old_id);
             $tag->delete();
         }
         $this->messages = '<div class="alert alert-success">
             Barcode table cleared <a href="ShelfTagIndex.php">Click here to continue</a>
             </div>';
         return true;
     } else {
         $this->messages = '<div class="alert alert-danger">
             <a href="DeleteShelfTags.php?id=' . $id . '&submit=1">Click 
             here to clear barcodes</a></div>';
         return true;
     }
     return true;
 }
Ejemplo n.º 4
0
 public function get_queueID_handler()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $tags = new ShelftagsModel($dbc);
     $tags->id($this->queueID);
     $this->u = array();
     foreach ($tags->find() as $tag) {
         $this->u[] = $tag->upc();
     }
     return $this->post_u_handler();
 }
Ejemplo n.º 5
0
 /**
   Create a one-item sale. Requires sample data
   for item, batch types
 */
 public function unitTest($phpunit)
 {
     $this->u = array('0001878777132');
     //14.99
     $this->post_u_handler();
     $phpunit->assertEquals(1, count($this->upcs));
     $post = $this->post_u_view();
     $phpunit->assertNotEquals(0, strlen($post));
     $form = new \COREPOS\common\mvc\ValueContainer();
     $form->upc = $this->u;
     $form->preferredVendor = 0;
     $this->setForm($form);
     ob_start();
     $this->post_redoSRPs_handler();
     $json = ob_get_clean();
     $arr = json_decode($json, true);
     $phpunit->assertInternalType('array', $arr);
     $phpunit->assertEquals(1, count($arr));
     $phpunit->assertEquals($this->u[0], $arr[0]['upc']);
     $phpunit->assertEquals(0, $arr[0]['srp']);
     $form->startDate = date('Y-m-d');
     $form->endDate = date('Y-m-d');
     $form->batchName = 'Test BatchFromSearch';
     $form->batchType = 3;
     // price change batch means tags get created
     $form->batchOwner = 'IT';
     $form->price = array(1.99);
     $form->tagset = 1;
     $this->setForm($form);
     $this->post_createBatch_handler();
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $batch = new BatchesModel($dbc);
     $batch->batchName('Test BatchFromSearch');
     $phpunit->assertEquals(1, count($batch->find()));
     $sale = new BatchListModel($dbc);
     $sale->upc($this->u[0]);
     $sale->salePrice(1.99);
     $phpunit->assertEquals(1, count($sale->find()));
     $tag = new ShelftagsModel($dbc);
     $tag->id(1);
     $tag->upc($this->u[0]);
     $phpunit->assertEquals(true, $tag->load());
 }
Ejemplo n.º 6
0
        $tag->units($units);
        $tag->vendor($vendor);
        $tag->pricePerUnit($ppo);
        $tag->save();
    }
    header("Location: index.php");
    return;
}
echo "<html><head><title>Edit shelftags</title>\n<style type=text/css>\n.one {\n    background: #ffffff;\n}\n.two {\n    background: #ffffcc;\n}\n</style></head>";
echo "<form action=edit.php method=post>";
echo "<table cellspacing=0 cellpadding=4 border=1>";
echo "<tr><th>UPC</th><th>Desc</th><th>Price</th><th>Brand</th><th>SKU</th>";
echo "<th>Size</th><th>Units</th><th>Vendor</th><th>PricePer</th></tr>";
$class = array("one", "two");
$c = 1;
$tags = new ShelftagsModel($sql);
$tags->id($id);
foreach ($tags->find() as $tag) {
    echo "<tr class={$class[$c]}>";
    echo "<td>" . $tag->upc() . "</td><input type=hidden name=upc[] value=\"" . $tag->upc() . "\" />";
    echo "<td><input type=text name=desc[] value=\"" . $tag->description() . "\" size=25 /></td>";
    echo "<td><input type=text name=price[] value=\"" . $tag->normal_price() . "\" size=5 /></td>";
    echo "<td><input type=text name=brand[] value=\"" . $tag->brand() . "\" size=13 /></td>";
    echo "<td><input type=text name=sku[] value=\"" . $tag->sku() . "\" size=6 /></td>";
    echo "<td><input type=text name=size[] value=\"" . $tag->size() . "\" size=6 /></td>";
    echo "<td><input type=text name=units[] value=\"" . $tag->units() . "\" size=4 /></td>";
    echo "<td><input type=text name=vendor[] value=\"" . $tag->vendor() . "\" size=7 /></td>";
    echo "<td><input type=text name=ppo[] value=\"" . $tag->pricePerUnit() . "\" size=10 /></td>";
    echo "</tr>";
    $c = ($c + 1) % 2;
}
Ejemplo n.º 7
0
 private function addToPos($upc, $vid, $price, $dept, $tags = -1)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $p = $dbc->prepare_statement("SELECT i.*,v.vendorName FROM vendorItems AS i\n            LEFT JOIN vendors AS v ON v.vendorID=i.vendorID\n            WHERE i.vendorID=? AND upc=?");
     $vinfo = $dbc->exec_statement($p, array($vid, $upc));
     $vinfo = $dbc->fetch_row($vinfo);
     $p = $dbc->prepare_statement("SELECT * FROM departments WHERE dept_no=?");
     $dinfo = $dbc->exec_statement($p, array($dept));
     $dinfo = $dbc->fetch_row($dinfo);
     $model = new ProductsModel($dbc);
     $model->upc(BarcodeLib::padUPC($upc));
     $model->description($vinfo['description']);
     $model->normal_price($price);
     $model->department($dept);
     $model->tax($dinfo['dept_tax']);
     $model->foodstamp($dinfo['dept_fs']);
     $model->cost($vinfo['cost']);
     $model->default_vendor_id($vid);
     $model->brand($vinfo['brand']);
     $model->store_id(1);
     $model->save();
     $xInsQ = $dbc->prepare_statement("INSERT INTO prodExtra (upc,manufacturer,distributor,cost,margin,variable_pricing,location,\n                case_quantity,case_cost,case_info) VALUES\n                (?,?,?,?,0.00,0,'','',0.00,'')");
     $args = array($upc, $vinfo['brand'], $vinfo['vendorName'], $vinfo['cost']);
     $dbc->exec_statement($xInsQ, $args);
     if ($tags !== -1) {
         $tag = new ShelftagsModel($dbc);
         $tag->id($tags);
         $tag->upc($upc);
         $info = $model->getTagData();
         $tag->normal_price($info['normal_price']);
         $tag->description($info['description']);
         $tag->brand($info['brand']);
         $tag->vendor($info['vendor']);
         $tag->sku($info['sku']);
         $tag->size($info['size']);
         $tag->units($info['units']);
         $tag->pricePerUnit($info['pricePerUnit']);
         $tag->save();
     }
     echo "Item added";
 }
Ejemplo n.º 8
0
                $updateBarR = $sql->execute($updateBarQ, array($value, $upc1));
            }
            if (substr($key, 0, 3) == 'del') {
                ${$key} = $value;
                $upc1 = substr($key, 3);
                $infoQ = $sql->prepare("select b.batchName,l.salePrice from batchListTest as l left join batchTest as b on b.batchID\n        = l.batchID where b.batchID = ? and l.upc = ?");
                $infoR = $sql->execute($infoQ, array($batchID, $upc1));
                $infoW = $sql->fetch_array($infoR);
                $name = $infoW[0];
                preg_match("/priceUpdate(.*?)\\d+/", $name, $matches);
                $name = $matches[1];
                $price = $infoW[1];
                $delItmQ = $sql->prepare("DELETE FROM batchListTest WHERE upc = ? and batchID = ?");
                $delItmR = $sql->execute($delItmQ, array($upc1, $batchID));
                $delBarR = $sql->execute($delBarQ, array($upc1, $price));
                $tags = new ShelftagsModel($sql);
                $tags->upc($upc1);
                $tags->normal_price($price);
                foreach ($tags->find as $tag) {
                    $tag->delete();
                }
            }
        }
    }
}
$batchInfoQ = $sql->prepare("SELECT * FROM batchTest WHERE batchID = ?");
$batchInfoR = $sql->execute($batchInfoQ, array($batchID));
$batchInfoW = $sql->fetch_array($batchInfoR);
$selBItemsQ = $sql->prepare("SELECT b.*,p.*  from batchListTest as b LEFT JOIN \n               products as p ON p.upc = b.upc WHERE batchID = ?\n               ORDER BY b.listID DESC");
//echo $selBItemsQ;
$selBItemsR = $sql->execute($selBItemsQ, array($batchID));
Ejemplo n.º 9
0
    public function delete_id_upc_view()
    {
        $dbc = $this->connection;
        $dbc->selectDB($this->config->get('OP_DB'));
        $tag = new ShelftagsModel($dbc);
        $tag->id($this->id);
        $tag->upc(BarcodeLib::padUPC($this->upc));
        $tag->load();
        $ret = <<<HTML
<form action="{{SELF}}" method="post">
<div class="panel panel-default">
    <div class="panel-heading">Selected Tag</div>
    <div class="panel-body">
        {{upc}} - {{brand}} {{description}}
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">Delete</div>
    <div class="panel-body">
        <div class="form-group">
            <a href="?_method=delete&id={{id}}&upc={{upc}}&confirm=1" class="btn btn-danger">
                {{ICON}} Remove Tag from Queue
            </a>
        </div>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">Move</div>
    <div class="panel-body">
        <div class="form-group">
            <label>Move to another Queue</label>
            <select name="newID" class="form-control">
                {{QUEUES}}
            </select>
        </div>
        <div class="form-group">
            <button class="btn btn-default" type="submit">Move Tag</button>
        </div>
        <input type="hidden" name="oldID" value="{{id}}" />
        <input type="hidden" name="upc" value="{{upc}}" />
    </div>
</div>
</form>
HTML;
        $queues = new ShelfTagQueuesModel($dbc);
        $ret = str_replace('{{SELF}}', $_SERVER['PHP_SELF'], $ret);
        $ret = str_replace('{{id}}', $this->id, $ret);
        $ret = str_replace('{{upc}}', $this->upc, $ret);
        $ret = str_replace('{{brand}}', $tag->brand(), $ret);
        $ret = str_replace('{{description}}', $tag->description(), $ret);
        $ret = str_replace('{{QUEUES}}', $queues->toOptions(), $ret);
        $ret = str_replace('{{ICON}}', \COREPOS\Fannie\API\lib\FannieUI::deleteIcon(), $ret);
        return $ret;
    }
Ejemplo n.º 10
0
        /* create a shelftag */
        $tag = new ShelftagsModel($dbc);
        $tag->id($sid);
        $tag->upc($upc);
        $tag->description($info['description']);
        $tag->normal_price($price);
        $tag->brand($info['brand']);
        $tag->sku($info['sku']);
        $tag->size($info['size']);
        $tag->units($info['units']);
        $tag->vendor($info['vendor']);
        $tag->pricePerUnit($info['pricePerUnit']);
        $tag->save();
        break;
    case 'batchDel':
        $vid = FormLib::get_form_value('vendorID');
        $bid = FormLib::get_form_value('batchID');
        $sid = FormLib::get_form_value('queueID', 0);
        if ($sid == 99) {
            $sid = 0;
        }
        $model = new BatchListModel($dbc);
        $model->batchID($bid);
        $model->upc($upc);
        $model->delete();
        $tag = new ShelftagsModel($dbc);
        $tag->id($sid);
        $tag->upc($upc);
        $tag->delete();
        break;
}
Ejemplo n.º 11
0
 protected function updateShelftagItem($upc, $brand, $description)
 {
     $dbc = $this->getDB();
     $model = new \ShelftagsModel($dbc);
     $model->id($this->source_id);
     $model->upc(\BarcodeLib::padUPC($upc));
     $model->brand($brand);
     $model->description($description);
     return $model->save();
 }
Ejemplo n.º 12
0
$id = 0;
$upc = $_REQUEST['upc'];
$description = $_REQUEST['description'];
$brand = $_REQUEST['brand'];
$units = $_REQUEST['units'];
if ($units == '') {
    $units = 'NULL';
}
$size = $_REQUEST['size'];
$ppo = $_REQUEST['ppo'];
$vendor = $_REQUEST['vendor'];
$sku = $_REQUEST['sku'];
$price = $_REQUEST['price'];
$id = $_REQUEST['subID'];
$count = FormLib::get('count', 1);
$shelftag = new ShelftagsModel($dbc);
$shelftag->id($id);
$shelftag->upc($upc);
$shelftag->normal_price($price);
$shelftag->pricePerUnit($ppo);
$shelftag->description($description);
$shelftag->brand($brand);
$shelftag->sku($sku);
$shelftag->size($size);
$shelftag->units($units);
$shelftag->vendor($vendor);
$shelftag->count($count);
$insR = $shelftag->save();
?>
<!doctype html>
<html>
Ejemplo n.º 13
0
}
$date = date('mjY');
$batchName = "priceUpdate" . $buyer . $date;
$insBatchQ = $sql->prepare("INSERT INTO batchTest(startDate,endDate,batchName,batchType,discounttype) \n              VALUES(" . $sql->now() . ',' . $sql->now() . ",?,7,0)");
//echo $insBatchQ;
$insBatchR = $sql->execute($insBatchQ, array($batchName));
$maxID = $sql->insert_id();
echo "<b>" . $buyer . "</b><br>";
echo "<html><head><title>Check tag info</title></head><body bgcolor='ffffcc'>";
echo "<table border=1 cellspacing=0 cellpadding=0><th>UPC<th><font color=blue>Description</font><th>SKU<th>Brand<th>Pack<th>Size<th>Price";
echo "<form action=newBarBatch.php method=Post>";
$getUNFIPriceQ = $sql->prepare('SELECT upc, srp as wfc_srp FROM vendorItems WHERE vendorID=1 AND upc=?');
$insBItemQ = $sql->prepare("INSERT INTO batchListTest(upc,batchID,salePrice)\n            VALUES(?,?,?)");
$getTagInfoQ = $sql->prepare('SELECT description as item_desc, sku as unfi_sku, brand, units as pack, size as pack_size
                            FROM vendorItems WHERE vendorID=1 AND upc LIKE ?');
$shelftag = new ShelftagsModel($sql);
foreach ($_POST["pricechange"] as $value) {
    //echo $getUNFIPriceQ . "<br>";
    $getUNFIPriceR = $sql->execute($getUNFIPriceQ, array($value));
    $getUNFIPriceW = $sql->fetch_array($getUNFIPriceR);
    $upc = $getUNFIPriceW['upc'];
    $upcl = ltrim($getUNFIPriceW['upc'], 0);
    $upcl = str_pad($upcl, 10, "0", STR_PAD_LEFT);
    //$upc = str_pad($upc,11,0,STR_PAD_LEFT);
    $unfiPrice = $getUNFIPriceW['wfc_srp'];
    $insBItemR = $sql->execute($insBItemQ, array($upc, $maxID, $unfiPrice));
    //echo $insBItemQ;
    //echo $getTagInfoQ;
    $getTagInfoR = $sql->execute($getTagInfoQ, array('%' . $upcl . '%'));
    $getTagInfoW = $sql->fetch_array($getTagInfoR);
    $desc = $getTagInfoW['item_desc'];