Commit f629746a by Van

feat(all): update fields

parent e5f95cd5
...@@ -46,6 +46,7 @@ class SearchController extends Base ...@@ -46,6 +46,7 @@ class SearchController extends Base
public function search() public function search()
{ {
$formData = $this->app['request']->request->get('resa'); $formData = $this->app['request']->request->get('resa');
dump($formData);
$this->_saveBaseFormData(); $this->_saveBaseFormData();
try { try {
...@@ -55,39 +56,75 @@ class SearchController extends Base ...@@ -55,39 +56,75 @@ class SearchController extends Base
; ;
} finally { } finally {
$idsProduct = $this->ellohaRequest->getIdProducts(); $idsProduct = $this->ellohaRequest->getIdProducts();
$results = $this->_searchReservableContents($idsProduct); $results = $this->_searchReservableContents($idsProduct, $formData);
$hotels = (!$results['hotels']) ? [] : $results['hotels'];
$locatifs_meubles = (isset($results['locatifs-meubles'])) ? $results['locatifs-meubles'] : [];
$hebergements_collectifs = (isset($results['hebergements-collectifs'])) ? $results['hebergements-collectifs'] : [];
return $this->render('@elloha/Frontend/search/results.html.twig', [ return $this->render('@elloha/Frontend/search/results.html.twig', [
'records' => [ 'results' => $results
'hotels' => $hotels,
'locatifs_meubles' => $locatifs_meubles,
'hebergements_collectifs' => $hebergements_collectifs
]
]); ]);
} }
} }
/** /**
* @param array $idsProduct * @param array $idsProduct
* @param array $formData
* @return array * @return array
* Search foreach contenttypes records where idsProduct is in the array * Search foreach contenttypes records where idsProduct is in the array
*/ */
private function _searchReservableContents(array $idsProduct = []) private function _searchReservableContents(array $idsProduct = [], array $formData = [])
{ {
$results = []; $results = [];
$ids = implode(' || ', $idsProduct); $ids = implode(' || ', $idsProduct);
$reservables = [];
$contentsSearchable = $this->_getSearchableContents();
dump(key($contentsSearchable));
dump($contentsSearchable[]);
if (in_array($formData['Type'], $contentsSearchable)){
dump("BOOOOOOOOOOOUUUYAH");
}
foreach ($this->_getSearchableContents() as $content) { foreach ($this->_getSearchableContents() as $content) {
$records = $this->app['storage']->getContent($content['slug'], ['resacode' => $ids, 'returnsingle' => false]); $records = $this->app['storage']->getContent($content['slug'], ['resacode' => $ids, 'returnsingle' => false]);
$results[$content['slug']]= $records; $reservables[$content['slug']]= $records;
} }
$nonReservables = $this->_getNonReservablesRecords($reservables);
$results['reservables'] = $reservables;
$results['nonreservables'] = $nonReservables;
return $results; return $results;
} }
/** /**
* @param array $reservables
* @return array
*/
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(!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);
$records = $this->app['storage']->getContent($content['slug'], ['id' => implode(' || ', $idsNonReservable), 'returnsingle' => false]);
$nonReservables[$content['slug']] = $records;
}
return $nonReservables;
}
/**
* @return array * @return array
* Get the define searchable table * Get the define searchable table
*/ */
...@@ -96,7 +133,6 @@ class SearchController extends Base ...@@ -96,7 +133,6 @@ class SearchController extends Base
foreach($this->config['searchable_contenttypes'] as $contenttype) { foreach($this->config['searchable_contenttypes'] as $contenttype) {
$tables[] = $this->getContenttypeTablename($contenttype); $tables[] = $this->getContenttypeTablename($contenttype);
} }
return $tables; return $tables;
} }
...@@ -107,7 +143,8 @@ class SearchController extends Base ...@@ -107,7 +143,8 @@ class SearchController extends Base
protected function _getSearchableContents(){ protected function _getSearchableContents(){
$contents = []; $contents = [];
foreach($this->config['searchable_contenttypes'] as $contenttype) { foreach($this->config['searchable_contenttypes'] as $contenttype) {
$contents[] = $this->getContenttype($contenttype); /*$contents[$contenttype] = $this->getContenttype($contenttype);*/
$contents[$contenttype] = $this->getContenttype($contenttype);
} }
return $contents; return $contents;
} }
......
...@@ -115,7 +115,10 @@ class EllohaExtension extends SimpleExtension ...@@ -115,7 +115,10 @@ class EllohaExtension extends SimpleExtension
protected function _getResaTypesForOptions() protected function _getResaTypesForOptions()
{ {
$types = []; $types = [];
foreach ($this->getConfig()['resa_types'] as $key => $value) { /*foreach ($this->getConfig()['resa_types'] as $key => $value) {
$types[$key] = (isset($value['label'])) ? $value['label'] : 'Non défini';
}*/
foreach ($this->getConfig()['resa_content'] as $key => $value) {
$types[$key] = (isset($value['label'])) ? $value['label'] : 'Non défini'; $types[$key] = (isset($value['label'])) ? $value['label'] : 'Non défini';
} }
return $types; return $types;
......
...@@ -32,6 +32,7 @@ class ResaType extends AbstractType ...@@ -32,6 +32,7 @@ class ResaType extends AbstractType
'class' => 'main control-label col-xs-12' 'class' => 'main control-label col-xs-12'
], ],
'choices' => array_merge([null => 'Tous les hébergements'], $options['resaTypes']) 'choices' => array_merge([null => 'Tous les hébergements'], $options['resaTypes'])
]) ])
->add( ->add(
'StartDate', 'StartDate',
...@@ -83,6 +84,7 @@ class ResaType extends AbstractType ...@@ -83,6 +84,7 @@ class ResaType extends AbstractType
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'resaTypes' => null 'resaTypes' => null
]); ]);
} }
......
...@@ -55,7 +55,7 @@ class EllohaRequest ...@@ -55,7 +55,7 @@ class EllohaRequest
public function setData(array $data = []) public function setData(array $data = [])
{ {
$this $this
->setType($data['Type']) /*->setType($data['Type'])*/
->setStartDate(($data['StartDate'])) ->setStartDate(($data['StartDate']))
->setEndDate($data['EndDate']) ->setEndDate($data['EndDate'])
->setAdultNumber($data['AdultNumber']) ->setAdultNumber($data['AdultNumber'])
...@@ -69,9 +69,9 @@ class EllohaRequest ...@@ -69,9 +69,9 @@ class EllohaRequest
*/ */
public function getData() { public function getData() {
$data = []; $data = [];
if($this->getType()) { /*if($this->getType()) {
$data['Type'] = $this->getType(); $data['Type'] = $this->getType();
} }*/
if($this->getStartDate()) { if($this->getStartDate()) {
$data['StartDate'] = $this->getStartDate(); $data['StartDate'] = $this->getStartDate();
} }
......
...@@ -37,7 +37,6 @@ class QueryBuilder ...@@ -37,7 +37,6 @@ class QueryBuilder
$storage = $this->app['storage']; $storage = $this->app['storage'];
$query = $this->_buildQuery($contentType, $fields); $query = $this->_buildQuery($contentType, $fields);
dump($query);
if(!empty($query)) if(!empty($query))
{ {
$rows = $this->app['db']->fetchAll($query); $rows = $this->app['db']->fetchAll($query);
......
...@@ -13,69 +13,144 @@ ...@@ -13,69 +13,144 @@
{{ resaForm('resaform')}} {{ resaForm('resaform')}}
</div> </div>
{# Hotels réservables #} {% set reservables = results.reservables %}
{% if records.hotels is defined %} {% set nonreservables = results.nonreservables %}
{% if records.hotels != null %}
<h1>Hôtels réservable</h1> {# Hotels #}
{% for record in records.hotels %} {% if reservables['hotels'] or nonreservables['hotels'] != null %}
<h2>Hotels</h2>
{% if reservables['hotels'] != null %}
<h1>Reservable en ligne</h1>
{% for record in reservables['hotels'] %}
<div class="col-md-2"> <div class="col-md-2">
<div class="card-content" style="height: auto"> <div class="card-content" style="height: auto">
<div class="pictogrammes" style="float: left"> <div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %} {% if record.acceshandi == true %}
{# Icone + "Accessible aux personnes à mobilité réduite" #} {# Icone + "Accessible aux personnes à mobilité réduite" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd"> <img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd">
{% endif %} {% endif %}
{% if record.animaux == true %} {% if record.animaux == true %}
{# Icone + "Animaux bienvenus" #} {# Icone + "Animaux bienvenus" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;"> <img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;">
{% endif %} {% endif %}
{# A customiser avec des étoiles au lieu du texte #} {# A customiser avec des étoiles au lieu du texte #}
{% if record.clas != null %} {% if record.clas != null %}
{{ record.clas }} {{ record.clas }}
<br /> <br />
{% endif %} {% endif %}
{% if record.logisclas != null %} {% if record.logisclas != null %}
{% for clas in record.logisclas|hashtag %} {% for clas in record.logisclas|hashtag %}
{{ clas }} {{ clas }}
{% endfor %}
{% endif %}
{% if record.labels != null %}
<div class="labels">
{% for label in record.labels|hashtag %}
{{ label |label }}
{% endfor %} {% endfor %}
</div> {% endif %}
{% endif %} {% if record.labels != null %}
{# Générer un icone pour chaque chaine #} <div class="labels">
{% if record.chaines != null %} {% for label in record.labels|hashtag %}
{% for chaine in record.chaines|hashtag %} {{ label |label }}
{{ chaine }} {% endfor %}
{% endfor %} </div>
<br /> {% endif %}
{# Générer un icone pour chaque chaine #}
{% if record.chaines != null %}
{% for chaine in record.chaines|hashtag %}
{{ chaine }}
{% endfor %}
<br />
{% endif %}
{% if record.groupe != "non" or record.groupe != null %}
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p>
{% endif %}
</div>
{% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %} {% endif %}
{% if record.groupe != "non" or record.groupe != null %} <div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p> {# HUBRESA #}
{% if products[record.values.syndicobjectid] is defined %}
<div id="Resa">
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p>
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a>
</div>
{% endif %} {% endif %}
<br />
</div> </div>
</div>
{% endfor %}
{% endif %}
{% if nonreservables['hotels'] != null %}
<h1>Non réservable en ligne</h1>
{% for record in nonreservables['hotels'] %}
<div class="col-md-2">
<div class="card-content" style="height: auto">
<div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %}
{# Icone + "Accessible aux personnes à mobilité réduite" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd">
{% endif %}
{% if record.animaux == true %}
{# Icone + "Animaux bienvenus" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;">
{% endif %}
{# A customiser avec des étoiles au lieu du texte #}
{% if record.clas != null %}
{{ record.clas }}
<br />
{% endif %}
{% if record.logisclas != null %}
{% for clas in record.logisclas|hashtag %}
{{ clas }}
{% endfor %}
{% endif %}
{% if record.labels != null %}
<div class="labels">
{% for label in record.labels|hashtag %}
{{ label |label }}
{% endfor %}
</div>
{% endif %}
{# Générer un icone pour chaque chaine #}
{% if record.chaines != null %}
{% for chaine in record.chaines|hashtag %}
{{ chaine }}
{% endfor %}
<br />
{% endif %}
{% if record.groupe != "non" or record.groupe != null %}
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p>
{% endif %}
</div>
{% if record.photo != null %} {% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" /> <img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %} {% endif %}
<div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div> <div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
{# HUBRESA #}
{% if products[record.values.syndicobjectid] is defined %}
<div id="Resa">
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p>
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a>
</div>
{% endif %}
<br /> <br />
</div> </div>
</div> </div>
{% endfor %}
<hr> {% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{# Hebergements Collectifs réservables #} {# Hebergements Collectifs #}
{% if records.hebergements_collectifs is defined %} {% if reservables['hebergements-collectifs'] or nonreservables['hebergements-collectifs'] != null %}
{% if records.hebergements_collectifs != null %} <h2>Hébergements Collectifs</h2>
<h1>Hébergements collectifs réservable</h1> {% if reservables['hebergements-collectifs'] != null %}
{% for record in records.hebergements_collectifs %} <h1>Reservable en ligne</h1>
<div class="col-md-2"> {% for record in reservables['hebergements-collectifs'] %}
<div class="col-md-2">
<div class="card-content" style="height: auto"> <div class="card-content" style="height: auto">
<div class="pictogrammes" style="float: left"> <div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %} {% if record.acceshandi == true %}
...@@ -131,75 +206,195 @@ ...@@ -131,75 +206,195 @@
<br /> <br />
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<hr>
{% endif %} {% endif %}
{% endif %} {% if nonreservables['hebergements-collectifs'] != null %}
<h1>Non réservable en ligne</h1>
{# Locatifs meubles réservables #} {% for record in nonreservables['hebergements-collectifs'] %}
{% if records.locatifs_meubles is defined %} <div class="col-md-2">
{% if records.locatifs_meubles != null %} <div class="card-content" style="height: auto">
<h1>Locatifs meublés réservable</h1> <div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %}
{% for record in records.locatifs_meubles %} {# Icone + "Accessible aux personnes à mobilité réduite" #}
<div class="col-md-2"> <img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd">
<div class="card-content" style="height: auto"> {% endif %}
<div class="pictogrammes" style="float: left"> {% if record.animaux == true %}
{% if record.acceshandi == true %} {# Icone + "Animaux bienvenus" #}
{# Icone + "Accessible aux personnes à mobilité réduite" #} <img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;">
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd"> {% endif %}
{% endif %} {# A customiser avec des étoiles au lieu du texte #}
{% if record.animaux == true %} {% if record.clas != null %}
{# Icone + "Animaux bienvenus" #} {{ record.clas }}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;"> <br />
{% endif %} {% endif %}
{# A customiser avec des étoiles au lieu du texte #} {% if record.logisclas != null %}
{% if record.clas != null %} {% for clas in record.logisclas|hashtag %}
{{ record.clas }} {{ clas }}
<br /> {% endfor %}
{% endif %} {% endif %}
{% if record.logisclas != null %} {% if record.labels != null %}
{% for clas in record.logisclas|hashtag %} <div class="labels">
{{ clas }} {% for label in record.labels|hashtag %}
{% endfor %} {{ label |label }}
{% endif %} {% endfor %}
{% if record.labels != null %} </div>
<div class="labels"> {% endif %}
{% for label in record.labels|hashtag %} {# Générer un icone pour chaque chaine #}
{{ label |label }} {% if record.chaines != null %}
{% for chaine in record.chaines|hashtag %}
{{ chaine }}
{% endfor %} {% endfor %}
<br />
{% endif %}
{% if record.groupe != "non" or record.groupe != null %}
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p>
{% endif %}
</div>
{% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %}
<div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
{# HUBRESA #}
{% if products[record.values.syndicobjectid] is defined %}
<div id="Resa">
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p>
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a>
</div> </div>
{% endif %} {% endif %}
{# Générer un icone pour chaque chaine #}
{% if record.chaines != null %} <br />
{% for chaine in record.chaines|hashtag %} </div>
{{ chaine }} </div>
{% endfor %} {% endfor %}
<br /> {% endif %}
{% endif %}
{# Locatifs Meublés #}
{% if reservables['locatifs-meubles'] or nonreservables['locatifs-meubles'] != null %}
<h2>Locatifs meublés</h2>
{% if reservables['locatifs-meubles'] != null %}
<h1>Reservable en ligne</h1>
{% for record in reservables['locatifs-meubles'] %}
<div class="col-md-2">
<div class="card-content" style="height: auto">
<div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %}
{# Icone + "Accessible aux personnes à mobilité réduite" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd">
{% endif %}
{% if record.animaux == true %}
{# Icone + "Animaux bienvenus" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;">
{% endif %}
{# A customiser avec des étoiles au lieu du texte #}
{% if record.clas != null %}
{{ record.clas }}
<br />
{% endif %}
{% if record.logisclas != null %}
{% for clas in record.logisclas|hashtag %}
{{ clas }}
{% endfor %}
{% endif %}
{% if record.labels != null %}
<div class="labels">
{% for label in record.labels|hashtag %}
{{ label |label }}
{% endfor %}
</div>
{% endif %}
{# Générer un icone pour chaque chaine #}
{% if record.chaines != null %}
{% for chaine in record.chaines|hashtag %}
{{ chaine }}
{% endfor %}
<br />
{% endif %}
{% if record.groupe != "non" or record.groupe != null %}
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p>
{% endif %}
</div>
{% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %} {% endif %}
{% if record.groupe != "non" or record.groupe != null %} <div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p> {# HUBRESA #}
{% if products[record.values.syndicobjectid] is defined %}
<div id="Resa">
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p>
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a>
</div>
{% endif %} {% endif %}
</div>
{% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %}
<div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
{# HUBRESA #} <br />
{% if products[record.values.syndicobjectid] is defined %} </div>
<div id="Resa"> </div>
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p> {% endfor %}
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a> {% endif %}
{% if nonreservables['locatifs-meubles'] != null %}
<h1>Non réservable en ligne</h1>
{% for record in nonreservables['locatifs-meubles'] %}
<div class="col-md-2">
<div class="card-content" style="height: auto">
<div class="pictogrammes" style="float: left">
{% if record.acceshandi == true %}
{# Icone + "Accessible aux personnes à mobilité réduite" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/handicap.png" style="height: 15px; background: #519fbd">
{% endif %}
{% if record.animaux == true %}
{# Icone + "Animaux bienvenus" #}
<img src="http://tourisme-bearn-paysdenay.com/templates/otpaysdenay/img/labels/pictos/animaux.png" style="height: 15px; background: #519fbd; margin-right: 1em;">
{% endif %}
{# A customiser avec des étoiles au lieu du texte #}
{% if record.clas != null %}
{{ record.clas }}
<br />
{% endif %}
{% if record.logisclas != null %}
{% for clas in record.logisclas|hashtag %}
{{ clas }}
{% endfor %}
{% endif %}
{% if record.labels != null %}
<div class="labels">
{% for label in record.labels|hashtag %}
{{ label |label }}
{% endfor %}
</div>
{% endif %}
{# Générer un icone pour chaque chaine #}
{% if record.chaines != null %}
{% for chaine in record.chaines|hashtag %}
{{ chaine }}
{% endfor %}
<br />
{% endif %}
{% if record.groupe != "non" or record.groupe != null %}
{# Icone Groupe + "Groupes bienvenus" #}
<p>Groupes bienvenus</p>
{% endif %}
</div> </div>
{% endif %} {% if record.photo != null %}
<img class="main-photo" src="{{ record.photo|mainPhoto }}" />
{% endif %}
<div><a href="{{ record.link }}">{{ record.nomoffre }} à {{ record.commune }}</a></div>
<br /> {# HUBRESA #}
{% if products[record.values.syndicobjectid] is defined %}
<div id="Resa">
<p class="button">{{ products[record.values.syndicobjectid].prix }}</p>
<a href="{{ products[record.values.syndicobjectid].url }}" class="button is-primary"> Je réserve</a>
</div>
{% endif %}
<br />
</div>
</div> </div>
</div> {% endfor %}
{% endfor %}
<hr>
{% endif %} {% endif %}
{% endif %} {% endif %}
......
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