Example #1
0
 protected function get_id_view()
 {
     $query = '
         SELECT l.upc,
             CASE WHEN u.brand IS NOT NULL AND u.brand <> \'\' THEN u.brand ELSE p.brand END as brand,
             CASE WHEN u.description IS NOT NULL AND u.description <> \'\' THEN u.description ELSE p.description END as description,
             p.normal_price,
             l.salePrice,
             l.signMultiplier
         FROM batchList AS l
             ' . DTrans::joinProducts('l', 'p', 'INNER') . '
             LEFT JOIN productUser AS u ON l.upc=u.upc
         WHERE l.batchID=? ';
     $args = array($this->id);
     if ($this->config->get('STORE_MODE') === 'HQ') {
         $query .= ' AND p.store_id=? ';
         $args[] = $this->config->get('STORE_ID');
     }
     $query .= ' ORDER BY l.upc';
     $prep = $this->connection->prepare($query);
     $res = $this->connection->execute($prep, $args);
     $rows = array();
     while ($row = $this->connection->fetchRow($res)) {
         $rows[] = $row;
     }
     $query = '
         SELECT l.upc,
             \'\' AS brand,
             c.likeCodeDesc AS description,
             0 AS normal_price,
             l.salePrice,
             l.signMultiplier
         FROM batchList AS l
             LEFT JOIN likeCodes AS c ON l.upc=' . $this->connection->concat("'LC'", 'c.likeCode', '') . '
         WHERE l.batchID=? 
             AND l.upc LIKE \'LC%\'';
     $args = array($this->id);
     $prep = $this->connection->prepare($query);
     $res = $this->connection->execute($prep, $args);
     while ($row = $this->connection->fetchRow($res)) {
         $rows[] = $row;
     }
     $args = array($this->id);
     while ($row = $this->connection->fetchRow($res)) {
         $rows[] = $row;
     }
     $ret = '<form method="post">
         <table class="table table-bordered"><thead><tr>
         <th>UPC</th><th>Brand</th><th>Description</th>
         <th>Normal Price</th><th>Sale Price</th><th>Sign</th>
         </tr></thead><tbody>';
     $styles = $this->getStyles();
     foreach ($rows as $row) {
         $ret .= sprintf('<tr>
             <td>%s</td>
             <td>%s</td>
             <td>%s</td>
             <td>%.2f</td>
             <td>%.2f</td>
             <td><select class="form-control" name="style[]">
             %s
             </select>
             <input type="hidden" name="upc[]" value="%s" />
             </td>
             </tr>', \COREPOS\Fannie\API\lib\FannieUI::itemEditorLink($row['upc']), $row['brand'], $row['description'], $row['normal_price'], $row['salePrice'], $this->styleToOptions($styles, $row['signMultiplier']), $row['upc']);
     }
     $ret .= '</tbody></table>
     <p>
         <button type="submit" class="btn btn-default btn-core">Save</button>
         <a href="EditBatchPage.php?id=' . $this->id . '" class="btn btn-default btn-reset">Back to Batch</a>
     </p>
     <input type="hidden" name="id" value="' . $this->id . '" />
     </form>';
     return $ret;
 }
Example #2
0
 private function streamOutput($data)
 {
     $ret = '';
     $ret .= '<table class="table search-table">';
     $ret .= '<thead><tr>
             <th><input type="checkbox" onchange="toggleAll(this, \'.upcCheckBox\');" /></th>
             <th>UPC</th><th>Brand</th><th>Desc</th><th>Super</th><th>Dept</th>
             <th>Retail</th><th>On Sale</th><th>Sale</th>
             </tr></thead><tbody>';
     foreach ($data as $upc => $record) {
         $ret .= sprintf('<tr>
                         <td><input type="checkbox" name="u[]" class="upcCheckBox" value="%s" %s 
                             onchange="checkedCount(\'#selection-counter\', \'.upcCheckBox\');" /></td>
                         <td>%s</td>
                         <td>%s</td>
                         <td>%s</td>
                         <td>%s</td>
                         <td>%d %s</td>
                         <td>$%.2f</td>
                         <td>%s</td>
                         <td>$%.2f</td>
                         </tr>', $upc, $record['selected'] == 1 ? 'checked' : '', \COREPOS\Fannie\API\lib\FannieUI::itemEditorLink($upc), $record['brand'], $record['description'], $record['super_name'], $record['department'], $record['dept_name'], $record['normal_price'], $record['onSale'], $record['special_price']);
     }
     $ret .= '</tbody></table>';
     return $ret;
 }
Example #3
0
 /**
   Turn array into HTML table row
   @param $row an array of data
   @param $header True means <th> tags, False means <td> tags
   @return HTML string
 
   Javascript sorting utility requires header rows to be <th> tags
 */
 public function htmlLine($row, $header = False)
 {
     $url = $this->config->get('URL');
     $meta = 0;
     if (isset($row['meta'])) {
         $meta = $row['meta'];
         unset($row['meta']);
     }
     $ret = "\t<tr";
     if (($meta & self::META_CHART_DATA) != 0) {
         $ret .= ' class="d3ChartData"';
     }
     $ret .= ">\n";
     $tag = $header ? 'th' : 'td';
     if (($meta & self::META_BOLD) != 0) {
         $tag = 'th';
     }
     if (($meta & self::META_BLANK) != 0) {
         $ret = "</tbody>\n<tbody>\n\t<tr>\n";
         $header1 = $this->select_headers(False);
         // just using headers as a column count
         $row = array_map(function ($item) {
             return null;
         }, $header1);
     }
     $color_styles = '';
     if (($meta & self::META_COLOR) != 0) {
         if (isset($row['meta_background'])) {
             $color_styles .= 'background-color:' . $row['meta_background'] . ';';
             unset($row['meta_background']);
         }
         if (isset($row['meta_foreground'])) {
             $color_styles .= 'color:' . $row['meta_foreground'] . ';';
             unset($row['meta_foreground']);
         }
     }
     if (($meta & self::META_REPEAT_HEADERS) != 0) {
         $ret = "</tbody>\n<tbody>\n\t<tr>\n";
         $tag = 'th';
         $row = array();
         $header1 = $this->select_headers(true);
         $row = array_filter($header1, function ($item) {
             return true;
         });
     }
     $date = false;
     $trans = false;
     /* After removing HTML, the cell will be seen as a number
      *  and aligned right if it matches this pattern:
      * Optional leading $, optionally with space(s) after
      * Optional - sign
      * A digit
      * Possibly more decimal points, commas or digits
      * Optionally trailing %, optionally with space(s) before
      */
     $numberPattern = '/^(\\$ *)?(-)?(\\d)([.,\\d]*)( *%)?$/';
     for ($i = 0; $i < count($row); $i) {
         $span = 1;
         while (array_key_exists($i + $span, $row) && $row[$i + $span] === null && $i + $span < count($row)) {
             $span++;
         }
         $styles = $color_styles;
         if ($row[$i] === "" || $row[$i] === null) {
             $row[$i] = '&nbsp;';
         } elseif (is_numeric($row[$i]) && strlen($row[$i]) == 13) {
             // auto-link UPCs to edit tool
             $row[$i] = \COREPOS\Fannie\API\lib\FannieUI::itemEditorLink($row[$i]);
         } else {
             if (!$header && !$date && preg_match('/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/', $row[$i])) {
                 // cell contains a date column
                 $date = $row[$i];
             } elseif (!$header && !$date && preg_match('/^\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d$/', $row[$i])) {
                 // cell contains a date column
                 list($date, $time) = explode(' ', $row[$i]);
             } else {
                 if ($date && !$trans && preg_match('/^\\d+-\\d+-\\d+$/', $row[$i])) {
                     // row contains a trans_num column & a date column
                     // auto-link to reprint receipt
                     $trans = $row[$i];
                     $row[$i] = sprintf('<a href="%sadmin/LookupReceipt/RenderReceiptPage.php?date=%s&amp;receipt=%s"
                                    target="_rp_%s_%s">%s</a>', $url, $date, $row[$i], $date, $row[$i], $row[$i]);
                 } else {
                     if (preg_match($numberPattern, strip_tags($row[$i]))) {
                         $styles .= 'text-align:right;';
                     }
                 }
             }
         }
         $class = 'class="reportColumn' . $i;
         if (($meta & self::META_CHART_DATA) != 0) {
             if ($i == $this->chart_label_column) {
                 $class .= ' d3Label ';
             } else {
                 if (is_array($this->chart_data_columns) && (count($this->chart_data_columns) == 0 || in_array($i, $this->chart_data_columns))) {
                     $class .= ' d3Data ';
                 }
             }
         }
         $class .= '"';
         $ret .= "\t\t<" . $tag . ' ' . $class . ' style="' . $styles . '" colspan="' . $span . '">' . "\n" . "\t\t\t" . $row[$i] . "\n" . "\t\t</" . $tag . ">\n";
         $i += $span;
     }
     $ret .= "\t</tr>\n";
     if (($meta & self::META_REPEAT_HEADERS) != 0) {
         $ret .= "</tbody>\n<tbody>\n";
     } elseif (($meta & self::META_BLANK) != 0) {
         $ret .= "</tbody>\n";
     }
     return $ret;
 }
Example #4
0
    public function get_view()
    {
        $dbc = $this->connection;
        $dbc->selectDB($this->config->get('OP_DB'));
        $set = FormLib::get('deal-set');
        $optsR = $dbc->query('
            SELECT dealSet
            FROM CoopDealsItems
            GROUP BY dealSet
            ORDER BY MAX(coopDealsItemID) DESC');
        $deal_opts = '';
        while ($optsW = $dbc->fetchRow($optsR)) {
            if ($set === '') {
                $set = $optsW['dealSet'];
            }
            $deal_opts .= sprintf('<option %s>%s</option>', $set == $optsW['dealSet'] ? 'selected' : '', $optsW['dealSet']);
        }
        $query = $dbc->prepare_statement("\n            SELECT\n                t.upc,\n                p.description,\n                p.brand,\n                t.price,\n                CASE WHEN s.super_name IS NULL THEN 'sale' ELSE s.super_name END as batch,\n                t.abtpr as subbatch,\n                multiplier\n            FROM\n                CoopDealsItems as t\n                " . DTrans::joinProducts('t', 'p', 'INNER') . "\n                LEFT JOIN MasterSuperDepts AS s ON p.department=s.dept_ID\n            WHERE p.inUse=1\n                AND t.price < p.normal_price\n                AND t.dealSet=?\n            ORDER BY s.super_name,t.upc\n        ");
        $result = $dbc->exec_statement($query, array($set));
        $upcomingP = $dbc->prepare('
            SELECT batchName
            FROM batchList AS l
                INNER JOIN batches AS b ON l.batchID=b.batchID
            WHERE l.upc=?
                AND b.endDate >= ' . $dbc->curdate());
        $allR = $dbc->query('
            SELECT batchID,
                batchName
            FROM batches
            WHERE endDate >= ' . $dbc->curdate());
        $opts = array();
        while ($allW = $dbc->fetchRow($allR)) {
            $opts[$allW['batchID']] = $allW['batchName'];
        }
        $ret = "<form action=CoopDealsMergePage.php method=post>\n        <div class=\"form-group\">\n            <label>Month</label>\n            <select name=\"deal-set\" class=\"form-control\" \n                onchange=\"location='?deal-set='+this.value;\">\n            " . $deal_opts . "\n            </select>\n        </div>\n        <table class=\"table table-bordered table-striped tablesorter tablesorter-core small\">\n        <thead>\n        <tr><th>UPC</th><th>Brand</th><th>Desc</th><th>Sale Price</th>\n        <th>Add to Batch</th></tr>\n\n        </thead><tbody>";
        while ($row = $dbc->fetch_row($result)) {
            $upcoming = $dbc->getValue($upcomingP, array($row['upc']));
            if ($upcoming) {
                continue;
            }
            $name = $row['batch'] . ' Co-op Deals ' . $row['subbatch'];
            $ret .= sprintf('<tr>
                        <td><input type="hidden" name="upc[]" value="%s"/>%s
                            <input type="hidden" name="mult[]" value="%d" />
                        </td>
                        <td>%s</td>
                        <td>%s</td>
                        <td><input type="hidden" name="price[]" value="%.2f"/>%.2f</td>
                        <td><select class="form-control input-sm" name="batchID[]">
                            <option value="">Select batch...</option>', $row['upc'], \COREPOS\Fannie\API\lib\FannieUI::itemEditorLink($row['upc']), $row['multiplier'], $row['brand'], $row['description'], $row['price'], $row['price']);
            foreach ($opts as $id => $batch) {
                $ret .= sprintf('<option %s value="%d">%s</option>', strstr($batch, $name) ? 'selected' : '', $id, $batch);
            }
            $ret .= '</select></td></tr>';
        }
        $ret .= <<<html
        </tbody>
        </table>
        <p>    
            <button type=submit class="btn btn-default">Merge Items into Batch(es)</button>
            <a href="CoopDealsReviewPage.php" class="pull-right btn btn-default">Create New Batch(es)</a>
        </p>
        </form>
html;
        return $ret;
    }