Jump to content

Ability To Terminate Account Via Module Without Cancelling Service


Recommended Posts

+1

 

This is easy, only needs a new TAB on Admin Module called for exemple "Commands" and add all commands to manually execute like:

 

Terminate

Create

Suspend

Unsuspend

etc..

 

Yes, a more generic "command" capability completely detached from Blesta (simply passing commands straight to the module) would be ideal.

Link to comment
Share on other sites

We are going to improve the staff service management page, likely breaking it up into additional tabs as the default "Basic Options" tab has too much going on with it from features added since 3.0. An "Advanced" tab or similar may be beneficial for these kinds of actions, and possibly some other options not currently available.

Link to comment
Share on other sites

We are going to improve the staff service management page, likely breaking it up into additional tabs as the default "Basic Options" tab has too much going on with it from features added since 3.0. An "Advanced" tab or similar may be beneficial for these kinds of actions, and possibly some other options not currently available.

 

I wouldn't necessarily go that far, all I need is the ability to run the basic module commands in the basic options tab without messing with blesta data.

 

You have abstract methods for all of this on the Module class. A simple passthrough without the extra logic in the service layer would do the trick. No actual new code, I would think.

 

Strip the extra logic out of the Services model class and it's done. For example termination would just be (roughly) line 1470-1487 of the Services class, plus validation and logging (both already there).

Link to comment
Share on other sites

Termination would go something like this. COMPLETELY UNTESTED. DO NOT TRY AT HOME.


./app/models/services.php - add this method 
+	/**
+	 * Terminates a service.
+	 *
+	 * @param int $service_id The ID of the service to terminate.
+	 */
+	public function terminate($service_id, array $vars = array()) {
+	
+		extract($this->getRelations($service_id));
+		
+		// Terminate the service.
+		
+		if (!isset($this->ModuleManager))
+			Loader::loadModels($this, array("ModuleManager"));
+		
+		$module_data = $this->getModuleClassByPricingId($service->pricing_id);
+		
+		if ($module_data) {
+			$module = $this->ModuleManager->initModule($module_data->id, Configure::get("Blesta.company_id"));
+		
+			if ($module) {
+				// Set the module row used for this service
+				$module->setModuleRow($module->getModuleRow($service->module_row_id));
+				
+				$service_info = $module->cancelService($package, $service, $parent_package, $parent_service);
+				
+				if (($errors = $module->errors())) {
+					$this->Input->setErrors($errors);
+					return;
+				}
+				
+			}
+			
+		}				
+		
+	}

Replace in getActions method:

 	public function getActions($current_status = null) {
 		
 		$actions = array(
+			'terminate' => $this->_("Services.getActions.terminate"),
 			'suspend' => $this->_("Services.getActions.suspend"),
 			'unsuspend' => $this->_("Services.getActions.unsuspend"),
 			'cancel' => $this->_("Services.getActions.cancel"),

./app/controllers/admin_clients.php

 				switch ($this->post['section']) {
 					case "action":
 						switch ($this->post['action']) {
+							case "terminate":
+								$this->Services->terminate($service->id, $this->post);
+								break;
 							case "suspend":
 								$this->Services->suspend($service->id, $this->post);
 								break;

./clients/language/en_us/services.php

+$lang['Services.getActions.terminate'] = "Terminate";
 $lang['Services.getActions.suspend'] = "Suspend";
 $lang['Services.getActions.unsuspend'] = "Unsuspend";
 $lang['Services.getActions.cancel'] = "Cancel";

Link to comment
Share on other sites

  • 2 months later...

I have amended https://dev.blesta.com/browse/CORE-1808 which allows the re-provision of services through the module. This task now mentions the possibility of a new tab for performing the 4 types of module actions (create, cancel, suspend, unsuspend). The new tab seems to be more inclusive by supporting all of the standard module actions. Requires some more discussion internally, but this task may be updated/changed to fully support that idea.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...