/** * Add or Remove an order item to/from a server * * * @param integer $orderItemID * @param integer $serverID */ private static function doAddRemove($orderItemID, $serverID, $action = '') { $ret = false; if (is_numeric($orderItemID) && is_numeric($serverID) && ($action == 'add' || $action == 'remove')) { $serverID = intval($serverID); $itemID = intval($orderItemID); if ($action == 'remove') { $record = self::findByServerAndItem($serverID, $itemID); $record->delete(); $ret = true; } else { $order = OrdersItems::find($orderItemID, 'order_id', true); if (!empty($order) && is_array($order) && count($order) > 0) { $order = $order[0]; if (!isset($order['order_id']) || intval($order['order_id']) == 0) { $ret = false; } $orderID = intval($order['order_id']); $OrdersItemsServers = new self(); $OrdersItemsServers->server_id = $serverID; $OrdersItemsServers->order_id = $orderID; $OrdersItemsServers->orderitem_id = $itemID; $OrdersItemsServers->save(); $ret = true; } } // Always update server stats $Server = Servers::find($serverID); $Server->services = OrdersItemsServers::countByServerId($serverID); $Server->save(); return $ret; } return false; }
/** * Response * Create the Order, Invoice and send an email to the customer * @param $response from the Gateway Server * @return order_id or false */ public function Response($response) { $bank = self::getModule(); $bankid = $bank['bank_id']; if (!empty($response['item_number'])) { // Get the indexes of the order $orderid = trim($response['custom']); if (is_numeric($orderid) && is_numeric($bankid)) { // Replacing the comma with the dot in the amount value. $amount = str_replace(",", ".", $response['amount']); $payment = Payments::addpayment($orderid, $response['thx_id'], $bankid, 0, $amount); Orders::set_status($orderid, Statuses::id("paid", "orders")); // Paid OrdersItems::set_statuses($orderid, Statuses::id("paid", "orders")); // Paid return $orderid; } } }
/** * Execute all the registered tasks for the panel */ private function panelTask() { // Get 20 Active tasks items $tasks = PanelsActions::getTasks(Statuses::id("active", "domains_tasks"), Statuses::id('active', 'domains')); try { // Check all the tasks saved within the Panels_Actions table. foreach ($tasks as $task) { self::doPanelsTask($task); // Check if all orderitem of order is complete and if is ok set order to complete $OrderItem = OrdersItems::getDetail($task['orderitem_id']); if (is_numeric($OrderItem['order_id']) && Orders::checkIfOrderItemsAreCompleted($OrderItem['order_id'])) { Shineisp_Commons_Utilities::logs('Order #' . $OrderItem['order_id'] . ' has all items completed. Set order status to complete.', "tasks.log"); Orders::set_status($OrderItem['order_id'], Statuses::id("complete", "orders")); } } } catch (SoapFault $e) { $ISP = Isp::getActiveISP(); Shineisp_Commons_Utilities::SendEmail($ISP['email'], $ISP['email'], null, "Task error panel message", $e->getMessage()); return false; } }
/** * Check if all items of order are completed ***/ public static function checkIfOrderItemsAreCompleted($orderid) { $records = OrdersItems::getAllDetails($orderid, "s.code as statuscode", true); foreach ($records as $record) { if ($record['statuscode'] != Statuses::id('complete', 'orders')) { return false; } } return true; }
/** * Response * Create the Order, Invoice and send an email to the customer * @param $response from the Gateway Server * @return order_id or false */ public function Response($response) { $bank = self::getModule(); $bankid = $bank['bank_id']; if (!empty($response['payment_status']) && $response['payment_status'] == "Completed") { if (!empty($response['item_number'])) { // Get the indexes of the order $orderid = trim($response['custom']); if (is_numeric($orderid) && is_numeric($bankid)) { // Replacing the comma with the dot in the amount value. $amount = str_replace(",", ".", $response['amount']); Shineisp_Commons_Utilities::logs("Adding the payment information: " . $response['thx_id'], "iwbank.log"); $payment = Payments::addpayment($orderid, $response['thx_id'], $bankid, 0, $amount); Shineisp_Commons_Utilities::logs("Set the order in the processing mode", "iwbank.log"); Orders::set_status($orderid, Statuses::id("paid", "orders")); // Paid OrdersItems::set_status($orderid, Statuses::id("paid", "orders")); // Paid return $orderid; } } } return false; }
/** * CREATE THE ORDER FOR ALL THE AUTORENEWABLE DOMAINS/SERVICES * Check all the services [domains, products] and create the orders for each customer only if the service has been set as renewable * @return void */ public static function checkServices() { try { $i = 0; $customers = array(); /* We have to start to get all the domains that them expiring date is today then we have to create a custom array sorted by customerID in order to group services and domains of a specific customer. */ // Get all the active domains that expire in 1 day $domains = Domains::getExpiringDomainsByDays(1, Statuses::id("active", "domains")); if ($domains) { Shineisp_Commons_Utilities::log("There are (" . count($domains) . ") new domains to renew"); // Create the customer group list for the email summary foreach ($domains as $domain) { if (is_numeric($domain['reseller'])) { $invoice_dest = Customers::getAllInfo($domain['reseller']); $customers[$domain['customer_id']]['id'] = $invoice_dest['customer_id']; $customers[$domain['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company']; $customers[$domain['customer_id']]['email'] = $invoice_dest['email']; $customers[$domain['customer_id']]['language_id'] = $invoice_dest['language_id']; } else { $customers[$domain['customer_id']]['id'] = $domain['customer_id']; $customers[$domain['customer_id']]['fullname'] = $domain['fullname']; $customers[$domain['customer_id']]['email'] = $domain['email']; $customers[$domain['customer_id']]['language_id'] = $domain['language_id']; } $customers[$domain['customer_id']]['products'][$i]['name'] = $domain['domain']; $customers[$domain['customer_id']]['products'][$i]['type'] = "domain"; $customers[$domain['customer_id']]['products'][$i]['renew'] = $domain['renew']; $customers[$domain['customer_id']]['products'][$i]['expiring_date'] = $domain['expiringdate']; $customers[$domain['customer_id']]['products'][$i]['days'] = $domain['days']; // Get the last old order item id if (!empty($domain['oldorders'])) { // find the domain foreach ($domain['oldorders'] as $olditemorder) { // Get all the information from the old order $olditem = OrdersItems::getAllInfo($olditemorder['orderitem_id']); // Check if the old order item refers to the domain selected if (!empty($olditem['parameters']) && !empty($olditem['Orders']['OrdersItemsDomains'][0]['Domains']['tld_id'])) { // Get the old configuration parameters $params = json_decode($olditem['parameters'], true); // Zend_Debug::dump($olditem); // Zend_Debug::dump($params); // Zend_Debug::dump($domain['domain']); // Extract the domain name and match it with the domain selected if (!empty($params['domain']) && $params['domain']['name'] == $domain['domain']) { $customers[$domain['customer_id']]['products'][$i]['oldorderitemid'] = $olditemorder['orderitem_id']; } } } } Shineisp_Commons_Utilities::log("- " . $domain['domain']); $i++; } } /* * Now we have to get the services expired and we have to sum the previous $customers array with these * new information. */ // Get all the services active that expire the day after $services = OrdersItems::getExpiringServicesByDays(1, Statuses::id("complete", "orders")); if ($services) { Shineisp_Commons_Utilities::log("There are (" . count($services) . ") new services to renew"); // Create the customer group list for the email summary foreach ($services as $service) { if (is_numeric($service['reseller'])) { $invoice_dest = Customers::getAllInfo($service['reseller']); $customers[$service['customer_id']]['id'] = $invoice_dest['customer_id']; $customers[$service['customer_id']]['fullname'] = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'] . " " . $invoice_dest['company']; $customers[$service['customer_id']]['email'] = $invoice_dest['email']; $customers[$service['customer_id']]['password'] = $invoice_dest['password']; $customers[$service['customer_id']]['language_id'] = $invoice_dest['language_id']; } else { $customers[$service['customer_id']]['id'] = $service['id']; $customers[$service['customer_id']]['fullname'] = $service['fullname']; $customers[$service['customer_id']]['email'] = $service['email']; $customers[$service['customer_id']]['password'] = $service['password']; $customers[$service['customer_id']]['language_id'] = $service['language_id']; } $customers[$service['customer_id']]['products'][$i]['name'] = $service['product']; $customers[$service['customer_id']]['products'][$i]['type'] = "service"; $customers[$service['customer_id']]['products'][$i]['renew'] = $service['renew']; $customers[$service['customer_id']]['products'][$i]['expiring_date'] = $service['expiringdate']; $customers[$service['customer_id']]['products'][$i]['days'] = $service['days']; $customers[$service['customer_id']]['products'][$i]['oldorderitemid'] = $service['detail_id']; Shineisp_Commons_Utilities::log("- " . $service['product']); $i++; } } // Create the email messages for the customers if (count($customers) > 0) { foreach ($customers as $customer) { $items = ""; // **** CREATE THE ORDER FOR ALL THE AUTORENEWABLE DOMAINS/SERVICES *** // ============================================================ // Renew all the services and domain where the customer has choosen the autorenew of the service. $orderID = Orders::renewOrder($customer['id'], $customer['products']); if (is_numeric($orderID)) { $link = Fastlinks::findlinks($orderID, $customer['id'], 'orders'); // Create the fast link to include in the email if (!empty($link[0]['code'])) { $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code']; } else { $url = "http://" . $_SERVER['HTTP_HOST']; } Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'order_renew', array('fullname' => $customer['fullname'], ':shineisp:' => $customer, 'url' => $url), null, null, null, null, $customer['language_id'], Settings::findbyParam('cron_notify')); } } } /* * Now we have to set as expired all the domains records that the date is the date of the expiring of the domain * // Expired */ $dq = Doctrine_Query::create()->update('Domains d')->set('d.status_id', Statuses::id('expired', 'domains'))->where('DATEDIFF(d.expiring_date, CURRENT_DATE) <= ?', 0)->addWhere('DATEDIFF(d.expiring_date, CURRENT_DATE) >= ?', 0); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as closed all the domains records that the date is older of -2 days * // Closed */ $dq = Doctrine_Query::create()->update('Domains d')->set('d.status_id', Statuses::id('suspended', 'domains'))->where('DATEDIFF(d.expiring_date, CURRENT_DATE) <= ?', -2); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as expired all the services records * // Expired */ $dq = Doctrine_Query::create()->update('OrdersItems oi')->set('oi.status_id', Statuses::id('expired', 'orders'))->where('DATEDIFF(oi.date_end, CURRENT_DATE) <= ?', 0); $dq->execute(null, Doctrine::HYDRATE_ARRAY); /* * Now we have to set as deleted all the services records * // Deleted */ $dq = Doctrine_Query::create()->update('OrdersItems oi')->set('oi.status_id', Statuses::id('deleted', 'orders'))->where('DATEDIFF(oi.date_end, CURRENT_DATE) <= ?', -2); $dq->execute(null, Doctrine::HYDRATE_ARRAY); Shineisp_Commons_Utilities::sendEmailTemplate(null, 'cron', array('cronjob' => 'Check Services'), null, null, null, null, null, Settings::findbyParam('cron_notify')); } catch (Exception $e) { Shineisp_Commons_Utilities::logs($e->getMessage(), "cron.log"); return false; } return true; }
/** * 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; }
public function getpriceAction() { $currency = Shineisp_Registry::get('Zend_Currency'); $translator = Shineisp_Registry::get('Zend_Translate'); $id = $this->getRequest()->getParam('id'); $refund = $this->getRequest()->getParam('refund'); $data = array(); if (is_numeric($id)) { $tranche = ProductsTranches::getTranchebyId($id); // JAY 20130409 - Add refund if exist $NS = new Zend_Session_Namespace('Default'); if (is_array($NS->upgrade)) { //Check if the product is OK for upgrade and if OK take refund foreach ($NS->upgrade as $orderid => $upgradeProduct) { if ($orderid != 0) { if (in_array($id, $upgradeProduct)) { $refundInfo = OrdersItems::getRefundInfo($orderid); $refund = $refundInfo['refund']; $idBillingCircle = $tranche['BillingCycle']['billing_cycle_id']; $monthBilling = BillingCycle::getMonthsNumber($idBillingCircle); if ($monthBilling > 0) { $priceToPay = $tranche['price'] * $monthBilling; $priceToPayWithRefund = $priceToPay - $refund; if ($priceToPayWithRefund < 0) { $priceToPayWithRefund = $priceToPay; } $tranche['price'] = round($priceToPayWithRefund / $monthBilling, 2); } else { $priceToPayWithRefund = $tranche['price'] - $refund; if ($priceToPayWithRefund > 0) { $tranche['price'] = $priceToPayWithRefund; } } break; } } } } $includes = ProductsTranchesIncludes::getIncludeForTrancheId($id); $textIncludes = array(); if (array_key_exists('domains', $includes)) { $textIncludes[] = $this->translator->translate('Domains Included') . ": " . implode(", ", $includes['domains']); } $textInclude = ""; if (!empty($textIncludes)) { $textInclude = implode("<br/>", $textIncludes); } // Prepare the data to send to the json $data['price'] = $tranche['price']; if (!empty($tranche['Products']['Taxes']['percentage']) && is_numeric($tranche['Products']['Taxes']['percentage'])) { $data['pricetax'] = $tranche['price'] * ($tranche['Products']['Taxes']['percentage'] + 100) / 100; } else { $data['pricetax'] = $tranche['price']; } $data['pricelbl'] = $currency->toCurrency($tranche['price'], array('currency' => Settings::findbyParam('currency'))); $data['months'] = $tranche['BillingCycle']['months']; $data['pricepermonths'] = $data['pricetax'] * $tranche['BillingCycle']['months']; $data['name'] = $this->translator->translate($tranche['BillingCycle']['name']); $data['pricetax'] = $currency->toCurrency($data['pricetax'], array('currency' => Settings::findbyParam('currency'))); $data['pricepermonths'] = $currency->toCurrency($data['pricepermonths'], array('currency' => Settings::findbyParam('currency'))); $data['setupfee'] = $currency->toCurrency($tranche['setupfee'], array('currency' => Settings::findbyParam('currency'))); $data['includes'] = $textInclude; } die(json_encode($data)); }
/** * Send the email profile to the user */ public function sendMail($task) { $ISP = ISP::getByCustomerId($task['customer_id']); if (!$ISP || !isset($ISP['isp_id']) || !is_numeric($ISP['isp_id'])) { // ISP not found, can't send mail return false; } // Get the service details $service = OrdersItems::getAllInfo($task['orderitem_id']); // If the setup has been written by the task action then ... if (!empty($service['setup'])) { $setup = json_decode($service['setup'], true); // Get the service/product name $productname = !empty($service['Products']['ProductsData'][0]['name']) ? $service['Products']['ProductsData'][0]['name'] : ""; $welcome_mail = !empty($service['Products']['welcome_mail_id']) && intval($service['Products']['welcome_mail_id']) > 0 ? intval($service['Products']['welcome_mail_id']) : 'new_hosting'; // new_hosting = fallback to old method if no template is set // Check if the customer is present in the service and if there is a welcome_mail set for the bought product if (!empty($service['Orders']['Customers'])) { // Getting the customer $customer = $service['Orders']['Customers']; $strSetup = ""; foreach ($setup as $section => $details) { $strSetup .= strtoupper($section) . "<hr/>"; foreach ($details as $label => $detail) { $strSetup .= "{$label}: " . $detail . "<br/>"; } $strSetup .= "<br/>"; } Shineisp_Commons_Utilities::sendEmailTemplate($ISP['email'], $welcome_mail, array('setup' => $strSetup, 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'hostingplan' => $productname, 'controlpanel' => $ISP['website'] . ":8080", 'signature' => $ISP['company']), null, null, null, $ISP, $customer['language_id']); } } }
/** * 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; } }
/** * 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; } }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $i = 0; $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $form = $this->getForm("/admin/services/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/services/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/services/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', 'services', 'admin'); } if ($form->isValid($request->getPost())) { // Get the id $id = $this->getRequest()->getParam('detail_id'); // Set the new values if (is_numeric($id)) { $this->services = Doctrine::getTable('OrdersItems')->find($id); } // Get the values posted $params = $form->getValues(); $datestart = explode(" ", $params['date_start']); try { $months = BillingCycle::getMonthsNumber($params['billing_cycle_id']); if ($months > 0) { $date_end = Shineisp_Commons_Utilities::add_date($datestart[0], null, $months); } else { $date_end = null; } $this->services->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']); $this->services->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end); $this->services->order_id = $params['order_id']; $this->services->product_id = $params['product_id']; $this->services->billing_cycle_id = $params['billing_cycle_id']; $this->services->quantity = $params['quantity']; $this->services->status_id = $params['status_id']; $this->services->setup = $params['setup']; $this->services->note = $params['note']; // Save the data $this->services->save(); $id = is_numeric($id) ? $id : $this->services->getIncremented(); // Set the autorenew OrdersItems::setAutorenew($id, $params['autorenew']); // Save the message note if (!empty($params['message'])) { $message = new Messages(); $message->dateposted = date('Y-m-d H:i:s'); $message->message = $params['message']; $message->isp_id = 1; $message->detail_id = $id; $message->save(); } // Clear the list from the DB Doctrine::getTable('OrdersItemsDomains')->findBy('orderitem_id', $id)->delete(); if ($params['domains_selected']) { $service_domains = new Doctrine_Collection('OrdersItemsDomains'); foreach ($params['domains_selected'] as $domain) { $service_domains[$i]->domain_id = $domain; $service_domains[$i]->order_id = $params['order_id']; $service_domains[$i]->orderitem_id = $id; $i++; } $service_domains->save(); } $this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } catch (Exception $e) { $this->_helper->redirector('edit', 'services', 'admin', array('id' => $id, 'mex' => $this->translator->translate('Unable to process the request at this time.') . ": " . $e->getMessage(), 'status' => 'danger')); } $redirector->gotoUrl("/admin/services/edit/id/{$id}"); } else { $this->view->form = $form; $this->view->title = $this->translator->translate("Service Details"); $this->view->description = $this->translator->translate("Here you can see the details of the service subscribed by the customer."); return $this->render('applicantform'); } }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/orders/process'); $id = $this->getRequest()->getParam('id'); $NS = new Zend_Session_Namespace('Default'); $currency = Shineisp_Registry::getInstance()->Zend_Currency; try { if (!empty($id) && is_numeric($id)) { $fields = "o.order_id, \n\t\t\t\t\t\t\to.order_number as order_number,\n\t\t\t\t\t\t\tDATE_FORMAT(o.order_date, '%d/%m/%Y') as Starting, \n\t\t\t\t\t\t\tDATE_FORMAT(o.expiring_date, '%d/%m/%Y') as Valid_Up, \n\t\t\t\t\t\t\tin.invoice_id as invoice_id, \n\t\t\t\t\t\t\tin.formatted_number as invoice_number, \n\t\t\t\t\t\t\tCONCAT(d.domain, '.', w.tld) as Domain, \n\t\t\t\t\t\t\tc.company as company, \n\t\t\t\t\t\t\to.status_id, \n\t\t\t\t\t\t\ts.status as Status, \n\t\t\t\t\t\t\to.vat as VAT, \n\t\t\t\t\t\t\to.total as Total, \n\t\t\t\t\t\t\to.grandtotal as Grandtotal"; $rs = Orders::getAllInfo($id, $fields, true, $NS->customer['customer_id']); if (!empty($rs)) { // Check the status of the order. // If the order has to be paid we have update it to the last prices and taxes if ($rs[0]['status_id'] == Statuses::id('tobepaid', 'orders')) { // Update the total order Orders::updateTotalsOrder($id); // Reload the data $rs = Orders::getAllInfo($id, $fields, true, $NS->customer['customer_id']); $rs[0]['Total'] = $currency->toCurrency($rs[0]['Total'], array('currency' => Settings::findbyParam('currency'))); $rs[0]['VAT'] = $currency->toCurrency($rs[0]['VAT'], array('currency' => Settings::findbyParam('currency'))); $rs[0]['Grandtotal'] = $currency->toCurrency($rs[0]['Grandtotal'], array('currency' => Settings::findbyParam('currency'))); $this->view->tobepaid = true; // To be Paid status } $records = OrdersItems::getAllDetails($id, "oi.detail_id, \n \t\t\t\t\t oi.description as description, \n \t\t\t\t\t DATE_FORMAT(oi.date_end, '%d/%m/%Y') as expiration_date, \n \t\t\t\t\t oi.quantity as quantity, \n \t\t\t\t\t oi.price as price, \n \t\t\t\t\t CONCAT(oi.discount, '%') as discount, \n \t\t\t\t\t oi.subtotal as subtotal, \n \t\t\t\t\t bc.name as billingcycle, \n \t\t\t\t\t oi.setupfee as setupfee", true); for ($i = 0; $i < count($records); $i++) { $records[$i]['price'] = $currency->toCurrency($records[$i]['price'], array('currency' => Settings::findbyParam('currency'))); $records[$i]['subtotal'] = $currency->toCurrency($records[$i]['subtotal'], array('currency' => Settings::findbyParam('currency'))); $records[$i]['setupfee'] = $currency->toCurrency($records[$i]['setupfee'], array('currency' => Settings::findbyParam('currency'))); } $columns = array(); $columns[] = $this->translator->translate('Description'); $columns[] = $this->translator->translate('Expiry Date'); $columns[] = $this->translator->translate('Qty'); $columns[] = $this->translator->translate('Price'); $columns[] = $this->translator->translate('Discount'); $columns[] = $this->translator->translate('Subtotal'); $columns[] = $this->translator->translate('Billing Cycle'); $columns[] = $this->translator->translate('Setup Fee'); $this->view->customer_id = $NS->customer['customer_id']; $this->view->invoiced = $rs[0]['status_id'] == Statuses::id("complete", "orders") && $rs[0]['invoice_number'] > 0 ? true : false; $this->view->invoice_id = $rs[0]['invoice_id']; $this->view->order = array('records' => $rs); $this->view->details = array('records' => $records, 'columns' => $columns); // Get Order status history $this->view->statushistory = StatusHistory::getStatusList($id); // Show the list of the messages attached to this domain $this->view->messages = Messages::getbyOrderId($id); $this->view->headTitle()->prepend($this->translator->_('Order %s', $rs[0]['order_number'])); $rsfiles = Files::findbyExternalId($id, "orders", "file, Date_Format(date, '%d/%m/%Y') as date, fc.name as categoryname, publickey, download"); if (isset($rsfiles[0])) { $this->view->files = $rsfiles; } // Send the data to the form $form->populate($rs[0]); $this->view->title = $this->translator->_('Order %s', $rs[0]['order_number']); $this->view->orderid = $id; } else { $this->_helper->redirector('index', 'orders', 'default', array('mex' => 'Order not found', 'status' => 'information')); die; } } #$this->view->title = $this->translator->_('Order %s', $formattedID); $this->view->description = "Here you can see all the order information."; $this->view->dnsdatagrid = $this->dnsGrid(); $this->view->form = $form; $this->_helper->viewRenderer('customform'); } catch (Exception $e) { echo $e->getMessage(); die; } }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index'); } // Get our form and validate it $form = $this->getForm('/admin/service/process'); if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; $this->view->title = $this->translator->translate("Service"); $this->view->description = $this->translator->translate("Check all the fields and click on the save button"); return $this->_helper->viewRenderer('customform'); // re-render the login form } // Get the values posted $params = $form->getValues(); // Get the id $id = $this->getRequest()->getParam('detail_id'); if (is_numeric($id)) { OrdersItems::setAutorenew($id, $params['autorenew']); } // Save the message note if (!empty($params['message'])) { Messages::addMessage($params['message'], $this->customer['customer_id'], null, null, $id); $isp = Shineisp_Registry::get('ISP'); $placeholder['fullname'] = $this->customer['firstname'] . " " . $this->customer['lastname']; $placeholder['messagetype'] = $this->translator->translate('Order Details'); $placeholder['message'] = $params['message']; Messages::sendMessage("message_new", $this->customer['email'], $placeholder); Messages::sendMessage("message_admin", $isp->email, $placeholder); } $this->_helper->redirector('edit', 'services', 'default', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success')); }
/** * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/admin/products/process'); $id = $this->getRequest()->getParam('id'); $orders = ""; // 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/products/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/products/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); if (!empty($id) && is_numeric($id)) { $this->session->productid = $id; $rs = $this->products->getAllInfo($id, $this->session->langid); if (!empty($rs)) { // Join the translated data information to populate the form $data = !empty($rs['ProductsData'][0]) ? $rs['ProductsData'][0] : array(); $rs = array_merge($rs, $data); $form = $this->createAttributesElements($form, $rs['group_id']); $this->view->isrecurring = $rs['ProductsAttributesGroups']['isrecurring']; $rs['language_id'] = $this->session->langid; // added to the form the language id selected $rs['related'] = ProductsRelated::getItemsbyProductID($rs['product_id']); //add panel for select upgrade $rs['upgrade'] = ProductsUpgrades::getItemsbyProductID($rs['product_id']); // Get the wiki pages attached to the product selected $rs['wikipages'] = Wikilinks::getWikiPagesList($rs['product_id'], "products", $this->session->langid); $form->populate($rs); $categories = explode("/", $rs['categories']); $this->view->categories = json_encode($this->createCategoryTree(0, $categories)); $this->view->title = !empty($rs['name']) ? $rs['name'] : ""; $this->view->icon = "fa fa-barcode"; $this->view->titlelink = !empty($rs['uri']) ? "/" . $rs['uri'] . ".html" : ""; $media = ProductsMedia::getMediabyProductId($id, "pm.media_id, pm.filename, pm.path"); if (isset($media[0])) { $this->view->media = array('records' => $media, 'delete' => array('controller' => 'products', 'action' => 'delmedia')); } $tranches = ProductsTranches::getTranches($id, "tranche_id, quantity, measurement, setupfee, price, bc.name as billingcycle, selected"); if (isset($tranches[0])) { $onclick = array(); foreach ($tranches as &$tranche) { $trancheid = $tranche['tranche_id']; $include = ProductsTranchesIncludes::getIncludeForTrancheId($trancheid); $textInclude = array(); if (array_key_exists('domains', $include)) { $textInclude[] = "Domains: " . implode(", ", $include['domains']); } $tranche['include'] = implode("<br/>", $textInclude); } $this->view->tranches = array('records' => $tranches, 'actions' => array('/admin/products/setdefaultrance/id/' => 'Set as default'), 'delete' => array('controller' => 'products', 'action' => 'deltranche')); } } $orders = array('records' => OrdersItems::ProductsInOrdersItems($id), 'edit' => array('controller' => 'ordersitems', 'action' => 'edit')); $this->view->buttons[] = array("url" => "/admin/products/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => null)); } $this->view->description = $this->translator->translate("Here you can edit the product details"); $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->orders = $orders; $this->view->isSold = (bool) OrdersItems::CheckIfProductExist($id); $this->view->form = $form; $this->render('applicantform'); }
/** * Create a new client * * Executes the creation of new client in the IspConfig control panel * Note in order to not fail this command, it must meet the following requirements: * * - The customer must be registered in the db. * - The customer has bought a hosting plan * * @param array $task Must be a valid task * @return integer RemoteClientId * @access public */ public function create_client(array $task) { $clientId = ""; if (empty($task)) { throw new Exception('Task empty.', '3000'); } // Execute a custom event $this->events()->trigger('panels_create_client_before', __CLASS__, array('task' => $task)); $server = self::getServer($task['orderitem_id'], 'web'); // Connection to the SOAP system $client = $this->connect($server['server_id']); if (!$client) { throw new Exception("There is no way to connect the client with the IspConfig Panel.", "3010"); } try { // Get all the customer information $customer = Customers::getAllInfo($task['customer_id']); // Get the client id saved previously in the customer information page $customAttribute = CustomAttributes::getAttribute($task['customer_id'], 'client_id'); // Get the custom ISPConfig attribute set in the customer control panel if (is_numeric($customAttribute['value'])) { /** * Client_id (IspConfig Attribute Set in ShineISP database in the setup of the panel) * @see Shineisp_Controller_Plugin_SetupcPanelsModules */ $clientId = $customAttribute['value']; $record = $client->client_get($this->getSession(), $clientId); if ($record == false) { $clientId = ""; } } // Customer Profile $record['company_name'] = $customer['company']; $record['contact_name'] = $customer['firstname'] . " " . $customer['lastname']; $record['customer_no'] = $customer['customer_id']; $record['vat_id'] = $customer['vat']; $record['email'] = $customer['email']; $record['street'] = !empty($customer['Addresses'][0]['address']) ? $customer['Addresses'][0]['address'] : ""; $record['zip'] = !empty($customer['Addresses'][0]['code']) ? $customer['Addresses'][0]['code'] : ""; $record['city'] = !empty($customer['Addresses'][0]['city']) ? $customer['Addresses'][0]['city'] : ""; $record['state'] = !empty($customer['Addresses'][0]['area']) ? $customer['Addresses'][0]['area'] : ""; $record['country'] = !empty($customer['Addresses'][0]['Countries']['code']) ? $customer['Addresses'][0]['Countries']['code'] : ""; $record['mobile'] = Contacts::getContact($customer['customer_id'], "Mobile"); $record['fax'] = Contacts::getContact($customer['customer_id'], "Fax"); $record['telephone'] = Contacts::getContact($customer['customer_id']); // System Configuration $languagecode = Languages::get_code($customer['language_id']); $record['language'] = $languagecode; $record['usertheme'] = "default"; $record['template_master'] = 0; $record['template_additional'] = ""; $record['created_at'] = date(''); $record['web_php_options'] = "no,fast-cgi,cgi,mod,suphp,php-fpm"; $record['ssh_chroot'] = 'jailkit'; // Get the Json encoded parameters in the task $parameters = json_decode($task['parameters'], true); // Match all the ShineISP product system attribute and IspConfig attributes (see below about info) $retval = self::matchFieldsValues($parameters, $record); if (is_array($retval)) { $record = array_merge($record, $retval); } else { Shineisp_Commons_Utilities::logs("No hosting attribute parameters have been set in ShineISP. Check the hosting product attributes section.", "ispconfig.log"); } // Execute the SOAP action if (!empty($clientId) && is_numeric($clientId)) { $client->client_update($this->getSession(), $clientId, 1, $record); } else { $arrUsernames = array(); $arrUsernames = self::generateUsernames($customer); // Check if username is available foreach ($arrUsernames as $username) { if (!$client->client_get_by_username($this->getSession(), $username)) { break; } } // Create a random password string $password = Shineisp_Commons_Utilities::GenerateRandomString(); $record['username'] = $username; $record['password'] = $password; // Save the setup in the service setup field OrdersItems::set_setup($task['orderitem_id'], array('url' => 'http://' . $server['ip'] . ':8080', 'username' => $username, 'password' => $password), "webpanel"); // Adding the client in ISPConfig $clientId = $client->client_add($this->getSession(), 0, $record); // Update the custom customer attribute client_id CustomAttributes::saveElementsValues(array(array('client_id' => $clientId)), $task['customer_id'], "customers"); // Execute a custom event $this->events()->trigger('panels_create_client_after', __CLASS__, array('task' => $task, 'clientid' => $clientId, 'customerdata' => $record)); } // Create the log message Shineisp_Commons_Utilities::logs("ID: " . $task['action_id'] . " - " . __METHOD__ . " - Parameters: " . json_encode($record), "ispconfig.log"); // Logout from the IspConfig Remote System $client->logout($this->getSession()); return $clientId; } catch (Exception $e) { Shineisp_Commons_Utilities::logs(__METHOD__ . ": " . $e->getMessage()); echo $e->getMessage(); } }
/** * Delete a product * * @param integer $id * @return boolean */ public static function del($id) { // Check if the product has been already attached to one or more orders if (0 < OrdersItems::CheckIfProductExist($id)) { // If the product is locked by an order disable it $product = Doctrine::getTable('Products')->find($id); if ($product->isp_id == Isp::getCurrentId()) { $product->enabled = 0; $product->save(); } return false; } // Delete the images of the product selected ProductsMedia::getMediabyProductId($id); // Delete the relationship between the products ProductsRelated::delItemsbyProductID($id); // Delete the product record self::find($id)->delete(); return true; }
public function delete($uuid, $order_uuid = null, $service_uuid) { $this->authenticate(); $customers = Customers::findWithUuid($uuid); if (empty($customers)) { throw new Shineisp_Api_Exceptions(400007, ":: 'uuid' not valid"); exit; } $id = $customers['customer_id']; if ($order_uuid == null && $service_uuid == null) { throw new Shineisp_Api_Exceptions(400007, ":: 'order_uuid' not valid and 'service_uuid' not valid"); } #TODO get order from $order_uuid if ($service_uuid != null) { $objService = OrdersItems::findByUUID($service_uuid); if ($objService == false) { return false; } $service = $objService->toArray(); $orderid = $service['order_id']; Orders::DeleteByID($orderid, $id); } }
/** * Update the Configuration of the Hosting Plan * * * Update the configuration of the service selected * with the new parameters of the service. * * IMPORTANT: * We have to sync the parameters with the Isp Panel selected */ public function updateconfAction() { $id = $this->getRequest()->getParam('id'); if (is_numeric($id)) { // Get the service information $service = OrdersItems::getAllInfo($id, "product_id"); if (!empty($service['product_id'])) { // Get the system parameters/attributes of the service selected $sysattributes = ProductsAttributes::getSysAttributes($service['product_id']); // Update the parameters in the service order detail OrdersItems::updateSysParameters($id, $sysattributes); } $this->_helper->redirector('edit', 'ordersitems', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success')); } else { $this->_helper->redirector('list', 'orders', 'admin', array('mex' => $this->translator->translate('Service item not found.'), 'status' => 'danger')); } }
/** * Create the form module in order to create a record * @return unknown_type */ public function doAction() { $request = $this->getRequest(); $q = $request->getParam('q'); $results = array(); $q = strtolower($q); if (empty($q)) { die(json_encode(array($this->translator->translate('No Records')))); } $cms = CmsPages::getList(); foreach ($cms as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-file', 'section' => $this->translator->translate('Cms'), 'value' => $value, 'url' => "/admin/cmspages/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } $customers = Customers::getList(); if (!empty($customers)) { foreach ($customers as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-user', 'section' => $this->translator->translate('Customer'), 'value' => $value, 'url' => "/admin/customers/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $domains = Domains::getList(); if (!empty($domains)) { foreach ($domains as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-globe', 'section' => $this->translator->translate('Domain'), 'value' => $value, 'url' => "/admin/domains/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $products = Products::getList(); if (!empty($products)) { foreach ($products as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-barcode', 'section' => $this->translator->translate('Product'), 'value' => $value, 'url' => "/admin/products/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $orders = Orders::getList(); if (!empty($orders)) { foreach ($orders as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-briefcase', 'section' => $this->translator->translate('Order'), 'value' => $value, 'url' => "/admin/orders/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $ordersitems = OrdersItems::getItemsListbyDescription($q); if (!empty($ordersitems)) { foreach ($ordersitems as $key => $value) { $results[] = array('icon' => 'glyphicon-briefcase', 'section' => $this->translator->translate('Order Item'), 'value' => $value, 'url' => "/admin/ordersitems/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } $tickets = Tickets::getList(); if (!empty($tickets)) { foreach ($tickets as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-check', 'section' => $this->translator->translate('Ticket'), 'value' => $value, 'url' => "/admin/tickets/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $wiki = Wiki::getList(); if (!empty($wiki)) { foreach ($wiki as $key => $value) { if (strpos(strtolower($value), $q) !== false) { $results[] = array('icon' => 'glyphicon-question-sign', 'section' => $this->translator->translate('Wiki'), 'value' => $value, 'url' => "/admin/wiki/edit/id/{$key}", 'tokens' => explode(' ', $value)); } } } $ticket = TicketsNotes::getItemsNote($q); foreach ($ticket as $key => $value) { $results[] = array('icon' => 'glyphicon-question-sign', 'section' => $this->translator->translate('Ticket Notes'), 'value' => $value, 'url' => "/admin/wiki/tickets/id/{$key}", 'tokens' => explode(' ', $value)); } die(json_encode($results)); }
public function checkIfComplete($uuid) { $this->authenticate(); return OrdersItems::checkIfCompletedByUUID($uuid); }
/** * Response * Create the Order, Invoice and send an email to the customer * @param $response from the Gateway Server * @return order_id or false */ public function Response($response) { $bank = self::getModule(); $bankid = $bank['bank_id']; $url = $bank['test_mode'] ? $bank['url_test'] : $bank['url_official']; list($tid, $ksig) = explode(":", $bank['account']); Shineisp_Commons_Utilities::logs("-----> Callback starts!", "bnl_igfs.log"); $session = new Zend_Session_Namespace('Default'); $IgfsCgVerify = new Shineisp_Banks_BNL_Igfs_CgVerify(); $IgfsCgVerify->disableCheckSSLCert(); $IgfsCgVerify->timeout = 150000; $IgfsCgVerify->paymentID = $session->paymentid; $IgfsCgVerify->kSig = $ksig; $IgfsCgVerify->shopID = self::getOrderID(); $IgfsCgVerify->tid = $tid; $IgfsCgVerify->serverURL = $url; $requestdata = json_encode($IgfsCgVerify, true); Shineisp_Commons_Utilities::logs("---> IgfsCgVerify Request: {$requestdata}", 'bnl_igfs.log'); $result = $IgfsCgVerify->execute(); $responsedata = json_encode($IgfsCgVerify, true); Shineisp_Commons_Utilities::logs("-----> IgfsCgVerify Response: {$responsedata}", 'bnl_igfs.log'); if ($IgfsCgVerify->error) { Shineisp_Commons_Utilities::logs("-----> " . $IgfsCgVerify->rc . ": " . $IgfsCgVerify->error, 'bnl_igfs.log'); return false; } #Zend_Debug::dump($IgfsCgVerify); // Get the orderid back from the bank post variables $orderid = trim($response['custom']); $order = self::getOrder(); $amount = $order['grandtotal']; Shineisp_Commons_Utilities::logs("Adding the payment information: " . $IgfsCgVerify->tranID, "bnl_igfs.log"); $payment = Payments::addpayment($orderid, $IgfsCgVerify->tranID, $bankid, 0, $amount, date('Y-m-d H:i:s'), $order['customer_id'], $IgfsCgVerify->errorDesc); Shineisp_Commons_Utilities::logs("Set the order in the processing mode", "bnl_igfs.log"); Orders::set_status($orderid, Statuses::id("paid", "orders")); // Paid OrdersItems::set_status($orderid, Statuses::id("paid", "orders")); // Paid Shineisp_Commons_Utilities::logs("End callback", "bnl_igfs.log"); return $orderid; }