public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('TLD Name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('text', 'tags', array('filters' => array('StringTrim'), 'label' => $translate->_('Tags/Type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'ishighlighted', array('label' => $translate->_('Is Highlighted'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'isrefundable', array('label' => $translate->_('Is Refundable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('text', 'resultcontrol', array('filters' => array('StringTrim'), 'label' => $translate->_('Result String Control'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'registration_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Registration Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'renewal_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Renewal Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'transfer_price', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Transfer Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'server_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('TLD Server'), 'class' => 'form-control')); $this->getElement('server_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(WhoisServers::getList()); $this->addElement('select', 'tax_id', array('label' => $translate->_('Tax'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('tax_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Taxes::getList())->setRequired(true); $this->addElement('text', 'registration_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Registration Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'renewal_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Renewal Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'transfer_cost', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Transfer Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('select', 'registrars_id', array('label' => $translate->_('Registrars'), 'decorators' => array('Bootstrap'), 'class' => 'form-control updatechkdomain')); $this->getElement('registrars_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Registrars::getList(false))->setRequired(true); $this->addElement('submit', 'save', array('required' => false, 'label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn')); $this->addElement('hidden', 'tld_id'); }
/** * saveAll * Save all the data * @param $params * @return Boolean */ public static function saveAll($id, $params) { $date_end = null; if (!is_array($params)) { return false; } $details = Doctrine::getTable('OrdersItems')->find($id); // Generic price setting $rowtotal = $params['price']; $vat = null; $percentage = null; // Get the taxes applied $tax = Taxes::getTaxbyProductID($params['product_id']); if ($tax['percentage'] > 0) { $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100; $vat = $params['price'] * $tax['percentage'] / 100; $percentage = $tax['percentage']; } else { if (!empty($params['parameters'])) { // it is a domain $domainparams = json_decode($params['parameters'], true); if (!empty($domainparams['domain']['tld'])) { $tax = Taxes::getTaxbyTldID($domainparams['domain']['tld']); if ($tax['percentage'] > 0) { $vat = $params['price'] * $tax['percentage'] / 100; $percentage = $tax['percentage']; $rowtotal = $params['price'] * (100 + $tax['percentage']) / 100; } } } } if (!empty($params['billing_cycle_id'])) { $months = BillingCycle::getMonthsNumber($params['billing_cycle_id']); } if ($months > 0 && is_numeric($params['product_id']) && $params['product_id'] > 0) { // only for the product and services. Domains excluded $rowtotal = $rowtotal * $months; } $params['date_end'] = Shineisp_Commons_Utilities::add_date($params['date_start'], null, $months); $details->quantity = $params['quantity']; $details->date_start = Shineisp_Commons_Utilities::formatDateIn($params['date_start']); $details->date_end = Shineisp_Commons_Utilities::formatDateIn($params['date_end']); $details->billing_cycle_id = !empty($params['billing_cycle_id']) ? $params['billing_cycle_id'] : null; $details->price = $params['price']; $details->vat = $vat; $details->percentage = $percentage; $details->cost = $params['cost']; $details->product_id = is_numeric($params['product_id']) && $params['product_id'] > 0 ? $params['product_id'] : NULL; $details->setupfee = $params['setupfee']; $details->discount = $params['discount']; $details->subtotal = $rowtotal * $params['quantity']; $details->status_id = $params['status_id']; $details->description = $params['description']; $details->parameters = $params['parameters']; if ($details->trySave()) { OrdersItems::setAutorenew($id, $params['autorenew']); // Remove all domains OrdersItemsDomains::removeAllDomains($id); if ($params['domains_selected']) { foreach ($params['domains_selected'] as $domain) { OrdersItemsDomains::addDomain($details['order_id'], $domain); } } return true; } return false; }
/** * Get the price of the product * * If there's a refund subtrack to the price (20130409) * @param integer $productid * @param float $refund */ public static function getPrices($productid, $refund = false) { $prices = array(); 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) { if ($refund !== false) { $priceToPayWithRefund = $product['price_1'] - $refund; if ($priceToPayWithRefund < 0) { $product['price_1'] = $priceToPayWithRefund; } } // Taxes calculation if (!empty($tax['percentage']) && is_numeric($tax['percentage'])) { $taxincluded = $product['price_1'] * ($tax['percentage'] + 100) / 100; } else { $taxincluded = $product['price_1']; } return array('type' => 'flat', 'value' => $product['price_1'], 'taxincluded' => $taxincluded, 'taxes' => $tax); } else { // Get the price min & max interval tranches $tranches = ProductsTranches::getMinMaxTranches($productid); if (!empty($tranches[1])) { // Refund calculation price if ($refund !== false) { $idBillingCircle = $tranches[0]['BillingCycle']['billing_cycle_id']; $monthBilling = BillingCycle::getMonthsNumber($idBillingCircle); if ($monthBilling > 0) { $priceToPay = $tranches[0]['price'] * $monthBilling; $priceToPayWithRefund = $priceToPay - $refund; if ($priceToPayWithRefund < 0) { $priceToPayWithRefund = $priceToPay; } $tranches[0]['price'] = round($priceToPayWithRefund / $monthBilling, 2); } else { $priceToPayWithRefund = $tranches[0]['price'] - $refund; if ($priceToPayWithRefund > 0) { $tranches[0]['price'] = $priceToPayWithRefund; } } $idBillingCircle = $tranches[1]['BillingCycle']['billing_cycle_id']; $monthBilling = BillingCycle::getMonthsNumber($idBillingCircle); if ($monthBilling > 0) { $priceToPay = $tranches[1]['price'] * $monthBilling; $priceToPayWithRefund = $priceToPay - $refund; if ($priceToPayWithRefund < 0) { $priceToPayWithRefund = $priceToPay; } $tranches[1]['price'] = round($priceToPayWithRefund / $monthBilling, 2); } else { $priceToPayWithRefund = $tranches[1]['price'] - $refund; if ($priceToPayWithRefund > 0) { $tranches[1]['price'] = $priceToPayWithRefund; } } } // Taxes calculation if (!empty($tax['percentage']) && is_numeric($tax['percentage'])) { $minvaluewithtaxes = $tranches[0]['price'] * ($tax['percentage'] + 100) / 100; $maxvaluewithtaxes = $tranches[1]['price'] * ($tax['percentage'] + 100) / 100; } else { $minvaluewithtaxes = $tranches[0]['price']; $maxvaluewithtaxes = $tranches[1]['price']; } $discount = floatval($tranches[1]['price']) - floatval($tranches[0]['price']); $minvalue = $tranches[0]['price']; $maxvalue = $tranches[1]['price']; $data = array('type' => 'multiple', 'measurement' => $tranches[0]['measurement'], 'tranches' => $tranches, 'minvalue' => $minvalue, 'maxvalue' => $maxvalue, 'minvaluewithtaxes' => $minvaluewithtaxes, 'maxvaluewithtaxes' => $maxvaluewithtaxes, 'discount' => $discount, 'taxes' => $tax); return $data; } elseif (!empty($tranches['price'])) { // Taxes calculation if ($refund !== false) { $priceToPayWithRefund = $tranches['price'] - $refund; if ($priceToPayWithRefund < 0) { $tranches['price'] = $priceToPayWithRefund; } } if (!empty($tax['percentage']) && is_numeric($tax['percentage'])) { $minvaluewithtaxes = $tranches['price'] * ($tax['percentage'] + 100) / 100; } else { $minvaluewithtaxes = $tranches['price']; } $price = $tranches['price']; $data = array('type' => 'multiple', 'measurement' => $tranches['measurement'], 'minvalue' => $price, 'maxvalue' => $price, 'taxes' => $tax, 'minvaluewithtaxes' => $minvaluewithtaxes, 'maxvaluewithtaxes' => 0, 'discount' => 0); return $data; } } } } return array('type' => 'flat', 'value' => 0, 'taxincluded' => 0, 'taxes' => 0); }
function initQuery($params) { $tables = Taxes::getTables(); $c = $tables["tax_rates"]["columns"]; $this->addSelectField($c['id'], 'id'); $this->WhereValue($c['rates_set'], DB_EQ, $params['sid']); }
<?php require_once './classes/Taxes.php'; $taxes = new Taxes(); $list = $taxes->get_state_taxes_list(); echo $list; ?> <script type="text/javascript"> $(document).ready(function () { $(function () { $('#pagination').pagination({ items: 51, itemsOnPage: <?php echo $taxes->limit; ?> , cssStyle: 'light-theme' }); }); $("#pagination").click(function () { var page = $('#pagination').pagination('getCurrentPage'); console.log('Page: ' + page); var url = "/lms/custom/taxes/get_tax_item.php"; $.post(url, {id: page}).done(function (data) { $('#state_taxes').html(data); }); });
/** * print the order * * @param unknown_type $invoiceid */ public static function pdf($order_id, $show = true, $force = false, $path = "/documents/orders/") { $taxpercent = ""; $currency = Shineisp_Registry::getInstance()->Zend_Currency; if (!is_numeric($order_id)) { return false; } $pdf = new Shineisp_Commons_PdfOrder(); $translator = Shineisp_Registry::getInstance()->Zend_Translate; $payments = Payments::findbyorderid($order_id, null, true); $order = self::getAllInfo($order_id, null, true); // Set the name of the file $filename = $order[0]['order_date'] . " - " . $order[0]['order_id'] . ".pdf"; $database['header']['label'] = $translator->translate('Order No.') . " " . $order[0]['order_number'] . " - " . Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']); $database['columns'][] = array("value" => $translator->translate("SKU"), "size" => 40); $database['columns'][] = array("value" => $translator->translate("Description")); $database['columns'][] = array("value" => $translator->translate("Qty"), "size" => 30, "align" => "center"); $database['columns'][] = array("value" => $translator->translate("Unit"), "size" => 30); $database['columns'][] = array("value" => $translator->translate("Tax Free Price"), "size" => 60, "align" => "right"); $database['columns'][] = array("value" => $translator->translate("Discount"), "size" => 60, "align" => "right"); $database['columns'][] = array("value" => $translator->translate("Setup fee"), "size" => 60, "align" => "right"); $database['columns'][] = array("value" => $translator->translate("Tax %"), "size" => 40, "align" => "center"); $database['columns'][] = array("value" => $translator->translate("Total"), "size" => 50, "align" => "right"); if (isset($order[0])) { $orderinfo['order_number'] = !empty($order[0]['order_number']) ? $order[0]['order_number'] : self::formatOrderId($order[0]['order_id']); $orderinfo['invoice_id'] = ""; $orderinfo['date'] = Shineisp_Commons_Utilities::formatDateOut($order[0]['order_date']); //if customer comes from reseller if ($order[0]['Customers']['parent_id']) { $isTaxFree = Customers::isTaxFree($order[0]['Customers']['parent_id']); $isVATFree = Customers::isVATFree($order[0]['Customers']['parent_id']); $invoice_dest = Customers::getAllInfo($order[0]['Customers']['parent_id'], 'c.*, a.*'); $orderinfo['customer']['customer_id'] = $invoice_dest['customer_id']; $orderinfo['customer']['company'] = $invoice_dest['company']; $orderinfo['customer']['firstname'] = $invoice_dest['firstname']; $orderinfo['customer']['lastname'] = $invoice_dest['lastname']; $orderinfo['customer']['vat'] = $invoice_dest['vat']; $orderinfo['customer']['taxpayernumber'] = $invoice_dest['taxpayernumber']; $orderinfo['customer']['email'] = $invoice_dest['email']; if (isset($invoice_dest['Addresses'][0])) { $orderinfo['customer']['address'] = $invoice_dest['Addresses'][0]['address']; $orderinfo['customer']['city'] = $invoice_dest['Addresses'][0]['city']; $orderinfo['customer']['code'] = $invoice_dest['Addresses'][0]['code']; $orderinfo['customer']['country'] = !empty($invoice_dest['Addresses'][0]['Countries']['name']) ? $invoice_dest['Addresses'][0]['Countries']['name'] : ""; } } else { $isTaxFree = Customers::isTaxFree($order[0]['Customers']['customer_id']); $isVATFree = Customers::isVATFree($order[0]['Customers']['customer_id']); $orderinfo['customer']['customer_id'] = $order[0]['Customers']['customer_id']; $orderinfo['customer']['company'] = $order[0]['Customers']['company']; $orderinfo['customer']['firstname'] = $order[0]['Customers']['firstname']; $orderinfo['customer']['lastname'] = $order[0]['Customers']['lastname']; $orderinfo['customer']['vat'] = $order[0]['Customers']['vat']; $orderinfo['customer']['taxpayernumber'] = $order[0]['Customers']['taxpayernumber']; $orderinfo['customer']['email'] = $order[0]['Customers']['email']; if (isset($order[0]['Customers']['Addresses'][0])) { $orderinfo['customer']['address'] = $order[0]['Customers']['Addresses'][0]['address']; $orderinfo['customer']['city'] = $order[0]['Customers']['Addresses'][0]['city']; $orderinfo['customer']['code'] = $order[0]['Customers']['Addresses'][0]['code']; $orderinfo['customer']['country'] = $order[0]['Customers']['Addresses'][0]['Countries']['name']; } } if (count($payments) > 0) { $orderinfo['payment_date'] = Shineisp_Commons_Utilities::formatDateOut($payments[0]['paymentdate']); $orderinfo['payment_mode'] = $payments[0]['Banks']['name']; $orderinfo['payment_description'] = $payments[0]['description']; $orderinfo['payment_transaction_id'] = $payments[0]['reference']; } $orderinfo['invoice_id'] = ""; $orderinfo['company']['name'] = $order[0]['Isp']['company']; $orderinfo['company']['manager'] = $order[0]['Isp']['manager']; $orderinfo['company']['vat'] = $order[0]['Isp']['vatnumber']; $orderinfo['company']['bankname'] = $order[0]['Isp']['bankname']; $orderinfo['company']['iban'] = $order[0]['Isp']['iban']; $orderinfo['company']['bic'] = $order[0]['Isp']['bic']; $orderinfo['company']['address'] = $order[0]['Isp']['address']; $orderinfo['company']['zip'] = $order[0]['Isp']['zip']; $orderinfo['company']['city'] = $order[0]['Isp']['city']; $orderinfo['company']['country'] = $order[0]['Isp']['country']; $orderinfo['company']['telephone'] = $order[0]['Isp']['telephone']; $orderinfo['company']['fax'] = $order[0]['Isp']['fax']; $orderinfo['company']['website'] = $order[0]['Isp']['website']; $orderinfo['company']['email'] = $order[0]['Isp']['email']; $orderinfo['company']['slogan'] = $order[0]['Isp']['slogan']; $orderinfo['company']['custom1'] = $order[0]['Isp']['custom1']; $orderinfo['company']['custom2'] = $order[0]['Isp']['custom2']; $orderinfo['company']['custom3'] = $order[0]['Isp']['custom3']; if ($order[0]['status_id'] == Statuses::id("tobepaid", "orders")) { // To be payed $orderinfo['ribbon']['text'] = $translator->translate("To be Paid"); $orderinfo['ribbon']['color'] = "#D60000"; $orderinfo['ribbon']['border-color'] = "#BD0000"; } elseif ($order[0]['status_id'] == Statuses::id("complete", "orders")) { // Complete $orderinfo['ribbon']['text'] = $translator->translate("Paid"); $orderinfo['ribbon']['color'] = "#009926"; $orderinfo['ribbon']['border-color'] = "#00661A"; } else { $orderinfo['ribbon']['text'] = $translator->translate(Statuses::getLabel($order[0]['status_id'])); $orderinfo['ribbon']['color'] = "#FFCC33"; $orderinfo['ribbon']['border-color'] = "#E6AC00"; } $orderinfo['subtotal'] = $order[0]['total']; $orderinfo['grandtotal'] = $order[0]['grandtotal']; $orderinfo['vat'] = $order[0]['vat']; $orderinfo['delivery'] = 0; $database['records'] = $orderinfo; foreach ($order[0]['OrdersItems'] as $item) { $price = $item['price'] * $item['quantity'] + $item['setupfee']; $tax = Taxes::getTaxbyProductID($item['product_id']); if ($tax['percentage'] > 0) { $rowtotal = $price * (100 + $tax['percentage']) / 100; } else { $rowtotal = $price; } if (!$isTaxFree && !$isVATFree) { $taxes = Taxes::getTaxbyProductID($item['product_id']); if (!empty($taxes['percentage'])) { $taxpercent = $taxes['percentage']; } } if (!empty($item['discount'])) { $item['discount'] = $item['discount'] . "%"; } $database['records'][] = array($item['Products']['sku'], $item['description'], $item['quantity'], $translator->translate('nr'), $item['price'], $item['discount'], $item['setupfee'], $taxpercent, $rowtotal); } if (isset($order[0])) { $pdf->CreatePDF($database, $filename, $show, $path, $force); // Execute a custom event self::events()->trigger('orders_pdf_created', "Orders", array('file' => "{$path}/{$filename}")); return $path . $filename; } } return false; }
<?php require_once './classes/Taxes.php'; $taxes = new Taxes(); $id = $_POST['id']; $list = $taxes->get_tax_item($id); echo $list;
<?php require_once './classes/Taxes.php'; $taxes = new Taxes(); $id = $_POST['id']; $value = $_POST['tax']; $list = $taxes->update_state_tax($id, $value); echo $list;
/** * Get the price and cost of a tld * * @param integer $tld * @param string $mode [registration, transfer] * @return array or boolean false */ public static function getPrice($tldId, $mode = "registerDomain") { if (is_numeric($tldId)) { $tld = self::getAllInfo($tldId); if ($tld) { if ($mode == "registerDomain") { $cost = $tld['registration_cost']; $price = $tld['registration_price']; } else { $cost = $tld['transfer_cost']; $price = $tld['transfer_price']; } $totalTaxIncluded = $price * (100 + Taxes::get_percentage($tld['tax_id'])) / 100; return array('price' => $price, 'setupfee' => 0, 'cost' => $cost, 'tax_id' => $tld['tax_id'], 'pricetax' => $totalTaxIncluded); } } return false; }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Product name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'nickname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Product Nickname'), 'description' => $translate->_('This is the short name of the product'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'uri', array('filters' => array('StringTrim'), 'label' => $translate->_('URI'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'sku', array('filters' => array('StringTrim'), 'label' => $translate->_('SKU'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'shortdescription', array('filters' => array('StringTrim'), 'label' => $translate->_('Short Description'), 'id' => 'shortdescription', 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('textarea', 'metakeywords', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Keywords'), 'rows' => 5, 'class' => 'col-lg-12 form-control')); $this->addElement('textarea', 'metadescription', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Meta Description'), 'rows' => 5, 'class' => 'col-lg-12 form-control')); $this->addElement('textarea', 'description', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'id' => 'description', 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('select', 'category_id', array('label' => $translate->_('Category'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ProductsCategories::getList()); $this->addElement('select', 'welcome_mail_id', array('label' => $translate->_('Welcome E-Mail'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('welcome_mail_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(EmailsTemplates::getList()); $this->addElement('select', 'server_group_id', array('label' => $translate->_('Server group'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('server_group_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ServersGroups::getList(true)); $this->addElement('select', 'autosetup', array('label' => $translate->_('Automatic setup'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('autosetup')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(array('0' => 'Do not automatically setup this product', '1' => 'Automatically setup the product as soon as an order is placed', '2' => 'Automatically setup the product as soon as the first payment is received', '3' => 'Automatically setup the product when you manually accept a pending order', '4' => 'Automatically setup the product as soon as the payment is complete')); $this->addElement('multiselect', 'related', array('label' => $translate->_('Related Products'), 'decorators' => array('Bootstrap'), 'size' => '20x', 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4')); $this->addElement('multiselect', 'upgrade', array('label' => $translate->_('Product Upgrades'), 'decorators' => array('Bootstrap'), 'size' => '20x', 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4')); $this->getElement('related')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Products::getList()); $this->getElement('upgrade')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Products::getList()); $this->addElement('select', 'tax_id', array('label' => 'Tax', 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('tax_id')->setAllowEmpty(false)->setMultiOptions(Taxes::getList(true)); $this->addElement('text', 'cost', array('filters' => array('StringTrim'), 'label' => $translate->_('Cost'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'price_1', array('filters' => array('StringTrim'), 'label' => $translate->_('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('textarea', 'setup', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('XML Setup Configuration. See the manual'), 'class' => 'col-lg-12 form-control')); $this->addElement('select', 'enabled', array('label' => $translate->_('Enabled'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'Disabled', '1' => 'Active'))); $this->addElement('select', 'ishighlighted', array('label' => $translate->_('Is Highlighted'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'isrefundable', array('label' => $translate->_('Is Refundable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'default', array('label' => $translate->_('Default Image'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'iscomparable', array('label' => $translate->_('Is Comparable'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'showonrss', array('label' => $translate->_('Publish on RSS Feed'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'downgradable', array('label' => $translate->_('Allow downgrades'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('0' => 'No', '1' => 'Yes'))); $this->addElement('select', 'type', array('label' => $translate->_('Product Type'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('generic' => $translate->_('Generic'), 'domain' => $translate->_('Domain'), 'hosting' => $translate->_('Hosting')))); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $this->addElement('text', 'filedescription', array('filters' => array('StringTrim'), 'label' => $translate->_('Description'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $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')); $file->addValidator('Extension', false, $filetypes)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } $this->addElement('multiselect', 'wikipages', array('label' => $translate->_('Wiki Pages'), 'decorators' => array('Bootstrap'), 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4')); $this->getElement('wikipages')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Wiki::getList()); $this->addElement('select', 'tranche_billing_cycle_id', array('label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('tranche_billing_cycle_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(BillingCycle::getList()); $this->addElement('text', 'tranche_qty', array('filters' => array('StringTrim'), 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'tranche_measure', array('filters' => array('StringTrim'), 'label' => $translate->_('Measurement label'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'tranche_setupfee', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup fee'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'tranche_price', array('filters' => array('StringTrim'), 'label' => $translate->_('Unit Price'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('multiselect', 'tranche_includes_domains', array('isArray' => true, 'label' => $translate->_('Domain included'), 'decorators' => array('Bootstrap'), 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4')); $this->getElement('tranche_includes_domains')->setAllowEmpty(true)->setRegisterInArrayValidator(false)->setMultiOptions(DomainsTlds::getList()); $this->addElement('select', 'group_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Attribute Group'), 'required' => true, 'class' => 'form-control')); $this->getElement('group_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ProductsAttributesGroups::getList()); $this->addElement('text', 'position', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Position'), 'class' => 'form-control')); $this->addElement('textarea', 'blocks', array('filters' => array('StringTrim'), 'label' => $translate->_('Blocks'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control')); $this->addElement('hidden', 'product_id'); }
/** * Calculate the subtotal for each product in the cart * * @param integer $id * @param integer $qty * @param boolean $isvatfree * @return ArrayObject */ private function calcSubtotal(CartItem $item, $isvatfree = false) { foreach ($this->items as $item) { $isrecurring = false; $months = 0; $percentage = 0; $tax = 0; if ("domain" == $item->getType()) { $item->setIsrecurring(true); // Get the billyng cycle / term / recurring period price if ($item->getTerm()) { $priceInfo = ProductsTranches::getTranchebyId($item->getTerm()); $item->setBillingid($priceInfo['BillingCycle']['billing_cycle_id']); $months = $priceInfo['BillingCycle']['months']; } else { $priceInfo = BillingCycle::getDefaultDomainBillingCycle(); $item->setBillingid($priceInfo['billing_cycle_id']); $months = $priceInfo['months']; } $unitprice = $item->getUnitPrice(); $setupfee = 0; // Calculate the price per Quantity $subtotal = $unitprice * $item->getQty(); // check the taxes if (Taxes::get_percentage($item->getTaxId())) { $percentage = Taxes::get_percentage($item->getTaxId()); $tax = $subtotal * $percentage / 100; $price = $subtotal * (100 + $percentage) / 100; } } else { // Get all the product information $product = Products::getAllInfo($item->getId()); // Check the type of the product and get the price information if ($product['ProductsAttributesGroups']['isrecurring']) { $item->setIsrecurring(true); // Get the billyng cycle / term / recurring period price $priceInfo = ProductsTranches::getTranchebyId($item->getTerm()); // Price multiplier $months = $priceInfo['BillingCycle']['months']; $unitprice = $priceInfo['price']; $setupfee = $priceInfo['setupfee']; // Calculate the price per the months per Quantity $subtotal = $unitprice * $months * $item->getQty(); $item->setBillingid($priceInfo['BillingCycle']['billing_cycle_id']); } else { $item->setIsrecurring(false); $unitprice = $product['price_1']; $setupfee = $product['setupfee']; // Calculate the price per Quantity $subtotal = $unitprice * $item->getQty(); } // check the taxes for each product if (!empty($product['tax_id']) && !$isvatfree) { if (!empty($product['Taxes']['percentage']) && is_numeric($product['Taxes']['percentage'])) { $percentage = $product['Taxes']['percentage']; $tax = $subtotal * $percentage / 100; $price = $subtotal * (100 + $percentage) / 100; } } } // ... and add the setup fees $price = $subtotal + $setupfee; $item->setSubtotals(array('months' => $months, 'subtotal' => $subtotal, 'setupfee' => $setupfee, 'price' => $price, 'taxes' => $tax, 'percentage' => $percentage)); } return $this->items; }
/** * editAction * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/admin/taxes/process'); //* GUEST - ALE - 20130322: Rimosso setLabel in quanto il campo non e' presente nella form // $id = $this->getRequest()->getParam('id'); // 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/taxes/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/taxes/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); if (!empty($id) && is_numeric($id)) { $rs = Taxes::find($id, null, true); if (!empty($rs[0])) { $form->populate($rs[0]); $this->view->buttons[] = array("url" => "/admin/taxes/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => null)); } } $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->title = $this->translator->translate("Tax edit"); $this->view->description = $this->translator->translate("Here you can edit the tax percentage data."); $this->view->form = $form; $this->render('applicantform'); }
/** * Installs the specified module in the system. * * The uninstall() method is called statically. * To call other methods of this class from this method, * the static call is used, for example, * News::getTables() instead of $this->getTables() */ function uninstall() { global $application; $query = new DB_Table_Delete(Taxes::getTables()); $application->db->getDB_Result($query); }