Initial commit

This commit is contained in:
2021-03-23 13:54:38 +01:00
commit 82b142ff95
16941 changed files with 2617212 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
<?php
/*************************************************************************************/
/* */
/* Copyright (c) CQFDev */
/* email : thelia@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/*************************************************************************************/
namespace Beds24\Controller\Back;
use Beds24\Beds24;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Tools\URL;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
class ConfigurationController extends BaseAdminController
{
public function clearCache()
{
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'Beds24', AccessManager::UPDATE)) {
return $response;
}
(new Beds24\Beds24Request())->clearCache();
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/Beds24'));
}
public function configure()
{
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'Beds24', AccessManager::UPDATE)) {
return $response;
}
$configurationForm = $this->createForm('beds24.form.configuration');
try {
$form = $this->validateForm($configurationForm, "POST");
// Get the form field values
$data = $form->getData();
foreach ($data as $name => $value) {
if (is_array($value)) {
$value = implode(';', $value);
}
Beds24::setConfigValue($name, $value);
}
if ($this->getRequest()->get('save_mode') == 'stay') {
$url = '/admin/module/Beds24';
} else {
$url = '/admin/modules';
}
return $this->generateRedirect(URL::getInstance()->absoluteUrl($url));
} catch (FormValidationException $ex) {
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
} catch (\Exception $ex) {
$error_msg = $ex->getMessage();
}
$this->setupFormErrorContext(
$this->getTranslator()->trans("Configuration du franco", [], Beds24::DOMAIN_NAME),
$error_msg,
$configurationForm,
$ex
);
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/Beds24'));
}
}

View File

@@ -0,0 +1,53 @@
<?php
/*************************************************************************************/
/* Copyright (c) Franck Allimant, CQFDev */
/* email : thelia@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/* For the full copyright and license information, please view the LICENSE */
/* file that was distributed with this source code. */
/*************************************************************************************/
/**
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
* Date: 17/06/2019 13:03
*/
namespace Beds24\Controller\Front;
use Beds24\Beds24\Beds24Request;
use Beds24\Model\Beds24BookingOrderProductQuery;
use Thelia\Controller\Front\BaseFrontController;
use Thelia\Core\HttpFoundation\Response;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
class NotificationController extends BaseFrontController
{
/**
* @return Response
* @throws \Propel\Runtime\Exception\PropelException
*/
public function notify()
{
// Clear request cache
$api = new Beds24Request();
$api->clearCache();
// Update booking, if required.
$bookId = $this->getRequest()->get('bookId');
if (! empty($bookId)) {
if (null !== $bookingInfo = Beds24BookingOrderProductQuery::create()->findOneByBeds24BookingId($bookId)) {
$status = $this->getRequest()->get('status');
if ($status === 'cancel') {
$bookingInfo->setBeds24BookingId('')->save();
}
}
}
return new Response('Cache cleared', 200);
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*************************************************************************************/
/* Copyright (c) Franck Allimant, CQFDev */
/* email : thelia@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/* For the full copyright and license information, please view the LICENSE */
/* file that was distributed with this source code. */
/*************************************************************************************/
/**
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
* Date: 17/06/2019 13:03
*/
namespace Beds24\Controller\Front;
use Beds24\Beds24\Beds24Request;
use Beds24\Beds24\SearchParameters;
use Beds24\Model\Base\Beds24ProductInfoQuery;
use Thelia\Controller\Front\BaseFrontController;
use Thelia\Log\Tlog;
/**
* @author Franck Allimant <franck@cqfdev.fr>
*/
class SearchController extends BaseFrontController
{
public function searchAll()
{
return $this->search("ajax/home-search-results");
}
public function searchProduct($productId)
{
return $this->search("ajax/product-search-results", $productId);
}
public function search($resultTemplate, $productId = null)
{
$searchForm = $this->createForm('beds24.form.search');
try {
$form = $this->validateForm($searchForm, "POST");
// Get the form field values
$data = $form->getData();
$startDate = \DateTime::createFromFormat("Y-m-d", $data['start_date']);
$endDate = \DateTime::createFromFormat("Y-m-d", $data['end_date']);
$searchParameters = new SearchParameters($this->getRequest());
$searchParameters->setSearchParameters(
$startDate,
$endDate,
intval($data['adults']),
intval($data['children'])
);
$roomId = null;
if (null !== $productId) {
if (null !== $productInfo = Beds24ProductInfoQuery::create()->findOneByProductId($productId)) {
$roomId = $productInfo->getRoomId();
}
}
return $this->render(
$resultTemplate,
[
'startDate' => $searchParameters->getStartDate()->format("Y-m-d"),
'endDate' => $searchParameters->getEndDate()->format("Y-m-d"),
'adultCount' => $searchParameters->getAdultCount(),
'childCount' => $searchParameters->getChildCount(),
'product_id' => $productId,
'room_id' => $roomId,
'error' => ''
]
);
} catch (\Exception $ex) {
Tlog::getInstance()->addError($ex->getMessage(), $ex);
return $this->render(
$resultTemplate,
[
'product_id' => $productId,
'error' => $ex->getMessage()
]
);
}
}
}