From b886747720b2f245fd1a579126bbb39ceec9331c Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 11 Jan 2017 11:25:50 +0000 Subject: [PATCH] done #1082 @1 --- framework/application/Fluidbook/Coupon.php | 43 +++++++++++++++++++ .../views/helpers/HeaderContactNav.php | 2 +- .../application/views/helpers/LinkQuote.php | 32 +++++++++----- less/104-nav.less | 41 ++++++++++++++++++ 4 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 framework/application/Fluidbook/Coupon.php diff --git a/framework/application/Fluidbook/Coupon.php b/framework/application/Fluidbook/Coupon.php new file mode 100644 index 0000000..992d617 --- /dev/null +++ b/framework/application/Fluidbook/Coupon.php @@ -0,0 +1,43 @@ + array('discount' => '-30%', 'from_date' => '10/01/2017', 'to_date' => '31/01/2017')); + + protected static function _getCoupon() { + $session = Bootstrap::getInstance()->getSession(); + // Check coupon code + if (isset($session->coupon) && isset(self::$_coupons[$session->coupon])) { + $c = self::$_coupons[$session->coupon]; + // Check dates + $now = CubeIT_Date::now(); + $from = new CubeIT_Date($c['from_date'], CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); + if ($now->isEarlier($from)) { + return false; + } + $to = new CubeIT_Date($c['to_date'], CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); + if ($now->isLater($to)) { + return false; + } + return array('code' => $session->coupon, 'discount' => $c['discount']); + } + + return false; + } + + public static function getCouponCode() { + $c = self::_getCoupon(); + if ($c === false) { + return false; + } + return $c['code']; + } + + public static function getCouponDiscount() { + $c = self::_getCoupon(); + if ($c === false) { + return false; + } + return $c['discount']; + } +} \ No newline at end of file diff --git a/framework/application/views/helpers/HeaderContactNav.php b/framework/application/views/helpers/HeaderContactNav.php index 7f964f1..82486c6 100644 --- a/framework/application/views/helpers/HeaderContactNav.php +++ b/framework/application/views/helpers/HeaderContactNav.php @@ -8,7 +8,7 @@ class Fluidbook_View_Helper_HeaderContactNav extends CubeIT_View_Helper_Abstract $res = array(); $res[] = $this->linkInternal(null, 'internal:agences',array('class'=>'agencies')); - $res[] = $this->linkQuote(__('Demandez un devis')); + $res[] = $this->linkQuote(__('Demandez un devis'),'',true); return $this->htmlElement($this->listUnordered($res), 'nav', array('id' => 'contactnav', 'role' => 'navigation')); } diff --git a/framework/application/views/helpers/LinkQuote.php b/framework/application/views/helpers/LinkQuote.php index be14bd7..07459e4 100644 --- a/framework/application/views/helpers/LinkQuote.php +++ b/framework/application/views/helpers/LinkQuote.php @@ -4,19 +4,29 @@ class Fluidbook_View_Helper_LinkQuote extends CubeIT_View_Helper_Abstract { /** * @return string */ - public function linkQuote($label, $style = '') { + public function linkQuote($label, $style = '', $header = false) { $this->headScript()->addScriptAndStyle('005-fancyselect'); $this->headScript()->addScriptAndStyle('315-quote'); + + $attrs = ['data-popup-href' => '/ajaxPopup/quoteForm', + 'class' => 'quoteLink', + 'data-event' => [ + 'category' => 'form', + 'action' => 'open', + 'label' => 'quote' + ], + 'style' => $style + ]; + + if ($header) { + $discount = Fluidbook_Coupon::getCouponDiscount(); + if ($discount) { + $label .= $this->htmlElement(str_replace('%', '%', $discount), 'div', array('class' => 'macaron')); + } + } + return $this->linkPopup($label, - 'internal:contact', - ['data-popup-href' => '/ajaxPopup/quoteForm', - 'class' => 'quoteLink', - 'data-event' => [ - 'category' => 'form', - 'action' => 'open', - 'label' => 'quote' - ], - 'style' => $style - ]); + 'internal:contact', + $attrs); } } \ No newline at end of file diff --git a/less/104-nav.less b/less/104-nav.less index fb8271c..22b815e 100644 --- a/less/104-nav.less +++ b/less/104-nav.less @@ -160,6 +160,8 @@ nav#contactnav { @media @m640 { display: none; } + + position: relative; } &.agencies { .border-button-fill(@color-header-grey, #c2c4c7, 5%); @@ -187,6 +189,45 @@ nav#contactnav { } } +.macaron { + box-sizing: border-box; + display: inline-block; + position: absolute; + top: -22px; + right: -25px; + width: 45px; + height: 45px; + border-radius: 50%; + background-color: #f7807e; + color: #fff; + font-family: "Times New Roman", "Times", serif; + font-size: 19px; + text-align: center; + padding-top: 13px; + sup { + font-size: 50%; + } + z-index: 1; + + @media @m1024 { + width: 35px; + height: 35px; + font-size: 17px; + padding-top: 8px; + top: -12px; + right: -18px; + line-height:17px; + } + + @media @m640 { + position: absolute; + top: 12px; + right: auto; + margin-left:20px; + padding-top:6px; + } +} + #nav-icon { width: 31px; height: 26px; -- 2.39.5