public function indexAction() { $userInfo = $this->permissions->getUserInformation(); if (!$userInfo) { Uri_helper::redirect("users"); } $commerce = new \modules\commerce\models\Commerce_shares('frontend_add'); $commerce->attributes = $this->Input->input['post']; $commerce->user_id = $userInfo->user_id; if ($commerce->save()) { Uri_helper::redirect("commerce_sharing"); } else { return $this->render('commerce_manage_sharing', ['item' => $commerce->get()]); } }
public function manageAction($id = false) { $this->permission('manage'); if ($id) { $commerce = new \modules\commerce\models\Commerce_shares('edit'); } else { $commerce = new \modules\commerce\models\Commerce_shares('add'); } $commerce->attributes = $this->Input->input['post']; if ($id) { $commerce->commerce_shares_id = $id; } $commerce->language_id = $this->language->getDefaultLanguage(); $user = Form_helper::queryToDropdown('users', 'user_id', 'fullname'); if ($commerce->save()) { Uri_helper::redirect("management/commerce_shares"); } else { return $this->render('commerce_shares/manage', ['item' => $id ? $commerce->get() : null, 'user' => $user]); } }