Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/fourn/card.php
This commit is contained in:
commit
ecde594a15
@ -240,6 +240,7 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
|
||||
if (empty($nocommentremoval)) {
|
||||
$buf = preg_replace('/([,;ERLT\)])\s*--.*$/i', '\1', $buf); //remove comment from a line that not start with -- before add it to the buffer
|
||||
}
|
||||
if ($buffer) $buffer .= ' ';
|
||||
$buffer .= trim($buf);
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ class modHoliday extends DolibarrModules
|
||||
$this->rights[$r][0] = 20005; // Permission id (must not be already used)
|
||||
$this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label
|
||||
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
|
||||
$this->rights[$r][4] = 'writeall_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$this->rights[$r][4] = 'writeall'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||
$r++;
|
||||
|
||||
|
||||
@ -134,6 +134,14 @@ if ($object->id > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
$candelete = 0;
|
||||
if (!empty($user->rights->expensereport->supprimer)) {
|
||||
$candelete = 1;
|
||||
}
|
||||
if ($object->statut == ExpenseReport::STATUS_DRAFT && $user->rights->expensereport->write && in_array($object->fk_user_author, $childids)) {
|
||||
$candelete = 1;
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
@ -226,7 +234,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && GETPOST("confirm", 'alpha') == "yes" && $id > 0 && $user->rights->expensereport->supprimer) {
|
||||
if ($action == 'confirm_delete' && GETPOST("confirm", 'alpha') == "yes" && $id > 0 && $candelete) {
|
||||
$object = new ExpenseReport($db);
|
||||
$result = $object->fetch($id);
|
||||
$result = $object->delete($user);
|
||||
@ -2737,7 +2745,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') {
|
||||
if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->status < ExpenseReport::STATUS_APPROVED) {
|
||||
// Delete
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
|
||||
} elseif ($user->rights->expensereport->supprimer && $object->status != ExpenseReport::STATUS_CLOSED) {
|
||||
} elseif ($candelete && $object->status != ExpenseReport::STATUS_CLOSED) {
|
||||
// Delete
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ if ($object->id > 0) {
|
||||
print '<table class="noborder centpercent lastrecordtable">';
|
||||
print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
|
||||
print '<td colspan="3">'.$langs->trans("ProductsAndServices").'</td><td class="right">';
|
||||
print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'">'.$langs->trans("AllProductReferencesOfSupplier").'<span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().'</span>';
|
||||
print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllProductReferencesOfSupplier").'</span><span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().'</span>';
|
||||
print '</a></td></tr>';
|
||||
|
||||
$return = array();
|
||||
@ -557,7 +557,7 @@ if ($object->id > 0) {
|
||||
print $productstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $objp->supplier_ref;
|
||||
print dol_escape_htmltag($objp->supplier_ref);
|
||||
print '</td>';
|
||||
print '<td class="maxwidthonsmartphone">';
|
||||
print dol_trunc(dol_htmlentities($objp->label), 30);
|
||||
@ -566,7 +566,7 @@ if ($object->id > 0) {
|
||||
print '<td class="right">';
|
||||
//print (isset($objp->unitprice) ? price($objp->unitprice) : '');
|
||||
if (isset($objp->price)) {
|
||||
print price($objp->price);
|
||||
print '<span class="amount">'.price($objp->price).'</span>';
|
||||
if ($objp->quantity > 1) {
|
||||
print ' / ';
|
||||
print $objp->quantity;
|
||||
@ -609,7 +609,7 @@ if ($object->id > 0) {
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">';
|
||||
print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
|
||||
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'">'.$langs->trans("AllPriceRequests").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllPriceRequests").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td></tr>';
|
||||
@ -693,7 +693,7 @@ if ($object->id > 0) {
|
||||
$num = $object_count->total;
|
||||
}
|
||||
|
||||
$sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
|
||||
$sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
|
||||
$sql .= " WHERE p.fk_soc = ".((int) $object->id);
|
||||
$sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
|
||||
@ -709,9 +709,9 @@ if ($object->id > 0) {
|
||||
print '<table class="noborder centpercent lastrecordtable">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">';
|
||||
print '<td colspan="4">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
|
||||
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'">'.$langs->trans("AllOrders").'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllOrders").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td></tr>';
|
||||
@ -720,22 +720,23 @@ if ($object->id > 0) {
|
||||
while ($i < $num && $i < $MAXLIST) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$orderstatic->id = $obj->rowid;
|
||||
$orderstatic->ref = $obj->ref;
|
||||
$orderstatic->total_ht = $obj->total_ht;
|
||||
$orderstatic->total_tva = $obj->total_tva;
|
||||
$orderstatic->total_ttc = $obj->total_ttc;
|
||||
$orderstatic->date = $db->jdate($obj->date);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
print $orderstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td class="center" width="80">';
|
||||
if ($obj->dc) {
|
||||
print dol_print_date($db->jdate($obj->dc), 'day');
|
||||
} else {
|
||||
print "-";
|
||||
if ($obj->date) {
|
||||
print dol_print_date($orderstatic->date, 'day');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).'</span></td>';
|
||||
print '<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
@ -759,7 +760,7 @@ if ($object->id > 0) {
|
||||
|
||||
if ($user->rights->fournisseur->facture->lire) {
|
||||
// TODO move to DAO class
|
||||
$sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc as amount,f.paye,';
|
||||
$sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,';
|
||||
$sql .= ' SUM(pf.amount) as am';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
|
||||
@ -777,7 +778,8 @@ if ($object->id > 0) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'">'.$langs->trans('AllBills').'<span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
|
||||
print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans('AllBills').'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
|
||||
print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td></tr>';
|
||||
@ -786,8 +788,6 @@ if ($object->id > 0) {
|
||||
while ($i < min($num, $MAXLIST)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
$facturestatic->id = $obj->rowid;
|
||||
$facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
|
||||
$facturestatic->ref_supplier = $obj->ref_supplier;
|
||||
@ -796,12 +796,16 @@ if ($object->id > 0) {
|
||||
$facturestatic->total_ht = $obj->total_ht;
|
||||
$facturestatic->total_tva = $obj->total_tva;
|
||||
$facturestatic->total_ttc = $obj->total_ttc;
|
||||
$facturestatic->date = $db->jdate($obj->df);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="tdoverflowmax200">';
|
||||
print '<span class="nowraponall">'.$facturestatic->getNomUrl(1).'</span>';
|
||||
print $obj->ref_supplier ? ' - '.$obj->ref_supplier : '';
|
||||
print ($obj->label ? ' - ' : '').dol_trunc($obj->label, 14);
|
||||
print '</td>';
|
||||
print '<td class="center nowrap">'.dol_print_date($db->jdate($obj->df), 'day').'</td>';
|
||||
print '<td class="right nowrap">'.price($obj->amount).'</td>';
|
||||
print '<td class="center nowrap">'.dol_print_date($facturestatic->date, 'day').'</td>';
|
||||
print '<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).'</span></td>';
|
||||
print '<td class="right nowrap">';
|
||||
print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
|
||||
print '</td>';
|
||||
|
||||
@ -257,6 +257,7 @@ if ($resql) {
|
||||
$trackid = 'prod'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="liste centpercent">';
|
||||
|
||||
// Fields title search
|
||||
@ -357,7 +358,7 @@ if ($resql) {
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
print "</table>";
|
||||
print "</table></div>";
|
||||
|
||||
print '</form>';
|
||||
} else {
|
||||
|
||||
@ -90,13 +90,14 @@ if (($id > 0) || $ref) {
|
||||
$hookmanager->initHooks(array('holidaycard', 'globalcard'));
|
||||
|
||||
$cancreate = 0;
|
||||
|
||||
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
$cancreateall = 0;
|
||||
if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->writeall)) {
|
||||
$cancreate = 1;
|
||||
$cancreateall = 1;
|
||||
}
|
||||
|
||||
$candelete = 0;
|
||||
if (!empty($user->rights->holiday->delete)) {
|
||||
@ -181,23 +182,25 @@ if (empty($reshook)) {
|
||||
$description = trim(GETPOST('description', 'restricthtml'));
|
||||
|
||||
// Check that leave is for a user inside the hierarchy or advanced permission for all is set
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
||||
if (empty($user->rights->holiday->write)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
} elseif (!in_array($fuserid, $childids)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
} else {
|
||||
if (empty($user->rights->holiday->write) && empty($user->rights->holiday->writeall_advance)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
} elseif (empty($user->rights->holiday->writeall_advance) && !in_array($fuserid, $childids)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
|
||||
$action = 'create';
|
||||
if (!$cancreateall) {
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
|
||||
if (empty($user->rights->holiday->write)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
} elseif (!in_array($fuserid, $childids)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
} else {
|
||||
if (empty($user->rights->holiday->write) && empty($user->rights->holiday->writeall_advance)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
} elseif (empty($user->rights->holiday->writeall_advance) && !in_array($fuserid, $childids)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +282,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
// If update and we are an approver, we can update with another approver
|
||||
// If this is an update and we are an approver, we can update to change the approver
|
||||
if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) {
|
||||
$object->fetch($id);
|
||||
|
||||
@ -319,10 +322,18 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// If no right to modify a request
|
||||
if (!$user->rights->holiday->write) {
|
||||
setEventMessages($langs->trans("CantUpdate"), null, 'errors');
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
|
||||
exit;
|
||||
if (!$cancreateall) {
|
||||
if ($cancreate) {
|
||||
if (!in_array($fuserid, $childids)) {
|
||||
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$object->fetch($id);
|
||||
@ -337,13 +348,13 @@ if (empty($reshook)) {
|
||||
$description = trim(GETPOST('description', 'restricthtml'));
|
||||
|
||||
// If no start date
|
||||
if (empty($_POST['date_debut_'])) {
|
||||
if (!GETPOST('date_debut_')) {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=nodatedebut');
|
||||
exit;
|
||||
}
|
||||
|
||||
// If no end date
|
||||
if (empty($_POST['date_fin_'])) {
|
||||
if (!GETPOST('date_fin_')) {
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'&error=nodatefin');
|
||||
exit;
|
||||
}
|
||||
@ -394,7 +405,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// If delete of request
|
||||
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights->holiday->delete) {
|
||||
if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $candelete) {
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
@ -403,14 +414,11 @@ if (empty($reshook)) {
|
||||
|
||||
// If this is a rough draft, approved, canceled or refused
|
||||
if ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED) {
|
||||
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
||||
if ($candelete) {
|
||||
$result = $object->delete($user);
|
||||
} else {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorCantDeleteCP'), null, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
$result = $object->delete($user);
|
||||
} else {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('BadStatusOfObject'), null, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
@ -765,7 +773,7 @@ if (empty($reshook)) {
|
||||
|
||||
// If status pending validation and validator = validator or user, or rights to do for others
|
||||
if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) &&
|
||||
(!empty($user->admin) || $user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))) {
|
||||
(!empty($user->admin) || $user->id == $object->fk_validator || $cancreate || $cancreateall)) {
|
||||
$db->begin();
|
||||
|
||||
$oldstatus = $object->statut;
|
||||
@ -996,12 +1004,11 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield fieldrequired">'.$langs->trans("User").'</td>';
|
||||
print '<td>';
|
||||
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) {
|
||||
if ($cancreate && !$cancreateall) {
|
||||
print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500');
|
||||
//print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
|
||||
} else {
|
||||
print img_picto('', 'user').$form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500');
|
||||
print img_picto('', 'user').$form->select_dolusers($fuserid ? $fuserid : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -1464,7 +1471,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
|
||||
print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>';
|
||||
|
||||
// Button Cancel (because we can't approve)
|
||||
if (in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) {
|
||||
if ($cancreate || $cancreateall) {
|
||||
if (($object->date_debut > dol_now()) || !empty($user->admin)) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
} else {
|
||||
@ -1473,17 +1480,15 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($object->statut == Holiday::STATUS_APPROVED) { // If validated or approved
|
||||
if ($user->id == $object->fk_validator
|
||||
|| in_array($object->fk_user, $childids)
|
||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) {
|
||||
if ($object->statut == Holiday::STATUS_APPROVED) { // If validated and approved
|
||||
if ($user->id == $object->fk_validator || $cancreate || $cancreateall) {
|
||||
if (($object->date_debut > dol_now()) || !empty($user->admin)) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
} else {
|
||||
print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'-'.$langs->trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
}
|
||||
} else { // I have no rights on the user of the holiday.
|
||||
if (!empty($user->admin)) { // If current validator can't cancel an approved leave, we allow admin user
|
||||
if (!empty($user->admin)) { // If current approver can't cancel an approved leave, we allow admin user
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel&token='.newToken().'" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
} else {
|
||||
print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
@ -1491,7 +1496,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) {
|
||||
if (($cancreate || $cancreateall) && $object->statut == Holiday::STATUS_CANCELED) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
|
||||
}
|
||||
if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) { // If draft or canceled or refused
|
||||
|
||||
@ -93,23 +93,6 @@ if (($id > 0) || $ref) {
|
||||
}
|
||||
}
|
||||
|
||||
/*$cancreate = 0;
|
||||
|
||||
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
|
||||
$candelete = 0;
|
||||
if (!empty($user->rights->holiday->delete)) {
|
||||
$candelete = 1;
|
||||
}
|
||||
if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) {
|
||||
$candelete = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
$upload_dir = $conf->holiday->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, '');
|
||||
$modulepart = 'holiday';
|
||||
|
||||
@ -488,9 +488,15 @@ if ($resql) {
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
$canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))));
|
||||
$cancreate = 0;
|
||||
if (!empty($user->rights->holiday->writeall)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->write) && in_array($user_id, $childids)) {
|
||||
$cancreate = 1;
|
||||
}
|
||||
|
||||
if ($canedit) {
|
||||
if ($cancreate) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
|
||||
}
|
||||
|
||||
|
||||
@ -482,3 +482,5 @@ ALTER TABLE llx_inventorydet ADD COLUMN fk_movement integer NULL;
|
||||
ALTER TABLE llx_stock_mouvement MODIFY COLUMN origintype varchar(64);
|
||||
|
||||
ALTER TABLE llx_intracommreport CHANGE COLUMN period periods varchar(32);
|
||||
|
||||
UPDATE llx_rights_def SET perms = 'writeall' WHERE perms = 'writeall_advance' AND module = 'holiday';
|
||||
|
||||
@ -893,12 +893,11 @@ Permission701=Read donations
|
||||
Permission702=Create/modify donations
|
||||
Permission703=Delete donations
|
||||
Permission771=Read expense reports (yours and your subordinates)
|
||||
Permission772=Create/modify expense reports
|
||||
Permission772=Create/modify expense reports (for you and your subordinates)
|
||||
Permission773=Delete expense reports
|
||||
Permission774=Read all expense reports (even for user not subordinates)
|
||||
Permission775=Approve expense reports
|
||||
Permission776=Pay expense reports
|
||||
Permission777=Read expense reports of everybody
|
||||
Permission777=Read all expense reports (even those of user not subordinates)
|
||||
Permission778=Create/modify expense reports of everybody
|
||||
Permission779=Export expense reports
|
||||
Permission1001=Read stocks
|
||||
@ -977,9 +976,9 @@ Permission10005=Delete website content
|
||||
Permission20001=Read leave requests (your leave and those of your subordinates)
|
||||
Permission20002=Create/modify your leave requests (your leave and those of your subordinates)
|
||||
Permission20003=Delete leave requests
|
||||
Permission20004=Read all leave requests (even of user not subordinates)
|
||||
Permission20005=Create/modify leave requests for everybody (even of user not subordinates)
|
||||
Permission20006=Admin leave requests (setup and update balance)
|
||||
Permission20004=Read all leave requests (even those of user not subordinates)
|
||||
Permission20005=Create/modify leave requests for everybody (even those of user not subordinates)
|
||||
Permission20006=Administer leave requests (setup and update balance)
|
||||
Permission20007=Approve leave requests
|
||||
Permission23001=Read Scheduled job
|
||||
Permission23002=Create/update Scheduled job
|
||||
|
||||
@ -1080,11 +1080,12 @@ class User extends CommonObject
|
||||
$sql .= " ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql .= " WHERE r.id = ur.fk_id";
|
||||
if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) {
|
||||
// on old version, we use entity defined into table r
|
||||
// on old version, we use entity defined into table r only
|
||||
$sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")";
|
||||
} else {
|
||||
// we must now use entity into table ur
|
||||
$sql .= " AND ur.entity = ".((int) $conf->entity);
|
||||
// On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation.
|
||||
// So we must include the filter on entity on both table r. and ur.
|
||||
$sql .= " AND r.entity = ".((int) $conf->entity)." AND ur.entity = ".((int) $conf->entity);
|
||||
}
|
||||
$sql .= " AND ur.fk_user= ".((int) $this->id);
|
||||
$sql .= " AND r.perms IS NOT NULL";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user