mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
NEW Accountancy - Differentiated export
This commit is contained in:
@@ -146,6 +146,7 @@ $arrayfields=array(
|
|||||||
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
|
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
|
||||||
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
|
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
|
||||||
't.tms'=>array('label'=>$langs->trans("DateModification"), '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']);
|
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_creation_end = '';
|
||||||
$search_date_modification_start = '';
|
$search_date_modification_start = '';
|
||||||
$search_date_modification_end = '';
|
$search_date_modification_end = '';
|
||||||
|
$search_date_export_start = '';
|
||||||
|
$search_date_export_end = '';
|
||||||
$search_debit = '';
|
$search_debit = '';
|
||||||
$search_credit = '';
|
$search_credit = '';
|
||||||
$search_lettering_code = '';
|
$search_lettering_code = '';
|
||||||
@@ -272,6 +275,16 @@ if (! empty($search_date_modification_end)) {
|
|||||||
$tmp=dol_getdate($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'];
|
$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)) {
|
if (! empty($search_debit)) {
|
||||||
$filter['t.debit'] = $search_debit;
|
$filter['t.debit'] = $search_debit;
|
||||||
$param .= '&search_debit=' . urlencode($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, ...)
|
// Export into a file with format defined into setup (FEC, CSV, ...)
|
||||||
if ($action == 'export_file') {
|
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)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
@@ -363,6 +377,22 @@ if ($action == 'export_file') {
|
|||||||
$accountancyexport = new AccountancyExport($db);
|
$accountancyexport = new AccountancyExport($db);
|
||||||
$accountancyexport->export($object->lines);
|
$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))
|
if (!empty($accountancyexport->errors))
|
||||||
{
|
{
|
||||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||||
@@ -446,10 +476,10 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|||||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
|
|
||||||
$listofformat=AccountancyExport::getType();
|
$listofformat=AccountancyExport::getType();
|
||||||
$button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
|
$button = '<input type="checkbox" name="already_exported"> ' . $langs->trans("IncludeDocsAlreadyExported");
|
||||||
|
$button .= '<a class="butAction" title="'.$langs->trans("ExportFilteredList").' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')'.'" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
|
||||||
if (count($filter)) $button.= $langs->trans("ExportFilteredList");
|
if (count($filter)) $button.= $langs->trans("ExportFilteredList");
|
||||||
else $button.= $langs->trans("ExportList");
|
else $button.= $langs->trans("ExportList");
|
||||||
//$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')';
|
|
||||||
$button.= '</a>';
|
$button.= '</a>';
|
||||||
|
|
||||||
|
|
||||||
@@ -600,6 +630,20 @@ if (! empty($arrayfields['t.tms']['checked']))
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
// Date export
|
||||||
|
if (! empty($arrayfields['t.date_export']['checked']))
|
||||||
|
{
|
||||||
|
print '<td class="liste_titre center">';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $langs->trans('From') . ' ';
|
||||||
|
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
|
||||||
|
print '</div>';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $langs->trans('to') . ' ';
|
||||||
|
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
|
||||||
|
print '</div>';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="liste_titre center">';
|
print '<td class="liste_titre center">';
|
||||||
$searchpicto=$form->showFilterButtons();
|
$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.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.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.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_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@@ -732,10 +777,19 @@ if ($num > 0)
|
|||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exported operation date
|
||||||
|
if (! empty($arrayfields['t.date_export']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center">' . dol_print_date($line->date_export, 'dayhour') . '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="nowraponall center">';
|
print '<td class="nowraponall center">';
|
||||||
|
if(empty($line->date_export)) {
|
||||||
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a> ';
|
print '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_edit() . '</a> ';
|
||||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield='.$sortfield : '') . ($sortorder ? '&sortorder='.$sortorder : '') . '">' . img_delete() . '</a>';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
|
|||||||
@@ -872,9 +872,10 @@ class BookKeeping extends CommonObject
|
|||||||
* @param int $offset Offset limit
|
* @param int $offset Offset limit
|
||||||
* @param array $filter Filter array
|
* @param array $filter Filter array
|
||||||
* @param string $filtermode Filter mode (AND or OR)
|
* @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
|
* @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;
|
global $conf;
|
||||||
|
|
||||||
@@ -904,7 +905,8 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.journal_label,";
|
$sql .= " t.journal_label,";
|
||||||
$sql .= " t.piece_num,";
|
$sql .= " t.piece_num,";
|
||||||
$sql .= " t.date_creation,";
|
$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';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array ();
|
$sqlwhere = array ();
|
||||||
@@ -924,6 +926,8 @@ class BookKeeping extends CommonObject
|
|||||||
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
||||||
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
|
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
|
||||||
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
$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') {
|
} elseif ($key == 't.credit' || $key == 't.debit') {
|
||||||
$sqlwhere[] = natural_search($key, $value, 1, 1);
|
$sqlwhere[] = natural_search($key, $value, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
@@ -978,6 +982,7 @@ class BookKeeping extends CommonObject
|
|||||||
$line->piece_num = $obj->piece_num;
|
$line->piece_num = $obj->piece_num;
|
||||||
$line->date_creation = $this->db->jdate($obj->date_creation);
|
$line->date_creation = $this->db->jdate($obj->date_creation);
|
||||||
$line->date_modification = $this->db->jdate($obj->date_modification);
|
$line->date_modification = $this->db->jdate($obj->date_modification);
|
||||||
|
$line->date_export = $this->db->jdate($obj->date_export);
|
||||||
|
|
||||||
$this->lines[] = $line;
|
$this->lines[] = $line;
|
||||||
|
|
||||||
|
|||||||
@@ -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_projet integer DEFAULT NULL;
|
||||||
ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN fk_reception 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;
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
-- Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
-- Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
-- Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
--
|
--
|
||||||
-- This program is free software; you can redistribute it and/or modify
|
-- 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
|
-- 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
|
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)
|
validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification)
|
||||||
date_validated datetime, -- FEC:ValidDate
|
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
|
extraparams varchar(255) -- for other parameters with json format
|
||||||
) ENGINE=innodb;
|
) ENGINE=innodb;
|
||||||
|
|||||||
@@ -842,6 +842,7 @@ Exports=Exports
|
|||||||
ExportFilteredList=Export filtered list
|
ExportFilteredList=Export filtered list
|
||||||
ExportList=Export list
|
ExportList=Export list
|
||||||
ExportOptions=Export Options
|
ExportOptions=Export Options
|
||||||
|
IncludeDocsAlreadyExported=Include docs already exported
|
||||||
Miscellaneous=Miscellaneous
|
Miscellaneous=Miscellaneous
|
||||||
Calendar=Calendar
|
Calendar=Calendar
|
||||||
GroupBy=Group by...
|
GroupBy=Group by...
|
||||||
|
|||||||
Reference in New Issue
Block a user