diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 0fbb2764ae6..49478ffdc2b 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -754,30 +754,33 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements } else { if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { if (is_array($object->lines)) { + dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + // Specify as export : update field date_export or date_validated $db->begin(); + // TODO Merge update for each line into one gloacl using rowid IN (list of movement ids) foreach ($object->lines as $movement) { $now = dol_now(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET"; - if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - $sql .= ", date_validated = '".$db->idate($now)."'"; - } elseif (!empty($notifiedexportdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - } elseif (!empty($notifiedvalidationdate)) { - $sql .= " date_validated = '".$db->idate($now)."'"; + $setfields = ''; + if (!empty($notifiedexportdate) && empty($movement->date_export)) { + $setfields .= ($setfields ? "," : "")." date_export = '".$db->idate($now)."'"; + } + if (!empty($notifiedvalidationdate) && empty($movement->date_validation)) { + $setfields .= ($setfields ? "," : "")." date_validated = '".$db->idate($now)."'"; } - $sql .= " WHERE rowid = ".((int) $movement->id); - dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + if ($setfields) { + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET ".$setfields; + $sql .= " WHERE rowid = ".((int) $movement->id); - $result = $db->query($sql); - if (!$result) { - $error++; - break; + $result = $db->query($sql); + if (!$result) { + $error++; + break; + } } } @@ -1014,17 +1017,17 @@ $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; if (empty($reshook)) { // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton .= ''.img_picto($langs->trans("ClickToHideAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"'); + $newcardbutton .= ''.img_picto($langs->trans("ClickToHideAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"'); $newcardbutton .= ''.$langs->trans("ClickToHideAlreadyExportedLines").''; $newcardbutton .= ''; } else { - $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"'); + $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"'); $newcardbutton .= ''.$langs->trans("DocsAlreadyExportedAreExcluded").''; $newcardbutton .= ''; } if ($user->hasRight('accounting', 'mouvements', 'export')) { - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->hasRight('accounting', 'mouvements', 'export')); + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : '').'&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder), $user->hasRight('accounting', 'mouvements', 'export')); } $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); @@ -1522,7 +1525,7 @@ while ($i < min($num, $limit)) { // Creation operation date if (!empty($arrayfields['t.date_creation']['checked'])) { - print ''.dol_print_date($line->date_creation, 'dayhour').''; + print ''.dol_print_date($line->date_creation, 'dayhour', 'tzuserrel').''; if (!$i) { $totalarray['nbfield']++; } @@ -1530,7 +1533,7 @@ while ($i < min($num, $limit)) { // Modification operation date if (!empty($arrayfields['t.tms']['checked'])) { - print ''.dol_print_date($line->date_modification, 'dayhour').''; + print ''.dol_print_date($line->date_modification, 'dayhour', 'tzuserrel').''; if (!$i) { $totalarray['nbfield']++; } @@ -1538,7 +1541,7 @@ while ($i < min($num, $limit)) { // Exported operation date if (!empty($arrayfields['t.date_export']['checked'])) { - print ''.dol_print_date($line->date_export, 'dayhour').''; + print ''.dol_print_date($line->date_export, 'dayhour', 'tzuserrel').''; if (!$i) { $totalarray['nbfield']++; } @@ -1546,7 +1549,7 @@ while ($i < min($num, $limit)) { // Validated operation date if (!empty($arrayfields['t.date_validated']['checked'])) { - print ''.dol_print_date($line->date_validation, 'dayhour').''; + print ''.dol_print_date($line->date_validation, 'dayhour', 'tzuserrel').''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 2c72878d40e..f189c96939d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -349,8 +349,8 @@ ACCOUNTING_ENABLE_AUTOLETTERING=Enable the automatic lettering when transferring ## Export NotExportLettering=Do not export the lettering when generating the file -NotifiedExportDate=Flag exported lines as Exported (to modify a line, you will need to delete the whole transaction and re-transfert it into accounting) -NotifiedValidationDate=Validate and Lock the exported entries (same effect than the "%s" feature, modification and deletion of the lines will DEFINITELY not be possible) +NotifiedExportDate=Flag not yet exported lines as Exported (to modify a line flagged as exported, you will need to delete the whole transaction and re-transfert it into accounting) +NotifiedValidationDate=Validate and Lock the exported entries not yet already locked (same effect than the "%s" feature, modification and deletion of the lines will DEFINITELY not be possible) NotifiedExportFull=Export documents ? DateValidationAndLock=Date validation and lock ConfirmExportFile=Confirmation of the generation of the accounting export file ?