Ejemplo n.º 1
0
 protected function get_type_handler()
 {
     if ($this->type == '') {
         echo '';
         return false;
     }
     $this->connection->selectDB($this->config->get('OP_DB'));
     $model = new CustomReceiptModel($this->connection);
     $model->type($this->type);
     $ret = '<table class="table table-bordered">
         <tr>
             <th>Line #</th>
             <th>Text</th>
             <th>' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</th>
         </tr>';
     foreach ($model->find('seq') as $obj) {
         $ret .= sprintf('<tr>
             <td>%d<input type="hidden" name="id[]" value="%d" /></td>
             <td><input type="text" maxlength="55" name="line[]" class="form-control" value="%s" /></td>
             <td><input type="checkbox" name="del[]" value="%d" /></td>
             </tr>', $obj->seq(), $obj->seq(), $obj->text(), $obj->seq());
     }
     $ret .= '<tr><td>NEW</td><td><input type="text" name="newLine" class="form-control" /></td>
         <td>&nbsp;</td></tr>';
     $ret .= '</table>';
     echo $ret;
     return false;
 }
Ejemplo n.º 2
0
 function showEditForm($memNum, $country = "US")
 {
     $account = self::getAccount();
     $ret = "<div class=\"panel panel-default\">\n            <div class=\"panel-heading\">Membership Dates</div>\n            <div class=\"panel-body\">";
     $ret .= '<div class="form-group form-inline">';
     $ret .= '<span class="label primaryBackground">Start</span>';
     $ret .= sprintf(' <input name="MemDates_start"
             maxlength="10" value="%s" id="MemDates_start"
             class="form-control date-field" /> ', \COREPOS\Fannie\API\lib\FannieUI::formatDate($account['startDate']));
     $ret .= '<span class="label primaryBackground">End</span>';
     $ret .= sprintf(' <input name="MemDates_end" 
             maxlength="10" value="%s" id="MemDates_end"
             class="form-control date-field" />', \COREPOS\Fannie\API\lib\FannieUI::formatDate($account['endDate']));
     $ret .= '</div>';
     $ret .= "</div>";
     $ret .= "</div>";
     return $ret;
 }
Ejemplo n.º 3
0
 public function fetch_report_data()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('TRANS_DB'));
     $prep = $dbc->prepare('
         SELECT tdate,
             description,
             trans_num,
             total
         FROM voidTransHistory 
         WHERE tdate BETWEEN ? AND ?
         ORDER BY tdate
     ');
     $res = $dbc->execute($prep, array($this->form->date1 . ' 00:00:00', $this->form->date2 . ' 23:59:59'));
     $data = array();
     while ($row = $dbc->fetchRow($res)) {
         $original = substr($row['description'], 20);
         $data[] = array($row['tdate'], $row['trans_num'], $row['total'], \COREPOS\Fannie\API\lib\FannieUI::receiptLink($row['tdate'], $original));
     }
     return $data;
 }
Ejemplo n.º 4
0
 function get_view()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $ret = '<form onsubmit="save();return false;">
         <div class="form-group">
             <label>UPC</label>
             <input type="text" id="upc" class="form-control" required />
         </div>
         <div class="form-group">
             <label>Limit</label> (max uses per transaction)
             <input type="number" id="limit" class="form-control" 
                 value="0" required />
         </div>
         <div class="form-group">
             <label>Reason</label>
             <input type="text" id="reason" class="form-control" required />
         </div>
         <p>
         <button type="submit" class="btn btn-default">Save</button>
         </p>
         </form>
         <hr/>';
     $model = new DisableCouponModel($dbc);
     $ret .= '<table class="table">
         <tr><th>UPC</th><th>Limit</th><th>Reason</th><th></th></tr>';
     foreach ($model->find('upc') as $obj) {
         $ret .= sprintf('<tr><td><a href="" onclick="loadcoupon(\'%s\');return false;">%s</a></td>
                 <td>%d</td><td>%s</td>
                 <td><a href="" onclick="deletecoupon(\'%s\');return false;">%s</a></td>
                 </tr>', $obj->upc(), $obj->upc(), $obj->threshold(), $obj->reason(), $obj->upc(), \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }
     $ret .= '</table>';
     $this->add_onload_command("\$('#upc').focus();\n");
     return $ret;
 }
Ejemplo n.º 5
0
    function body_content()
    {
        ob_start();
        ?>
        <div id="bdiv">
            <p><a href="#" onclick="window.open('SaScanningPage.php','scan','width=320, height=200, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');">Enter a new scan</a></p>
            <p><a href="SaHandheldPage.php">Alternate Scan Page</a></p>
            <p><?php 
        echo $this->sql_actions;
        ?>
</p>
            <p><?php 
        echo $this->status;
        ?>
</p>
            <p><a href="?view=dept">view by pos department</a> <a href="SaReportPage.php">view by scanned section</a></p>
            <p><a href="?excel=yes">download as csv</a></p>
        <?php 
        if ($this->scans) {
            $clear = '<div><a href="SaReportPage.php?clear=yes">Clear Old</a></div>';
            print_r($clear);
        }
        $table = '';
        $view = FormLib::get_form_value('view', 'dept');
        $counter = $view == 'dept' ? 'd' : 's';
        $counter_total = 0;
        foreach ($this->scans as $row) {
            if (!isset($counter_number)) {
                if ($counter == 'd') {
                    $counter_number = $row['dept_no'];
                } else {
                    $counter_number = $row['section'];
                }
                $counter_total = $row['quantity'] * $row['normal_retail'];
                if ($counter == 'd') {
                    $caption = $row['dept_name'] . ' Department';
                } else {
                    $caption = 'Section #' . $row['section'];
                }
                $table .= '
        <table class="table shelf-audit">
            <caption>' . $caption . '</caption>
            <thead>
                <tr>
                    <th>Date+Time</th>
                    <th>UPC</th>
                    <th>Description</th>
                    <th>Qty</th>
                    <th>Unit Cost</th>
                    <th>Total Cost</th>
                    <th>Retail (Normal)</th>
                    <th>Retail (Current)</th>
                    <th>Sale</th>
                    <th>Total Retail</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td id="col_a" class="small">' . $row['datetime'] . '</td>
                    <td id="col_b">' . $row['upc'] . '</td>
                    <td id="col_c">' . $row['description'] . '</td>
                    <td id="col_d" class="right">' . $row['quantity'] . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['cost']) . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['cost']) . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['normal_retail']) . '</td>
                    <td id="col_f" class="right">' . money_format('%.2n', $row['actual_retail']) . '</td>
                    <td id="col_g">' . ($row['retailstatus'] ? $row['retailstatus'] : '&nbsp;') . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['normal_retail']) . '</td>
                    <td id="col_i"><a href="SaReportPage.php?delete=yes&id=' . $row['id'] . '">' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</td>
                </tr>';
            } else {
                if ($counter_number != $row['section'] && $counter_number != $row['dept_no']) {
                    if ($counter == 'd') {
                        $counter_number = $row['dept_no'];
                    } else {
                        $counter_number = $row['section'];
                    }
                    if ($counter == 'd') {
                        $caption = $row['dept_name'] . ' Department';
                    } else {
                        $caption = 'Section #' . $row['section'];
                    }
                    $table .= '
            </tbody>
            <tfoot>
                <tr>
                    <td colspan=6>&nbsp;</td>
                    <td class="right">' . money_format('%.2n', $counter_total) . '</td>
                    <td>&nbsp;</td>
                </tr>
            </tfoot>
        </table>
        <table class="table shelf-audit">
            <caption>' . $caption . '</caption>
            <thead>
                <tr>
                    <th>Date+Time</th>
                    <th>UPC</th>
                    <th>Description</th>
                    <th>Qty</th>
                    <th>Unit Cost</th>
                    <th>Total Cost</th>
                    <th>Retail (Normal)</th>
                    <th>Retail (Current)</th>
                    <th>Sale</th>
                    <th>Total Retail</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td id="col_a" class="small">' . $row['datetime'] . '</td>
                    <td id="col_b">' . $row['upc'] . '</td>
                    <td id="col_c">' . $row['description'] . '</td>
                    <td id="col_d" class="right">' . $row['quantity'] . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['cost']) . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['cost']) . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['normal_retail']) . '</td>
                    <td id="col_f" class="right">' . money_format('%.2n', $row['actual_retail']) . '</td>
                    <td id="col_g">' . ($row['retailstatus'] ? $row['retailstatus'] : '&nbsp;') . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['normal_retail']) . '</td>
                    <td id="col_i"><a href="SaReportPage.php?delete=yes&id=' . $row['id'] . '">' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</td>
                </tr>';
                    $counter_total = $row['quantity'] * $row['normal_retail'];
                } else {
                    $counter_total += $row['quantity'] * $row['normal_retail'];
                    $table .= '
                <tr>
                    <td id="col_a" class="small">' . $row['datetime'] . '</td>
                    <td id="col_b">' . $row['upc'] . '</td>
                    <td id="col_c">' . $row['description'] . '</td>
                    <td id="col_d" class="right">' . $row['quantity'] . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['cost']) . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['cost']) . '</td>
                    <td id="col_e" class="right">' . money_format('%.2n', $row['normal_retail']) . '</td>
                    <td id="col_f" class="right">' . money_format('%.2n', $row['actual_retail']) . '</td>
                    <td id="col_g">' . ($row['retailstatus'] ? $row['retailstatus'] : '&nbsp;') . '</td>
                    <td id="col_h" class="right">' . money_format('%!.2n', $row['quantity'] * $row['normal_retail']) . '</td>
                    <td id="col_i"><a href="SaReportPage.php?delete=yes&id=' . $row['id'] . '">' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</td>
                </tr>';
                }
            }
        }
        $table .= '
            </tbody>
            <tfoot>
                <tr>
                    <td colspan=6>&nbsp;</td>
                    <td class="right">' . money_format('%.2n', $counter_total) . '</td>
                    <td>&nbsp;</td>
                </tr>
            </tfoot>
        </table>
        </div>
';
        if (!empty($table)) {
            print_r($table);
        }
        ?>
        <?php 
        return ob_get_clean();
    }
Ejemplo n.º 6
0
 protected function get_view()
 {
     $privs = new UserKnownPrivsModel($this->connection);
     $pages = FannieAPI::listModules('FanniePage');
     sort($pages);
     $custom = new PagePermissionsModel($this->connection);
     $ret = '<form method="post">
         <div class="panel panel-default">
             <div class="panel-heading">Create Custom Permissions</div>
             <div class="panel-body">
                 <div class="form-group">
                     <label>Page</label>
                     <select name="page" class="form-control">
                         <option value="">Choose page</option>
                         ' . array_reduce($pages, function ($carry, $page) {
         return $carry . '<option>' . $page . '</option>';
     }) . '
                     </select>
                 </div>
                 <div class="form-group">
                     <label>Permission Class</label>
                     <select name="auth" class="form-control">
                     ' . $privs->toOptions(-1, true) . '
                     </select>
                 </div>
                 <div class="form-group">
                     <button type="submit" class="btn btn-default btn-core">Create</button>
                 </div>
             </div>
         </div>
         </form>
         <div class="panel panel-default">
             <div class="panel-heading">Pages With Custom Permissions</div>
             <div class="panel-body">
                 <table class="table table-bordered table-striped">
                     <tr><th>Name</th><th>Description</th><th>&nbsp;</th></tr>
                     ' . array_reduce($custom->find('pageClass'), function ($carry, $obj) {
         $page_class = $obj->pageClass();
         $page = new $page_class();
         return $carry . sprintf('<tr><td>%s</td><td>%s</td><td>
                             <a href="_method=delete&id=%s" class="btn btn-danger btn-xs">%s</a></td></tr>', $page_class, $page->description, $page_class, \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }) . '
                 </table>
             </div>
         </div>
         ';
     return $ret;
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
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.º 9
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;
    }
Ejemplo n.º 10
0
 function batchListDisplay($filter = '', $mode = '', $maxBatchID = '')
 {
     global $FANNIE_URL;
     $dbc = $this->con;
     if ($mode === '') {
         $mode = $this->config->get('BATCH_VIEW', 'all');
     }
     $colors = array('#ffffff', '#ffffcc');
     $c = 0;
     $ret = "";
     $ret .= "<b>Display</b>: ";
     if ($mode != 'pending') {
         $ret .= "<a href=\"\" onclick=\"changeTimeSlice('pending'); return false;\">Pending</a> | ";
     } else {
         $ret .= "Pending | ";
     }
     if ($mode != 'current') {
         $ret .= "<a href=\"\" onclick=\"changeTimeSlice('current'); return false;\">Current</a> | ";
     } else {
         $ret .= "Current | ";
     }
     if ($mode != 'historical') {
         $ret .= "<a href=\"\" onclick=\"changeTimeSlice('historical'); return false;\">Historical</a> | ";
     } else {
         $ret .= "Historical | ";
     }
     if ($mode != 'all') {
         $ret .= "<a href=\"\" onclick=\"changeTimeSlice('all'); return false;\">All</a>";
     } else {
         $ret .= "All<br />";
     }
     $sort = \COREPOS\Fannie\API\lib\FannieUI::tableSortIcons();
     $ret .= '<table class="table tablesorter tablesorter-core"><thead>';
     $ret .= "<tr><th bgcolor={$colors[$c]}>Batch Name{$sort}</th>";
     $ret .= "<th bgcolor={$colors[$c]}>Type{$sort}</th>";
     $ret .= "<th bgcolor={$colors[$c]}>Items{$sort}</th>";
     $ret .= "<th bgcolor={$colors[$c]}>Start date{$sort}</th>";
     $ret .= "<th bgcolor={$colors[$c]}>End date{$sort}</th>";
     $ret .= "<th bgcolor={$colors[$c]}>Owner/Super Dept.{$sort}</th>";
     $ret .= "<th colspan=\"3\">&nbsp;</th></tr></thead><tbody>";
     // owner column might be in different places
     // depending if schema is up to date
     $ownerclause = "'' as owner FROM batches AS b";
     $batchesTable = $dbc->tableDefinition('batches');
     $owneralias = '';
     if (isset($batchesTable['owner'])) {
         $ownerclause = 'b.owner FROM batches AS b';
         $owneralias = 'b';
     } else {
         if ($dbc->tableExists('batchowner')) {
             $ownerclause = 'o.owner FROM batches AS b LEFT JOIN
                         batchowner AS o ON b.batchID=o.batchID';
             $owneralias = 'o';
         }
     }
     // the 'all' query
     // where clause is for str_ireplace below
     $fetchQ = "SELECT b.batchName,\n                        b.batchType,\n                        b.startDate,\n                        b.endDate,\n                        b.batchID,\n                        t.typeDesc,\n                        COUNT(l.upc) AS items,\n                   {$ownerclause}\n                    LEFT JOIN batchType AS t ON b.batchType = t.batchTypeID\n                    LEFT JOIN batchList AS l ON b.batchID=l.batchID\n                   WHERE 1=1 ";
     $args = array();
     switch ($mode) {
         case 'pending':
             $fetchQ .= ' AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' > 0 ';
             break;
         case 'current':
             $fetchQ .= '
                 AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' <= 0
                 AND ' . $dbc->datediff("b.endDate", $dbc->now()) . ' >= 0 ';
             break;
         case 'historical':
             $fetchQ .= ' AND ' . $dbc->datediff("b.startDate", $dbc->now()) . ' <= 0 ';
             break;
     }
     // use a filter - only works in 'all' mode
     if ($filter != '') {
         $fetchQ .= ' AND ' . $owneralias . '.owner = ? ';
         $args[] = $filter;
     }
     $fetchQ .= ' GROUP BY b.batchName, b.batchType, b.startDate, b.endDate, b.batchID,
                     t.typeDesc, ' . $owneralias . '.owner ';
     $fetchQ .= ' ORDER BY b.batchID DESC';
     $fetchQ = $dbc->add_select_limit($fetchQ, 50);
     if (is_numeric($maxBatchID)) {
         $fetchQ = str_replace("WHERE ", "WHERE b.batchID < ? AND ", $fetchQ);
         array_unshift($args, $maxBatchID);
     }
     $fetchR = $dbc->exec_statement($fetchQ, $args);
     $count = 0;
     $lastBatchID = 0;
     while ($fetchW = $dbc->fetch_array($fetchR)) {
         /**
           strtotime() and date() are not reciprocal functions
           date('Y-m-d', strtotime('0000-00-00')) results in
           -0001-11-30 instead of the expected 0000-00-00
         */
         if ($fetchW['startDate'] == '0000-00-00 00:00:00') {
             $fetchW['startDate'] = '';
         }
         if ($fetchW['endDate'] == '0000-00-00 00:00:00') {
             $fetchW['endDate'] = '';
         }
         $c = ($c + 1) % 2;
         $id = $fetchW['batchID'];
         $ret .= '<tr id="batchRow' . $fetchW['batchID'] . '" class="batchRow">';
         $ret .= "<td bgcolor={$colors[$c]} id=name{$id}><a id=namelink{$id} \n                href=\"EditBatchPage.php?id={$id}\">{$fetchW['batchName']}</a></td>";
         $ret .= "<td bgcolor={$colors[$c]} id=type{$id}>" . $fetchW['typeDesc'] . "</td>";
         $ret .= "<td bgcolor={$colors[$c]}>" . $fetchW['items'] . "</td>";
         $ret .= "<td bgcolor={$colors[$c]} id=startdate{$id}>" . (strtotime($fetchW['startDate']) ? date('Y-m-d', strtotime($fetchW['startDate'])) : '') . "</td>";
         $ret .= "<td bgcolor={$colors[$c]} id=enddate{$id}>" . (strtotime($fetchW['endDate']) ? date('Y-m-d', strtotime($fetchW['endDate'])) : '') . "</td>";
         $ret .= "<td bgcolor={$colors[$c]} id=owner{$id}>{$fetchW['owner']}</td>";
         $ret .= "<td bgcolor={$colors[$c]} id=edit{$id}>\n                <a href=\"\" onclick=\"editBatchLine({$id}); return false;\" class=\"batchEditLink btn btn-default btn-xs\">\n                    " . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . "\n                </a>\n                <a href=\"\" onclick=\"saveBatchLine({$id}); return false;\" class=\"batchSaveLink btn btn-default btn-xs collapse\">\n                    " . \COREPOS\Fannie\API\lib\FannieUI::saveIcon() . "\n                </a>\n                </td>";
         $ret .= "<td bgcolor={$colors[$c]}><a href=\"\" class=\"btn btn-danger btn-xs\"\n                onclick=\"deleteBatch({$id},'" . str_replace("'", '', $fetchW['batchName']) . "'); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a></td>';
         $ret .= "<td bgcolor={$colors[$c]}><a href=\"batchReport.php?batchID={$id}\">Report</a></td>";
         $ret .= "</tr>";
         $count++;
         $lastBatchID = $fetchW[4];
     }
     $ret .= "</tbody></table>";
     if (is_numeric($maxBatchID)) {
         $ret .= sprintf("<a href=\"\" \n                    onclick=\"scroll(0,0); batchListPager('%s','%s',''); return false;\">First page</a>\n                     | ", $filter, $mode);
     }
     if ($count >= 50) {
         $ret .= sprintf("<a href=\"\" \n                    onclick=\"scroll(0,0); batchListPager('%s','%s',%d); return false;\">Next page</a>", $filter, $mode, $lastBatchID);
     } else {
         $ret .= "Next page";
     }
     return $ret;
 }
Ejemplo n.º 11
0
 private function editableItemList($orderID)
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $TRANS = $this->config->get('TRANS_DB') . $dbc->sep();
     $deptP = $dbc->prepare_statement("SELECT dept_no,dept_name FROM departments order by dept_no");
     $deptR = $dbc->exec_statement($deptP);
     $depts = array(0 => 'Unassigned');
     while ($deptW = $dbc->fetch_row($deptR)) {
         $depts[$deptW['dept_no']] = $deptW['dept_name'];
     }
     $ret = '<table class="table table-bordered table-striped">';
     $ret .= '<tr><th>UPC</th><th>SKU</th><th>Description</th><th>Cases</th><th>SRP</th><th>Actual</th><th>Qty</th><th>Dept</th><th>&nbsp;</th></tr>';
     $prep = $dbc->prepare_statement("SELECT o.upc,o.description,total,quantity,department,\n            v.sku,ItemQtty,regPrice,o.discounttype,o.charflag,o.mixMatch,\n            o.trans_id,o.unitPrice,o.memType,o.staff\n            FROM {$TRANS}PendingSpecialOrder as o\n            left join vendorItems as v on o.upc=v.upc AND vendorID=1\n            WHERE order_id=? AND trans_type='I' \n            ORDER BY trans_id DESC");
     $res = $dbc->exec_statement($prep, array($orderID));
     $num_rows = $dbc->num_rows($res);
     $prev_id = 0;
     while ($row = $dbc->fetch_row($res)) {
         if ($row['trans_id'] == $prev_id) {
             continue;
         }
         $ret .= sprintf('
                 <tbody>
                 <tr>
                 <td>%s</td>
                 <td>%s</td>
                 <td><input class="form-control input-sm item-field" name="description"
                     value="%s" /></td>
                 <td>%d</td>
                 <td><input size="5" class="form-control input-sm price-field item-field" id="srp%d" 
                     name="srp" value="%.2f" /></td>
                 <td><input size="5" class="form-control input-sm price-field item-field" id="act%d" 
                     value="%.2f" name="actual" /></td>
                 <td><input size="4" class="form-control input-sm price-field item-field" 
                     value="%.2f" name="qty" /></td>
                 <td><select class="form-control input-sm editDept item-field" 
                     name="dept">', $row['upc'], !empty($row['sku']) ? $row['sku'] : '&nbsp;', $row['description'], $row['ItemQtty'], $row['trans_id'], $row['regPrice'], $row['trans_id'], $row['total'], $row['quantity']);
         foreach ($depts as $id => $name) {
             $ret .= sprintf('<option value="%d" %s>%d %s</option>', $id, $id == $row['department'] ? 'selected' : '', $id, $name);
         }
         $ret .= sprintf('</select></td>
                 <td><a href="" data-order="%d" data-trans="%d" 
                     class="btn btn-danger btn-xs btn-delete">%s</a></td>
                 </tr>', $orderID, $row['trans_id'], \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
         $ret .= '<tr>';
         $ret .= sprintf('<td colspan="2" align="right" class="form-inline">Unit Price: 
             <input type="text" size="4" value="%.2f" id="unitp%d" name="unitPrice"
             class="form-control input-sm price-field item-field" /></td>', $row['unitPrice'], $row['trans_id']);
         $ret .= sprintf('<td class="form-inline">Supplier: <input type="text" value="%s" size="12" 
                 class="form-control input-sm item-field" name="vendor"
                 maxlength="26" 
                 /></td>', $row['mixMatch']);
         $ret .= '<td>Discount</td>';
         if ($row['discounttype'] == 1 || $row['discounttype'] == 2) {
             $ret .= '<td class="disc-percent" id="discPercent' . $row['trans_id'] . '">Sale</td>';
         } else {
             if ($row['regPrice'] != $row['total']) {
                 $ret .= sprintf('<td class="disc-percent" id="discPercent%d">%d%%</td>', $row['upc'], round(100 * (($row['regPrice'] - $row['total']) / $row['regPrice'])));
             } else {
                 $ret .= '<td class="disc-percent" id="discPercent' . $row['upc'] . '">0%</td>';
             }
         }
         $ret .= sprintf('<td colspan="2">Printed: %s</td>', $row['charflag'] == 'P' ? 'Yes' : 'No');
         if ($num_rows > 1) {
             $ret .= sprintf('<td colspan="2"><a href="" class="btn btn-default btn-sm"
                 onclick="orderView.doSplit(%d,%d);return false;">Split Item to New Order</a><br />
                 O <input type="checkbox" class="itemChkO" %s data-order="%d" data-trans="%d" />&nbsp;&nbsp;&nbsp;&nbsp;
                 A <input type="checkbox" class="itemChkA" %s data-order="%d" data-trans="%d" />
                 </td>', $orderID, $row['trans_id'], $row['memType'] > 0 ? 'checked' : '', $orderID, $row['trans_id'], $row['staff'] > 0 ? 'checked' : '', $orderID, $row['trans_id']);
         } else {
             $ret .= '<td colspan="2"></td>';
         }
         $ret .= '</tr>';
         $ret .= '<tr><td class="small" colspan="9"><span style="font-size:1;">&nbsp;</span>';
         $ret .= '<input type="hidden" name="transID" class="item-field" value="' . $row['trans_id'] . '" /></td></tr>';
         $ret .= '</tbody>';
         $prev_id = $row['trans_id'];
     }
     $ret .= '</table>';
     return $ret;
 }
Ejemplo n.º 12
0
 public function get_view()
 {
     $obj = $this->getCRUDModel();
     $id_col = $this->getIdCol();
     $columns = $obj->getColumns();
     $ret = '<form class="crud-form" method="post">';
     $ret .= '<div class="flash-div">';
     $ret .= array_reduce(\FormLib::get('flash', array()), function ($carry, $item) {
         $css = '';
         switch (substr($item, 0, 1)) {
             case 's':
                 $css = 'alert-success';
                 break;
             case 'd':
                 $css = 'alert-danger';
                 break;
         }
         $carry .= '<div class="alert ' . $css . '" role="alert">' . substr($item, 1) . '<button type="button" class="close" data-dismiss="alert">' . '<span>&times;</span></button>' . '</div>';
         return $carry;
     }, '');
     $ret .= '</div>';
     $ret .= '<table class="table table-bordered">';
     $ret .= '<tr>';
     foreach ($columns as $col_name => $c) {
         if ($col_name != $id_col) {
             if (isset($this->column_name_map[$col_name])) {
                 $col_name = $this->column_name_map[$col_name];
             }
             $ret .= '<th>' . ucwords($col_name) . '</th>';
         }
     }
     $ret .= '</tr>';
     $sort = !empty($this->display_sorting) ? $this->display_sorting : $id_col;
     foreach ($obj->find($sort) as $o) {
         $ret .= '<tr>';
         foreach ($columns as $col_name => $c) {
             if ($col_name == $id_col) {
                 $ret .= '<input type="hidden" name="id[]" value="' . $o->{$id_col}() . '" />';
             } else {
                 $css = 'form-control';
                 if (strtoupper($c['type'] == 'DATETIME')) {
                     $css .= ' date-field';
                 }
                 $ret .= sprintf('<td><input type="text" class="%s" 
                                         name="%s[]" value="%s" /></td>', $css, $col_name, $o->{$col_name}());
             }
         }
         $ret .= sprintf('<td>
                     <a href="?_method=delete&id=%s" class="btn btn-xs btn-default btn-danger"
                         onclick="return confirm(\'Delete entry?\');">
                     ' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a>
                     </td>', $o->{$id_col}());
         $ret .= '</tr>';
     }
     $ret .= '</table>';
     $ret .= '<p>
         <button type="submit" class="btn btn-default">Save Changes</button>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a href="" onclick="addEntry(); return false;" class="btn btn-default">Add Entry</a>
         </p>';
     $ret .= '</form>';
     $ret .= '<script type="text/javascript">
         function addEntry()
         {
             $.ajax({
                 method: "PUT",
                 dataType: "json",
                 success: function(resp) {
                     if (resp.added) {
                         $("form.crud-form").submit();
                     } else {
                         showBootstrapAlert(".flash-div", "danger", "Error adding entry");
                     }
                 }
             });
         }
         </script>';
     return $ret;
 }
Ejemplo n.º 13
0
    public function body_content()
    {
        include dirname(__FILE__) . '/../config.php';
        ob_start();
        echo showInstallTabs('Stores');
        ?>

<form action=InstallStoresPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<p class="ichunk">Revised 23Apr2014</p>
<?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />
<h4 class="install">Stores</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
<?php 
        $model = new StoresModel(FannieDB::get($FANNIE_OP_DB));
        $model->dbHost($FANNIE_SERVER);
        $myself = $model->find();
        if (count($myself) == 0) {
            echo '<i>No entry found for this store. Adding one automatically...</i><br />';
            $model->description('CURRENT STORE');
            $model->save();
        } else {
            if (count($myself) > 1) {
                echo '<i>Warning: more than one entry for store host: ' . $FANNIE_SERVER . '</i><br />';
            } else {
                echo '<i>This store is #' . installTextField('FANNIE_STORE_ID', $FANNIE_STORE_ID, $myself[0]->storeID()) . '</i><br />';
            }
        }
        $model->reset();
        echo '<label>Mode</label>';
        echo installSelectField('FANNIE_STORE_MODE', $FANNIE_STORE_MODE, array('STORE' => 'Single Store', 'HQ' => 'HQ'), 'STORE');
        $supportedTypes = array('none' => '');
        if (extension_loaded('pdo') && extension_loaded('pdo_mysql')) {
            $supportedTypes['PDO_MYSQL'] = 'PDO MySQL';
        }
        if (extension_loaded('mysqli')) {
            $supportedTypes['MYSQLI'] = 'MySQLi';
        }
        if (extension_loaded('mysql')) {
            $supportedTypes['MYSQL'] = 'MySQL';
        }
        if (extension_loaded('mssql')) {
            $supportedTypes['MSSQL'] = 'MSSQL';
        }
        ?>
<table class="table">
<tr>
    <th>Store #</th><th>Description</th><th>DB Host</th>
    <th>Driver</th><th>Username</th><th>Password</th>
    <th>Operational DB</th>
    <th>Transaction DB</th>
    <th>Push</th>
    <th>Pull</th>
    <th>Own Items</th>
    <th>Delete Entry</th>
</tr>
<?php 
        foreach ($model->find('storeID') as $store) {
            printf('<tr %s>
            <td>%d<input type="hidden" name="storeID[]" value="%d" /></td>
            <td><input type="text" class="form-control" name="storeName[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeHost[]" value="%s" /></td>', $store->dbHost() == $FANNIE_SERVER ? 'class="info"' : '', $store->storeID(), $store->storeID(), $store->description(), $store->dbHost());
            echo '<td><select name="storeDriver[]" class="form-control">';
            foreach ($supportedTypes as $key => $label) {
                printf('<option %s value="%s">%s</option>', $store->dbDriver() == $key ? 'selected' : '', $key, $label);
            }
            echo '</select></td>';
            printf('<td><input type="text" class="form-control" name="storeUser[]" value="%s" /></td>
            <td><input type="password" class="form-control" name="storePass[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeOp[]" value="%s" /></td>
            <td><input type="text" class="form-control" name="storeTrans[]" value="%s" /></td>
            <td><input type="checkbox" name="storePush[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storePull[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storeItems[]" value="%d" %s /></td>
            <td><input type="checkbox" name="storeDelete[]" value="%d" /></td>
            </tr>', $store->dbUser(), $store->dbPassword(), $store->opDB(), $store->transDB(), $store->storeID(), $store->push() ? 'checked' : '', $store->storeID(), $store->pull() ? 'checked' : '', $store->storeID(), $store->hasOwnItems() ? 'checked' : '', $store->storeID());
        }
        ?>
</table>
</p>
<hr />
<h4 class="install">Testing Connections</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
    <ul>
<?php 
        foreach ($model->find('storeID') as $store) {
            $test = db_test_connect($store->dbHost(), $store->dbDriver(), $store->transDB(), $store->dbUser(), $store->dbPassword());
            echo '<li> Store #' . $store->storeID() . ': ' . ($test ? 'Connected' : 'No connection') . '</li>';
        }
        ?>
    </ul>
    <i>Note: it's OK if this store's connection fails as long as it succeeds
       on the "Necessities" tab.</i>
</p>
<hr />
<h4 class="install">Read-only Database Server(s)</h4>
<p class="ichunk" style="margin:0.0em 0em 0.4em 0em;">
Specify one or more database servers that can be used strictly
for read operations. If more than one database is listed, read-only
queries will be load-balanced across them.
<?php 
        if (!isset($FANNIE_READONLY_JSON)) {
            $FANNIE_READONLY_JSON = json_encode(array(array('host' => $FANNIE_SERVER, 'type' => $FANNIE_SERVER_DBMS, 'user' => $FANNIE_SERVER_USER, 'pw' => $FANNIE_SERVER_PW)));
        }
        confset('FANNIE_READONLY_JSON', "'{$FANNIE_READONLY_JSON}'");
        ?>
<textarea rows="10" cols="30" name="FANNIE_READONLY_JSON" class="form-control">
<?php 
        echo \COREPOS\Fannie\API\lib\FannieUI::prettyJSON($FANNIE_READONLY_JSON);
        ?>
</textarea>
<hr />
<p>
<button type=submit name="saveButton" value="Save" class="btn btn-default">Save</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type=submit name="addButton" value="Add Another Store" class="btn btn-default">Add Another Store</button>
</p>
</form>

<?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 14
0
    function body_content()
    {
        global $FANNIE_URL;
        $user = FannieAuth::checkLogin();
        ob_start();
        ?>
        <form style='margin-top:1.0em;' id="osForm" onsubmit="setdate(); return false;" >
        <div class="form-group form-inline">
        <label>Date</label>:<input class="form-control date-field" type=text id=date name=arg />
        <select class="form-control" name="mode">
            <option value="cashier">Cashier</option>
            <option value="drawer">Drawer</option>
        </select>
        <?php 
        $_REQUEST['store'] = 1;
        $sp = FormLib::storePicker();
        echo $sp['html'];
        ?>
        <button type=submit class="btn btn-default">Set</button>
        <input type=hidden id=user value="<?php 
        if (isset($user)) {
            echo $user;
        }
        ?>
" />
        </div>
        </form>

        <div id="loading-bar" class="collapse">
            <?php 
        echo \COREPOS\Fannie\API\lib\FannieUI::loadingBar();
        ?>
        </div>
        <div id="forms"></div>
        <?php 
        return ob_get_clean();
    }
Ejemplo n.º 15
0
 function body_content()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $filter = FormLib::get_form_value('filter', 1);
     $order = FormLib::get_form_value('order', 'num');
     $orderby = '';
     switch ($order) {
         case 'num':
         default:
             $orderby = 'emp_no';
             break;
         case 'name':
             $orderby = 'FirstName';
             break;
         case 'pass':
             $orderby = 'CashierPassword';
             break;
         case 'fes':
             $orderby = 'frontendsecurity';
             break;
     }
     $ret = '<div id="alert-area"></div><div class="form-inline">';
     $ret .= "<label>Showing</label> <select class=\"form-control\"\n            onchange=\"location='ViewCashiersPage.php?filter='+this.value;\">";
     if ($filter == 1) {
         $ret .= "<option value=1 selected>Active Cashiers</option>";
         $ret .= "<option value=0>Disabled Cashiers</option>";
     } else {
         $ret .= "<option value=1>Active Cashiers</option>";
         $ret .= "<option value=0 selected>Disabled Cashiers</option>";
     }
     $ret .= "</select></div><hr />";
     $ret .= "<table class=\"table\"><tr>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=num>#</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=name>Name</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=pass>Password</th>";
     $ret .= "<th><a href=ViewCashiersPage.php?filter={$filter}&order=fes>Privileges</th>";
     $ret .= "<th>&nbsp;</th><th>&nbsp;</th></tr>";
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $employees = new EmployeesModel($dbc);
     $employees->EmpActive($filter);
     foreach ($employees->find($orderby) as $emp) {
         $ret .= sprintf("<tr><td>%d</td><td>%s</td><td>%d</td><td>%s</td>", $emp->emp_no(), $emp->FirstName() . ' ' . $emp->LastName(), $emp->CashierPassword(), $emp->frontendsecurity() <= 20 ? 'Regular' : 'Manager');
         $ret .= sprintf("<td><a href=\"CashierEditor.php?emp_no=%d\">%s</a></td>\n                <td><a href=\"\" onclick=\"deleteEmp(%d,%d); return false;\">%s</a></td></tr>", $emp->emp_no(), \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $emp->emp_no(), $filter, \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }
     $ret .= "</table>";
     return $ret;
 }
Ejemplo n.º 16
0
 private function printRow($row)
 {
     printf("<tr>\n        <td>%s barcodes/shelftags</td>\n        <td style='text-align:right;'>%d</td>\n        <td><a href=\"\" onclick=\"goToPage('%d');return false;\">Print</a></td>\n        <td><a href=\"DeleteShelfTags.php?id=%d\">Clear</a></td>\n        <td><a href=\"EditShelfTags.php?id=%d\">" . \COREPOS\Fannie\API\lib\FannieUI::editIcon() . "</td>\n        <td><a href=\"SignFromSearch.php?queueID=%d\">Signs</a></td>\n        </tr>", $row[1], $row[2], $row[0], $row[0], $row[0], $row[0]);
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
0
 public function get_view()
 {
     global $FANNIE_OP_DB;
     $reasons = new ShrinkReasonsModel(FannieDB::get($FANNIE_OP_DB));
     $ret = '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
         <div id="alert-area"></div>
         <table class="table">';
     foreach ($reasons->find('shrinkReasonID') as $reason) {
         $ret .= sprintf('<tr>
             <td><input type="text" class="form-control" name="desc[]" value="%s" /></td>
             <td><a href="%s?_method=delete&id=%d">%s</a></td>
             <input type="hidden" name="id[]" value="%d" />
             </tr>', $reason->description(), $_SERVER['PHP_SELF'], $reason->shrinkReasonID(), \COREPOS\Fannie\API\lib\FannieUI::deleteIcon(), $reason->shrinkReasonID());
     }
     $ret .= '</table>';
     $ret .= '<p>
         <button type="submit" class="btn btn-default">Save Reasons</button>
         <a href="' . $_SERVER['PHP_SELF'] . '?new=1" class="btn btn-default">Add New Reason</a>
         </p>
         </form>';
     return $ret;
 }
Ejemplo n.º 19
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
    
    }
    */
    function body_content()
    {
        include '../config.php';
        ob_start();
        ?>
        <?php 
        echo showInstallTabs('Menu');
        ?>

        <form action=InstallMenuPage.php method=post>
        <h1 class="install">
            <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
        </h1>
        <?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
            echo "<br />Full path is: " . '../config.php' . "<br />";
            if (function_exists('posix_getpwuid')) {
                $chk = posix_getpwuid(posix_getuid());
                echo "PHP is running as: " . $chk['name'] . "<br />";
            } else {
                echo "PHP is (probably) running as: " . get_current_user() . "<br />";
            }
        }
        ?>

        <hr  />
        <p class="ichunk">
        Whether to always show the Fannie Administration Menu.
        <ul>
        <li>Coops may prefer not to show the menu in order to maximize the space available on the page for the report or tool.
        <li>Some pages may show or not show the Fannie Menu regardless of this setting,
        but setting it to Yes will increase the number of pages on which the menu appears.
        </ul>
        <b>Show Admin menu</b>
        <!-- "windowdressing" is the term used in Class Lib 2.0 for the heading and navigation menu.
             Use this to set the value of $window_dressing. -->
        <?php 
        echo installSelectField('FANNIE_WINDOW_DRESSING', $FANNIE_WINDOW_DRESSING, array(1 => 'Yes', 0 => 'No'), false);
        ?>
        </p>

        <hr  />
        <p class="ichunk">
        Use this tool to customize Fannie's menu. Usage:
        <ul>
        <li>Left hand text box contains the menu entry text
        <li>Right hand box contains a URL or a special value for other
        types of entries such as section headers.
        <li>URLs are relative to Fannie <i>unless</i> they begin with / or
        a protocol (http://, https://, etc).
        </ul>

        <h4 class="install">Fannie Menu Builder</h4>
        <?php 
        $VALID_MENUS = array('Item Maintenance', 'Sales Batches', 'Reports', 'Membership', 'Synchronize', 'Admin', '__store__');
        if (!isset($FANNIE_MENU) || !is_array($FANNIE_MENU)) {
            include '../src/init_menu.php';
            $FANNIE_MENU = $INIT_MENU;
        } else {
            foreach ($FANNIE_MENU as $menu => $content) {
                if (!in_array($menu, $VALID_MENUS)) {
                    // menu is not valid
                    // reset to default
                    // obviously not ideal error recovery
                    include '../src/init_menu.php';
                    $FANNIE_MENU = $INIT_MENU;
                    break;
                }
            }
        }
        for ($i = 0; $i < count($VALID_MENUS); $i++) {
            $post_titles = FormLib::get('m_title' . $i);
            $post_urls = FormLib::get('m_url' . $i);
            if (!is_array($post_titles) || !is_array($post_urls)) {
                continue;
            }
            /** rebuild from posted data **/
            $FANNIE_MENU[$VALID_MENUS[$i]] = array();
            $divider_count = 1;
            for ($j = 0; $j < count($post_titles); $j++) {
                $p_title = $post_titles[$j];
                $p_url = $post_urls[$j];
                // url must have some kind of value
                // title may be empty on dividers
                if (empty($p_url)) {
                    continue;
                }
                if ($p_url == '__divider__') {
                    $p_title = 'divider' . $divider_count;
                    $divider_count++;
                } elseif (empty($p_title)) {
                    continue;
                }
                $FANNIE_MENU[$VALID_MENUS[$i]][$p_title] = $p_url;
            }
        }
        if (FormLib::get('import-menu') !== '') {
            $import = FormLib::get('import-menu');
            $json = json_decode($import, true);
            if ($json === null) {
                echo '<div class="alert alert-danger">Menu Import is not valid JSON</div>';
            } else {
                $valid = true;
                foreach ($json as $menu => $content) {
                    if (!in_array($menu, $VALID_MENUS)) {
                        echo '<div class="alert alert-danger"><strong>' . $menu . '</strong> is not a valid top-level menu</div>';
                        $valid = false;
                        break;
                    } elseif (!is_array($content)) {
                        echo '<div class="alert alert-danger">Entries for <strong>' . $menu . '</strong> are not valid. It should be a JSON
                            object with keys representing menu titles and values
                            represeting URLs or the special values __header__ and
                            __divider__</div>';
                        $valid = false;
                        break;
                    }
                }
                if ($valid) {
                    $FANNIE_MENU = $json;
                    echo '<div class="alert alert-success">Imported menu</div>';
                }
            }
        }
        $saveStr = 'array(';
        $menu_number = 0;
        $select = '<select onchange="$(this).next(\'input\').val($(this).val());"
                        class="form-control">
                <option value="">URL</option>';
        $opts = array('__header__' => 'Section Header', '__divider__' => 'Divider Line');
        foreach ($FANNIE_MENU as $menu => $content) {
            $saveStr .= "'" . $menu . "' => array(";
            echo '<b>' . $menu . '</b>';
            echo '<ul id="menuset' . $menu_number . '">';
            foreach ($content as $m_title => $m_url) {
                $saveStr .= "'" . str_replace("'", "\\'", $m_title) . "' => '" . $m_url . "',";
                echo '<li class="form-inline">';
                printf('<input type="text" name="m_title%d[]" value="%s" class="form-control" />', $menu_number, $m_title);
                echo $select;
                foreach ($opts as $key => $val) {
                    printf('<option %s value="%s">%s</option>', $key == $m_url ? 'selected' : '', $key, $val);
                }
                echo '</select>';
                printf('<input type="text" name="m_url%d[]" value="%s" class="form-control" />', $menu_number, $m_url);
                echo ' [ <a href="" onclick="$(this).parent().remove(); return false;">Remove Entry</a> ]';
                echo '</li>';
            }
            $saveStr .= '),';
            echo '</ul>';
            $newEntry = sprintf('<li class="form-inline">
                            <input type="text" name="m_title%d[]" value="" class="form-control" />%s', $menu_number, $select);
            foreach ($opts as $key => $val) {
                $newEntry .= sprintf('<option value="%s">%s</option>', $key, $val);
            }
            $newEntry .= sprintf('</select><input type="text" name="m_url%d[]" value="" class="form-control" />
                    [ <a href="" onclick="$(this).parent().remove(); return false;">Remove Entry</a> ]
                    </li>', $menu_number);
            echo '<div id="newEntry' . $menu_number . '" class="collapse">';
            echo $newEntry;
            echo '</div>';
            printf('[ <a href="" onclick="$(\'ul#menuset%d\').append($(\'#newEntry%d\').html()); return false;">Add New Entry</a>
                to %s ]', $menu_number, $menu_number, $menu);
            echo '<br />';
            $menu_number++;
        }
        $saveStr .= ')';
        confset('FANNIE_MENU', $saveStr);
        ?>
        <hr />
        <div class="form-group">
        <label>Hand-editable Menu / Export</label>
        <textarea class="form-control" rows="15">
<?php 
        echo \COREPOS\Fannie\API\lib\FannieUI::prettyJSON(json_encode($FANNIE_MENU));
        ?>
        </textarea>
        </div>
        <div class="form-group">
        <label>Import Menu (use same JSON format)</label>
        <textarea name="import-menu" class="form-control" rows="15"></textarea>
        </div>
        <p>
            <button type="submit" name="psubmit" value="1" class="btn btn-default">Save Configuration</button>
        </p>
        </form>
        </body>
        </html>

        <?php 
        return ob_get_clean();
        // body_content
    }
Ejemplo n.º 20
0
    public function get_view()
    {
        $dbc = $this->connection;
        $settings = $this->config->get('PLUGIN_SETTINGS');
        $dbc->selectDB($settings['TimesheetDatabase']);
        $model = new TimesheetEmployeesModel($dbc);
        $ret = <<<HTML
<table class="table table-bordered table-striped">
<thead>
<tr>
    <th>#</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Department</th>
    <th>Position</th>
    <th>View/Edit</th>
</tr>
</thead>
<tbody>
HTML;
        $depts = array();
        $dModel = new TimesheetDepartmentsModel($dbc);
        foreach ($dModel->find() as $d) {
            $depts[$d->timesheetDepartmentID()] = $d->name();
        }
        $shifts = array();
        $sModel = new ShiftsModel($dbc);
        foreach ($sModel->find() as $s) {
            $shifts[$s->shiftID()] = $s->NiceName();
        }
        foreach ($model->find('timesheetEmployeeID') as $obj) {
            $ret .= sprintf('<tr>
                <td>%d</td>
                <td>%s</td>
                <td>%s</td>
                <td>%s</td>
                <td>%s</td>
                <td><a href="?id=%d" class="btn btn-default btn-xs">%s</a></td>
                </tr>', $obj->timesheetEmployeeID(), $obj->firstName(), $obj->lastName(), isset($depts[$obj->timesheetDepartmentID()]) ? $depts[$obj->timesheetDepartmentID()] : '?', isset($shifts[$obj->primaryShiftID()]) ? $shifts[$obj->primaryShiftID()] : '?', $obj->timesheetEmployeeID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon());
        }
        $ret .= <<<HTML
</tbody>
</table>
<form class="form-inline" method="post">
<p>
    <label>Timesheet ID</label>
    <input type="text" class="form-control" name="newID"
        placeholder="Optional - omit for automatic ID" 
        title="Optional - omit for automatic ID" 
        />
    <button type="submit" class="btn btn-default">Create New Employee</button>
</p>
HTML;
        return $ret;
    }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
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;
 }
Ejemplo n.º 23
0
 public function get_view()
 {
     $dbc = $this->connection;
     $settings = $this->config->get('PLUGIN_SETTINGS');
     $dbc->selectDB($settings['ScheduledEmailDB']);
     $templates = new ScheduledEmailTemplatesModel($dbc);
     $ret = '<table class="table table-bordered table-striped">
         <thead>
         <tr>
             <th>ID</th>
             <th>Name</th>
             <th>&nbsp;</th>
             <th>&nbsp;</th>
         </tr>
         </thead>
         <tbody>';
     foreach ($templates->find('scheduledEmailTemplateID') as $t) {
         $ret .= sprintf('<tr>
             <td>%d</td>
             <td>%s</td>
             <td><a class="btn btn-default btn-xs" href="?id=%d">%s</a></td>
             <td><a class="btn btn-danger btn-xs" href="?_method=delete&id=%d"
                 onclick="return confirm(\'Delete template %s?\');">%s</a></td>
             </tr>', $t->scheduledEmailTemplateID(), $t->name(), $t->scheduledEmailTemplateID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon(), $t->scheduledEmailTemplateID(), $t->name(), \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }
     $ret .= '</tbody></table>';
     $ret .= '<p>
         <a href="?_method=put" class="btn btn-default">Create New Template</a>
         </p>';
     return $ret;
 }
Ejemplo n.º 24
0
 public function get_view()
 {
     $dbc = FannieDB::getReadOnly($this->config->get('OP_DB'));
     $plans = new EquityPaymentPlansModel($dbc);
     $ret = '<table class="table table-bordered">
         <tr>
             <th>Name</th>
             <th>Payment Amount</th>
             <th>Frequency</th>
         </tr>';
     foreach ($plans->find('name') as $plan) {
         $ret .= sprintf('
             <tr>
                 <td>%s</td>
                 <td>%.2f</td>
                 <td>%s</td>
                 <td><a class="btn btn-default btn-xs" href="%s?id=%d">%s</a></td>
             </tr>', $plan->name(), $plan->recurringPayment(), $plan->billingCycle(), filter_input(INPUT_SERVER, 'PHP_SELF'), $plan->equityPaymentPlanID(), \COREPOS\Fannie\API\lib\FannieUI::editIcon());
     }
     $ret .= '</table>';
     $ret .= '<p>
         <a href="?_method=put" class="btn btn-default">Create New Plan</a>
         </p>';
     return $ret;
 }
Ejemplo n.º 25
0
 public function get_view()
 {
     $lib_class = $this->lib_class;
     $dbc = $lib_class::getDB();
     $model = $lib_class::getCategory($dbc);
     $model->hasSales(1);
     $map = $lib_class::getCategoryMap($dbc);
     $supers = 'SELECT s.superID, s.super_name
                FROM ' . $this->config->get('OP_DB') . $dbc->sep() . 'superDeptNames AS s
                ORDER BY s.super_name';
     $res = $dbc->query($supers);
     $sdepts = array();
     while ($row = $dbc->fetch_row($res)) {
         $sdepts[$row['superID']] = $row['super_name'];
     }
     $ret = '<div class="col-sm-5">';
     $ret .= '<form method="post">';
     $ret .= '<table class="table">';
     $ret .= '<tr>
              </tr>';
     foreach ($model->find() as $cat) {
         $ret .= '<tr><th colspan="2">' . $cat->name() . '</th>
                 <td>' . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon('Check box for row to delete') . '
                 </td></tr>';
         $map->obfCategoryID($cat->obfCategoryID());
         foreach ($map->find() as $obj) {
             $ret .= sprintf('<tr>
                             <input type="hidden" name="id[]" value="%d" />
                             <input type="hidden" name="superID[]" value="%d" />
                             <td>%s</td>
                             <td><div class="input-group">
                                 <input type="text" name="growth[]" class="form-control" required value="%.3f" />
                                 <span class="input-group-addon">%%</span>
                             </div></td>
                             <td><input type="checkbox" name="delete[]" value="%d:%d" /></td>
                             </tr>', $obj->obfCategoryID(), $obj->superID(), $sdepts[$obj->superID()], $obj->growthTarget() * 100, $obj->obfCategoryID(), $obj->superID());
             unset($sdepts[$obj->superID()]);
         }
     }
     $ret .= '</table>';
     $ret .= '<p><button type="submit" class="btn btn-default">Save Mapping</button></p>';
     $ret .= '</form>';
     $ret .= '</div>';
     $ret .= '<div class="col-sm-5">';
     $ret .= '<div class="panel panel-default"><div class="panel-body">';
     $ret .= '<form method="post">
                 <div class="form-group form-inline">';
     $ret .= '<label>Add</label> <select name="add" class="form-control">';
     foreach ($sdepts as $id => $name) {
         $ret .= sprintf('<option value="%d">%s</option>', $id, $name);
     }
     $ret .= '</select>';
     $ret .= ' <label>to</label> <select name="cat" class="form-control">';
     foreach ($model->find() as $cat) {
         $ret .= sprintf('<option value="%d">%s</option>', $cat->obfCategoryID(), $cat->name());
     }
     $ret .= '</select></div>';
     $ret .= '<p><button type="submit" class="btn btn-default">Add New Mapping</button>';
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<button type="button" class="btn btn-default"
             onclick="location=\'index.php\';return false;">Home</button></p>';
     $ret .= '</form>';
     $ret .= '</div>';
     $ret .= '<div class="panel-footer">Note: percentages are sales growth targets for categories</div>';
     $ret .= '</div>';
     $ret .= '</div>';
     return $ret;
 }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
0
 function body_content()
 {
     $this->addScript('type-editor.js');
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $model = new BatchTypeModel($dbc);
     $ret = '<table class="table">';
     $ret .= '<tr>
         <th>ID#</th>
         <th>Description</th>
         <th>Discount Type</th>
         <th>Dated Signs</th>
         <th title="Special Order Eligible">SO Eligible</th>
         <th>Editing Interface</th>
         <th>&nbsp;</td>
     </tr>';
     foreach ($model->find('batchTypeID') as $obj) {
         $ret .= sprintf('<tr>
             <td>%d</td>
             <td><input type="text" class="form-control" onchange="saveDesc.call(this,this.value,%d)" value="%s" /></td>
             <td><select onchange="saveType.call(this, $(this).val(),%d);" class="form-control">', $obj->batchTypeID(), $obj->batchTypeID(), $obj->typeDesc(), $obj->batchTypeID());
         $found = false;
         foreach ($this->price_methods as $id => $desc) {
             if ($id == $obj->discType()) {
                 $found = true;
                 $ret .= sprintf('<option value="%d" selected>%d %s</option>', $id, $id, $desc);
             } else {
                 $ret .= sprintf('<option value="%d">%d %s</option>', $id, $id, $desc);
             }
         }
         if (!$found) {
             $ret .= sprintf('<option value="%d" selected>%d (Custom)</option>', $w['discType'], $w['discType']);
         }
         $ret .= '</select></td>';
         $ret .= sprintf('<td align="center">
                 <input type="checkbox" %s onchange="saveDated.call(this, %d);" />
                 </td>', $obj->datedSigns() ? 'checked' : '', $obj->batchTypeID());
         $ret .= sprintf('<td align="center">
                 <input type="checkbox" %s onchange="saveSO.call(this, %d);" />
                 </td>', $obj->specialOrderEligible() ? 'checked' : '', $obj->batchTypeID());
         $ret .= sprintf('<td>
                 <select onchange="saveUI.call(this, $(this).val(),%d);" class="form-control">', $obj->batchTypeID());
         foreach ($this->editor_uis as $id => $desc) {
             $ret .= sprintf('<option %s value="%d">%s</option>', $id == $obj->editorUI() ? 'selected' : '', $id, $desc);
         }
         $ret .= '</select></td>';
         $ret .= sprintf('<td><a href="BatchTypeEditor.php?deltype=yes&bid=%d"
             class="btn btn-danger btn-sm"
             onclick="return confirm(\'Are you sure?\');">%s</a>
         </td></tr>', $obj->batchTypeID(), \COREPOS\Fannie\API\lib\FannieUI::deleteIcon());
     }
     $ret .= '</table>';
     $ret .= '<p><button onclick="location=\'BatchTypeEditor.php?addtype=yes\';"
         class="btn btn-default">Create New Type</button></p>';
     return $ret;
 }
Ejemplo n.º 28
0
 private function pairedTableBody($dbc, $result)
 {
     $colors = array('#ffffff', '#ffffcc');
     $cur = 0;
     $FANNIE_URL = $this->config->get('URL');
     $ret = '';
     while ($fetchW = $dbc->fetch_array($result)) {
         $cur = ($cur + 1) % 2;
         $ret .= "<tr>";
         $fetchW[0] = rtrim($fetchW[0]);
         if (substr($fetchW[0], 0, 2) == "LC") {
             $likecode = rtrim(substr($fetchW[0], 2));
             $ret .= "<td bgcolor={$colors[$cur]}>" . $fetchW['upc'];
             $ret .= " <a href=\"\" onclick=\"\$('.lc-item-{$likecode}').toggle(); return false;\">[+]</a>";
             $ret .= "</td>";
         } else {
             $ret .= "<td bgcolor={$colors[$cur]}><a href={$FANNIE_URL}item/ItemEditorPage.php?searchupc={$fetchW['0']} target=_new{$fetchW['0']}>{$fetchW['0']}</a></td>";
         }
         $ret .= "<td bgcolor={$colors[$cur]}>{$fetchW['1']}</td>";
         $ret .= "<td bgcolor={$colors[$cur]}>\n                <a href=\"\" class=\"down-arrow\" onclick=\"swapQualifierToDiscount(this, '{$fetchW['0']}'); return false;\">\n                    <img src=\"{$FANNIE_URL}src/img/buttons/arrow_down.gif\" alt=\"Make Discount Item\" /></a>\n                <a href=\"\" class=\"up-arrow collapse\" onclick=\"swapDiscountToQualifier(this, '{$fetchW['0']}'); return false;\">\n                    <img src=\"{$FANNIE_URL}src/img/buttons/arrow_up.gif\" alt=\"Make Qualifying Item\" />\n                    </a>\n                </td>";
         $ret .= "<td bgcolor={$colors[$cur]}><a href=\"\" onclick=\"deleteUPC.call(this, {$fetchW['batchID']}, '{$fetchW['0']}'); return false;\">" . \COREPOS\Fannie\API\lib\FannieUI::deleteIcon() . '</a></td>';
         $ret .= "</tr>";
         if (substr($fetchW['upc'], 0, 2) == "LC") {
             $likecode = rtrim(substr($fetchW['upc'], 2));
             $ret .= self::likeToTable($dbc, $likecode, $fetchW['salePrice']);
         }
     }
     return $ret;
 }