Example #1
0
 public function checkfastlinkAction()
 {
     $request = $this->getRequest();
     $fastlink = $request->getParam('id');
     $link_exist = Fastlinks::findbyCode($fastlink);
     if (count($link_exist) > 0) {
         echo 1;
     } else {
         echo 0;
     }
     die;
 }
Example #2
0
 public static function sendOrder($orderid, $customURL = null)
 {
     $bank = "";
     if (is_numeric($orderid)) {
         $order = self::getAllInfo($orderid, null, true);
         //if customer comes from reseller
         if ($order[0]['Customers']['parent_id']) {
             $customer_email = Contacts::getEmails($order[0]['Customers']['parent_id']);
             $invoice_dest = Customers::getAllInfo($order[0]['Customers']['parent_id']);
             $customer = $invoice_dest['firstname'] . " " . $invoice_dest['lastname'];
             $customer .= !empty($invoice_dest['company']) ? " - " . $invoice_dest['company'] : "";
             $fastlink = Fastlinks::findlinks($orderid, $order[0]['Customers']['parent_id'], 'orders');
             $language_id = $invoice_dest['language_id'];
         } else {
             $customer_email = Contacts::getEmails($order[0]['Customers']['customer_id']);
             $customer = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'];
             $customer .= !empty($order[0]['Customers']['company']) ? " - " . $order[0]['Customers']['company'] : "";
             $fastlink = Fastlinks::findlinks($orderid, $order[0]['Customers']['customer_id'], 'orders');
             $language_id = $order[0]['Customers']['language_id'];
         }
         $email = $order[0]['Isp']['email'];
         $bankInfo = Banks::getBankInfo();
         if (!empty($bankInfo['description'])) {
             $bank = $bankInfo['description'];
         }
         if (!empty($customURL)) {
             $url = $customURL;
         } else {
             if (!empty($fastlink[0]['code'])) {
                 $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $fastlink[0]['code'];
             } else {
                 $url = "http://" . $_SERVER['HTTP_HOST'];
             }
         }
         $date = explode("-", $order[0]['order_date']);
         Shineisp_Commons_Utilities::sendEmailTemplate($customer_email, 'order_new', array('orderid' => $order[0]['order_number'], 'fullname' => $customer, 'email' => $email, 'bank' => $bank, 'url' => $url, ':shineisp:' => $order[0]['Customers'], 'conditions' => strip_tags(Settings::findbyParam('conditions'))), null, null, null, null, $language_id);
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 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;
     }
 }
Example #5
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $isp = Shineisp_Registry::get('ISP');
     $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/orders/process');
     if (!$form->isValid($request->getPost())) {
         // Invalid entries
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Order process");
         $this->view->description = $this->translator->translate("Check the information posted and then click on the save button.");
         return $this->_helper->viewRenderer('applicantform');
         // re-render the login form
     }
     // Get the values posted
     $params = $form->getValues();
     // Get the id
     $id = $this->getRequest()->getParam('order_id');
     // Save the message note
     if (!empty($params['note'])) {
         // If the order is commentable then go on
         if (Orders::IsCommentable($id)) {
             $order = Orders::getAllInfo($id, null, true);
             $link = Fastlinks::findlinks($id, $this->customer['customer_id'], 'orders');
             if (!empty($link[0]['code'])) {
                 $code = $link[0]['code'];
             } else {
                 $code = Fastlinks::CreateFastlink('orders', 'edit', json_encode(array('id' => $id)), 'orders', $id, $this->customer['customer_id']);
             }
             // Save the message in the database
             Messages::addMessage($params['note'], $this->customer['customer_id'], null, $id);
             $in_reply_to = md5($id);
             $placeholder['messagetype'] = $this->translator->translate('Order');
             $placeholders['subject'] = sprintf("%03s", $id) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']);
             $placeholders['fullname'] = $this->customer['firstname'] . " " . $this->customer['lastname'];
             $placeholders['orderid'] = $placeholders['subject'];
             $placeholders['conditions'] = Settings::findbyParam('conditions');
             $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $code;
             // Send a message to the customer
             Shineisp_Commons_Utilities::sendEmailTemplate($order[0]['Customers']['email'], 'order_message', $placeholders, $in_reply_to, null, null, $isp, $order[0]['Customers']['language_id']);
             $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/{$code}/keypass/" . Shineisp_Commons_Hasher::hash_string($isp->email);
             $placeholders['message'] = $params['note'];
             // Send a message to the administrator
             Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'order_message_admin', $placeholders, $in_reply_to);
         }
     }
     $this->_helper->redirector('index', 'orders', 'default', array('mex' => 'The requested task has been completed successfully', 'status' => 'success'));
 }
Example #6
0
 /**
  * renewdomainAction
  * Renew a group of domains selected
  * @param $items
  * @return void
  */
 private function renewdomains($items)
 {
     $mex = "";
     if (is_array($items)) {
         try {
             $Orderid = Orders::createOrderWithMultiProducts($items, $this->customer['customer_id']);
             $isp = Shineisp_Registry::get('ISP');
             $order = Orders::getAllInfo($Orderid, null, true);
             $link = Fastlinks::findlinks($Orderid, $this->customer['customer_id'], 'orders');
             $retval = Shineisp_Commons_Utilities::getEmailTemplate('new_order');
             if ($retval) {
                 $subject = $retval['subject'];
                 $subject = str_replace("[orderid]", sprintf("%03s", $Orderid) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']), $subject);
                 $orderbody = $retval['template'];
                 $orderbody = str_replace("[fullname]", $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'], $orderbody);
                 $orderbody = str_replace("[bank]", $isp->bankname . "\nc/c:" . $isp->bankaccount . "\nIBAN: " . $isp->iban . "\nBIC: " . $isp->bic, $orderbody);
                 $orderbody = str_replace("[orderid]", $Orderid . "/" . date('Y'), $orderbody);
                 $orderbody = str_replace("[email]", $isp->email, $orderbody);
                 $orderbody = str_replace("[signature]", $isp->company . "\n" . $isp->email, $orderbody);
                 if (!empty($link[0])) {
                     $orderbody = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code'], $orderbody);
                 } else {
                     $orderbody = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'], $orderbody);
                 }
                 if (!empty($order[0]['Customers']['email'])) {
                     Shineisp_Commons_Utilities::SendEmail($isp->email, $order[0]['Customers']['email'], $isp->email, $subject, $orderbody);
                 }
             }
             die(json_encode(array('reload' => '/orders/edit/id/' . $Orderid)));
         } catch (Exception $e) {
             die(json_encode(array('mex' => $e->getMessage())));
         }
     }
     return false;
 }
Example #7
0
 /**
  * Get the fastlink of invoice, if not exist create it
  ****/
 public static function getFastlinksInvoice($invoiceid, $orderid, $customerid)
 {
     $link_exist = Fastlinks::findlinks($orderid, $customerid, 'orders');
     // The fastlink does not exists and we have to create it
     if (count($link_exist) == 0) {
         $fastlink = Fastlinks::CreateFastlink("orders", "createinvoice", json_encode(array('id' => $invoiceid)), "orders", $orderid, $customerid);
     } else {
         // The fastlink exists and we get it in order to write it in the email content
         // but before we have to check if the link that we have to send to the user contain the right invoice
         // If the id of the invoice is not equal to the id of the invoice attached into the order we have to create a new fastlink
         $params = json_decode($link_exist[0]['params'], true);
         if (!empty($params['id']) && $params['id'] == $invoiceid) {
             $fastlink = $link_exist[0]['code'];
         } else {
             $fastlink = Fastlinks::CreateFastlink("orders", "createinvoice", json_encode(array('id' => $invoiceid)), "orders", $orderid, $customerid);
         }
     }
     return $fastlink;
 }
Example #8
0
 /**
  * editAction
  * Get a record and populate the application form 
  * @return unknown_type
  */
 public function editAction()
 {
     $form = $this->getForm('/admin/orders/process');
     $currency = Shineisp_Registry::getInstance()->Zend_Currency;
     $customer = null;
     $createInvoiceConfirmText = $this->translator->translate('Are you sure you want to create or overwrite the invoice for this order?');
     $id = intval($this->getRequest()->getParam('id'));
     $this->view->description = $this->translator->translate("Here you can edit the selected order.");
     if (!empty($id) && is_numeric($id)) {
         $rs = $this->orders->find($id);
         if (!empty($rs)) {
             $rs = $rs->toArray();
             $rs['setupfee'] = Orders::getSetupfee($id);
             $rs['order_date'] = Shineisp_Commons_Utilities::formatDateOut($rs['order_date']);
             $rs['expiring_date'] = Shineisp_Commons_Utilities::formatDateOut($rs['expiring_date']);
             $rs['received_income'] = 0;
             $rs['missing_income'] = $rs['grandtotal'];
             $rs['order_number'] = !empty($rs['order_number']) ? $rs['order_number'] : Orders::formatOrderId($rs['order_id']);
             $payments = Payments::findbyorderid($id, 'income', true);
             if (isset($payments)) {
                 foreach ($payments as $payment) {
                     $rs['received_income'] += isset($payment['income']) ? $payment['income'] : 0;
                     $rs['missing_income'] -= isset($payment['income']) ? $payment['income'] : 0;
                 }
             }
             $rs['profit'] = $rs['total'] - $rs['cost'];
             $rs['profit'] = $currency->toCurrency($rs['profit'], array('currency' => Settings::findbyParam('currency')));
             // set the default income to prepare the payment task
             $rs['income'] = $rs['missing_income'];
             $rs['missing_income'] = sprintf('%.2f', $rs['missing_income']);
             unset($payments);
             $parent = Customers::find($rs['customer_id']);
             //if customer comes from reseller
             if ($parent['parent_id']) {
                 $rs['customer_parent_id'] = $parent['parent_id'];
             } else {
                 $rs['customer_parent_id'] = $rs['customer_id'];
             }
             $link = Fastlinks::findlinks($id, $rs['customer_id'], 'Orders');
             if (isset($link[0])) {
                 $rs['fastlink'] = $link[0]['code'];
                 $rs['visits'] = $link[0]['visits'];
             }
             $form->populate($rs);
             $this->view->id = $id;
             $this->view->customerid = $rs['customer_id'];
             if (!empty($rs['fastlink'])) {
                 $this->view->titlelink = "/index/link/id/" . $rs['fastlink'];
             }
             if (!empty($rs['order_number'])) {
                 $this->view->title = $this->translator->_("Order nr. %s", $rs['order_number']);
             }
             $this->view->messages = Messages::getbyOrderId($id);
             $createInvoiceConfirmText = $rs['missing_income'] > 0 ? $this->translator->translate('Are you sure you want to create or overwrite the invoice for this order? The order status is: not paid.') : $createInvoiceConfirmText;
             $customer = Customers::get_by_customerid($rs['customer_id'], 'company, firstname, lastname, email');
         } else {
             $this->_helper->redirector('list', 'orders', 'admin');
         }
     }
     $this->view->mex = urldecode($this->getRequest()->getParam('mex'));
     $this->view->mexstatus = $this->getRequest()->getParam('status');
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('id' => 'submit', 'css' => array('btn btn-success'))), array("url" => "/admin/orders/print/id/{$id}", "label" => $this->translator->translate('Print'), "params" => array('css' => null)), array("url" => "/admin/orders/dropboxit/id/{$id}", "label" => $this->translator->translate('Dropbox It'), "params" => array('css' => null)), array("url" => "/admin/orders/clone/id/{$id}", "label" => $this->translator->translate('Clone'), "params" => array('css' => null)), array("url" => "/admin/orders/sendorder/id/{$id}", "label" => $this->translator->translate('Email'), "params" => array('css' => array('btn btn-danger'))), array("url" => "/admin/orders/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => array('btn btn-danger'))), array("url" => "/admin/orders/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     // Check if the order has been invoiced
     $invoice_id = Orders::isInvoiced($id);
     if ($invoice_id) {
         $this->view->buttons[] = array("url" => "/admin/orders/sendinvoice/id/{$invoice_id}", "label" => $this->translator->translate('Email invoice'), "params" => array('css' => array('btn btn-danger')));
         $this->view->buttons[] = array("url" => "/admin/invoices/print/id/{$invoice_id}", "label" => $this->translator->translate('Print invoice'), "params" => array('css' => null));
     } else {
         // Order not invoiced, show button to create a new invoice
         $this->view->buttons[] = array("url" => "/admin/orders/createinvoice/id/{$id}", "label" => $this->translator->translate('Invoice'), "params" => array('css' => array('btn btn-danger')), 'onclick' => "return confirm('" . $createInvoiceConfirmText . "')");
     }
     $this->view->customer = array('records' => $customer, 'editpage' => 'customers');
     $this->view->ordersdatagrid = $this->orderdetailGrid();
     $this->view->paymentsdatagrid = $this->paymentsGrid();
     $this->view->statushistory = StatusHistory::getStatusList($id);
     // Get Order status history
     $this->view->filesgrid = $this->filesGrid();
     $this->view->statushistorygrid = $this->statusHistoryGrid();
     $this->view->form = $form;
     $this->render('applicantform');
 }
Example #9
0
 public function linkAction()
 {
     $request = $this->getRequest();
     try {
         $code = $request->getParam('id');
         $keypass = $request->getParam('keypass');
         $link = Fastlinks::findbyCode($code);
         $auth = Zend_Auth::getInstance();
         if (!empty($link[0]['controller']) && !empty($link[0]['action'])) {
             $adapter = new Shineisp_Auth_Adapter_Secretkey(Doctrine_Manager::connection()->getTable("AdminUser"), "email");
             $adapter->setIdentity($keypass);
             $adapter->setType('operator');
             $auth->setStorage(new Zend_Auth_Storage_Session('admin'));
             $auth->authenticate($adapter);
             // Check if the credentials are set in the Operator profile or the credentials are set in the ISP profile
             if ($auth->hasIdentity()) {
                 Fastlinks::updateVisits($link[0]['fastlink_id']);
                 Shineisp_Commons_Utilities::log("Login: The user has been logged in correctly from " . $_SERVER['REMOTE_ADDR'], "login.log");
                 $this->_helper->redirector($link[0]['action'], $link[0]['controller'], 'admin', json_decode($link[0]['params'], true));
             } else {
                 // Check if the credentials are set in the Isp profile
                 $adapter->setType('isp');
                 $auth->setStorage(new Zend_Auth_Storage_Session('admin'));
                 $auth->authenticate($adapter);
                 if ($auth->hasIdentity()) {
                     Fastlinks::updateVisits($link[0]['fastlink_id']);
                     Shineisp_Commons_Utilities::log("Login: The user has been logged in correctly from " . $_SERVER['REMOTE_ADDR'], "login.log");
                     $this->_helper->redirector($link[0]['action'], $link[0]['controller'], 'admin', json_decode($link[0]['params'], true));
                 } else {
                     $auth->clearIdentity();
                     header('location: /admin');
                     die;
                 }
             }
         } else {
             $auth->clearIdentity();
             header('location: /admin');
             die;
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         die;
     }
 }
Example #10
0
 /**
  * This batch has been created in order to remind customers
  * that one or more tickets are still open.
  */
 public static function checkTickets()
 {
     $isp = Isp::getActiveISP();
     $tickets = Tickets::getWaitingReply();
     // Get the template from the main email template folder
     $retval = Shineisp_Commons_Utilities::getEmailTemplate('ticket_waitreply');
     foreach ($tickets as $ticket) {
         $customer = $ticket['Customers'];
         // Get the fastlink attached
         $link_exist = Fastlinks::findlinks($ticket['ticket_id'], $customer['customer_id'], 'tickets');
         if (count($link_exist) > 0) {
             $fastlink = $link_exist[0]['code'];
         } else {
             $fastlink = Fastlinks::CreateFastlink('tickets', 'edit', json_encode(array('id' => $ticket['ticket_id'])), 'tickets', $ticket['ticket_id'], $customer['customer_id']);
         }
         $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/{$fastlink}";
         if ($retval) {
             $subject = $retval['subject'];
             $Template = nl2br($retval['template']);
             $subject = str_replace("[subject]", $ticket['subject'], $subject);
             $Template = str_replace("[subject]", $ticket['subject'], $Template);
             $Template = str_replace("[lastname]", $customer['lastname'], $Template);
             $Template = str_replace("[issue_number]", $ticket['ticket_id'], $Template);
             $Template = str_replace("[date_open]", Shineisp_Commons_Utilities::formatDateOut($ticket['date_open']), $Template);
             $Template = str_replace("[link]", $customer_url, $Template);
             $Template = str_replace("[signature]", $isp['company'] . "<br/>" . $isp['website'], $Template);
             Shineisp_Commons_Utilities::SendEmail($isp['email'], Contacts::getEmails($customer['customer_id']), null, $subject, $Template, true);
         }
     }
     return true;
 }
Example #11
0
 public static function CreateFastlink($controller, $action, $params, $sqltable, $id, $customerid)
 {
     $link = new Fastlinks();
     $fastlink = self::checkFastlinkCode(Shineisp_Commons_Utilities::GenerateRandomString());
     $link->controller = $controller;
     $link->action = $action;
     $link->params = $params;
     $link->customer_id = $customerid;
     $link->sqltable = $sqltable;
     $link->id = $id;
     $link->code = $fastlink;
     $link->save();
     return $fastlink;
 }