diff --git a/.gitignore b/.gitignore
index 953299758..782ae6c16 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@ bin/security-checker
bin/security-checker.bat
composer.dev.json
+composer.dev.json.tmp
composer.phar
.idea/*
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1968ad9a8..3cc136c9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,17 +9,50 @@ and to the [CHANGELOG recommendations](http://keepachangelog.com/).
## [Unreleased]
+### Added
+
+### Fixed
+
+### Changed
+
+
+## [0.15.1] - (2020-07-07)
+
### Added
- Add default FB og:image
+- Add ListingSessionBundle compatibility
+- Add ListingPublicBundle compatibility
### Fixed
- Fix update "unread" message in dashboard
- Fix multi timezone in day mode
+- Fix admin access front link
+- Fix Nesting level too deep error in user comparison in twig
### Changed
+- Update doc for SF 3.4
+- Update listing option bundle to v0.15.1
+- Update report bundle to v0.15.1
- Add acceptation delay constraint in day mode
- Replace cocorico.booking.min_start_delay parameter by cocorico.booking.min_start_time_delay in day mode
- Change invoice number generation method
+- Handle end date not manually selected in range mode
+- Change form phone fields to TelType
+- Add condition to replace Translation extension
+- Update listing-alert-bundle to v0.15.1
+- Fork sonata user bundle
+- Replace app/console by bin/console in bin init scripts
+- Add NotFoundException to listings unreachable
+- Remove the comma for last link in edit dashboard page.
+- Add alert box when user delete his listing in edit listing page.
+- Move the description and title block on the right of the category block in deposit listing page.
+- Design changes for calendar title.
+- Remove in user profile page, language related last comma
+- Remove in home and search page category related last comma
+- Enhance error message displaying
+- Change comment count displaying
+- Add comment counts on HP listings
+- Add transchoice to nb comments
## [0.15.0] - (2019-03-21)
@@ -112,7 +145,7 @@ and to the [CHANGELOG recommendations](http://keepachangelog.com/).
- Fix listing availabilities checking in not day mode and with availabilities by default unavailable
### Changed
-
+- Disable JMS translation reference file adding
## [0.9.1] - (2019-01-15)
@@ -136,6 +169,7 @@ and to the [CHANGELOG recommendations](http://keepachangelog.com/).
### Added
### Fixed
+- Set gc_probability to null
### Changed
- Add BookingSubscriber for new booking
diff --git a/app/AppKernel.php b/app/AppKernel.php
index 38cb25cd9..54712a453 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -19,19 +19,21 @@ public function registerBundles()
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
+ new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
+ new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
new JMS\TranslationBundle\JMSTranslationBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
- new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\UserBundle\SonataUserBundle(),
+ new Sonata\IntlBundle\SonataIntlBundle(),
new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
new Oneup\UploaderBundle\OneupUploaderBundle(),
new Liip\ImagineBundle\LiipImagineBundle(),
@@ -43,7 +45,6 @@ public function registerBundles()
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
new FOS\CKEditorBundle\FOSCKEditorBundle(),
new FM\ElfinderBundle\FMElfinderBundle(),
- new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
//Required bundles
new Cocorico\CoreBundle\CocoricoCoreBundle(),
diff --git a/app/Resources/translations/cocorico_listing_public.en.xlf b/app/Resources/translations/cocorico_listing_public.en.xlf
new file mode 100644
index 000000000..6f8bdc5f9
--- /dev/null
+++ b/app/Resources/translations/cocorico_listing_public.en.xlf
@@ -0,0 +1,56 @@
+
+
+
+
+
+ The source node in most cases contains the sample message as written by the developer. If it looks
+ like a
+ dot-delimitted string such as "form.label.firstname", then the developer has not provided a default
+ message.
+
+
+
+
+ listing.price_four
+ 0-3 years
+
+
+ listing.price_four.help
+ listing.price_four.help
+
+
+ listing.price_one
+ 18 years+
+
+
+ listing.price_one.help
+ listing.price_one.help
+
+
+ listing.price_three
+ 4-12 years
+
+
+ listing.price_three.help
+ listing.price_three.help
+
+
+ listing.price_two
+ 13-18 years
+
+
+ listing.price_two.help
+ listing.price_two.help
+
+
+ listing_public.price.required
+ At least one price must be filled
+
+
+ price
+ Price
+
+
+
+
diff --git a/app/Resources/translations/cocorico_listing_public.fr.xlf b/app/Resources/translations/cocorico_listing_public.fr.xlf
new file mode 100644
index 000000000..257cb8b0f
--- /dev/null
+++ b/app/Resources/translations/cocorico_listing_public.fr.xlf
@@ -0,0 +1,56 @@
+
+
+
+
+
+ The source node in most cases contains the sample message as written by the developer. If it looks
+ like a
+ dot-delimitted string such as "form.label.firstname", then the developer has not provided a default
+ message.
+
+
+
+
+ listing.price_four
+ 0-3 ans
+
+
+ listing.price_four.help
+ listing.price_four.help
+
+
+ listing.price_one
+ 18 ans+
+
+
+ listing.price_one.help
+ listing.price_one.help
+
+
+ listing.price_three
+ 4-12 ans
+
+
+ listing.price_three.help
+ listing.price_three.help
+
+
+ listing.price_two
+ 13-18 ans
+
+
+ listing.price_two.help
+ listing.price_two.help
+
+
+ listing_public.price.required
+ Au moins un prix doit être renseigné
+
+
+ price
+ Prix
+
+
+
+
diff --git a/app/Resources/translations/cocorico_listing_session.en.xlf b/app/Resources/translations/cocorico_listing_session.en.xlf
new file mode 100644
index 000000000..237c2e8c5
--- /dev/null
+++ b/app/Resources/translations/cocorico_listing_session.en.xlf
@@ -0,0 +1,37 @@
+
+
+
+
+
+ The source node in most cases contains the sample message as written by the developer. If it looks
+ like a
+ dot-delimitted string such as "form.label.firstname", then the developer has not provided a default
+ message.
+
+
+
+
+ listing.duration
+ Duration
+
+
+ listing.form.duration
+ Session duration
+
+
+ listing.show.duration
+ Session duration
+
+
+ listing_session.duration.min {{ min }}
+ THe minimum duration is {{ min }}
+
+
+ time_unit_session
+ {-3} by session|{-1} hour(s)|{0} session|]0,1] %hour%h %minute%|]1,Inf]%hour%h%minute%
+
+
+
+
+
diff --git a/app/Resources/translations/cocorico_listing_session.fr.xlf b/app/Resources/translations/cocorico_listing_session.fr.xlf
new file mode 100644
index 000000000..1973aec53
--- /dev/null
+++ b/app/Resources/translations/cocorico_listing_session.fr.xlf
@@ -0,0 +1,36 @@
+
+
+
+
+
+ The source node in most cases contains the sample message as written by the developer. If it looks
+ like a
+ dot-delimitted string such as "form.label.firstname", then the developer has not provided a default
+ message.
+
+
+
+
+ listing.duration
+ Durée
+
+
+ listing.form.duration
+ Durée d'une séance
+
+
+ listing.show.duration
+ Durée d'une séance
+
+
+ listing_session.duration.min {{ min }}
+ La durée minimum est de {{ min }}
+
+
+ time_unit_session
+ {-3} par séance|{-1} heure(s)|{0} séance|]0,1] %hour%h%minute%|]1,Inf]%hour%h%minute%
+
+
+
+
diff --git a/app/config/config.yml b/app/config/config.yml
index cc907c849..13b0a3426 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -34,7 +34,7 @@ framework:
handler_id: ~
name: _csess
#on debian there is a /etc/cron.d/php5 doing the job
- gc_probability: 0 #todo check in prod
+ gc_probability: null
fragments: ~
http_method_override: true
diff --git a/app/config/config_staging.yml b/app/config/config_staging.yml
index 32621cc81..ad5e54144 100644
--- a/app/config/config_staging.yml
+++ b/app/config/config_staging.yml
@@ -4,7 +4,7 @@ imports:
framework:
test: ~
session:
- gc_probability: 0
+ gc_probability: null
# storage_id: session.storage.mock_file
# profiler:
# collect: false
diff --git a/composer.json b/composer.json
index c28b4a140..7b941a3d1 100644
--- a/composer.json
+++ b/composer.json
@@ -3,6 +3,7 @@
"license": "MIT",
"type": "project",
"description": "The Cocorico Standard Edition distribution",
+ "version": "0.15.1",
"keywords": [
"marketplace",
"service",
@@ -10,7 +11,7 @@
"platform",
"consumption"
],
- "homepage": "http://cocorico.io",
+ "homepage": "http://www.cocorico.io",
"authors": [
{
"name": "Cocolabs SAS",
diff --git a/src/Cocorico/CoreBundle/Controller/Dashboard/Offerer/ListingAvailabilityPriceController.php b/src/Cocorico/CoreBundle/Controller/Dashboard/Offerer/ListingAvailabilityPriceController.php
index e6621c8be..94c733b9a 100644
--- a/src/Cocorico/CoreBundle/Controller/Dashboard/Offerer/ListingAvailabilityPriceController.php
+++ b/src/Cocorico/CoreBundle/Controller/Dashboard/Offerer/ListingAvailabilityPriceController.php
@@ -79,7 +79,7 @@ public function editAvailabilitiesPricesAction(Request $request, Listing $listin
'CocoricoCoreBundle:Dashboard/Listing:edit_availabilities_prices.html.twig',
array(
'listing' => $listing,
- 'form_prices' => $form->createView()
+ 'form' => $form->createView()
)
);
diff --git a/src/Cocorico/CoreBundle/Controller/Frontend/ListingController.php b/src/Cocorico/CoreBundle/Controller/Frontend/ListingController.php
index 8ddc07879..d9235a76d 100644
--- a/src/Cocorico/CoreBundle/Controller/Frontend/ListingController.php
+++ b/src/Cocorico/CoreBundle/Controller/Frontend/ListingController.php
@@ -39,6 +39,8 @@ class ListingController extends Controller
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
+ * @throws \Symfony\Component\Form\Exception\RuntimeException
+ * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
*/
public function newAction(Request $request)
{
diff --git a/src/Cocorico/CoreBundle/Controller/Frontend/ListingSearchController.php b/src/Cocorico/CoreBundle/Controller/Frontend/ListingSearchController.php
index 42445ca72..6fc77e08f 100644
--- a/src/Cocorico/CoreBundle/Controller/Frontend/ListingSearchController.php
+++ b/src/Cocorico/CoreBundle/Controller/Frontend/ListingSearchController.php
@@ -160,23 +160,34 @@ protected function getMarkers(Request $request, $results, $resultsIterator)
$liipCacheManager = $this->get('liip_imagine.cache.manager');
$currencyExtension = $this->get('lexik_currency.currency_extension');
$currencyExtension->getFormatter()->setLocale($locale);
+ $listingSession = array_key_exists('CocoricoListingSessionBundle', $this->getParameter('kernel.bundles'));
$markers = $listingsIds = array();
foreach ($results->getIterator() as $i => $result) {
$listing = $result[0];
$listingsIds[] = $listing['id'];
+ $isInCurrentPage = in_array($listing['id'], $resultsInPage);
+ //Image
$imageName = count($listing['images']) ? $listing['images'][0]['name'] : ListingImage::IMAGE_DEFAULT;
-
$image = $liipCacheManager->getBrowserPath($imagePath . $imageName, 'listing_medium', array());
+ //Price
$price = $currencyExtension->convertAndFormat($listing['price'] / 100, $currentCurrency, false);
+ //Duration
+ $duration = null;
+ if ($listingSession && array_key_exists('duration', $listing)) {
+ /** @var \DateTime $duration */
+ $duration = $listing['duration'];
+ $duration = '(' . $duration->format('H\hi') . ')';
+ }
+
+ //Categories
$categories = count($listing['listingListingCategories']) ?
$listing['listingListingCategories'][0]['category']['translations'][$locale]['name'] : '';
- $isInCurrentPage = in_array($listing['id'], $resultsInPage);
-
+ //Ratings
$rating1 = $rating2 = $rating3 = $rating4 = $rating5 = 'hidden';
if ($listing['averageRating']) {
$rating1 = ($listing['averageRating'] >= 1) ? '' : 'inactive';
@@ -201,14 +212,14 @@ protected function getMarkers(Request $request, $results, $resultsIterator)
'rating4' => $rating4,
'rating5' => $rating5,
'price' => $price,
+ 'duration' => $duration,
'certified' => $listing['certified'] ? 'certified' : 'hidden',
- 'url' => $url = $this->generateUrl(
+ 'url' => $this->generateUrl(
'cocorico_listing_show',
array('slug' => $listing['translations'][$locale]['slug'])
),
'zindex' => $isInCurrentPage ? 2 * $nbResults - $i : $i,
'opacity' => $isInCurrentPage ? 1 : 0.4,
-
);
}
diff --git a/src/Cocorico/CoreBundle/Event/BookingFormEvents.php b/src/Cocorico/CoreBundle/Event/BookingFormEvents.php
index 4e3a378f9..8ae757f3a 100644
--- a/src/Cocorico/CoreBundle/Event/BookingFormEvents.php
+++ b/src/Cocorico/CoreBundle/Event/BookingFormEvents.php
@@ -14,6 +14,16 @@
class BookingFormEvents
{
+
+ /**
+ * The BOOKING_PRICE_FORM_BUILD event is thrown each time a booking price form is build
+ *
+ * This event allows you to add form fields and validation on them.
+ *
+ * The event listener receives a \Cocorico\CoreBundle\Event\BookingFormBuilderEvent instance.
+ */
+ const BOOKING_PRICE_FORM_BUILD = 'cocorico.booking_price.form.build';
+
/**
* The BOOKING_NEW_FORM_BUILD event is thrown each time a new booking form is build
*
@@ -32,4 +42,6 @@ class BookingFormEvents
* The event listener receives a \Cocorico\CoreBundle\Event\BookingFormEvent instance.
*/
const BOOKING_NEW_FORM_PROCESS = 'cocorico.booking_new.form.process';
+
+
}
\ No newline at end of file
diff --git a/src/Cocorico/CoreBundle/Event/ListingFormEvents.php b/src/Cocorico/CoreBundle/Event/ListingFormEvents.php
index 9258a6ba2..53ab2dc2b 100644
--- a/src/Cocorico/CoreBundle/Event/ListingFormEvents.php
+++ b/src/Cocorico/CoreBundle/Event/ListingFormEvents.php
@@ -51,4 +51,14 @@ class ListingFormEvents
*/
const LISTING_NEW_FORM_BUILD = 'cocorico.listing_new.form.build';
+
+ /**
+ * The LISTING_AVAILABILITIES_FORM_BUILD event is thrown each time a listing availability edition form is build
+ *
+ * This event allows you to add form fields and validation on them.
+ *
+ * The event listener receives a \Cocorico\CoreBundle\Event\ListingFormBuilderEvent instance.
+ */
+ const LISTING_AVAILABILITIES_FORM_BUILD = 'cocorico.listing_edit.availabilities.form.build';
+
}
\ No newline at end of file
diff --git a/src/Cocorico/CoreBundle/Form/Handler/Dashboard/ListingAvailabilityPriceFormHandler.php b/src/Cocorico/CoreBundle/Form/Handler/Dashboard/ListingAvailabilityPriceFormHandler.php
index d5ec219cd..d5c13afef 100644
--- a/src/Cocorico/CoreBundle/Form/Handler/Dashboard/ListingAvailabilityPriceFormHandler.php
+++ b/src/Cocorico/CoreBundle/Form/Handler/Dashboard/ListingAvailabilityPriceFormHandler.php
@@ -22,7 +22,6 @@
/**
* Handle Listing Availability Price Form
- *
*/
class ListingAvailabilityPriceFormHandler extends ListingAvailabilityFormHandler
{
diff --git a/src/Cocorico/CoreBundle/Form/Type/Dashboard/ListingEditAvailabilitiesType.php b/src/Cocorico/CoreBundle/Form/Type/Dashboard/ListingEditAvailabilitiesType.php
index ddefdb3b6..71c689e2f 100644
--- a/src/Cocorico/CoreBundle/Form/Type/Dashboard/ListingEditAvailabilitiesType.php
+++ b/src/Cocorico/CoreBundle/Form/Type/Dashboard/ListingEditAvailabilitiesType.php
@@ -11,10 +11,13 @@
namespace Cocorico\CoreBundle\Form\Type\Dashboard;
+use Cocorico\CoreBundle\Event\ListingFormBuilderEvent;
+use Cocorico\CoreBundle\Event\ListingFormEvents;
use Cocorico\TimeBundle\Form\Type\DateRangeType;
use Cocorico\TimeBundle\Form\Type\TimeRangeType;
use Cocorico\TimeBundle\Form\Type\WeekDaysType;
use Cocorico\TimeBundle\Validator\Constraints\TimeRangesOverlap;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -23,17 +26,19 @@
class ListingEditAvailabilitiesType extends AbstractType
{
-
+ protected $dispatcher;
protected $timeUnit;
protected $timeUnitIsDay;
protected $daysMaxEdition;
/**
- * @param int $timeUnit
- * @param int $daysMaxEdition
+ * @param EventDispatcherInterface $dispatcher
+ * @param int $timeUnit
+ * @param int $daysMaxEdition
*/
- public function __construct($timeUnit, $daysMaxEdition)
+ public function __construct(EventDispatcherInterface $dispatcher, $timeUnit, $daysMaxEdition)
{
+ $this->dispatcher = $dispatcher;
$this->timeUnit = $timeUnit;
$this->timeUnitIsDay = ($timeUnit % 1440 == 0) ? true : false;
$this->daysMaxEdition = $daysMaxEdition;
@@ -91,6 +96,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);
}
+ //Dispatch LISTING_AVAILABILITIES_FORM_BUILD Event. Listeners can add fields and validation
+ $this->dispatcher->dispatch(
+ ListingFormEvents::LISTING_AVAILABILITIES_FORM_BUILD,
+ new ListingFormBuilderEvent($builder)
+ );
}
/**
diff --git a/src/Cocorico/CoreBundle/Form/Type/Frontend/BookingPriceType.php b/src/Cocorico/CoreBundle/Form/Type/Frontend/BookingPriceType.php
index 04eee5e91..abf3d18a4 100644
--- a/src/Cocorico/CoreBundle/Form/Type/Frontend/BookingPriceType.php
+++ b/src/Cocorico/CoreBundle/Form/Type/Frontend/BookingPriceType.php
@@ -12,10 +12,13 @@
namespace Cocorico\CoreBundle\Form\Type\Frontend;
use Cocorico\CoreBundle\Entity\Booking;
+use Cocorico\CoreBundle\Event\BookingFormBuilderEvent;
+use Cocorico\CoreBundle\Event\BookingFormEvents;
use Cocorico\TimeBundle\Form\Type\DateRangeType;
use Cocorico\TimeBundle\Form\Type\TimeRangeType;
use Cocorico\TimeBundle\Model\DateRange;
use Cocorico\TimeBundle\Model\DateTimeRange;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use DateTime;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -26,6 +29,7 @@
class BookingPriceType extends AbstractType
{
+ protected $dispatcher;
protected $allowSingleDay;
protected $endDayIncluded;
protected $daysDisplayMode;
@@ -33,6 +37,7 @@ class BookingPriceType extends AbstractType
protected $timeUnitIsDay;
/**
+ * @param EventDispatcherInterface $dispatcher
* @param bool $allowSingleDay
* @param bool $endDayIncluded
* @param string $daysDisplayMode
@@ -40,12 +45,14 @@ class BookingPriceType extends AbstractType
* @param int $timeUnit
*/
public function __construct(
+ $dispatcher,
$allowSingleDay,
$endDayIncluded,
$daysDisplayMode,
$timesDisplayMode,
$timeUnit
) {
+ $this->dispatcher = $dispatcher;
$this->allowSingleDay = $allowSingleDay;
$this->endDayIncluded = $endDayIncluded;
$this->daysDisplayMode = $daysDisplayMode;
@@ -109,11 +116,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => true,
/** @Ignore */
'label' => false,
- 'display_mode' => $this->timesDisplayMode
+ 'display_mode' => $this->timesDisplayMode,
)
);
}
+ //Dispatch BOOKING_PRICE_FORM_BUILD Event. Listener listening this event can add fields and validation
+ $this->dispatcher->dispatch(
+ BookingFormEvents::BOOKING_PRICE_FORM_BUILD,
+ new BookingFormBuilderEvent($builder)
+ );
+
//Sync date and time
$builder->addEventListener(
FormEvents::SUBMIT,
@@ -154,11 +167,6 @@ public function configureOptions(OptionsResolver $resolver)
'translation_domain' => 'cocorico_booking',
'constraints' => new Valid(),
'validation_groups' => array('new'),
-// 'error_bubbling' => false,//To prevent errors bubbling up to the parent form
-// //To map errors of all unmapped properties (date_range) to a particular field (date_range)
-// 'error_mapping' => array(
-// '.' => 'date_range',
-// ),
)
);
}
diff --git a/src/Cocorico/CoreBundle/Form/Type/Frontend/ListingNewType.php b/src/Cocorico/CoreBundle/Form/Type/Frontend/ListingNewType.php
index 5e5916975..c744c557c 100644
--- a/src/Cocorico/CoreBundle/Form/Type/Frontend/ListingNewType.php
+++ b/src/Cocorico/CoreBundle/Form/Type/Frontend/ListingNewType.php
@@ -18,6 +18,7 @@
use Cocorico\CoreBundle\Event\ListingFormEvents;
use Cocorico\CoreBundle\Form\Type\ImageType;
use Cocorico\CoreBundle\Form\Type\PriceType;
+use Cocorico\UserBundle\Entity\User;
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -41,24 +42,24 @@ class ListingNewType extends AbstractType implements TranslationContainerInterfa
public static $credentialError = 'user.form.credential.error';
private $request;
+ protected $dispatcher;
private $locale;
private $locales;
- protected $dispatcher;
/**
* @param RequestStack $requestStack
- * @param array $locales
* @param EventDispatcherInterface $dispatcher
+ * @param array $locales
*/
public function __construct(
RequestStack $requestStack,
- $locales,
- EventDispatcherInterface $dispatcher
+ EventDispatcherInterface $dispatcher,
+ $locales
) {
$this->request = $requestStack->getCurrentRequest();
+ $this->dispatcher = $dispatcher;
$this->locale = $this->request->getLocale();
$this->locales = $locales;
- $this->dispatcher = $dispatcher;
}
/**
@@ -96,33 +97,32 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);
}
- $builder->add(
- 'translations',
- TranslationsType::class,
- array(
- 'required_locales' => array($this->locale),
- 'fields' => array(
- 'title' => array(
- 'field_type' => 'text',
- 'locale_options' => $titles,
- ),
- 'description' => array(
- 'field_type' => 'textarea',
- 'locale_options' => $descriptions,
- ),
- 'rules' => array(
- 'display' => false,
- ),
- 'slug' => array(
- 'display' => false
+ $builder
+ ->add(
+ 'translations',
+ TranslationsType::class,
+ array(
+ 'required_locales' => array($this->locale),
+ 'fields' => array(
+ 'title' => array(
+ 'field_type' => 'text',
+ 'locale_options' => $titles,
+ ),
+ 'description' => array(
+ 'field_type' => 'textarea',
+ 'locale_options' => $descriptions,
+ ),
+ 'rules' => array(
+ 'display' => false,
+ ),
+ 'slug' => array(
+ 'display' => false
+ ),
),
- ),
- /** @Ignore */
- 'label' => false,
+ /** @Ignore */
+ 'label' => false,
+ )
)
- );
-
- $builder
->add(
'price',
PriceType::class,
@@ -133,28 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add(
'image',
ImageType::class
- );
-
- //Default listing location
- $listingLocation = null;
- $user = $listing->getUser();
- if ($user) {
- if ($user->getListings()->count()) {
- /** @var Listing $listing */
- $listing = $user->getListings()->first();
- $location = $listing->getLocation();
-
- $listingLocation = new ListingLocation();
- $listingLocation->setListing($listing);
- $listingLocation->setCountry($location->getCountry());
- $listingLocation->setCity($location->getCity());
- $listingLocation->setZip($location->getZip());
- $listingLocation->setRoute($location->getRoute());
- $listingLocation->setStreetNumber($location->getStreetNumber());
- }
- }
-
- $builder
+ )
->add(
'location',
ListingLocationType::class,
@@ -162,11 +141,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'data_class' => 'Cocorico\CoreBundle\Entity\ListingLocation',
/** @Ignore */
'label' => false,
- 'data' => $listingLocation,
+ 'data' => $this->getDefaultListingLocation($listing->getUser()),
)
- );
-
- $builder
+ )
->add(
'tac',
CheckboxType::class,
@@ -189,6 +166,30 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);
}
+ /**
+ * @param User $user
+ * @return ListingLocation|null
+ */
+ private function getDefaultListingLocation(User $user)
+ {
+ $listingLocation = null;
+ if ($user && $user->getListings()->count()) {
+ /** @var Listing $listing */
+ $listing = $user->getListings()->first();
+ $location = $listing->getLocation();
+
+ $listingLocation = new ListingLocation();
+ $listingLocation->setListing($listing);
+ $listingLocation->setCountry($location->getCountry());
+ $listingLocation->setCity($location->getCity());
+ $listingLocation->setZip($location->getZip());
+ $listingLocation->setRoute($location->getRoute());
+ $listingLocation->setStreetNumber($location->getStreetNumber());
+ }
+
+ return $listingLocation;
+ }
+
/**
* @param OptionsResolver $resolver
*/
diff --git a/src/Cocorico/CoreBundle/Model/Manager/BookingManager.php b/src/Cocorico/CoreBundle/Model/Manager/BookingManager.php
index 6f450c079..6f62100e8 100644
--- a/src/Cocorico/CoreBundle/Model/Manager/BookingManager.php
+++ b/src/Cocorico/CoreBundle/Model/Manager/BookingManager.php
@@ -223,6 +223,12 @@ public function initBookingDatesInNotDayMode(Booking $booking)
}
// echo "hourToFind: " . $hourToFind. " ";
+ //TimeUnit
+ $timeUnit = $this->timeUnit;
+ if ($this->listingSessionIsEnabled()) {//Time unit is equal to listing duration
+ $timeUnit = $booking->getListing()->getDurationInMinute();
+ }
+
//We look for each days if some availabilities are defined
$found = false;
for ($d = clone $minStartDay; $d <= $maxEndDate; $d->add(new DateInterval('P1D'))) {
@@ -245,8 +251,8 @@ public function initBookingDatesInNotDayMode(Booking $booking)
$minHourBis = ($d == $minStartDay ? intval($minStartDate->format('H')) * 60 : $minHour);
for ($m = $minHourBis; $m <= $maxHour; $m++) {
// echo $m . ":" . $availability[$m] . " ";
- if ($nbMinutesAvailable == $this->timeUnit) {//Previous "timeUnit" minutes was available
- $hourToFind = $m - $this->timeUnit;//This is the minute in the day of the first hour available
+ if ($nbMinutesAvailable == $timeUnit) {//Previous "timeUnit" minutes was available
+ $hourToFind = $m - $timeUnit;//This is the minute in the day of the first hour available
// echo "hour found:" . $hourToFind . " ";
if ($hourToFind >= $minHour && $hourToFind <= $maxHour) {//If the found hour is in the hours available range
// echo "found" . " ";
@@ -292,12 +298,12 @@ public function initBookingDatesInNotDayMode(Booking $booking)
//Time of end date is equal to start time plus one hour
$end = clone $endDayToFind;
$end->setTime(0, 0, 0);
- $end->add(new DateInterval('PT'.($hourToFind + $this->timeUnit).'M'));
+ $end->add(new DateInterval('PT' . ($hourToFind + $timeUnit) . 'M'));
$booking->setEnd($end);
//End date time is equal to start date time plus one hour
$endTime = clone $start;
- $endTime->add(new DateInterval('PT'.($this->timeUnit).'M'));
+ $endTime->add(new DateInterval('PT' . ($timeUnit) . 'M'));
$booking->setEndTime($endTime);
}
@@ -649,9 +655,15 @@ private function checkBookingAvailabilityInNoDayMode(Booking $booking, $availabi
$daysTimeRanges = $booking->getDateTimeRange()->getDaysTimeRanges(true);
- $duration = $booking->getDuration($this->endDayIncluded, $this->timeUnit);
+ //If session is enabled then time unit is equal to listing session duration
+ $timeUnit = $this->timeUnit;
+ if ($this->listingSessionIsEnabled()) {
+ $timeUnit = $booking->getListing()->getDurationInMinute();
+ }
+
+ $duration = $booking->getDuration($this->endDayIncluded, $timeUnit);
$price = $booking->getListing()->getPrice();
- $amountByMinute = $price / $this->timeUnit;
+ $amountByMinute = $price / $timeUnit;
$amount = $duration * $price;
// echo count($availabilities) . ' ';
@@ -691,7 +703,7 @@ private function checkBookingAvailabilityInNoDayMode(Booking $booking, $availabi
//If price reported to one minute is defined for this minute, it is added to amount
if (isset($times[$k])) {
$amount -= $amountByMinute;
- $amount += $times[$k]["p"] / $this->timeUnit;
+ $amount += $times[$k]["p"] / $timeUnit;
}
}
}
@@ -1563,6 +1575,14 @@ private function voucherIsEnabled()
return isset($this->bundles["CocoricoVoucherBundle"]);
}
+ /**
+ * @return bool
+ */
+ private function listingSessionIsEnabled()
+ {
+ return isset($this->bundles["CocoricoListingSessionBundle"]);
+ }
+
/**
*
* @return BookingRepository
diff --git a/src/Cocorico/CoreBundle/Model/Manager/ListingAvailabilityManager.php b/src/Cocorico/CoreBundle/Model/Manager/ListingAvailabilityManager.php
index 899d1fac3..9c510e471 100644
--- a/src/Cocorico/CoreBundle/Model/Manager/ListingAvailabilityManager.php
+++ b/src/Cocorico/CoreBundle/Model/Manager/ListingAvailabilityManager.php
@@ -178,7 +178,7 @@ public function saveAvailabilities(
* @param DateTime $day
* @param array $timeRanges
* @param int $status
- * @param int $price
+ * @param int $price
* @param int|null $defaultPrice
* @param bool $bookingCancellation
*
@@ -453,9 +453,9 @@ public function asCalendarEvents($availabilities, $timezone)
$prevEvent = $event;
//Get start and end in UTC
- $startUTC = new DateTime($event['start'], new DateTimeZone($timezone));
+ $startUTC = new \DateTime($event['start'], new DateTimeZone($timezone));
$startUTC->setTimezone(new DateTimeZone('UTC'));
- $endUTC = new DateTime($event['end'], new DateTimeZone($timezone));
+ $endUTC = new \DateTime($event['end'], new DateTimeZone($timezone));
$endUTC->setTimezone(new DateTimeZone('UTC'));
$result[] = array(
@@ -485,14 +485,14 @@ public function asCalendarEvents($availabilities, $timezone)
*/
private function asCalendarDayEvents($availability, $timezone)
{
- /** @var MongoDate $dayMD */
+ /** @var \MongoDate $dayMD */
$dayMD = $availability['d'];
- $day = new DateTime();
+ $day = new \DateTime();
$day->setTimestamp($dayMD->sec);
$dayAsString = $dayEndAsString = $day->format('Y-m-d');//by default day is the same for an event
$nextDay = clone $day;//if end time is 00:00 the day will be the next one
- $nextDay->add(new DateInterval('P1D'));
+ $nextDay->add(new \DateInterval('P1D'));
$nextDayAsString = $nextDay->format('Y-m-d');
//time ranges array in UTC
@@ -507,8 +507,8 @@ private function asCalendarDayEvents($availability, $timezone)
$dayEndAsString = $nextDayAsString;
}
- $startUTC = new DateTime($dayAsString.' '.$timeRange['start']);
- $endUTC = new DateTime($dayEndAsString.' '.$timeRange['end']);
+ $startUTC = new \DateTime($dayAsString . ' ' . $timeRange['start']);
+ $endUTC = new \DateTime($dayEndAsString . ' ' . $timeRange['end']);
// echo $startUTC->format('Y-m-d H:i') . ' / ' . $endUTC->format('Y-m-d H:i') . ' ';
@@ -548,8 +548,8 @@ private function asCalendarDayEvents($availability, $timezone)
}
}
} else {
- $start = new DateTime($dayAsString.' '.'00:00');
- $end = new DateTime($dayAsString.' '.'23:59');
+ $start = new \DateTime($dayAsString . ' ' . '00:00');
+ $end = new \DateTime($dayAsString . ' ' . '23:59');
$events[$start->format('Y-m-d')][] = array(
'id' => $availability['_id'] . '0000',
@@ -572,10 +572,10 @@ private function asCalendarDayEvents($availability, $timezone)
*/
public function duplicate($listingId, $duplicatedListingId, $daysMaxEdition)
{
- $start = new DateTime();
- $start->sub(new DateInterval('P1D'));
- $end = new DateTime();
- $end = $end->add(new DateInterval('P'.$daysMaxEdition.'D'));
+ $start = new \DateTime();
+ $start->sub(new \DateInterval('P1D'));
+ $end = new \DateTime();
+ $end = $end->add(new \DateInterval('P' . $daysMaxEdition . 'D'));
$availabilities = $this->getAvailabilitiesByListingAndDateRange($listingId, $start, $end);
$newAvailabilities = array();
diff --git a/src/Cocorico/CoreBundle/Resources/config/Services/forms.yml b/src/Cocorico/CoreBundle/Resources/config/Services/forms.yml
index 7f2ec1c6d..9148afb78 100644
--- a/src/Cocorico/CoreBundle/Resources/config/Services/forms.yml
+++ b/src/Cocorico/CoreBundle/Resources/config/Services/forms.yml
@@ -4,8 +4,8 @@ services:
class: Cocorico\CoreBundle\Form\Type\Frontend\ListingNewType
arguments:
- "@request_stack"
- - "%cocorico.locales%"
- "@event_dispatcher"
+ - "%cocorico.locales%"
tags:
- { name: form.type }
@@ -61,6 +61,7 @@ services:
cocorico.form.type.listing_edit_availabilities:
class: Cocorico\CoreBundle\Form\Type\Dashboard\ListingEditAvailabilitiesType
arguments:
+ - "@event_dispatcher"
- "%cocorico.time_unit%"
- "%cocorico.days_max_edition%"
tags:
@@ -226,6 +227,7 @@ services:
cocorico.form.type.booking_price:
class: Cocorico\CoreBundle\Form\Type\Frontend\BookingPriceType
arguments:
+ - "@event_dispatcher"
- "%cocorico.booking.allow_single_day%"
- "%cocorico.booking.end_day_included%"
- "%cocorico.days_display_mode%"
diff --git a/src/Cocorico/CoreBundle/Resources/config/parameters.yml b/src/Cocorico/CoreBundle/Resources/config/parameters.yml
index c81bb52fd..39d5a0d3b 100644
--- a/src/Cocorico/CoreBundle/Resources/config/parameters.yml
+++ b/src/Cocorico/CoreBundle/Resources/config/parameters.yml
@@ -3,7 +3,7 @@ parameters:
#Site general info
cocorico.site_name: Cocorico
cocorico.phone: +33(0) 1 43 79 86 30
- cocorico.address: 67 rue de Provence, 75009
+ cocorico.address: 67 rue de Provence, 75009, Paris
cocorico.short_description: 'Cocorico is collaborative consumption platform'
cocorico.contact_mail: contact@cocorico.io
#To obfuscate see http://wbwip.com/wbw/emailencoder.html
@@ -11,7 +11,7 @@ parameters:
cocorico.from_email: no-reply@cocorico.io
cocorico.webmaster_email: webmaster@cocorico.io
cocorico.vat_number: FR 12 123 456 789
- cocorico.home_rss_feed: 'http://www.cocolabs.io/fr/feed/'
+ cocorico.home_rss_feed: 'https://www.cocolabs.io/fr/feed/'
#Languages
#For knp translatable
diff --git a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/_edit_availabilities.html.twig b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/_edit_availabilities.html.twig
new file mode 100644
index 000000000..0078dbfaa
--- /dev/null
+++ b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/_edit_availabilities.html.twig
@@ -0,0 +1,35 @@
+{% trans_default_domain 'cocorico_listing' %}
+
+
+ {{ form_errors(form) }}
+
+ {{ form_errors(form.date_range) }}
+ {{ form_label(form.date_range) }}
+ {{ form_widget(form.date_range) }}
+
+
+{{ 'listing.edit.price.choose_weekdays.title'|trans }}
+
+{{ form_errors(form.weekdays) }}
+{{ form_label(form.weekdays) }}
+{{ form_widget(form.weekdays) }}
+
+{% if bundleExist('CocoricoListingSessionBundle') %}
+ {%- include 'CocoricoListingSessionBundle:Dashboard:Listing/_show_duration.html.twig' with {
+ 'form': form,
+ 'duration': listing.duration,
+ } only %}
+{% endif %}
+
+{% if not timeUnitIsDay %}
+
+ {{ 'listing.edit.price.choose_times.title'|trans }}
+ ({{ 'form.time_zone'|trans({}, 'cocorico_user') }} :
+ {{ app.session.get('timezone')|timezone_name }})
+
+
+ {{ form_errors(form.time_ranges) }}
+ {{ form_label(form.time_ranges) }}
+ {{ form_widget(form.time_ranges) }}
+
+{% endif %}
\ No newline at end of file
diff --git a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_prices.html.twig b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_prices.html.twig
index adb60e0cb..308dcb1b9 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_prices.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_prices.html.twig
@@ -63,42 +63,24 @@
diff --git a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_status.html.twig b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_status.html.twig
index 1203db799..c40f3781e 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_status.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/edit_availabilities_status.html.twig
@@ -47,29 +47,10 @@
{{ 'listing.edit.calendar.range.title'|trans }}
-
- {{ form_errors(form) }}
- {{ form_errors(form.date_range) }}
- {{ form_label(form.date_range) }}
- {{ form_widget(form.date_range) }}
-
-
-
{{ 'listing.edit.calendar.choose_weekdays.title'|trans }}
-
- {{ form_errors(form.weekdays) }}
- {{ form_label(form.weekdays) }}
- {{ form_widget(form.weekdays) }}
-
-
- {% if ( not timeUnitIsDay ) %}
-
{{ 'listing.edit.calendar.choose_times.title'|trans }}
-
-
- {{ form_errors(form.time_ranges) }}
- {{ form_label(form.time_ranges) }}
- {{ form_widget(form.time_ranges) }}
-
- {% endif %}
+ {% include 'CocoricoCoreBundle:Dashboard/Listing:_edit_availabilities.html.twig' ignore missing with {
+ 'listing': listing,
+ 'form': form
+ } only %}
{{ form_errors(form.status) }}
diff --git a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/form_price.html.twig b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/form_price.html.twig
index f3e65fa64..1e9bc77fb 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/form_price.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Dashboard/Listing/form_price.html.twig
@@ -92,19 +92,19 @@
+
+{#Session bundle #}
+{% include '@CocoricoListingSession/Dashboard/Listing/js/_sync_timepicker_js.html.twig' ignore missing with {
+ 'edit_mode': edit_mode
+} only %}
\ No newline at end of file
diff --git a/src/Cocorico/CoreBundle/Resources/views/Frontend/Listing/new.html.twig b/src/Cocorico/CoreBundle/Resources/views/Frontend/Listing/new.html.twig
index 3d42db256..4d25c4324 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Frontend/Listing/new.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Frontend/Listing/new.html.twig
@@ -61,208 +61,11 @@
-
-
-
-
{{ 'listing.edit.various_information.title'|trans }}
-
{{ 'listing_edit.photos.title'|trans({'%max_images%': listing_img_max}) }}
+ {% include '@CocoricoCore/Frontend/Listing/_new_images.html.twig' with {'form': form, 'listing' : listing} only %}
-
-
-
- {{ form_errors(form.image.new) }}
- {{ form_widget(form.image.new) }}
+ {% include '@CocoricoCore/Frontend/Listing/_new_price.html.twig' with {'form': form} only %}
- {{ form_errors(form.image.uploaded) }}
- {{ form_widget(form.image.uploaded ) }}
-
-
-
-
{{ 'listing_edit.photos.details'|trans }}
-
-
-
- {{ 'listing.drop.files'|trans }}
-
-
{{ 'listing.images.to_upload.title'|trans }}
-
-
-
-
-
- {% for image in listing.images %}
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
{{ 'listing.new.price.title'|trans }}
-
-
-
-
- {{ 'listing.new.price.rent'|trans }}
-
-
-
- {{ form_errors(form.price) }}
-
- {{ form_label(form.price, 0|add_time_unit_text|capitalize) }}
-
- {{ form_widget(form.price, {
- 'attr': {
- 'class': 'numbers-only form-control',
- 'help': 'listing.edit.price.help'|trans
- }
- }) }}
-
-
- {% if bundleExist('CocoricoDeliveryBundle') %}
- {% include 'CocoricoDeliveryBundle:Frontend:Listing/_form_delivery.html.twig' with {
- 'form': form
- } only %}
- {% elseif bundleExist('CocoricoCarrierBundle') %}
- {% include 'CocoricoCarrierBundle:Frontend:Listing/_form_carrier.html.twig' with {
- 'form': form
- } only %}
- {% endif %}
-
-
-
- {% include '@CocoricoCore/Frontend/Common/_currency_converter.html.twig' with {'close' : true} only %}
-
-
-
-
-
!
-
-
- {{ 'listing.new.price_notice'| trans }}
-
-
-
-
-
+ {% include '@CocoricoCore/Frontend/Listing/_new_location.html.twig' with {'form' : form} only %}
@@ -333,4 +136,6 @@
'upload_max': listing_img_max - listing.images.count,
} only %}
+ {#Session #}
+ {% include '@CocoricoListingSession/Common/js/_init_timepicker_js.html.twig' ignore missing only %}
{% endblock %}
diff --git a/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_marker.html.twig b/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_marker.html.twig
index 781afb9cd..7c80490ee 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_marker.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_marker.html.twig
@@ -65,7 +65,7 @@
-
%title%
+
%title% %duration%
{{ 'listing.search.result.certified'|trans }}
diff --git a/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_result_listings.html.twig b/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_result_listings.html.twig
index 2ee9afa31..bbabe2c60 100644
--- a/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_result_listings.html.twig
+++ b/src/Cocorico/CoreBundle/Resources/views/Frontend/ListingResult/_result_listings.html.twig
@@ -28,23 +28,23 @@
-
-
{{ price }}
+
+
{{ price }}
-
- {{ vatInclusionText(app.request.getLocale()) }}
- / {{ (0)|add_time_unit_text }}
-
-
+
+ {{ vatInclusionText(app.request.getLocale()) }}
+ / {{ (0)|add_time_unit_text }}
+
+