Fix look and feel v6

This commit is contained in:
Laurent Destailleur 2017-06-13 15:34:18 +02:00
parent 9f3e35ef85
commit c8856182a6
5 changed files with 204 additions and 120 deletions

View File

@ -1891,6 +1891,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1;
$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu supplier invoice
elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output))
{
if ($fuser->rights->expensereport->{$lire}) $accessallowed=1;
$original_file=$conf->expensereport->dir_output.'/'.$original_file;
}
// Wrapping pour les images des stats propales
elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp))
{

View File

@ -1155,14 +1155,15 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (class_exists("Imagick"))
{
if ($object->element == 'propal') $modulepart='propal';
if ($object->element == 'commande') $modulepart='commande';
if ($object->element == 'facture') $modulepart='facture';
if ($object->element == 'fichinter') $modulepart='ficheinter';
if ($object->element == 'contrat') $modulepart='contract';
if ($object->element == 'propal') $modulepart='propal';
if ($object->element == 'commande') $modulepart='commande';
if ($object->element == 'facture') $modulepart='facture';
if ($object->element == 'fichinter') $modulepart='ficheinter';
if ($object->element == 'contrat') $modulepart='contract';
if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal';
if ($object->element == 'order_supplier') $modulepart='supplier_order';
if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice';
if ($object->element == 'expensereport') $modulepart='expensereport';
}
if ($object->element == 'product')
@ -1192,7 +1193,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
$phototoshow='';
// Check if a preview file is available
if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice')) && class_exists("Imagick"))
if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick"))
{
$objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->$modulepart->dir_output . "/";

View File

@ -576,27 +576,27 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
{
$object = new Holiday($db);
$object->fetch($id);
$oldstatus = $object->statut;
$object->statut = 1;
$result = $object->update($user);
if ($result < 0)
{
$error = $langs->trans('ErrorBackToDraft');
}
if (! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
{
$db->rollback();
}
}
}
// Si Validation de la demande
@ -1029,7 +1029,7 @@ else
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
}
$head=holiday_prepare_head($object);
@ -1041,17 +1041,17 @@ else
print '<input type="hidden" name="id" value="'.$object->id.'" />'."\n";
}
dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday');
dol_fiche_head($head, 'card', $langs->trans("CPTitreMenu"), -1, 'holiday');
$linkback='<a href="'.DOL_URL_ROOT.'/holiday/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref');
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<tbody>';
@ -1153,9 +1153,9 @@ else
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
// Info workflow
print '<table class="border centpercent">'."\n";
print '<tbody>';
@ -1212,12 +1212,12 @@ else
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
if ($action == 'edit' && $object->statut == 1)
{
print '<div align="center">';
@ -1273,7 +1273,7 @@ else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
}
print '</div>';
}

View File

@ -1195,12 +1195,15 @@ class Holiday extends CommonObject
*
* @param boolean $stringlist If true return a string list of id. If false, return an array
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
* @param string $filters Filters
* @return array|string|int Return an array
*/
function fetchUsers($stringlist=true,$type=true)
function fetchUsers($stringlist=true, $type=true, $filters='')
{
global $conf;
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
// Si vrai donc pour user Dolibarr
if ($stringlist)
{
@ -1219,11 +1222,12 @@ class Holiday extends CommonObject
$sql.= " OR u.admin = 1";
}
else
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
$sql.= " AND u.statut > 0";
if ($filters) $sql.=$filters;
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@ -1261,9 +1265,10 @@ class Holiday extends CommonObject
{
// We want only list of user id
$sql = "SELECT DISTINCT cpu.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE cpu.fk_user = u.user";
if ($filters) $sql.=$filters;
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@ -1318,8 +1323,8 @@ class Holiday extends CommonObject
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql.= " AND u.statut > 0";
if ($filters) $sql.=$filters;
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@ -1358,14 +1363,13 @@ class Holiday extends CommonObject
}
}
else
{
{
// List of vacation balance users
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu,";
$sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE cpu.fk_user = u.rowid";
if ($filters) $sql.=$filters;
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL

View File

@ -30,81 +30,135 @@ require('../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
$langs->load('users');
$langs->load('hrm');
$action=GETPOST('action','aZ09');
$search_name=GETPOST('search_name', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="t.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC";
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
// If the user does not have perm to read the page
if(!$user->rights->holiday->read) accessforbidden();
$action=GETPOST('action','aZ09');
// Initialize technical object to manage context to save list fields
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'defineholidaylist';
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('defineholidaylist'));
$extrafields = new ExtraFields($db);
$holiday = new Holiday($db);
$langs->load('users');
$langs->load('hrm');
/*
* Actions
*/
// Si il y a une action de mise à jour
if ($action == 'update' && isset($_POST['update_cp']))
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
$error = 0;
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
$typeleaves=$holiday->getTypes(1,1);
$userID = array_keys($_POST['update_cp']);
$userID = $userID[0];
foreach($typeleaves as $key => $val)
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{
$userValue = $_POST['nb_holiday_'.$val['rowid']];
$userValue = $userValue[$userID];
if (!empty($userValue))
{
$userValue = price2num($userValue,5);
} else {
$userValue = '';
}
//If the user set a comment, we add it to the log comment
$comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
//print 'eee'.$val['rowid'].'-'.$userValue;
if ($userValue != '')
{
// We add the modification to the log (must be before update of sold because we read current value of sold)
$result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
if ($result < 0)
{
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// Update of the days of the employee
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
if ($result < 0)
{
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// If it first update of balance, we set date to avoid to have sold incremented by new month
/*
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
$result = $db->query($sql);
*/
}
$search_name='';
$toselect='';
$search_array_options=array();
}
if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
// Mass actions
/*
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permtoread = $user->rights->skeleton->read;
$permtodelete = $user->rights->skeleton->delete;
$uploaddir = $conf->skeleton->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
*/
// Si il y a une action de mise à jour
if ($action == 'update' && isset($_POST['update_cp']))
{
$error = 0;
$typeleaves=$holiday->getTypes(1,1);
$userID = array_keys($_POST['update_cp']);
$userID = $userID[0];
foreach($typeleaves as $key => $val)
{
$userValue = $_POST['nb_holiday_'.$val['rowid']];
$userValue = $userValue[$userID];
if (!empty($userValue))
{
$userValue = price2num($userValue,5);
} else {
$userValue = '';
}
//If the user set a comment, we add it to the log comment
$comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
//print 'eee'.$val['rowid'].'-'.$userValue;
if ($userValue != '')
{
// We add the modification to the log (must be before update of sold because we read current value of sold)
$result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
if ($result < 0)
{
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// Update of the days of the employee
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
if ($result < 0)
{
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// If it first update of balance, we set date to avoid to have sold incremented by new month
/*
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
$result = $db->query($sql);
*/
}
}
if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
}
}
@ -117,6 +171,17 @@ $userstatic=new User($db);
llxHeader('', $langs->trans('CPTitreMenu'));
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print load_fiche_titre($langs->trans('MenuConfCP'), '', 'title_hrm.png');
print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
@ -137,10 +202,12 @@ if ($result < 0)
setEventMessages($holiday->error, $holiday->errors, 'errors');
}
$listUsers = $holiday->fetchUsers(false,true);
$filters=natural_search(array('u.firstname','u.lastname'), $search_name);
$listUsers = $holiday->fetchUsers(false,true,$filters);
if (is_numeric($listUsers) && $listUsers < 0)
{
setEventMessages($holiday->error, $holiday->errors, 'errors');
setEventMessages($holiday->error, $holiday->errors, 'errors');
}
$var=true;
@ -159,22 +226,44 @@ else
{
$canedit=0;
if (! empty($user->rights->holiday->define_holiday)) $canedit=1;
// Get array of ids of all childs
$userchilds=array();
if (empty($user->rights->holiday->read_all))
{
$userchilds=$user->getAllChildIds();
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="action" value="update" />';
$moreforfilter='';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).'"></td>';
if (count($typeleaves))
{
foreach($typeleaves as $key => $val)
{
print '<td class="liste_titre" style="text-align:center"></td>';
}
}
else
{
print '<td class="liste_titre"></td>';
}
print '<td class="liste_titre"></td>';
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('Employee'), $_SERVER["PHP_SELF"]);
if (count($typeleaves))
@ -193,35 +282,18 @@ else
print '</th>';
print_liste_field_titre('');
print '</tr>';
print '<tr class="liste_titre">';
print '<td class="liste_titre"></td>';
if (count($typeleaves))
{
foreach($typeleaves as $key => $val)
{
print '<td class="liste_titre" style="text-align:center"></td>';
}
}
else
{
print '<td class="liste_titre"></td>';
}
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '</tr>';
foreach($listUsers as $users)
{
// If user has not permission to edit/read all, we must see only subordinates
if (empty($user->rights->holiday->read_all))
if (empty($user->rights->holiday->read_all))
{
if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
}
print '<tr class="oddeven">';
// User
print '<td>';
$userstatic->id=$users['rowid'];
@ -252,7 +324,7 @@ else
{
print '<td></td>';
}
// Note
print '<td style="text-align:center">';
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
@ -270,9 +342,10 @@ else
print '</table>';
print '</div>';
print '</form>';
}
print '</form>';
llxFooter();
$db->close();