Beispiel #1
0
 public function post_addfinance()
 {
     $result = '';
     $val_error = [];
     $val = Model_Finance::validate('create');
     $values['usd'] = \Input::post('finance_usd') ? \Input::post('finance_usd') : 0;
     $values['jpy'] = \Input::post('finance_jpy') ? \Input::post('finance_jpy') : 0;
     $values['operationData'] = \Date::forge()->format('mysql');
     $values['memo'] = \Input::post('comment');
     if ($val->run($values)) {
         $finance = \Model_Finance::forge($values);
         $finance->set($values);
         if ($finance->save()) {
             $result = 'Record successfully created';
         } else {
             $val_error[] = 'Could not create new record';
         }
     } else {
         foreach ($val->error() as $error) {
             $val_error[] = $error->get_message();
         }
     }
     $this->response(['result' => $result, 'error' => implode('<br>', (array) $val_error)]);
 }