コード例 #1
3
ファイル: DefaultPdfPoExport.php プロジェクト: phpsmith/IS4C
 function export_order($id)
 {
     global $FANNIE_OP_DB, $FANNIE_ROOT;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $order = new PurchaseOrderModel($dbc);
     $order->orderID($id);
     $order->load();
     $items = new PurchaseOrderItemsModel($dbc);
     $items->orderID($id);
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($order->vendorID());
     $vendor->load();
     $contact = new VendorContactModel($dbc);
     $contact->vendorID($order->vendorID());
     $contact->load();
     if (!class_exists('FPDF')) {
         include_once $FANNIE_ROOT . 'src/fpdf/fpdf.php';
     }
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', '12');
     $pdf->Cell(100, 5, 'Vendor: ' . $vendor->vendorName(), 0, 0);
     $pdf->Cell(100, 5, 'Date: ' . date('Y-m-d'), 0, 0);
     $pdf->Ln();
     $pdf->Cell(100, 5, 'Phone: ' . $contact->phone(), 0, 0);
     $pdf->Cell(100, 5, 'Fax: ' . $contact->fax(), 0, 0);
     $pdf->Ln();
     $pdf->Cell(100, 5, 'Email: ' . $contact->email(), 0, 0);
     $pdf->Cell(100, 5, 'Website: ' . $contact->website(), 0, 0);
     $pdf->Ln();
     $pdf->MultiCell(0, 5, "Ordering Info:\n" . $contact->notes(), 'B');
     $pdf->Ln();
     $cur_page = 0;
     $pdf->SetFontSize(10);
     foreach ($items->find() as $obj) {
         if ($cur_page != $pdf->PageNo()) {
             $cur_page = $pdf->PageNo();
             $pdf->Cell(25, 5, 'SKU', 0, 0);
             $pdf->Cell(20, 5, 'Order Qty', 0, 0);
             $pdf->Cell(30, 5, 'Brand', 0, 0);
             $pdf->Cell(65, 5, 'Description', 0, 0);
             $pdf->Cell(20, 5, 'Case Size', 0, 0);
             $pdf->Cell(20, 5, 'Est. Cost', 0, 0);
             $pdf->Ln();
         }
         $pdf->Cell(25, 5, $obj->sku(), 0, 0);
         $pdf->Cell(20, 5, $obj->quantity(), 0, 0, 'C');
         $pdf->Cell(30, 5, $obj->brand(), 0, 0);
         $pdf->Cell(65, 5, $obj->description(), 0, 0);
         $pdf->Cell(20, 5, $obj->caseSize(), 0, 0, 'C');
         $pdf->Cell(20, 5, sprintf('%.2f', $obj->caseSize() * $obj->unitCost() * $obj->quantity()), 0, 0);
         $pdf->Ln();
     }
     $pdf->Output('order_export.pdf', 'D');
 }
コード例 #2
0
ファイル: DefaultCsvPoExport.php プロジェクト: phpsmith/IS4C
 function export_order($id)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $order = new PurchaseOrderModel($dbc);
     $order->orderID($id);
     $order->load();
     $items = new PurchaseOrderItemsModel($dbc);
     $items->orderID($id);
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($order->vendorID());
     $vendor->load();
     echo 'Vendor,"' . $vendor->vendorName() . '",Order Date,' . date('Y-m-d') . "\r\n";
     echo "\r\n";
     echo "SKU,\"Order Qty\",Brand,Description,\"Case Size\",\"Est. Cost\"\r\n";
     foreach ($items->find() as $obj) {
         echo $obj->sku() . ',';
         echo $obj->quantity() . ',';
         echo '"' . $obj->brand() . '",';
         echo '"' . $obj->description() . '",';
         echo '"' . $obj->caseSize() . '",';
         printf('%.2f', $obj->unitCost() * $obj->caseSize() * $obj->quantity());
         echo "\r\n";
     }
 }
コード例 #3
0
ファイル: ProductListPage.php プロジェクト: phpsmith/IS4C
 function list_content()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $supertype = FormLib::get_form_value('supertype', 'dept');
     $manufacturer = FormLib::get_form_value('manufacturer', '');
     $mtype = FormLib::get_form_value('mtype', 'prefix');
     $deptStart = FormLib::get_form_value('deptStart', 0);
     $deptEnd = FormLib::get_form_value('deptEnd', 0);
     $deptMulti = FormLib::get('departments', array());
     $subDepts = FormLib::get('subdepts', array());
     $super = FormLib::get_form_value('deptSub');
     $vendorID = FormLib::get('vendor');
     $upc_list = FormLib::get('u', array());
     $inUse = FormLib::get('inUse', 1);
     $store = FormLib::get('store', 0);
     $sort = FormLib::get_form_value('sort', 'Department');
     $order = 'dept_name';
     if ($sort === 'UPC') {
         $order = 'i.upc';
     } elseif ($sort === 'Description') {
         $order = 'i.description, i.upc';
     }
     $ret = 'Report sorted by ' . $sort . '<br />';
     if ($supertype == 'dept' && $super === '') {
         $ret .= 'Department ' . $deptStart . ' to ' . $deptEnd . '<br />';
     } else {
         if ($supertype == 'dept') {
             $ret .= 'Sub department ' . $super . '<br />';
         } else {
             if ($supertype == 'manu') {
                 $ret .= _('Brand') . ' ' . $manufacturer . '<br />';
             } else {
                 if ($supertype == 'vendor') {
                     $vendor = new VendorsModel($dbc);
                     $vendor->vendorID($vendorID);
                     $vendor->load();
                     $ret .= 'Vendor ' . $vendor->vendorName() . '<br />';
                 }
             }
         }
     }
     $ret .= date("F j, Y, g:i a") . '<br />';
     $page_url = sprintf('ProductListPage.php?supertype=%s&deptStart=%s&deptEnd=%s&deptSub=%s&manufacturer=%s&mtype=%s&vendor=%d', $supertype, $deptStart, $deptEnd, $super, $manufacturer, $mtype, $vendorID);
     if (!$this->excel) {
         $ret .= '<form action="' . filter_input(INPUT_SERVER, 'PHP_SELF') . '" method="post" id="excel-form">
             <input type="hidden" name="supertype" value="' . $supertype . '" />
             <input type="hidden" name="deptStart" value="' . $deptStart . '" />
             <input type="hidden" name="deptEnd" value="' . $deptEnd . '" />
             <input type="hidden" name="deptSub" value="' . $super . '" />
             <input type="hidden" name="manufacturer" value="' . $manufacturer . '" />
             <input type="hidden" name="mtype" value="' . $mtype . '" />
             <input type="hidden" name="vendor" value="' . $vendorID . '" />
             <input type="hidden" name="inUse" value="' . $inUse . '" />
             <input type="hidden" name="excel" value="yes" />';
         if (is_array($subDepts)) {
             foreach ($subDepts as $s) {
                 $ret .= '<input type="hidden" name="subdepts[]" value="' . $s . '" />';
             }
         }
         if (is_array($upc_list)) {
             foreach ($upc_list as $u) {
                 $ret .= '<input type="hidden" name="u[]" value="' . $u . '" />';
             }
         }
         $ret .= '</form>';
         $ret .= sprintf('<a href="" onclick="$(\'#excel-form\').submit();return false;">Save to Excel</a> 
             &nbsp; &nbsp; <a href="%s">Back</a><br />', basename(__FILE__));
     }
     /** base select clause and joins **/
     $query = "\n            SELECT i.upc,\n                i.description,\n                i.brand,\n                d.dept_name as department,\n                i.normal_price,\n                (CASE WHEN i.tax = 1 THEN 'X' WHEN i.tax=0 THEN '-' ELSE LEFT(t.description,1) END) as Tax,              \n                (CASE WHEN i.foodstamp = 1 THEN 'X' ELSE '-' END) as FS,\n                (CASE WHEN i.discount = 0 THEN '-' ELSE 'X'END) as DISC,\n                (CASE WHEN i.scale = 1 THEN 'X' ELSE '-' END) as WGHd,\n                (CASE WHEN i.local > 0 AND o.originID IS NULL THEN 'X' \n                  WHEN i.local > 0 AND o.originID IS NOT NULL THEN LEFT(o.shortName,1) ELSE '-' END) as local,\n                COALESCE(v.vendorName, x.distributor) AS distributor,\n                i.cost,\n                i.store_id,\n                l.description AS storeName\n            FROM products as i \n                LEFT JOIN departments as d ON i.department = d.dept_no\n                LEFT JOIN taxrates AS t ON t.id = i.tax\n                LEFT JOIN prodExtra as x on i.upc = x.upc\n                LEFT JOIN vendors AS v ON i.default_vendor_id=v.vendorID\n                LEFT JOIN Stores AS l ON i.store_id=l.storeID\n                LEFT JOIN origins AS o ON i.local=o.originID";
     /** add extra joins if this lookup requires them **/
     if ($supertype == 'dept' && $super !== '') {
         if ($super >= 0) {
             $query .= ' LEFT JOIN superdepts AS s ON i.department=s.dept_ID ';
         } elseif ($super == -2) {
             $query .= ' LEFT JOIN MasterSuperDepts AS s ON i.department=s.dept_ID ';
         }
     } elseif ($supertype == 'vendor') {
         $query .= ' LEFT JOIN vendors AS z ON z.vendorName=x.distributor ';
     }
     /** build where clause and parameters based on
         the lookup type **/
     $query .= ' WHERE 1=1 ';
     $args = array();
     if ($supertype == 'dept' && $super !== '') {
         if ($super >= 0) {
             $query .= ' AND s.superID=? ';
             $args = array($super);
         } elseif ($super == -2) {
             $query .= ' AND s.superID <> 0 ';
         }
         if ($deptStart != 0 && $deptEnd != 0) {
             $query .= ' AND i.department BETWEEN ? AND ? ';
             $args[] = $deptStart;
             $args[] = $deptEnd;
         } elseif (count($deptMulti) > 0) {
             $query .= ' AND i.department IN (';
             foreach ($deptMulti as $d) {
                 $query .= '?,';
                 $args[] = $d;
             }
             $query = substr($query, 0, strlen($query) - 1) . ')';
         }
         if (is_array($subDepts) && count($subDepts) > 0) {
             $query .= ' AND i.subdept IN (';
             foreach ($subDepts as $s) {
                 $query .= '?,';
                 $args[] = $s;
             }
             $query = substr($query, 0, strlen($query) - 1) . ')';
         }
     } elseif ($supertype == 'manu' && $mtype == 'prefix') {
         $query .= ' AND i.upc LIKE ? ';
         $args = array('%' . $manufacturer . '%');
     } elseif ($supertype == 'manu' && $mtype != 'prefix') {
         $query .= ' AND (i.brand LIKE ? OR x.manufacturer LIKE ?) ';
         $args = array('%' . $manufacturer . '%', '%' . $manufacturer . '%');
     } elseif ($supertype == 'vendor') {
         $query .= ' AND (i.default_vendor_id=? OR z.vendorID=?) ';
         $args = array($vendorID, $vendorID);
     } elseif ($supertype == 'upc') {
         $inp = '';
         foreach ($upc_list as $u) {
             $inp .= '?,';
             $args[] = $u;
         }
         $inp = substr($inp, 0, strlen($inp) - 1);
         $query .= ' AND i.upc IN (' . $inp . ') ';
     } else {
         $query .= ' AND i.department BETWEEN ? AND ? ';
         $args = array($deptStart, $deptEnd);
         if (is_array($subDepts) && count($subDepts) > 0) {
             $query .= ' AND i.subdept IN (';
             foreach ($subDepts as $s) {
                 $query .= '?,';
                 $args[] = $s;
             }
         }
     }
     if ($inUse == 1) {
         $query .= ' AND i.inUse=1 ';
     } else {
         $query .= ' AND i.inUse=0 ';
     }
     if ($store > 0) {
         $query .= ' AND i.store_id=? ';
         $args[] = $store;
     }
     /** finish building query w/ order clause **/
     $query .= 'ORDER BY ' . $order;
     if ($order != "i.upc") {
         $query .= ",i.upc";
     }
     $prep = $dbc->prepare_statement($query);
     $result = $dbc->exec_statement($prep, $args);
     if ($result === false || $dbc->num_rows($result) == 0) {
         return 'No data found!';
     }
     $ret .= '<table class="table table-striped table-bordered tablesorter small">
         <thead>
         <tr>';
     $ret .= "<th>UPC</th><th>Brand</th><th>Description</th><th>Dept</th><th>" . _('Vendor') . "</th><th>Cost</th><th>Price</th>";
     $ret .= "<th>Tax</th><th>FS</th><th>Disc</th><th>Wg'd</th><th>Local</th>";
     if (!$this->excel && $this->canEditItems !== false) {
         $ret .= '<th>&nbsp;</th>';
     }
     $ret .= "</tr></thead><tbody>";
     $multi = $this->config->get('STORE_MODE') == 'HQ' ? true : false;
     while ($row = $dbc->fetch_row($result)) {
         $ret .= '<tr id="' . $row[0] . '">';
         $enc = base64_encode($row[1]);
         if (!$this->excel) {
             $ret .= "<td align=center class=\"td_upc\"><a href=ItemEditorPage.php?searchupc={$row['0']}>{$row['0']}</a>";
             if ($multi) {
                 $ret .= ' (' . substr($row['storeName'], 0, 1) . ')';
             }
             if ($this->canDeleteItems !== false) {
                 $ret .= " <a href=\"\" onclick=\"deleteCheck('{$row['0']}','{$enc}'); return false;\">";
                 $ret .= \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a>';
             }
             $ret .= '</td>';
             $ret .= '<input type="hidden" class="hidden_upc" value="' . $row[0] . '" />';
             $ret .= '<input type="hidden" class="hidden_store_id" value="' . $row['store_id'] . '" />';
         } else {
             $ret .= "<td align=center>{$row['0']}</td>";
         }
         $ret .= "<td align=center class=\"td_brand clickable\">{$row['brand']}</td>";
         $ret .= "<td align=center class=\"td_desc clickable\">{$row['description']}</td>";
         $ret .= "<td align=center class=\"td_dept clickable\">{$row['department']}</td>";
         $ret .= "<td align=center class=\"td_supplier clickable\">{$row['distributor']}</td>";
         $ret .= "<td align=center class=\"td_cost clickable\">" . sprintf('%.2f', $row['cost']) . "</td>";
         $ret .= "<td align=center class=\"td_price clickable\">{$row['normal_price']}</td>";
         $ret .= "<td align=center class=td_tax>{$row['Tax']}</td>";
         $ret .= "<td align=center class=td_fs>{$row['FS']}</td>";
         $ret .= "<td align=center class=td_disc>{$row['DISC']}</td>";
         $ret .= "<td align=center class=td_wgt>{$row['WGHd']}</td>";
         $ret .= "<td align=center class=td_local>{$row['local']}</td>";
         if (!$this->excel && $this->canEditItems !== False) {
             $ret .= "<td align=center class=td_cmd><a href=\"\" \n                    class=\"edit-link\"\n                    onclick=\"edit(\$(this).closest('tr')); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . '</a>
                 <a href="" class="save-link collapse"
                 onclick="save($(this).closest(\'tr\')); return false;">' . \COREPOS\Fannie\API\lib\FannieUI::saveIcon() . '</a></td>';
         }
         $ret .= "</tr>\n";
     }
     $ret .= '</tbody></table>';
     if ($this->excel) {
         header('Content-Type: application/ms-excel');
         header('Content-Disposition: attachment; filename="itemList.csv"');
         $array = \COREPOS\Fannie\API\data\DataConvert::htmlToArray($ret);
         $ret = \COREPOS\Fannie\API\data\DataConvert::arrayToCsv($array);
     } else {
         $this->add_script('../src/javascript/tablesorter/jquery.tablesorter.min.js');
         $this->add_onload_command("\$('.tablesorter').tablesorter();\n");
     }
     return $ret;
 }
コード例 #4
0
ファイル: VendorIndexPage.php プロジェクト: phpsmith/IS4C
 private function newVendor($name)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $id = 1;
     $p = $dbc->prepare_statement("SELECT max(vendorID) FROM vendors");
     $rp = $dbc->exec_statement($p);
     $rw = $dbc->fetch_row($rp);
     if ($rw[0] != "") {
         $id = $rw[0] + 1;
     }
     $model = new VendorsModel($dbc);
     $model->vendorID($id);
     $model->vendorName($name);
     $model->vendorAbbreviation(substr($name, 0, 10));
     $model->save();
     echo $id;
 }
コード例 #5
0
ファイル: ajax-calls.php プロジェクト: phpsmith/IS4C
function addUPC($orderID, $memNum, $upc, $num_cases = 1)
{
    global $FANNIE_OP_DB, $TRANS;
    $dbc = FannieDB::get($FANNIE_OP_DB);
    $sku = str_pad($upc, 6, '0', STR_PAD_LEFT);
    if (is_numeric($upc)) {
        $upc = BarcodeLib::padUPC($upc);
    }
    $manualSKU = false;
    if (isset($upc[0]) && $upc[0] == "+") {
        $sku = substr($upc, 1);
        $upc = "zimbabwe";
        // string that will not match
        $manualSKU = true;
    }
    $ins_array = genericRow($orderID);
    $ins_array['upc'] = "{$upc}";
    if ($manualSKU) {
        $ins_array['upc'] = BarcodeLib::padUPC($sku);
    }
    $ins_array['card_no'] = "{$memNum}";
    $ins_array['trans_type'] = "I";
    $caseSize = 1;
    $vendor = "";
    $vendor_desc = !is_numeric($upc) ? $upc : "";
    $srp = 0.0;
    $vendor_upc = !is_numeric($upc) ? '0000000000000' : "";
    $skuMatch = 0;
    $caseP = $dbc->prepare_statement("\n        SELECT units,\n            vendorName,\n            description,\n            i.srp,\n            i.upc,\n            CASE WHEN i.upc=? THEN 0 ELSE 1 END as skuMatch \n        FROM vendorItems as i\n            LEFT JOIN vendors AS v ON i.vendorID=v.vendorID \n        WHERE i.upc=? \n            OR i.sku=? \n            OR i.sku=?\n        ORDER BY i.vendorID");
    $caseR = $dbc->exec_statement($caseP, array($upc, $upc, $sku, '0' . $sku));
    if ($dbc->num_rows($caseR) > 0) {
        $row = $dbc->fetch_row($caseR);
        $caseSize = $row['units'];
        $vendor = $row['vendorName'];
        $vendor_desc = $row['description'];
        $srp = $row['srp'];
        $vendor_upc = $row['upc'];
        $skuMatch = $row['skuMatch'];
    }
    if (!empty($vendor_upc)) {
        $ins_array['upc'] = "{$vendor_upc}";
    }
    if ($skuMatch == 1) {
        $ins_array['upc'] = "{$vendor_upc}";
        $upc = $vendor_upc;
    }
    $ins_array['quantity'] = $caseSize;
    $ins_array['ItemQtty'] = $num_cases;
    $ins_array['mixMatch'] = substr($vendor, 0, 26);
    $ins_array['description'] = substr($vendor_desc, 0, 32) . " SO";
    $mempricing = false;
    if ($memNum != 0 && !empty($memNum)) {
        $p = $dbc->prepare_statement("SELECT Type,memType FROM custdata WHERE CardNo=?");
        $r = $dbc->exec_statement($p, array($memNum));
        $w = $dbc->fetch_row($r);
        if ($w['Type'] == 'PC') {
            $mempricing = true;
        } elseif ($w['memType'] == 9) {
            $mempricing = true;
        }
    }
    $pdP = $dbc->prepare_statement("\n        SELECT normal_price,\n            special_price,\n            department,\n            discounttype,\n            description,\n            discount,\n            default_vendor_id\n        FROM products WHERE upc=?");
    $pdR = $dbc->exec_statement($pdP, array($upc));
    $qtyReq = False;
    if ($dbc->num_rows($pdR) > 0) {
        $pdW = $dbc->fetch_row($pdR);
        $ins_array['department'] = $pdW['department'];
        $ins_array['discountable'] = $pdW['discount'];
        $mapP = $dbc->prepare_statement("SELECT map_to FROM \n                {$TRANS}SpecialOrderDeptMap WHERE dept_ID=?");
        $mapR = $dbc->exec_statement($mapP, array($pdW['department']));
        if ($dbc->num_rows($mapR) > 0) {
            $ins_array['department'] = array_pop($dbc->fetch_row($mapR));
        }
        $superP = $dbc->prepare_statement("SELECT superID \n                FROM superdepts WHERE dept_ID=?");
        $superR = $dbc->exec_statement($superP, array($ins_array['department']));
        while ($superW = $dbc->fetch_row($superR)) {
            if ($superW[0] == 5) {
                $qtyReq = 3;
            }
            if ($qtyReq !== false) {
                $caseSize = $qtyReq;
                $ins_array['quantity'] = $qtyReq;
                break;
            }
        }
        // only calculate prices for items that exist in
        // vendorItems (i.e., have known case size)
        $ins_array['discounttype'] = $pdW['discounttype'];
        if ($dbc->num_rows($caseR) > 0 || true) {
            // test always do this
            $ins_array['total'] = $pdW['normal_price'] * $caseSize * $num_cases;
            $ins_array['regPrice'] = $pdW['normal_price'] * $caseSize * $num_cases;
            $ins_array['unitPrice'] = $pdW['normal_price'];
            if ($pdW['discount'] != 0 && $pdW['discounttype'] == 1) {
                /**
                  Only apply sale pricing from non-closeout batches
                  At WFC closeout happens to be batch type #11
                */
                $closeoutP = $dbc->prepare('
                    SELECT l.upc
                    FROM batchList AS l
                        INNER JOIN batches AS b ON l.batchID=b.batchID
                    WHERE l.upc=?
                        AND ' . $dbc->curdate() . ' >= b.startDate
                        AND ' . $dbc->curdate() . ' <= b.endDate
                        AND b.batchType=11
                ');
                $closeoutR = $dbc->execute($closeoutP, array($upc));
                if ($closeoutR && $dbc->num_rows($closeoutR) == 0) {
                    $ins_array['total'] = $pdW['special_price'] * $caseSize * $num_cases;
                    $ins_array['unitPrice'] = $pdW['special_price'];
                }
            } elseif ($mempricing) {
                if ($pdW['discounttype'] == 2) {
                    $ins_array['total'] = $pdW['special_price'] * $caseSize * $num_cases;
                    $ins_array['unitPrice'] = $pdW['special_price'];
                } elseif ($pdW['discounttype'] == 3) {
                    $ins_array['unitPrice'] = $pdW['normal_price'] * (1 - $pdW['special_price']);
                    $ins_array['total'] = $ins_array['unitPrice'] * $caseSize * $num_cases;
                } elseif ($pdW['discounttype'] == 5) {
                    $ins_array['unitPrice'] = $pdW['normal_price'] - $pdW['special_price'];
                    $ins_array['total'] = $ins_array['unitPrice'] * $caseSize * $num_cases;
                }
                if ($pdW['discount'] != 0 && $pdW['normal_price'] * $caseSize * $num_cases * 0.85 < $ins_array['total']) {
                    $ins_array['total'] = $pdW['normal_price'] * $caseSize * $num_cases * 0.85;
                    $ins_array['discounttype'] = 0;
                    $ins_array['unitPrice'] = $pdW['normal_price'];
                }
            }
        }
        $ins_array['description'] = substr($pdW['description'], 0, 32);
        /**
          If product has a default vendor, lookup
          vendor name and add it
        */
        if ($pdW['default_vendor_id'] != 0) {
            $v = new VendorsModel($dbc);
            $v->vendorID($pdW['default_vendor_id']);
            if ($v->load()) {
                $ins_array['mixMatch'] = substr($v->vendorName(), 0, 26);
            }
        }
        /**
          If no vendor name was found, try looking in prodExtra
        */
        if (empty($ins_array['mixMatch']) && $dbc->tableExists('prodExtra')) {
            $distP = $dbc->prepare('
                SELECT x.distributor
                FROM prodExtra AS x
                WHERE x.upc=?
            ');
            $distR = $dbc->execute($distP, array($upc));
            if ($distR && $dbc->num_rows($distR) > 0) {
                $distW = $dbc->fetch_row($distR);
                $ins_array['mixMatch'] = substr($distW['distributor'], 0, 26);
            }
        }
    } elseif ($srp != 0) {
        // use vendor SRP if applicable
        $ins_array['regPrice'] = $srp * $caseSize * $num_cases;
        $ins_array['total'] = $srp * $caseSize * $num_cases;
        $ins_array['unitPrice'] = $srp;
        if ($mempricing) {
            $ins_array['total'] *= 0.85;
        }
    }
    $tidP = $dbc->prepare_statement("SELECT MAX(trans_id),MAX(voided),MAX(numflag) \n            FROM {$TRANS}PendingSpecialOrder WHERE order_id=?");
    $tidR = $dbc->exec_statement($tidP, array($orderID));
    $tidW = $dbc->fetch_row($tidR);
    $ins_array['trans_id'] = $tidW[0] + 1;
    $ins_array['voided'] = $tidW[1];
    $ins_array['numflag'] = $tidW[2];
    $dbc->smart_insert("{$TRANS}PendingSpecialOrder", $ins_array);
    return array($qtyReq, $ins_array['trans_id'], $ins_array['description']);
}
コード例 #6
0
 private function vendorDeptDisplay($id)
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $v = new VendorsModel($dbc);
     $v->vendorID($id);
     $v->load();
     $name = $v->vendorName();
     $ret = "<strong>Subcategories in {$name}</strong><br />";
     $ret .= "<table class=\"table\">";
     $ret .= "<tr><th>No.</th><th>Name</th><th>Margin</th><th>POS Dept#</th>\n            <th>&nbsp;</th><th>&nbsp;</th></tr>";
     $deptQ = $dbc->prepare_statement("\n            SELECT d.vendorID,\n                deptID,\n                name,\n                margin,\n                testing,\n                posDeptID\n            FROM vendorDepartments AS d\n            WHERE d.vendorID=?\n            ORDER BY deptID");
     $deptR = $dbc->exec_statement($deptQ, array($id));
     while ($row = $dbc->fetch_row($deptR)) {
         $ret .= sprintf("<tr id=\"row-%d\">\n                <td>%d</td>\n                <td id=nametd%d>%s</td>\n                <td id=margintd%d>%.2f%%</td>\n                <td id=posdepttd%d>%d</td>\n                <td id=button%d>\n                    <a href=\"\" onclick=\"edit(%d);return false;\"\n                        class=\"edit-link\">%s</a>\n                    <a href=\"\" onclick=\"save(%d);return false;\"\n                        class=\"save-link collapse\">%s</a>\n                </td>\n                <td><a href=\"\" onclick=\"deleteCat(%d,'%s');return false\">%s</a></td>\n                <td><a href=\"../../reports/VendorCategory/VendorCategoryReport.php?id=%d&category=%d\"\n                    title=\"View Items in this Category\">\n                    <span class=\"glyphicon glyphicon-th-list\"></span>\n                    </a></td>\n                </tr>", $row['deptID'], $row['deptID'], $row['deptID'], $row['name'], $row['deptID'], $row['margin'] * 100, $row['deptID'], $row['posDeptID'], $row['deptID'], $row['deptID'], \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $row['deptID'], \COREPOS\Fannie\API\lib\FannieUI::saveIcon(), $row['deptID'], $row['name'], \COREPOS\Fannie\API\lib\FannieUI::deleteIcon(), $id, $row['deptID']);
     }
     $ret .= "</table>";
     $ret .= '<p><a href="VendorIndexPage.php?vid=' . $id . '" class="btn btn-default">Home</a></p>';
     return $ret;
 }
コード例 #7
0
ファイル: ImportPurchaseOrder.php プロジェクト: phpsmith/IS4C
 function preview_content()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID(FormLib::get('vendorID'));
     $vendor->load();
     $ret = sprintf("<b>Batch Type</b>: %s <input type=hidden value=%d name=vendorID /><br />", $vendor->vendorName(), FormLib::get_form_value('vendorID'));
     $ret .= sprintf("<b>PO/Inv#</b>: %s <input type=hidden value=\"%s\" name=identifier /><br />", FormLib::get_form_value('identifier'), FormLib::get_form_value('identifier'));
     $ret .= sprintf("<b>Order Date</b>: %s <input type=hidden value=\"%s\" name=orderDate /><br />", FormLib::get_form_value('orderDate'), FormLib::get_form_value('orderDate'));
     $ret .= sprintf("<b>Recv'd Date</b>: %s <input type=hidden value=\"%s\" name=recvDate /><br />", FormLib::get_form_value('recvDate'), FormLib::get_form_value('recvDate'));
     return $ret;
 }
コード例 #8
0
ファイル: SaOrderingPage.php プロジェクト: phpsmith/IS4C
 public function preprocess()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB, $FANNIE_URL, $FANNIE_TRANS_DB;
     //$this->add_script($FANNIE_URL.'src/javascript/jquery.js');
     //$this->add_script($FANNIE_URL.'src/javascript/jquery-ui.js');
     if (FormLib::get('upc_in') !== '') {
         $upc = BarcodeLib::padUPC(FormLib::get('upc_in'));
         $this->current_item_data['upc'] = $upc;
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $model = new ProductsModel($dbc);
         $model->upc($upc);
         $vendorID = 0;
         if ($model->load()) {
             $this->current_item_data['desc'] = $model->brand() . ' ' . $model->description();
             $this->current_item_data['par'] = $model->auto_par();
             $vendorID = $model->default_vendor_id();
         }
         $model = new VendorsModel($dbc);
         $model->vendorID($vendorID);
         if ($model->load()) {
             $this->current_item_data['vendor'] = $model->vendorName();
             $schedule = new VendorDeliveriesModel($dbc);
             $schedule->vendorID($vendorID);
             if ($schedule->load() && $schedule->regular() == 1) {
                 $this->current_item_data['nextDelivery'] = date('D, M jS', strtotime($schedule->nextDelivery())) . ' & ' . date('D, M jS', strtotime($schedule->nextNextDelivery()));
                 $nd = new DateTime(date('Y-m-d', strtotime($schedule->nextDelivery())));
                 $nnd = new DateTime(date('Y-m-d', strtotime($schedule->nextNextDelivery())));
                 $this->current_item_data['deliverySpan'] = $nnd->diff($nd)->format('%a');
             }
             $items = new VendorItemsModel($dbc);
             $items->vendorID($vendorID);
             $items->upc($upc);
             $this->current_item_data['cases'] = array();
             foreach ($items->find('units') as $item) {
                 $this->current_item_data['cases'][] = $item->units();
             }
         }
         $saleNow = 'SELECT b.batchName, b.startDate, b.endDate
                     FROM batchList AS l
                         INNER JOIN batches AS b ON b.batchID=l.batchID
                     WHERE l.upc=?
                         AND b.discounttype <> 0
                         AND b.startDate <= ' . $dbc->now() . '
                         AND b.endDate >= ' . $dbc->now();
         $saleNow = $dbc->prepare($saleNow);
         $saleNow = $dbc->execute($saleNow, array($upc));
         if ($dbc->num_rows($saleNow) > 0) {
             $row = $dbc->fetch_row($saleNow);
             $this->current_item_data['onSale'] = $row['batchName'] . ' thru ' . date('D, M jS', strtotime($row['endDate']));
         }
         $saleNext = 'SELECT b.batchName, b.startDate, b.endDate
                     FROM batchList AS l
                         INNER JOIN batches AS b ON b.batchID=l.batchID
                     WHERE l.upc=?
                         AND b.discounttype <> 0
                         AND b.startDate >= ' . $dbc->now() . '
                         AND b.endDate >= ' . $dbc->now();
         $saleNext = $dbc->prepare($saleNext);
         $saleNext = $dbc->execute($saleNext, array($upc));
         if ($dbc->num_rows($saleNext) > 0) {
             $row = $dbc->fetch_row($saleNext);
             $this->current_item_data['soonSale'] = $row['batchName'] . ' on ' . date('D, M jS', strtotime($row['startDate']));
         }
         $ordersQ = 'SELECT v.vendorName,
                         o.placedDate,
                         i.quantity,
                         i.caseSize
                     FROM PurchaseOrderItems AS i
                         INNER JOIN PurchaseOrder AS o ON i.orderID=o.orderID
                         INNER JOIN vendors AS v ON o.vendorID=v.vendorID
                     WHERE i.internalUPC = ?
                     ORDER BY o.placedDate DESC';
         $ordersQ = $dbc->add_select_limit($ordersQ, 10);
         $ordersP = $dbc->prepare($ordersQ);
         $ordersR = $dbc->execute($ordersP, array($upc));
         $orders = array();
         while ($w = $dbc->fetch_row($ordersR)) {
             $orders[] = $w;
         }
         $this->current_item_data['orders'] = $orders;
         $salesQ = 'SELECT ' . DTrans::sumQuantity('d') . ' AS qty,
                     MIN(tdate) as day
                    FROM ' . $FANNIE_TRANS_DB . $dbc->sep() . 'dlog_15 AS d
                    WHERE upc = ?
                    GROUP BY YEAR(tdate), MONTH(tdate), DAY(tdate)
                    ORDER BY YEAR(tdate) DESC, MONTH(tdate) DESC, DAY(tdate) DESC';
         $salesP = $dbc->prepare($salesQ);
         $salesR = $dbc->execute($salesP, array($upc));
         $sales = array();
         while ($w = $dbc->fetch_row($salesR)) {
             $sales[] = $w;
         }
         $this->current_item_data['sales'] = $sales;
     }
     $this->linea_ios_mode = $this->linea_support_available();
     if ($this->linea_ios_mode) {
         $this->add_script($FANNIE_URL . 'src/javascript/linea/cordova-2.2.0.js');
         $this->add_script($FANNIE_URL . 'src/javascript/linea/ScannerLib-Linea-2.0.0.js');
     }
     $this->add_script($FANNIE_URL . 'src/javascript/tablesorter/jquery.tablesorter.js');
     $this->add_css_file($FANNIE_URL . 'src/javascript/tablesorter/themes/blue/style.css');
     //$this->add_css_file($FANNIE_URL.'src/javascript/jquery-ui.css');
     return true;
 }
コード例 #9
0
 public function get_id_view()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($this->id);
     $vendor->load();
     $ret = '<p id="vendor-name">New <strong>' . $vendor->vendorName() . '</strong> order</p>';
     $ret .= '<div id="alert-area"></div>';
     $ret .= '<form id="order-form" onsubmit="saveOrder(); return false;">
         <input type="hidden" id="vendor-id" name="id" value="' . $this->id . '" />
         <div class="form-group form-inline">
             <label>Order Date</label>
             <input type="text" name="order-date" class="form-control date-field"
                 value="' . date('Y-m-d') . '" />
             <label>PO #</label>
             <input type="text" name="po-number" class="form-control" />
             <label>Inv. #</label>
             <input type="text" name="inv-number" class="form-control" />
         </div>';
     $ret .= '<div class="collapse" id="delete-html">' . FannieUI::deleteIcon() . '</div>';
     $ret .= '<div class="form-group">
         <button type="button" class="btn btn-default" onclick="addInvoiceLine();">Add Line</button>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <button type="submit" class="btn btn-default" id="save-btn">Save As Order</button>
         </div>';
     $ret .= '<table class="table table-bordered" id="invoice-table">
         <thead><tr>
             <th>SKU</th>
             <th>UPC</th>
             <th>Cases</th>
             <th>Units/Case</th>
             <th>Total Cost</th>
             <th>Brand</th>
             <th>Description</th>
         </thead>
         <tbody>
         </tbody>
         </table>';
     $ret .= '</form>';
     $this->addScript('js/manual.js');
     $this->addScript('../item/autocomplete.js');
     $this->addOnloadCommand('addInvoiceLine();');
     return $ret;
 }
コード例 #10
0
ファイル: BaseItemModule.php プロジェクト: phpsmith/IS4C
 function AjaxCallback()
 {
     $db = $this->db();
     $json = array();
     if (FormLib::get('action') == 'addVendor') {
         $name = FormLib::get('newVendorName');
         if (empty($name)) {
             $json['error'] = 'Name is required';
         } else {
             $vendor = new VendorsModel($db);
             $vendor->vendorName($name);
             if (count($vendor->find()) > 0) {
                 $json['error'] = 'Vendor "' . $name . '" already exists';
             } else {
                 $max = $db->query('SELECT MAX(vendorID) AS max
                                    FROM vendors');
                 $newID = 1;
                 if ($max && ($maxW = $db->fetch_row($max))) {
                     $newID = (int) $maxW['max'] + 1;
                 }
                 $vendor->vendorAbbreviation(substr($name, 0, 10));
                 $vendor->vendorID($newID);
                 $vendor->save();
                 $json['vendorID'] = $newID;
                 $json['vendorName'] = $name;
             }
         }
     } elseif (FormLib::get('dept_defaults') !== '') {
         $json = array('tax' => 0, 'fs' => False, 'nodisc' => False);
         $dept = FormLib::get_form_value('dept_defaults', '');
         $p = $db->prepare_statement('SELECT dept_tax,dept_fs,dept_discount
                 FROM departments WHERE dept_no=?');
         $r = $db->exec_statement($p, array($dept));
         if ($db->num_rows($r)) {
             $w = $db->fetch_row($r);
             $json['tax'] = $w['dept_tax'];
             if ($w['dept_fs'] == 1) {
                 $json['fs'] = True;
             }
             if ($w['dept_discount'] == 0) {
                 $json['nodisc'] = True;
             }
         }
     } elseif (FormLib::get('vendorChanged') !== '') {
         $v = new VendorsModel($db);
         $v->vendorName(FormLib::get('vendorChanged'));
         $matches = $v->find();
         $json = array('error' => false);
         if (count($matches) == 1) {
             $json['localID'] = $matches[0]->localOriginID();
             $json['vendorID'] = $matches[0]->vendorID();
         } else {
             $json['error'] = true;
         }
     }
     echo json_encode($json);
 }
コード例 #11
0
ファイル: ViewPurchaseOrders.php プロジェクト: phpsmith/IS4C
 function get_id_view()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $order = new PurchaseOrderModel($dbc);
     $order->orderID($this->id);
     $order->load();
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($order->vendorID());
     $vendor->load();
     $ret = '<p><div class="form-inline">';
     $ret .= '<b>Vendor</b>: ' . $vendor->vendorName();
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<b>Created</b>: ' . $order->creationDate();
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<b>Placed</b>: <span id="orderPlacedSpan">' . ($order->placed() ? $order->placedDate() : 'n/a') . '</span>';
     $ret .= '<input type="checkbox" ' . ($order->placed() ? 'checked' : '') . ' id="placedCheckbox"
             onclick="togglePlaced(' . $this->id . ');" />';
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= 'Export as: <select id="exporterSelect" class="form-control">';
     $dh = opendir('exporters');
     while (($file = readdir($dh)) !== False) {
         if (substr($file, -4) != '.php') {
             continue;
         }
         include 'exporters/' . $file;
         $class = substr($file, 0, strlen($file) - 4);
         if (!class_exists($class)) {
             continue;
         }
         $obj = new $class();
         if (!isset($obj->nice_name)) {
             continue;
         }
         $ret .= '<option value="' . $class . '">' . $obj->nice_name . '</option>';
     }
     $ret .= '</select> ';
     $ret .= '<button type="submit" class="btn btn-default" onclick="doExport(' . $this->id . ');return false;">Export</button>';
     $ret .= '&nbsp;&nbsp;&nbsp;';
     $init = $order->placed() ? 'init=placed' : 'init=pending';
     $ret .= '<button type="button" class="btn btn-default" 
         onclick="location=\'ViewPurchaseOrders.php?' . $init . '\'; return false;">All Orders</button>';
     $ret .= '</div></p>';
     $ret .= '<div class="row"><div class="col-sm-6">';
     $ret .= '<table class="table table-bordered"><tr><th colspan="2">Coding(s)</th>';
     $ret .= '<td><b>PO#</b>: ' . $order->vendorOrderID() . '</td>';
     $ret .= '<td><b>Invoice#</b>: ' . $order->vendorInvoiceID() . '</td>';
     $ret .= '</tr>';
     $ret .= '{{CODING}}';
     $ret .= '</table>';
     $ret .= '</div><div class="col-sm-6">';
     if (!$order->placed()) {
         $ret .= '<button class="btn btn-default"
             onclick="location=\'EditOnePurchaseOrder.php?id=' . $order->vendorID() . '\'; return false;">Add Items</button>';
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         $ret .= '<button class="btn btn-default" onclick="deleteOrder(' . $this->id . '); return false;">Delete Order</button>';
     } else {
         $ret .= '<a class="btn btn-default"
             href="ManualPurchaseOrderPage.php?id=' . $order->vendorID() . '&adjust=' . $this->id . '">Edit Order</a>';
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         $ret .= '<a class="btn btn-default"
             href="ViewPurchaseOrders.php?id=' . $this->id . '&receive=1">Receive Order</a>';
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         $ret .= '<a class="btn btn-default"
             href="ViewPurchaseOrders.php?id=' . $this->id . '&recode=1">Alter Codings</a>';
     }
     $ret .= '</div></div>';
     $model = new PurchaseOrderItemsModel($dbc);
     $model->orderID($this->id);
     $codings = array();
     $accounting = $this->config->get('ACCOUNTING_MODULE');
     if (!class_exists($accounting)) {
         $accounting = '\\COREPOS\\Fannie\\API\\item\\Accounting';
     }
     $ret .= '<table class="table tablesorter"><thead>';
     $ret .= '<tr><th>Coding</th><th>SKU</th><th>UPC</th><th>Brand</th><th>Description</th>
         <th>Unit Size</th><th>Units/Case</th><th>Cases</th>
         <th>Est. Cost</th><th>&nbsp;</th><th>Received</th>
         <th>Rec. Qty</th><th>Rec. Cost</th></tr></thead><tbody>';
     foreach ($model->find() as $obj) {
         $css = '';
         if ($obj->receivedQty() == 0 && $obj->quantity() != 0) {
             $css = 'class="danger"';
         } elseif ($obj->receivedQty() < $obj->quantity()) {
             $css = 'class="warning"';
         }
         if ($obj->salesCode() == '') {
             $code = $obj->guessCode();
             $obj->salesCode($code);
             $obj->save();
         }
         $coding = (int) $obj->salesCode();
         $coding = $accounting::toPurchaseCode($coding);
         if (!isset($codings[$coding])) {
             $codings[$coding] = 0.0;
         }
         $codings[$coding] += $obj->receivedTotalCost();
         $ret .= sprintf('<tr %s><td>%d</td><td>%s</td>
                 <td><a href="../item/ItemEditorPage.php?searchupc=%s">%s</a></td><td>%s</td><td>%s</td>
                 <td>%s</td><td>%s</td><td>%d</td><td>%.2f</td>
                 <td>&nbsp;</td><td>%s</td><td>%d</td><td>%.2f</td>
                 </tr>', $css, $accounting::toPurchaseCode($obj->salesCode()), $obj->sku(), $obj->internalUPC(), $obj->internalUPC(), $obj->brand(), $obj->description(), $obj->unitSize(), $obj->caseSize(), $obj->quantity(), $obj->quantity() * $obj->caseSize() * $obj->unitCost(), date('Y-m-d', strtotime($obj->receivedDate())), $obj->receivedQty(), $obj->receivedTotalCost());
     }
     $ret .= '</tbody></table>';
     $coding_rows = '';
     foreach ($codings as $coding => $ttl) {
         $coding_rows .= sprintf('<tr><td>%d</td><td>%.2f</td></tr>', $coding, $ttl);
     }
     $ret = str_replace('{{CODING}}', $coding_rows, $ret);
     $this->add_script('js/view.js');
     $this->add_script('../src/javascript/tablesorter/jquery.tablesorter.min.js');
     $this->addOnloadCommand("\$('.tablesorter').tablesorter();\n");
     return $ret;
 }
コード例 #12
0
 public function get_id_view()
 {
     $this->addScript('pricing-batch.js');
     $dbc = $this->connection;
     $dbc->selectDB($this->config->OP_DB);
     $superID = FormLib::get_form_value('super', 99);
     $queueID = FormLib::get('queueID');
     $vendorID = $this->id;
     $filter = FormLib::get_form_value('filter') == 'Yes' ? True : False;
     /* lookup vendor and superdept names to build a batch name */
     $sname = "All";
     if ($superID != 99) {
         $smodel = new SuperDeptNamesModel($dbc);
         $smodel->superID($superID);
         $smodel->load();
         $sname = $smodel->super_name();
     }
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($vendorID);
     $vendor->load();
     $batchName = $sname . " " . $vendor->vendorName() . " PC " . date('m/d/y');
     /* find a price change batch type */
     $types = new BatchTypeModel($dbc);
     $types->discType(0);
     $bType = 0;
     foreach ($types->find() as $obj) {
         $bType = $obj->batchTypeID();
         break;
     }
     /* get the ID of the current batch. Create it if needed. */
     $bidQ = $dbc->prepare("\n            SELECT batchID \n            FROM batches \n            WHERE batchName=? \n                AND batchType=? \n                AND discounttype=0\n            ORDER BY batchID DESC");
     $bidR = $dbc->execute($bidQ, array($batchName, $bType));
     $batchID = 0;
     if ($dbc->numRows($bidR) == 0) {
         $b = new BatchesModel($dbc);
         $b->batchName($batchName);
         $b->startDate('1900-01-01');
         $b->endDate('1900-01-01');
         $b->batchType($bType);
         $b->discountType(0);
         $b->priority(0);
         $batchID = $b->save();
     } else {
         $bidW = $dbc->fetchRow($bidR);
         $batchID = $bidW['batchID'];
     }
     $ret = sprintf('<b>Batch</b>: 
                 <a href="%sbatches/newbatch/BatchManagementTool.php?startAt=%d">%s</a>', $this->config->URL, $batchID, $batchName);
     $ret .= sprintf("<input type=hidden id=vendorID value=%d />\n            <input type=hidden id=batchID value=%d />\n            <input type=hidden id=queueID value=%d />\n            <input type=hidden id=superID value=%d />", $vendorID, $batchID, $queueID, $superID);
     $batchUPCs = array();
     $batchList = new BatchListModel($dbc);
     $batchList->batchID($batchID);
     foreach ($batchList->find() as $obj) {
         $batchUPCs[$obj->upc()] = true;
     }
     $costSQL = Margin::adjustedCostSQL('v.cost', 'b.discountRate', 'b.shippingMarkup');
     $marginSQL = Margin::toMarginSQL($costSQL, 'p.normal_price');
     $p_def = $dbc->tableDefinition('products');
     $marginCase = '
         CASE 
             WHEN g.margin IS NOT NULL AND g.margin <> 0 THEN g.margin
             WHEN s.margin IS NOT NULL AND s.margin <> 0 THEN s.margin
             ELSE d.margin
         END';
     $srpSQL = Margin::toPriceSQL($costSQL, $marginCase);
     $query = "SELECT p.upc,\n            p.description,\n            v.cost,\n            b.shippingMarkup,\n            b.discountRate,\n            p.normal_price,\n            " . Margin::toMarginSQL($costSQL, 'p.normal_price') . " AS current_margin,\n            " . Margin::toMarginSQL($costSQL, 'v.srp') . " AS desired_margin,\n            " . $costSQL . " AS adjusted_cost,\n            v.srp,\n            " . $srpSQL . " AS rawSRP,\n            v.vendorDept,\n            x.variable_pricing,\n            " . $marginCase . " AS margin\n            FROM products AS p \n                INNER JOIN vendorItems AS v ON p.upc=v.upc AND p.default_vendor_id=v.vendorID\n                INNER JOIN vendors as b ON v.vendorID=b.vendorID\n                LEFT JOIN departments AS d ON p.department=d.dept_no\n                LEFT JOIN vendorDepartments AS s ON v.vendorDept=s.deptID AND v.vendorID=s.vendorID\n                LEFT JOIN VendorSpecificMargins AS g ON p.department=g.deptID AND v.vendorID=g.vendorID\n                LEFT JOIN prodExtra AS x on p.upc=x.upc ";
     $args = array($vendorID);
     if ($superID != 99) {
         $query .= " LEFT JOIN MasterSuperDepts AS m\n                ON p.department=m.dept_ID ";
     }
     $query .= "WHERE v.cost > 0 \n                    AND v.vendorID=?\n                    AND p.inUse=1 ";
     if ($superID != 99) {
         $query .= " AND m.superID=? ";
         $args[] = $superID;
     }
     if ($filter === false) {
         $query .= " AND p.normal_price <> v.srp ";
     }
     if ($this->config->get('STORE_MODE') == 'HQ') {
         $query .= ' AND p.store_id=? ';
         $args[] = $this->config->get('STORE_ID');
     }
     $query .= " ORDER BY p.upc";
     if (isset($p_def['price_rule_id'])) {
         $query = str_replace('x.variable_pricing', 'p.price_rule_id AS variable_pricing', $query);
     }
     $prep = $dbc->prepare_statement($query);
     $result = $dbc->exec_statement($prep, $args);
     $ret .= "<table class=\"table table-bordered small\">";
     $ret .= "<tr><td colspan=6>&nbsp;</td><th colspan=2>Current</th>\n            <th colspan=3>Vendor</th></tr>";
     $ret .= "<tr><th>UPC</th><th>Our Description</th>\n            <th>Base Cost</th>\n            <th>Shipping</th>\n            <th>Discount%</th>\n            <th>Adj. Cost</th>\n            <th>Price</th><th>Margin</th><th>Raw</th><th>SRP</th>\n            <th>Margin</th><th>Cat</th><th>Var</th>\n            <th>Batch</th></tr>";
     while ($row = $dbc->fetch_row($result)) {
         $background = "white";
         if (isset($batchUPCs[$row['upc']])) {
             $background = 'selection';
         } elseif ($row['variable_pricing'] == 0) {
             $background = $row['normal_price'] + 0.1 < $row['rawSRP'] ? 'red' : 'green';
             if ($row['normal_price'] - 0.1 > $row['rawSRP']) {
                 $background = $row['normal_price'] - 0.1 > $row['rawSRP'] ? 'yellow' : 'green';
             }
         }
         if (isset($batchUPCs[$row['upc']])) {
             $icon = '<span class="glyphicon glyphicon-minus-sign"
                 title="Remove from batch">
                 </span>';
         } else {
             $icon = '<span class="glyphicon glyphicon-plus-sign"
                 title="Add to batch">
                 </span>';
         }
         $ret .= sprintf("<tr id=row%s class=%s>\n                <td class=\"sub\"><a href=\"%sitem/ItemEditorPage.php?searchupc=%s\">%s</a></td>\n                <td class=\"sub\">%s</td>\n                <td class=\"sub cost\">%.2f</td>\n                <td class=\"sub shipping\">%.2f%%</td>\n                <td class=\"sub discount\">%.2f%%</td>\n                <td class=\"sub adj-cost\">%.2f</td>\n                <td class=\"sub price\">%.2f</td>\n                <td class=\"sub cmargin\">%.2f%%</td>\n                <td class=\"sub raw-srp\">%.2f</td>\n                <td onclick=\"reprice('%s');\" class=\"sub srp\">%.2f</td>\n                <td class=\"sub dmargin\">%.2f%%</td>\n                <td class=\"sub\">%d</td>\n                <td><input class=varp type=checkbox onclick=\"toggleV('%s');\" %s /></td>\n                <td class=white>\n                    <a class=\"add-button %s\" href=\"\" \n                        onclick=\"addToBatch('%s'); return false;\">\n                        <span class=\"glyphicon glyphicon-plus-sign\"\n                            title=\"Add item to batch\"></span>\n                    </a>\n                    <a class=\"remove-button %s\" href=\"\" \n                        onclick=\"removeFromBatch('%s'); return false;\">\n                        <span class=\"glyphicon glyphicon-minus-sign\"\n                            title=\"Remove item from batch\"></span>\n                    </a>\n                </td>\n                </tr>", $row['upc'], $background, $this->config->URL, $row['upc'], $row['upc'], $row['description'], $row['cost'], $row['shippingMarkup'] * 100, $row['discountRate'] * 100, $row['adjusted_cost'], $row['normal_price'], 100 * $row['current_margin'], $row['rawSRP'], $row['upc'], $row['srp'], 100 * $row['desired_margin'], $row['vendorDept'], $row['upc'], $row['variable_pricing'] >= 1 ? 'checked' : '', isset($batchUPCs[$row['upc']]) ? 'collapse' : '', $row['upc'], !isset($batchUPCs[$row['upc']]) ? 'collapse' : '', $row['upc']);
     }
     $ret .= "</table>";
     return $ret;
 }