Exemplo n.º 1
0
 /**
  * a fast way to signin in the user profile
  */
 public function fastloginAction()
 {
     $request = $this->getRequest();
     $NS = new Zend_Session_Namespace('Default');
     $registry = Shineisp_Registry::getInstance();
     $translator = $registry->Zend_Translate;
     $secretKey = $request->getParam('id');
     if (!empty($secretKey)) {
         $sha1 = Shineisp_Commons_Hasher::unhash_string($secretKey);
         // Trying to get the user in the database
         $retval = Customers::getCustomerbyEmailSha1($sha1);
         if (count($retval) == 0) {
             $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $secretKey);
             $NS->customer = null;
             $this->view->message = $translator->translate('Email Address or Password is incorrect.');
             return $this->_helper->viewRenderer('generic');
         } else {
             $NS->customer = $retval[0];
             // Set the default control panel language
             if (!empty($retval[0]['language'])) {
                 $lang = $retval[0]['language'];
             }
         }
     }
     // If the software detects that there is a redirect to a specific page then ...
     if (!empty($NS->goto) && is_array($NS->goto)) {
         $this->_helper->redirector($NS->goto['action'], $NS->goto['controller'], $NS->goto['module'], $NS->goto['options']);
     }
     if (!empty($lang)) {
         $this->_helper->redirector('index', 'dashboard', 'default', array('lang' => $lang));
         // back to login page
     } else {
         $this->_helper->redirector('index', 'dashboard', 'default');
     }
 }
Exemplo n.º 2
0
 /**
  * saveAll
  * Save all the data in the database
  * @param array $params
  * @param integer $id
  */
 public static function saveAll($params, $id = "")
 {
     $orders = new Orders();
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $currentStatus = "";
     try {
         // Set the new values
         if (is_numeric($id)) {
             $orders = Doctrine::getTable('Orders')->find($id);
             $currentStatus = $orders->status_id;
             // used to detect status changes
         }
         if (!empty($params) && is_array($params)) {
             $params['date_start'] = !empty($params['date_start']) ? $params['date_start'] : new Zend_Date();
             $params['order_date'] = !empty($params['order_date']) ? $params['order_date'] : new Zend_Date();
             $customer = Customers::getAllInfo($params['customer_id']);
             $isp_id = $customer['isp_id'];
             $orders->order_date = Shineisp_Commons_Utilities::formatDateIn($params['order_date']);
             $orders->customer_id = $params['customer_id'];
             $orders->isp_id = $isp_id;
             $orders->status_id = $params['status_id'];
             $orders->invoice_id = !empty($params['invoice_id']) ? $params['invoice_id'] : null;
             $orders->note = $params['note'];
             $orders->is_renewal = $params['is_renewal'] == 1 ? 1 : 0;
             $orders->expiring_date = Shineisp_Commons_Utilities::formatDateIn($params['expiring_date']);
             $orders->vat = $params['vat'];
             $orders->total = $params['total'];
             $orders->grandtotal = $params['total'] + $params['vat'];
             // Save the data
             $orders->save();
             $id = is_numeric($id) ? $id : $orders->getIncremented();
             // Status changed? Let's call set_status. This is needed to properly log all status change.
             if (isset($params['status_id']) && $params['status_id'] != $currentStatus) {
                 self::logStatusChange($id, $params['status_id']);
             }
             // Add a fastlink to a order
             $link_exist = Fastlinks::findlinks($id, 'orders');
             $link = new Fastlinks();
             if (count($link_exist) == 0) {
                 $link->controller = "orders";
                 $link->action = "edit";
                 $link->params = json_encode(array('id' => $id));
                 $link->customer_id = $params['customer_id'];
                 $link->sqltable = "orders";
                 $link->id = $id;
                 $link->code = Shineisp_Commons_Utilities::GenerateRandomString();
             } else {
                 $link = Doctrine::getTable('Fastlinks')->find($link_exist[0]['fastlink_id']);
                 $link->code = $params['fastlink'];
             }
             $link->save();
             // Save the message note and send an alert
             if (!empty($params['message'])) {
                 $order = self::getAllInfo($id, null, true);
                 $link = Fastlinks::findlinks($id, $params['customer_id'], 'orders');
                 $isp = Isp::find($isp_id);
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('order_message');
                 if ($retval) {
                     $in_reply_to = md5($id);
                     // Save the message written by the ISP owner
                     Messages::addMessage($params['message'], null, null, $id, null, $isp_id);
                     // Create the array with all the placeholders
                     $placeholders['fullname'] = $order[0]['Customers']['firstname'] . " " . $order[0]['Customers']['lastname'];
                     $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $link[0]['code'];
                     $placeholders['orderid'] = sprintf("%03s", $id) . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']);
                     $placeholders['messagetype'] = $translator->translate('Order Details');
                     $placeholders['message'] = $params['message'];
                     Shineisp_Commons_Utilities::sendEmailTemplate(Contacts::getEmails($order[0]['Customers']['customer_id']), 'order_message', $placeholders, $in_reply_to, null, null, null, $order[0]['Customers']['language_id']);
                     // Change the URL for the administrator
                     $placeholders['url'] = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/" . $link[0]['code'] . "/keypass/" . Shineisp_Commons_Hasher::hash_string($isp->email);
                     // Send a message to the administrator
                     Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'order_message_admin', $placeholders, $in_reply_to);
                 }
             }
             // Saving the domain
             if (!empty($params['domains_selected'])) {
                 self::SaveDomainsDetails($params, $id);
             } else {
                 if (!empty($params['products'])) {
                     $date_end = null;
                     // Get the product information
                     $product = Products::getAllInfo($params['products']);
                     // Manage the details of the order
                     if (!empty($params['billingcycle_id'])) {
                         $months = BillingCycle::getMonthsNumber($params['billingcycle_id']);
                         // Add months to the starting date
                         if ($months > 0) {
                             $params['date_end'] = Shineisp_Commons_Utilities::add_date($params['date_start'], null, $months);
                         }
                     }
                     // Format the dates before to save them in the database
                     $params['date_end'] = Shineisp_Commons_Utilities::formatDateIn($params['date_end']);
                     $params['date_start'] = Shineisp_Commons_Utilities::formatDateIn($params['date_start']);
                     if (!empty($product['Taxes']['tax_id'])) {
                         $vat = $params['price'] * $product['Taxes']['percentage'] / 100;
                         $subtotal = $params['price'] * ($product['Taxes']['percentage'] + 100) / 100;
                         $percentage = $product['Taxes']['percentage'];
                     } else {
                         $vat = 0;
                         $subtotal = $params['price'];
                         $percentage = 0;
                     }
                     $details = new OrdersItems();
                     $details->order_id = $id;
                     $details->quantity = $params['quantity'];
                     $details->cost = Products::getCost($params['products']);
                     $details->price = $params['price'];
                     $details->date_start = $params['date_start'];
                     $details->date_end = $params['date_end'];
                     $details->billing_cycle_id = !empty($params['billingcycle_id']) ? $params['billingcycle_id'] : null;
                     $details->product_id = $params['products'];
                     $details->description = $params['description'];
                     $details->status_id = $params['status_id'];
                     $details->vat = $vat;
                     $details->percentage = $percentage;
                     $details->subtotal = $subtotal;
                     if ($product['type'] == "hosting") {
                         // Get all the product attributes
                         $attrs = ProductsAttributes::getAttributebyProductID($params['products']);
                         // Create the system attributes parameters
                         foreach ($attrs as $attr) {
                             if ($attr['system'] && !empty($attr['ProductsAttributesIndexes'][0]['value'])) {
                                 $hostingplan[$attr['code']] = $attr['ProductsAttributesIndexes'][0]['value'];
                             }
                         }
                         $details->parameters = json_encode($hostingplan);
                     }
                     $details->save();
                     $detail_id = $details->getIncremented();
                     // Attaching of the service a particular domain. It's not a mandatory field because the services and the products can be bought also without a domain
                     if (is_numeric($params['referdomain']) && $params['referdomain'] > 0) {
                         $ordersitemsdomains = new OrdersItemsDomains();
                         $ordersitemsdomains->domain_id = $params['referdomain'];
                         $ordersitemsdomains->order_id = $id;
                         $ordersitemsdomains->orderitem_id = $detail_id;
                         $ordersitemsdomains->save();
                     }
                 }
             }
             // Handle the payment transaction
             if (!empty($params['paymentdate'])) {
                 Payments::addPayment($id, $params['reference'], $params['bank_id'], $params['confirmed'], $params['income'], $params['paymentdate'], $params['customer_id'], $params['payment_description']);
             }
             // Set the status of the order
             OrdersItems::setNewStatus($id, $params['status_id']);
             // Update the totals of the order selected
             self::updateTotalsOrder($id);
             return $id;
         }
     } catch (Exception $e) {
         die($e->getMessage());
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Signup Action Controller
  */
 public function dosignupAction()
 {
     $request = $this->getRequest();
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = new Default_Form_SignupForm(array('action' => '/customer/dosignup', 'method' => 'post'));
     $this->view->form = $form;
     $post = $request->getPost();
     if (is_array($post)) {
         if (!$form->isValid($request->getPost())) {
             // Invalid entries
             $this->view->form = $form;
             return $this->_helper->viewRenderer('signup');
             // re-render the signup form
         }
         // Get the values posted
         $params = $form->getValues();
         // Create the user
         Customers::Create($params);
         // Send the user to the auto login page
         $url = '/default/index/fastlogin/id/' . Shineisp_Commons_Hasher::hash_string($params['email']);
         $redirector->gotoUrl($url);
     }
 }
Exemplo n.º 4
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'));
 }
Exemplo n.º 5
0
 /**
  * editAction
  * Get a record and populate the application form 
  * @return unknown_type
  */
 public function editAction()
 {
     $form = $this->getForm('/admin/customers/process');
     $id = $this->getRequest()->getParam('id');
     $this->view->title = $this->translator->translate("Customer edit");
     $this->view->description = $this->translator->translate("Here you can edit the customer details.");
     // 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/customers/list", "label" => $this->translator->translate('List'), "params" => array('css' => null)), array("url" => "/admin/customers/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     if (!empty($id) && is_numeric($id)) {
         $rs = $this->customers->getAllInfo($id);
         if (!empty($rs)) {
             $rs += CustomAttributes::getElementsValues($id, 'customers');
             $rs['birthdate'] = Shineisp_Commons_Utilities::formatDateOut($rs['birthdate']);
             $this->view->id = $id;
             $form->populate($rs);
             if (!empty($rs['company'])) {
                 $this->view->title = $rs['company'] . " - " . $rs['firstname'] . " " . $rs['lastname'];
             } else {
                 $this->view->title = $rs['firstname'] . " " . $rs['lastname'];
             }
             $this->view->buttons[] = array("url" => "/admin/orders/new", "label" => $this->translator->translate('New Order'), "params" => array('css' => null));
             $this->view->buttons[] = array("url" => "/admin/customers/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => null));
             $this->view->buttons[] = array("url" => "/default/index/fastlogin/id/" . Shineisp_Commons_Hasher::hash_string($rs['email']), "label" => $this->translator->translate('Public profile'), "params" => array('css' => null));
         }
     }
     $this->view->mex = $this->getRequest()->getParam('mex');
     $this->view->mexstatus = $this->getRequest()->getParam('status');
     $this->view->editmode = true;
     $this->view->addressesdatagrid = $this->addressesGrid();
     $this->view->contactsdatagrid = $this->contactsGrid();
     $this->view->filesdatagrid = $this->filesGrid();
     $this->view->domainsdatagrid = $this->domainsGrid();
     $this->view->servicesdatagrid = $this->servicesGrid();
     $this->view->ordersdatagrid = $this->ordersGrid();
     $this->view->tickets = $this->ticketsGrid();
     $this->view->invoicesdatagrid = $this->invoicesGrid();
     $this->view->sentmailsdatagrid = $this->sentmailsGrid();
     $this->view->form = $form;
     $this->render('applicantform');
 }
Exemplo n.º 6
0
 /**
  * Send ticket by email
  * 
  * @param integer $id
  * @param boolean $isTicket
  * @param string $attachment
  */
 public static function send($id, $isTicket = true, $attachment = null)
 {
     $isp = Isp::getActiveISP();
     $placeholders = array();
     $customer_url = "";
     $admin_url = "";
     if ($isTicket) {
         $ticket = self::getAllInfo($id, null, true);
         $customer = $ticket[0]['Customers'];
         $operator = AdminUser::getAllInfo($ticket[0]['user_id']);
     } else {
         $ticket = TicketsNotes::getAllInfo($id);
         $customer = $ticket[0]['Tickets']['Customers'];
         $operator = AdminUser::getAllInfo($ticket[0]['Tickets']['user_id']);
     }
     if (!empty($ticket[0])) {
         if ($isp) {
             $ispmail = explode("@", $isp['email']);
             $retval = Shineisp_Commons_Utilities::getEmailTemplate('ticket_message');
             if ($retval) {
                 $s = $retval['subject'];
                 $ticketid = $ticket[0]['ticket_id'];
                 $in_reply_to = md5($ticketid);
                 $ispmail = "noreply@" . $ispmail[1];
                 $rec = Fastlinks::findlinks($ticketid, $customer['customer_id'], 'tickets');
                 if (!empty($rec[0]['code'])) {
                     $customer_url = "http://" . $_SERVER['HTTP_HOST'] . "/index/link/id/" . $rec[0]['code'];
                     $admin_url = "http://" . $_SERVER['HTTP_HOST'] . "/admin/login/link/id/" . $rec[0]['code'];
                 }
                 // Check the attachments
                 if (!empty($attachment) && file_exists(PUBLIC_PATH . $attachment)) {
                     $attachment = PUBLIC_PATH . $attachment;
                 }
                 if ($isTicket) {
                     $placeholders['subject'] = $ticket[0]['subject'];
                     $placeholders['description'] = $ticket[0]['description'];
                     $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['date_open']);
                     $placeholders['status'] = $ticket[0]['Statuses']['status'];
                 } else {
                     $placeholders['subject'] = $ticket[0]['Tickets']['subject'];
                     $placeholders['description'] = $ticket[0]['note'];
                     $placeholders['date_open'] = Shineisp_Commons_Utilities::formatDateOut($ticket[0]['Tickets']['date_open']);
                     $placeholders['status'] = $ticket[0]['Tickets']['Statuses']['status'];
                 }
                 $placeholders['customer'] = $customer['firstname'] . " " . $customer['lastname'] . " " . $customer['company'];
                 $placeholders['link'] = $customer_url;
                 $placeholders['company'] = $isp['company'];
                 $placeholders['issue_number'] = $ticketid;
                 $placeholders['operator'] = $operator['lastname'] . " " . $operator['firstname'];
                 // Send a message to the customer
                 Shineisp_Commons_Utilities::sendEmailTemplate(Contacts::getEmails($customer['customer_id']), 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp, $customer['language_id']);
                 // Update the link for the administrator email
                 $placeholders['link'] = $admin_url . "/keypass/" . Shineisp_Commons_Hasher::hash_string($operator['email']);
                 Shineisp_Commons_Utilities::sendEmailTemplate($isp['email'], 'ticket_message', $placeholders, $in_reply_to, $attachment, null, $isp);
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 7
0
 /**
  * Check the user credencials by the secret key
  * @param string $email
  */
 public static function checkIspCredencialsBySecretKey($secretKey)
 {
     // Remove salt from hashed string
     $string = Shineisp_Commons_Hasher::unhash_string($secretKey);
     // Check if the user exists!
     $record = Doctrine_Query::create()->select('u.*, r.*, p.*, s.*')->from('AdminUser u')->leftJoin('u.Isp i')->leftJoin('u.AdminRoles r')->leftJoin('r.AdminPermissions p')->leftJoin('p.AdminResources s')->where('SHA1(i.email) = ?', $string)->limit(1)->execute(array(), Doctrine::HYDRATE_ARRAY);
     if ($record) {
         return !empty($record[0]) ? $record[0] : FALSE;
     } else {
         return NULL;
     }
 }