public function customers() { $registry = Shineisp_Registry::getInstance(); $translator = $registry->Zend_Translate; $this->view->customers = Customers::getList($translator->translate('Select the customer ...'), array(array('where' => 'u.status_id = ?', 'params' => Statuses::id('active', 'customers')))); return $this->view->render('partials/customers.phtml'); }
public function init() { $NS = new Zend_Session_Namespace('Default'); $translate = Shineisp_Registry::get('Zend_Translate'); // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElement('select', 'domain_id', array('decorators' => array('Bootstrap'), 'required' => false, 'label' => $translate->_('Domain'), 'description' => $translate->_('Choose the domain name reference'), 'class' => 'form-control large-input')); $this->getElement('domain_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList(true, $NS->customer['customer_id'])); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'title' => $translate->_('Write here a subject of the issue.'), 'label' => $translate->_('Subject'), 'description' => $translate->_('Write here the domain name or a simple description of the problem.'), 'class' => 'form-control large-input')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Body Message'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here all the information.'), 'rows' => '8', 'class' => 'form-control wysiwyg-simple')); $this->addElement('select', 'status', array('filters' => array('StringTrim'), 'label' => $translate->_('Set the issue status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input', 'multioptions' => array('' => '', Statuses::id("solved", "tickets") => $translate->_('Solved'), Statuses::id("closed", "tickets") => $translate->_('Closed')))); $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'description' => 'Select a category.', 'class' => 'form-control large-input')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList(true)); if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('useruploadlimit'); $Types = Settings::findbyParam('useruploadfiletypes'); if (empty($MBlimit)) { $MBlimit = 1; } if (empty($Types)) { $Types = "zip,jpg"; } $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)))); $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } else { $this->addElement('hidden', 'attachments'); } $this->addElement('submit', 'submit', array('label' => $translate->_('Send help request'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary btn-lg')); $this->addElement('hidden', 'ticket_id'); }
/** * 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; } } }
/** * login * Check if the customer exist * @param $email * @param $password * @return boolean */ public static function login($email, $password) { try { $isMD5 = false; $dbUser = Doctrine_Query::create()->from('Customers u')->where('email = ? AND status_id = ?', array($email, Statuses::id('active', 'customers')))->andWhere("u.isp_id = ?", Isp::getCurrentId())->limit(1)->fetchArray(); if ($dbUser && isset($dbUser[0])) { $dbUser = $dbUser[0]; $dbPass = $dbUser['password']; if (strlen($dbPass) > 32 && substr($dbPass, 0, 1) == '$') { $userPassword = crypt($password, $dbPass); } else { $isMD5 = true; $userPassword = md5($password); } if ($userPassword == $dbPass) { //* if password was crypted in plain MD5, force convertion to crypt if ($isMD5) { $cryptPassword = crypt($password); Doctrine_Query::create()->update('Customers u')->set('u.password', '?', $cryptPassword)->where('email = ?', $email)->limit(1)->execute(); } // Auth OK return $dbUser; } } return array(); } catch (Exception $e) { echo $e->getMessage(); die; } }
/** * getSummaryPerMonth * Get the summary of the tld registered per month * @return Array */ public static function getSummaryPerMonth($customer_id = null) { $dq = Doctrine_Query::create()->select("domain_id, Count(*) as total, Month(expiring_date) as month_number, Monthname(expiring_date) as month")->from('Domains d')->leftJoin('d.Customers c')->where('expiring_date is not null')->addWhere("c.isp_id = ?", Isp::getCurrentId())->andWhere('status_id = ?', Statuses::id("active", "domains"))->addGroupBy('MonthName(expiring_date)')->orderBy('Month(expiring_date)'); if (is_numeric($customer_id)) { $dq->andWhere('d.customer_id = ?', $customer_id); } $domains = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); return $domains; }
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; }
/** * 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; }
/** * 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; } }
/** * 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; }
public function create($params) { $this->authenticate(); $uuid = $params['uuid']; $customers = Customers::find($uuid); if (empty($customers)) { throw new Shineisp_Api_Exceptions(400006, ":: 'uuid' not valid"); exit; } $trancheid = intval($params['trancheid']); $tranche = ProductsTranches::getTranchebyId($trancheid); if (empty($tranche)) { throw new Shineisp_Api_Exceptions(400006, ":: 'trancheid' not valid"); exit; } #Check Products if (empty($params['products']) && !is_array($params['products'])) { throw new Shineisp_Api_Exceptions(400006, ":: not 'products' choose"); exit; } foreach ($params['products'] as $product) { $productid = intval($product['productid']); $billingid = intval($product['billingid']); $ttry = ProductsTranches::getTranchesBy_ProductId_BillingId($productid, $billingid); if (empty($ttry)) { throw new Shineisp_Api_Exceptions(400006, ":: 'productid' or 'bilingid' not valid"); exit; } $ttry = array_shift($ttry); if ($ttry['tranche_id'] != $trancheid) { throw new Shineisp_Api_Exceptions(400006, ":: 'bilingid' not valid"); exit; } } $id = $customers['customer_id']; $isVATFree = Customers::isVATFree($id); if ($params['status'] == "complete") { $status = Statuses::id('complete', 'orders'); } else { $status = Statuses::id('tobepaid', 'orders'); } $theOrder = Orders::create($customers['customer_id'], $status, $params['note']); foreach ($params['products'] as $product) { $productid = intval($product['productid']); $billingid = intval($product['billingid']); $quantity = intval($product['quantity']); $p = Products::getAllInfo($productid); Orders::addItem($productid, $quantity, $billingid, $trancheid, $p['ProductsData'][0]['name'], array()); } $orderID = $theOrder['order_id']; if ($params['sendemail'] == 1) { Orders::sendOrder($orderID); } $banks = Banks::find($params['payment'], "*", true); if (!empty($banks[0]['classname'])) { $class = $banks[0]['classname']; if (class_exists($class)) { // Get the payment form object $banks = Banks::findbyClassname($class); $gateway = new $class($orderID); $gateway->setFormHidden(true); $gateway->setRedirect(true); $gateway->setUrlOk($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($banks['classname'])); $gateway->setUrlKo($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($banks['classname'])); $gateway->setUrlCallback($_SERVER['HTTP_HOST'] . "/common/callback/gateway/" . md5($banks['classname'])); return $gateway->CreateForm(); } } throw new Shineisp_Api_Exceptions(400006, ":: bad request"); exit; }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $this->getHelper('layout')->setLayout('1column'); $form = $this->getForm('/tickets/process'); $id = $this->getRequest()->getParam('id'); if (!empty($id) && is_numeric($id)) { $isp = Shineisp_Registry::get('ISP'); $fields = "DATE_FORMAT(t.date_open, '%d/%m/%Y %H:%i:%s') as creationdate, t.sibling_id, DATE_FORMAT(t.date_close, '%d/%m/%Y %H:%i:%s') as expiringdate, \n\t\t\tt.subject, t.description, t.status_id as status_id, t.vote as vote, s.status as status, c.email as email, CONCAT(c.firstname, ' ', c.lastname) as customer, c.company as company, (DATEDIFF(t.date_close, t.date_open)) as days"; $rs = $this->tickets->getAllInfo($id, $fields, true); if (!empty($rs[0])) { if (!empty($rs[0]['sibling_id'])) { $rs[0]['sibling'] = Tickets::getAllInfo($rs[0]['sibling_id'], $fields, true); } $this->view->headTitle()->prepend($rs[0]['customer']); $this->view->headTitle()->prepend($rs[0]['subject']); $form->populate($rs[0]); $this->view->record = $rs[0]; $this->view->isp = $isp; $this->view->adminavatar = Shineisp_Commons_Gravatar::get_gravatar($isp->email, 80); $this->view->customeravatar = Shineisp_Commons_Gravatar::get_gravatar($rs[0]['email'], 80); $this->view->notes = Tickets::Notes($id, "note_id, admin as adminreply, vote as vote, DATE_FORMAT(date_post, '%d/%m/%Y %H:%i:%s') as date_post,CONCAT(c.firstname, ' ', c.lastname) as customer, c.company as company, note", true); $this->view->summary = $rs[0]; $status = $rs[0]['status_id']; if ($status == Statuses::id('closed', 'tickets') || $status == Statuses::id('solved', 'tickets')) { $this->view->canreply = false; } else { $this->view->canreply = true; } $this->view->name = $rs[0]['subject']; } $this->view->id = $id; $this->view->title = $this->translator->translate('Ticket'); $this->getHelper('layout')->setLayout('2columns-right'); $this->view->placeholder("right")->append($this->view->partial('partials/wikisidebar.phtml', array('items' => Wiki::get_items(5)))); } $this->view->title = $this->translator->translate("Ticket"); $this->view->description = $this->translator->translate("Here you can write down your problem. Remember to be clear and analytic in order to explain the problem that has been occurred."); $this->view->dnsdatagrid = $this->dnsGrid(); $this->view->form = $form; $this->_helper->viewRenderer('customform'); }
/** * print the invoice * @param unknown_type $invoiceid */ public static function PrintPDF($invoice_id, $show = true, $force = false, $path = "/documents/invoices/") { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $pdf = new Shineisp_Commons_PdfOrder(); if (!is_numeric($invoice_id)) { return false; } $invoice = Invoices::find($invoice_id); if (!$invoice) { return false; } $invoice = $invoice->toArray(); // Set the basepath for the file $Order = Doctrine::getTable('Orders')->findOneBy('order_id', $invoice['order_id']); $invoicePath = $path . $Order->isp_id . '/' . str_replace('-', '/', $invoice['invoice_id']); // Set the name of the file $filename = $invoicePath . '/' . $invoice['invoice_id'] . ".pdf"; $filenameOld = $path . $invoice['invoice_date'] . " - " . $invoice['number'] . ".pdf"; // Invoice already exists, we return it if ((file_exists(PUBLIC_PATH . $filename) || file_exists(PUBLIC_PATH . $filenameOld)) && $show && !$force) { $outputFilename = !empty($invoice['formatted_number']) ? $invoice['formatted_number'] . ".pdf" : $invoice['invoice_date'] . "_" . $invoice['number'] . ".pdf"; header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="' . $outputFilename . '"'); $invoice = file_exists(PUBLIC_PATH . $filename) ? file_get_contents(PUBLIC_PATH . $filename) : file_get_contents(PUBLIC_PATH . $filenameOld); die($invoice); } $translator = Shineisp_Registry::getInstance()->Zend_Translate; $payments = Payments::findbyorderid($invoice['order_id'], null, true); $order = Orders::getAllInfo($invoice['order_id'], null, true); $database['header']['label'] = $translator->translate('Invoice No.') . " " . (!empty($invoice['formatted_number']) ? $invoice['formatted_number'] : $database['records']['invoice_number']) . " - " . Shineisp_Commons_Utilities::formatDateOut($invoice['invoice_date']); $database['columns'][] = array("value" => $translator->translate("SKU"), "size" => 20, "align" => "left", "key" => "sku"); $database['columns'][] = array("value" => $translator->translate("Description"), "size" => 65, "align" => "left", "key" => "description"); $database['columns'][] = array("value" => $translator->translate("Qty"), "size" => 2, "align" => "right", "key" => "qty"); $database['columns'][] = array("value" => $translator->translate("Unit"), "size" => 12, "align" => "left", "key" => "unit"); $database['columns'][] = array("value" => $translator->translate("Tax Free Price"), "size" => 9, "align" => "right", "key" => "taxfreeprice"); $database['columns'][] = array("value" => $translator->translate("Discount"), "size" => 10, "align" => "right", "key" => "discount"); $database['columns'][] = array("value" => $translator->translate("Setup fee"), "size" => 15, "align" => "right", "key" => "setup"); $database['columns'][] = array("value" => $translator->translate("Total"), "size" => 18, "align" => "right", "key" => "total"); if (isset($order[0])) { $orderinfo['order_number'] = !empty($order[0]['order_number']) ? $order[0]['order_number'] : Orders::formatOrderId($order[0]['order_id']); $orderinfo['invoice_id'] = $invoice['number']; $orderinfo['date'] = Shineisp_Commons_Utilities::formatDateOut($invoice['invoice_date']); //if customer comes from reseller if ($order[0]['Customers']['parent_id']) { $invoice_dest = Customers::getAllInfo($order[0]['Customers']['parent_id'], 'c.*, a.*'); $orderinfo['customer']['customer_id'] = $invoice_dest['customer_id']; $orderinfo['customer']['company'] = $invoice_dest['company']; $orderinfo['customer']['firstname'] = $invoice_dest['firstname']; $orderinfo['customer']['lastname'] = $invoice_dest['lastname']; $orderinfo['customer']['vat'] = $invoice_dest['vat']; $orderinfo['customer']['taxpayernumber'] = $invoice_dest['taxpayernumber']; $orderinfo['customer']['email'] = $invoice_dest['email']; if (isset($invoice_dest['Addresses'][0])) { $orderinfo['customer']['address'] = $invoice_dest['Addresses'][0]['address']; $orderinfo['customer']['city'] = $invoice_dest['Addresses'][0]['city']; $orderinfo['customer']['code'] = $invoice_dest['Addresses'][0]['code']; $orderinfo['customer']['country'] = !empty($invoice_dest['Addresses'][0]['Countries']['name']) ? $invoice_dest['Addresses'][0]['Countries']['name'] : ""; } } else { $orderinfo['customer']['customer_id'] = $order[0]['Customers']['customer_id']; $orderinfo['customer']['company'] = $order[0]['Customers']['company']; $orderinfo['customer']['firstname'] = $order[0]['Customers']['firstname']; $orderinfo['customer']['lastname'] = $order[0]['Customers']['lastname']; $orderinfo['customer']['vat'] = $order[0]['Customers']['vat']; $orderinfo['customer']['taxpayernumber'] = $order[0]['Customers']['taxpayernumber']; $orderinfo['customer']['email'] = $order[0]['Customers']['email']; if (isset($order[0]['Customers']['Addresses'][0])) { $orderinfo['customer']['address'] = $order[0]['Customers']['Addresses'][0]['address']; $orderinfo['customer']['city'] = $order[0]['Customers']['Addresses'][0]['city']; $orderinfo['customer']['code'] = $order[0]['Customers']['Addresses'][0]['code']; $orderinfo['customer']['country'] = $order[0]['Customers']['Addresses'][0]['Countries']['name']; } } $orderinfo['payments'] = array(); if (count($payments) > 0) { if ($payments > 1) { $numPayment = 1; foreach ($payments as $payment) { if ($numPayment++ > 10) { break; } $payment['paymentdate'] = Shineisp_Commons_Utilities::formatDateOut($payment['paymentdate']); $payment['income'] = $currency->toCurrency($payment['income'], array('currency' => Settings::findbyParam('currency'))); $orderinfo['payments'][] = $payment; } } $orderinfo['payment_date'] = Shineisp_Commons_Utilities::formatDateOut($payments[0]['paymentdate']); $orderinfo['payment_mode'] = $payments[0]['Banks']['name']; $orderinfo['payment_description'] = $payments[0]['description']; $orderinfo['payment_transaction_id'] = $payments[0]['reference']; } $orderinfo['invoice_number'] = $invoice['number']; $orderinfo['company']['name'] = $order[0]['Isp']['company']; $orderinfo['company']['manager'] = $order[0]['Isp']['manager']; $orderinfo['company']['vat'] = $order[0]['Isp']['vatnumber']; $orderinfo['company']['bankname'] = $order[0]['Isp']['bankname']; $orderinfo['company']['iban'] = $order[0]['Isp']['iban']; $orderinfo['company']['bic'] = $order[0]['Isp']['bic']; $orderinfo['company']['address'] = $order[0]['Isp']['address']; $orderinfo['company']['zip'] = $order[0]['Isp']['zip']; $orderinfo['company']['city'] = $order[0]['Isp']['city']; $orderinfo['company']['country'] = $order[0]['Isp']['country']; $orderinfo['company']['telephone'] = $order[0]['Isp']['telephone']; $orderinfo['company']['fax'] = $order[0]['Isp']['fax']; $orderinfo['company']['website'] = $order[0]['Isp']['website']; $orderinfo['company']['email'] = $order[0]['Isp']['email']; $orderinfo['company']['slogan'] = $order[0]['Isp']['slogan']; $orderinfo['company']['custom1'] = $order[0]['Isp']['custom1']; $orderinfo['company']['custom2'] = $order[0]['Isp']['custom2']; $orderinfo['company']['custom3'] = $order[0]['Isp']['custom3']; $orderinfo['subtotal'] = $currency->toCurrency($order[0]['total'], array('currency' => Settings::findbyParam('currency'))); $orderinfo['grandtotal'] = $currency->toCurrency($order[0]['grandtotal'], array('currency' => Settings::findbyParam('currency'))); $orderinfo['vat'] = $currency->toCurrency($order[0]['vat'], array('currency' => Settings::findbyParam('currency'))); $orderinfo['delivery'] = 0; if ($order[0]['status_id'] == Statuses::id("tobepaid", "orders")) { // To be payed $orderinfo['ribbon']['text'] = $translator->translate("To be Paid"); $orderinfo['ribbon']['color'] = "#D60000"; } elseif ($order[0]['status_id'] == Statuses::id("paid", "orders")) { // Paid $orderinfo['ribbon']['text'] = $translator->translate("Paid"); $orderinfo['ribbon']['color'] = "#009926"; } elseif ($order[0]['status_id'] == Statuses::id("complete", "orders")) { // Complete $orderinfo['ribbon']['text'] = $translator->translate("Complete"); $orderinfo['ribbon']['color'] = "#009926"; } else { $orderinfo['ribbon']['text'] = $translator->translate(Statuses::getLabel($order[0]['status_id'])); $orderinfo['ribbon']['color'] = "#FFCC33"; } $database['records'] = $orderinfo; foreach ($order[0]['OrdersItems'] as $item) { $billingCycle = BillingCycle::getAllinfo($item['billing_cycle_id']); if (!empty($billingCycle)) { if (!empty($billingCycle['months']) && empty($item['tld_id'])) { $price = $item['price'] * $billingCycle['months'] + $item['setupfee']; } else { $price = $item['price'] + $item['setupfee']; } } else { $price = $item['price'] * $item['quantity'] + $item['setupfee']; } $rowtotal = $price + $item['vat']; $item['price'] = $currency->toCurrency($item['price'], array('currency' => Settings::findbyParam('currency'))); $item['setupfee'] = $currency->toCurrency($item['setupfee'], array('currency' => Settings::findbyParam('currency'))); $rowtotal = $currency->toCurrency($rowtotal, array('currency' => Settings::findbyParam('currency'))); if (!empty($item['discount'])) { $item['discount'] = $item['discount'] . "%"; } if (!empty($billingCycle['name']) && empty($item['tld_id'])) { $item['date_end'] = Shineisp_Commons_Utilities::formatDateOut($item['date_end']); $billingCycleName = $billingCycle['name']; $item['description'] .= "<br/><br/> - " . $translator->translate('Expiring date') . ": " . $item['date_end']; } else { $billingCycleName = "-"; } // var_dump($item); $database['records']['items'][] = array($item['Products']['sku'], $item['description'], $item['quantity'], $billingCycleName, $item['price'], $item['discount'], $item['setupfee'], $rowtotal); } // var_dump($database['records']); // die; // Sanitize some fields $database['records']['invoice_number'] = !empty($database['records']['invoice_number']) ? $database['records']['invoice_number'] : ""; $database['records']['formatted_number'] = !empty($invoice['formatted_number']) ? $invoice['formatted_number'] : $database['records']['invoice_number']; $database['records']['payment_description'] = !empty($database['records']['payment_description']) ? $database['records']['payment_description'] : ""; $database['records']['payment_mode'] = !empty($database['records']['payment_mode']) ? $database['records']['payment_mode'] : ""; $database['records']['payment_date'] = !empty($database['records']['payment_date']) ? $database['records']['payment_date'] : ""; $database['records']['totalPayments'] = count($database['records']['payments']); // QRCode Image $code['order'] = $database['records']['order_number']; $code['customer'] = $database['records']['customer']['customer_id']; $jcode = base64_encode(json_encode($code)); $database['records']['qrcode_url'] = $_SERVER['HTTP_HOST'] . "/index/qrcode/q/" . $jcode; $database['records']['skip_barcode'] = 1; if (!empty($database['records']['invoice_number'])) { $database['records']['barcode'] = $database['records']['invoice_number']; $database['records']['skip_barcode'] = 0; } if (isset($order[0])) { // Create the path structure if (!is_dir(PUBLIC_PATH . $invoicePath)) { mkdir(PUBLIC_PATH . $invoicePath, 0700, true); } // Template name $templateName = Settings::findByParam('invoice_template'); if (empty($templateName)) { $templateName = Shineisp_Commons_Utilities::getFirstFile(PUBLIC_PATH . '/skins/commons/invoices', '/\\.phtml$/'); } $invoiceview = new Shineisp_Invoice(); $invoiceview->assign('header', $database['header']); $invoiceview->assign('columns', $database['columns']); $invoiceview->assign('data', $database['records']); $html = $invoiceview->render($templateName); $html2pdf = new HTML2PDF('P', 'A4', 'it', true, 'UTF-8', array(4, 4, 4, 1)); $html2pdf->WriteHTML($html); $html2pdf->Output(PUBLIC_PATH . $filename, "F"); // Execute a custom event self::events()->trigger('invoices_pdf_created', "Invoices", array('order' => $order, 'invoice' => $invoice, 'file' => $filename)); return PUBLIC_PATH . $filename; } } return false; }
/** * runActivate * run activation procedure if payment is confirmed and order is fully paid */ public static function runActivate($orderid) { Shineisp_Commons_Utilities::logs(__METHOD__ . ": payment confirmed."); // Let's check if we have the whole invoice paid. $isPaid = Orders::isPaid($orderid); // Check to see if order is totally paid. // This will generate invoice or, if an invoice is still present, it will overwrite it (proforma to invoice conversion) if ($isPaid) { Shineisp_Commons_Utilities::logs(__METHOD__ . ": isPaid ok, payment has been completed 100%"); // Set order status as "Paid" Orders::set_status($orderid, Statuses::id('paid', 'orders')); Shineisp_Commons_Utilities::logs(__METHOD__ . ": subscribed services activation starts "); // If we have to autosetup as soon as first payment is received, let's do here. Orders::activateItems($orderid, 4); // If automatic invoice creation is set to 1, we have to create the invoice $autoCreateInvoice = intval(Settings::findbyParam('auto_create_invoice_after_payment')); $invoiceId = intval(Orders::isInvoiced($orderid)); if (!$invoiceId) { // order not invoiced? Shineisp_Commons_Utilities::logs(__METHOD__ . ": order not invoiced."); if ($autoCreateInvoice === 1) { Shineisp_Commons_Utilities::logs(__METHOD__ . ": start order invoicing process."); // invoice not created yet. Let's create now Invoices::Create($orderid); } } else { Shineisp_Commons_Utilities::logs(__METHOD__ . ": invoice already created overwrite of the old invoice"); // set invoice as paid Invoices::overwrite($invoiceId); } } else { Shineisp_Commons_Utilities::logs(__METHOD__ . ": isPaid KO, payment not completed"); Shineisp_Commons_Utilities::logs(__METHOD__ . ": check if one or more services have been activated when a first payment is received"); // If we have to autosetup as soon as first payment is received, let's do here. Orders::activateItems($orderid, 3); } }
/** * 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/domains/process'); if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; $this->view->title = $this->translator->translate("Domain process task"); $this->view->description = $this->translator->translate("Here you have to fix the domain parameters set."); return $this->render('applicantform'); // re-render the login form } // Get the values posted $params = $form->getValues(); // Get the id $id = $this->getRequest()->getParam('domain_id'); // 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/domains/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/domains/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); try { $id = Domains::saveAll($id, $params); Domains::saveDnsZones($id, $params); Domains::setAutorenew($id, $params['autorenew'] == 0 ? false : true); DomainsNichandle::setNicHandles($id, $params['owner'], $params['admin'], $params['tech'], $params['billing']); // If the domain status has been set as active // the registrar task record will be set as completed if ($params['status_id'] == Statuses::id("active", 'domains')) { DomainsTasks::setStatusTask($id, Statuses::id("complete", 'domains_tasks')); // Complete } // 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->domain_id = $id; $message->save(); } $this->_helper->redirector('edit', 'domains', 'admin', array('id' => $id, 'mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } catch (Exception $e) { $this->_helper->redirector('list', 'domains', 'admin', array('mex' => $e->getMessage(), 'status' => 'danger')); } }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/admin/tickets/process'); $id = $this->getRequest()->getParam('id'); $this->view->title = $this->translator->translate("Edit Ticket"); $this->view->description = $this->translator->translate("Here you can handle the ticket support."); // 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/tickets/list/", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/tickets/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); if (!empty($id) && is_numeric($id)) { $this->view->buttons[] = array("url" => "/admin/tickets/setstatus/id/{$id}/statusid/" . Statuses::id('closed', 'tickets'), "label" => $this->translator->translate('Set as closed'), "params" => array('css' => array('btn btn-primary'))); $this->view->buttons[] = array("url" => "/admin/tickets/setstatus/id/{$id}/statusid/" . Statuses::id('solved', 'tickets'), "label" => $this->translator->translate('Set as solved'), "params" => array('css' => array('btn btn-success'))); $this->view->buttons[] = array("url" => "/admin/tickets/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => array('btn btn-danger'))); $form->populate(array('datetime' => date('d/m/Y H:i:s'), 'ticket_id' => $id)); $fields = "DATE_FORMAT(t.date_open, '%d/%m/%Y') as date_open, user_id, sibling_id, category_id as category, CONCAT(d.domain, '.', ws.tld) as domain, DATE_FORMAT(t.date_close, '%d/%m/%Y') as date_close, t.subject, t.description, t.status_id, s.status, c.email as email, c.customer_id as customer_id, CONCAT(c.firstname, ' ', c.lastname) as fullname, c.company as company, (DATEDIFF(t.date_close, t.date_open)) as days"; $rs = $this->tickets->getAllInfo($id, $fields, true); if (!empty($rs[0])) { $form->populate(array('datetime' => date('d/m/Y H:i:s'), 'ticket_id' => $id) + $rs[0]); $siblings = Tickets::getListbyCustomerId($rs[0]['customer_id'], true, true); unset($siblings[$id]); $form->getElement('sibling_id')->setMultiOptions($siblings); if (!empty($rs[0]['sibling_id'])) { $rs[0]['sibling'] = $this->tickets->getAllInfo($rs[0]['sibling_id'], $fields, true); } $this->view->record = $rs[0]; $this->view->siblings = $siblings; $this->view->customerid = $rs[0]['customer_id']; $isp = Isp::getActiveISP(); $this->view->customeravatar = Shineisp_Commons_Gravatar::get_gravatar($rs[0]['email'], 50); $this->view->notes = Tickets::Notes($id, "c.customer_id, tn.note_id, t.ticket_id, note_id as id, admin as adminreply, DATE_FORMAT(date_post, '%d/%m/%Y %H:%i:%s') as date_post, note as reply", true); // Header Information $this->view->title = "Edit Ticket: " . $rs[0]['subject']; $userlink = "<a href='/admin/customers/edit/id/" . $rs[0]['customer_id'] . "'>" . $rs[0]['fullname'] . "</a>"; if (!empty($rs[0]['company'])) { $userlink .= " [<a href='/admin/customers/edit/id/" . $rs[0]['customer_id'] . "'>" . $rs[0]['company'] . "</a>]"; } $description[] = $this->translator->_("Support Ticket from %s", $userlink); $description[] = TicketsCategories::getName($rs[0]['category']); $description[] = $this->translator->_("Opened on %s", $rs[0]['date_open']); if (!empty($rs[0]['date_close'])) { $description[] = $this->translator->_("Closed on %s", $rs[0]['date_close']); } if (!empty($rs[0]['domain'])) { $description[] = "<a target=\"blank\" href=\"http://www." . $rs[0]['domain'] . "\">" . $rs[0]['domain'] . "</a>"; } $this->view->description = implode(" - ", $description); // Hide these fields and values inside the vertical grid object unset($rs[0]['parent']); unset($rs[0]['description']); $this->view->data = array('records' => $rs); } } $this->view->form = $form; $this->render('applicantform'); }
/** * Save the ticket * * @param integer $id * @param integer $customer * @param string $subject * @param string $description * @param integer $category * @param integer $status * @param integer $domain * @return Boolean or integer */ public static function saveIt($id = null, $customer, $subject, $description, $category, $status = null, $domain = null) { $translator = Shineisp_Registry::getInstance()->Zend_Translate; $isUpdate = false; if (is_numeric($id)) { $ticket = self::find($id); $isUpdate = true; } else { $ticket = new Tickets(); } $operatorId = Settings::findbyParam('tickets_operator', 'admin', Isp::getActiveISPID()); if (!is_numeric($operatorId)) { $operator = AdminUser::getFirstAdminUser(); } else { $operator = AdminUser::getAllInfo($operatorId); } if (is_numeric($customer)) { $ticket->subject = !empty($subject) ? $subject : $translator->translate('Generic Issue'); $ticket->description = !empty($description) ? $description : null; $ticket->category_id = !empty($category) ? $category : null; $ticket->customer_id = $customer; $ticket->user_id = $operator['user_id']; $ticket->date_open = date('Y-m-d H:i:s'); $ticket->date_updated = date('Y-m-d H:i:s'); $ticket->domain_id = is_numeric($domain) && $domain > 0 ? $domain : NULL; $ticket->status_id = !empty($status) ? $status : Statuses::id("expectingreply", "tickets"); // Expecting a reply as default $ticket->save(); $id = $ticket->getIncremented(); // Save the upload file $attachment = self::UploadDocument($id, $customer); // Check if the request is an update if ($isUpdate == false) { // Create for the first time the fast link Fastlinks::CreateFastlink('tickets', 'edit', json_encode(array('id' => $id)), 'tickets', $id, $customer); // Send ticket by email self::send($id, true, $attachment); } return $id; } return false; }
/** * Create a new Order * * @return boolean */ public function createOrder() { if (!$this->getOrderid()) { $theOrder = Orders::create($this->getCustomerId(), Statuses::id('tobepaid', 'orders'), null); // For each item in the cart foreach ($this->getItems() as $item) { $item = Orders::addOrderItem($item); } $this->setOrderid($theOrder['order_id']); // Send the email to confirm the order Orders::sendOrder($theOrder['order_id']); return Orders::getOrder(); } else { return Orders::find($this->getOrderid()); } }
public function linkAction() { $request = $this->getRequest(); $NS = new Zend_Session_Namespace('Default'); try { $code = $request->getParam('id'); $link = Fastlinks::findbyCode($code); $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('default')); if (!empty($link[0]['controller'])) { $customer = Customers::find($link[0]['customer_id']); //TODO: GUEST - ALE - 20130516: remove access for disabled customers if (isset($customer) && in_array($customer['status_id'], array(Statuses::id("active", "customers"), Statuses::id("disabled", "customers")))) { $NS->customer = $customer; Fastlinks::updateVisits($link[0]['fastlink_id']); $this->_helper->redirector($link[0]['action'], $link[0]['controller'], 'default', json_decode($link[0]['params'], true)); } else { header('location: /customer/login'); die; } } else { header('location: /customer/login'); die; } } catch (Exception $e) { echo $e->getMessage(); die; } }
public static function getAllPaymentsbyMonthYear($month, $year) { if (!is_numeric($month) || !is_numeric($year)) { return array(); } $records = Doctrine_Query::create()->select("ip.purchase_id,\r\n \t\t\tpm.method as method,\r\n \t\t\tip.number as invoice,\t\r\n \t\t\tDATE_FORMAT(ip.creationdate, '" . Settings::getMySQLDateFormat('dateformat') . "') as date, \t\t\r\n \t\t\tDATE_FORMAT(ip.expiringdate, '" . Settings::getMySQLDateFormat('dateformat') . "') as expiring_date, \t\t\r\n \t\t\tip.company as company,\r\n \t\t\tip.total_net as total,\r\n \t\t\tip.total_vat as vat,\r\n \t\t\tip.total as grandtotal")->from('PurchaseInvoices ip')->leftJoin('ip.PaymentsMethods pm')->where('YEAR(ip.creationdate) = ?', $year)->andWhere('MONTH(ip.creationdate) = ?', $month)->andWhere('ip.status_id = ?', Statuses::id("complete", "orders"))->execute(array(), Doctrine_Core::HYDRATE_ARRAY); return $records; }
public static function getActiveWebserver() { $dq = Doctrine_Query::create()->from('Servers i')->leftJoin('i.Servers_Types st ON st.type_id = i.type_id')->where("type_id = ?", 1)->where("status_id = ?", Statuses::id('active', 'servers'))->andWhere("isp_id = ?", Isp::getActiveISPID()); $record = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); return !empty($record[0]) ? $record[0] : false; }
/** * 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; } }
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(); }
public function get($uuid, $order_uuid = null, $service_uuid = null) { $this->authenticate(); $customers = Customers::findWithUuid($uuid); if (empty($customers)) { throw new Shineisp_Api_Exceptions(400006, ":: 'uuid' not valid"); exit; } $id = $customers['customer_id']; if ($order_uuid == null && $service_uuid == null) { throw new Shineisp_Api_Exceptions(400006, ":: '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']; $fields = "o.order_id, \n \t\t o.order_number,\n DATE_FORMAT(o.order_date, '%d/%m/%Y') as Starting, \n DATE_FORMAT(o.expiring_date, '%d/%m/%Y') as Valid_Up, \n in.invoice_id as invoice_id, \n in.number as Invoice, \n CONCAT(d.domain, '.', w.tld) as Domain, \n c.company as company, \n o.status_id, \n s.status as Status, \n o.vat as VAT, \n o.total as Total, \n o.grandtotal as Grandtotal\n so.code as servStatus"; $rs = Orders::getAllInfo($orderid, "*", true, $id); if (empty($rs)) { throw new Shineisp_Api_Exceptions(404001, ":: Orders not found"); } return $rs; $currency = Shineisp_Registry::getInstance()->Zend_Currency; $result = array(); $order = array_shift($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 ($order['status_id'] == Statuses::id('tobepaid', 'orders')) { // Update the total order Orders::updateTotalsOrder($orderid); // Reload the data $rs = Orders::getAllInfo($orderid, $fields, true, $id); $order = array_shift($rs); $order['Total'] = $currency->toCurrency($order['Total'], array('currency' => Settings::findbyParam('currency'))); $order['VAT'] = $currency->toCurrency($order['VAT'], array('currency' => Settings::findbyParam('currency'))); $order['Grandtotal'] = $currency->toCurrency($order['Grandtotal'], array('currency' => Settings::findbyParam('currency'))); $order['price'] = $order['Grandtotal']; $result['tobepaid'] = true; } $result['order'] = $order; $records = OrdersItems::getAllDetails($orderid, "oi.detail_id, oi.description as description, DATE_FORMAT(oi.date_end, '%d/%m/%Y') as expiration_date, oi.quantity as quantity, oi.price as price, bc.name as billingcycle, oi.setupfee as setupfee,p.autosetup as autosetup, s.code as statuscode", true); $allactive = false; for ($i = 0; $i < count($records); $i++) { $records[$i]['itemactiveonorder'] = false; if ($records[$i]['autosetup'] == 1) { $records[$i]['itemactiveonorder'] = true; $allactive = true; } else { $allactive = false; } $records[$i]['price'] = $currency->toCurrency($records[$i]['price'], array('currency' => Settings::findbyParam('currency'))); $records[$i]['setupfee'] = $currency->toCurrency($records[$i]['setupfee'], array('currency' => Settings::findbyParam('currency'))); } $result['activeonorder'] = $allactive; $result['orderitems'] = $records; $result['invoidid'] = $order['status_id'] == Statuses::id("complete", "orders") && $order['Invoice'] > 0 ? true : false; $result['invoidnumber'] = $order['Invoice']; $result['invoidid'] = $order['invoice_id']; $result['payments'] = ""; if ($result['tobepaid'] == true) { $result['payments'] = array(); $banks = Banks::findAllActive("classname", true); if (!empty($banks)) { foreach ($banks as $bank) { if (!empty($bank['classname']) && class_exists($bank['classname'])) { if (class_exists($bank['classname'])) { $class = $bank['classname']; $payment = new $class($id); $payment->setUrlOk($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($bank['classname'])); $payment->setUrlKo($_SERVER['HTTP_HOST'] . "/orders/response/gateway/" . md5($bank['classname'])); $payment->setUrlCallback($_SERVER['HTTP_HOST'] . "/common/callback/gateway/" . md5($bank['classname'])); $result['payments'][] = $payment->CreateForm(); } } } } } return $result; } }
/** * 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; }
/** * 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; } }
/** * Get the product sold summary or per year */ public static function getBestseller($year = null) { $Session = new Zend_Session_Namespace('Admin'); $locale = $Session->langid; // Get the year incomes total and subtract the credit memo $dq = Doctrine_Query::create()->select('detail_id, p.product_id as id, count(*) as total, pag.name as group, pd.name as product,')->from('OrdersItems oi')->leftJoin('oi.Orders o')->leftJoin('oi.Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin('p.ProductsAttributesGroups pag')->where('oi.status_id = ? OR oi.status_id = ?', array(Statuses::id('paid', 'orders'), Statuses::id('complete', 'orders')))->andWhere('p.isp_id = ?', Isp::getCurrentId())->groupBy('pd.name')->orderBy('count(*) desc'); if (is_numeric($year)) { $dq->andWhere('Year(o.order_date) = ?', $year); } $data = $dq->execute(null, Doctrine::HYDRATE_ARRAY); return $data; }
/** * 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; }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $id = $this->getRequest()->getParam('id'); if (!empty($id) && is_numeric($id)) { $NS = new Zend_Session_Namespace('Default'); $NS->productid = $id; $form = $this->getForm('/services/process'); //Add upgrade service if exists $fields = "o.order_id as order, pd.name as product, CONCAT(d.domain, '.', ws.tld) as domain, oi.status_id, oi.detail_id, DATE_FORMAT(o.order_date, '%d/%m/%Y') as order_date, DATE_FORMAT(oi.date_end, '%d/%m/%Y') as next_deadline, (DATEDIFF(oi.date_end, CURRENT_DATE)) as daysleft, b.name, oi.price as price, t.name as tax, t.percentage as vat, s.status as status, bc.name as billing_cycle, oi.autorenew as autorenew, oi.note as note"; $rs = $this->services->getAllInfo($id, $fields, 'c.customer_id = ' . $NS->customer['customer_id'] . ' OR c.parent_id = ' . $NS->customer['customer_id']); if (empty($rs)) { $this->_helper->redirector('list', 'services', 'default', array('mex' => 'The service selected has been not found.', 'status' => 'danger')); } if (!empty($rs['vat']) && $rs['price'] > 0) { $rs['total_with_tax'] = $currency->toCurrency($rs['price'] * (100 + $rs['vat']) / 100, array('currency' => Settings::findbyParam('currency'))); $rs['tax'] = $rs['vat'] . "% " . $this->translator->translate($rs['tax']); } $form->populate($rs); // Hide these fields and values inside the vertical grid object unset($rs['autorenew']); unset($rs['vat']); unset($rs['note']); if ($rs['status_id'] == Statuses::id("complete", "orders")) { $this->view->expired = true; } else { $this->view->expired = false; } $this->view->datagrid = array('records' => array($rs)); $this->view->id = $id; $this->view->setup = OrdersItems::getSetupConfig($id); // Get all the messages attached to the ordersitems $this->view->messages = Messages::getbyServiceId($id); $this->view->title = $rs['product']; } else { $this->view->title = $this->translator->translate("Detail of the service"); } $this->view->description = $this->translator->translate("Here you can see the detail of the service."); $this->view->dnsdatagrid = $this->dnsGrid(); $this->view->form = $form; $this->_helper->viewRenderer('customform'); }
/** * 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; }