diff --git a/src/com_tjvendors/admin/controllers/vendorfee.php b/src/com_tjvendors/admin/controllers/vendorfee.php index b02167cf..b5db8978 100644 --- a/src/com_tjvendors/admin/controllers/vendorfee.php +++ b/src/com_tjvendors/admin/controllers/vendorfee.php @@ -11,6 +11,7 @@ // No direct access defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\Router\Route; use Joomla\Registry\Registry; @@ -106,4 +107,108 @@ public function edit($key = null, $urlVar = null) ); $this->setRedirect($link); } + + /** + * Save vendor fee data + * + * @param integer $key key. + * + * @param integer $urlVar url + * + * @return string The arguments to append to the redirect URL. + * + * @since __DEPLOY_VERSION__ + */ + public function save($key = null, $urlVar = null) + { + // Initialise variables. + $app = Factory::getApplication(); + $model = $this->getModel('Vendorfee', 'TjvendorsModel'); + $input = $app->input; + $client = $input->get('client', '', 'STRING'); + $vendorId = $input->get('vendor_id'); + + // Get the user data. + $data = Factory::getApplication()->input->get('jform', array(), 'array'); + + // Validate the posted data. + $form = $model->getForm(); + + if (!$form) + { + JError::raiseError(500, $model->getError()); + + return false; + } + + // Validate the posted data. + $validate = $model->validate($form, $data); + + // Check for errors. + if ($validate === false) + { + // Get the validation messages. + $errors = $model->getErrors(); + + // Push up to three validation messages out to the user. + for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) + { + if ($errors[$i] instanceof Exception) + { + $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); + } + else + { + $app->enqueueMessage($errors[$i], 'warning'); + } + } + + // Redirect back to the edit screen. + $id = (int) $app->getUserState('com_tjvendors.edit.vendorfee.id'); + $app->setUserState('com_tjvendors.edit.vendorfee.data', $data); + + $this->setRedirect(Route::_('index.php?option=com_tjvendors&view=vendorfee&layout=edit&id='. $id . '&vendor_id='. $vendorId . '&client=' . $client, false)); + + return false; + } + + $return = $model->save($data); + + // Check for errors. + if ($return === false) + { + $app->setUserState('com_tjvendors.edit.vendorfee.data', $data); + + // Redirect back to the edit screen. + $id = (int) $app->getUserState('com_tjvendors.edit.vendorfee.id'); + $this->setMessage(Text::sprintf('COM_TJVENDORS_VENDOR_ERROR_MSG_SAVE', $model->getError()), 'warning'); + $this->setRedirect(Route::_('index.php?option=com_tjvendors&view=vendorfee&layout=edit&id=' . $id . '&vendor_id=' . $vendorId .'&client=' . $client, false)); + + return false; + } + + $msg = Text::_('COM_TJVENDORS_VENDORFEE_SAVE_SUCCESS'); + $id = $input->get('id'); + + if (empty($id)) + { + $id = $return; + } + + $task = $input->get('task'); + + if ($task == 'apply') + { + $redirect = Route::_('index.php?option=com_tjvendors&view=vendorfee&layout=edit&id=' . $id . '&vendor_id=' . $vendorId . '&client=' . $client, false); + $app->redirect($redirect, $msg); + } + + // Clear the profile id from the session. + $app->setUserState('com_tjvendors.edit.vendorfee.id', null); + $redirect = Route::_('index.php?option=com_tjvendors&view=vendorfees&vendor_id=' . $vendorId . '&client=' . $client, false); + $app->redirect($redirect, $msg); + + // Flush the data from the session. + $app->setUserState('com_tjvendors.edit.vendorfee.data', null); + } } diff --git a/src/com_tjvendors/admin/models/payout.php b/src/com_tjvendors/admin/models/payout.php index d3e4dcdd..a64ddc15 100644 --- a/src/com_tjvendors/admin/models/payout.php +++ b/src/com_tjvendors/admin/models/payout.php @@ -230,9 +230,6 @@ public function save($data) // Update their details in the users table using id as the primary key. $result = Factory::getDbo()->updateObject('#__tjvendors_passbook', $payout_update, 'id'); - $message = Text::_('COM_TJVENDORS_PAYOUT_SUCCESSFULL_MESSAGE'); - Factory::getApplication()->enqueueMessage($message); - return true; } diff --git a/src/com_tjvendors/admin_language/en-GB/en-GB.com_tjvendors.ini b/src/com_tjvendors/admin_language/en-GB/en-GB.com_tjvendors.ini index 4a5d8382..0f1d571b 100755 --- a/src/com_tjvendors/admin_language/en-GB/en-GB.com_tjvendors.ini +++ b/src/com_tjvendors/admin_language/en-GB/en-GB.com_tjvendors.ini @@ -18,7 +18,6 @@ COM_TJVENDORS_N_ITEMS_TRASHED_1="%d vendor successfully trashed" COM_TJVENDORS_N_ITEMS_UNPUBLISHED="%d vendors successfully unpublished" COM_TJVENDORS_N_ITEMS_UNPUBLISHED_1="%d vendor successfully unpublished" COM_TJVENDORS_NO_ITEM_SELECTED="No vendors selected" -COM_TJVENDORS_SAVE_SUCCESS="Vendor fee successfully saved" COM_TJVENDORS_ITEM_ID_SELECT_LABEL="Select the item ID" COM_TJVENDORS_ITEM_ID_SELECT_LABEL_FORM="Select the Item ID to Edit (Set up as 0 if you want to set up as add form)" COM_TJVENDORS_FIELDSET_ITEM_ID_SELECT_LABEL="Required Settings" @@ -273,3 +272,7 @@ JGLOBAL_MAXIMUM_UPLOAD_SIZE_LIMIT="" ; Since v1.4.1 COM_TJVENDORS_VENDORS_VENDOR_UNAPPROVED="Pending" + +; Since v1.4.2 +COM_TJVENDORS_SAVE_SUCCESS="Payment successfully Done." +COM_TJVENDORS_VENDORFEE_SAVE_SUCCESS="Vendor fee successfully saved"