Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
2018_web_app
Overview
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
inutralia
2018_web_app
Commits
30b2ecc5
Commit
30b2ecc5
authored
Dec 05, 2018
by
David Villalba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guardamos perfil
parent
944d4390
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
31 deletions
+65
-31
index.php
fuel/app/classes/controller/perfil/index.php
+13
-1
inutraliaWS.php
fuel/app/classes/trait/inutraliaWS.php
+8
-8
datos_generales.twig
fuel/app/views/perfil/datos_generales.twig
+8
-8
switches.twig
fuel/app/views/perfil/switches.twig
+5
-5
index.js
public/assets/js/perfil/index.js
+31
-9
No files found.
fuel/app/classes/controller/perfil/index.php
View file @
30b2ecc5
...
@@ -33,6 +33,13 @@ class Controller_Perfil_Index extends \Controller_App{
...
@@ -33,6 +33,13 @@ class Controller_Perfil_Index extends \Controller_App{
parent
::
before
();
parent
::
before
();
}
}
/**
*
* Pantalla carga perfil
*
* @return Response
*/
public
function
action_index
(){
public
function
action_index
(){
$view
=
View
::
forge
(
'perfil/index.twig'
);
$view
=
View
::
forge
(
'perfil/index.twig'
);
...
@@ -51,9 +58,14 @@ class Controller_Perfil_Index extends \Controller_App{
...
@@ -51,9 +58,14 @@ class Controller_Perfil_Index extends \Controller_App{
return
Response
::
forge
(
$view
);
return
Response
::
forge
(
$view
);
}
}
/**
* Guardamos datos perfil.
*
* @return bool
*/
public
function
post_update
(){
public
function
post_update
(){
$this
->
ws_profile_put
(
\Input
::
post
(
'id'
),
\Input
::
post
(
'inputs'
))
;
return
$this
->
ws_profile_put
(
\Input
::
post
(
'id'
),
\Input
::
post
(
'inputs'
))
?
true
:
false
;
}
}
...
...
fuel/app/classes/trait/inutraliaWS.php
View file @
30b2ecc5
...
@@ -25,18 +25,18 @@ trait Trait_InutraliaWS {
...
@@ -25,18 +25,18 @@ trait Trait_InutraliaWS {
}
}
/**
/**
* Method to make requests to inutralia.
*
* Metodo generico para relaizar peticiones al WS de inutralia
*
*
* MORE INFO CURL --> http://php.net/manual/es/function.curl-setopt.php
* MORE INFO CURL --> http://php.net/manual/es/function.curl-setopt.php
*
*
* @param $parameter_url
* @param $url
* @param bool $header
* @param string $method
* @param int $timeout
* @param bool $httpget
* @param int $return_transfer
* @param int $return_transfer
* @param array $extra_options --> Opciones extra para la request curl, arrat(key, opcion curl / value, valor curl).
* @param array $add_params_header --> Array para añadir mas opciones a la cabecera por defecto.
* @return mixed
* @return mixed
*/
*/
public
function
request_generic
(
$url
,
$method
=
"get"
,
$return_transfer
=
1
,
$extra_options
=
array
(),
$add_params_header
=
array
()){
public
function
request_generic
(
$url
,
$method
=
"get"
,
$return_transfer
=
1
,
$extra_options
=
array
(),
$add_params_header
=
array
()){
$constant
=
\Config
::
load
(
'constants'
);
$constant
=
\Config
::
load
(
'constants'
);
...
@@ -98,10 +98,10 @@ trait Trait_InutraliaWS {
...
@@ -98,10 +98,10 @@ trait Trait_InutraliaWS {
*/
*/
public
function
ws_profile_put
(
$id
,
$data
){
public
function
ws_profile_put
(
$id
,
$data
){
$data_json
=
http_build_query
(
$data
);
$data_json
=
json_encode
(
$data
);
$extra_options
=
array
(
$extra_options
=
array
(
CURLOPT_CUSTOMREQUEST
=>
'
put
'
,
CURLOPT_CUSTOMREQUEST
=>
'
PUT
'
,
CURLOPT_POSTFIELDS
=>
$data_json
CURLOPT_POSTFIELDS
=>
$data_json
);
);
...
...
fuel/app/views/perfil/datos_generales.twig
View file @
30b2ecc5
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"age"
name=
"age"
required=
""
value=
"
{{
profile.age
}}
"
/>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"age"
rel=
"age"
name=
"age"
required=
""
value=
"
{{
profile.age
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"age"
>
<label
class=
"input__label input__label--nao"
for=
"age"
>
<span
class=
"input__label-content input__label-content--nao"
>
Edad
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Edad
</span>
</label>
</label>
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
</span>
</span>
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"height"
name=
"height"
required=
""
value=
"
{{
profile.height
}}
"
/>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"height"
rel=
"height"
name=
"height"
required=
""
value=
"
{{
profile.height
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"height"
>
<label
class=
"input__label input__label--nao"
for=
"height"
>
<span
class=
"input__label-content input__label-content--nao"
>
Altura
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Altura
</span>
</label>
</label>
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
</span>
</span>
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"weight"
name=
"weight"
required=
""
value=
"
{{
profile.weight
}}
"
/>
<input
class=
"input__field input__field--nao data-profile"
type=
"text"
id=
"weight"
rel=
"weight"
name=
"weight"
required=
""
value=
"
{{
profile.weight
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"weight"
>
<label
class=
"input__label input__label--nao"
for=
"weight"
>
<span
class=
"input__label-content input__label-content--nao"
>
Peso
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Peso
</span>
</label>
</label>
...
@@ -28,15 +28,15 @@
...
@@ -28,15 +28,15 @@
</svg>
</svg>
</span>
</span>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
id
=
"gender"
>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
rel
=
"gender"
>
<option
value=
""
{%
if
(
profile.gender
==
''
)
%}
selected
{%
endif
%}
disabled
>
Género...
</option>
<option
value=
""
{%
if
(
profile.gender
==
''
)
%}
selected
{%
endif
%}
disabled
>
Género...
</option>
<option
value=
"
1
"
{%
if
(
profile.gender
==
'H'
)
%}
selected
{%
endif
%}
>
Hombre
</option>
<option
value=
"
H
"
{%
if
(
profile.gender
==
'H'
)
%}
selected
{%
endif
%}
>
Hombre
</option>
<option
value=
"
2
"
{%
if
(
profile.gender
==
'M'
)
%}
selected
{%
endif
%}
>
Mujer
</option>
<option
value=
"
M
"
{%
if
(
profile.gender
==
'M'
)
%}
selected
{%
endif
%}
>
Mujer
</option>
</select>
</select>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
id
=
"physical"
>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
rel
=
"physical"
>
<option
value=
""
{%
if
(
profile.physical
==
''
)
%}
selected
{%
endif
%}
disabled
>
Actividad fisica...
</option>
<option
value=
""
{%
if
(
profile.physical
==
''
)
%}
selected
{%
endif
%}
disabled
>
Actividad fisica...
</option>
<option
value=
"1"
{%
if
(
profile.physical
==
'1'
)
%}
selected
{%
endif
%}
>
Sedentario
</option>
<option
value=
"1"
{%
if
(
profile.physical
==
'1'
)
%}
selected
{%
endif
%}
>
Sedentario
</option>
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
<option
value=
"5"
{%
if
(
profile.physical
==
'5'
)
%}
selected
{%
endif
%}
>
Muy Intenso
</option>
<option
value=
"5"
{%
if
(
profile.physical
==
'5'
)
%}
selected
{%
endif
%}
>
Muy Intenso
</option>
</select>
</select>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
id
=
"preference"
>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
rel
=
"preference"
>
<option
value=
""
{%
if
profile.preference
==
""
%}
selected
{%
endif
%}
disabled
>
Preferencia de dieta...
</option>
<option
value=
""
{%
if
profile.preference
==
""
%}
selected
{%
endif
%}
disabled
>
Preferencia de dieta...
</option>
<option
value=
"1"
{%
if
profile.preference
==
"1"
%}
selected
{%
endif
%}
>
Normal
</option>
<option
value=
"1"
{%
if
profile.preference
==
"1"
%}
selected
{%
endif
%}
>
Normal
</option>
<option
value=
"2"
{%
if
profile.preference
==
"2"
%}
selected
{%
endif
%}
>
Vegetariana
</option>
<option
value=
"2"
{%
if
profile.preference
==
"2"
%}
selected
{%
endif
%}
>
Vegetariana
</option>
...
...
fuel/app/views/perfil/switches.twig
View file @
30b2ecc5
...
@@ -30,10 +30,10 @@
...
@@ -30,10 +30,10 @@
<div
class=
"row"
>
<div
class=
"row"
>
{%
endif
%}
{%
endif
%}
<div
class=
"col-md-4 col-lg-4 visible-md visible-lg"
>
<div
class=
"co
ntainer-checkbox co
l-md-4 col-lg-4 visible-md visible-lg"
>
<div
class=
"form-group text-center"
>
<div
class=
"form-group text-center"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
key
}}
"
rel=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<div
class=
"slider round"
></div>
<div
class=
"slider round"
></div>
</label>
</label>
<p>
{{
value
}}
</p>
<p>
{{
value
}}
</p>
...
@@ -52,10 +52,10 @@
...
@@ -52,10 +52,10 @@
<div
class=
"row"
>
<div
class=
"row"
>
{%
endif
%}
{%
endif
%}
<div
class=
"col-xs-6 col-sm-6 visible-xs visible-sm"
>
<div
class=
"co
ntainer-checkbox co
l-xs-6 col-sm-6 visible-xs visible-sm"
>
<div
class=
"form-group text-center"
>
<div
class=
"form-group text-center"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<label
class=
"switch"
for=
"
{{
"movil_"
~
key
}}
"
>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
"movil_"
~
key
}}
"
rel=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<div
class=
"slider round"
></div>
<div
class=
"slider round"
></div>
</label>
</label>
<p>
{{
value
}}
</p>
<p>
{{
value
}}
</p>
...
...
public/assets/js/perfil/index.js
View file @
30b2ecc5
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
/**
* Guardamos perfil
*/
$
(
'#save-profile'
).
on
(
'click'
,
function
()
{
$
(
'#save-profile'
).
on
(
'click'
,
function
()
{
var
inputs
=
{};
var
inputs
=
{};
// Recorremos todos los inputs a guardar
$
(
'.data-profile'
).
map
(
function
()
{
$
(
'.data-profile'
).
map
(
function
()
{
if
(
typeof
$
(
this
).
attr
(
'id'
)
!==
"undefined"
){
if
(
typeof
$
(
this
).
attr
(
'rel'
)
!==
"undefined"
){
// Si el input es de tipo checkout lo tratamos de forma diferente.
if
(
$
(
this
).
attr
(
'type'
)
===
"checkbox"
){
// Exiten inputs ocultos (para movil) identicos a los visibles, con esto los diferenciamos.
if
(
$
(
this
).
closest
(
'div.container-checkbox'
).
css
(
'display'
)
!==
'none'
){
inputs
[
$
(
this
).
attr
(
'rel'
)]
=
$
(
this
).
is
(
':checked'
)
?
"1"
:
"0"
;
inputs
[
$
(
this
).
attr
(
'id'
)]
=
$
(
this
).
attr
(
'type'
)
===
"checkbox"
?
$
(
this
).
is
(
':checked'
)
:
$
(
this
).
val
();
}
}
else
{
inputs
[
$
(
this
).
attr
(
'rel'
)]
=
$
(
this
).
val
()
}
}
}
...
@@ -26,17 +49,16 @@ $(document).ready(function() {
...
@@ -26,17 +49,16 @@ $(document).ready(function() {
},
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
log
(
data
);
if
(
data
!=
""
&&
data
!=
0
){
// Modal success
},
}
else
{
error
:
function
(
data
)
{
// Modal error
}
console
.
log
(
data
);
location
.
reload
();
}
}
})
})
})
})
});
});
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