Example #1
0
 public function get_view()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $model = new $this->model_name($dbc);
     $ret = '';
     if (FormLib::get('flash') !== '') {
         $ret .= '<div class="alert alert-info">' . FormLib::get('flash') . '</div>';
     }
     $ret .= '<form method="get">';
     $ret .= '<div class="form-inline">';
     foreach ($model->getColumns() as $name => $info) {
         $ret .= sprintf('
             <div class="form-group">
                 <label class="control-label">%s</label>
                 <input type="text" class="form-control" name="%s" %s />
             </div> ', ucwords($name), $name, isset($info['primary_key']) && $info['primary_key'] ? 'required' : '');
     }
     $ret .= '<input type="hidden" name="_method" value="put" />';
     $ret .= '<button type="submit" class="btn btn-default">Add Entry</button>';
     $ret .= '</div>';
     $ret .= '</form>';
     $ret .= '<hr />';
     $ret .= '<form method="post">';
     $ret .= '<table class="table table-striped table-bordered">';
     $ret .= '<thead><tr>';
     foreach ($model->getColumns() as $name => $info) {
         $ret .= '<th>' . ucwords($name) . '</th>';
     }
     $ret .= '</tr></thead>';
     $ret .= '<tbody>';
     foreach ($model->find() as $obj) {
         $ret .= '<tr>';
         $pk = false;
         foreach ($model->getColumns() as $name => $info) {
             if (isset($info['primary_key']) && $info['primary_key']) {
                 $ret .= sprintf('<td>%s
                             <input type="hidden" name="%s[]" value="%s" />
                             </td>', $obj->{$name}(), $name, $obj->{$name}());
                 if ($pk === false) {
                     $pk = $obj->{$name}();
                 } else {
                     $pk = false;
                 }
             } else {
                 $ret .= sprintf('<td>
                             <input type="text" class="form-control" name="%s[]" value="%s" />
                             </td>', $name, $obj->{$name}());
             }
         }
         $ret .= '<td>';
         if ($pk != false) {
             $ret .= '<a href="?_method=delete&id=' . $pk . '" class="btn btn-danger">' . FannieUI::deleteIcon() . '</a>';
         }
         $ret .= '</td>';
         $ret .= '</tr>';
     }
     $ret .= '</tbody></table>';
     $ret .= '<p><button class="btn btn-default">Save Changes</button></p>';
     $ret .= '</form>';
     $this->addOnloadCommand("\$('input:first').focus();\n");
     return $ret;
 }
Example #2
0
 public function get_id_view()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $prep = $dbc->prepare("\n            SELECT m.sku,\n                m.upc,\n                v.description AS vendorDescript,\n                p.description as storeDescript\n            FROM VendorBreakdowns AS m\n                " . DTrans::joinProducts('m') . "\n                LEFT JOIN vendorItems AS v ON v.sku=m.sku AND v.vendorID=m.vendorID\n            WHERE m.vendorID = ?\n            ORDER BY m.upc\n        ");
     $ret = '';
     $ret .= '<form action="' . $_SERVER['PHP_SELF'] . '" method="get">';
     $ret .= '<div class="form-group form-inline">
         <label>SKU</label>
         <input type="text" class="form-control" name="sku" placeholder="Vendor SKU" />
         <label>PLU/UPC</label>
         <input type="text" class="form-control" name="plu" placeholder="Our PLU" />
         <button type="submit" class="btn btn-default">Add Entry</button>
         <input type="hidden" name="id" value="' . $this->id . '" />
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a href="?id=' . $this->id . '&break=1" class="btn btn-default">Run Breakdowns</a>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a href="VendorIndexPage.php?vid=' . $this->id . '" class="btn btn-default">Home</a>
         </div>
         </form>';
     $ret .= '<table class="table table-bordered">';
     $ret .= '<thead><tr>
         <th>Vendor SKU</th>
         <th>Our PLU</th>
         <th>Vendor Description</th>
         <th>Our Description</th>
         <th>&nbsp;</th>
         </tr></thead><tbody>';
     $res = $dbc->execute($prep, array($this->id));
     while ($row = $dbc->fetchRow($res)) {
         if (empty($row['vendorDescript'])) {
             $row['vendorDescript'] = '<span class="alert-danger">Discontinued by vendor?</span>';
         }
         if (empty($row['storeDescript'])) {
             $row['storeDescript'] = '<span class="alert-danger">Discontinued by us?</span>';
         }
         $ret .= sprintf('
             <tr>
                 <td>%s</td>
                 <td><a href="../ItemEditorPage.php?searchupc=%s">%s</a></td>
                 <td>%s</td>
                 <td>%s</td>
                 <td>
                     <a href="?_method=delete&id=%d&sku=%s&plu=%s" 
                     onclick="return confirm(\'Delete entry for PLU #%s?\');">%s</a>
                 </td>
             </tr>', $row['sku'], $row['upc'], $row['upc'], $row['vendorDescript'], $row['storeDescript'], $this->id, $row['sku'], $row['upc'], $row['upc'], FannieUI::deleteIcon());
     }
     $ret .= '</tbody></table>';
     $this->addScript('../../src/javascript/tablesorter/jquery.tablesorter.js');
     $this->addOnloadCommand("\$('.table').tablesorter([[1,0]]);\n");
     return $ret;
 }
 public function get_id_view()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $vendor = new VendorsModel($dbc);
     $vendor->vendorID($this->id);
     $vendor->load();
     $ret = '<p id="vendor-name">New <strong>' . $vendor->vendorName() . '</strong> order</p>';
     $ret .= '<div id="alert-area"></div>';
     $ret .= '<form id="order-form" onsubmit="saveOrder(); return false;">
         <input type="hidden" id="vendor-id" name="id" value="' . $this->id . '" />
         <div class="form-group form-inline">
             <label>Order Date</label>
             <input type="text" name="order-date" class="form-control date-field"
                 value="' . date('Y-m-d') . '" />
             <label>PO #</label>
             <input type="text" name="po-number" class="form-control" />
             <label>Inv. #</label>
             <input type="text" name="inv-number" class="form-control" />
         </div>';
     $ret .= '<div class="collapse" id="delete-html">' . FannieUI::deleteIcon() . '</div>';
     $ret .= '<div class="form-group">
         <button type="button" class="btn btn-default" onclick="addInvoiceLine();">Add Line</button>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <button type="submit" class="btn btn-default" id="save-btn">Save As Order</button>
         </div>';
     $ret .= '<table class="table table-bordered" id="invoice-table">
         <thead><tr>
             <th>SKU</th>
             <th>UPC</th>
             <th>Cases</th>
             <th>Units/Case</th>
             <th>Total Cost</th>
             <th>Brand</th>
             <th>Description</th>
         </thead>
         <tbody>
         </tbody>
         </table>';
     $ret .= '</form>';
     $this->addScript('js/manual.js');
     $this->addScript('../item/autocomplete.js');
     $this->addOnloadCommand('addInvoiceLine();');
     return $ret;
 }