diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 7df29416878..ac9811c687c 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -146,6 +146,7 @@ $arrayfields=array(
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
+ 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>0),
);
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
@@ -181,6 +182,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_date_creation_end = '';
$search_date_modification_start = '';
$search_date_modification_end = '';
+ $search_date_export_start = '';
+ $search_date_export_end = '';
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
@@ -272,6 +275,16 @@ if (! empty($search_date_modification_end)) {
$tmp=dol_getdate($search_date_modification_end);
$param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year'];
}
+if (! empty($search_date_export_start)) {
+ $filter['t.date_export>='] = $search_date_export_start;
+ $tmp=dol_getdate($search_date_export_start);
+ $param .= '&date_export_startmonth=' . $tmp['mon'] . '&date_export_startday=' . $tmp['mday'] . '&date_export_startyear=' . $tmp['year'];
+}
+if (! empty($search_date_export_end)) {
+ $filter['t.date_export<='] = $search_date_export_end;
+ $tmp=dol_getdate($search_date_export_end);
+ $param .= '&date_export_endmonth=' . $tmp['mon'] . '&date_export_endday=' . $tmp['mday'] . '&date_export_endyear=' . $tmp['year'];
+}
if (! empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . urlencode($search_debit);
@@ -351,8 +364,9 @@ if ($action == 'delmouvconfirm') {
// Export into a file with format defined into setup (FEC, CSV, ...)
if ($action == 'export_file') {
+ $reexportMovements = GETPOST('already_exported')=='on'?1:0;
- $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
+ $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $reexportMovements);
if ($result < 0)
{
@@ -363,6 +377,22 @@ if ($action == 'export_file') {
$accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines);
+ // TODO Move in class bookKeeping
+ // Specify as export : update field date_export
+ foreach ( $object->lines as $movement ) {
+ $now = dol_now();
+ $sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
+ $sql .= " SET date_export = '" . $db->idate($now) . "'";
+ $sql .= " WHERE rowid = " . $movement->id;
+
+ dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG);
+ if ($db->query($sql)) {
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
+ }
+
if (!empty($accountancyexport->errors))
{
setEventMessages('', $accountancyexport->errors, 'errors');
@@ -446,10 +476,10 @@ print '';
print '';
$listofformat=AccountancyExport::getType();
-$button = '';
+$button = ' ' . $langs->trans("IncludeDocsAlreadyExported");
+$button .= 'global->ACCOUNTING_EXPORT_MODELCSV].')'.'" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
if (count($filter)) $button.= $langs->trans("ExportFilteredList");
else $button.= $langs->trans("ExportList");
-//$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')';
$button.= '';
@@ -600,6 +630,20 @@ if (! empty($arrayfields['t.tms']['checked']))
print '';
print '';
}
+// Date export
+if (! empty($arrayfields['t.date_export']['checked']))
+{
+ print '
';
+ print ' ';
+ print $langs->trans('From') . ' ';
+ print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
+ print ' ';
+ print '';
+ print $langs->trans('to') . ' ';
+ print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
+ print ' ';
+ print ' | ';
+}
// Action column
print '';
$searchpicto=$form->showFilterButtons();
@@ -620,6 +664,7 @@ if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_tit
if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
+if (! empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "\n";
@@ -732,11 +777,20 @@ if ($num > 0)
if (! $i) $totalarray['nbfield']++;
}
+ // Exported operation date
+ if (! empty($arrayfields['t.date_export']['checked']))
+ {
+ print ' | ' . dol_print_date($line->date_export, 'dayhour') . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
// Action column
print '';
- print '' . img_edit() . ' ';
- print '' . img_delete() . '';
- print ' | ';
+ if(empty($line->date_export)) {
+ print '' . img_edit() . ' ';
+ print '' . img_delete() . '';
+ }
+ print '';
if (! $i) $totalarray['nbfield']++;
print "\n";
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index c1df8b1045c..872bd56ca0f 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -866,15 +866,16 @@ class BookKeeping extends CommonObject
/**
* Load object in memory from the database
*
- * @param string $sortorder Sort Order
- * @param string $sortfield Sort field
- * @param int $limit Offset limit
- * @param int $offset Offset limit
- * @param array $filter Filter array
- * @param string $filtermode Filter mode (AND or OR)
- * @return int <0 if KO, >0 if OK
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit Offset limit
+ * @param int $offset Offset limit
+ * @param array $filter Filter array
+ * @param string $filtermode Filter mode (AND or OR)
+ * @param int $showAlreadyExportMovements Show movements when field 'date_export' is not empty (0:No / 1:Yes (Default))
+ * @return int <0 if KO, >0 if OK
*/
- public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $showAlreadyExportMovements = 1)
{
global $conf;
@@ -904,7 +905,8 @@ class BookKeeping extends CommonObject
$sql .= " t.journal_label,";
$sql .= " t.piece_num,";
$sql .= " t.date_creation,";
- $sql .= " t.tms as date_modification";
+ $sql .= " t.tms as date_modification,";
+ $sql .= " t.date_export";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
$sqlwhere = array ();
@@ -924,6 +926,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
+ } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
+ $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} else {
@@ -978,6 +982,7 @@ class BookKeeping extends CommonObject
$line->piece_num = $obj->piece_num;
$line->date_creation = $this->db->jdate($obj->date_creation);
$line->date_modification = $this->db->jdate($obj->date_modification);
+ $line->date_export = $this->db->jdate($obj->date_export);
$this->lines[] = $line;
diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
index b53d0603be6..ef8a8c7b750 100644
--- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
+++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
@@ -366,4 +366,6 @@ ALTER TABLE llx_reception_extrafields ADD INDEX idx_reception_extrafields (fk_ob
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN fk_projet integer DEFAULT NULL;
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN fk_reception integer DEFAULT NULL;
+ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_export datetime DEFAULT NULL after date_validated;
+
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
index af693c273a4..4a8f3ac7587 100644
--- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql
@@ -1,6 +1,6 @@
-- ============================================================================
-- Copyright (C) 2013-2014 Olivier Geffroy
--- Copyright (C) 2013-2017 Alexandre Spangaro
+-- Copyright (C) 2013-2019 Alexandre Spangaro
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@@ -51,6 +51,7 @@ CREATE TABLE llx_accounting_bookkeeping
piece_num integer NOT NULL, -- FEC:EcritureNum | accounting source document
validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification)
date_validated datetime, -- FEC:ValidDate
- import_key varchar(14),
+ date_export datetime DEFAULT NULL, --
+ import_key varchar(14), --
extraparams varchar(255) -- for other parameters with json format
) ENGINE=innodb;
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index f91cbd8f1eb..be4d25cfef5 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -842,6 +842,7 @@ Exports=Exports
ExportFilteredList=Export filtered list
ExportList=Export list
ExportOptions=Export Options
+IncludeDocsAlreadyExported=Include docs already exported
Miscellaneous=Miscellaneous
Calendar=Calendar
GroupBy=Group by...