From be1f41e2dc7d175ed7805d003bae9171b5de6dad Mon Sep 17 00:00:00 2001 From: DanielSeifert Date: Thu, 16 Oct 2014 12:17:12 +0000 Subject: [PATCH] skip no working days while transportation --- .../inc/d3ga_universal_trustedstore.tpl | 10 +++-- .../d3_thankyou_googleanalytics.php | 43 +++++++++++++------ .../admin/de/d3_googleanalytics_lang.php | 4 +- .../admin/en/d3_googleanalytics_lang.php | 4 +- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl index fe24b45..8909f5a 100644 --- a/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl +++ b/changed_full/470-/modules/d3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl @@ -68,10 +68,12 @@ [{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}] [{$sPrice|string_format:"%.2f"}] [{$oOrderArticle->getFieldData('oxamount')}] - [{$oView->d3GAgetProductId($oOrderArticle)}] - [{$oD3GASettings->getValue('sD3GATSShoppingAccountId')}] - [{$oD3GASettings->getValue('sD3GATSShoppingCountry')|upper}] - [{$oD3GASettings->getValue('sD3GATSShoppingLanguage')|lower}] + [{if $oD3GASettings->getValue('sD3GATSShoppingActive')}] + [{$oView->d3GAgetProductId($oOrderArticle)}] + [{$oD3GASettings->getValue('sD3GATSShoppingAccountId')}] + [{$oD3GASettings->getValue('sD3GATSShoppingCountry')|upper}] + [{$oD3GASettings->getValue('sD3GATSShoppingLanguage')|lower}] + [{/if}] [{/foreach}] diff --git a/copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php b/copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php index 1fc72e7..8f9d4e5 100644 --- a/copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php +++ b/copy_this/modules/d3/d3_googleanalytics/modules/controllers/d3_thankyou_googleanalytics.php @@ -86,7 +86,11 @@ class d3_thankyou_googleanalytics extends d3_thankyou_googleanalytics_parent */ public function d3GAgetEstimatedShippingDate() { - return $this->_d3GAgetEstimatedDate('iEstShippingTimeValue', time()); + startProfile(__METHOD__); + $iTimeStamp = $this->_d3GAgetEstimatedDate('iEstShippingTimeValue', time()); + stopProfile(__METHOD__); + + return $iTimeStamp; } /** @@ -94,8 +98,12 @@ class d3_thankyou_googleanalytics extends d3_thankyou_googleanalytics_parent */ public function d3GAgetEstimatedDeliveryDate() { + startProfile(__METHOD__); $iShippingDate = $this->d3GAgetEstimatedShippingDate(); - return $this->_d3GAgetEstimatedDate('iEstDeliveryTimeValue', $iShippingDate); + $iTimeStamp = $this->_d3GAgetEstimatedDate('iEstDeliveryTimeValue', $iShippingDate); + stopProfile(__METHOD__); + + return $iTimeStamp; } /** @@ -107,12 +115,16 @@ class d3_thankyou_googleanalytics extends d3_thankyou_googleanalytics_parent protected function _d3GAgetEstimatedDate($sModCfgVarName, $iTimestamp) { $iTimeValue = d3_cfg_mod::get($this->_sModCfgId)->getValue($sModCfgVarName); - $iTimestamp = strtotime('+ ' . $iTimeValue . ' day', $iTimestamp); - do { - $this->_blD3GADateChanged = false; - $iTimestamp = $this->_d3GAavoidIdlePeriod($iTimestamp); - } while ($this->_blD3GADateChanged === true); + for ($i = 0; $i < $iTimeValue; $i++) { + $iTimestamp += 86400; + + // check, if transportation day is a working day, else transportation has a break + do { + $this->_blD3GADateChanged = false; + $iTimestamp = $this->_d3GAskipIdlePeriod($iTimestamp); + } while ($this->_blD3GADateChanged === true); + } return $iTimestamp; } @@ -122,17 +134,20 @@ class d3_thankyou_googleanalytics extends d3_thankyou_googleanalytics_parent * * @return int */ - protected function _d3GAavoidIdlePeriod($iTimestamp) + protected function _d3GAskipIdlePeriod($iTimestamp) { + startProfile(__METHOD__); $iWeekday = date('N', $iTimestamp); if (in_array($iWeekday, $this->aD3GAWeekendDays)) { $iOffset = 8 - $iWeekday; - $iTimestamp = strtotime('+ '.$iOffset.' day', $iTimestamp); + $iTimestamp += $iOffset * 86400; $this->_blD3GADateChanged = true; } - return $this->_d3GAavoidFeastDays($iTimestamp); + stopProfile(__METHOD__); + + return $this->_d3GAskipFeastDays($iTimestamp); } /** @@ -140,13 +155,17 @@ class d3_thankyou_googleanalytics extends d3_thankyou_googleanalytics_parent * * @return int */ - protected function _d3GAavoidFeastDays($iTimestamp) + protected function _d3GAskipFeastDays($iTimestamp) { + startProfile(__METHOD__); + while (in_array(date('d-m', $iTimestamp), $this->aD3GAfixFeastDays)) { - $iTimestamp = strtotime('+ 1 day', $iTimestamp); + $iTimestamp += 86400; $this->_blD3GADateChanged = true; } + stopProfile(__METHOD__); + return $iTimestamp; } diff --git a/copy_this/modules/d3/d3_googleanalytics/views/admin/de/d3_googleanalytics_lang.php b/copy_this/modules/d3/d3_googleanalytics/views/admin/de/d3_googleanalytics_lang.php index 4dce63f..38aca61 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/admin/de/d3_googleanalytics_lang.php +++ b/copy_this/modules/d3/d3_googleanalytics/views/admin/de/d3_googleanalytics_lang.php @@ -279,7 +279,7 @@ $aLang = array( 'D3_GOOGLEANALYTICS_TS_ACTIVE' => 'Trusted Store aktivieren', 'D3_GOOGLEANALYTICS_TS_ID' => 'Trusted Store-ID', 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER' => 'Zeitraum vom Bestelleingang bis zum Versand', - 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DAYS' => 'Kalendertag(e)', + 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DAYS' => 'Werktag(e)', 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DESC' => '

Google teilt Ihrem Kunden per Mail mit, '. 'nach welchem Zeitraum ausgehend vom Bestelleingang die bestellten Artikel versendet werden. Geben Sie hier '. 'den für Normalfälle größten Zeitraum bis zum Versand in Tagen an (z.B. 3 bei "1 bis 3 Tage"). Nach dem '. @@ -289,7 +289,7 @@ $aLang = array( 'erweitern Sie die Überladung der thankyou-Klasse entsprechend.

', 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER' => 'Zeitraum vom Versand bis zur Lieferung beim '. 'Empfänger', - 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DAYS' => 'Kalendertag(e)', + 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DAYS' => 'Werktag(e)', 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DESC' => '

Google teilt Ihrem Kunden per Mail mit, '. 'nach welchem Zeitraum die bestellten Artikel in der Regel beim Kunden eintreffen. Geben Sie hier den für '. 'Normalfälle größten Zeitraum für die Lieferung in Tagen an (z.B. 4 bei "1 bis 4 Tage"). Der errechnete '. diff --git a/copy_this/modules/d3/d3_googleanalytics/views/admin/en/d3_googleanalytics_lang.php b/copy_this/modules/d3/d3_googleanalytics/views/admin/en/d3_googleanalytics_lang.php index 3374931..9e3db68 100644 --- a/copy_this/modules/d3/d3_googleanalytics/views/admin/en/d3_googleanalytics_lang.php +++ b/copy_this/modules/d3/d3_googleanalytics/views/admin/en/d3_googleanalytics_lang.php @@ -278,7 +278,7 @@ $aLang = array( 'D3_GOOGLEANALYTICS_TS_ACTIVE' => 'Trusted Store aktivieren', 'D3_GOOGLEANALYTICS_TS_ID' => 'Trusted Store-ID', 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER' => 'Zeitraum vom Bestelleingang bis zum Versand', - 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DAYS' => 'Kalendertag(e)', + 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DAYS' => 'Werktag(e)', 'D3_GOOGLEANALYTICS_TS_ESTSHIPDATEAFTER_DESC' => '

Google teilt Ihrem Kunden per Mail mit, '. 'nach welchem Zeitraum ausgehend vom Bestelleingang die bestellten Artikel versendet werden. Geben Sie hier '. 'den für Normalfälle größten Zeitraum bis zum Versand in Tagen an (z.B. 3 bei "1 bis 3 Tage"). Nach dem '. @@ -288,7 +288,7 @@ $aLang = array( 'erweitern Sie die Überladung der thankyou-Klasse entsprechend.

', 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER' => 'Zeitraum vom Versand bis zur Lieferung beim '. 'Empfänger', - 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DAYS' => 'Kalendertag(e)', + 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DAYS' => 'Werktag(e)', 'D3_GOOGLEANALYTICS_TS_ESTDELDATEAFTER_DESC' => '

Google teilt Ihrem Kunden per Mail mit, '. 'nach welchem Zeitraum die bestellten Artikel in der Regel beim Kunden eintreffen. Geben Sie hier den für '. 'Normalfälle größten Zeitraum für die Lieferung in Tagen an (z.B. 4 bei "1 bis 4 Tage"). Der errechnete '.