Merge pull request #13676 from TobiasSekan/CleanupUserRightsForunFactureCard
Cleanup user rights on forun facture card
This commit is contained in:
commit
c7eb71e19e
@ -99,12 +99,20 @@ if (!empty($user->socid)) $socid = $user->socid;
|
|||||||
$isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
|
$isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
|
||||||
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft);
|
$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;
|
$usercancreate = $user->rights->fournisseur->facture->creer;
|
||||||
|
$usercandelete = $user->rights->fournisseur->facture->supprimer;
|
||||||
|
|
||||||
$permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
|
// Advanced permissions
|
||||||
$permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php
|
$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)));
|
||||||
$permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php
|
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send);
|
||||||
$permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
|
||||||
|
// 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
|
||||||
|
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -159,11 +167,7 @@ if (empty($reshook))
|
|||||||
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
|
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
} elseif ($action == 'confirm_valid' && $confirm == 'yes' &&
|
} elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) {
|
||||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
|
|
||||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$idwarehouse = GETPOST('idwarehouse');
|
$idwarehouse = GETPOST('idwarehouse');
|
||||||
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
@ -222,8 +226,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$isErasable = $object->is_erasable();
|
$isErasable = $object->is_erasable();
|
||||||
|
|
||||||
if (($user->rights->fournisseur->facture->supprimer && $isErasable > 0)
|
if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1))
|
||||||
|| ($user->rights->fournisseur->facture->creer && $isErasable == 1))
|
|
||||||
{
|
{
|
||||||
$result = $object->delete($user);
|
$result = $object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -237,7 +240,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove a product line
|
// Remove a product line
|
||||||
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
|
||||||
{
|
{
|
||||||
$result = $object->deleteline($lineid);
|
$result = $object->deleteline($lineid);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@ -268,13 +271,12 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete link of credit note to invoice
|
// Delete link of credit note to invoice
|
||||||
elseif ($action == 'unlinkdiscount' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'unlinkdiscount' && $usercancreate)
|
||||||
{
|
{
|
||||||
$discount = new DiscountAbsolute($db);
|
$discount = new DiscountAbsolute($db);
|
||||||
$result = $discount->fetch(GETPOST("discountid"));
|
$result = $discount->fetch(GETPOST("discountid"));
|
||||||
$discount->unlink_invoice();
|
$discount->unlink_invoice();
|
||||||
} elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
} elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercancreate) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$result = $object->set_paid($user);
|
$result = $object->set_paid($user);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@ -284,7 +286,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set supplier ref
|
// Set supplier ref
|
||||||
if ($action == 'setref_supplier' && $user->rights->fournisseur->facture->creer)
|
if ($action == 'setref_supplier' && $usercancreate)
|
||||||
{
|
{
|
||||||
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
|
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
|
||||||
|
|
||||||
@ -312,7 +314,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// payments conditions
|
// payments conditions
|
||||||
if ($action == 'setconditions' && $user->rights->fournisseur->facture->creer)
|
if ($action == 'setconditions' && $usercancreate)
|
||||||
{
|
{
|
||||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||||
}
|
}
|
||||||
@ -324,35 +326,34 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// payment mode
|
// payment mode
|
||||||
elseif ($action == 'setmode' && $user->rights->fournisseur->facture->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->fournisseur->facture->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->fournisseur->facture->creer) {
|
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
|
||||||
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha')));
|
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// bank account
|
// bank account
|
||||||
elseif ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) {
|
elseif ($action == 'setbankaccount' && $usercancreate) {
|
||||||
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
|
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set label
|
// Set label
|
||||||
elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'setlabel' && $usercancreate)
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->label = GETPOST('label');
|
$object->label = GETPOST('label');
|
||||||
$result = $object->update($user);
|
$result = $object->update($user);
|
||||||
if ($result < 0) dol_print_error($db);
|
if ($result < 0) dol_print_error($db);
|
||||||
} elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer)
|
} elseif ($action == 'setdatef' && $usercancreate) {
|
||||||
{
|
|
||||||
$newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']);
|
$newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']);
|
||||||
if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)))
|
if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)))
|
||||||
{
|
{
|
||||||
@ -375,8 +376,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$result = $object->update($user);
|
$result = $object->update($user);
|
||||||
if ($result < 0) dol_print_error($db, $object->error);
|
if ($result < 0) dol_print_error($db, $object->error);
|
||||||
} elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->facture->creer)
|
} elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']);
|
$object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']);
|
||||||
if (!empty($object->date_echeance) && $object->date_echeance < $object->date)
|
if (!empty($object->date_echeance) && $object->date_echeance < $object->date)
|
||||||
@ -591,7 +591,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
|
|
||||||
// Delete payment
|
// Delete payment
|
||||||
elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate)
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0)
|
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0)
|
||||||
@ -1033,7 +1033,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Edit line
|
// Edit line
|
||||||
elseif ($action == 'updateline' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'updateline' && $usercancreate)
|
||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
@ -1122,8 +1122,7 @@ if (empty($reshook))
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
|
} elseif ($action == 'addline' && $usercancreate) {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$ret = $object->fetch($id);
|
$ret = $object->fetch($id);
|
||||||
@ -1411,15 +1410,14 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$action = '';
|
$action = '';
|
||||||
} elseif ($action == 'classin' && $user->rights->fournisseur->facture->creer)
|
} elseif ($action == 'classin' && $usercancreate) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$result = $object->setProject($projectid);
|
$result = $object->setProject($projectid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set invoice to draft status
|
// Set invoice to draft status
|
||||||
elseif ($action == 'confirm_edit' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'confirm_edit' && $confirm == 'yes' && $usercancreate)
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
@ -1484,7 +1482,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set invoice to validated/unpaid status
|
// Set invoice to validated/unpaid status
|
||||||
elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'reopen' && $usercancreate)
|
||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($object->statut == FactureFournisseur::STATUS_CLOSED
|
if ($object->statut == FactureFournisseur::STATUS_CLOSED
|
||||||
@ -1513,7 +1511,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Actions to build doc
|
// Actions to build doc
|
||||||
$upload_dir = $conf->fournisseur->facture->dir_output;
|
$upload_dir = $conf->fournisseur->facture->dir_output;
|
||||||
$permissiontoadd = $user->rights->fournisseur->facture->creer;
|
$permissiontoadd = $usercancreate;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||||
|
|
||||||
// Make calculation according to calculationrule
|
// Make calculation according to calculationrule
|
||||||
@ -1555,7 +1553,7 @@ if (empty($reshook))
|
|||||||
$action = 'edit_extras';
|
$action = 'edit_extras';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer)
|
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate)
|
||||||
{
|
{
|
||||||
if ($action == 'addcontact')
|
if ($action == 'addcontact')
|
||||||
{
|
{
|
||||||
@ -2372,8 +2370,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->facture->creer, 'string', '', 0, 1);
|
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1);
|
||||||
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1);
|
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
|
||||||
// Thirdparty
|
// Thirdparty
|
||||||
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
|
$morehtmlref .= '<br>'.$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.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
|
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
|
||||||
@ -2382,7 +2380,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||||
if ($user->rights->fournisseur->facture->creer)
|
if ($usercancreate)
|
||||||
{
|
{
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||||
@ -2482,11 +2480,11 @@ if ($action == 'create')
|
|||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, ($user->rights->fournisseur->facture->creer)).'</td>';
|
print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, ($usercancreate)).'</td>';
|
||||||
print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, ($user->rights->fournisseur->facture->creer)).'</td>';
|
print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, ($usercancreate)).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$form_permission = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $user->rights->fournisseur->facture->creer && ($object->getSommePaiement() <= 0);
|
$form_permission = ($object->statut < FactureFournisseur::STATUS_CLOSED) && $usercancreate && ($object->getSommePaiement() <= 0);
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
print '<tr><td>'.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').'</td><td colspan="3">';
|
||||||
@ -2507,7 +2505,7 @@ if ($action == 'create')
|
|||||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
print $langs->trans('PaymentConditions');
|
print $langs->trans('PaymentConditions');
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($action != 'editconditions' && $user->rights->fournisseur->facture->creer) {
|
if ($action != 'editconditions' && $usercancreate) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
@ -2527,7 +2525,7 @@ if ($action == 'create')
|
|||||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
print $langs->trans('PaymentMode');
|
print $langs->trans('PaymentMode');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($action != 'editmode' && $user->rights->fournisseur->facture->creer) {
|
if ($action != 'editmode' && $usercancreate) {
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
|
||||||
}
|
}
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
@ -2594,7 +2592,7 @@ if ($action == 'create')
|
|||||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
print $langs->trans('BankAccount');
|
print $langs->trans('BankAccount');
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if ($action != 'editbankaccount' && $user->rights->fournisseur->facture->creer)
|
if ($action != 'editbankaccount' && $usercancreate)
|
||||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
|
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&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">';
|
||||||
@ -2613,7 +2611,7 @@ if ($action == 'create')
|
|||||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||||
print $langs->trans('IncotermLabel');
|
print $langs->trans('IncotermLabel');
|
||||||
print '<td><td class="right">';
|
print '<td><td class="right">';
|
||||||
if ($user->rights->fournisseur->facture->creer) print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
if ($usercancreate) print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
|
||||||
else print ' ';
|
else print ' ';
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -2996,7 +2994,7 @@ if ($action == 'create')
|
|||||||
$num = count($object->lines);
|
$num = count($object->lines);
|
||||||
|
|
||||||
// Form to add new line
|
// Form to add new line
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $user->rights->fournisseur->facture->creer)
|
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $usercancreate)
|
||||||
{
|
{
|
||||||
if ($action != 'editline')
|
if ($action != 'editline')
|
||||||
{
|
{
|
||||||
@ -3029,7 +3027,7 @@ if ($action == 'create')
|
|||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
// Modify a validated invoice with no payments
|
// Modify a validated invoice with no payments
|
||||||
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
|
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $usercancreate)
|
||||||
{
|
{
|
||||||
// We check if lines of invoice are not already transfered into accountancy
|
// We check if lines of invoice are not already transfered into accountancy
|
||||||
$ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection.
|
$ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection.
|
||||||
@ -3050,11 +3048,11 @@ if ($action == 'create')
|
|||||||
|| ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)))
|
|| ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)))
|
||||||
&& ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely)
|
&& ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely)
|
||||||
{
|
{
|
||||||
if (!$facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice
|
if (!$facidnext && $object->close_code != 'replaced' && $usercancreate) // Not replaced by another invoice
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans('ReOpen').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans('ReOpen').'</a></div>';
|
||||||
} else {
|
} else {
|
||||||
if ($user->rights->fournisseur->facture->creer) {
|
if ($usercancreate) {
|
||||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('ReOpen').'</span></div>';
|
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('ReOpen').'</span></div>';
|
||||||
} elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
|
} elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
|
||||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans('ReOpen').'</span></div>';
|
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans('ReOpen').'</span></div>';
|
||||||
@ -3066,7 +3064,7 @@ if ($action == 'create')
|
|||||||
if (empty($user->socid)) {
|
if (empty($user->socid)) {
|
||||||
if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED))
|
if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED))
|
||||||
{
|
{
|
||||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send)
|
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"><span class="butActionRefused classfortooltip">'.$langs->trans('SendMail').'</a></div>';
|
} else print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans('SendMail').'</a></div>';
|
||||||
@ -3102,18 +3100,18 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For standard invoice with excess paid
|
// For standard invoice with excess paid
|
||||||
if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $user->rights->fournisseur->facture->creer && empty($discount->id))
|
if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id))
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertExcessPaidToReduc').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertExcessPaidToReduc').'</a></div>';
|
||||||
}
|
}
|
||||||
// For credit note
|
// For credit note
|
||||||
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer
|
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate
|
||||||
&& (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
|
&& (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
|
||||||
) {
|
) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReducSupplier2")).'">'.$langs->trans('ConvertToReduc').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReducSupplier2")).'">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||||
}
|
}
|
||||||
// For deposit invoice
|
// For deposit invoice
|
||||||
if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->fournisseur->facture->creer && empty($discount->id))
|
if ($object->type == FactureFournisseur::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $usercancreate && empty($discount->id))
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||||
}
|
}
|
||||||
@ -3124,8 +3122,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
if (count($object->lines))
|
if (count($object->lines))
|
||||||
{
|
{
|
||||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
|
if ($usercanvalidate)
|
||||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
|
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid"';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid"';
|
||||||
print '>'.$langs->trans('Validate').'</a></div>';
|
print '>'.$langs->trans('Validate').'</a></div>';
|
||||||
@ -3143,13 +3140,13 @@ if ($action == 'create')
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
if ($action != 'edit' && $user->rights->fournisseur->facture->creer)
|
if ($action != 'edit' && $usercancreate)
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=clone&socid='.$object->socid.'">'.$langs->trans('ToClone').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=clone&socid='.$object->socid.'">'.$langs->trans('ToClone').'</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a credit note
|
// Create a credit note
|
||||||
if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $user->rights->fournisseur->facture->creer)
|
if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_DEPOSIT) && $object->statut > 0 && $usercancreate)
|
||||||
{
|
{
|
||||||
if (!$objectidnext)
|
if (!$objectidnext)
|
||||||
{
|
{
|
||||||
@ -3159,7 +3156,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
$isErasable = $object->is_erasable();
|
$isErasable = $object->is_erasable();
|
||||||
if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($user->rights->fournisseur->facture->creer && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
||||||
{
|
{
|
||||||
//var_dump($isErasable);
|
//var_dump($isErasable);
|
||||||
if ($isErasable == -4) {
|
if ($isErasable == -4) {
|
||||||
@ -3190,8 +3187,8 @@ if ($action == 'create')
|
|||||||
$subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref;
|
$subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref;
|
||||||
$filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
|
$filedir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
|
||||||
$urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
|
$urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
|
||||||
$genallowed = $user->rights->fournisseur->facture->lire;
|
$genallowed = $usercanread;
|
||||||
$delallowed = $user->rights->fournisseur->facture->creer;
|
$delallowed = $usercancreate;
|
||||||
$modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF));
|
$modelpdf = (!empty($object->modelpdf) ? $object->modelpdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ? '' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF));
|
||||||
|
|
||||||
print $formfile->showdocuments('facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang);
|
print $formfile->showdocuments('facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0, '', '', '', $societe->default_lang);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user