예제 #1
0
 public function showEditForm($upc, $display_mode = 1, $expand_mode = 1)
 {
     $upc = BarcodeLib::padUPC($upc);
     $dbc = $this->db();
     $p = $dbc->prepare_statement('SELECT * FROM scaleItems WHERE plu=?');
     $r = $dbc->exec_statement($p, array($upc));
     $scale = array('itemdesc' => '', 'weight' => 0, 'bycount' => 0, 'tare' => 0, 'shelflife' => 0, 'label' => 133, 'graphics' => 0, 'text' => '', 'netWeight' => 0);
     $found = false;
     if ($dbc->num_rows($r) > 0) {
         $scale = $dbc->fetch_row($r);
         $found = true;
     }
     if (!$found && $display_mode == 2 && substr($upc, 0, 3) != '002') {
         return '';
     }
     $css = '';
     if ($expand_mode == 1) {
         $css = '';
     } else {
         if ($found && $expand_mode == 2) {
             $css = '';
         } else {
             $css = 'display:none;';
         }
     }
     $ret = '<div id="ScaleItemFieldset" class="panel panel-default">';
     $ret .= "<div class=\"panel-heading\">\n                <a href=\"\" onclick=\"\$('#ScaleFieldsetContent').toggle();return false;\">\n                Scale</a>\n                </div>";
     $ret .= '<div id="ScaleFieldsetContent" class="panel-body" style="' . $css . '">';
     $p = $dbc->prepare_statement('SELECT description FROM products WHERE upc=?');
     $r = $dbc->exec_statement($p, array($upc));
     $reg_description = '';
     if ($dbc->num_rows($r) > 0) {
         $w = $dbc->fetch_row($r);
         $reg_description = $w['description'];
     }
     $ret .= sprintf('<input type="hidden" name="s_plu" value="%s" />', $upc);
     $ret .= "<table style=\"background:#ffffcc;\" class=\"table\">";
     $ret .= sprintf("<tr><th colspan=2>Longer description</th><td colspan=5><input size=35 \n                type=text name=s_longdesc maxlength=100 value=\"%s\" \n                class=\"form-control\" /></td></tr>", $reg_description == $scale['itemdesc'] ? '' : $scale['itemdesc']);
     $ret .= "<tr><th>Weight</th><th>By Count</th><th>Tare</th><th>Shelf Life</th>";
     $ret .= "<th>Net Wt (oz)</th><th>Label</th><th>Safehandling</th></tr>";
     $ret .= '<tr><td><select name="s_type" class="form-control" size="2">';
     if ($scale['weight'] == 0) {
         $ret .= "<option value=\"Random Weight\" selected /> Random</option>";
         $ret .= "<option value=\"Fixed Weight\" /> Fixed</option>";
     } else {
         $ret .= "<option value=\"Random Weight\" /> Random</option>";
         $ret .= "<option value=\"Fixed Weight\" selected /> Fixed</option>";
     }
     $ret .= '</select></td>';
     $ret .= sprintf("<td align=center><input type=checkbox value=1 name=s_bycount %s /></td>", $scale['bycount'] == 1 ? 'checked' : '');
     $ret .= sprintf("<td align=center><input type=text class=\"form-control\" name=s_tare value=\"%s\" /></td>", $scale['tare']);
     $ret .= sprintf("<td align=center><input type=text class=\"form-control\" name=s_shelflife value=\"%s\" /></td>", $scale['shelflife']);
     $ret .= sprintf("<td align=center><input type=text class=\"form-control\" name=s_netwt value=\"%s\" /></td>", $scale['netWeight']);
     $ret .= "<td><select name=s_label size=2 class=\"form-control\">";
     $label_attr = \COREPOS\Fannie\API\item\ServiceScaleLib::labelToAttributes($scale['label']);
     if ($label_attr['align'] == 'horizontal') {
         $ret .= "<option value=horizontal selected>Horizontal</option>";
         $ret .= "<option value=vertical>Vertical</option>";
     } else {
         $ret .= "<option value=horizontal>Horizontal</option>";
         $ret .= "<option value=vertical selected>Vertical</option>";
     }
     $ret .= '</select></td>';
     $ret .= sprintf("<td align=center><input type=checkbox value=1 name=s_graphics %s /></td>", $scale['graphics'] > 0 ? 'checked' : '');
     $ret .= '</tr>';
     $ret .= "<tr><td colspan=7>";
     $ret .= '<div class="col-sm-6">';
     $ret .= "<b>Expanded text:<br />\n            <textarea name=s_text rows=4 cols=45 class=\"form-control\">";
     $ret .= $scale['text'];
     $ret .= "</textarea>";
     $ret .= '</div>';
     $scales = new ServiceScalesModel($dbc);
     $mapP = $dbc->prepare('SELECT upc
                            FROM ServiceScaleItemMap
                            WHERE serviceScaleID=?
                             AND upc=?');
     $deptP = $dbc->prepare('SELECT p.upc
                             FROM products AS p
                                 INNER JOIN superdepts AS s ON p.department=s.dept_ID
                             WHERE p.upc=?
                                 AND s.superID=?');
     $ret .= '<div class="col-sm-6">';
     foreach ($scales->find('description') as $scale) {
         $checked = false;
         $mapR = $dbc->execute($mapP, array($scale->serviceScaleID(), $upc));
         if ($dbc->num_rows($mapR) > 0) {
             // marked in map table
             $checked = true;
         } else {
             $deptR = $dbc->execute($deptP, array($upc, $scale->superID()));
             if ($dbc->num_rows($deptR) > 0) {
                 // in a POS department corresponding
                 // to this scale
                 $checked = true;
             }
         }
         $css_class = '';
         $title = '';
         if ($checked) {
             $online = \COREPOS\Fannie\API\item\ServiceScaleLib::scaleOnline($scale->host());
             $css_class = $online ? 'has-success' : 'has-danger';
             $title = $online ? 'Scale Online' : 'Scale Offline';
         }
         $ret .= sprintf('<div class="form-group %s" title="%s"><div class="checkbox">
                         <label class="control-label">
                         <input type="checkbox" name="scaleID[]" id="scaleID%d" value=%d %s />
                         %s</label>
                         </div></div>', $css_class, $title, $scale->serviceScaleID(), $scale->serviceScaleID(), $checked ? 'checked' : '', $scale->description());
     }
     $ret .= '</div>';
     $ret .= "</td></tr>";
     $ret .= '</table></div></div>';
     return $ret;
 }
예제 #2
0
 public function preview_content()
 {
     $scales = new ServiceScalesModel($this->connection);
     $ret = '<fieldset><legend>Send to Scales</legend>';
     foreach ($scales->find('description') as $obj) {
         $ret .= sprintf('<label>
             <input type="checkbox" name="scales[]" value="%d" /> %s
             </label><br />', $obj->serviceScaleID(), $obj->description());
     }
     $ret .= '</fieldset>';
     $ret .= '<label><input type="checkbox" name="prodPricing" />
                 Update POS Product Pricing</label>';
     return $ret;
 }
예제 #3
0
 function post_u_view()
 {
     global $FANNIE_OP_DB, $FANNIE_URL;
     $this->add_script($FANNIE_URL . '/src/javascript/jquery.js');
     $this->add_css_file($FANNIE_URL . '/src/style.css');
     $ret = '';
     $ret .= '<form action="SyncFromSearch.php" method="post">';
     $scales = new ServiceScalesModel(FannieDB::get($FANNIE_OP_DB));
     $ret .= '<div class="panel panel-default">
         <div class="panel-heading">Scales</div>
         <div class="panel-body">';
     foreach ($scales->find('description') as $scale) {
         $ret .= sprintf('<input type="checkbox" class="scaleID" name="scaleID[]" 
                             id="scaleID%d" value="%d" />
                          <label for="scaleID%d">%s</label><br />', $scale->serviceScaleID(), $scale->serviceScaleID(), $scale->serviceScaleID(), $scale->description());
     }
     $ret .= '</div></div>';
     $ret .= '<p><button type="submit" name="sendall" value="1"
                 class="btn btn-default">Sync All Items</button></p>';
     $ret .= '<div id="alert-area"></div>';
     $ret .= '<table class="table">';
     $ret .= '<tr>
             <th>UPC</th>
             <th>Description</th>
             <th>Price</th>
             <th>Last Changed</th>
             <th>Send Now</th>
             </tr>';
     $model = new ScaleItemsModel(FannieDB::get($FANNIE_OP_DB));
     foreach ($this->upcs as $upc) {
         $model->plu($upc);
         if (!$model->load()) {
             continue;
         }
         $ret .= sprintf('<tr id="row%s">
                         <td>%s</td>
                         <td>%s</td>
                         <td>%.2f</td>
                         <td>%s</td>
                         <td><button type="button" class="btn btn-default"
                             onclick="sendOne(\'%s\'); return false;">Sync Item</button></td>
                         <input type="hidden" name="upcs[]" value="%s" />
                         </tr>', $model->plu(), $model->plu(), $model->mergeDescription(), $model->price(), $model->modified(), $model->plu(), $model->plu());
     }
     $ret .= '</table>';
     $ret .= '</form>';
     return $ret;
 }
예제 #4
0
 public function get_view()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $scales = new ServiceScalesModel($dbc);
     $supers = array();
     $result = $dbc->query('SELECT superID, super_name FROM superDeptNames ORDER BY super_name');
     while ($row = $dbc->fetch_row($result)) {
         $supers[$row['superID']] = $row['super_name'];
     }
     $ret = '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
     $ret .= '<table class="table">
         <tr><th>Description</th><th>Host</th><th>Type</th><th>Scale Dept.</th><th>POS Super Dept</th>
         <th>Store # (EP)</th><th>Dept # (EP)</th><th>Address # (EP)</th>
         </tr>';
     foreach ($scales->find('description') as $scale) {
         $ret .= sprintf('<tr>
                         <input type="hidden" name="id[]" value="%d" />
                         <td><input type="text" name="description[]" 
                             class="form-control" value="%s" /></td>
                         <td><input type="text" name="host[]" 
                             class="form-control" value="%s" /></td>
                         <td><input type="text" name="type[]" 
                             class="form-control" value="%s" /></td>
                         <td><input type="text" name="scaleDept[]" 
                             class="form-control" value="%s" /></td>
                             ', $scale->serviceScaleID(), $scale->description(), $scale->host(), $scale->scaleType(), $scale->scaleDeptName());
         $ret .= '<td><select name="super[]" class="form-control">
                     <option value="">None</option>';
         foreach ($supers as $id => $name) {
             $ret .= sprintf('<option %s value="%d">%s</option>', $scale->superID() !== null && $scale->superID() == $id ? 'selected' : '', $id, $name);
         }
         $ret .= '</select></td>';
         $ret .= sprintf('
                     <td><input type="text" name="store-no[]"
                         class="form-control" value="%d" /></td>
                     <td><input type="text" name="dept-no[]"
                         class="form-control" value="%d" /></td>
                     <td><input type="text" name="address-no[]"
                         class="form-control" value="%d" /></td>', $scale->epStoreNo(), $scale->epDeptNo(), $scale->epScaleAddress());
         $ret .= '</tr>';
     }
     $ret .= '</table>';
     $ret .= '<p><button type="submit" class="btn btn-default">Save Changes</button>';
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<button type="button" class="btn btn-default"
                 onclick="location=\'ScaleEditor.php?new=true\';return false;">Add Scale</button>
              </p>';
     $ret .= '</form>';
     return $ret;
 }