Ejemplo n.º 1
0
 protected function post_fname_lname_fes_birthdate_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $passwd = $this->genPassword($dbc);
     $emp_no = $this->nextEmpNo($dbc);
     $employee = new EmployeesModel($dbc);
     $employee->emp_no($emp_no);
     $employee->CashierPassword($passwd);
     $employee->AdminPassword($passwd);
     $employee->FirstName($this->fname);
     $employee->LastName($this->lname);
     $employee->JobTitle('');
     $employee->EmpActive(1);
     $employee->frontendsecurity($this->fes);
     $employee->backendsecurity($this->fes);
     $employee->birthdate($this->birthdate);
     $employee->save();
     try {
         $this->saveStoreMapping($dbc, $emp_no, $this->form->stores);
     } catch (Exception $e) {
         // likely means HQ is disabled or
         // not stores were selected
     }
     $message = sprintf("Cashier Created<br />Name:%s<br />Emp#:%d<br />Password:%d", $this->fname . ' ' . $this->lname, $emp_no, $passwd);
     return '?flash=' . base64_encode($message);
 }
Ejemplo n.º 2
0
 public function testAddCashier($page, $phpunit)
 {
     $form = new \COREPOS\common\mvc\ValueContainer();
     $form->_method = 'get';
     $page->setForm($form);
     $get = $this->runRESTfulPage($page, $form);
     $phpunit->assertNotEquals(0, strlen($get));
     $form->_method = 'post';
     $form->lname = 'test';
     $form->fname = 'cashier';
     $form->fes = 20;
     $form->birthdate = date('Y-m-d');
     $page->setForm($form);
     $post = $this->runRESTfulPage($page, $form);
     $this->connection->selectDB($this->config->get('OP_DB'));
     $emp = new EmployeesModel($this->connection);
     $emp->FirstName($form->fname);
     $emp->LastName($form->lname);
     $emp->frontendsecurity($form->fes);
     $emp->backendsecurity($form->fes);
     $emp->birthdate($form->birthdate);
     $phpunit->assertNotEquals(0, count($emp->find()));
 }
Ejemplo n.º 3
0
    function body_content()
    {
        global $FANNIE_OP_DB;
        $dbc = FannieDB::get($FANNIE_OP_DB);
        $ret = '';
        if (!empty($this->messages)) {
            $ret .= '<blockquote style="background: solid 1x black; 
                padding: 5px; margin: 5px;">';
            $ret .= $this->messages;
            $ret .= '</blockquote>';
        }
        $emp_no = FormLib::get_form_value('emp_no', 0);
        $employee = new EmployeesModel($dbc);
        $employee->emp_no($emp_no);
        $employee->load();
        ob_start();
        ?>
        <div id="alert-area"></div>
        <form action="<?php 
        echo filter_input(INPUT_SERVER, 'PHP_SELF');
        ?>
" method="post">
        <div class="form-group">
            <label>First Name</label>
            <input type="text" name="fname" value="<?php 
        echo $employee->FirstName();
        ?>
"
                class="form-control" required />
        </div>
        <div class="form-group">
            <label>Last Name</label>
            <input type="text" name="lname" value="<?php 
        echo $employee->LastName();
        ?>
"
                class="form-control" />
        </div>
        <div class="form-group">
            <label>Password</label>
            <input type="text" name="passwd" value="<?php 
        echo $employee->CashierPassword();
        ?>
"
                class="form-control" required />
        </div>
        <div class="form-group">
            <label>Privileges</label>
            <select name="fes" class="form-control">
            <option value="20" <?php 
        echo $employee->frontendsecurity() <= 20 ? 'selected' : '';
        ?>
>Regular</option>
            <option value="30" <?php 
        echo $employee->frontendsecurity() > 20 ? 'selected' : '';
        ?>
>Manager</option>
            </select>
        </div>
        <div class="form-group">
            <label>Active
                <input type="checkbox" name="active" class="checkbox-inline"
                    <?php 
        echo $employee->EmpActive() == 1 ? 'checked' : '';
        ?>
 />
            </label>
        </div>
        <div class="form-group">
            <label>Birthdate</label>
            <input type="text" class="form-control date-field" name="birthdate" 
                id="birth-date-field" value="<?php 
        echo $employee->birthdate();
        ?>
"
                placeholder="Optional; for stores selling age-restricted items" />
        </div>
        <?php 
        if ($this->config->get('STORE_MODE') == 'HQ') {
            echo '<div class="form-group">';
            $stores = new StoresModel($dbc);
            $mapP = $dbc->prepare('SELECT storeID FROM StoreEmployeeMap WHERE storeID=? AND empNo=?');
            foreach ($stores->find('storeID') as $s) {
                $mapR = $dbc->execute($mapP, array($s->storeID(), $emp_no));
                $checked = $mapR && $dbc->numRows($mapR) ? 'checked' : '';
                printf('<label>
                    <input type="checkbox" name="store[]" value="%d" %s />
                    %s
                    </label> | ', $s->storeID(), $checked, $s->description());
            }
            echo '</div>';
        }
        ?>
        <p>
            <button type="submit" class="btn btn-default">Save</button>
            <button type="button" class="btn btn-default"
                onclick="location='ViewCashiersPage.php';return false;">Back</button>
        </p>
        <input type="hidden" name="emp_no" value="<?php 
        echo $emp_no;
        ?>
" />
        </form>
        <?php 
        $this->add_onload_command("\$('input.form-control:first').focus();\n");
        return ob_get_clean();
    }