/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { if (Valid::email($form->object->email, TRUE)) { //check we have this email in the DB $user = new Model_User(); $user = $user->where('email', '=', Kohana::$_POST_ORIG['formorm']['email'])->where('id_user', '!=', $this->request->param('id'))->limit(1)->find(); if ($user->loaded()) { Alert::set(Alert::ERROR, __('A user with the email you specified already exists')); } else { $form->save_object(); Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } } else { Alert::set(Alert::ERROR, __('Invalid Email')); } } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/user/update', array('form' => $form)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); // fields array foreach ($form->fields as $field_key => $field) { $fields[$field_key] = array('name' => $field['field_name'], 'value' => $field['value'], 'id' => $field['field_id'], 'label' => $field['label']); } if ($this->request->post()) { if ($success = $form->submit()) { $form->object->description = Kohana::$_POST_ORIG['formorm']['description']; $form->save_object(); Alert::set(Alert::SUCCESS, __('Blog post updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/blog/update', array('form' => $fields)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { $form->save_object(); Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1">' . __('Delete All') . '</a>'); $this->request->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/crud/update', array('form' => $form)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { $form->save_object(); //if fraud or refunded....disable licenses!! AND commissions if ($form->object->status == Model_Order::STATUS_FRAUD or $form->object->status == Model_Order::STATUS_REFUND) { foreach ($form->object->licenses->find_all() as $l) { $l->status = Model_License::STATUS_NOACTIVE; $l->save(); } //change affiliate commision if ($form->object->affiliate->loaded()) { $form->object->affiliate->status = $form->object->status; $form->object->affiliate->save(); } } Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1">' . __('Delete All') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } $licenses = new Model_License(); $licenses = $licenses->where('id_order', '=', $this->request->param('id'))->find_all(); return $this->render('oc-panel/pages/order/update', array('form' => $form, 'licenses' => $licenses)); }