diff --git a/modules/entities/difflist_display.php b/modules/entities/difflist_display.php index c4193b6fb907c2e16e80948b05533a95df349c2e..eb4e8887d3b8f3b0980d282e6565222107b8ea78 100755 --- a/modules/entities/difflist_display.php +++ b/modules/entities/difflist_display.php @@ -1,112 +1,112 @@ <?php -# Display list -/* Requires - $difflist = diffusion list array - $_SESSION[m_admin]['entities'][listmodel] - $_SESSION[$origin][listinstance] - $roles = list of available roles - $onlyCC = hide 'dest'; +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. + +* +* @brief difflist_display +* +* @author dev <dev@maarch.org> +* @ingroup entities */ - echo '<div style="max-height:490px;overflow:auto;">'; - $empty = 0; - $nb_roles = 0; - if($origin == 'indexing' && $category == 'outgoing'){ - //$difflist['copy'] = array(); +$contentDiffList = ''; + +$contentDiffList .= '<div style="max-height:490px;overflow:auto;">'; + +$empty = 0; +$nb_roles = 0; +foreach ($roles as $role_id => $role_label) { + ++$nb_role; + if ($category == 'outgoing' && $role_label == 'Destinataire') { + $role_label = _SHIPPER; } + if (($specific_role != $role_id && $specific_role.'_copy' != $role_id && $specific_role.'_info' != $role_id) && isset($specific_role) && $specific_role != '') { + continue; + } + if (count($difflist[$role_id]['users']) > 0 + || count($difflist[$role_id]['entities']) > 0 + ) { + ++$empty; + $contentDiffList .= '<h3 class="sstit" style="font-size: 1.2em;">'.$role_label.'</h3>'; + + if (count($difflist[$role_id]['users']) > 0) { + $contentDiffList .= '<table id="diffListUser_'.$role_id.'" cellpadding="0" cellspacing="0" border="0" class="listingsmall liste_diff spec" style="width:100%;margin:0;">'; - foreach($roles as $role_id => $role_label) { - $nb_role++; - if($category == 'outgoing' && $role_label == 'Destinataire'){ - $role_label = _SHIPPER; - } - if(($specific_role != $role_id && $specific_role.'_copy' != $role_id && $specific_role.'_info' != $role_id) && isset($specific_role) && $specific_role <> '') - continue; - if(count($difflist[$role_id]['users']) > 0 - || count($difflist[$role_id]['entities']) > 0 - ) { - $empty++; - ?> - <h3 class="sstit" style="font-size: 1.2em;"><?php functions::xecho($role_label);?></h3><?php - if(count($difflist[$role_id]['users']) > 0) { ?> - <table cellpadding="0" cellspacing="0" border="0" class="listingsmall liste_diff spec" style="width:100%;margin:0;"><?php $color = ' class="col"'; - for($i=0, $l=count($difflist[$role_id]['users']); - $i<$l; - $i++ - ) { + + for ($i = 0, $l = count($difflist[$role_id]['users']); $i < $l; ++$i) { $user = $difflist[$role_id]['users'][$i]; - - if ($color == ' class="col"') $color = ' '; - else $color = ' class="col"'; - + + if ($color == ' class="col"') { + $color = ' '; + } else { + $color = ' class="col"'; + } + if (preg_match("/\[DEL\]/", $difflist[$role_id]['users'][$i]['process_comment'])) { - $styleMoved=" style='text-decoration: line-through;opacity:0.5;' "; - $descMoved=$difflist[$role_id]['users'][$i]['process_comment']; + $styleMoved = " style='text-decoration: line-through;opacity:0.5;' "; + $descMoved = $difflist[$role_id]['users'][$i]['process_comment']; } else { - $styleMoved=""; - $descMoved=""; + $styleMoved = ''; + $descMoved = ''; } - ?> - <tr <?php echo $color.$styleMoved;?> title="<?php echo $descMoved;?>"> - <td style="width:15%;text-align:center;"> - <i class="fa fa-user fa-2x" title="<?php echo _USER;?>"></i> - </td> - <td style="width:10%;"><?php - /* if($user['visible'] == 'Y') { ?> - <i class="fa fa-check fa-2x" title="<?php echo _VISIBLE;?>"></i> <?php - } else {?> - <i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE;?>"></i><?php - } */?> - </td> - <td style="width:37%;"><?php functions::xecho($user['lastname'] . " " . $user['firstname']);?></td> - <td style="width:38%;"><?php functions::xecho($user['entity_label']);?></td> - <?php - if($showStatus == true){ - if(!empty($difflist[$role_id]['users'][$i]['process_date'])){ - echo '<td style="width:5%;"><i class="fa fa-check" aria-hidden="true" style="color:green;"></i></td>'; - }else{ - echo '<td style="width:5%;"><i class="fa fa-hourglass-half" aria-hidden="true"></i></td>'; - } + + $contentDiffList .= '<tr id="'.$user['user_id'].'_'.$role_id.'" '.$color.$styleMoved.' title="'.$descMoved.'">'; + $contentDiffList .= '<td style="width:15%;text-align:center;">'; + $contentDiffList .= '<i class="fa fa-user fa-2x" title="'._USER.'"></i>'; + $contentDiffList .= '</td>'; + $contentDiffList .= '<td style="width:37%;">'.$user['lastname'].' '.$user['firstname'].'</td>'; + $contentDiffList .= '<td style="width:43%;">'.$user['entity_label'].'</td>'; + $contentDiffList .= '<td class="movedest" style="width:5%;">'; + + if (!empty($difflist['dest']['users'][0]) && $role_id != 'dest' && $origin != null && !$core->test_service('add_copy_in_indexing_validation', 'entities', false)) { + $contentDiffList .= '<i class="fa fa-arrow-up" style="cursor:pointer;" title="'._DEST.'" onclick="moveToDest(\''.$user['user_id'].'\',\''.$role_id.'\',\''.$origin.'\');"></i>'; + } + $contentDiffList .= '</td>'; + + if ($showStatus == true) { + if (!empty($difflist[$role_id]['users'][$i]['process_date'])) { + $contentDiffList .= '<td style="width:5%;"><i class="fa fa-check" aria-hidden="true" style="color:green;"></i></td>'; + } else { + $contentDiffList .= '<td style="width:5%;"><i class="fa fa-hourglass-half" aria-hidden="true"></i></td>'; } - - ?> - </tr><?php - } ?> - </table><?php - } - if(count($difflist[$role_id]['entities']) > 0) { ?> - <table cellpadding="0" cellspacing="0" border="0" class="listingsmall liste_diff spec" style="width:100%;margin:0;"><?php + } + $contentDiffList .= '</tr>'; + } + $contentDiffList .= '</table>'; + } + if (count($difflist[$role_id]['entities']) > 0) { + $contentDiffList .= '<table cellpadding="0" cellspacing="0" border="0" class="listingsmall liste_diff spec" style="width:100%;margin:0;">'; $color = ' class="col"'; - for ($i=0, $l=count($difflist[$role_id]['entities']); - $i<$l; - $i++ - ) { + + for ($i = 0, $l = count($difflist[$role_id]['entities']); $i < $l; ++$i) { $entity = $difflist[$role_id]['entities'][$i]; - if ($color == ' class="col"') $color = ''; - else $color = ' class="col"';?> - <tr <?php echo $color;?> > - <td style="width:15%;text-align:center;"> - <i class="fa fa-sitemap fa-2x" title="<?php echo _ENTITY . " " . $role_label ;?>" ></i> - </td> - <td style="width:10%;"><?php - /*if($entity['visible'] == 'Y') { ?> - <i class="fa fa-check fa-2x" title="<?php echo _VISIBLE;?>"></i><?php - } else {?> - <i class="fa fa-times fa-2x" title="<?php echo _NOT_VISIBLE;?>"></i><?php - }*/ ?> - </td> - <td style="width:37%;"><?php functions::xecho($entity['entity_id']);?></td> - <td style="width:38%;"><?php functions::xecho($entity['entity_label']);?></td> - </tr> <?php - } ?> - </table><?php - } ?> - <br/><?php + if ($color == ' class="col"') { + $color = ''; + } else { + $color = ' class="col"'; + } + + $contentDiffList .= '<tr '.$color.'>'; + $contentDiffList .= '<td style="width:15%;text-align:center;">'; + $contentDiffList .= '<i class="fa fa-sitemap fa-2x" title="'._ENTITY.' '.$role_label.'"></i>'; + $contentDiffList .= '</td>'; + $contentDiffList .= '<td style="width:37%;">'.$entity['entity_id'].'</td>'; + $contentDiffList .= '<td style="width:38%;">'.$entity['entity_label'].'</td>'; + $contentDiffList .= '<td style="width:10%;">'; + $contentDiffList .= '</td>'; + $contentDiffList .= '</tr>'; + } + $contentDiffList .= '</table>'; } + $contentDiffList .= '<br/>'; } +} + +if ($empty == $nb_roles) { + $contentDiffList .= '<div style="font-style:italic;text-align:center;color:#ea0000;margin:10px;">'._DIFF_LIST.' '._IS_EMPTY.'</div>'; +} +$contentDiffList .= '</div>'; - if($empty == $nb_roles){ - echo '<div style="font-style:italic;text-align:center;color:#ea0000;margin:10px;">'._DIFF_LIST.' '._IS_EMPTY.'</div>'; - } -echo '</div>'; -?> +echo $contentDiffList; diff --git a/modules/entities/js/functions.js b/modules/entities/js/functions.js index 873dc180991dfb33a2bd03cd2cd19680785001c4..fdf411b19631d1d73e991a3a841e94a887bda5b2 100755 --- a/modules/entities/js/functions.js +++ b/modules/entities/js/functions.js @@ -167,7 +167,6 @@ function load_listmodel( }); } - function change_diff_list( origin, display_value_tr, @@ -176,7 +175,6 @@ function change_diff_list( category, specific_role ) { - if(category === undefined){ category = ''; } @@ -364,4 +362,66 @@ function loadToolbarEntities(where) //alert('erreur'); } }); +} + +function moveToDest(user_id,role_id,origin) { + var pos = $j('#'+user_id+'_'+role_id)[0].rowIndex; + + $j('tr[id$=_dest]').after($j('#'+user_id+'_'+role_id)[0]); + + console.log($j('#diffListUser_'+role_id+' tr:eq('+pos+')')); + if ($j('#diffListUser_'+role_id+' tr:eq('+pos+')').length) { + $j('#diffListUser_'+role_id+' tr:eq('+pos+')')[0].before($j('tr[id$=_dest]')[0]); + }else{ + $j('#diffListUser_'+role_id)[0].append($j('tr[id$=_dest]')[0]); + } + + var destUserId = $j('tr[id$=_dest]')[0].id.replace("_dest",""); + + $j('#'+destUserId+'_dest .movedest').append('<i class="fa fa-arrow-up" style="cursor:pointer;" title="" onclick="moveToDest(\''+destUserId+'\',\''+role_id+'\');"></i>'); + + $j('tr[id$=_dest]')[0].id = destUserId+'_'+role_id; + + + $j('#'+user_id+'_'+role_id).removeClass('col'); + $j('#'+user_id+'_'+role_id+' .movedest i').remove(); + + $j('#'+user_id+'_'+role_id).prop('onclick',null).off('click'); + + $j('#'+user_id+'_'+role_id)[0].id = user_id+'_dest'; + + i=0; + $j("#diffListUser_"+role_id+' tr').each(function() { + $j('#'+this.id).removeClass('col'); + + if (i%2) { + $j('#'+this.id).addClass('col'); + } + i++ + }); + + $j.ajax({ + url : 'index.php?display=true&module=entities&page=reloadListDiff', + type : 'POST', + dataType : 'JSON', + data: { + rank: pos, + origin: origin, + role_id: role_id + + }, + success : function(response){ + if (response.status == 0) { + + var userList = response.result; + + } else { + alert('ERROR!'); + } + }, + error : function(error){ + console.log('ERROR!'); + } + + }); } \ No newline at end of file diff --git a/modules/entities/reloadListDiff.php b/modules/entities/reloadListDiff.php new file mode 100644 index 0000000000000000000000000000000000000000..e8bd5d11ba6f3baeb99fd8a577ebef51a2d1f714 --- /dev/null +++ b/modules/entities/reloadListDiff.php @@ -0,0 +1,22 @@ +<?php +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. + +* @brief reloadListDiff +* @author dev <dev@maarch.org> +* @ingroup entities +*/ + +$origin = $_REQUEST['origin']; +$role_id = $_REQUEST['role_id']; +$rank = $_REQUEST['rank']; + +$oldDest = $_SESSION[$origin]['diff_list']['dest']['users'][0]; + +$_SESSION[$origin]['diff_list']['dest']['users'][0] = $_SESSION[$origin]['diff_list'][$role_id]['users'][$rank]; + +$_SESSION[$origin]['diff_list'][$role_id]['users'][$rank] = $oldDest; + +echo "{\"status\" : 0}"; \ No newline at end of file