]> _ Git - fluidbook-v3.git/commitdiff
done #1082 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 11 Jan 2017 11:25:50 +0000 (11:25 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 11 Jan 2017 11:25:50 +0000 (11:25 +0000)
framework/application/Fluidbook/Coupon.php [new file with mode: 0644]
framework/application/views/helpers/HeaderContactNav.php
framework/application/views/helpers/LinkQuote.php
less/104-nav.less

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