Add right supplier_invoice

This commit is contained in:
Alexandre SPANGARO 2021-04-12 07:37:34 +02:00
parent 2a1a22763d
commit 87cc1b2601
17 changed files with 69 additions and 45 deletions

View File

@ -1038,7 +1038,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (!empty($conf->societe->enabled) && !empty($conf->supplier_invoice->enabled)) {
$langs->load("bills");
$newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills', 0, '', '', '', img_picto('', 'supplier_invoice', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
$newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), '', $mainmenu, 'suppliers_bills_create');
$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {

View File

@ -44,9 +44,17 @@ if ($module == 'propal') {
} elseif ($module == 'fichinter') {
$permission = $user->rights->ficheinter->creer;
} elseif ($module == 'order_supplier') {
$permission = $user->rights->fournisseur->commande->creer;
} elseif ($module == 'invoice_supplier') {
$permission = $user->rights->fournisseur->facture->creer;
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permission = $user->rights->fournisseur->commande->creer;
} else {
$permission = $user->rights->supplier_order->creer;
}
} elseif ($module == 'invoice_supplier' && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permission = $user->rights->fournisseur->facture->creer;
} else {
$permission = $user->rights->supplier_invoice->creer;
}
} elseif ($module == 'project') {
$permission = $user->rights->projet->creer;
} elseif ($module == 'action') {

View File

@ -162,10 +162,18 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
$permok = !empty($user->rights->$keyforperm->creer) || !empty($user->rights->$keyforperm->create) || !empty($user->rights->$keyforperm->write);
}
if ($object->element == 'order_supplier') {
$permok = $user->rights->fournisseur->commande->creer;
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permok = $user->rights->fournisseur->commande->creer;
} else {
$permok = $user->rights->supplier_order->creer;
}
}
if ($object->element == 'invoice_supplier') {
$permok = $user->rights->fournisseur->facture->creer;
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permok = $user->rights->fournisseur->facture->creer;
} else {
$permok = $user->rights->supplier_invoice->creer;
}
}
if ($object->element == 'shipping') {
$permok = $user->rights->expedition->creer;

View File

@ -70,9 +70,17 @@ if ($module == 'propal') {
} elseif ($module == 'project_task') {
$permission = $user->rights->projet->creer;
} elseif ($module == 'invoice_supplier') {
$permission = $user->rights->fournisseur->facture->creer;
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permission = $user->rights->fournisseur->facture->creer;
} else {
$permission = $user->rights->supplier_invoice->creer;
}
} elseif ($module == 'order_supplier') {
$permission = $user->rights->fournisseur->commande->creer;
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
$permission = $user->rights->fournisseur->commande->creer;
} else {
$permission = $user->rights->supplier_order->creer;
}
} elseif ($module == 'societe') {
$permission = $user->rights->societe->creer;
} elseif ($module == 'contact') {

View File

@ -841,7 +841,7 @@ if ($object->id > 0) {
}
}
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
if (!empty($orders2invoice) && $orders2invoice > 0) {
if ($object->status == 1) {
// Company is open
@ -854,7 +854,7 @@ if ($object->id > 0) {
}
}
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
$langs->load("bills");
if ($object->status == 1) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';

View File

@ -2465,7 +2465,7 @@ if ($action == 'create') {
//if (! empty($conf->facture->enabled))
//{
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
}
}
@ -2477,7 +2477,7 @@ if ($action == 'create') {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
} else {
if (!empty($object->linkedObjectsIds['invoice_supplier'])) {
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
}
} else {

View File

@ -459,7 +459,7 @@ if (empty($reshook)) {
// Fac builddoc
$donotredirect = 1;
$upload_dir = $conf->fournisseur->facture->dir_output;
$permissiontoadd = $user->rights->fournisseur->facture->creer;
$permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
//include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
@ -880,7 +880,7 @@ if ($resql) {
'builddoc'=>$langs->trans("PDFMerge"),
'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
}
if ($user->rights->fournisseur->commande->supprimer) {

View File

@ -111,9 +111,9 @@ $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft);
// Common permissions
$usercanread = $user->rights->fournisseur->facture->lire;
$usercancreate = $user->rights->fournisseur->facture->creer;
$usercandelete = $user->rights->fournisseur->facture->supprimer;
$usercanread = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
$usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
$usercandelete = ($user->rights->fournisseur->facture->supprimer || $user->rights->supplier_invoice->supprimer);
// Advanced permissions
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)));
@ -395,7 +395,7 @@ if (empty($reshook)) {
}
if ($action == 'settransportmode' && $user->rights->fournisseur->facture->creer) {
if ($action == 'settransportmode' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
// transport mode
$result = $object->setTransportMode(GETPOST('transport_mode_id', 'int'));
} elseif ($action == 'setlabel' && $usercancreate) {
@ -2894,7 +2894,7 @@ if ($action == 'create') {
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('IntracommReportTransportMode');
print '</td>';
if ($action != 'editmode' && $user->rights->fournisseur->facture->creer) {
if ($action != 'editmode' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
}
print '</tr></table>';

View File

@ -53,7 +53,7 @@ $object = new FactureFournisseur($db);
* Ajout d'un nouveau contact
*/
if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) {
if ($action == 'addcontact' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$result = $object->fetch($id, $ref);
if ($result > 0 && $id > 0) {
@ -73,14 +73,14 @@ if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
} elseif ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) {
} elseif ($action == 'swapstatut' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
// bascule du statut d'un contact
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
} else {
dol_print_error($db);
}
} elseif ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) {
} elseif ($action == 'deletecontact' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
// Efface un contact
$object->fetch($id);
$result = $object->delete_contact(GETPOST("lineid", 'int'));

View File

@ -251,8 +251,8 @@ if ($object->id > 0) {
$modulepart = 'facture_fournisseur';
$permission = $user->rights->fournisseur->facture->creer;
$permtoedit = $user->rights->fournisseur->facture->creer;
$permission = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
$permtoedit = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
$param = '&facid='.$object->id;
$defaulttpldir = '/core/tpl';

View File

@ -274,9 +274,9 @@ if (empty($reshook)) {
// Mass actions
$objectclass = 'FactureFournisseur';
$objectlabel = 'SupplierInvoices';
$permissiontoread = $user->rights->fournisseur->facture->lire;
$permissiontoadd = $user->rights->fournisseur->facture->creer;
$permissiontodelete = $user->rights->fournisseur->facture->supprimer;
$permissiontoread = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
$permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
$permissiontodelete = ($user->rights->fournisseur->facture->supprimer || $user->rights->supplier_invoice->supprimer);
$uploaddir = $conf->fournisseur->facture->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@ -878,7 +878,7 @@ if ($resql) {
if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->rights->fournisseur->facture->creer);
$newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer));
$i = 0;
print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";

View File

@ -48,7 +48,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
$object = new FactureFournisseur($db);
$object->fetch($id, $ref);
$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
$permissionnote = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer); // Used by the include of actions_setnotes.inc.php
/*
@ -58,7 +58,7 @@ $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the inc
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
// Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) {
if ($action == 'setlabel' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$object->label = $_POST['label'];
$result = $object->update($user);
if ($result < 0) {

View File

@ -62,7 +62,7 @@ if ($socid && $socid != $object->thirdparty->id) {
* Actions
*/
if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) {
if ($action == 'setnote' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$db->begin();
$object->fetch($id);
@ -92,7 +92,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
}
if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && (!empty($user->rights->fournisseur->facture->creer) || !empty($user->rights->supplier_invoice->creer)))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
) {
$db->begin();
@ -182,9 +182,9 @@ if ($result > 0) {
print '</td></tr>';*/
// Date of payment
print '<tr><td class="titlefield">'.$form->editfieldkey("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td>';
print '<tr><td class="titlefield">'.$form->editfieldkey("Date", 'datep', $object->date, $object, $object->statut == 0 && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)).'</td>';
print '<td>';
print $form->editfieldval("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer, 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'));
print $form->editfieldval("Date", 'datep', $object->date, $object, $object->statut == 0 && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
// Payment mode
@ -241,9 +241,9 @@ if ($result > 0) {
}
// Note
print '<tr><td>'.$form->editfieldkey("Comments", 'note', $object->note, $object, $user->rights->fournisseur->facture->creer).'</td>';
print '<tr><td>'.$form->editfieldkey("Comments", 'note', $object->note, $object, ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)).'</td>';
print '<td>';
print $form->editfieldval("Note", 'note', $object->note, $object, $user->rights->fournisseur->facture->creer, 'textarea');
print $form->editfieldval("Note", 'note', $object->note, $object, ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), 'textarea');
print '</td></tr>';
print '</table>';
@ -336,7 +336,7 @@ if ($result > 0) {
print '<div class="tabsAction">';
if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
if ($user->socid == 0 && $object->statut == 0 && $action == '') {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && (!empty($user->rights->fournisseur->facture->creer) || !empty($user->rights->supplier_invoice->creer)))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=validate">'.$langs->trans('Valid').'</a>';
}
@ -363,8 +363,8 @@ if ($result > 0) {
$ref = dol_sanitizeFileName($object->ref);
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
$genallowed = $user->rights->fournisseur->facture->lire;
$delallowed = $user->rights->fournisseur->facture->creer;
$genallowed = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
$delallowed = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
$modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ? '' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
print $formfile->showdocuments('supplier_payment', $ref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang);

View File

@ -1274,7 +1274,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
$langs->load("suppliers");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierOrder").'</a>';
}
if (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer) {
if (!empty($conf->supplier_invoice->enabled) && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$langs->load("suppliers");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierInvoice").'</a>';
}

View File

@ -437,8 +437,8 @@ $listofreferent = array(
'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id, // No socid parameter here, the socid is often the customer and we create a supplier object
'lang'=>'suppliers',
'buttonnew'=>'AddSupplierInvoice',
'testnew'=>$user->rights->fournisseur->facture->creer,
'test'=>$conf->supplier_invoice->enabled && $user->rights->fournisseur->facture->lire),
'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer),
'test'=>$conf->supplier_invoice->enabled && ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire),
'contract'=>array(
'name'=>"Contracts",
'title'=>"ListContractAssociatedProject",

View File

@ -1983,7 +1983,7 @@ if ($action == 'create') {
// Create bill
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) {
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
// TODO show button only if (! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))
// If we do that, we must also make this option official.
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';

View File

@ -384,7 +384,7 @@ if (empty($reshook)) {
// Fac builddoc
$donotredirect = 1;
$upload_dir = $conf->fournisseur->facture->dir_output;
$permissiontoadd = $user->rights->fournisseur->facture->creer;
$permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
@ -596,7 +596,7 @@ $arrayofmassactions = array(
// 'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->fournisseur->facture->creer) {
if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
$arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisSupplier");
}
if ($massaction == 'createbills') {