diff --git a/controllers/front/quote.php b/controllers/front/quote.php index 051350a..cbe90b3 100644 --- a/controllers/front/quote.php +++ b/controllers/front/quote.php @@ -182,17 +182,16 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i // Then add product $ever_cart->addProductToQuoteCart( - (int)$id_product, - (int)$id_product_attribute, - (int)$id_customization, - (int)$qty + (int) $id_product, + (int) $id_product_attribute, + (int) $id_customization, + (int) $qty ); // Get ever cart informations $cart_details = $ever_cart->getSummaryDetails( - (int)$cart->id + (int) $cart->id ); - // die(var_dump($cart_details)); $cart_products = $ever_cart->getProducts(); // Now create quotation @@ -247,7 +246,6 @@ private function createSimpleProductQuote($id_product, $id_product_attribute, $i $total = (float) $price_without_tax * (int) $cart_product['cart_quantity']; // $product_taxes = $price_with_tax - $price_without_tax; // $total_product_taxes = $total_wt - $total; - // die(var_dump($price_without_tax)); $quotedetail = new EverpsquotationDetail(); $quotedetail->id_everpsquotation_quotes = (int) $quote->id; // $quotedetail->id_warehouse = (int)$cart_details['total_discounts']['id_warehouse']; @@ -347,7 +345,7 @@ private function setCartAsQuote(): int } parent::initContent(); - $customer = new Customer((int)$cart->id_customer); + $customer = new Customer((int) $cart->id_customer); if (!Validate::isLoadedObject($customer)) { Tools::redirect('index.php?controller=order&step=1'); @@ -369,7 +367,7 @@ private function setCartAsQuote(): int Hook::exec('actionBeforeCreateEverQuote'); $id_quote_cart = EverpsquotationCart::copyCartToQuoteCart( - (int)$cart->id + (int) $cart->id ); if (!Validate::isInt($id_quote_cart)) { die($this->trans('An error has occured.', array(), 'Modules.Everpsquotation.Shop')); @@ -380,31 +378,31 @@ private function setCartAsQuote(): int $cartproducts = $cart->getProducts(); $quote = new EverpsquotationClass(); - $quote->reference = (string)Configuration::get('EVERPSQUOTATION_PREFIX'); - $quote->id_shop_group = (int)$cart->id_shop_group; - $quote->id_shop = (int)$cart->id_shop; - $quote->id_carrier = (int)$cart->id_carrier; - $quote->id_lang = (int)$cart->id_lang; - $quote->id_customer = (int)$cart->id_customer; - $quote->id_cart = (int)$cart->id; - $quote->id_currency = (int)$cart->id_currency; - $quote->id_address_delivery = (int)$cart->id_address_delivery; - $quote->id_address_invoice = (int)$cart->id_address_invoice; - $quote->secure_key = (string)$cart->secure_key; - $quote->recyclable = (int)$cart->recyclable; - $quote->total_discounts = (float)$cartdetails['total_discounts']; - $quote->total_discounts_tax_incl = (float)$cartdetails['total_discounts']; - $quote->total_discounts_tax_excl = (float)$cartdetails['total_discounts_tax_exc']; - $quote->total_paid_tax_incl = (float)$cartdetails['total_price']; - $quote->total_paid_tax_excl = (float)$cartdetails['total_price_without_tax']; - $quote->total_products = (float)$cartdetails['total_products']; - $quote->total_products_wt = (float)$cartdetails['total_products_wt']; - $quote->total_shipping = (float)$cartdetails['total_shipping']; - $quote->total_shipping_tax_incl = (float)$cartdetails['total_shipping']; - $quote->total_shipping_tax_excl = (float)$cartdetails['total_shipping_tax_exc']; - $quote->total_wrapping = (float)$cartdetails['total_wrapping']; - $quote->total_wrapping_tax_incl = (float)$cartdetails['total_wrapping']; - $quote->total_wrapping_tax_excl = (float)$cartdetails['total_wrapping_tax_exc']; + $quote->reference = (string) Configuration::get('EVERPSQUOTATION_PREFIX'); + $quote->id_shop_group = (int) $cart->id_shop_group; + $quote->id_shop = (int) $cart->id_shop; + $quote->id_carrier = (int) $cart->id_carrier; + $quote->id_lang = (int) $cart->id_lang; + $quote->id_customer = (int) $cart->id_customer; + $quote->id_cart = (int) $cart->id; + $quote->id_currency = (int) $cart->id_currency; + $quote->id_address_delivery = (int) $cart->id_address_delivery; + $quote->id_address_invoice = (int) $cart->id_address_invoice; + $quote->secure_key = (string) $cart->secure_key; + $quote->recyclable = (int) $cart->recyclable; + $quote->total_discounts = (float) $cartdetails['total_discounts']; + $quote->total_discounts_tax_incl = (float) $cartdetails['total_discounts']; + $quote->total_discounts_tax_excl = (float) $cartdetails['total_discounts_tax_exc']; + $quote->total_paid_tax_incl = (float) $cartdetails['total_price']; + $quote->total_paid_tax_excl = (float) $cartdetails['total_price_without_tax']; + $quote->total_products = (float) $cartdetails['total_products']; + $quote->total_products_wt = (float) $cartdetails['total_products_wt']; + $quote->total_shipping = (float) $cartdetails['total_shipping']; + $quote->total_shipping_tax_incl = (float) $cartdetails['total_shipping']; + $quote->total_shipping_tax_excl = (float) $cartdetails['total_shipping_tax_exc']; + $quote->total_wrapping = (float) $cartdetails['total_wrapping']; + $quote->total_wrapping_tax_incl = (float) $cartdetails['total_wrapping']; + $quote->total_wrapping_tax_excl = (float) $cartdetails['total_wrapping_tax_exc']; $quote->valid = 0; $quote->date_add = date('Y-m-d H:i:s'); $quote->date_upd = date('Y-m-d H:i:s'); @@ -413,26 +411,26 @@ private function setCartAsQuote(): int //Now create new Everpsquotationdetail object foreach ($cartproducts as $cartproduct) { $quotedetail = new EverpsquotationDetail(); - $quotedetail->id_everpsquotation_quotes = (int)$quote->id; - $quotedetail->id_shop = (int)$cartproduct['id_shop']; - $quotedetail->product_id = (int)$cartproduct['id_product']; - $quotedetail->product_attribute_id = (int)$cartproduct['id_product_attribute']; - $quotedetail->id_customization = (int)$cartproduct['id_customization']; - $quotedetail->product_name = (string)$cartproduct['name']; - $quotedetail->product_quantity = (int)$cartproduct['cart_quantity']; - $quotedetail->product_quantity_in_stock = (int)$cartproduct['stock_quantity']; + $quotedetail->id_everpsquotation_quotes = (int) $quote->id; + $quotedetail->id_shop = (int) $cartproduct['id_shop']; + $quotedetail->product_id = (int) $cartproduct['id_product']; + $quotedetail->product_attribute_id = (int) $cartproduct['id_product_attribute']; + $quotedetail->id_customization = (int) $cartproduct['id_customization']; + $quotedetail->product_name = (string) $cartproduct['name']; + $quotedetail->product_quantity = (int) $cartproduct['cart_quantity']; + $quotedetail->product_quantity_in_stock = (int) $cartproduct['stock_quantity']; $quotedetail->product_price = $cartproduct['price']; - $quotedetail->product_ean13 = (string)$cartproduct['ean13']; - $quotedetail->product_isbn = (string)$cartproduct['isbn']; - $quotedetail->product_upc = (string)$cartproduct['upc']; - $quotedetail->product_reference = (string)$cartproduct['reference']; - $quotedetail->product_supplier_reference = (string)$cartproduct['supplier_reference']; - $quotedetail->product_weight = (float)$cartproduct['weight']; - $quotedetail->tax_name = (string)$cartproduct['tax_name']; - $quotedetail->ecotax = (float)$cartproduct['ecotax']; - $quotedetail->unit_price_tax_excl = (float)$cartproduct['price']; - $quotedetail->total_price_tax_incl = (float)$cartproduct['total_wt']; - $quotedetail->total_price_tax_excl = (float)$cartproduct['total']; + $quotedetail->product_ean13 = (string) $cartproduct['ean13']; + $quotedetail->product_isbn = (string) $cartproduct['isbn']; + $quotedetail->product_upc = (string) $cartproduct['upc']; + $quotedetail->product_reference = (string) $cartproduct['reference']; + $quotedetail->product_supplier_reference = (string) $cartproduct['supplier_reference']; + $quotedetail->product_weight = (float) $cartproduct['weight']; + $quotedetail->tax_name = (string) $cartproduct['tax_name']; + $quotedetail->ecotax = (float) $cartproduct['ecotax']; + $quotedetail->unit_price_tax_excl = (float) $cartproduct['price']; + $quotedetail->total_price_tax_incl = (float) $cartproduct['total_wt']; + $quotedetail->total_price_tax_excl = (float) $cartproduct['total']; $quotedetail->add(); } Hook::exec('actionAfterCreateEverQuote'); @@ -454,7 +452,7 @@ private function setCartAsQuote(): int $id_shop = (int) Context::getContext()->shop->id; $mailDir = _PS_MODULE_DIR_ . 'everpsquotation/mails/'; $pdf = new PDF($quote->id, 'EverQuotationPdf', Context::getContext()->smarty); - $customerNames = $customer->firstname.' '.$customer->lastname; + $customerNames = $customer->firstname . ' ' . $customer->lastname; $attachment = array(); $attachment['content'] = $pdf->render(false); $attachment['name'] = $ever_filename; @@ -465,11 +463,11 @@ private function setCartAsQuote(): int (string)$subject, array( '{shop_name}' => Configuration::get('PS_SHOP_NAME'), - '{shop_logo}'=>_PS_IMG_DIR_.Configuration::get( + '{shop_logo}'=>_PS_IMG_DIR_ . Configuration::get( 'PS_LOGO', null, null, - (int)$id_shop + (int) $id_shop ), '{firstname}' => (string) $customer->firstname, '{lastname}' => (string) $customer->lastname, diff --git a/everpsquotation.php b/everpsquotation.php index 0323444..9b996a8 100644 --- a/everpsquotation.php +++ b/everpsquotation.php @@ -39,7 +39,7 @@ public function __construct() { $this->name = 'everpsquotation'; $this->tab = 'payments_gateways'; - $this->version = '5.1.0'; + $this->version = '5.1.1'; $this->author = 'Team Ever'; $this->need_instance = 0; $this->bootstrap = true; @@ -512,15 +512,6 @@ protected function getConfigForm() 'required' => true, 'tree' => $tree, ], - [ - 'col' => 3, - 'type' => 'text', - 'lang' => false, - 'label' => $this->l('Conversion ID for Google Ads'), - 'desc' => $this->l('Please set here transaction id for Google Ads, such as AW-XXXXXXXXX/XXXXXXXXXXX'), - 'hint' => $this->l('Will be used to track quotation creation using Google Ads'), - 'name' => 'EVERPSQUOTATION_TRANSACTION_ID', - ], ], 'submit' => [ 'title' => $this->l('Save'), @@ -736,11 +727,6 @@ protected function postProcess() Tools::getValue('EVERPSQUOTATION_SUGGEST_CONNECT_UNLOGGED') ); - Configuration::updateValue( - 'EVERPSQUOTATION_TRANSACTION_ID', - Tools::getValue('EVERPSQUOTATION_TRANSACTION_ID') - ); - /* Uploads image */ $type = Tools::strtolower(Tools::substr(strrchr($_FILES['image']['name'], '.'), 1)); $imagesize = @getimagesize($_FILES['image']['tmp_name']); @@ -872,9 +858,6 @@ protected function getConfigFormValues() 'EVERPSQUOTATION_DURATION' => Configuration::get( 'EVERPSQUOTATION_DURATION' ), - 'EVERPSQUOTATION_TRANSACTION_ID' => Configuration::get( - 'EVERPSQUOTATION_TRANSACTION_ID' - ), ]; } @@ -974,7 +957,6 @@ public function hookHeader($params) Media::addJsDef([ $this->name . '_quote_link ' => $quoteAjaxLink, $this->name . '_quoterequest_link ' => $quoteRequestAjaxLink, - 'quotation_event_id' => Configuration::get('EVERPSQUOTATION_TRANSACTION_ID'), ]); if ($controller_name == 'product') { $this->context->controller->addJs($this->_path.'views/js/createProductQuote.js'); diff --git a/models/EverpsquotationCart.php b/models/EverpsquotationCart.php index 43b6ef0..60d3fc3 100644 --- a/models/EverpsquotationCart.php +++ b/models/EverpsquotationCart.php @@ -252,29 +252,29 @@ public function getProductQtyFromQuoteCart($id_product, $id_product_attribute, $ public function addProductToQuoteCart($id_product, $id_product_attribute, $id_customization, $qty) { - $cart_qty = (int)$this->getProductQtyFromQuoteCart( - (int)$id_product, - (int)$id_product_attribute, - (int)$id_customization + $cart_qty = (int) $this->getProductQtyFromQuoteCart( + (int) $id_product, + (int) $id_product_attribute, + (int) $id_customization ); if ($cart_qty > 0) { return $this->updateProductToQuoteCart( - (int)$id_product, - (int)$id_product_attribute, - (int)$id_customization, - (int)$qty + (int) $id_product, + (int) $id_product_attribute, + (int) $id_customization, + (int) $qty ); } return Db::getInstance()->insert( 'everpsquotation_cart_product', array( - 'id_everpsquotation_cart' => (int)$this->id, - 'id_product' => (int)$id_product, - 'id_address_delivery' => (int)$this->id_address_delivery, - 'id_shop' => (int)$this->id_shop, - 'id_product_attribute' => (int)$id_product_attribute, - 'id_customization' => (int)$id_customization, - 'quantity' => (int)$qty, + 'id_everpsquotation_cart' => (int) $this->id, + 'id_product' => (int) $id_product, + 'id_address_delivery' => (int) $this->id_address_delivery, + 'id_shop' => (int) $this->id_shop, + 'id_product_attribute' => (int) $id_product_attribute, + 'id_customization' => (int) $id_customization, + 'quantity' => (int) $qty, 'date_add' => date('Y-m-d H:i:s') ), false, @@ -285,14 +285,14 @@ public function addProductToQuoteCart($id_product, $id_product_attribute, $id_cu public function updateProductToQuoteCart($id_product, $id_product_attribute, $id_customization, $qty) { - $where = 'id_everpsquotation_cart = '.(int)$this->id.' - AND id_product = '.(int)$id_product.' - AND id_product_attribute = '.(int)$id_product_attribute.' - AND id_customization = '.(int)$id_customization; + $where = 'id_everpsquotation_cart = ' . (int) $this->id.' + AND id_product = ' . (int) $id_product.' + AND id_product_attribute = ' . (int) $id_product_attribute.' + AND id_customization = ' . (int) $id_customization; return Db::getInstance()->update( 'everpsquotation_cart_product', array( - 'quantity' => (int)$qty + 'quantity' => (int) $qty ), $where ); @@ -300,10 +300,10 @@ public function updateProductToQuoteCart($id_product, $id_product_attribute, $id public function deleteProductFromEverCart($id_product, $id_product_attribute, $id_customization) { - $where = 'id_everpsquotation_cart = '.(int)$this->id.' - AND id_product = '.(int)$id_product.' - AND id_product_attribute = '.(int)$id_product_attribute.' - AND id_customization = '.(int)$id_customization; + $where = 'id_everpsquotation_cart = ' . (int) $this->id . ' + AND id_product = ' . (int) $id_product . ' + AND id_product_attribute = ' . (int) $id_product_attribute . ' + AND id_customization = ' . (int) $id_customization; return Db::getInstance()->delete( 'everpsquotation_cart_product', $where @@ -312,7 +312,7 @@ public function deleteProductFromEverCart($id_product, $id_product_attribute, $i public function dropQuoteCartProducts() { - $where = 'id_everpsquotation_cart = '.(int)$this->id; + $where = 'id_everpsquotation_cart = ' . (int) $this->id; Db::getInstance()->delete( 'everpsquotation_cart_product', $where @@ -326,7 +326,7 @@ public function dropQuoteCartProducts() public function getSummaryDetails($id_cart) { $cart = new Cart( - (int)$id_cart + (int) $id_cart ); $delivery = new Address((int) $this->id_address_delivery); $invoice = new Address((int) $this->id_address_invoice); @@ -350,18 +350,18 @@ public function getSummaryDetails($id_cart) foreach ($products as $key => &$product) { $product['price_without_quantity_discount'] = Product::getPriceStatic( - (int)$product['id_product'], + (int) $product['id_product'], !Product::getTaxCalculationMethod(), - (int)$product['id_product_attribute'], + (int) $product['id_product_attribute'], 6, null, false, false ); $product['price_wt'] = Product::getPriceStatic( - (int)$product['id_product'], + (int) $product['id_product'], true, - (int)$product['id_product_attribute'], + (int) $product['id_product_attribute'], 6, null, false, @@ -417,7 +417,7 @@ public function getProducts() } $id_lang = (int)Context::getContext()->language->id; $address = new Address( - (int)$this->id_address_delivery + (int) $this->id_address_delivery ); $id_country = $address->id_country; // Build query @@ -457,7 +457,7 @@ public function getProducts() 'product_lang', 'pl', 'p.`id_product` = pl.`id_product` - AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang( + AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang( 'pl', 'cp.id_shop' ) @@ -467,7 +467,7 @@ public function getProducts() 'category_lang', 'cl', 'product_shop.`id_category_default` = cl.`id_category` - AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang( + AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang( 'cl', 'cp.id_shop' ) @@ -542,13 +542,13 @@ public function getProducts() 'image_shop', 'image_shop', 'image_shop.`id_product` = p.`id_product` - AND image_shop.cover=1 AND image_shop.id_shop='.(int)$this->id_shop + AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $this->id_shop ); $sql->leftJoin( 'image_lang', 'il', 'il.`id_image` = image_shop.`id_image` - AND il.`id_lang` = '.(int)$id_lang + AND il.`id_lang` = ' . (int) $id_lang ); $result = Db::getInstance()->executeS($sql); @@ -601,8 +601,6 @@ public function getProducts() $row['price_without_reduction'] = $additionalRow['price_without_reduction']; $row['specific_prices'] = $additionalRow['specific_prices']; unset($additionalRow); - - $this->_products[] = $row; } return $this->_products; diff --git a/models/HTMLTemplateEverQuotationPdf.php b/models/HTMLTemplateEverQuotationPdf.php index 246eb83..4a12c33 100644 --- a/models/HTMLTemplateEverQuotationPdf.php +++ b/models/HTMLTemplateEverQuotationPdf.php @@ -35,12 +35,12 @@ public function __construct($id_everpsquotation_quotes, $smarty) $this->pdfDir = _PS_MODULE_DIR_ . 'everpsquotation/views/templates/front/pdf/'; $this->context = Context::getContext(); $this->shop = new Shop(Context::getContext()->shop->id); - $this->lang = new Language((int)Context::getContext()->language->id); - $this->text = $text[(int)Context::getContext()->language->id]; - $this->mentions = $mentions[(int)Context::getContext()->language->id]; + $this->lang = new Language((int) Context::getContext()->language->id); + $this->text = $text[(int) Context::getContext()->language->id]; + $this->mentions = $mentions[(int) Context::getContext()->language->id]; $this->duration = Configuration::get('EVERPSQUOTATION_DURATION'); - $this->filename = $filename[(int)Context::getContext()->language->id] - .$this->id_everpsquotation_quotes; + $this->filename = $filename[(int) Context::getContext()->language->id] + . $this->id_everpsquotation_quotes; } /** @@ -50,7 +50,7 @@ public function __construct($id_everpsquotation_quotes, $smarty) public function getContent() { $everpsquotation = new EverpsquotationClass( - (int)$this->id_everpsquotation_quotes + (int) $this->id_everpsquotation_quotes ); $everpsquotation->date_add = date( 'd/m/Y', @@ -63,19 +63,19 @@ public function getContent() ); $customizations = array(); foreach ($details as $detail) { - if ((int)$detail['id_customization']) { + if ((int) $detail['id_customization']) { $custs = EverpsquotationDetail::getCustomizationValue( - (int)$detail['id_customization'] - ); - $customizations[] = array( - 'product_id' => (int)$detail['product_id'], - 'customizations' => $custs + (int) $detail['id_customization'] ); + $customizations[] = [ + 'product_id' => (int) $detail['product_id'], + 'customizations' => $custs, + ]; } } $total_taxes = $everpsquotation->total_paid_tax_incl - $everpsquotation->total_paid_tax_excl; - $this->smarty->assign(array( + $this->smarty->assign([ '_PS_VERSION_' => _PS_VERSION_, 'details' => $details, 'customizations' => $customizations, @@ -95,7 +95,7 @@ public function getContent() 'total_taxes' => $total_taxes, 'date_add' => $everpsquotation->date_add, 'everpsquotationmentions' => $this->mentions, - )); + ]); return $this->smarty->fetch($this->pdfDir . '/everquotation_content.tpl'); } @@ -118,17 +118,17 @@ public function getHeader() $deadline = false; } - if (file_exists(_PS_MODULE_DIR_.'everpsquotation/views/img/quotation.jpg')) { - $pathLogo = _PS_MODULE_DIR_.'everpsquotation/views/img/quotation.jpg'; + if (file_exists(_PS_MODULE_DIR_ . 'everpsquotation/views/img/quotation.jpg')) { + $pathLogo = _PS_MODULE_DIR_ . 'everpsquotation/views/img/quotation.jpg'; } else { - $pathLogo = __PS_BASE_URI__.'img/'.Configuration::get( + $pathLogo = __PS_BASE_URI__ . 'img/' . Configuration::get( 'PS_LOGO' ); } - $width = (int)Configuration::get('EVERPSQUOTATION_LOGO_WIDTH'); + $width = (int) Configuration::get('EVERPSQUOTATION_LOGO_WIDTH'); - $this->smarty->assign(array( + $this->smarty->assign([ 'deadline' => $deadline, 'id_everpsquotation_quotes' => $this->id_everpsquotation_quotes, 'prefix' => Configuration::get('EVERPSQUOTATION_PREFIX'), @@ -140,9 +140,9 @@ public function getHeader() 'shop_address' => $shop_address, 'logo_path' => $pathLogo, 'width_logo' => $width, - 'shop_phone' => Configuration::get('PS_SHOP_PHONE', null, null, (int)$id_shop), - 'shop_email' => Configuration::get('PS_SHOP_EMAIL', null, null, (int)$id_shop), - )); + 'shop_phone' => Configuration::get('PS_SHOP_PHONE', null, null, (int) $id_shop), + 'shop_email' => Configuration::get('PS_SHOP_EMAIL', null, null, (int) $id_shop), + ]); return $this->smarty->fetch($this->pdfDir . '/everquotation_header.tpl'); } diff --git a/views/js/everpsquotation.js b/views/js/everpsquotation.js index d4e0cf5..2ffb974 100644 --- a/views/js/everpsquotation.js +++ b/views/js/everpsquotation.js @@ -36,7 +36,6 @@ $(document).ready(function() { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': response.gtm.quoteEvent, - 'quoteEventId': quotation_event_id, 'quoteId': response.gtm.quoteId, // 'customer_email': response.gtm.quoteCustomer.email, 'currency': response.gtm.quoteCurrency.name, @@ -129,7 +128,6 @@ $(document).ready(function() { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'requestForQuote', - 'quoteEventId': quotation_event_id, }); if (response.confirmModal) { $('body').append(response.confirmModal); diff --git a/views/templates/admin/upgrade.tpl b/views/templates/admin/upgrade.tpl index c2a8f75..ea43703 100644 --- a/views/templates/admin/upgrade.tpl +++ b/views/templates/admin/upgrade.tpl @@ -19,7 +19,7 @@

- {l s='An upgrade is available on our shop. Please check' mod='everpsquotation'} https://www.team-ever.com {l s='to get latest version of this module' mod='everpsquotation'} + {l s='An upgrade for Ever Quotation is available on our shop. Please check' mod='everpsquotation'} https://www.team-ever.com {l s='to get latest version of this module' mod='everpsquotation'}