Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
elloha
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bolt Extensions
elloha
Commits
e3a7234e
Commit
e3a7234e
authored
Nov 20, 2018
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(all): Checkbox for type logement and view by contenttype selected
parent
f629746a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
27 deletions
+50
-27
SearchController.php
src/Controller/Frontend/SearchController.php
+38
-23
ResaType.php
src/Form/ResaType.php
+4
-2
GetterSetterTrait.php
src/Request/GetterSetterTrait.php
+1
-0
generateForm.html.twig
templates/Frontend/generateForm.html.twig
+1
-1
elloha.css
web/css/elloha.css
+5
-0
elloha.js
web/js/elloha.js
+1
-1
No files found.
src/Controller/Frontend/SearchController.php
View file @
e3a7234e
...
...
@@ -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
;
...
...
src/Form/ResaType.php
View file @
e3a7234e
...
...
@@ -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
(
...
...
src/Request/GetterSetterTrait.php
View file @
e3a7234e
...
...
@@ -28,6 +28,7 @@ trait GetterSetterTrait
*/
private
$key
;
public
function
setStartDate
(
$startDate
)
{
$this
->
startDate
=
$startDate
;
...
...
templates/Frontend/generateForm.html.twig
View file @
e3a7234e
...
...
@@ -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
)
}}
...
...
web/css/elloha.css
View file @
e3a7234e
...
...
@@ -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
web/js/elloha.js
View file @
e3a7234e
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment