NEW: expense reports: make project field required on lines
This commit is contained in:
parent
3d4bb66853
commit
0dae918b76
@ -145,7 +145,14 @@ if ($action == 'updateMask') {
|
||||
$draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha');
|
||||
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if (!$res1 > 0 || !$res2 > 0) {
|
||||
if ($conf->projet->enabled) {
|
||||
$projects = GETPOST('EXPENSEREPORT_PROJECT_IS_REQUIRED', 'int');
|
||||
$res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', intval($projects), 'chaine', 0, '', $conf->entity);
|
||||
} else {
|
||||
$res3 = dolibarr_del_const($this->db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', $conf->entity);
|
||||
}
|
||||
|
||||
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -458,6 +465,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 ($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 '</table>';
|
||||
|
||||
print $form->buttonsSaveCancel("Save", '');
|
||||
|
||||
@ -330,6 +330,10 @@ class modProjet extends DolibarrModules
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if (dolibarr_del_const($this->db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', $conf->entity) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Permissions
|
||||
$this->remove($options);
|
||||
|
||||
|
||||
@ -106,6 +106,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;
|
||||
@ -1132,6 +1134,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
|
||||
|
||||
@ -1265,6 +1273,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);
|
||||
@ -2075,7 +2089,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>';
|
||||
|
||||
@ -2252,7 +2266,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>';
|
||||
}
|
||||
|
||||
@ -2426,11 +2440,11 @@ if ($action == 'create') {
|
||||
print '</td>';
|
||||
|
||||
// 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');
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
print '<td>';
|
||||
$formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Select type
|
||||
print '<td class="center">';
|
||||
|
||||
@ -517,6 +517,7 @@ Field=Field
|
||||
ProductDocumentTemplates=Document templates to generate product document
|
||||
FreeLegalTextOnExpenseReports=Free legal text on expense reports
|
||||
WatermarkOnDraftExpenseReports=Watermark on draft expense reports
|
||||
ProjectIsRequiredOnExpenseReports=Require selecting a project on expense reports
|
||||
AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable)
|
||||
FilesAttachedToEmail=Attach file
|
||||
SendEmailsReminders=Send agenda reminders by emails
|
||||
|
||||
Loading…
Reference in New Issue
Block a user