/** * ServicesExpiration * List of all the services near the expiring date * @return array */ public function Last() { $ns = new Zend_Session_Namespace(); if (!empty($ns->customer)) { $data = $ns->customer; return array('records' => Tickets::Last($data['customer_id']), 'actions' => array('/tickets/edit/id/' => 'Show')); } else { return null; } }
/** * 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; }
/** * showAction * Create the reports page */ public function showAction() { $request = $this->getRequest(); $datatype = $request->getParam('type'); $param = $request->getParam('q'); $autorenew = 1; $links = ""; switch ($datatype) { case 'profitofyear': if (is_numeric($param)) { $links = $this->translator->_("Click one of these links to show the economic reports"); $years = Invoices::getYears(); foreach ($years as $year) { $links .= " <a href='/admin/reports/show/type/profitofyear/q/{$year}'>{$year}</a>"; } $this->view->title = $this->translator->_("Estimated Revenue for %s", $param); if (!empty($years)) { $this->view->description = $this->translator->_("Below is the economic summary of the %s.", $param) . " " . $links; } else { $this->view->description = $this->translator->_("Below is the economic summary of the %s.", $param); } $this->view->year = $param; $graph = new Shineisp_Commons_Morris(); // Get the total of the revenues per year $graphdata = $graph->setType('Area')->setData(Orders::prepareGraphData(array($param), 'month', false))->setElement('graph')->setXkey('xdata')->setLabels(array($this->translator->translate('Net Revenue (Taxable Income less Costs)')))->setOptions(array('lineColors' => array('#428BCA'), 'preUnits' => Settings::findbyParam('currency') . " "))->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); Invoices::getSummaryGrid($this->_helper, $param); PurchaseInvoices::getSummaryGrid($this->_helper, $param); } else { $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'profitofyear', 'q' => date('Y'))); } break; case 'productsummary': $years = Invoices::getYears(); foreach ($years as $year) { $links .= " <a href='/admin/reports/show/type/productsummary/q/{$year}'>{$year}</a>"; } if (!empty($years)) { $this->view->description = $this->translator->_("In this list you can see the summary of the products sold. %s", $param) . " <br/> " . $links . " <a href='/admin/reports/show/type/productsummary/'>" . $this->translator->translate('Show All') . "</a> "; } else { $this->view->description = $this->translator->_("In this list you can see the summary of the products sold. %s", $param); } $this->view->title = $this->translator->translate("Products summary"); $this->view->data = array('records' => Products::getBestseller($param)); break; case 'tldsummarypermonth': $this->view->title = $this->translator->translate("Domain TLD monthly summary"); $this->view->description = $this->translator->translate("In this list you can see the summary of the TLD per month."); $graph = new Shineisp_Commons_Morris(); $data = Domains::prepareGraphDataperMonth(); if (!empty($data)) { // Get the total of the revenues per year $graphdata = $graph->setType('Bar')->setData($data)->setElement('graph')->setXkey('xdata')->setLabels(array_keys($data['tld']))->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); } $this->view->data = array('records' => Domains::getSummaryPerMonth()); break; case 'domainstats': $this->view->title = $this->translator->translate("Domain stats"); $this->view->description = $this->translator->translate("This list shows all the costs and earnings of the domains sold grouped by tld."); $graph = new Shineisp_Commons_Morris(); // Get the tlds domains per type $graphdata = $graph->setType('Donut')->setData(Domains::prepareGraphData())->setElement('graph')->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); $this->view->data = array('records' => Domains::getSummary()); break; case 'tldsummaryowner': $this->view->title = $this->translator->translate("Summary per client"); $this->view->description = $this->translator->translate("By this list you can see the summary of the domains bought per client."); $this->view->data = array('records' => Domains::domains_per_customers(), 'pager' => true); break; case 'domainstasks': $this->view->title = $this->translator->translate("List of all domain tasks (last 100 records)"); $this->view->description = $this->translator->translate("By this list you can know all the tasks for each created domain."); $this->view->graph = ""; $this->view->data = array('records' => DomainsTasks::GetTask(100), 'delete' => array('controller' => 'reports', 'action' => 'deletetask'), 'pager' => true); break; case 'servicesummary': // get all the recurring products and services as default $groups = ProductsAttributesGroups::getList(null, true); if (!empty($groups)) { $groups = array_keys($groups); } $groups = array('3', '9'); $fields = "detail_id,\n\t\t\t\t\t\t\to.order_id as orderid,\n\t\t\t\t\t\t\tc.customer_id as customer_id, \n\t\t\t\t\t\t\toid.relationship_id as relationship_id,\n\t\t\t\t\t\t\tDATE_FORMAT(oi.date_end, '%d/%m/%Y') as expiringdate,\n\t\t\t\t\t\t\td.autorenew as autorenew,\n\t\t\t\t\t\t\tCONCAT(c.firstname, ' ', c.lastname, ' ', c.company) as customer,\n\t\t\t\t\t\t\toi.description as description,\n\t\t\t\t\t\t\tCONCAT(d.domain, '.', d.tld) as domain, \n\t\t\t\t\t\t\toi.cost as cost, \n\t\t\t\t\t\t\toi.price as price"; $this->view->title = $this->translator->translate("List of the recurring services"); $this->view->description = $this->translator->translate("By this list you can see the summary of the services bought per client."); $this->view->graph = ""; $this->view->data = array('records' => OrdersItems::getAllRecurringServices($fields, $groups), 'pager' => true); break; case 'ticketsummary': $this->view->title = $this->translator->translate("Ticket summary"); $this->view->description = $this->translator->translate("List of the last help requests."); $this->view->graph = ""; $this->view->data = array('records' => Tickets::Last(), 'actions' => array('/admin/tickets/edit/id/' => 'show'), 'pager' => true); break; case 'domainsexpiration': $this->view->title = $this->translator->translate("Expiration list of domains"); $this->view->description = $this->translator->translate("This view helps you to check which are the domains next to expiration."); $this->view->graph = ""; $this->view->data = array('records' => Domains::getExpiringDomains(), 'actions' => array('/admin/domains/edit/id/' => 'show'), 'pager' => true); break; case 'servicesexpiration': $this->view->title = $this->translator->translate("Expiration list of services"); $this->view->description = $this->translator->translate("This view helps you to check which are the services next to expiration."); $this->view->graph = ""; $this->view->data = array('records' => Products::getExpiringProducts(), 'actions' => array('/admin/services/edit/id/' => 'show'), 'pager' => true); break; default: $this->_helper->redirector('show', 'reports', 'admin', array('type' => 'profitofyear', 'q' => date('Y'))); break; } }