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); }
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> </th><th> </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; }
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(); }