/** * * Create the action */ public function doAction() { $id = $this->getRequest()->getParam('id'); $execute = $this->getRequest()->getParam('execute'); if (is_numeric($id) && !empty($execute)) { // Get the service information $service = OrdersItems::getAllInfo($id, "o.customer_id, oi.parameters"); $parameters = $service['parameters']; $customer_id = $service['Orders']['customer_id']; PanelsActions::Addtask($customer_id, $id, $execute, $parameters); $this->_helper->redirector('edit', 'ordersitems', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success')); } $this->_helper->redirector('list', 'orders', 'admin', array('mex' => $this->translator->translate('Service item not found.'), 'status' => 'danger')); }
/** * activate * Activate an order item * @param $orderItemId * @return true|false */ public static function activate($orderItemId) { Shineisp_Commons_Utilities::log(__METHOD__ . " - Activate Detail ID #" . $orderItemId); $orderItemId = intval($orderItemId); if ($orderItemId < 1) { // missing order item id from arguments return false; } // Get OrderItem $ordersItem = self::find($orderItemId); $ordersItem = $ordersItem->toArray(); $OrderItem = array_shift($ordersItem); if (!$OrderItem) { // order item not found return false; } // Get customerId related to this order $customerId = Orders::getCustomer($OrderItem['order_id']); /* * START ACTIVATIONS CODE */ $upgrade = Orders::isUpgrade($OrderItem['order_id']); $upgrade_uuid = false; if ($upgrade !== false) { $orderItem = OrdersItems::getDetail($upgrade); Shineisp_Commons_Utilities::logs(__METHOD__ . " - OITEM::" . print_r($orderItem, true)); $oldOrderId = $orderItem['order_id']; Orders::set_status($oldOrderId, Statuses::id("changed", "orders")); // Close the old order ::status changed OrdersItems::set_status($upgrade, Statuses::id("changed", "orders")); $upgrade_uuid = $orderItem['uuid']; // log Shineisp_Commons_Utilities::logs(__METHOD__ . " - Order changed from #" . $oldOrderId . " to #" . $OrderItem['order_id']); } if (empty($OrderItem['parameters'])) { Shineisp_Commons_Utilities::logs(__METHOD__ . " - Order items setup parameters empty"); return false; } // Is this an hosting? execute panel task // TODO: this should call an hook or an even bound to the panel if (isset($OrderItem['Products']) && isset($OrderItem['Products']['type']) && $OrderItem['Products']['type'] == 'hosting') { Shineisp_Commons_Utilities::logs(__METHOD__ . " Hosting task queued"); PanelsActions::AddTask($customerId, $OrderItem['detail_id'], "fullProfile", $OrderItem['parameters']); return true; } // Is this a domain? execute domain task if (isset($OrderItem['tld_id']) && intval($OrderItem['tld_id']) > 0) { $parameters = json_decode($OrderItem['parameters']); if (empty($parameters->domain)) { Shineisp_Commons_Utilities::logs(__METHOD__ . " Domain has been not set in the order detail #{$orderItemId}"); return false; } // Create the domain record $domain = Domains::Create($parameters->domain, intval($OrderItem['tld_id']), intval($customerId), $orderItemId); // Create the domain task if (!empty($parameters->domain) && !empty($parameters->action)) { $domains[] = array('domain' => $parameters->domain, 'action' => $parameters->action); $retval = DomainsTasks::AddTasks($domains); Shineisp_Commons_Utilities::logs(__METHOD__ . " Domain task queued"); } return $retval; } }
/** * Create the tasks for hosting plans * @param integer $orderid */ private static function CreateHostingTasks($orderid) { if (empty($orderid) || !is_numeric($orderid)) { return false; } $hostingplans = self::get_hostingplans_from_order($orderid); if ($hostingplans) { foreach ($hostingplans as $data) { PanelsActions::AddTask($data['customer_id'], $data['orderitem_id'], "fullProfile", $data['parameters']); } } }
/** * Create a new widget for the dashboard */ public function widgetsAction() { $auth = Zend_Auth::getInstance(); $translator = Shineisp_Registry::getInstance()->Zend_Translate; $auth->setStorage(new Zend_Auth_Storage_Session('admin')); $id = $this->getRequest()->getParam('id', 'widget_' . rand()); $icon = $this->getRequest()->getParam('icon', 'fa fa-file'); $type = $this->getRequest()->getParam('type'); $title = $this->getRequest()->getParam('title'); $buttons = array(); if (!empty($id)) { $widget = new Shineisp_Commons_Widgets(); $widget->setId($id); // Ajax load of the widgets // Get only the new orders if ($type == "new_order_widget") { $records = Orders::Last(array(Statuses::id("tobepaid", "orders"))); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // Get all the pending, processing, and paid orders to be complete } elseif ($type == 'processing_order_widget') { $statuses = array(Statuses::id("processing", "orders"), Statuses::id("pending", "orders"), Statuses::id("paid", "orders")); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $records = Orders::Last($statuses); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // Get all the services / order items next to the expiration date from -10 days to 30 days } elseif ($type == 'recurring_services_widget') { $records = OrdersItems::getServices(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/ordersitems/edit/id/%d")); $widget->setBasepath('/admin/ordersitems/')->setIdxfield($records['index'])->setButtons($buttons); // Get the last 5 tickets opened by the customers } elseif ($type == 'last_tickets_widget') { $records = Tickets::Last(null, 5); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/tickets/edit/id/%d")); $widget->setBasepath('/admin/tickets/')->setIdxfield($records['index'])->setButtons($buttons); // get the last domain tasks to be executed } elseif ($type == 'last_domain_tasks_widget') { $records = DomainsTasks::Last(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domainstasks/edit/id/%d")); $widget->setBasepath('/admin/domainstasks/')->setIdxfield($records['index'])->setButtons($buttons); // get the last ISP panel tasks to be executed } elseif ($type == 'last_panel_tasks_widget') { $records = PanelsActions::Last(); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/panelsactions/edit/id/%d")); $widget->setBasepath('/admin/panelsactions/')->setIdxfield($records['index'])->setButtons($buttons); // get the domains next the expiration date } elseif ($type == 'expiring_domain_widget') { // Create the header table columns $records['fields'] = array('expiringdate' => array('label' => $translator->translate('Expiry Date')), 'domains' => array('label' => $translator->translate('Domain')), 'days' => array('label' => $translator->translate('Days left'))); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domains/edit/id/%d")); $records['data'] = Domains::getExpiringDomains(null, 107, -1, 5); $records['index'] = "domain_id"; $widget->setBasepath('/admin/domains/')->setIdxfield($records['index'])->setButtons($buttons); // get the messages/notes posted by the customers within the orders } elseif ($type == 'order_messages_widget') { $records = Messages::Last('orders'); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/orders/edit/id/%d")); $widget->setBasepath('/admin/orders/')->setIdxfield($records['index'])->setButtons($buttons); // get the messages/notes posted by the customers within the domain } elseif ($type == 'domain_messages_widget') { $records = Messages::Last('domains'); $buttons = array('edit' => array('label' => $translator->translate('Edit'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/domains/edit/id/%d")); $widget->setBasepath('/admin/domains/')->setIdxfield($records['index'])->setButtons($buttons); // get the list of your best customers } elseif ($type == 'customers_parade_widget') { $buttons = array('edit' => array('label' => $translator->translate('Show'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/customers/edit/id/%d")); $records = Customers::Hitparade(); $widget->setBasepath('/admin/customers/')->setIdxfield($records['index'])->setButtons($buttons); // get the customer status summary } elseif ($type == 'customer_summary_widget') { $records = Customers::summary(); // get the tickets summary } elseif ($type == 'ticket_summary_widget') { $records = Tickets::summary(); // get the domains summary } elseif ($type == 'summary_domains_widget') { $records = Domains::summary(); // get the product reviews stats } elseif ($type == 'product_reviews_widget') { $records = Reviews::summary(); // get the bestseller product stats } elseif ($type == 'bestseller_widget') { $buttons = array('edit' => array('label' => $translator->translate('Show'), 'cssicon' => 'glyphicon glyphicon-pencil', 'action' => "/admin/products/edit/id/%d")); $records = Products::summary(); $widget->setBasepath('/admin/products/')->setIdxfield($records['index'])->setButtons($buttons); // get the last ISP notes } elseif ($type == 'notes_widget') { $user = $auth->getIdentity(); $records = Notes::summary($user['user_id']); $widget->setBasepath('/admin/notes/'); } else { die('No widget type has been selected: ' . $type); } // Records Builtin columns. The code get the field names as header column name if (!empty($records['fields'])) { foreach ($records['fields'] as $field => $column) { $column['alias'] = !empty($column['alias']) ? $column['alias'] : $field; $widget->setColumn($field, $column); } } if (!empty($records['data'])) { $widget->setIcon($icon)->setLabel($title)->setRecords($records['data']); die($widget->create()); } } die; }
private function doDomainTask($task) { if (!isset($task['Domains']) || !isset($task['Domains']['Customers']) || !isset($task['Domains']['Customers']['customer_id'])) { PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate('customer_id not found')); } $customer_id = intval($task['Domains']['Customers']['customer_id']); $ISP = Isp::getByCustomerId($customer_id); if (!$ISP || !isset($ISP['isp_id']) || !is_numeric($ISP['isp_id'])) { PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate('isp_id not found')); return false; } try { // Getting domains details $domain = Domains::find($task['domain_id'], null, true); if (!empty($domain[0])) { $domain_name = $domain[0]['domain'] . "." . $domain[0]['tld']; // Get the associated registrar for the domain selected $registrar = Registrars::getRegistrarId($task['registrars_id']); if (!empty($registrar['class'])) { // Create the class registrar object $class = $registrar['class']; $regclass = new $class(); $action = $task['action']; // Check if the task is REGISTER or TRANSFER the domain name if ($action == "registerDomain") { $regclass->registerDomain($task['domain_id']); // Set the DNS ZONES DomainsTasks::AddTask($domain_name, "setDomainHosts"); // Update the domain information DomainsTasks::AddTask($domain_name, "updateDomain"); } elseif ($action == "transferDomain") { $regclass->transferDomain($task['domain_id']); } elseif ($action == "renewDomain") { $regclass->renewDomain($task['domain_id']); // Update the domain information DomainsTasks::AddTask($domain_name, "updateDomain"); } elseif ($action == "lockDomain") { $regclass->lockDomain($task['domain_id']); } elseif ($action == "unlockDomain") { $regclass->unlockDomain($task['domain_id']); // Update the domain information DomainsTasks::AddTask($domain_name, "updateDomain"); } elseif ($action == "setNameServers") { $regclass->setNameServers($task['domain_id']); } elseif ($action == "setDomainHosts") { $regclass->setDomainHosts($task['domain_id']); } else { $regclass->{$action}($task['domain_id']); } // Update the log description of the task DomainsTasks::UpdateTaskLog($task['task_id'], $this->translations->translate("Your request has been executed.")); // Update the status of the task DomainsTasks::UpdateTaskStatus($task['task_id'], Statuses::id('complete', 'domains_tasks')); // Set the task as "Complete" // Increment the task counter number DomainsTasks::UpdateTaskCounter($task['task_id']); // Set the status as Active Domains::setStatus($task['domain_id'], Statuses::id('active', 'domains_tasks')); } } } catch (Exception $e) { DomainsTasks::UpdateTaskLog($task['task_id'], $this->translations->translate($e->getMessage())); Shineisp_Commons_Utilities::SendEmail($ISP['email'], $ISP['email'], null, "Task error message: " . $task['Domains']['domain'] . "." . $task['Domains']['tld'], $e->getMessage()); Shineisp_Commons_Utilities::logs("Task error message: " . $task['Domains']['domain'] . "." . $task['Domains']['tld'] . ":" . $e->getMessage(), "tasks.log"); } return true; }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/panelsactions/process"); $request = $this->getRequest(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/panelsactions/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/panelsactions/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('list', 'panelsactions', 'admin'); } if ($form->isValid($request->getPost())) { $params = $form->getValues(); // Get the id $id = PanelsActions::saveData($params, $params['action_id']); if (is_numeric($id)) { $this->_helper->redirector('edit', 'panelsactions', 'admin', array('id' => $id, 'mex' => $this->translator->translate("The task requested has been executed successfully."), 'status' => 'success')); } else { $redirector->gotoUrl("/admin/panelsactions/list/"); } } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Panel action edit"); $this->view->description = $this->translator->translate("Here you can edit the panel actions."); return $this->render('applicantform'); } }
/** * add a task to be done by the cron job */ public static function Addtask($customer_id, $orderitem_id, $action, $parameters = "") { $panel = Panels::getActivePanel(); if (!empty($panel)) { $task = new PanelsActions(); $task->panel_id = $panel['panel_id']; $task->start = date('Y-m-d H:i:s'); $task->customer_id = $customer_id; $task->orderitem_id = $orderitem_id; $task->action = $action; $task->parameters = $parameters; $task->status_id = Statuses::id("active", "domains_tasks"); // Task Processing; return $task->trySave(); } else { return false; } }