Ejemplo n.º 1
0
 public function listAction()
 {
     $ns = new Zend_Session_Namespace();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $pages = CmsPages::getblogpages($ns->lang);
     $isp = Isp::getActiveISP();
     $this->view->headerdata = array('title' => $translator->_("%s's blog", $isp['company']));
     $this->view->pages = $pages;
 }
Ejemplo n.º 2
0
 /**
  * CreateForm
  * Create the skrill form
  * @return string
  */
 public function CreateForm()
 {
     $order = self::getOrder();
     $bank = self::getModule();
     $isp = Isp::getActiveISP();
     $translator = self::getTranslator();
     // Check the skrill account field value
     if (empty($bank['account'])) {
         return null;
     }
     if ($order) {
         $form = "";
         $url = $bank['test_mode'] ? $bank['url_test'] : $bank['url_official'];
         if (!self::isHidden()) {
             $form .= "<div class=\"skrill_" . $bank['name'] . "\">" . $bank['description'] . "</div>";
         }
         $form .= '<form id="skrill" method="POST" action="' . $url . '">';
         $form .= '<input type="hidden" name="recipient_description" value="' . $isp['company'] . '"/>';
         $form .= '<input type="hidden" name="firstname" value="' . $order['Customers']['firstname'] . '"/>';
         $form .= '<input type="hidden" name="lastname" value="' . $order['Customers']['lastname'] . '"/>';
         $form .= '<input type="hidden" name="pay_from_email" value="' . $order['Customers']['email'] . '"/>';
         $form .= '<input type="hidden" name="pay_to_email" value="' . $bank['account'] . '"/>';
         $form .= '<input type="hidden" name="language" value="' . strtoupper($translator->getAdapter()->getLocale()) . '"/>';
         $form .= '<input type="hidden" name="amount" value="' . number_format($order['grandtotal'], 2, '.', '') . '"/>';
         $form .= '<input type="hidden" name="currency" value="EUR"/>';
         $form .= '<input type="hidden" name="transaction_id" value="' . self::getOrderID() . '"/>';
         $form .= '<input type="hidden" name="detail1_description" value="' . $translator->translate('Order No.') . '"/>';
         $form .= '<input type="hidden" name="detail1_text" value="' . self::getOrderID() . " - " . date('Y') . '"/>';
         $form .= '<input type="hidden" name="return_url" value="' . self::getUrlOk() . '"/>';
         $form .= '<input type="hidden" name="cancel_url" value="' . self::getUrlKo() . '"/>';
         $form .= '<input type="hidden" name="status_url" value="' . self::getUrlCallback() . '"/>';
         if (!self::doRedirect()) {
             $form .= '<input class="btn btn-success" type="submit" name="submit" value="' . $translator->translate('Pay Now') . '">';
         }
         $form .= '</form>';
         if (self::doRedirect()) {
             $form .= $translator->translate('You will be redirected to the secure bank website, please be patient.');
             $form .= "<script type=\"text/javascript\">\nsetTimeout(function () {\n\$('#skrill').submit();\n}, 3000);\n</script>";
         }
         return array('name' => $bank['name'], 'description' => $bank['description'], 'html' => $form);
     }
 }
Ejemplo n.º 3
0
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     $registry = Shineisp_Registry::getInstance();
     $translation = Shineisp_Registry::get('Zend_Translate');
     $retval = array();
     if ($auth->hasIdentity()) {
         $request = Zend_Controller_Front::getInstance()->getRequest();
         try {
             $form = new Admin_Form_BulkmailForm(array('action' => '/admin/bulkmail/#bulkmail', 'method' => 'post'));
             if ($request->isPost()) {
                 $isp = Isp::getActiveISP();
                 if ($form->isValid($request->getPost())) {
                     $data = $request->getPost();
                     $mail = new Bulkmails();
                     $mail->subject = $data['subject'];
                     $mail->body = $data['body'];
                     $mail->senddate = date('Y-m-d H:i:s');
                     $mail->save();
                     $customers = Customers::getEmails();
                     foreach ($customers as $customer) {
                         $body = str_replace('{fullname}', $customer['fullname'], $data['body']);
                         $result = Shineisp_Commons_Utilities::SendEmail($isp['email'], $customer['email'], null, $data['subject'], $body, true);
                         if ($result !== true) {
                             $retval[] = $result;
                         }
                     }
                 }
             }
             $retval = count($retval) > 0 ? $retval : null;
             $this->view->form = $form;
             $this->view->title = $translation->translate("Mass eMail");
             $this->view->description = $translation->translate("Write here a message to send to all your own customers.");
             $this->view->errors = $retval;
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * setDeleted
  * Set the order as deleted
  * @param $id, $customerid
  * @return boolean
  */
 public static function setDeleted($id, $customerid)
 {
     $dq = Doctrine_Query::create()->update('Orders o')->set('status_id', Statuses::id("deleted", "orders"))->where('order_id = ?', $id)->andWhere("customer_id = ?", $customerid);
     $dq->execute();
     $dq = Doctrine_Query::create()->update('OrdersItems oi')->set('status_id', Statuses::id("deleted", "orders"))->where('order_id = ?', $id);
     $dq->execute();
     $customer = Customers::getAllInfo($customerid);
     $order = self::getAllInfo($id, null, true);
     $date = explode("-", $order[0]['order_date']);
     Shineisp_Commons_Utilities::sendEmailTemplate($customer['email'], 'order_deleted', array('orderid' => $order[0]['order_number'], 'fullname' => $customer['lastname'], ':shineisp:' => Isp::getActiveISP(), 'conditions' => strip_tags(Settings::findbyParam('conditions'))), null, null, null, null, $customer['language_id']);
     return true;
 }
Ejemplo n.º 5
0
 /**
  * Send the newsletter to the queue
  */
 public static function send_queue($test = FALSE, $id = NULL)
 {
     $queue = NewslettersHistory::get_active_queue($test, $id);
     $isp = Isp::getActiveISP();
     try {
         // Get the template from the main email template folder
         $retval = Shineisp_Commons_Utilities::getEmailTemplate('newsletter');
         if (!empty($retval) && !empty($queue)) {
             $contents = Newsletters::fill_content();
             $subject = $retval['subject'];
             $template = $retval['template'];
             $subject = str_replace("[subject]", $queue[0]['Newsletters']['subject'], $subject);
             $template = str_replace("[subject]", $queue[0]['Newsletters']['subject'], $template);
             $template = str_replace("[body]", $queue[0]['Newsletters']['message'], $template);
             foreach ($contents as $name => $content) {
                 $template = str_replace("[" . $name . "]", $content, $template);
             }
             foreach ($isp as $field => $value) {
                 $template = str_replace("[" . $field . "]", $value, $template);
             }
             $template = str_replace("[url]", "http://" . $_SERVER['HTTP_HOST'] . "/media/newsletter/", $template);
             foreach ($queue as $item) {
                 // Send a test of the newsletter to the default isp email otherwise send an email to the queue
                 if ($test) {
                     $body = str_replace("[optout]", "#", $template);
                     Shineisp_Commons_Utilities::SendEmail($isp['email'], $isp['email'], null, "<!--TEST --> " . $subject, $body, true);
                     break;
                 } else {
                     // Create the optout link to be added in the email
                     $body = str_replace("[optout]", '<a href="http://' . $_SERVER['HTTP_HOST'] . "/newsletter/optout/id/" . MD5($item['NewslettersSubscribers']['email']) . '" >Unsubscribe</a>', $template);
                     $result = Shineisp_Commons_Utilities::SendEmail($isp['email'], $item['NewslettersSubscribers']['email'], null, $subject, $body, true);
                     if ($result === true) {
                         NewslettersHistory::set_status($item['subscriber_id'], $item['newsletter_id'], 1, "Mail Sent");
                     } else {
                         NewslettersHistory::set_status($item['subscriber_id'], $item['newsletter_id'], 0, $result['message']);
                     }
                     Newsletters::set_sending_date($item['news_id']);
                 }
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * export the content in a excel file
  * @param array $items
  */
 public function bulk_excel($items)
 {
     if (empty($items)) {
         return false;
     }
     $objPHPExcel = new PHPExcel();
     $company = Isp::getActiveISP();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $objPHPExcel->getProperties()->setCreator($company['company']);
     $objPHPExcel->getProperties()->setLastModifiedBy($company['manager']);
     $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX __CLASS__ Document");
     $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX __CLASS__ Document");
     $objPHPExcel->setActiveSheetIndex(0);
     // Get the records from the customer table
     $data = self::get_customers($items);
     // Create the PDF header
     $objPHPExcel->getActiveSheet()->setTitle($translator->translate('Customer List'));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, strtoupper($translator->translate('Customer List')));
     if (!empty($data[0])) {
         $row = 4;
         $column = 0;
         // Fields header title
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, 3, $translator->translate('Id'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Company'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Firstname'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Lastname'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Gender'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Email'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Password'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Birth Date'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Birth Place'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Birth District'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Birth Country'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Birth Nationality'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Tax Payer Number'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('VAT'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Company Type'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Legal form'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Note'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Status'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Group'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Language'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Newsletter'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Creation Date'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Upload Date'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Tax Free'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Address'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('City'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Code'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Country'));
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, 3, $translator->translate('Area'));
         $column = 0;
         // Get the main information of the client
         foreach ($data as $item) {
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, $row, $item['customer_id']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['company']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['firstname']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['lastname']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['gender']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['email']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['password']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['birthdate']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['birthplace']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['birthdistrict']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['birthcountry']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['birthnationality']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['taxpayernumber']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['vat']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['CompanyTypes']['name']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['Legalforms']['name']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['note']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['Statuses']['status']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['CustomersGroups']['name']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['issubscriber']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['created_at']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['updated_at']);
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $item['taxfree']);
             // get all the addresses
             foreach ($item['Addresses'] as $address) {
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $address['address']);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $address['city']);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $address['code']);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $address['Countries']['name']);
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $address['area']);
                 break;
             }
             // get all the contacts
             foreach ($item['Contacts'] as $contact) {
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, 3, $translator->translate($contact['ContactsTypes']['name']));
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column++, $row, $contact['contact']);
                 break;
             }
             $row++;
             $column = 0;
         }
     }
     // Create the XLS
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     $objWriter->save(PUBLIC_PATH . "/tmp/" . __CLASS__ . '.xlsx');
     die(json_encode(array('url' => "/tmp/" . __CLASS__ . ".xlsx")));
 }
Ejemplo n.º 7
0
 /**
  * Execute the panel tasks
  */
 private function doPanelsTask(array $task)
 {
     $ISP = Isp::getByCustomerId($task['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'));
         $ISP = empty($ISP) ? Isp::getActiveISP() : $ISP;
         Shineisp_Commons_Utilities::SendEmail($ISP['email'], $ISP['email'], null, "Task error panel message", 'Customer ISP ID has been not set yet.');
         return false;
     }
     try {
         $customer_id = isset($task['customer_id']) ? $task['customer_id'] : 0;
         $ISPpanel = Isp::getPanel($ISP['isp_id']);
         $class = "Shineisp_Plugins_Panels_" . $ISPpanel . "_Main";
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": Loading {$class} panel plugin");
         // Create the class registrar object
         $ISPclass = new $class();
         $action = $task['action'];
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": Start {$action} action");
         if ($action == "createClient") {
             // Create the website plan
             $clientId = $ISPclass->create_client($task);
         } elseif ($action == "createWebsite") {
             // Create the website plan
             $websiteID = $ISPclass->create_website($task);
             // Create the main ftp account
             $ftpID = $ISPclass->create_ftp($task, $websiteID);
             // Send the configuration email
             $ISPclass->sendMail($task);
         } elseif ($action == "createMail") {
             // Create the email account
             $emailID = $ISPclass->create_mail($task);
             // Send the configuration email
             $ISPclass->sendMail($task);
         } elseif ($action == "createDatabase") {
             // Create the database
             $databaseID = $ISPclass->create_database($task);
             // Send the configuration email
             $ISPclass->sendMail($task);
         } elseif ($action == "fullProfile") {
             $websiteID = $ISPclass->create_website($task);
             // Create the website plan
             $ftpID = $ISPclass->create_ftp($task, $websiteID);
             // Create the main ftp account
             $emailID = $ISPclass->create_mail($task);
             // Create the email account
             $databaseID = $ISPclass->create_database($task);
             // Create the database
             // Send the configuration email
             $ISPclass->sendMail($task);
         }
         // Update the log description of the panel action
         PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate("Your request has been executed."));
         // Update the status of the task
         PanelsActions::UpdateTaskStatus($task['action_id'], Statuses::id('complete', 'domains_tasks'));
         // Set the task as "Complete"
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": End {$class} process");
     } catch (Exception $e) {
         PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate($e->getMessage()));
         Shineisp_Commons_Utilities::SendEmail($ISP['email'], $ISP['email'], null, "Task error panel message", $e->getMessage());
         Shineisp_Commons_Utilities::logs(__METHOD__ . ": " . $e->getMessage());
     }
 }
Ejemplo n.º 8
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the domains table
     $domains = self::get_domains($items, "d.domain_id, \r\n\t\t\t\t\t\t\t\t\t\t\t  CONCAT(d.domain, '.', d.tld) as domain, \r\n\t\t\t\t\t\t\t\t\t\t\t  DATE_FORMAT(d.creation_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as creation_date, \r\n\t\t\t\t\t\t\t\t\t\t\t  DATE_FORMAT(d.expiring_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as expiring_date, , \r\n\t\t\t\t\t\t\t\t\t\t\t  DATEDIFF(expiring_date, CURRENT_DATE) as days,\r\n                       \t\t\t\t\t\t  IF(d.autorenew = 1, 'YES', 'NO') as renew,\r\n\t\t\t\t\t\t\t\t\t\t\t  s.status as status", "d.expiring_date, d.domain");
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Domain Listing');
     $grid['headers']['subtitle'] = $translator->_("List of the domains since %s and sorted by the expiring date and domain name", date('d/m/Y H:i:s'));
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($domains[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Domain'));
     }
     $grid['columns'][] = array("value" => $translator->translate('Creation Date'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Expiry Date'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Days'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Automatic Renewal'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Status'), 'size' => 80);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($domains as $domain) {
         $values = array_values($domain);
         array_shift($values);
         $grid['records'][] = $values;
     }
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 9
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_pdf_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the purchase invoices table
     $invoices = self::get_invoices($items, "purchase_id, \r\n\t\t\t\t\t\t\t\t\t\t\t\tDATE_FORMAT(creationdate, '" . Settings::getMySQLDateFormat('dateformat') . "') as creationdate, \r\n\t\t\t\t\t\t\t\t\t\t\t\tnumber as number, \r\n\t\t\t\t\t\t\t\t\t\t\t\tcompany as company, \r\n\t\t\t\t\t\t\t\t\t\t\t\tpm.method as method,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttotal_net as net, \r\n\t\t\t\t\t\t\t\t\t\t\t\ttotal_vat as vat, \r\n\t\t\t\t\t\t\t\t\t\t\t\ttotal as total,\r\n\t\t\t\t\t\t\t\t\t\t\t\ts.status as status", 'number, creationdate');
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Purchases Invoices List');
     $grid['headers']['subtitle'] = $translator->translate('List of the the purchases invoices');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($invoices[0])) {
         $total = 0;
     }
     $vat = 0;
     $grandtotal = 0;
     // Create the columns of the grid
     $grid['columns'][] = array("value" => $translator->translate('Date'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('Number'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Company'));
     $grid['columns'][] = array("value" => $translator->translate('Method'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Total Net'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('VAT'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Status'), 'size' => 50);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($invoices as $item) {
         $values = array_values($item);
         array_shift($values);
         $grid['records'][] = $values;
         $total += is_numeric($values[4]) ? $values[4] : 0;
         $vat += is_numeric($values[5]) ? $values[5] : 0;
         $grandtotal += is_numeric($values[6]) ? $values[6] : 0;
     }
     $grid['records'][] = array('', '', '', '', $total, $vat, $grandtotal, '');
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 10
0
 /**
  * Execute the request of the admin user to change the password
  */
 public function dopasswordAction()
 {
     $code = $this->getRequest()->getParam('id');
     $user = AdminUser::checkMD5CredencialsByIspEmail($code);
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $form = new Admin_Form_PasswordForm(array('action' => '/admin/login/password', 'method' => 'post'));
     if (!empty($user)) {
         $isp = Isp::getActiveISP();
         // Get the template from the main email template folder
         $retval = Shineisp_Commons_Utilities::getEmailTemplate('isp_password_changed');
         $newpassword = AdminUser::resetPassword($user['user_id']);
         if (!empty($retval)) {
             $subject = $retval['subject'];
             $template = $retval['template'];
             $subject = str_replace("[lastname]", $user['lastname'], $subject);
             $template = str_replace("[lastname]", $user['lastname'], $template);
             $template = str_replace("[admin_url]", "http://" . $_SERVER['HTTP_HOST'] . "/admin/", $template);
             $template = str_replace("[email]", $user['email'], $template);
             $template = str_replace("[password]", $newpassword, $template);
             $template = str_replace("[signature]", $isp['company'], $template);
             Shineisp_Commons_Utilities::SendEmail($user['email'], $user['email'], null, $subject, $template);
             $this->view->message = $translator->translate('An email has been sent with the new login credentials');
         }
     }
     $this->view->passwordform = $form;
     return $this->render('password');
     // re-render the login form
 }
Ejemplo n.º 11
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the payment table
     $orders = self::get_payments($items, "p.payment_id,\r\n\t\t\t\t\t\t\t\t\t\t\t  o.order_id as orderid,\r\n\t\t\t\t\t\t\t\t\t\t\t  o.order_date as orderdate,\r\n\t\t\t\t\t\t\t\t\t\t\t  i.number as invoice,\r\n                                              DATE_FORMAT(p.paymentdate, '" . Settings::getMySQLDateFormat('dateformat') . "') as paymentdate,\r\n                                              CONCAT(c.firstname, ' ', c.lastname, ' ', c.company) as customer,\r\n                                              CONCAT(r.firstname, ' ', r.lastname, ' ', r.company) as reseller,\r\n                                              p.reference as reference,\r\n                                              p.confirmed as confirmed,\r\n                                              p.income as income,\r\n                                              p.outcome as outcome,\r\n\t\t\t\t\t\t\t\t\t\t\t  o.grandtotal as grandtotal\r\n                                              ", 'o.order_date');
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Payment Transaction Listing');
     $grid['headers']['subtitle'] = $translator->translate('List of the payment transactions');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($orders[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Payment'), 'size' => 50);
         $grid['columns'][] = array("value" => $translator->translate('Order'), 'size' => 50);
         $grid['columns'][] = array("value" => $translator->translate('Order Date'), 'size' => 50);
         $grid['columns'][] = array("value" => $translator->translate('Invoice'), 'size' => 100);
         $grid['columns'][] = array("value" => $translator->translate('Transaction Date'), 'size' => 100);
         $grid['columns'][] = array("value" => $translator->translate('Company'));
         $grid['columns'][] = array("value" => $translator->translate('Reseller'));
         $grid['columns'][] = array("value" => $translator->translate('Reference'));
         $grid['columns'][] = array("value" => $translator->translate('Confirmed'));
         $grid['columns'][] = array("value" => $translator->translate('Income'), 'size' => 50);
         $grid['columns'][] = array("value" => $translator->translate('Expense'), 'size' => 50);
         $grid['columns'][] = array("value" => $translator->translate('Grand Total'), 'size' => 50);
         // Getting the records values and delete the first column the customer_id field.
         foreach ($orders as $item) {
             $values = array_values($item);
             $grid['records'][] = $values;
         }
         // Create the PDF
         die($pdf->create($grid));
     }
     return false;
 }
Ejemplo n.º 12
0
 /**
  * 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');
 }
Ejemplo n.º 13
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulkexport($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $fields = " t.ticket_id,\n\t\t\t\t\tt.subject as subject, \n\t\t\t\t\ttc.category as category, \n\t\t\t\t\ts.status as status, \n\t\t\t\t\tDATE_FORMAT(t.date_open, '" . Settings::getMySQLDateFormat('dateformat') . " %H:%i') as creation_date, \n\t\t\t\t\tDATE_FORMAT(t.date_updated, '" . Settings::getMySQLDateFormat('dateformat') . " %H:%i') as updated_at, \n\t\t\t\t\tCONCAT(c.firstname, ' ', c.lastname) as fullname,\n\t\t\t\t\tc.company as company";
     // Get the records from the customer table
     $tickets = self::get_tickets($items, $fields);
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Tickets List');
     $grid['headers']['subtitle'] = $translator->translate('List of the selected tickets');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($tickets[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Subject'), 'size' => 100);
     }
     $grid['columns'][] = array("value" => $translator->translate('Category'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Status'));
     $grid['columns'][] = array("value" => $translator->translate('Creation Date'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('Upload Date'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Fullname'), 'size' => 80);
     $grid['columns'][] = array("value" => $translator->translate('Company'), 'size' => 80);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($tickets as $ticket) {
         $values = array_values($ticket);
         array_shift($values);
         $grid['records'][] = $values;
     }
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 14
0
 public static function optIn($email)
 {
     if (Shineisp_Commons_Utilities::isEmail($email)) {
         // Check if the email is already registered
         $retval = Doctrine::getTable('NewslettersSubscribers')->findOneBy('email', $email);
         if (empty($retval)) {
             // Save the new email address
             $subscriber = new NewslettersSubscribers();
             $subscriber->email = $email;
             $subscriber->subscriptiondate = date('Y-m-d H:i:s');
             if ($subscriber->trySave()) {
                 // Send the email to confirm the subscription
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('new_subscriber');
                 if ($retval) {
                     $subject = $retval['subject'];
                     $template = $retval['template'];
                     $isp = Isp::getActiveISP();
                     $template = str_replace("[signature]", $isp['company'], $template);
                     Shineisp_Commons_Utilities::SendEmail($isp['email'], $email, null, $subject, $template);
                 }
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 15
0
 public static function getEmailTemplate($template, $language_id = null)
 {
     $fallbackLocale = "en_US";
     $subject = "";
     $locale = Shineisp_Registry::get('Zend_Locale')->toString();
     if (empty($language_id)) {
         $language_id = Languages::get_language_id($locale);
     } else {
         $locale = Languages::get_locale($language_id);
     }
     $EmailTemplate = EmailsTemplates::findByCode($template, null, false, $language_id);
     // Template missing from DB. Let's add it.
     if (!is_object($EmailTemplate) || !isset($EmailTemplate->EmailsTemplatesData) || !isset($EmailTemplate->EmailsTemplatesData->{0}) || !isset($EmailTemplate->EmailsTemplatesData->{0}->subject)) {
         $filename = PUBLIC_PATH . "/languages/emails/" . $locale . "/" . $template . ".htm";
         // Check if the file exists
         if (!file_exists($filename)) {
             $filename = PUBLIC_PATH . "/languages/emails/" . $fallbackLocale . "/" . $template . ".htm";
             Shineisp_Commons_Utilities::log("This email template has not been found: {$filename}");
             $language_id = 1;
             // set the right default language id
             // Also the fallback template is missing. Something strange is going on.....
             if (!file_exists($filename)) {
                 Shineisp_Commons_Utilities::log("The default email template has not been found: {$filename}");
                 return array('template' => "Template: " . $template . " not found", 'subject' => $template);
             }
         }
         // Get the content of the file
         $body = '';
         foreach (file($filename) as $line) {
             // Get the subject written in the template file
             if (preg_match('/<!--@subject\\s*(.*?)\\s*@-->/', $line, $matches)) {
                 $subject = $matches[1];
                 // Get the subject
                 $subject = trim($subject);
                 continue;
             }
             // Delete all the comments
             $body .= preg_replace('#\\{\\*.*\\*\\}#suU', '', $line);
         }
         $isp = Isp::getActiveISP();
         $body = trim($body);
         $subject = trim($subject);
         // check if the string contains html tags and if it does not contain tags
         // means that it is a simple text. In this case add the tag "<br/>" for each return carrier
         if (!self::isHtml($body)) {
             $body = nl2br($body);
         }
         // Store mail in DB
         $array = array('type' => 'general', 'name' => $template, 'code' => $template, 'plaintext' => 0, 'active' => 1, 'fromname' => is_array($isp) && isset($isp['company']) ? $isp['company'] : 'ShineISP', 'fromemail' => is_array($isp) && isset($isp['email']) ? $isp['email'] : '*****@*****.**', 'subject' => $subject, 'html' => $body);
         // Save the data
         EmailsTemplates::saveAll(null, $array, $language_id);
         // Return the email template
         return array_merge($array, array('template' => $body, 'subject' => $subject));
     }
     // template is numeric but there is not template in db. something strange happened. Exit.
     if (is_numeric($template) && !is_object($EmailTemplate)) {
         return false;
     }
     $email = array('subject' => $EmailTemplate->EmailsTemplatesData->{0}->subject, 'plaintext' => intval($EmailTemplate->plaintext), 'fromname' => $EmailTemplate->EmailsTemplatesData->{0}->fromname, 'fromemail' => $EmailTemplate->EmailsTemplatesData->{0}->fromemail, 'cc' => $EmailTemplate->cc, 'bcc' => $EmailTemplate->bcc, 'template' => '');
     if (!empty($EmailTemplate->EmailsTemplatesData->{0}->html) && !empty($EmailTemplate->EmailsTemplatesData->{0}->text)) {
         // Both version are present
         $body = intval($EmailTemplate->plaintext) ? $EmailTemplate->EmailsTemplatesData->{0}->text : $EmailTemplate->EmailsTemplatesData->{0}->html;
     } else {
         if (empty($EmailTemplate->EmailsTemplatesData->{0}->html) && !empty($EmailTemplate->EmailsTemplatesData->{0}->text)) {
             // Only TEXT version
             $body = $EmailTemplate->EmailsTemplatesData->{0}->text;
         } else {
             // Only HTML version
             $body = $EmailTemplate->EmailsTemplatesData->{0}->html;
         }
     }
     $email['template'] = $body;
     return $email;
 }
Ejemplo n.º 16
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the reviews table
     $reviews = self::get_reviews($items, "review_id, nick, subject, review");
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Product Reviews List');
     $grid['headers']['subtitle'] = $translator->translate('List of the product reviews.');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($reviews[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Nick'), 'size' => 100);
     }
     $grid['columns'][] = array("value" => $translator->translate('Subject'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('review'));
     // Getting the records values and delete the first column the customer_id field.
     foreach ($reviews as $item) {
         $values = array_values($item);
         array_shift($values);
         $grid['records'][] = $values;
     }
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 17
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the order table
     $creditnotes = self::get_items($items, "creditnote_id, i.number as invoicenum, DATE_FORMAT(o.order_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as orderdate, c.company as company, CONCAT(c.firstname, ' ', c.lastname) as fullname, cn.total as total, cn.total_vat as vat, cn.total as grandtotal, s.status as status", 'cn.creationdate');
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Credit Note List');
     $grid['headers']['subtitle'] = $translator->translate('List Credit Notes');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($creditnotes[0])) {
         // Create the columns of the grid
         $grid['columns'][] = array("value" => $translator->translate('Credit Note'), 'size' => 50);
     }
     $grid['columns'][] = array("value" => $translator->translate('Invoice'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Date'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('Company'));
     $grid['columns'][] = array("value" => $translator->translate('Fullname'));
     $grid['columns'][] = array("value" => $translator->translate('Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('VAT'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Grand Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Status'), 'size' => 100);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($creditnotes as $item) {
         $values = array_values($item);
         $grid['records'][] = $values;
     }
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }
Ejemplo n.º 18
0
 /**
  * export the content in a pdf file
  * @param array $items
  */
 public function bulk_pdf_export($items)
 {
     $isp = Isp::getActiveISP();
     $pdf = new Shineisp_Commons_PdfList();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     // Get the records from the order table
     $orders = self::get_invoices($items, "invoice_id, number as num, order_id as orderid, DATE_FORMAT(invoice_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as invoicedate, \n\t\tc.company as company, CONCAT(c.firstname, ' ', c.lastname) as fullname, o.total as total, o.vat as vat, o.grandtotal as grandtotal,", 'number, invoice_date');
     // Create the PDF header
     $grid['headers']['title'] = $translator->translate('Invoices Listing');
     $grid['headers']['subtitle'] = $translator->translate('Here you can see the invoices listing');
     $grid['footer']['text'] = $isp['company'] . " - " . $isp['website'];
     if (!empty($orders[0])) {
         $total = 0;
     }
     $vat = 0;
     $grandtotal = 0;
     // Create the columns of the grid
     $grid['columns'][] = array("value" => $translator->translate('Invoice'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Order'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Date'), 'size' => 100);
     $grid['columns'][] = array("value" => $translator->translate('Company'));
     $grid['columns'][] = array("value" => $translator->translate('Fullname'));
     $grid['columns'][] = array("value" => $translator->translate('Total'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('VAT'), 'size' => 50);
     $grid['columns'][] = array("value" => $translator->translate('Grand Total'), 'size' => 50);
     // Getting the records values and delete the first column the customer_id field.
     foreach ($orders as $item) {
         $values = array_values($item);
         array_shift($values);
         $grid['records'][] = $values;
         $total += is_numeric($values[5]) ? $values[5] : 0;
         $vat += is_numeric($values[6]) ? $values[6] : 0;
         $grandtotal += is_numeric($values[7]) ? $values[7] : 0;
     }
     $grid['records'][] = array('', '', '', '', $translator->translate('Totals'), $total, $vat, $grandtotal);
     // Create the PDF
     die($pdf->create($grid));
     return false;
 }