public function Alerts() { $registry = Shineisp_Registry::getInstance(); $currency = Shineisp_Registry::getInstance()->Zend_Currency; $translation = $registry->Zend_Translate; $alerts = array(); $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $NS = new Zend_Session_Namespace('Default'); if (!empty($NS->customer)) { $data = $NS->customer; $orders = Orders::find_all_not_paid_ordersbyCustomerID($data['customer_id']); $tasks_errors = DomainsTasks::GetIncompleteTask($data['customer_id']); if (count($tasks_errors) > 0) { foreach ($tasks_errors as $task) { if (!empty($task['log'])) { $alerts[] = array('message' => $task['domain'] . " - " . $translation->_($task['log']), $task['domain_id'], 'link' => '/domains/edit/id/' . $task['domain_id'], 'icon' => 'danger'); } } } if (count($orders) > 0) { foreach ($orders as $order) { $order['grandtotal'] = $currency->toCurrency($order['grandtotal'], array('currency' => Settings::findbyParam('currency'))); if (!empty($order['invoice_id'])) { $alerts[] = array('message' => $translation->_('The invoice %s of %s (%s) has been not payed yet, click here to show more details.', $order['Invoices']['number'], Shineisp_Commons_Utilities::formatDateOut($order['order_date']), $order['grandtotal']), 'link' => '/orders/edit/id/' . $order['order_id'], 'icon' => 'danger'); } else { $alerts[] = array('message' => $translation->_('The order %s that you have requested the %s with total %s has not been paid yet, click here for more information.', $order['order_number'], Shineisp_Commons_Utilities::formatDateOut($order['order_date']), $order['grandtotal']), 'link' => '/orders/edit/id/' . $order['order_id'], 'icon' => 'danger'); } } } $this->view->alerts = $alerts; // Path of the template return $this->view->render('partials/alerts.phtml'); } }
/** * 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 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 static function CreateDomainTasks($OrderID) { // Check if the order contains domains if (is_numeric($OrderID)) { $domains = self::getDomainsFromOrder($OrderID); if (count($domains) > 0) { // Create the new domains for ($i = 0; $i < count($domains); $i++) { $domains[$i]['domain_id'] = Domains::Create($domains[$i]['domain'], $domains[$i]['tld_id'], $domains[$i]['customer_id'], $domains[$i]['orderitem_id']); } // Add the tasks in order to register or transfer them $retval = DomainsTasks::AddTasks($domains); if ($retval === true) { return true; } else { return $retval; } } } }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/domainstasks/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/domainstasks/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/domainstasks/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', 'domainstasks', 'admin'); } if ($form->isValid($request->getPost())) { $params = $form->getValues(); // Get the id $id = DomainsTasks::saveData($params, $params['task_id']); if (is_numeric($id)) { $this->_helper->redirector('edit', 'domainstasks', 'admin', array('id' => $id, 'mex' => $this->translator->translate("The task requested has been executed successfully."), 'status' => 'success')); } else { $redirector->gotoUrl("/admin/domainstasks/list/"); } } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Domain task"); $this->view->description = $this->translator->translate("Here you can edit the domain task information."); return $this->render('applicantform'); } }
public static function AddTask($domain, $action) { $task = new DomainsTasks(); $task->startdate = date('Y-m-d H:i:s'); $task->action = $action; $task->domain_id = Domains::getDomainIDbyName($domain); $task->registrars_id = Registrars::findRegistrarIDbyDomain($domain); $task->status_id = Statuses::id('active', 'domains_tasks'); //Domains Task Status; return $task->trySave(); }
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; }
/** * Bulk registrar task request * @param array $items Items selected * @param array $parameters Custom parameters */ public function bulk_registrar_tasks($items, $parameters) { $errors = array(); if (!empty($parameters['task'])) { $domains = self::get_domains($items, "d.domain_id, CONCAT(d.domain, '.', ws.tld) as name, d.registrars_id as registrar", "d.domain"); foreach ($domains as $domain) { if (!empty($domain['name'])) { if (!empty($domain['registrar'])) { DomainsTasks::AddTask($domain['name'], $parameters['task']); } else { $errors[] = "Registrar service not set for: " . $domain['name']; } } } } if (count($errors) > 0) { die(json_encode(array('mex' => implode("<br/>", $errors)))); } return true; }
/** * Register * Execute a Register task */ public function registerAction() { $domainID = $this->getRequest()->getParam('id'); $action = $this->getRequest()->getParam('do'); // Check if the request comes from the owner of the domain if (!Domains::isOwner($domainID, $this->customer['customer_id'])) { $this->_helper->redirector('list', 'domains', 'default', array('mex' => 'A problem has been occurred during the request.', 'status' => 'danger')); } // Get the domain name $domain = Domains::getDomainName($domainID); if (empty($domain)) { $this->_helper->redirector('list', 'domains', 'default', array('mex' => 'A problem has been occurred during the request.', 'status' => 'danger')); } switch ($action) { case 'lockDomain': DomainsTasks::AddTask($domain, 'lockDomain'); break; case 'unlockDomain': DomainsTasks::AddTask($domain, 'unlockDomain'); break; case 'updateDomain': DomainsTasks::AddTask($domain, 'updateDomain'); break; default: $this->_helper->redirector('list', 'domains', 'default', array('mex' => 'A problem has been occurred during the request.', 'status' => 'danger')); break; } $this->_helper->redirector('edit', 'domains', 'default', array('id' => $domainID, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success')); }
/** * addtask [Ajax call] * Add a Task for the domain selected * @return json array */ public function addtaskAction() { // Check if it is an ajax request if ($this->_request->isXmlHttpRequest()) { // Get the parameters $domain_id = $this->getRequest()->getParam('id'); $method = $this->getRequest()->getParam('method'); // Check the parameters if (is_numeric($domain_id) && !empty($method)) { $record = $this->domains->find($domain_id, "d.domain as domain, ws.tld as tld, d.authinfocode, d.customer_id as customer_id, cdr.value as nichandle", true); if (is_array($record[0])) { $domain = $record[0]['domain'] . "." . $record[0]['tld']; $domain_id = $record[0]['domain_id']; $retval = DomainsTasks::AddTask($domain, $method, $domain_id); if ($retval) { die(json_encode(array('result' => 1))); } else { die(json_encode(array('result' => 0))); } } } } die(json_encode(array('result' => 0))); }
/** * deletetaskAction * delete a task action * @return null */ public function deletetaskAction() { $id = $this->getRequest()->getParam('id'); if (is_numeric($id)) { DomainsTasks::DeleteTask($id); } $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'domainstasks', 'mex' => 'Domain task has been deleted.', 'status' => 'success')); $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'domainstasks', 'mex' => 'Domain task has not been deleted.', 'status' => 'danger')); }