Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F1299670
select_modalities.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Nov 19, 12:09 AM
Size
10 KB
Mime Type
text/x-php
Expires
Fri, Nov 21, 12:09 AM (16 h, 3 m)
Engine
blob
Format
Raw Data
Handle
294689
Attached To
rDIAS DIAS
select_modalities.php
View Options
<?php
require_once
(
"../../db_connect.php"
);
global
$dbh
;
global
$dbh_portal
;
$userid
=
(
isset
(
$_SERVER
[
'persistent-id'
])
?
$_SERVER
[
'persistent-id'
]
:
null
);
$institution
=
(
isset
(
$_SERVER
[
'HTTP_SCHACHOMEORGANIZATION'
])
?
$_SERVER
[
'HTTP_SCHACHOMEORGANIZATION'
]
:
null
);
global
$src_aet
;
require_once
(
'../../institutions_mapping.php'
);
if
(
isset
(
$_POST
[
'action'
])
&&
$_POST
[
'action'
]
==
'read'
){
//**************************** READ ********************************************
$sth
=
$dbh_portal
->
prepare
(
"SELECT * FROM db_modalities where persistent_id = ?;"
);
$sth
->
bindParam
(
1
,
$userid
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$db_modalities_count
=
$sth
->
rowCount
();
$db_mod_row
=
$sth
->
fetch
();
$sth
=
$dbh
->
prepare
(
"SELECT DISTINCT mods_in_study as name FROM study left join series on study.pk = series.study_fk WHERE src_aet=?;"
);
$sth
->
bindParam
(
1
,
$src_aet
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
// ---- If user id doctor and has filtered modalities
if
(
$db_modalities_count
>
0
&&
$db_mod_row
[
'filter_user_modal'
]
!=
"all"
&&
(
$db_mod_row
[
'filter_user_modal'
]
!=
""
||
$db_mod_row
[
'filter_user_modal'
]
!=
NULL
)){
$temp
=
explode
(
","
,
$db_mod_row
[
'filter_user_modal'
]);
foreach
(
$temp
as
$tmp
){
$modalities
[]
=
array
(
"name"
=>
$tmp
);
}
}
else
{
$modalities
=
$sth
->
fetchAll
();
}
$modalityX
=
array
();
foreach
(
$modalities
as
$modx
){
$arrMod
=
explode
(
"
\\
"
,
$modx
[
'name'
]);
foreach
(
$arrMod
as
$modpart
){
$modalityX
=
array_merge
(
$modalityX
,
array
(
$modpart
=>
'1'
));
}
}
$modArrx
=
array
();
foreach
(
$modalityX
as
$keyx
=>
$val
){
$modArrx
[]
=
$keyx
;
}
sort
(
$modArrx
);
?>
<script type='text/javascript'>
$(function(){
//Init
$('#dialog-modalities .chkb').not("#dialog-modalities .select_all input").each(function(){
if(this.checked){
$('#dialog-modalities .select_all input').get(0).checked = true;
$('#dialog-modalities .select_all').addClass('selected_checkbox');
}
else{
$('#dialog-modalities .select_all input').get(0).checked = false;
$('#dialog-modalities .select_all').removeClass('selected_checkbox');
return false;
}
});
$('#dialog-modalities .select_all').click(function() {
if($(this).hasClass("selected_checkbox")) {
$('#dialog-modalities .chkb').each(function() {
this.checked = false;
$('#dialog-modalities .mob_chk').removeClass('selected_checkbox');
});
}else{
$('#dialog-modalities .chkb').each(function() {
this.checked = true;
$('#dialog-modalities .mob_chk').addClass('selected_checkbox');
});
}
});
$('#dialog-modalities .mob_chk').not("#dialog-modalities .select_all").click(function(){
$('#dialog-modalities .select_all').removeClass('selected_checkbox').find('input').get(0).checked = false;
$(this).find('input').get(0).checked = !$(this).find('input').get(0).checked;
$(this).toggleClass('selected_checkbox');
if($('#dialog-modalities .mob_chk.selected_checkbox').not('#dialog-modalities .select_all').length < $('#dialog-modalities .mob_chk').not('#dialog-modalities .select_all').length)
$('#dialog-modalities .select_all').removeClass('selected_checkbox').find('input').get(0).checked = false;
else
$('#dialog-modalities .select_all').addClass('selected_checkbox').find('input').get(0).checked = true;
});
});
</script>
<br>
<div class="mob_chk select_all"><input type="checkbox" class="chkb"> Επιλογή / Αποεπιλογή Όλων</div>
<br>
<?php
$db_mod_row
=
explode
(
","
,
$db_mod_row
[
'modalities'
]);
foreach
(
$modArrx
as
$keyx
){
$selected
=
false
;
for
(
$i
=
0
;
$i
<
count
(
$db_mod_row
);
$i
++){
if
(
$keyx
==
$db_mod_row
[
$i
]){
$selected
=
true
;
break
;
}
}
if
(
$selected
){
?>
<div class="mob_chk selected_checkbox"><input class="chkb" type="checkbox" name="db_modal[]" value="
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
" checked >
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
</div>
<?php
}
else
{
?>
<div class="mob_chk"><input class="chkb" type="checkbox" name="db_modal[]" value="
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
" >
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
</div>
<?php
}
}
}
elseif
(
isset
(
$_POST
[
'action'
])
&&
$_POST
[
'action'
]
==
'write'
){
//**************************** WRITE ********************************************
$modal
=
''
;
foreach
(
$_POST
[
'modalities'
]
as
$item
){
if
(
$modal
==
''
)
$modal
=
$item
;
else
$modal
=
$modal
.
","
.
$item
;
}
$sth_user_id
=
$dbh_portal
->
prepare
(
"SELECT id FROM db_user WHERE persistent_id = ?;"
);
$sth_user_id
->
bindParam
(
1
,
$userid
,
PDO
::
PARAM_STR
);
$sth_user_id
->
execute
();
$sth_user_id
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$user_id_row
=
$sth_user_id
->
fetch
();
$user_id
=
$user_id_row
[
'id'
];
$sth
=
$dbh_portal
->
prepare
(
"SELECT * FROM db_modalities;"
);
$sth
->
execute
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$flag
=
0
;
while
(
$row
=
$sth
->
fetch
()){
if
(
$row
[
'persistent_id'
]
==
$userid
)
$flag
=
1
;
}
if
(
$flag
==
1
){
$sth
=
$dbh_portal
->
prepare
(
"UPDATE db_modalities SET modalities = ? WHERE persistent_id = ? ;"
);
$sth
->
bindParam
(
1
,
$modal
,
PDO
::
PARAM_STR
);
$sth
->
bindParam
(
2
,
$userid
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
}
else
{
$sth
=
$dbh_portal
->
prepare
(
"INSERT INTO db_modalities (user_id, modalities, filter_user_modal, persistent_id) VALUES (?, ?, 'all', ?)"
);
$sth
->
bindParam
(
1
,
$user_id
,
PDO
::
PARAM_STR
);
$sth
->
bindParam
(
2
,
$modal
,
PDO
::
PARAM_STR
);
$sth
->
bindParam
(
3
,
$userid
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
}
// --------- Get the selected Modalities ---------------------------------------
$sth
=
$dbh_portal
->
prepare
(
"SELECT * FROM db_modalities where persistent_id = ?;"
);
$sth
->
bindParam
(
1
,
$userid
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$db_mod_row
=
$sth
->
fetch
();
?>
<ul>
<?php
$db_mod_row
=
explode
(
","
,
$db_mod_row
[
'modalities'
]);
if
(!
empty
(
$db_mod_row
[
0
])){
for
(
$i
=
0
;
$i
<
count
(
$db_mod_row
);
$i
++){
?>
<li>
<div class="checkbox_container">
<input class="chk" type="checkbox" name="modality[]" value="
<?php
print
(
htmlspecialchars
(
$db_mod_row
[
$i
],
ENT_QUOTES
));
?>
"> <span class="checkbox_label">
<?php
print
(
htmlspecialchars
(
$db_mod_row
[
$i
],
ENT_QUOTES
));
?>
</span>
</div>
</li>
<?php
}
}
?>
</ul>
<?php
}
elseif
(
isset
(
$_POST
[
'action'
])
&&
$_POST
[
'action'
]
==
'user_filter'
){
//**************************** USER FILTER ********************************************
$sth
=
$dbh_portal
->
prepare
(
"SELECT * FROM db_modalities where user_id = ?;"
);
$sth
->
bindParam
(
1
,
$_POST
[
'user_id'
],
PDO
::
PARAM_STR
);
$sth
->
execute
();
$db_mod_row_count
=
$sth
->
rowCount
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$db_mod_row
=
$sth
->
fetch
();
$sth
=
$dbh
->
prepare
(
"SELECT DISTINCT mods_in_study as name FROM study left join series on study.pk = series.study_fk WHERE src_aet = ?;"
);
$sth
->
bindParam
(
1
,
$src_aet
,
PDO
::
PARAM_STR
);
$sth
->
execute
();
$sth
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$modalities
=
$sth
->
fetchAll
();
$modalityX
=
array
();
foreach
(
$modalities
as
$modx
){
$arrMod
=
explode
(
"
\\
"
,
$modx
[
'name'
]);
foreach
(
$arrMod
as
$modpart
){
$modalityX
=
array_merge
(
$modalityX
,
array
(
$modpart
=>
'1'
));
}
}
$modArrx
=
array
();
foreach
(
$modalityX
as
$keyx
=>
$val
){
$modArrx
[]
=
$keyx
;
}
sort
(
$modArrx
);
?>
<script type='text/javascript'>
$(function(){
//Init
$('#dialog-modalities .chkb').not("#dialog-modalities .select_all input").each(function(){
if(this.checked){
$('#dialog-modalities .select_all input').get(0).checked = true;
$('#dialog-modalities .select_all').addClass('selected_checkbox');
}
else{
$('#dialog-modalities .select_all input').get(0).checked = false;
$('#dialog-modalities .select_all').removeClass('selected_checkbox');
return false;
}
});
$('#dialog-modalities .select_all').click(function() {
if($(this).hasClass("selected_checkbox")) {
$('#dialog-modalities .chkb').each(function() {
this.checked = false;
$('#dialog-modalities .mob_chk').removeClass('selected_checkbox');
});
}else{
$('#dialog-modalities .chkb').each(function() {
this.checked = true;
$('#dialog-modalities .mob_chk').addClass('selected_checkbox');
});
}
});
$('#dialog-modalities .mob_chk').not("#dialog-modalities .select_all").click(function(){
$('#dialog-modalities .select_all').removeClass('selected_checkbox').find('input').get(0).checked = false;
$(this).find('input').get(0).checked = !$(this).find('input').get(0).checked;
$(this).toggleClass('selected_checkbox');
if($('#dialog-modalities .mob_chk.selected_checkbox').not('#dialog-modalities .select_all').length < $('#dialog-modalities .mob_chk').not('#dialog-modalities .select_all').length)
$('#dialog-modalities .select_all').removeClass('selected_checkbox').find('input').get(0).checked = false;
else
$('#dialog-modalities .select_all').addClass('selected_checkbox').find('input').get(0).checked = true;
});
<?php
if
((
$_POST
[
"edit"
]==
"edit"
&&
$db_mod_row_count
==
0
)
||
$db_mod_row
[
'filter_user_modal'
]
==
'all'
){
?>
$('.mob_chk.select_all').click();
<?php
}
?>
});
</script>
<br>
<div class="mob_chk select_all"><input type="checkbox" value="" class="chkb"> Επιλογή / Αποεπιλογή Όλων</div>
<br>
<?php
$db_mod_row
=
explode
(
","
,
$db_mod_row
[
'filter_user_modal'
]);
foreach
(
$modArrx
as
$keyx
){
$selected
=
false
;
for
(
$i
=
0
;
$i
<
count
(
$db_mod_row
);
$i
++){
if
(
$keyx
==
$db_mod_row
[
$i
]){
$selected
=
true
;
break
;
}
}
if
(
$selected
){
?>
<div class="mob_chk selected_checkbox"><input class="chkb" type="checkbox" name="db_modal[]" value="
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
" checked >
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
</div>
<?php
}
else
{
?>
<div class="mob_chk"><input class="chkb" type="checkbox" name="db_modal[]" value="
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
" >
<?php
print
(
htmlspecialchars
(
$keyx
,
ENT_QUOTES
));
?>
</div>
<?php
}
}
}
?>
Event Timeline
Log In to Comment