Example #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);
 }
Example #2
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $emp_no = FormLib::get_form_value('emp_no', 0);
     if (FormLib::get_form_value('fname') !== '') {
         $fname = FormLib::get_form_value('fname');
         $lname = FormLib::get_form_value('lname');
         $passwd = FormLib::get_form_value('passwd');
         $fes = FormLib::get_form_value('fes');
         $active = FormLib::get_form_value('active') !== '' ? 1 : 0;
         $dob = FormLib::get_form_value('birthdate');
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $employee = new EmployeesModel($dbc);
         $employee->emp_no($emp_no);
         $employee->FirstName($fname);
         $employee->LastName($lname);
         $employee->CashierPassword($passwd);
         $employee->AdminPassword($passwd);
         $employee->frontendsecurity($fes);
         $employee->backendsecurity($fes);
         $employee->EmpActive($active);
         $employee->birthdate($dob);
         $saved = $employee->save();
         $map = new StoreEmployeeMapModel($dbc);
         $map->empNo($emp_no);
         $stores = FormLib::get('store', array());
         foreach ($stores as $s) {
             $map->storeID($s);
             $map->save();
         }
         $map->reset();
         $map->empNo($emp_no);
         foreach ($map->find() as $obj) {
             if (!in_array($obj->storeID(), $stores)) {
                 $obj->delete();
             }
         }
         if ($saved) {
             $message = "Cashier Updated. <a href=ViewCashiersPage.php>Back to List of Cashiers</a>";
             $this->add_onload_command("showBootstrapAlert('#alert-area', 'success', '{$message}');\n");
         } else {
             $this->add_onload_command("showBootstrapAlert('#alert-area', 'danger', 'Error saving cashier');\n");
         }
     }
     return true;
 }
Example #3
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()));
 }