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
066dbd66
Commit
066dbd66
authored
Dec 05, 2018
by
gema
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.setisl.com/inutraliaapp/2018_web_app
into gemis_dev
parents
76f5d585
5e23a7bf
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
259 additions
and
63 deletions
+259
-63
app.php
fuel/app/classes/controller/app.php
+3
-1
index.php
fuel/app/classes/controller/login/index.php
+2
-1
index.php
fuel/app/classes/controller/perfil/index.php
+22
-1
inutraliaWS.php
fuel/app/classes/trait/inutraliaWS.php
+47
-18
extension.php
fuel/app/classes/twig/seti/extension.php
+14
-0
constants.php
fuel/app/config/development/constants.php
+3
-4
constants.php
fuel/app/config/production/constants.php
+3
-0
routes.php
fuel/app/config/routes.php
+12
-1
datos_generales.twig
fuel/app/views/perfil/datos_generales.twig
+26
-30
index.twig
fuel/app/views/perfil/index.twig
+5
-2
switches.twig
fuel/app/views/perfil/switches.twig
+58
-5
index.js
public/assets/js/perfil/index.js
+64
-0
No files found.
fuel/app/classes/controller/app.php
View file @
066dbd66
...
@@ -22,9 +22,11 @@ use Fuel\Core\Session;
...
@@ -22,9 +22,11 @@ use Fuel\Core\Session;
class
Controller_App
extends
Controller
{
class
Controller_App
extends
Controller
{
use
Trait_InutraliaWS
;
public
function
before
(){
public
function
before
(){
if
(
!
$this
->
control_time_session
()){
if
(
!
Session
::
get
(
'token_auth'
)
||
!
$this
->
control_time_session
()){
Session
::
destroy
();
Session
::
destroy
();
Response
::
redirect
(
"/"
);
Response
::
redirect
(
"/"
);
}
}
...
...
fuel/app/classes/controller/login/index.php
View file @
066dbd66
...
@@ -55,6 +55,7 @@ class Controller_Login_Index extends Controller
...
@@ -55,6 +55,7 @@ class Controller_Login_Index extends Controller
'Se perdio la ventana de autenticación, ha pasado demasiado tiempo
'Se perdio la ventana de autenticación, ha pasado demasiado tiempo
inactivo, intentelo de nuevo.'
inactivo, intentelo de nuevo.'
);
);
\Session
::
delete
(
'token_auth'
);
Response
::
redirect
(
'auth/login'
);
Response
::
redirect
(
'auth/login'
);
return
null
;
return
null
;
}
}
...
@@ -85,7 +86,7 @@ class Controller_Login_Index extends Controller
...
@@ -85,7 +86,7 @@ class Controller_Login_Index extends Controller
);
);
}
}
\Session
::
delete
(
'token_auth'
);
Response
::
redirect
(
'auth/login'
);
Response
::
redirect
(
'auth/login'
);
return
null
;
return
null
;
}
}
...
...
fuel/app/classes/controller/perfil/index.php
View file @
066dbd66
...
@@ -23,7 +23,7 @@ class Controller_Perfil_Index extends \Controller_App{
...
@@ -23,7 +23,7 @@ class Controller_Perfil_Index extends \Controller_App{
public
function
before
(){
public
function
before
(){
//Se cargan funciones de javascript especificas de esta funcionalidad
//Se cargan funciones de javascript especificas de esta funcionalidad
Casset
::
js
(
'
dashboard
/index.js'
);
Casset
::
js
(
'
perfil
/index.js'
);
//Se marca la navegación en forma de migas de pan. Cada miga de pan la forman dos variables:
//Se marca la navegación en forma de migas de pan. Cada miga de pan la forman dos variables:
// ds : String a mostrar
// ds : String a mostrar
...
@@ -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'
);
...
@@ -46,8 +53,21 @@ class Controller_Perfil_Index extends \Controller_App{
...
@@ -46,8 +53,21 @@ class Controller_Perfil_Index extends \Controller_App{
//Paso de las opciones de menu que deben aparecer seleccionadas
//Paso de las opciones de menu que deben aparecer seleccionadas
$view
->
option_menu
=
$this
->
_option_menu
;
$view
->
option_menu
=
$this
->
_option_menu
;
$view
->
profile
=
$this
->
ws_profile_get
();
return
Response
::
forge
(
$view
);
return
Response
::
forge
(
$view
);
}
}
/**
* Guardamos datos perfil.
*
* @return bool
*/
public
function
post_update
(){
return
$this
->
ws_profile_put
(
\Input
::
post
(
'id'
),
\Input
::
post
(
'inputs'
))
?
true
:
false
;
}
}
}
\ No newline at end of file
fuel/app/classes/trait/inutraliaWS.php
View file @
066dbd66
...
@@ -15,43 +15,49 @@ trait Trait_InutraliaWS {
...
@@ -15,43 +15,49 @@ trait Trait_InutraliaWS {
public
function
get_header
(){
public
function
get_header
(){
return
array
(
return
array
(
'Content-Type: application/json'
,
'Content-Type: application/json'
,
'Accept: application/json'
,
'Accept: application/json'
,
'Authorization: Basic '
.
\Session
::
get
(
'token_auth'
)
'Authorization: Basic '
.
\Session
::
get
(
'token_auth'
)
,
);
);
}
}
/**
/**
* 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
(
$parameter_url
,
$header
=
false
,
$timeout
=
30
,
$httpget
=
true
,
$return_transfer
=
1
){
$constant
=
\Config
::
load
(
'constants'
);
$constant
=
\Config
::
load
(
'constants'
);
// La url la obtiene de config dependiendo del entorno.
// La url la obtiene de config dependiendo del entorno.
$
process
=
curl_init
(
$constant
[
$parameter_url
]);
$
ch
=
curl_init
(
$constant
[
'domain'
]
.
$url
.
$constant
[
'apikey'
]);
curl_setopt
(
$process
,
CURLOPT_HTTPHEADER
,
$this
->
get_header
());
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array_merge
(
$this
->
get_header
(),
$add_params_header
));
curl_setopt
(
$process
,
CURLOPT_HEADER
,
$header
);
curl_setopt
(
$process
,
CURLOPT_TIMEOUT
,
$timeout
);
curl_setopt
(
$process
,
CURLOPT_HTTPGET
,
$httpget
);
curl_setopt
(
$process
,
CURLOPT_RETURNTRANSFER
,
$return_transfer
);
$return
=
curl_exec
(
$process
);
curl_setopt
(
$ch
,
$method
==
"get"
?
CURLOPT_HTTPGET
:
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
$return_transfer
);
foreach
(
$extra_options
as
$key
=>
$value
){
curl_setopt
(
$ch
,
$key
,
$value
);
}
curl_close
(
$process
);
$return
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$return
;
return
$return
;
}
}
...
@@ -73,13 +79,35 @@ trait Trait_InutraliaWS {
...
@@ -73,13 +79,35 @@ trait Trait_InutraliaWS {
}
}
/**
/**
* Request get profile
* Reques profile get
*
* @param null $data
* @return mixed
*/
*/
public
function
ws_profile
(){
public
function
ws_profile
_get
(){
return
json_decode
(
$this
->
request_generic
(
'profile'
));
return
json_decode
(
$this
->
request_generic
(
'profile'
));
}
}
/**
* Reques profile put
*
* @param $data
* @return mixed
*/
public
function
ws_profile_put
(
$id
,
$data
){
$data_json
=
json_encode
(
$data
);
$extra_options
=
array
(
CURLOPT_CUSTOMREQUEST
=>
'PUT'
,
CURLOPT_POSTFIELDS
=>
$data_json
);
return
json_decode
(
$this
->
request_generic
(
'profile'
.
DS
.
$id
,
"post"
,
1
,
$extra_options
,
array
(
'Content-Length: '
.
strlen
(
$data_json
))));
}
}
}
\ No newline at end of file
fuel/app/classes/twig/seti/extension.php
View file @
066dbd66
...
@@ -124,6 +124,7 @@ class Twig_Seti_Extension extends Twig_Extension
...
@@ -124,6 +124,7 @@ class Twig_Seti_Extension extends Twig_Extension
'sha1'
=>
new
Twig_Function_Function
(
'sha1'
),
'sha1'
=>
new
Twig_Function_Function
(
'sha1'
),
'var_dump'
=>
new
Twig_Function_Function
(
'var_dump'
),
'var_dump'
=>
new
Twig_Function_Function
(
'var_dump'
),
'is_divisible'
=>
new
Twig_Function_Method
(
$this
,
'is_divisible'
),
);
);
}
}
...
@@ -185,4 +186,17 @@ class Twig_Seti_Extension extends Twig_Extension
...
@@ -185,4 +186,17 @@ class Twig_Seti_Extension extends Twig_Extension
return
Fuel
::
VERSION
;
return
Fuel
::
VERSION
;
}
}
/**
*
* Comprueba si un numero es divisible a otro.
*
* @param $num
* @param $div
* @return bool
*/
public
function
is_divisible
(
$num
,
$div
)
{
return
(
$num
%
$div
==
0
)
?
true
:
false
;
}
}
}
fuel/app/config/development/constants.php
View file @
066dbd66
...
@@ -29,13 +29,11 @@
...
@@ -29,13 +29,11 @@
const
DOMAIN
=
"http://inutraliaback20"
;
const
DOMAIN
=
"http://inutraliaback20"
;
const
V1
=
'/api/v1/'
;
const
V1
=
'/api/v1/'
;
const
APIKEY
=
"?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e"
;
// PARAMETERS
// PARAMETERS
const
USER
=
'user'
;
return
array
(
return
array
(
'user'
=>
DOMAIN
.
V1
.
USER
.
APIKEY
,
'domain'
=>
DOMAIN
.
V1
,
'apikey'
=>
"?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e"
);
);
\ No newline at end of file
fuel/app/config/production/constants.php
View file @
066dbd66
...
@@ -32,9 +32,11 @@ const APIKEY = "?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e";
...
@@ -32,9 +32,11 @@ const APIKEY = "?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e";
// PARAMETERS
// PARAMETERS
const
USER
=
'user'
;
const
USER
=
'user'
;
const
PROFILE
=
'profile'
;
return
array
(
return
array
(
'user'
=>
DOMAIN
.
V1
.
USER
.
APIKEY
,
'user'
=>
DOMAIN
.
V1
.
USER
.
APIKEY
,
'profile'
=>
DOMAIN
.
V1
.
PROFILE
.
APIKEY
,
);
);
\ No newline at end of file
fuel/app/config/routes.php
View file @
066dbd66
...
@@ -25,17 +25,28 @@ return array(
...
@@ -25,17 +25,28 @@ return array(
/*HOME*/
/*HOME*/
'dashboard'
=>
'dashboard/index'
,
'dashboard'
=>
'dashboard/index'
,
'perfil'
=>
'perfil/index'
,
// PERFIL
'perfil'
=>
'perfil/index'
,
'perfil/update'
=>
'perfil/index/update'
,
// MENU PERSONALIZADO
'menupersonalizado'
=>
'menupersonalizado/index'
,
'menupersonalizado'
=>
'menupersonalizado/index'
,
// MENU SALUDABLES
'menussaludables'
=>
'menussaludables/lista/index'
,
'menussaludables'
=>
'menussaludables/lista/index'
,
'menussaludables-menu'
=>
'menussaludables/menu/index'
,
'menussaludables-menu'
=>
'menussaludables/menu/index'
,
// RECETA
'receta-detalle'
=>
'receta/index'
,
'receta-detalle'
=>
'receta/index'
,
// RECETARIO
'recetario'
=>
'recetario/index'
,
'recetario'
=>
'recetario/index'
,
// BOLETIN SALUDABLE
'boletin-saludable'
=>
'boletinsaludable/index'
,
'boletin-saludable'
=>
'boletinsaludable/index'
,
// ARTICULO
'articulo-detalle'
=>
'articulo/index'
,
'articulo-detalle'
=>
'articulo/index'
,
'lista-compra'
=>
'listacompra/index'
,
'lista-compra'
=>
'listacompra/index'
,
...
...
fuel/app/views/perfil/datos_generales.twig
View file @
066dbd66
...
@@ -3,9 +3,8 @@
...
@@ -3,9 +3,8 @@
</div>
</div>
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao"
type=
"text"
id=
"edad"
name=
"edad"
required=
""
/>
<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=
"input-1"
>
<span
class=
"input__label-content input__label-content--nao"
>
Edad
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Edad
</span>
</label>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
@@ -14,9 +13,8 @@
...
@@ -14,9 +13,8 @@
</span>
</span>
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao"
type=
"text"
id=
"altura"
name=
"altura"
required=
""
/>
<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=
"input-1"
>
<span
class=
"input__label-content input__label-content--nao"
>
Altura
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Altura
</span>
</label>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
@@ -25,9 +23,8 @@
...
@@ -25,9 +23,8 @@
</span>
</span>
<span
class=
"input input--nao"
>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao"
type=
"text"
id=
"peso"
name=
"peso"
required=
""
/>
<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=
"input-1"
>
<span
class=
"input__label-content input__label-content--nao"
>
Peso
</span>
<span
class=
"input__label-content input__label-content--nao"
>
Peso
</span>
</label>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
@@ -35,29 +32,27 @@
...
@@ -35,29 +32,27 @@
</svg>
</svg>
</span>
</span>
<span
class=
"input input--nao"
>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
rel=
"gender"
>
<input
class=
"input__field input__field--nao"
type=
"text"
id=
"genero"
name=
"genero"
required=
""
/>
<label
class=
"input__label input__label--nao"
for=
"input-1"
>
<option
value=
""
{%
if
(
profile.gender
==
''
)
%}
selected
{%
endif
%}
disabled
>
Género...
</option>
<span
class=
"input__label-content input__label-content--nao"
>
Género
</span>
<option
value=
"H"
{%
if
(
profile.gender
==
'H'
)
%}
selected
{%
endif
%}
>
Hombre
</option>
</label>
<option
value=
"M"
{%
if
(
profile.gender
==
'M'
)
%}
selected
{%
endif
%}
>
Mujer
</option>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
<path
d=
"M0,56.5c0,0,298.666,0,399.333,0C448.336,56.5,513.994,46,597,46c77.327,0,135,10.5,200.999,10.5c95.996,0,402.001,0,402.001,0"
/>
</svg>
</span>
<select
class=
"cs-select cs-skin-underline mt20"
>
<option
value=
""
disabled
selected
>
Actividad fisica...
</option>
<option
value=
"1"
>
Sedentario
</option>
<option
value=
"2"
>
Ligero
</option>
<option
value=
"3"
>
Moderado
</option>
<option
value=
"4"
>
Intenso
</option>
<option
value=
"5"
>
Muy Intenso
</option>
</select>
</select>
<select
class=
"cs-select cs-skin-underline mt20"
>
<select
class=
"cs-select cs-skin-underline mt20 data-profile"
rel=
"physical"
>
<option
value=
""
disabled
selected
>
Preferencia de dieta...
</option>
<option
value=
"1"
>
Normal
</option>
<option
value=
""
{%
if
(
profile.physical
==
''
)
%}
selected
{%
endif
%}
disabled
>
Actividad fisica...
</option>
<option
value=
"2"
>
Vegetariana
</option>
<option
value=
"1"
{%
if
(
profile.physical
==
'1'
)
%}
selected
{%
endif
%}
>
Sedentario
</option>
<option
value=
"3"
>
Vegana
</option>
<option
value=
"2"
{%
if
(
profile.physical
==
'2'
)
%}
selected
{%
endif
%}
>
Ligero
</option>
<option
value=
"3"
{%
if
(
profile.physical
==
'3'
)
%}
selected
{%
endif
%}
>
Moderado
</option>
<option
value=
"4"
{%
if
(
profile.physical
==
'4'
)
%}
selected
{%
endif
%}
>
Intenso
</option>
<option
value=
"5"
{%
if
(
profile.physical
==
'5'
)
%}
selected
{%
endif
%}
>
Muy Intenso
</option>
</select>
<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=
"1"
{%
if
profile.preference
==
"1"
%}
selected
{%
endif
%}
>
Normal
</option>
<option
value=
"2"
{%
if
profile.preference
==
"2"
%}
selected
{%
endif
%}
>
Vegetariana
</option>
<option
value=
"3"
{%
if
profile.preference
==
"3"
%}
selected
{%
endif
%}
>
Vegana
</option>
</select>
</select>
\ No newline at end of file
fuel/app/views/perfil/index.twig
View file @
066dbd66
...
@@ -15,7 +15,9 @@
...
@@ -15,7 +15,9 @@
</div>
</div>
</div>
</div>
<div
class=
"container pb80"
>
<div
class=
"container pb80"
>
<input
type=
"hidden"
id=
"profile_id"
value=
"
{{
profile.id
}}
"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<div
class=
"solid-box bg-color-perfil pb50"
>
<div
class=
"solid-box bg-color-perfil pb50"
>
...
@@ -34,7 +36,8 @@
...
@@ -34,7 +36,8 @@
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-6 col-md-offset-6"
>
<div
class=
"col-md-6 col-md-offset-6"
>
<button
class=
"btn btn-custom btn-perfil mt40"
><i
class=
"fa fa-save"
></i>
Guardar Perfil
</button>
<button
class=
"btn btn-custom btn-perfil mt40"
><i
class=
"fa fa-save"
></i>
Guardar Perfil
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
fuel/app/views/perfil/switches.twig
View file @
066dbd66
<div
class=
"row"
>
<div
class=
"row"
>
{%
for
i
in
1.
.
13
%}
<div
class=
"col-xs-6 col-sm-6 col-md-4"
>
{%
set
caracterisitcas
=
{
'cv'
:
'una enfermedad cardiovascular ?'
,
'hypertension'
:
'hipertensión ?'
,
'menopause'
:
'menopausia ?'
,
'pregnancy'
:
'embarazo ?'
,
'lactation'
:
'lactancia ?'
,
'celiac'
:
'celiacos ?'
,
'lactose'
:
'intolerante a la lactosa?'
,
'diabetes'
:
'diabetes ?'
,
'cholesterol'
:
'colesterol ?'
,
'triglycerides'
:
'trígliceridos ?'
,
'al_fish'
:
'alergia al pescado/marisco ?'
,
'al_egg'
:
'alergia al huevo ?'
,
'al_nuts'
:
'alergia a los frutos secos ?'
}
%}
<div
class=
"row"
>
{#FOR PARA COLOCAR EN ROWS DE 3 COLUMNAS LAS CARACTERISTICAS EN PANTALLAS GRANDES ( MD Y LG )#}
{%
for
key
,
value
in
caracterisitcas
%}
{%
if
is_divisible
(
loop.index
-
1
,
3
)
%}
</div>
<div
class=
"row"
>
{%
endif
%}
<div
class=
"container-checkbox col-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=
"checkbox_
{{
i
}}
"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<input
type=
"checkbox"
id=
"checkbox_
{{
i
}}
"
/>
<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>
caracteristica
{{
i
}}
</p>
<p>
{{
value
}}
</p>
</div>
</div>
</div>
</div>
{%
endfor
%}
{%
endfor
%}
{#FIN FOR LG / MG#}
{#FOR PARA COLOCAR EN ROWS DE 2 COLUMNAS LAS CARACTERISTICAS EN PANTALLAS PEQUEÑAS ( XS Y SM )#}
{%
for
key
,
value
in
caracterisitcas
%}
{%
if
is_divisible
(
loop.index
-
1
,
2
)
%}
</div>
<div
class=
"row"
>
{%
endif
%}
<div
class=
"container-checkbox col-xs-6 col-sm-6 visible-xs visible-sm"
>
<div
class=
"form-group text-center"
>
<label
class=
"switch"
for=
"
{{
"movil_"
~
key
}}
"
>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
"movil_"
~
key
}}
"
rel=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<div
class=
"slider round"
></div>
</label>
<p>
{{
value
}}
</p>
</div>
</div>
{%
endfor
%}
</div>
</div>
</div>
\ No newline at end of file
public/assets/js/perfil/index.js
0 → 100644
View file @
066dbd66
$
(
document
).
ready
(
function
()
{
/**
* Guardamos perfil
*/
$
(
'#save-profile'
).
on
(
'click'
,
function
()
{
var
inputs
=
{};
// Recorremos todos los inputs a guardar
$
(
'.data-profile'
).
map
(
function
()
{
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"
;
}
}
else
{
inputs
[
$
(
this
).
attr
(
'rel'
)]
=
$
(
this
).
val
()
}
}
});
$
.
ajax
({
url
:
"perfil/update"
,
type
:
"POST"
,
method
:
"post"
,
data
:
{
id
:
$
(
'#profile_id'
).
val
(),
inputs
:
inputs
},
success
:
function
(
data
)
{
if
(
data
!=
""
&&
data
!=
0
){
// Modal success
}
else
{
// Modal error
}
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