public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'creationdate', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Date'), 'title' => $translate->_('eg: 01/11/2010'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'expiringdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'title' => $translate->_('eg: 01/11/2011'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'paymentdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Payment Date'), 'title' => $translate->_('eg: 01/11/2010'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('select', 'category_id', array('label' => $translate->_('Category'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('category_id')->setAllowEmpty(false)->setMultiOptions(PurchaseCategories::getList()); $this->addElement('select', 'method_id', array('label' => $translate->_('Payment Method'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('method_id')->setAllowEmpty(false)->setMultiOptions(PaymentsMethods::getList()); $this->addElement('text', 'number', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company'), 'required' => true, 'title' => $translate->_('eg: Google inc.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_net', array('filters' => array('StringTrim'), 'label' => $translate->_('Total Net'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_vat', array('filters' => array('StringTrim'), 'label' => $translate->_('Total VAT'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total', array('filters' => array('StringTrim'), 'label' => $translate->_('Total'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Note'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control')); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('adminuploadlimit'); $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $filetypes = Settings::findbyParam('adminuploadfiletypes', 'Admin'); $file = $this->createElement('file', 'document', array('label' => $translate->_('Document'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $filetypes, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle')); $file->addValidator('Extension', false, $filetypes)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $file->setValueDisabled(true); $file->setRequired(false); $this->addElement($file); } $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders')); $this->addElement('hidden', 'purchase_id'); }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'nick', array('filters' => array('StringTrim'), 'required' => true, 'description' => $translate->_('Add your own nickname'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Nick'), 'class' => 'form-control')); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write down a subject of the review'), 'label' => $translate->_('Subject'), 'class' => 'form-control')); $this->addElement('select', 'referer', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Where did you find us?'), 'label' => $translate->_('Who is Talking About Us?'), 'class' => 'form-control', 'multiOptions' => array('Google' => 'Google', 'Bing' => 'Bing', 'Yahoo' => 'Yahoo', 'Other Search Engine' => 'Other Search Engine', 'Websites' => 'Websites/Blogs', 'Magento Commerce' => 'Magento Commerce', 'Friend suggestion' => 'Friend suggestion'))); $this->addElement('text', 'city', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Which is your own city? If added we will promote your review in our website using Google Maps'), 'label' => $translate->_('City'), 'class' => 'form-control')); $this->addElement('text', 'email', array('filters' => array('StringTrim'), 'required' => true, 'validators' => array('EmailAddress'), 'decorators' => array('Bootstrap'), 'description' => 'Your email will be not published', 'label' => $translate->_('Email'), 'class' => 'form-control')); $this->addElement('select', 'stars', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Stars'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multiOptions' => array(1 => '1 ' . $translate->_('Star'), 2 => '2 ' . $translate->_('Stars'), 3 => '3 ' . $translate->_('Stars'), 4 => '4 ' . $translate->_('Stars'), 5 => '5 ' . $translate->_('Stars')))); $this->addElement('textarea', 'review', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'required' => true, 'description' => $translate->_('Write down your review with details and you will earn points and discounts'), 'label' => $translate->_('Review'), 'class' => 'form-control', 'rows' => '8')); $privKey = Settings::findbyParam('recaptcha_private_key'); $pubKey = Settings::findbyParam('recaptcha_public_key'); if (!empty($pubKey) && !empty($privKey)) { $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Captcha Check'), 'description' => $translate->_('Type the characters you see in the picture below.'), 'captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha))); $this->addElement($captcha); } else { $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Write the chars to the field'), 'captcha' => array('captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'font' => PUBLIC_PATH . '/resources/fonts/arial.ttf', 'imgDir' => PUBLIC_PATH . '/tmp', 'imgUrl' => '/tmp/'))); $this->addElement($captcha); } $this->addElement('submit', 'save', array('required' => false, 'label' => $translate->_('Publish your Review'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary')); $this->addElement('hidden', 'product_id'); }
public function init() { $NS = new Zend_Session_Namespace('Default'); $translate = Shineisp_Registry::get('Zend_Translate'); // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElement('select', 'domain_id', array('decorators' => array('Bootstrap'), 'required' => false, 'label' => $translate->_('Domain'), 'description' => $translate->_('Choose the domain name reference'), 'class' => 'form-control large-input')); $this->getElement('domain_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList(true, $NS->customer['customer_id'])); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'title' => $translate->_('Write here a subject of the issue.'), 'label' => $translate->_('Subject'), 'description' => $translate->_('Write here the domain name or a simple description of the problem.'), 'class' => 'form-control large-input')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Body Message'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here all the information.'), 'rows' => '8', 'class' => 'form-control wysiwyg-simple')); $this->addElement('select', 'status', array('filters' => array('StringTrim'), 'label' => $translate->_('Set the issue status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input', 'multioptions' => array('' => '', Statuses::id("solved", "tickets") => $translate->_('Solved'), Statuses::id("closed", "tickets") => $translate->_('Closed')))); $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'description' => 'Select a category.', 'class' => 'form-control large-input')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList(true)); if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('useruploadlimit'); $Types = Settings::findbyParam('useruploadfiletypes'); if (empty($MBlimit)) { $MBlimit = 1; } if (empty($Types)) { $Types = "zip,jpg"; } $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)))); $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } else { $this->addElement('hidden', 'attachments'); } $this->addElement('submit', 'submit', array('label' => $translate->_('Send help request'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary btn-lg')); $this->addElement('hidden', 'ticket_id'); }
/** * showblock * Handle the XML Blocks * @param unknown_type $side */ public function showblock($side) { $ns = new Zend_Session_Namespace('Admin'); $languageID = Languages::get_language_id($ns->lang); $record = array(); $blocks = array(); // Get the main variables $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $customskin = Settings::findbyParam('adminskin'); $skin = !empty($customskin) ? $customskin : "base"; // call the placeholder view helper for each side parsed echo $this->view->placeholder($side); // Get all the xml blocks $xmlblocks = Shineisp_Commons_Layout::getBlocks($module, $side, $controller, $skin); if (!empty($xmlblocks)) { $blocks['reference'] = $xmlblocks; } if (!empty($blocks['reference'])) { $blocks['reference'] = Shineisp_Commons_Utilities::columnSort($blocks['reference'], 'position'); } if (isset($blocks['reference']['block'])) { $this->Iterator($blocks['reference'], $side); } elseif (isset($blocks['reference'][0])) { foreach ($blocks['reference'] as $block) { $this->Iterator($block, $side); } } $this->view->module = $module; $this->view->controller = $controller; $this->view->action = $action; }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElementPrefixPath('Default', APPLICATION_PATH . '/modules/default/forms/validate/', 'validate'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'fullname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Fullname'), 'title' => $translate->_('Write here your firstname and lastname.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company'), 'title' => $translate->_('Write here your company name.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $email = $this->createElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'decorators' => array('Bootstrap'), 'validators' => array('EmailAddress'), 'required' => true, 'label' => $translate->_('Email'), 'title' => $translate->_('Write here your email'), 'class' => 'form-control large-input')); $this->addElement($email); $status = $this->addElement('select', 'subject', array('label' => $translate->_('Subject'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $status = $this->getElement('subject')->setAllowEmpty(false)->setMultiOptions(array('Sales Question' => 'Sales Question', 'Billing Question' => 'Billing Question', 'Partnership Inquiry' => 'Partnership Inquiry', 'Website Feedback' => 'Website Feedback')); $this->addElement('textarea', 'message', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'required' => true, 'rows' => 5, 'description' => $translate->_('Write here your message.'), 'label' => $translate->_('Message'), 'class' => 'form-control')); $privKey = Settings::findbyParam('recaptcha_private_key'); $pubKey = Settings::findbyParam('recaptcha_public_key'); if (!empty($pubKey) && !empty($privKey)) { $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Captcha Check'), 'description' => $translate->_('Type the characters you see in the picture below.'), 'captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha))); $this->addElement($captcha); } else { $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Write the chars to the field'), 'captcha' => array('captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'font' => PUBLIC_PATH . '/resources/fonts/arial.ttf', 'imgDir' => PUBLIC_PATH . '/tmp', 'imgUrl' => '/tmp/'))); $this->addElement($captcha); } $this->addElement('submit', 'submit', array('required' => false, 'label' => $translate->_('Submit your request'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary bigbtn')); }
public function preStmtExecute(Doctrine_Event $event) { // Check if the administrator has enabled the query logging feature if (Settings::findbyParam('debug_queries')) { $breadcrumps = array(); $query = $event->getQuery(); $params = $event->getParams(); $callers = array_reverse(debug_backtrace(), true); $callers = array_slice($callers, 4, count($callers) - 10); foreach ($callers as $caller) { $class = !empty($caller['class']) ? $caller['class'] : null; $breadcrumps[] = $class . "->" . $caller['function']; } $strBreadcrump = "System: " . implode(" / ", $breadcrumps); //the below makes some naive assumptions about the queries being logged while (sizeof($params) > 0) { $param = array_shift($params); if (!is_numeric($param)) { $param = sprintf("'%s'", $param); } $query = substr_replace($query, $param, strpos($query, '?'), 1); } Shineisp_Commons_Utilities::log($query, "queries.log"); Shineisp_Commons_Utilities::log($strBreadcrump, "debug.log", Zend_Log::DEBUG); // Increase query counter $queryCount = Shineisp_Registry::isRegistered('querycount') ? Shineisp_Registry::get('querycount') : 0; $queryCount = $queryCount + 1; Shineisp_Registry::set('querycount', $queryCount); } }
public function querycount() { if (Settings::findbyParam('debug_queries')) { return "Queries: " . Shineisp_Registry::get('querycount'); } else { return null; } }
/** * * @param unknown_type $type * @return string */ public function paths($type = "") { switch ($type) { case "skin": // Get the custom skin folder path $skin = Settings::findbyParam('skin'); if (!empty($skin)) { return "/skins/default/{$skin}/"; } else { return "/skins/default/base/"; } break; case "css": // Get the custom skin css folder path $skin = Settings::findbyParam('skin'); if (!empty($skin)) { return "/skins/default/{$skin}/css/"; } else { return "/skins/default/base/css/"; } break; case "images": // Get the custom skin images folder path $skin = Settings::findbyParam('skin'); if (!empty($skin)) { return "/skins/default/{$skin}/images/"; } else { return "/skins/default/base/images/"; } break; case "js": // Get the custom skin javascript folder path $skin = Settings::findbyParam('skin'); if (!empty($skin)) { return "/skins/default/{$skin}/js/"; } else { return "/skins/default/base/js/"; } break; default: // Get the custom skin folder path $skin = Settings::findbyParam('skin'); if (!empty($skin)) { return "/skins/default/{$skin}/"; } else { return "/skins/default/base/"; } break; } }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'validators' => array('EmailAddress'), 'decorators' => array('Bootstrap'), 'required' => true, 'description' => $translate->_('Write your own email'), 'label' => $translate->_('Email'), 'class' => 'form-control')); $privKey = Settings::findbyParam('recaptcha_private_key'); $pubKey = Settings::findbyParam('recaptcha_public_key'); if (!empty($pubKey) && !empty($privKey)) { $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Captcha Check'), 'description' => $translate->_('Type the characters you see in the picture below.'), 'captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha))); $this->addElement($captcha); } $this->addElement('submit', 'submit', array('label' => $translate->_('Reset my password'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-danger')); }
public function productsAction() { $ns = new Zend_Session_Namespace(); $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><shineisp></shineisp>'); $localeID = $ns->idlang; $products = $xml->addChild('products'); try { // Get all the products $records = Products::getAll(null, $localeID); if (!empty($records)) { foreach ($records as $item) { $item['ProductsData'][0]['shortdescription'] = strip_tags($item['ProductsData'][0]['shortdescription']); $item['ProductsData'][0]['description'] = strip_tags($item['ProductsData'][0]['description']); $item['ProductsData'][0]['shortdescription'] = html_entity_decode($item['ProductsData'][0]['shortdescription'], ENT_NOQUOTES, "UTF-8"); $item['ProductsData'][0]['description'] = html_entity_decode($item['ProductsData'][0]['description'], ENT_NOQUOTES, "UTF-8"); $item['ProductsData'][0]['shortdescription'] = str_replace("&", "", $item['ProductsData'][0]['shortdescription']); $item['ProductsData'][0]['description'] = str_replace("&", "", $item['ProductsData'][0]['description']); $categories = products::get_text_categories($item['categories']); $categories = htmlspecialchars($categories); $product = $products->addChild('product'); $product->addAttribute('uuid', $item['uuid']); $product->addAttribute('id', $item['product_id']); $product->addAttribute('inserted_at', !empty($item['inserted_at']) ? strtotime($item['inserted_at']) : null); $product->addAttribute('updated_at', !empty($item['updated_at']) ? strtotime($item['updated_at']) : null); $product->addChild('sku', htmlentities($item['sku'])); if (!empty($item['ProductsMedia'][0]['path']) && file_exists(PUBLIC_PATH . $item['ProductsMedia'][0]['path'])) { $product->addChild('image', "http://" . $_SERVER['HTTP_HOST'] . $item['ProductsMedia'][0]['path']); } $product->addChild('name', !empty($item['ProductsData'][0]['name']) ? $item['ProductsData'][0]['name'] : null); $product->addChild('shortdescription', !empty($item['ProductsData'][0]['shortdescription']) ? "<![CDATA[" . $item['ProductsData'][0]['shortdescription'] . "]]>" : null); $product->addChild('description', !empty($item['ProductsData'][0]['description']) ? "<![CDATA[" . $item['ProductsData'][0]['description'] . "]]>" : null); $product->addChild('categories', $categories); $price = $product->addChild('price', Products::getPrice($item['product_id'])); $price->addAttribute('taxincluded', 0); $price->addAttribute('isrecurrent', products::isRecurring($item['product_id'])); $price->addAttribute('currency', Settings::findbyParam('currency')); } } header('Content-Type: text/xml; charset=utf-8'); die($xml->asXML()); } catch (Exception $e) { Shineisp_Commons_Utilities::log(__CLASS__ . " " . $e->getMessage()); die; } }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'label' => $translate->_('Subject'), 'class' => 'form-control')); $this->addElement('text', 'datetime', array('filters' => array('StringTrim'), 'label' => $translate->_('Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('select', 'sendemail', array('label' => $translate->_('Send Email'), 'description' => $translate->_('Send an email to the customer.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('1' => $translate->_('Yes'), '0' => $translate->_('No')))); $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList()); $this->addElement('select', 'customer_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Customer'), 'class' => 'form-control')); $this->getElement('customer_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Customers::getList()); $this->addElement('select', 'category', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control')); $this->getElement('category')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList()); $this->addElement('select', 'order_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Order reference'), 'class' => 'form-control')); $this->getElement('order_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Orders::getList(true)); $this->addElement('select', 'sibling_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Relationships'), 'class' => 'form-control')); $this->getElement('sibling_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false); $this->addElement('select', 'user_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Operator'), 'class' => 'form-control')); $this->getElement('user_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(AdminUser::getList()); #->setMultiOptions(AdminUser::getUserbyRoleID(AdminRoles::getIdRoleByName('operator'))); $this->addElement('select', 'status_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Status'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Statuses::getList('tickets')); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('adminuploadlimit'); $Types = Settings::findbyParam('adminuploadfiletypes', 'Admin'); if (empty($MBlimit)) { $MBlimit = 1; } if (empty($Types)) { $Types = "zip,jpg"; } $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle')); $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } else { $this->addElement('hidden', 'attachments'); } $this->addElement('hidden', 'ticket_id'); }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'firstname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('First name'), 'description' => $translate->_('Write here your first name.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('text', 'lastname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Last name'), 'description' => $translate->_('Write here your last name.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('text', 'birthdate', array('filters' => array('StringTrim'), 'validators' => array(new Zend_Validate_Date('dd/mm/yyyy', 'it')), 'label' => $translate->_('Birthdate'), 'description' => $translate->_('Write here your birthday (eg. dd/mm/yyyy)'), 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input')); $this->addElement('text', 'birthplace', array('filters' => array('StringTrim'), 'label' => $translate->_('Birthplace'), 'description' => $translate->_('Write here the birthplace.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('select', 'company_type_id', array('label' => $translate->_('Company Type'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Select the company type'), 'class' => 'form-control large-input')); $this->getElement('company_type_id')->setAllowEmpty(false)->setMultiOptions(CompanyTypes::getList(true)); $this->addElement('select', 'legalform', array('label' => $translate->_('Legal form'), 'required' => true, 'decorators' => array('Bootstrap'), 'description' => $translate->_('Select the type of company.'), 'class' => 'form-control large-input')); $this->getElement('legalform')->setAllowEmpty(false)->setMultiOptions(Legalforms::getList()); $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company Name'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here your company name.'), 'class' => 'form-control large-input')); $this->addElement('text', 'birthplace', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth place'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('text', 'birthdistrict', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth District'), 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input', 'maxlength' => 2)); $this->addElement('text', 'birthcountry', array('filters' => array('StringTrim'), 'label' => $translate->_('Country of Birth'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('text', 'birthnationality', array('filters' => array('StringTrim'), 'label' => $translate->_('Birth Nationality'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); if (Settings::findbyParam('customer_vat')) { $this->addElement('text', 'vat', array('filters' => array('StringTrim'), 'label' => $translate->_('VAT'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input', 'description' => $translate->_('Write here the VAT number.'))); } $this->addElement('text', 'area', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Area'), 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input', 'description' => 'Write the area code')); if (Settings::findbyParam('customer_taxpayernumber')) { $this->addElement('text', 'taxpayernumber', array('filters' => array('StringTrim'), 'label' => $translate->_('Tax payer number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input', 'description' => 'Write the tax payer number.')); } $this->addElement('text', 'address', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Address'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write the address'), 'class' => 'form-control large-input')); $this->addElement('text', 'code', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Zip'), 'description' => 'Write the zip code', 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input')); $this->addElement('text', 'city', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('City'), 'description' => $translate->_('Write here your city name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->addElement('select', 'country_id', array('label' => $translate->_('Country'), 'required' => true, 'description' => $translate->_('Select your own country'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->getElement('country_id')->setAllowEmpty(false)->setMultiOptions(Countries::getList())->setRequired(true); $this->addElement('select', 'gender', array('label' => $translate->_('Gender'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input')); $this->getElement('gender')->setAllowEmpty(false)->setMultiOptions(array('M' => 'M', 'F' => 'F'))->setRequired(true); $this->addElement('select', 'newsletter', array('label' => $translate->_('Newsletter'), 'description' => $translate->_('Subscribe to our free content feeds and get all the news for your bought services and products.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control medium-input')); $this->getElement('newsletter')->setAllowEmpty(false)->setMultiOptions(array('0' => $translate->_('No, I am not interested'), '1' => $translate->_('Yes, please send me your updates')))->setRequired(true); $this->addElement('select', 'contacttypes', array('label' => $translate->_('Contact Types'), 'required' => true, 'description' => $translate->_('Select the contact type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $this->getElement('contacttypes')->setAllowEmpty(false)->setMultiOptions(ContactsTypes::getList()); $this->addElement('text', 'contact', array('filters' => array('StringTrim'), 'label' => $translate->_('Contact'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here the contact (eg. +39.98368276)'), 'class' => 'form-control medium-input')); $this->addElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'required' => true, 'decorators' => array('Bootstrap'), 'validators' => array('EmailAddress'), 'required' => true, 'label' => $translate->_('Email'), 'description' => $translate->_('Write here your email'), 'class' => 'form-control large-input')); $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'validators' => array(array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'description' => $translate->_('Write here your password. (min.6 chars - max.20 chars)'), 'label' => $translate->_('Password'), 'class' => 'form-control large-input')); $this->addElement('submit', 'submit', array('label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary')); $this->addElement('hidden', 'customer_id'); }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElementPrefixPath('Default', APPLICATION_PATH . '/modules/default/forms/validate/', 'validate'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company Name'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here your company name.'), 'class' => 'form-control')); $this->addElement('text', 'firstname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('First name'), 'description' => $translate->_('Write here your first name.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'lastname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Last name'), 'description' => $translate->_('Write here your lastname.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $email = $this->createElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'decorators' => array('Bootstrap'), 'validators' => array('EmailAddress'), 'required' => true, 'label' => $translate->_('Email'), 'description' => $translate->_('Write here your email'), 'class' => 'form-control')); $email->addValidator('UniqueEmail', false, array(new Customers())); $this->addElement($email); // Password manager $passwordConfirmation = new Shineisp_Validate_PasswordConfirmation(); $password = $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here your password. (min.8 chars - max.20 chars)'), 'validators' => array($passwordConfirmation, array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'class' => 'form-control', 'required' => true, 'label' => $translate->_('Password'))); $password_confirm = $this->addElement('password', 'password_confirm', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Please repeat the password'), 'validators' => array($passwordConfirmation, array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'class' => 'form-control', 'required' => true, 'label' => 'Confirm Password')); if (Settings::findbyParam('customer_vat')) { #$vatValidator = new Shineisp_Validate_Vat(); $this->addElement('text', 'vat', array('filters' => array('StringTrim'), 'label' => $translate->_('VAT Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'description' => $translate->_('Write here the VAT code. Eg: IT123456789'))); #$this->getElement('vat')->addValidator($vatValidator); } $this->addElement('select', 'company_type_id', array('label' => 'Company Type', 'decorators' => array('Bootstrap'), 'description' => $translate->_('Select the company type'), 'class' => 'form-control')); $this->getElement('company_type_id')->setAllowEmpty(false)->setMultiOptions(CompanyTypes::getList(true)); $this->addElement('select', 'legalform', array('label' => $translate->_('Legal form'), 'required' => true, 'decorators' => array('Bootstrap'), 'description' => $translate->_('Select the type of company.'), 'class' => 'form-control')); $this->getElement('legalform')->setAllowEmpty(false)->setMultiOptions(Legalforms::getList(true))->addValidator(new Shineisp_Validate_Customer()); if (Settings::findbyParam('customer_taxpayernumber')) { $fiscalcodeValidator = new Shineisp_Validate_Fiscalcode(); $this->addElement('text', 'taxpayernumber', array('filters' => array('StringTrim'), 'label' => $translate->_('Tax payer number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'description' => $translate->_('Write the tax payer number.'))); # TODO: check both fiscalcode for generic person or giuridic person. (XYZYXZ88D22C123X and 1234567890) #$this->getElement('taxpayernumber')->addValidator($fiscalcodeValidator); } $this->addElement('submit', 'signup', array('label' => $translate->_('Create my account'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-success btn-lg')); $privKey = Settings::findbyParam('recaptcha_private_key'); $pubKey = Settings::findbyParam('recaptcha_public_key'); if (!empty($pubKey) && !empty($privKey)) { $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $translate->_('Captcha Check'), 'description' => $translate->_('Type the characters you see in the picture below.'), 'captcha' => 'ReCaptcha', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha))); $this->addElement($captcha); } }
public function Alerts() { $registry = Shineisp_Registry::getInstance(); $currency = Shineisp_Registry::getInstance()->Zend_Currency; $translation = $registry->Zend_Translate; $alerts = array(); $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $NS = new Zend_Session_Namespace('Default'); if (!empty($NS->customer)) { $data = $NS->customer; $orders = Orders::find_all_not_paid_ordersbyCustomerID($data['customer_id']); $tasks_errors = DomainsTasks::GetIncompleteTask($data['customer_id']); if (count($tasks_errors) > 0) { foreach ($tasks_errors as $task) { if (!empty($task['log'])) { $alerts[] = array('message' => $task['domain'] . " - " . $translation->_($task['log']), $task['domain_id'], 'link' => '/domains/edit/id/' . $task['domain_id'], 'icon' => 'danger'); } } } if (count($orders) > 0) { foreach ($orders as $order) { $order['grandtotal'] = $currency->toCurrency($order['grandtotal'], array('currency' => Settings::findbyParam('currency'))); if (!empty($order['invoice_id'])) { $alerts[] = array('message' => $translation->_('The invoice %s of %s (%s) has been not payed yet, click here to show more details.', $order['Invoices']['number'], Shineisp_Commons_Utilities::formatDateOut($order['order_date']), $order['grandtotal']), 'link' => '/orders/edit/id/' . $order['order_id'], 'icon' => 'danger'); } else { $alerts[] = array('message' => $translation->_('The order %s that you have requested the %s with total %s has not been paid yet, click here for more information.', $order['order_number'], Shineisp_Commons_Utilities::formatDateOut($order['order_date']), $order['grandtotal']), 'link' => '/orders/edit/id/' . $order['order_id'], 'icon' => 'danger'); } } } $this->view->alerts = $alerts; // Path of the template return $this->view->render('partials/alerts.phtml'); } }
/** * The default action - show the home page */ public function indexAction() { $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('admin')); $translator = Shineisp_Registry::getInstance()->Zend_Translate; if ($auth->hasIdentity()) { $this->view->show_dashboard = true; $this->view->user = $auth->getIdentity(); $this->getHelper('layout')->setLayout('1column'); $graph = new Shineisp_Commons_Morris(); // Get the total of the revenues per year $graphdata = $graph->setType('Area')->setData(Orders::prepareGraphData(array(), 'year'))->setElement('yeargraph')->setXkey('xdata')->setLabels(array($translator->translate('Net Revenue (Taxable Income less Costs)')))->setOptions(array('lineColors' => array('#428BCA'), 'preUnits' => Settings::findbyParam('currency') . " "))->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); // Get the total of the revenues per quarter of year $graphdata = $graph->setType('Area')->setData(Orders::prepareGraphData(array(2012, 2013), 'quarter'))->setElement('quartergraph')->setXkey('xdata')->setLabels(array($translator->translate('Net Revenue (Taxable Income less Costs)')))->setOptions(array('lineColors' => array('#428BCA'), 'preUnits' => Settings::findbyParam('currency') . " "))->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); // Get the total of the revenues per months $graphdata = $graph->setType('Bar')->setData(Orders::prepareGraphData(array(), 'month'))->setElement('monthgraph')->setXkey('xdata')->setLabels(array($translator->translate('Net Revenue (Taxable Income less Costs)')))->setOptions(array('barColors' => array('#428BCA'), 'preUnits' => Settings::findbyParam('currency') . " "))->plot(); $this->view->placeholder("admin_endbody")->append($graphdata); } else { $this->_helper->redirector('index', 'login', 'admin'); // back to login page } }
/** * Get the price including the VAT tax rate * @param integer $productid * @return string */ public function getPriceIncludedVat($productid) { $currency = Shineisp_Registry::get('Zend_Currency'); $translator = Shineisp_Registry::get('Zend_Translate'); $measurement = ""; $data = Products::getPrices($productid); if ($data['type'] == "multiple") { if (!empty($data['minvalue'])) { // Get the minimum value from the group of the prices $pricetax = $data['minvaluewithtaxes']; $pricetax = $currency->toCurrency($pricetax, array('currency' => Settings::findbyParam('currency'))); // Get the recurring period label if (!empty($data['tranches'][0]['measurement'])) { $measurement = '<span class="frequency">' . $translator->translate($data['tranches'][0]['measurement']) . '</span>'; } // Print the price return $pricetax . $measurement; } } else { $pricetax = $data['taxincluded']; // Print the price return $pricetax; } }
/** * print the credit note * @param integer $creditnoteId */ public static function PrintPDF($creditnoteId, $show = true) { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $pdf = new Shineisp_Commons_PdfOrder(); $translator = Shineisp_Registry::getInstance()->Zend_Translate; $creditnote = Doctrine_Query::create()->from('CreditNotes cn')->leftJoin('cn.CreditNotesItems cni')->leftJoin('cn.Invoices i')->leftJoin('i.Customers c')->leftJoin('c.Addresses a')->leftJoin('a.Countries co')->leftJoin('i.Orders o')->leftJoin('o.OrdersItems oi')->leftJoin('o.Isp isp')->leftJoin('o.Payments p')->leftJoin('p.Banks b')->leftJoin('o.Statuses s')->leftJoin('o.Customers oc')->where("cn.creditnote_id = ?", $creditnoteId)->execute(array(), Doctrine::HYDRATE_ARRAY); if (empty($creditnote)) { return false; } $invoice = $creditnote[0]['Invoices']; $customer = $creditnote[0]['Invoices']['Customers']; $payments = $creditnote[0]['Invoices']['Orders']['Payments']; $order = $creditnote[0]['Invoices']['Orders']; $items = $creditnote[0]['CreditNotesItems']; $database['header']['label'] = $translator->translate('Credit Note No.') . " " . sprintf("%03d", $creditnote[0]['number']) . " - " . Shineisp_Commons_Utilities::formatDateOut($creditnote[0]['creationdate']); $database['columns'][] = array("value" => "Description"); $database['columns'][] = array("value" => "Qty", "size" => 30, "align" => "center"); $database['columns'][] = array("value" => "Unit", "size" => 30); $database['columns'][] = array("value" => "Tax Free Price", "size" => 60, "align" => "right"); $database['columns'][] = array("value" => "VAT", "size" => 40, "align" => "right"); $database['columns'][] = array("value" => "Total", "size" => 50, "align" => "right"); if (isset($order)) { $info['order_number'] = $order['order_id']; $info['invoice_number'] = $invoice['number']; $info['date'] = Shineisp_Commons_Utilities::formatDateOut($invoice['invoice_date']); //if customer comes from reseller if ($order['Customers']['parent_id']) { $reseller = Customers::getAllInfo($order['Customers']['parent_id']); $info['customer']['customer_id'] = $reseller['customer_id']; $info['customer']['company'] = $reseller['company']; $info['customer']['firstname'] = $reseller['firstname']; $info['customer']['lastname'] = $reseller['lastname']; $info['customer']['vat'] = $reseller['vat']; $info['customer']['email'] = $reseller['email']; if (isset($reseller['Addresses'][0])) { $info['customer']['address'] = $reseller['Addresses'][0]['address']; $info['customer']['city'] = $reseller['Addresses'][0]['city']; $info['customer']['code'] = $reseller['Addresses'][0]['code']; $info['customer']['country'] = !empty($reseller['Addresses'][0]['Countries']['name']) ? $reseller['Addresses'][0]['Countries']['name'] : ""; } } else { $info['customer']['customer_id'] = $customer['customer_id']; $info['customer']['company'] = $customer['company']; $info['customer']['firstname'] = $customer['firstname']; $info['customer']['lastname'] = $customer['lastname']; $info['customer']['vat'] = $customer['vat']; $info['customer']['email'] = $customer['email']; if (isset($customer['Addresses'][0])) { $info['customer']['address'] = $customer['Addresses'][0]['address']; $info['customer']['city'] = $customer['Addresses'][0]['city']; $info['customer']['code'] = $customer['Addresses'][0]['code']; $info['customer']['country'] = $customer['Addresses'][0]['Countries']['name']; } } if (count($payments) > 0) { $info['payment_date'] = Shineisp_Commons_Utilities::formatDateOut($payments[0]['paymentdate']); $info['payment_mode'] = $payments[0]['Banks']['name']; $info['payment_description'] = $payments[0]['description']; $info['payment_transaction_id'] = $payments[0]['reference']; } $info['invoice_id'] = $invoice['number']; $info['company']['name'] = $order['Isp']['company']; $info['company']['vat'] = $order['Isp']['vatnumber']; $info['company']['bankname'] = $order['Isp']['bankname']; $info['company']['iban'] = $order['Isp']['iban']; $info['company']['bic'] = $order['Isp']['bic']; $info['company']['address'] = $order['Isp']['address']; $info['company']['zip'] = $order['Isp']['zip']; $info['company']['city'] = $order['Isp']['city']; $info['company']['country'] = $order['Isp']['country']; $info['company']['telephone'] = $order['Isp']['telephone']; $info['company']['fax'] = $order['Isp']['fax']; $info['company']['website'] = $order['Isp']['website']; $info['company']['email'] = $order['Isp']['email']; $info['company']['slogan'] = $order['Isp']['slogan']; $info['subtotal'] = $currency->toCurrency($creditnote[0]['total_net'], array('currency' => Settings::findbyParam('currency'))); $info['grandtotal'] = $currency->toCurrency($creditnote[0]['total'], array('currency' => Settings::findbyParam('currency'))); $info['vat'] = $currency->toCurrency($creditnote[0]['vat'], array('currency' => Settings::findbyParam('currency'))); $info['delivery'] = 0; $database['records'] = $info; // Zend_Debug::dump($creditnote); // die; foreach ($items as $item) { $item['price'] = $currency->toCurrency($item['price'], array('currency' => Settings::findbyParam('currency'))); $item['vat'] = $currency->toCurrency($item['vat'], array('currency' => Settings::findbyParam('currency'))); $item['total'] = $currency->toCurrency($item['total'], array('currency' => Settings::findbyParam('currency'))); $database['records'][] = array($item['description'], $item['quantity'], 'nr', $item['price'], $item['vat'], $item['total']); } if (isset($order)) { $pdf->CreatePDF($database, $creditnote[0]['creationdate'] . " - " . $creditnote[0]['number'] . ".pdf", $show, "/documents/creditnotes", true); } } }
/** * Creation of the footer details * * @return void */ private function FooterDetails() { $locale = Shineisp_Registry::get('Zend_Locale'); if ($this->h < 190) { $this->CreatePage(); } // Positioning for one transaction $toppos = 200; $bottomPos = 30; $h_offset = 30; $totalPayments = 0; $records = isset($this->data['records']) ? $this->data['records'] : array(); if (!empty($records['payments'])) { $totalPayments = count($records['payments']); if ($totalPayments > 1) { $toppos += $totalPayments * TRANSACTION_MULTIPLIER; $h_offset += $totalPayments * TRANSACTION_MULTIPLIER; } } $originalToppos = $toppos; $this->page->setLineWidth(0.5); $this->page->setLineColor(new Zend_Pdf_Color_Html('#333333')); $this->page->drawLine(PAGE_BOTH_MARGIN, $toppos, PAGE_WIDTH - PAGE_BOTH_MARGIN, $toppos); $this->page->setLineWidth(1); // Vertical lines $this->page->drawLine(PAGE_BOTH_MARGIN + 295, $toppos - 5, PAGE_BOTH_MARGIN + 295, $toppos - 140); $this->page->drawLine(PAGE_BOTH_MARGIN + 442, $toppos - 5, PAGE_BOTH_MARGIN + 442, $toppos - 40); // Horizontal Lines $toppos -= 40; $this->page->drawLine(PAGE_BOTH_MARGIN, $toppos, PAGE_WIDTH - PAGE_BOTH_MARGIN, $toppos); $toppos -= 40; $this->page->drawLine(PAGE_BOTH_MARGIN, $toppos, PAGE_BOTH_MARGIN + 295, $toppos); $toppos -= 30; $this->page->drawLine(PAGE_BOTH_MARGIN + 295, $toppos, PAGE_WIDTH - PAGE_BOTH_MARGIN, $toppos); $toppos -= 60; $this->page->drawLine(PAGE_BOTH_MARGIN, $bottomPos + $h_offset, PAGE_WIDTH - PAGE_BOTH_MARGIN, $bottomPos + $h_offset); // Prima riga, va dinamicizzata in base all'altezza $this->page->drawLine(PAGE_BOTH_MARGIN + 490, $bottomPos + $h_offset, PAGE_BOTH_MARGIN + 490, $bottomPos); // Vertical line //$toppos -= 30; $this->page->drawLine(PAGE_BOTH_MARGIN, $bottomPos, PAGE_WIDTH - PAGE_BOTH_MARGIN, $bottomPos); // Ultima riga, deve essere fissa // Reset of the height for writing the labels $toppos = $originalToppos; $this->setFontandSize(Zend_Pdf_Font::FONT_HELVETICA, 5); $this->Write(strtoupper($this->translator->translate("Bank Name")), PAGE_BOTH_MARGIN + 2, $toppos - 10); $this->Write($this->translator->translate("IBAN"), PAGE_BOTH_MARGIN + 300, $toppos - 10); $this->Write($this->translator->translate("BIC"), PAGE_BOTH_MARGIN + 445, $toppos - 10); $this->Write(strtoupper($this->translator->translate("Company Name")), PAGE_BOTH_MARGIN + 2, $toppos - 50); $this->Write(strtoupper($this->translator->translate("Payment mode")), PAGE_BOTH_MARGIN + 300, $toppos - 50); $this->Write(strtoupper($this->translator->translate("Payment note")), PAGE_BOTH_MARGIN + 300, $toppos - 80); $this->Write(strtoupper($this->translator->translate("Customer Information")), PAGE_BOTH_MARGIN + 2, $toppos - 90); $this->Write(strtoupper($this->translator->translate("Transaction ID")), PAGE_BOTH_MARGIN + 2, $toppos - 150); $this->Write(strtoupper($this->translator->translate("Order Number")), PAGE_BOTH_MARGIN + 300, $toppos - 120); $this->Write(strtoupper($this->translator->translate("Invoice Number")), PAGE_BOTH_MARGIN + 400, $toppos - 120); $this->Write(strtoupper($this->translator->translate("Payment amount")), PAGE_BOTH_MARGIN + 240, $toppos - 150); $this->Write(strtoupper($this->translator->translate("Payment mode")), PAGE_BOTH_MARGIN + 295, $toppos - 150); $this->Write(strtoupper($this->translator->translate("Payment Date")), PAGE_BOTH_MARGIN + 420, $toppos - 150); $this->Write(Settings::findbyParam('currency'), PAGE_BOTH_MARGIN + 500, $toppos - 150); $this->setFontandSize(Zend_Pdf_Font::FONT_HELVETICA, 8); $this->Write($records['company']['bankname'], PAGE_BOTH_MARGIN + 2, $toppos - 24); $this->Write($records['company']['iban'], PAGE_BOTH_MARGIN + 300, $toppos - 24); $this->Write($records['company']['bic'], PAGE_BOTH_MARGIN + 445, $toppos - 24); $this->Write($records['company']['name'], PAGE_BOTH_MARGIN + 2, $toppos - 65); $this->Write($records['customer']['company'], PAGE_BOTH_MARGIN + 2, $toppos - 105); $records['customer']['address'] = !empty($records['customer']['address']) ? $records['customer']['address'] : ""; $records['customer']['code'] = !empty($records['customer']['code']) ? $records['customer']['code'] : ""; $records['customer']['city'] = !empty($records['customer']['city']) ? $records['customer']['city'] : ""; $records['customer']['country'] = !empty($records['customer']['country']) ? $records['customer']['country'] : ""; $this->Write($records['customer']['address'], PAGE_BOTH_MARGIN + 2, $toppos - 115); $this->Write($records['customer']['code'] . " " . $records['customer']['city'], PAGE_BOTH_MARGIN + 2, $toppos - 125); $this->Write($records['customer']['country'], PAGE_BOTH_MARGIN + 2, $toppos - 135); $this->Write($records['order_number'], PAGE_BOTH_MARGIN + 300, $toppos - 130); if (!empty($records['invoice_number'])) { $this->Write($records['invoice_number'], PAGE_BOTH_MARGIN + 400, $toppos - 130); } $records['payment_description'] = !empty($records['payment_description']) ? $records['payment_description'] : ""; $records['payment_mode'] = !empty($records['payment_mode']) ? $records['payment_mode'] : ""; if ($totalPayments > 1) { $c = 0; foreach ($records['payments'] as $payment) { $offset = $c * 10; $this->Write($payment['reference'], PAGE_BOTH_MARGIN + 2, $bottomPos + $offset + TRANSACTION_MULTIPLIER); $this->Write($payment['income'], PAGE_BOTH_MARGIN + 240, $bottomPos + $offset + TRANSACTION_MULTIPLIER); if (isset($payment['Banks']) && isset($payment['Banks']['name'])) { $this->Write($payment['Banks']['name'], PAGE_BOTH_MARGIN + 295, $bottomPos + $offset + TRANSACTION_MULTIPLIER); } $this->Write($payment['paymentdate'], PAGE_BOTH_MARGIN + 420, $bottomPos + $offset + TRANSACTION_MULTIPLIER); $c++; } } else { $records['payment_transaction_id'] = !empty($records['payment_transaction_id']) ? $records['payment_transaction_id'] : ""; $records['payment_date'] = !empty($records['payment_date']) ? $records['payment_date'] : ""; $this->Write($records['payment_transaction_id'], PAGE_BOTH_MARGIN + 2, $toppos - 162); if (isset($records['payments'])) { $this->Write($records['payments'][0]['income'], PAGE_BOTH_MARGIN + 240, $toppos - 162); } $this->Write($records['payment_mode'], PAGE_BOTH_MARGIN + 295, $toppos - 162); $this->Write($records['payment_date'], PAGE_BOTH_MARGIN + 420, $toppos - 162); } $this->setFontandSize(Zend_Pdf_Font::FONT_HELVETICA_BOLD, 9); $this->Write($records['grandtotal'], PAGE_BOTH_MARGIN + 500, $toppos - 162); $this->setFontandSize(Zend_Pdf_Font::FONT_HELVETICA, 8); $this->Write($records['payment_description'], PAGE_BOTH_MARGIN + 299, $toppos - 90); $this->Write($records['payment_mode'], PAGE_BOTH_MARGIN + 299, $toppos - 60); $this->h = $toppos - 210; }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'customer_id', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Customer'), 'decorators' => array('Bootstrap'), 'field-id' => "customer_id", 'fields-data' => "lastname firstname ( company )", 'url-search' => "/admin/customers/search", 'class' => 'select2')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'customer_parent_id', array('label' => $translate->_('Invoice destination'), 'decorators' => array('Bootstrap'), 'field-id' => "customer_id", 'fields-data' => "firstname lastname", 'url-search' => "/admin/customers/search", 'class' => 'select2', 'disable' => 'true')); $this->addElement('select', 'isp_id', array('required' => true, 'label' => $translate->_('ISP'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('isp_id')->setAllowEmpty(false)->setMultiOptions(Isp::getList()); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'categories', array('label' => $translate->_('Filter by categories'), 'decorators' => array('Bootstrap'), 'id' => 'productcategories', 'field-id' => "category_id", 'fields-data' => "name", 'url-search' => "/admin/productscategories/search", 'class' => 'select2', 'rel' => 'tree_select')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'referdomain', array('filters' => array('StringTrim'), 'label' => $translate->_('Reference Domain'), 'description' => $translate->_('Assign a domain in order to identify the service/product'), 'decorators' => array('Bootstrap'), 'field-id' => "domain_id", 'fields-data' => "domain", 'url-search' => "/admin/domains/search", 'class' => 'select2')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'products', array('id' => "products", 'required' => false, 'label' => $translate->_('Products'), 'field-id' => "product_id", 'fields-data' => "name", 'url-search' => "/admin/products/search", 'class' => 'select2')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'billingcycle_id', array('id' => 'billingid', 'label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'field-id' => "billing_cycle_id", 'fields-data' => "name ( price / setupfee )", 'url-search' => "/admin/orders/getbillingcycles", 'class' => 'select2')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'domains_selected', array('filters' => array('StringTrim'), 'label' => $translate->_('Add Domains'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('If you do not find a domain name from this list, you have to create it by the domain admministration page.'), 'multiple' => true, 'field-id' => "domain_id", 'fields-data' => "domain", 'url-search' => "/admin/domains/search", 'class' => 'select2')); $this->addElement('checkbox', 'is_renewal', array('label' => $translate->_('Is a Renewal?'), 'description' => "If this order is a renewal, it will be checked by ShineISP and it cannot be deleted by the customer in the customer order frontend panel.", 'decorators' => array('Bootstrap'), 'class' => 'form-control')); /* * This hidden form field will be converted in a advanced select object * the JQuery Select2 object is loaded automatically by the css class select2 */ $this->addElement('hidden', 'invoice_id', array('label' => $translate->_('Invoice No.'), 'decorators' => array('Bootstrap'), 'field-id' => "invoice_id", 'fields-data' => "formatted_number ( number )", 'url-search' => "/admin/invoices/search", 'class' => 'select2')); $this->addElement('text', 'order_date', array('filters' => array('StringTrim'), 'label' => $translate->_('Order Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'expiring_date', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'description' => $translate->_('If this date is set ShineISP will suspend the order at the specified date.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'date_start', array('filters' => array('StringTrim'), 'label' => $translate->_('Date Start'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'quantity', array('filters' => array('StringTrim'), 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'value' => '1', 'class' => 'form-control')); $this->addElement('text', 'profit', array('filters' => array('StringTrim'), 'label' => $translate->_('Profit'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'id' => 'description', 'rows' => '3', 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control')); $this->addElement('text', 'cost', array('filters' => array('StringTrim'), 'label' => $translate->_('Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'price', array('filters' => array('StringTrim'), 'label' => $translate->_('Price'), 'id' => 'price', 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'setupfee', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup fee'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'vat', array('filters' => array('StringTrim'), 'label' => $translate->_('VAT'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total', array('filters' => array('StringTrim'), 'label' => $translate->_('Total'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'grandtotal', array('filters' => array('StringTrim'), 'label' => $translate->_('Grand Total'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Save again in order to update the totals.'), 'class' => 'form-control bold')); $this->addElement('text', 'received_income', array('readonly' => 1, 'filters' => array('StringTrim'), 'label' => $translate->_('Income'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'missing_income', array('readonly' => 1, 'filters' => array('StringTrim'), 'label' => $translate->_('Missing income'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'fastlink', array('filters' => array('StringTrim'), 'id' => 'fastlink', 'label' => $translate->_('Fastlink Code'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Here you can read a unique code for redirect a user in the order page using the fastlink.'), 'class' => 'form-control readonly')); $this->addElement('text', 'visits', array('filters' => array('StringTrim'), 'label' => $translate->_('Visits'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Here you can read how many times the order has been viewed by the customer.'), 'class' => 'form-control readonly')); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('adminuploadlimit'); $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $filetypes = Settings::findbyParam('adminuploadfiletypes', 'Admin'); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $filetypes, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle')); if (!empty($filetypes)) { $file->addValidator('Extension', false, $filetypes); } $file->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); $this->addElement('select', 'filecategory', array('label' => $translate->_('Category'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('filecategory')->setAllowEmpty(false)->setMultiOptions(FilesCategories::getList())->setRegisterInArrayValidator(false)->setRequired(false); } $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Private Notes'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('textarea', 'message', array('filters' => array('StringTrim'), 'label' => $translate->_('Post a comment'), 'decorators' => array('Bootstrap'), 'class' => 'form-control wysiwyg')); $this->addElement('select', 'status_id', array('label' => 'Status', 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders')); $this->addElement('text', 'paymentdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Payment date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date')); $this->addElement('text', 'reference', array('filters' => array('StringTrim'), 'label' => $translate->_('Payment Reference'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'bank_id', array('id' => 'paymentmethods', 'label' => $translate->_('Bank name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('bank_id')->setAllowEmpty(false)->setMultiOptions(Banks::getList(true)); $this->addElement('text', 'income', array('filters' => array('StringTrim'), 'label' => $translate->_('Income'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'payment_description', array('filters' => array('StringTrim'), 'label' => $translate->_('Notes'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'confirmed', array('filters' => array('StringTrim'), 'label' => $translate->_('Has the Transaction been confirmed?'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('confirmed')->setAllowEmpty(false)->setMultiOptions(array('0' => "No, not yet", '1' => "Yes, it has been")); $this->addElement('hidden', 'order_id'); }
/** * List of the last 10 Orders * @return array */ public static function Last(array $statuses, $limit = 10) { $translator = Shineisp_Registry::getInstance()->Zend_Translate; $currency = Shineisp_Registry::getInstance()->Zend_Currency; $dq = Doctrine_Query::create()->select("order_id, DATE_FORMAT(order_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as orderdate, i.formatted_number as invoice,\n\t\t\t\t\t\t\t\t\t\t\tCONCAT(c.firstname, ' ', c.lastname, ' ', c.company) as fullname, \n\t\t\t\t\t\t\t\t\t\t\tc.customer_id as customer_id, \n\t\t\t\t\t\t\t\t\t\t\to.total as total, \n\t\t\t\t\t\t\t\t\t\t\ti.invoice_id as invoice_id, \n\t\t\t\t\t\t\t\t\t\t\to.grandtotal as grandtotal, \n\t\t\t\t\t\t\t\t\t\t\ts.status as status")->from('Orders o')->leftJoin('o.Customers c')->leftJoin('o.Invoices i')->leftJoin('o.Statuses s')->addWhere('c.isp_id = ?', Isp::getCurrentId()); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $logged_user = $auth->getIdentity(); $dq->where("o.isp_id = ?", $logged_user['isp_id']); } if (is_array($statuses) && !empty($statuses)) { $dq->whereIn('o.status_id', $statuses); } $dq->orderBy('order_date desc')->orderBy('order_id desc')->limit($limit); $records['data'] = $dq->execute(null, Doctrine::HYDRATE_ARRAY); for ($i = 0; $i < count($records['data']); $i++) { $records['data'][$i]['total'] = $currency->toCurrency($records['data'][$i]['total'], array('currency' => Settings::findbyParam('currency'))); $records['data'][$i]['grandtotal'] = $currency->toCurrency($records['data'][$i]['grandtotal'], array('currency' => Settings::findbyParam('currency'))); $records['data'][$i]['status'] = $translator->translate($records['data'][$i]['status']); } // adding the index reference $records['index'] = "order_id"; // Create the header table columns $records['fields'] = array('order_id' => array('label' => $translator->translate('ID'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'orderdate' => array('label' => $translator->translate('Date'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'invoice' => array('label' => $translator->translate('Invoice'), 'type' => 'link', 'link' => array('idx' => 'invoice_id', 'href' => '/admin/invoices/edit/id/%s'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'fullname' => array('label' => $translator->translate('Customer'), 'type' => 'link', 'link' => array('idx' => 'customer_id', 'href' => '/admin/customers/edit/id/%s')), 'total' => array('label' => $translator->translate('Total'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'grandtotal' => array('label' => $translator->translate('Grand Total'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'status' => array('label' => $translator->translate('Status'))); return $records; }
/** * getList * Get the product options by productid * @param $productid * @return array */ public static function getList($productid, $refund = false) { $translator = Shineisp_Registry::getInstance()->Zend_Translate; $currency = Shineisp_Registry::getInstance()->Zend_Currency; try { $items = array(); $dq = Doctrine_Query::create()->from('ProductsTranches pt')->leftJoin('pt.BillingCycle bc')->where('pt.product_id = ?', $productid)->orderBy('bc.months asc'); $records = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); // Check the refund options foreach ($records as $c) { if ($refund !== false) { $idBillingCircle = $c['BillingCycle']['billing_cycle_id']; $monthBilling = BillingCycle::getMonthsNumber($idBillingCircle); if ($monthBilling > 0) { $priceToPay = $c['price'] * $monthBilling; $priceToPayWithRefund = $priceToPay - $refund; if ($priceToPayWithRefund < 0) { $priceToPayWithRefund = $priceToPay; } $c['price'] = round($priceToPayWithRefund / $monthBilling, 2); } else { $priceToPayWithRefund = $c['price'] - $refund; if ($priceToPayWithRefund > 0) { $c['price'] = $priceToPayWithRefund; } } } $items[$c['tranche_id']] = ""; // If quantity is more than one ShineISP must show the item quantity if ($c['quantity'] > 1) { $items[$c['tranche_id']] .= "No. " . $c['quantity'] . " "; } $items[$c['tranche_id']] .= "(" . $translator->translate($c['BillingCycle']['name']) . ") - " . $currency->toCurrency($c['price'], array('currency' => Settings::findbyParam('currency'))); if (!empty($c['measurement'])) { $items[$c['tranche_id']] .= "/" . $translator->translate($c['measurement']); } } return $items; } catch (Exception $e) { die($e->getMessage()); } }
/** * Get the list of the domain next the expiration date * @param $customerID * @return Void */ public static function getExpiringDomains($customerID = null, $from = null, $to = null, $limit = null) { if (empty($from) || !is_numeric($from)) { // Try to read from DB $from = Settings::findbyParam('domains_show_before_expire_days'); } if (empty($to) || !is_numeric($to)) { // Try to read from DB $to = Settings::findbyParam('domains_show_after_expire_days'); } $from = is_numeric($from) ? intval($from) : 31; $to = is_numeric($to) ? intval($to) * -1 : -2; // force a negative value $fields = "d.domain_id, CONCAT(domain, '.', ws.tld) as domains, \r\n\t\t DATE_FORMAT(d.expiring_date, '" . Settings::getMySQLDateFormat('dateformat') . "') as expiringdate, \r\n\t\t DATEDIFF(expiring_date, CURRENT_DATE) as days,\r\n\t\t IF(d.autorenew = 1, 'YES', 'NO') as renew"; $dq = Doctrine_Query::create()->select($fields)->from('Domains d')->leftjoin('d.OrdersItems oi')->leftjoin('d.Statuses s')->leftJoin('d.Customers c')->leftJoin('d.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->where('DATEDIFF(expiring_date, CURRENT_DATE) <= ' . $from)->addWhere('DATEDIFF(expiring_date, CURRENT_DATE) >= ' . $to)->addWhere("c.isp_id = ?", Isp::getCurrentId())->orderBy('d.expiring_date asc'); if (is_numeric($customerID)) { $dq->addWhere('customer_id = ?', $customerID); } if (is_numeric($limit)) { $dq->limit($limit); } $result = $dq->execute(null, Doctrine::HYDRATE_ARRAY); return $result; }
public function checkdomainAction() { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $translator = Shineisp_Registry::getInstance()->Zend_Translate; $request = $this->getRequest(); try { if ($request->getPost()) { $params = $request->getPost(); $available = Domains::check_availability($params['name'], $params['tld']); $data = DomainsTlds::getAllInfo($params['tld']); $tldName = $data['WhoisServers']['tld']; // Create the domain name $domain = $params['name'] . "." . $tldName; if ($available) { $price = $data['registration_price']; // Get the price of the product } else { $price = $data['transfer_price']; } if (!empty($data['Taxes']['percentage']) && is_numeric($data['Taxes']['percentage'])) { $formatPrice = $currency->toCurrency($price * ($data['Taxes']['percentage'] + 100) / 100, array('currency' => Settings::findbyParam('currency'))); } else { $formatPrice = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency'))); } // Format the price number $strprice = $translator->translate('just') . " {$formatPrice}!"; // Create the message $mex = $available ? $translator->translate('The domain is available for registration') : $translator->translate("The domain is unavailable for registration, but if you are the domain owner, you can transfer it!"); // Reply with JSON code die(json_encode(array('available' => $available, 'name' => $params['name'], 'tld' => $params['tld'], 'price' => $strprice, 'domain' => $domain, 'mex' => $mex))); } } catch (Exception $e) { die(json_encode(array('mex' => $e->getMessage()))); } }
/** * 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; }
/** * Create the tld list */ private function createTldMenu() { $ns = new Zend_Session_Namespace(); $items = DomainsTlds::getHighlighted($ns->langid); $currency = Shineisp_Registry::get('Zend_Currency'); $html = ""; if (!empty($items)) { $html = "<li class=\"dropdown\">"; $html .= '<a class="dropdown-toggle" data-toggle="dropdown" href="#">' . $this->translator->translate('Domains') . '</a>'; $html .= "<ul class=\"dropdown-menu\">"; foreach ($items as $item) { if (!empty($item['DomainsTldsData'][0]['name'])) { $item['registration_price'] = $currency->toCurrency($item['registration_price'], array('currency' => Settings::findbyParam('currency'))); $html .= '<li class="dropdown"><a title="' . Shineisp_Commons_Utilities::truncate(strip_tags($item['DomainsTldsData'][0]['description']), 150, "...", false, true) . '" href="/tlds/' . $item['DomainsTldsData'][0]['name'] . '.html">.<b>' . strtoupper($item['DomainsTldsData'][0]['name']) . "</b> - " . $item['registration_price'] . " (" . $this->translator->translate('Tax excluded') . ")</a></li>"; } } $html .= "</ul>"; $html .= "</li>"; } return $html; }
/** * Get the page layouts templates */ public static function getPageLayouts() { $items = array(); $customskin = Settings::findbyParam('skin'); $skin = !empty($customskin) ? $customskin : "blank"; $files = Shineisp_Commons_Utilities::getDirectoryList(PUBLIC_PATH . "/skins/default/{$skin}/scripts/"); $items[] = ""; foreach ($files as $file) { if (strpos($file, ".phtml")) { $filename = basename($file); $name = str_replace(".phtml", "", $filename); $items[$name] = $name; } } return $items; }
/** * Get the suggested price * @param integer $productid * @param boolean $taxincluded */ public static function getPriceSuggested($productid, $taxincluded = false) { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $price = 0; if (is_numeric($productid)) { $product = self::getAllInfo($productid); // Get the tax percentage $tax = Taxes::getTaxbyProductID($productid); if (!empty($product)) { if (!empty($product['price_1']) && $product['price_1'] > 0) { // Taxes calculation if (!empty($tax['percentage']) && is_numeric($tax['percentage'])) { $price = $product['price_1'] * ($tax['percentage'] + 100) / 100; $price = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency'))); } else { $price = $currency->toCurrency($product['price_1'], array('currency' => Settings::findbyParam('currency'))); } } else { $tranches = ProductsTranches::getSuggestedTranche($productid); if (!empty($tranches[0])) { $price = $tranches[0]['price'] * $tranches[0]['BillingCycle']['months']; } else { if (!empty($product['ProductsTranches'])) { $price = $product['ProductsTranches'][0]['price'] * $product['ProductsTranches'][0]['BillingCycle']['months']; } } } } // Taxes calculation if ($taxincluded && $price > 0 && !empty($tax['percentage']) && is_numeric($tax['percentage'])) { $price = $price * ($tax['percentage'] + 100) / 100; $price = $currency->toCurrency($price, array('currency' => Settings::findbyParam('currency'))); } return $price; } }
/** * Get the list of best customers * @return ArrayObject */ public static function Hitparade() { $currency = Shineisp_Registry::getInstance()->Zend_Currency; $translator = Shineisp_Registry::getInstance()->Zend_Translate; $dq = Doctrine_Query::create()->select("i.invoice_id, c.customer_id as id, c.lastname as lastname, c.firstname as firstname, c.company as company, SUM(o.grandtotal) as grandtotal")->from('Invoices i')->leftJoin('i.Customers c')->leftJoin('i.Orders o')->groupBy('o.customer_id')->orderBy('c.lastname')->orderBy('SUM(o.grandtotal) desc')->limit(20); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $logged_user = $auth->getIdentity(); $dq->whereIn("c.isp_id", $logged_user['isp_id']); } else { $dq->andWhere("c.isp_id = ?", Isp::getCurrentId()); } $records['data'] = $dq->execute(null, Doctrine::HYDRATE_ARRAY); for ($i = 0; $i < count($records['data']); $i++) { $records['data'][$i]['grandtotal'] = $currency->toCurrency($records['data'][$i]['grandtotal'], array('currency' => Settings::findbyParam('currency'))); } // adding the index reference $records['index'] = "id"; // Create the header table columns $records['fields'] = array('lastname' => array('label' => $translator->translate('Last name'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'firstname' => array('label' => $translator->translate('First name'), 'attributes' => array('class' => 'visible-lg visible-md hidden-xs')), 'company' => array('label' => $translator->translate('Company')), 'grandtotal' => array('label' => $translator->translate('Total'))); return $records; }
/** * Get all the services from the order details bought by the customers and by days range * @param integer $from [0 days] * @param integer $to [30 days] * @param integer $status * @param integer $autorenew [0, 1] */ public static function getExpiringServicesByRange($from = null, $to = null, $status = null, $autorenew = null, array $types = array(), array $attributegrpcode = array()) { $currency = Shineisp_Registry::getInstance()->Zend_Currency; try { $dq = Doctrine_Query::create()->select("oi.detail_id, oi.price as price, oid.relationship_id,\n\t \t\t\t\t\t\t\t\t\t\t pd.name as product,\n\t \t\t\t\t\t\t\t\t\t\t c.customer_id as id, \n\t \t\t\t\t\t\t\t\t\t\t DATE_FORMAT(oi.date_end, '" . Settings::getMySQLDateFormat('dateformat') . "') as expiringdate,\n\t \t\t\t\t\t\t\t\t\t\t o.customer_id as customer_id,\n\t \t\t\t\t\t\t\t\t\t\t c.language_id as language_id,\n\t \t\t\t\t\t\t\t\t\t\t Concat(c.firstname, ' ', c.lastname, ' ', c.company) as fullname, \n\t \t\t\t\t\t\t\t\t\t\t c.email as email, \n\t \t\t\t\t\t\t\t\t\t\t c.password as password,\n\t \t\t\t\t\t\t\t\t\t\t c.parent_id as reseller, \n\t \t\t\t\t\t\t\t\t\t\t oi.autorenew as renew,\n\t \t p.product_id as product_id,\n\t \t p.type as type,\n\t \t\t\t\t\t\t\t\t\t\t\t d.domain as domain_id,\n\t \t\t\t\t\t\t\t\t\t\t\t CONCAT(d.domain, '.', ws.tld) as domain, \n\t \t\t\t\t\t\t\t\t\t\t DATEDIFF(oi.date_end, CURRENT_DATE) as days")->from('OrdersItems oi')->leftJoin('oi.Orders o')->leftJoin('oi.OrdersItemsDomains oid')->leftJoin('oid.Domains d')->leftJoin('d.DomainsTlds dt')->leftJoin('dt.WhoisServers ws')->leftJoin('oi.Products p')->leftJoin('p.ProductsAttributesGroups pag')->leftJoin("p.ProductsData pd WITH pd.language_id = 1")->leftJoin('o.Customers c'); if (!empty($types)) { $dq->andWhereIn('p.type', $types); } else { $dq->where('p.type <> ?', 'domain'); } if (!empty($attributegrpcode)) { $dq->andWhereIn('pag.code', $attributegrpcode); } if (!is_null($from) && !is_null($to)) { $dq->andWhere('DATEDIFF(oi.date_end, CURRENT_DATE) >= ? and DATEDIFF(oi.date_end, CURRENT_DATE) <= ?', array($from, $to)); } if (is_numeric($status)) { $dq->andWhere('oi.status_id = ?', $status); } else { $dq->andWhere('oi.status_id = ?', Statuses::id("complete", "orders")); } if (is_numeric($autorenew)) { $dq->andWhere('oi.autorenew = ?', $autorenew); } $dq->orderBy('oi.date_end asc'); $records = $dq->execute(null, Doctrine::HYDRATE_ARRAY); for ($i = 0; $i < count($records); $i++) { $records[$i]['price'] = $currency->toCurrency($records[$i]['price'], array('currency' => Settings::findbyParam('currency'))); } return $records; } catch (Exception $e) { die($e->getMessage()); } }
public function getpriceAction() { $currency = Shineisp_Registry::get('Zend_Currency'); $translator = Shineisp_Registry::get('Zend_Translate'); $id = $this->getRequest()->getParam('id'); $refund = $this->getRequest()->getParam('refund'); $data = array(); if (is_numeric($id)) { $tranche = ProductsTranches::getTranchebyId($id); // JAY 20130409 - Add refund if exist $NS = new Zend_Session_Namespace('Default'); if (is_array($NS->upgrade)) { //Check if the product is OK for upgrade and if OK take refund foreach ($NS->upgrade as $orderid => $upgradeProduct) { if ($orderid != 0) { if (in_array($id, $upgradeProduct)) { $refundInfo = OrdersItems::getRefundInfo($orderid); $refund = $refundInfo['refund']; $idBillingCircle = $tranche['BillingCycle']['billing_cycle_id']; $monthBilling = BillingCycle::getMonthsNumber($idBillingCircle); if ($monthBilling > 0) { $priceToPay = $tranche['price'] * $monthBilling; $priceToPayWithRefund = $priceToPay - $refund; if ($priceToPayWithRefund < 0) { $priceToPayWithRefund = $priceToPay; } $tranche['price'] = round($priceToPayWithRefund / $monthBilling, 2); } else { $priceToPayWithRefund = $tranche['price'] - $refund; if ($priceToPayWithRefund > 0) { $tranche['price'] = $priceToPayWithRefund; } } break; } } } } $includes = ProductsTranchesIncludes::getIncludeForTrancheId($id); $textIncludes = array(); if (array_key_exists('domains', $includes)) { $textIncludes[] = $this->translator->translate('Domains Included') . ": " . implode(", ", $includes['domains']); } $textInclude = ""; if (!empty($textIncludes)) { $textInclude = implode("<br/>", $textIncludes); } // Prepare the data to send to the json $data['price'] = $tranche['price']; if (!empty($tranche['Products']['Taxes']['percentage']) && is_numeric($tranche['Products']['Taxes']['percentage'])) { $data['pricetax'] = $tranche['price'] * ($tranche['Products']['Taxes']['percentage'] + 100) / 100; } else { $data['pricetax'] = $tranche['price']; } $data['pricelbl'] = $currency->toCurrency($tranche['price'], array('currency' => Settings::findbyParam('currency'))); $data['months'] = $tranche['BillingCycle']['months']; $data['pricepermonths'] = $data['pricetax'] * $tranche['BillingCycle']['months']; $data['name'] = $this->translator->translate($tranche['BillingCycle']['name']); $data['pricetax'] = $currency->toCurrency($data['pricetax'], array('currency' => Settings::findbyParam('currency'))); $data['pricepermonths'] = $currency->toCurrency($data['pricepermonths'], array('currency' => Settings::findbyParam('currency'))); $data['setupfee'] = $currency->toCurrency($tranche['setupfee'], array('currency' => Settings::findbyParam('currency'))); $data['includes'] = $textInclude; } die(json_encode($data)); }