Merge pull request #18863 from marc-dll/NEW_expense_report_project_required
NEW: expense reports: make project field required on lines
This commit is contained in:
commit
55652103fd
@ -145,13 +145,18 @@ if ($action == 'updateMask') {
|
||||
$draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha');
|
||||
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
$res3 = 0;
|
||||
if (!empty($conf->projet->enabled) && GETPOSTISSET('EXPENSEREPORT_PROJECT_IS_REQUIRED')) { // Option may not be provided
|
||||
$res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', GETPOST('EXPENSEREPORT_PROJECT_IS_REQUIRED', 'int'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
|
||||
$dates = GETPOST('EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', 'int');
|
||||
$res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates), 'chaine', 0, '', $conf->entity);
|
||||
$res4 = dolibarr_set_const($db, 'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
$amounts = GETPOST('EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', 'int');
|
||||
$res4 = dolibarr_set_const($db, 'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts), 'chaine', 0, '', $conf->entity);
|
||||
$res5 = dolibarr_set_const($db, 'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0) || !($res4 >0)) {
|
||||
if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0) || !($res4 >0) || !($res5 >0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -464,6 +469,14 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htm
|
||||
print '<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.$conf->global->EXPENSEREPORT_DRAFT_WATERMARK.'">';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans('ProjectIsRequiredOnExpenseReports');
|
||||
print '</td><td class="right">';
|
||||
print $form->selectyesno('EXPENSEREPORT_PROJECT_IS_REQUIRED', empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED) ? 0 : 1, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans('PrefillExpenseReportDatesWithCurrentMonth');
|
||||
print '</td><td class="right">';
|
||||
|
||||
@ -117,6 +117,8 @@ $permissiontoadd = $user->rights->expensereport->creer; // Used by the include o
|
||||
|
||||
$upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
$projectRequired = $conf->projet->enabled && ! empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED);
|
||||
|
||||
if ($object->id > 0) {
|
||||
// Check current user can read this expense report
|
||||
$canread = 0;
|
||||
@ -1147,6 +1149,12 @@ if (empty($reshook)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors');
|
||||
}
|
||||
|
||||
// If no project entered
|
||||
if ($projectRequired && $fk_project <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees
|
||||
|
||||
@ -1280,6 +1288,12 @@ if (empty($reshook)) {
|
||||
setEventMessages($langs->trans("WarningDateOfLineMustBeInExpenseReportRange"), null, 'warnings');
|
||||
}
|
||||
|
||||
// If no project entered
|
||||
if ($projectRequired && $projet_id <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// TODO Use update method of ExpenseReportLine
|
||||
$result = $object->updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $id, $fk_c_exp_tax_cat, $fk_ecm_files);
|
||||
@ -2092,7 +2106,7 @@ if ($action == 'create') {
|
||||
} else {
|
||||
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $line->vatrate));
|
||||
$pricenettoshow = price2num($line->value_unit / (1 + $tmpvat / 100), 'MU');
|
||||
print $pricenettoshow;
|
||||
print price($pricenettoshow);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -2269,7 +2283,7 @@ if ($action == 'create') {
|
||||
// Select project
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print '<td>';
|
||||
$formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||
$formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -2445,7 +2459,7 @@ if ($action == 'create') {
|
||||
// Select project
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print '<td>';
|
||||
$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||
$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
@ -516,6 +516,7 @@ Field=Field
|
||||
ProductDocumentTemplates=Document templates to generate product document
|
||||
FreeLegalTextOnExpenseReports=Free legal text on expense reports
|
||||
WatermarkOnDraftExpenseReports=Watermark on draft expense reports
|
||||
ProjectIsRequiredOnExpenseReports=The project is mandatory for entering an expense report
|
||||
PrefillExpenseReportDatesWithCurrentMonth=Pre-fill start and end dates of new expense report with start and end dates of the current month
|
||||
ForceExpenseReportsLineAmountsIncludingTaxesOnly=Force the entry of expense report amounts always in amount with taxes
|
||||
AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user