Beispiel #1
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;
 }
Beispiel #2
0
 public static function sendInvoice($invoiceid, $urlEmail = "")
 {
     if (is_numeric($invoiceid)) {
         $invoice = self::getAllInfo($invoiceid, null, true);
         if (!empty($invoice[0])) {
             $invoiceNum = $invoice[0]['number'];
             $orderid = $invoice[0]['order_id'];
             $customerid = $invoice[0]['customer_id'];
         } else {
             return false;
         }
         $fastlink = self::getFastlinksInvoice($invoiceid, $orderid, $customerid);
         $order = Orders::getAllInfo($orderid, null, true);
         //if customer comes from reseller
         if ($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'] : "";
             $customer_email = $invoice_dest['email'];
             $language_id = $invoice_dest['language_id'];
         } else {
             $customer = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'];
             $customer .= !empty($order[0]['Customers']['company']) ? " - " . $order[0]['Customers']['company'] : "";
             $customer_email = Contacts::getEmails($customerid);
             $language_id = $order[0]['Customers']['language_id'];
         }
         $email = $order[0]['Isp']['email'];
         $signature = $order[0]['Isp']['company'];
         if ($urlEmail == "") {
             $url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $fastlink;
         } else {
             $url = $urlEmail;
         }
         $date = explode("-", $order[0]['order_date']);
         Shineisp_Commons_Utilities::sendEmailTemplate($customer_email, 'new_invoice', array('orderid' => $order[0]['order_number'], 'invoiceid' => sprintf("%03s", $invoiceNum) . "/" . $date[0], 'fullname' => $customer, 'email' => $email, 'url' => $url, ':shineisp:' => $order[0]['Customers'], 'conditions' => strip_tags(Settings::findbyParam('conditions'))), null, null, null, null, $language_id);
         return true;
     }
     return false;
 }
Beispiel #3
0
 /**
  * reminderAction
  * This action send to every customers an email
  * reminder about their expiring services and domains
  */
 public static function remindersEmail()
 {
     $i = 0;
     $customers = array();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     /* 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 particular customer.
     		*/
     // Get all the active domains that expire in 1 day
     $domains = Domains::getExpiringDomainsByRange(0, 30, Statuses::id('active', 'domains'));
     if ($domains) {
         // Create the customer group list for the email summary
         foreach ($domains as $domain) {
             if ($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'];
             $customers[$domain['customer_id']]['products'][$i]['oldorderitemid'] = $domain['detail_id'];
             $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::getExpiringServicesByRange(0, 30, Statuses::id("complete", "orders"));
     if ($services) {
         // Create the customer group list for the email summary
         foreach ($services as $service) {
             if ($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'] = $customer_email = Contacts::getEmails($invoice_dest['customer_id']);
                 $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'] = $customer_email = Contacts::getEmails($service['id']);
                 $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'];
             $i++;
         }
     }
     // EMAIL SUMMARY FOR ALL THE EXPIRED AND NOT AUTORENEWABLE DOMAINS/SERVICES
     // =========================================================================
     // Create the emailS for the customers
     if (count($customers) > 0) {
         // For each client do ...
         foreach ($customers as $customer) {
             $items = array();
             $translator->setLocale(Languages::get_locale($customer['language_id']));
             // Check if there are some product to be expired
             if (count($customer['products']) > 0) {
                 $i = 0;
                 // For each product do ...
                 foreach ($customer['products'] as $product) {
                     $items[$i][$translator->translate("Expiry Date")] = $product['expiring_date'];
                     $items[$i][$translator->translate("Days")] = $product['days'];
                     $items[$i][$translator->translate("Description")] = $product['name'];
                     if ($product['renew']) {
                         $items[$i][$translator->translate("Auto Renewal")] = $translator->translate("Active");
                     } else {
                         $items[$i][$translator->translate("Auto Renewal")] = $translator->translate("Not Active");
                     }
                     $i++;
                 }
             }
             $items = Shineisp_Commons_Utilities::array2table($items);
             if (!empty($items)) {
                 Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'reminder', array('items' => $items, 'fullname' => $customer['fullname']), null, null, null, null, $customer['language_id'], Settings::findbyParam('cron_notify'));
             }
         }
     }
     return true;
 }
Beispiel #4
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;
 }