diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8da9b2c92dc..5ae4f00c66e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -122,7 +122,6 @@ $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancr $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); -$usercanmodify = $usercancreate && ($object->statut == Facture::STATUS_DRAFT || ($object->statut == Facture::STATUS_VALIDATED && !empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercancreatemargin = $user->rights->margins->creer; @@ -346,13 +345,13 @@ if (empty($reshook)) } } - elseif ($action == 'classin' && $usercanmodify) + elseif ($action == 'classin' && $usercancreate) { $object->fetch($id); $object->setProject($_POST['projectid']); } - elseif ($action == 'setmode' && $usercanmodify) + elseif ($action == 'setmode' && $usercancreate) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); @@ -360,7 +359,7 @@ if (empty($reshook)) dol_print_error($db, $object->error); } - elseif ($action == 'setretainedwarrantyconditions' && $usercanmodify) + elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { $object->fetch($id); $object->retained_warranty_fk_cond_reglement = 0; // To clean property @@ -375,7 +374,7 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } - elseif ($action == 'setretainedwarranty' && $usercanmodify) + elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); @@ -383,7 +382,7 @@ if (empty($reshook)) dol_print_error($db, $object->error); } - elseif ($action == 'setretainedwarrantydatelimit' && $usercanmodify) + elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); @@ -393,16 +392,16 @@ if (empty($reshook)) // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercanmodify) { + elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercanmodify) { + elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } - elseif ($action == 'setinvoicedate' && $usercanmodify) + elseif ($action == 'setinvoicedate' && $usercancreate) { $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; @@ -423,7 +422,7 @@ if (empty($reshook)) } } - elseif ($action == 'setdate_pointoftax' && $usercanmodify) + elseif ($action == 'setdate_pointoftax' && $usercancreate) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -434,7 +433,7 @@ if (empty($reshook)) } } - elseif ($action == 'setconditions' && $usercanmodify) + elseif ($action == 'setconditions' && $usercancreate) { $object->fetch($id); $object->cond_reglement_code = 0; // To clean property @@ -471,7 +470,7 @@ if (empty($reshook)) } } - elseif ($action == 'setpaymentterm' && $usercanmodify) + elseif ($action == 'setpaymentterm' && $usercancreate) { $object->fetch($id); $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); @@ -485,7 +484,7 @@ if (empty($reshook)) } } - elseif ($action == 'setrevenuestamp' && $usercanmodify) + elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); $object->revenuestamp = GETPOST('revenuestamp'); @@ -516,24 +515,24 @@ if (empty($reshook)) } // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercanmodify) + elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // bank account - elseif ($action == 'setbankaccount' && $usercanmodify) + elseif ($action == 'setbankaccount' && $usercancreate) { $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } - elseif ($action == 'setremisepercent' && $usercanmodify) + elseif ($action == 'setremisepercent' && $usercancreate) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); } - elseif ($action == "setabsolutediscount" && $usercanmodify) + elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] @@ -591,13 +590,13 @@ if (empty($reshook)) } } - elseif ($action == 'setref' && $usercanmodify) + elseif ($action == 'setref' && $usercancreate) { $object->fetch($id); $object->setValueFrom('ref', GETPOST('ref'), '', null, '', '', $user, 'BILL_MODIFY'); } - elseif ($action == 'setref_client' && $usercanmodify) + elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); $object->set_ref_client(GETPOST('ref_client')); @@ -1972,7 +1971,7 @@ if (empty($reshook)) } // Add a new line - elseif ($action == 'addline' && $usercanmodify) + elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); $error = 0; @@ -2301,7 +2300,7 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercanmodify && !GETPOST('cancel', 'alpha')) + elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); @@ -2511,7 +2510,7 @@ if (empty($reshook)) } } - elseif ($action == 'updatealllines' && $usercanmodify && $_POST['all_percent'] == $langs->trans('Modifier')) // Update all lines of situation invoice + elseif ($action == 'updatealllines' && $usercancreate && $_POST['all_percent'] == $langs->trans('Modifier')) // Update all lines of situation invoice { if (!$object->fetch($id) > 0) dol_print_error($db); if (GETPOST('all_progress') != "") @@ -2530,7 +2529,7 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercanmodify && $_POST['cancel'] == $langs->trans('Cancel')) { + elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page exit(); } @@ -2756,7 +2755,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - if ($action == 'update_extras' && $usercanmodify) { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from add form @@ -3765,9 +3764,6 @@ elseif ($id > 0 || !empty($ref)) exit; } - // Reassign, case when status is reset to draft - $usercanmodify = $usercancreate && ($object->statut == Facture::STATUS_DRAFT || ($object->statut == Facture::STATUS_VALIDATED && !empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED))); - /* * Show object in view mode */ @@ -4135,13 +4131,13 @@ elseif ($id > 0 || !empty($ref)) $morehtmlref = '
'; // Ref invoice if ($object->status == $object::STATUS_DRAFT && !$mysoc->isInEEC() && !empty($conf->global->INVOICE_ALLOW_FREE_REF)) { - $morehtmlref .= $form->editfieldkey("Ref", 'ref', $object->ref, $object, $usercanmodify, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("Ref", 'ref', $object->ref, $object, $usercanmodify, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', null, null, '', 1); $morehtmlref .= '
'; } // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercanmodify, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercanmodify, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherBills").')'; @@ -4150,7 +4146,7 @@ elseif ($id > 0 || !empty($ref)) { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($usercanmodify) + if ($usercancreate) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; @@ -4266,7 +4262,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $usercanmodify && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) print ''; print '
'; print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print ''; @@ -4291,7 +4287,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($usercanmodify) print ''; + print ''; print '
'; print $langs->trans('DatePointOfTax'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print ''; if ($action == 'editdate_pointoftax') { @@ -4307,7 +4303,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercanmodify) + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print ''; @@ -4328,7 +4324,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercanmodify) + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) print ''; print '
'; print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print ''; @@ -4352,7 +4348,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($action != 'editmode' && $usercanmodify) + if ($action != 'editmode' && $usercancreate) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; @@ -4375,7 +4371,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($usercanmodify && $action != 'editmulticurrencycode' && !empty($object->brouillon)) + if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) print ''; print '
'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print ''; @@ -4391,7 +4387,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($usercanmodify && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) print ''; print '
'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print ''; @@ -4399,7 +4395,7 @@ elseif ($id > 0 || !empty($ref)) if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercanmodify ? 'multicurrency_tx' : 'none'), $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { @@ -4417,7 +4413,7 @@ elseif ($id > 0 || !empty($ref)) print ''; print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $usercanmodify) + if (($action != 'editbankaccount') && $usercancreate) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print ''; @@ -4439,7 +4435,7 @@ elseif ($id > 0 || !empty($ref)) print '
'; print $langs->trans('IncotermLabel'); print ''; - if ($usercanmodify) print ''.img_edit().''; + if ($usercancreate) print ''.img_edit().''; else print ' '; print '
'; print ''; @@ -4469,7 +4465,7 @@ elseif ($id > 0 || !empty($ref)) print ''; - if ($action != 'editretainedwarranty' && $usercanmodify) { + if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { print ''; } @@ -4495,7 +4491,7 @@ elseif ($id > 0 || !empty($ref)) print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - if ($action != 'editretainedwarrantypaymentterms' && $usercanmodify) { + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { print ''; } @@ -4533,7 +4529,7 @@ elseif ($id > 0 || !empty($ref)) print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $usercanmodify) { + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { print ''; } @@ -4620,7 +4616,7 @@ elseif ($id > 0 || !empty($ref)) print '
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
'; - if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $usercanmodify) + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $usercancreate) { print ''; }
'; print $langs->trans('RevenueStamp'); print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'