Merge pull request #13679 from TobiasSekan/cleanupUserRightsSupplierProposalCard

Cleanup user rights on supplier proposal card
This commit is contained in:
Laurent Destailleur 2020-05-28 21:12:37 +02:00 committed by GitHub
commit 79c2d96375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,9 +96,23 @@ if ($id > 0 || !empty($ref)) {
dol_print_error('', $object->error); dol_print_error('', $object->error);
} }
$permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php // Common permissions
$permissiondellink = $user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php $usercanread = $user->rights->supplier_proposal->lire;
$permissiontoedit = $user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php $usercancreate = $user->rights->supplier_proposal->creer;
$usercandelete = $user->rights->supplier_proposal->supprimer;
// Advanced permissions
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance);
// Additional area permissions
$usercanclose = $user->rights->supplier_proposal->cloturer;
$usercancreateorder = $user->rights->fournisseur->commande->creer;
// Permissions for includes
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
/* /*
@ -148,7 +162,7 @@ if (empty($reshook))
} }
// Delete askprice // Delete askprice
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->supplier_proposal->supprimer) elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete)
{ {
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) { if ($result > 0) {
@ -161,7 +175,7 @@ if (empty($reshook))
} }
// Remove line // Remove line
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->supplier_proposal->creer) elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
{ {
$result = $object->deleteline($lineid); $result = $object->deleteline($lineid);
// reorder lines // reorder lines
@ -185,10 +199,7 @@ if (empty($reshook))
} }
// Validation // Validation
elseif ($action == 'confirm_validate' && $confirm == 'yes' && elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)))
)
{ {
$result = $object->valid($user); $result = $object->valid($user);
if ($result >= 0) if ($result >= 0)
@ -217,15 +228,14 @@ if (empty($reshook))
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
else setEventMessages($langs->trans($object->error), null, 'errors'); else setEventMessages($langs->trans($object->error), null, 'errors');
} }
} elseif ($action == 'setdate_livraison' && $user->rights->supplier_proposal->creer) } elseif ($action == 'setdate_livraison' && $usercancreate) {
{
$result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']));
if ($result < 0) if ($result < 0)
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
// Create supplier proposal // Create supplier proposal
elseif ($action == 'add' && $user->rights->supplier_proposal->creer) elseif ($action == 'add' && $usercancreate)
{ {
$object->socid = $socid; $object->socid = $socid;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -449,7 +459,7 @@ if (empty($reshook))
} }
// Reopen proposal // Reopen proposal
elseif ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) {
// prevent browser refresh from reopening proposal several times // prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) { if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) {
$object->reopen($user, SupplierProposal::STATUS_VALIDATED); $object->reopen($user, SupplierProposal::STATUS_VALIDATED);
@ -457,7 +467,7 @@ if (empty($reshook))
} }
// Close proposal // Close proposal
elseif ($action == 'close' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { elseif ($action == 'close' && $usercanclose && !GETPOST('cancel', 'alpha')) {
// prevent browser refresh from reopening proposal several times // prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED) { if ($object->statut == SupplierProposal::STATUS_SIGNED) {
$object->setStatut(SupplierProposal::STATUS_CLOSE); $object->setStatut(SupplierProposal::STATUS_CLOSE);
@ -465,7 +475,7 @@ if (empty($reshook))
} }
// Set accepted/refused // Set accepted/refused
elseif ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) {
if (!GETPOST('statut')) { if (!GETPOST('statut')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), null, 'errors');
$action = 'statut'; $action = 'statut';
@ -488,12 +498,12 @@ if (empty($reshook))
// Actions to build doc // Actions to build doc
$upload_dir = $conf->supplier_proposal->dir_output; $upload_dir = $conf->supplier_proposal->dir_output;
$permissiontoadd = $user->rights->supplier_proposal->creer; $permissiontoadd = $usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Go back to draft // Go back to draft
if ($action == 'modif' && $user->rights->supplier_proposal->creer) if ($action == 'modif' && $usercancreate)
{ {
$object->setDraft($user); $object->setDraft($user);
@ -509,7 +519,7 @@ if (empty($reshook))
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} elseif ($action == "setabsolutediscount" && $user->rights->supplier_proposal->creer) { } elseif ($action == "setabsolutediscount" && $usercancreate) {
if ($_POST["remise_id"]) { if ($_POST["remise_id"]) {
if ($object->id > 0) { if ($object->id > 0) {
$result = $object->insert_discount($_POST["remise_id"]); $result = $object->insert_discount($_POST["remise_id"]);
@ -521,7 +531,7 @@ if (empty($reshook))
} }
// Add a product line // Add a product line
if ($action == 'addline' && $user->rights->supplier_proposal->creer) if ($action == 'addline' && $usercancreate)
{ {
$langs->load('errors'); $langs->load('errors');
$error = 0; $error = 0;
@ -822,7 +832,7 @@ if (empty($reshook))
} }
// Mise a jour d'une ligne dans la demande de prix // Mise a jour d'une ligne dans la demande de prix
elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) { elseif ($action == 'updateline' && $usercancreate && GETPOST('save') == $langs->trans("Save")) {
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
// Define info_bits // Define info_bits
@ -988,42 +998,42 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition
exit(); exit();
} }
// Set project // Set project
elseif ($action == 'classin' && $user->rights->supplier_proposal->creer) { elseif ($action == 'classin' && $usercancreate) {
$object->setProject(GETPOST('projectid'), 'int'); $object->setProject(GETPOST('projectid'), 'int');
} }
// Delivery delay // Delivery delay
elseif ($action == 'setavailability' && $user->rights->supplier_proposal->creer) { elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability($_POST['availability_id']); $result = $object->availability($_POST['availability_id']);
} }
// Terms of payments // Terms of payments
elseif ($action == 'setconditions' && $user->rights->supplier_proposal->creer) { elseif ($action == 'setconditions' && $usercancreate) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
} elseif ($action == 'setremisepercent' && $user->rights->supplier_proposal->creer) { } elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise_percent($user, $_POST['remise_percent']); $result = $object->set_remise_percent($user, GETPOST('remise_percent', 'alpha'));
} elseif ($action == 'setremiseabsolue' && $user->rights->supplier_proposal->creer) { } elseif ($action == 'setremiseabsolue' && $usercancreate) {
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']); $result = $object->set_remise_absolue($user, GETPOST('remise_absolue', 'alpha'));
} }
// Payment mode // Payment mode
elseif ($action == 'setmode' && $user->rights->supplier_proposal->creer) { elseif ($action == 'setmode' && $usercancreate) {
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
} }
// Multicurrency Code // Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $user->rights->supplier_proposal->creer) { elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} }
// Multicurrency rate // Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $user->rights->supplier_proposal->creer) { elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
} elseif ($action == 'update_extras') { } elseif ($action == 'update_extras') {
$object->oldcopy = dol_clone($object); $object->oldcopy = dol_clone($object);
@ -1447,8 +1457,8 @@ if ($action == 'create')
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Ref supplier // Ref supplier
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)';
@ -1457,7 +1467,7 @@ if ($action == 'create')
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->supplier_proposal->creer) if ($usercancreate)
{ {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
@ -1647,7 +1657,7 @@ if ($action == 'create')
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount'); print $langs->trans('BankAccount');
print '</td>'; print '</td>';
if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) if ($action != 'editbankaccount' && $usercancreate)
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
@ -1776,7 +1786,7 @@ if ($action == 'create')
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
// Form to add new line // Form to add new line
if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) if ($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate)
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
@ -1837,22 +1847,20 @@ if ($action == 'create')
if ($action != 'statut' && $action != 'editline') if ($action != 'statut' && $action != 'editline')
{ {
// Validate // Validate
if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && $usercanvalidate)
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) {
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)))
) {
if (count($object->lines) > 0) if (count($object->lines) > 0)
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Validate').'</a></div>';
// else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>'; // else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>';
} }
// Edit // Edit
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->creer) { if ($object->statut == SupplierProposal::STATUS_VALIDATED && $usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a></div>';
} }
// ReOpen // ReOpen
if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $user->rights->supplier_proposal->cloturer) { if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $usercanclose) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"';
print '>'.$langs->trans('ReOpen').'</a></div>'; print '>'.$langs->trans('ReOpen').'</a></div>';
} }
@ -1860,7 +1868,7 @@ if ($action == 'create')
// Send // Send
if (empty($user->socid)) { if (empty($user->socid)) {
if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { if ($usercansend) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
} else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>'; } else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
} }
@ -1868,30 +1876,30 @@ if ($action == 'create')
// Create an order // Create an order
if (!empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { if (!empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) {
if ($user->rights->fournisseur->commande->creer) { if ($usercancreateorder) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>';
} }
} }
// Set accepted/refused // Set accepted/refused
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->cloturer) { if ($object->statut == SupplierProposal::STATUS_VALIDATED && $usercanclose) {
print '<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused').'"'; print '<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused').'"';
print '>'.$langs->trans('SetAcceptedRefused').'</a></div>'; print '>'.$langs->trans('SetAcceptedRefused').'</a></div>';
} }
// Close // Close
if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) { if ($object->statut == SupplierProposal::STATUS_SIGNED && $usercanclose) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=close'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=close'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
print '>'.$langs->trans('Close').'</a></div>'; print '>'.$langs->trans('Close').'</a></div>';
} }
// Clone // Clone
if ($user->rights->supplier_proposal->creer) { if ($usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
} }
// Delete // Delete
if (($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) { if (($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate) || $usercandelete) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
print '>'.$langs->trans('Delete').'</a></div>'; print '>'.$langs->trans('Delete').'</a></div>';
} }
@ -1911,8 +1919,8 @@ if ($action == 'create')
$filename = dol_sanitizeFileName($object->ref); $filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref); $filedir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->supplier_proposal->lire; $genallowed = $usercanread;
$delallowed = $user->rights->supplier_proposal->creer; $delallowed = $usercancreate;
print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);