コード例 #1
0
ファイル: ShrinkReasonEditor.php プロジェクト: phpsmith/IS4C
 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;
 }
コード例 #2
0
ファイル: ShrinkEditor.php プロジェクト: phpsmith/IS4C
 public function get_view()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $model = new ShrinkReasonsModel($dbc);
     $reasons = array(0 => 'n/a');
     foreach ($model->find('description') as $obj) {
         $reasons[$obj->shrinkReasonID()] = $obj->description();
     }
     $dbc = FannieDB::get($this->config->get('TRANS_DB'));
     $query = '
         SELECT upc,
             description,
             quantity,
             unitPrice,
             total,
             emp_no,
             register_no,
             trans_no,
             trans_id,
             store_id,
             charflag,
             numflag
         FROM dtransactions
         WHERE trans_status=\'Z\'
             AND trans_type IN (\'I\', \'D\')
             AND emp_no <> 9999
             AND register_no <> 99
             AND ' . $dbc->datediff('datetime', $dbc->now()) . ' = 0';
     $result = $dbc->query($query);
     $ret = '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
     $ret .= '<table class="table">';
     $ret .= '<tr><th>UPC</th><th>Description</th><th>Qty</th><th>Unit Price</th><th>Total</th>
              <th>Reason</th><th>Loss</th></tr>';
     while ($row = $dbc->fetch_row($result)) {
         $id = array('emp_no' => $row['emp_no'], 'register_no' => $row['register_no'], 'trans_no' => $row['trans_no'], 'trans_id' => $row['trans_id'], 'store_id' => $row['store_id']);
         $id = base64_encode(json_encode($id));
         $ret .= sprintf('<tr>
                     <td>%s<input type="hidden" name="id[]" value="%s" /></td>
                     <td>%s</td>
                     <td><input type="text" name="qty[]" value="%.2f" class="form-control" /></td>
                     <td>$%.2f</td>
                     <td>$%.2f</td>', $row['upc'], $id, $row['description'], $row['quantity'], $row['unitPrice'], $row['total']);
         $ret .= '<td><select name="reason[]" class="form-control">';
         foreach ($reasons as $id => $label) {
             $ret .= sprintf('<option %s value="%d">%s</option>', $id == $row['numflag'] ? 'selected' : '', $id, $label);
         }
         $ret .= '</select></td>';
         $ret .= '<td>
                     <select name="loss[]" class="form-control">
                         <option value="L">Loss</option> 
                         <option value="C" ' . ($row['charflag'] == 'C' ? 'selected' : '') . '>Contribute</option>
                     </select>
                  </td>
                  </tr>';
     }
     $ret .= '</table>';
     $ret .= '<p>
         <button type="submit" class="btn btn-default">Update Quantities</button>
         |
         <a href="ShrinkTool.php" class="btn btn-default">Enter More Items</a>
         </p>';
     $ret .= '</form>';
     return $ret;
 }
コード例 #3
0
ファイル: ShrinkTool.php プロジェクト: phpsmith/IS4C
    public function get_id_view()
    {
        global $FANNIE_OP_DB;
        $dbc = FannieDB::get($FANNIE_OP_DB);
        $this->add_onload_command("\$('#qty-field').focus();\n");
        $reasons = new ShrinkReasonsModel($dbc);
        $shrink_opts = '';
        foreach ($reasons->find('description') as $reason) {
            $shrink_opts .= sprintf('<option value="%d">%s</option>', $reason->shrinkReasonID(), $reason->description());
        }
        $ret = <<<HTML
<form method="post">
    <div class="form-group">
        <label>UPC</label> {{upc}} {{description}}
        <input type="hidden" name="upc" value="{{upc}}" />
        <input type="hidden" name="description" value="{{description}}" />
        <input type="hidden" name="department" value="{{department}}" />
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="row form-group">
                <label class="col-sm-3 text-right">Unit Cost</label>
                <div class="col-sm-9">
                    <div class="input-group">
                        <span class="input-group-addon">\$</span>
                        <input type="text" name="cost" class="form-control" value="{{cost}}" />
                    </div> 
                </div> 
            </div> 
            <div class="row form-group">
                <label class="col-sm-3 text-right">Quantity</label>
                <div class="col-sm-9">
                    <input type="text" name="qty" id="qty-field" class="form-control" required />
                </div>
            </div>
            <div class="row form-group">
                <label class="col-sm-3 text-right">Type</label>
                <div class="col-sm-9">
                    <select name="type" class="form-control">
                        <option>Loss</option>
                        <option>Contribute</option>
                    </select>
                </div> 
            </div> 
        </div> <!-- end left column col-sm-6 -->
        <div class="col-sm-6">
            <div class="form-group row">
                <label class="col-sm-3 text-right">Unit Price</label>
                <div class="col-sm-9">
                    <div class="input-group">
                        <span class="input-group-addon">\$</span>
                        <input type="text" name="price" class="form-control" value="{{price}}" />
                    </div> 
                </div> 
            </div> 
            <div class="row form-group">
                <label class="col-sm-3 text-right">Reason</label>
                <div class="col-sm-9">
                    <select name="reason" class="form-control">';
                        {{shrink_opts}}
                    </select>
                </div>
            </div>
        </div> <!-- end right column col-sm-6 -->
    </div> <!-- end row containing two col-sm-6 columns -->
    <div class="row form-group">
        <div class="col-sm-2">
            <button type="submit" class="btn btn-default">Enter Shrink</button>
        </div>
        <div class="col-sm-2">
            <a href="{{PHP_SELF}}" class="btn btn-default">Go Back</a>
        </div>
    </div>
</form>
HTML;
        $ret = str_replace('{{upc}}', $this->upc, $ret);
        $ret = str_replace('{{description}}', $this->description, $ret);
        $ret = str_replace('{{department}}', $this->department, $ret);
        $ret = str_replace('{{price}}', $this->price, $ret);
        $ret = str_replace('{{cost}}', $this->cost, $ret);
        $ret = str_replace('{{shrink_opts}}', $shrink_opts, $ret);
        $ret = str_replace('{{PHP_SELF}}', $_SERVER['PHP_SELF'], $ret);
        return $ret;
    }