Commit e3a7234e by Van

feat(all): Checkbox for type logement and view by contenttype selected

parent f629746a
......@@ -23,12 +23,23 @@ class SearchController extends Base
private $prefix;
/**
* @var array
*/
private $configContent;
/**
* @var array
*/
private $contentSlugs = [];
/**
* NewsletterController constructor.
* @param array $config
*/
public function __construct(array $config = [])
{
$this->config = $config;
$this->configContent = $this->config['resa_content'];
$this->ellohaRequest = new EllohaRequest($this->config);
}
......@@ -46,7 +57,13 @@ class SearchController extends Base
public function search()
{
$formData = $this->app['request']->request->get('resa');
dump($formData);
if(!empty($formData['Type'])) {
foreach ($formData['Type'] as $typology) {
$this->contentSlugs[] = (!empty($this->configContent[$typology]['slug'])) ? $this->configContent[$typology]['slug'] : null;
}
}
$this->_saveBaseFormData();
try {
......@@ -77,16 +94,12 @@ class SearchController extends Base
$reservables = [];
$contentsSearchable = $this->_getSearchableContents();
dump(key($contentsSearchable));
dump($contentsSearchable[]);
if (in_array($formData['Type'], $contentsSearchable)){
dump("BOOOOOOOOOOOUUUYAH");
}
foreach ($this->_getSearchableContents() as $content) {
$records = $this->app['storage']->getContent($content['slug'], ['resacode' => $ids, 'returnsingle' => false]);
$reservables[$content['slug']]= $records;
foreach ($contentsSearchable as $content) {
if(in_array($content['slug'], $this->contentSlugs)) {
$records = $this->app['storage']->getContent($content['slug'], ['resacode' => $ids, 'returnsingle' => false]);
$reservables[$content['slug']]= $records;
}
}
$nonReservables = $this->_getNonReservablesRecords($reservables);
......@@ -104,21 +117,24 @@ class SearchController extends Base
protected function _getNonReservablesRecords(array $reservables = []) {
$nonReservables = [];
foreach ($this->_getSearchableContents() as $content) {
$query = 'SELECT id FROM '.$this->getContenttypeTablename($content['slug']);
$idsReservable = array_keys($reservables[$content['slug']]);
if(in_array($content['slug'], $this->contentSlugs)) {
$query = 'SELECT id FROM ' . $this->getContenttypeTablename($content['slug']);
$idsReservable = array_keys($reservables[$content['slug']]);
if(!empty($idsReservable)) {
$idsReservableString = implode(', ',$idsReservable);
$query .= ' WHERE id NOT IN ('.$idsReservableString.')';
}
if (!empty($idsReservable)) {
$idsReservableString = implode(', ', $idsReservable);
$query .= ' WHERE id NOT IN (' . $idsReservableString . ')';
}
$rows = $this->app['db']->fetchAll($query);
$idsNonReservable = array_map(function($rows) {
return $rows['id'];
}, $rows);
$rows = $this->app['db']->fetchAll($query);
$idsNonReservable = array_map(function ($rows) {
return $rows['id'];
}, $rows);
$records = $this->app['storage']->getContent($content['slug'], ['id' => implode(' || ', $idsNonReservable), 'returnsingle' => false]);
$nonReservables[$content['slug']] = $records;
$records = $this->app['storage']->getContent($content['slug'], ['id' => implode(' || ', $idsNonReservable), 'returnsingle' => false]);
$nonReservables[$content['slug']] = $records;
}
}
return $nonReservables;
......@@ -143,7 +159,6 @@ class SearchController extends Base
protected function _getSearchableContents(){
$contents = [];
foreach($this->config['searchable_contenttypes'] as $contenttype) {
/*$contents[$contenttype] = $this->getContenttype($contenttype);*/
$contents[$contenttype] = $this->getContenttype($contenttype);
}
return $contents;
......
......@@ -26,12 +26,14 @@ class ResaType extends AbstractType
'label' => 'Type de logement',
'required' => false,
'attr' => [
'class' => 'input-resa'
'class' => 'checkbox-type'
],
'label_attr' => [
'class' => 'main control-label col-xs-12'
],
'choices' => array_merge([null => 'Tous les hébergements'], $options['resaTypes'])
'choices' => array_merge($options['resaTypes']),
'multiple' => true,
'expanded' => true
])
->add(
......
......@@ -28,6 +28,7 @@ trait GetterSetterTrait
*/
private $key;
public function setStartDate($startDate)
{
$this->startDate = $startDate;
......
......@@ -3,7 +3,7 @@
{{ form_start(form, {'action' : path('elloha_search'), 'method': 'POST'}) }}
<div class="notification is-primary">
<div class="row">
<div class="col-3" style="text-align: center">
<div class="col-12" style="text-align: center">
{{ form_label(form.Type) }}
<div class="col-xs-12">
{{ form_widget(form.Type) }}
......
......@@ -5,4 +5,8 @@
margin-bottom: 1em;
margin-top: 1em;
font-size: 1em;
}
.checkbox-type input, label{
margin-right: 1em;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ $(document).ready(function () {
// DatePicker
$('#resa_StartDate').datepicker({ dateFormat: 'yy-mm-dd' });
$('#resa_EndDate').datepicker();
$('#resa_EndDate').datepicker({ dateFormat: 'yy-mm-dd' });
setAdultNumber();
$(".choosen").chosen();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment