Files
apart-moment/local/Beds24/Beds24.php
2021-03-23 13:54:38 +01:00

73 lines
2.3 KiB
PHP

<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Beds24;
use Beds24\Model\Beds24ProductInfoQuery;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Install\Database;
use Thelia\Module\BaseModule;
class Beds24 extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'beds24';
public function postActivation(ConnectionInterface $con = null)
{
/*try {
Beds24ProductInfoQuery::create()->findOne();
} catch (\Exception $ex) {*/
$database = new Database($con->getWrappedConnection());
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
// }
}
/**
* Retourne la remise en fnction du nombre de jours achetés
*
* @param \DateTime $dateDebut
* @param \DateTime $dateFin
* @return float
*/
public static function getRemiseDuree(\DateTime $dateDebut, \DateTime $dateFin, &$nombreDeJours)
{
$nombreDeJours = round(($dateFin->getTimeStamp() - $dateDebut->getTimeStamp()) / 86400);
if ($nombreDeJours >= 7) {
return 0.09;
}
if ($nombreDeJours >= 6) {
return 0.08;
}
if ($nombreDeJours >= 5) {
return 0.07;
}
if ($nombreDeJours >= 4) {
return 0.06;
}
if ($nombreDeJours >= 3) {
return 0.05;
}
if ($nombreDeJours >= 2) {
return 0.03;
}
return 0.0;
}
}