diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index e3cac139c08..03600781319 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2017 Florian Henry - * Copyright (C) 2013-2018 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2020 Frédéric France * @@ -537,6 +537,22 @@ if ($action == 'create') { print ''; print ''; + // Date document creation + print ''; + print ''.$langs->trans("DateExport").''; + print ''; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; + print ''; + print ''; + + // Date document creation + print ''; + print ''.$langs->trans("DateValidation").''; + print ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print ''; + print ''; + // Validate /* print ''; @@ -619,7 +635,9 @@ if ($action == 'create') { print_liste_field_titre("LabelOperation"); print_liste_field_titre("Debit", "", "", "", "", 'class="right"'); print_liste_field_titre("Credit", "", "", "", "", 'class="right"'); - print_liste_field_titre("Action", "", "", "", "", 'width="60" class="center"'); + if (empty($object->date_validation)) { + print_liste_field_titre("Action", "", "", "", "", 'width="60" class="center"'); + } print "\n"; @@ -665,18 +683,22 @@ if ($action == 'create') { print ''.price($line->debit).''; print ''.price($line->credit).''; - print ''; - print 'id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">'; - print img_edit('', 0, 'class="marginrightonly"'); - print '  '; - - $actiontodelete = 'delete'; - if ($mode == '_tmp' || $action != 'delmouv') { - $actiontodelete = 'confirm_delete'; + if (empty($line->date_export) || empty($line->date_validation)) { + print ''; + print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; + print img_edit('', 0, 'class="marginrightonly"'); + print '  '; } - print ''; - print img_delete(); + if (empty($line->date_validation)) { + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') { + $actiontodelete = 'confirm_delete'; + } + + print ''; + print img_delete(); + } print ''; print ''; @@ -691,32 +713,33 @@ if ($action == 'create') { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } - if ($action == "" || $action == 'add') { - print ''; - print ''; - print ''; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); - print ''; - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1); - } else { - print ''; + if (empty($object->date_export) || empty($object->date_validation)) { + if ($action == "" || $action == 'add') { + print ''; + print ''; + print ''; + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount('', 'subledger_account', 1); + } else { + print ''; + } + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; } - print ''; - if ($mode == '_tmp' && $action == '') { print '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 40a8284adc4..dcaa16ffd4e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France * @@ -53,6 +53,8 @@ $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification $search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int')); $search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int')); $search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int')); +$search_date_validation_start = dol_mktime(0, 0, 0, GETPOST('date_validation_startmonth', 'int'), GETPOST('date_validation_startday', 'int'), GETPOST('date_validation_startyear', 'int')); +$search_date_validation_end = dol_mktime(0, 0, 0, GETPOST('date_validation_endmonth', 'int'), GETPOST('date_validation_endday', 'int'), GETPOST('date_validation_endyear', 'int')); //var_dump($search_date_start);exit; if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { @@ -157,6 +159,7 @@ $arrayfields = array( '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'=>1), + 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { @@ -224,6 +227,8 @@ if (empty($reshook)) { $search_date_modification_end = ''; $search_date_export_start = ''; $search_date_export_end = ''; + $search_date_validation_start = ''; + $search_date_validation_end = ''; $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; @@ -328,6 +333,16 @@ if (empty($reshook)) { $tmp = dol_getdate($search_date_export_end); $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); } + if (!empty($search_date_validation_start)) { + $filter['t.date_validated>='] = $search_date_validation_start; + $tmp = dol_getdate($search_date_validation_start); + $param .= '&date_validation_startmonth='.urlencode($tmp['mon']).'&date_validation_startday='.urlencode($tmp['mday']).'&date_validation_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_validation_end)) { + $filter['t.date_validated<='] = $search_date_validation_end; + $tmp = dol_getdate($search_date_validation_end); + $param .= '&date_validation_endmonth='.urlencode($tmp['mon']).'&date_validation_endday='.urlencode($tmp['mday']).'&date_validation_endyear='.urlencode($tmp['year']); + } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; $param .= '&search_debit='.urlencode($search_debit); @@ -447,7 +462,8 @@ $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; -$sql .= " t.date_export"; +$sql .= " t.date_export,"; +$sql .= " t.date_validated as date_validation"; $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -469,6 +485,8 @@ if (count($filter) > 0) { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; + } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { + $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -846,6 +864,17 @@ if (!empty($arrayfields['t.date_export']['checked'])) { print ''; print ''; } +// Date validation +if (!empty($arrayfields['t.date_validated']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_validation_start, 'date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_validation_end, 'date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print ''; +} // Action column print ''; $searchpicto = $form->showFilterButtons(); @@ -897,6 +926,9 @@ if (!empty($arrayfields['t.tms']['checked'])) { 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 '); } +if (!empty($arrayfields['t.date_validated']['checked'])) { + print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); +} print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -939,6 +971,7 @@ while ($i < min($num, $limit)) { $line->date_creation = $db->jdate($obj->date_creation); $line->date_modification = $db->jdate($obj->date_modification); $line->date_export = $db->jdate($obj->date_export); + $line->date_validation = $db->jdate($obj->date_validation); $total_debit += $line->debit; $total_credit += $line->credit; @@ -1131,12 +1164,22 @@ while ($i < min($num, $limit)) { } } + // Validated operation date + if (!empty($arrayfields['t.date_validated']['checked'])) { + print ''.dol_print_date($line->date_validation, 'dayhour').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column print ''; - if (empty($line->date_export)) { + if (empty($line->date_export) || empty($line->date_validation)) { if ($user->rights->accounting->mouvements->creer) { - print ''.img_edit().''; + print '' . img_edit() . ''; } + } + if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { print ''.img_delete().''; } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 7286e954d0e..d1939b84665 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -135,7 +135,6 @@ class BookKeeping extends CommonObject /** * @var float FEC:Amount (Not necessary) - * @deprecated No more used */ public $amount; @@ -722,7 +721,9 @@ class BookKeeping extends CommonObject $sql .= " t.code_journal,"; $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; - $sql .= " t.date_creation"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export,"; + $sql .= " t.date_validated as date_validation"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t'; $sql .= ' WHERE 1 = 1'; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -763,6 +764,9 @@ class BookKeeping extends CommonObject $this->journal_label = $obj->journal_label; $this->piece_num = $obj->piece_num; $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_export = $this->db->jdate($obj->date_export); + $this->date_validation = $this->db->jdate($obj->date_validated); + $this->date_validation = $this->db->jdate($obj->date_validation); } $this->db->free($resql); @@ -828,7 +832,8 @@ class BookKeeping extends CommonObject $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; - $sql .= " t.date_export"; + $sql .= " t.date_export,"; + $sql .= " t.date_validated as date_validation"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -847,6 +852,8 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -920,6 +927,8 @@ class BookKeeping extends CommonObject $line->piece_num = $obj->piece_num; $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_export = $this->db->jdate($obj->date_export); + $line->date_validation = $this->db->jdate($obj->date_validated); + $line->date_validation = $this->db->jdate($obj->date_validation); $this->lines[] = $line; @@ -982,6 +991,7 @@ class BookKeeping extends CommonObject $sql .= " t.date_lim_reglement,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export"; + $sql .= " t.date_validated as date_validation,"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -1003,6 +1013,8 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') { + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -1062,6 +1074,8 @@ class BookKeeping extends CommonObject $line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $line->date_modification = $this->db->jdate($obj->date_modification); $line->date_export = $this->db->jdate($obj->date_export); + $line->date_validation = $this->db->jdate($obj->date_validated); + $line->date_validation = $this->db->jdate($obj->date_validation); $this->lines[] = $line; @@ -1442,6 +1456,8 @@ class BookKeeping extends CommonObject $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; } $sql .= " AND entity IN (".getEntity('accountancy').")"; + // Exclusion of validated entries at the time of deletion + $sql .= " AND date_validated IS NULL"; // TODO: In a future we must forbid deletion if record is inside a closed fiscal period. @@ -1591,7 +1607,8 @@ class BookKeeping extends CommonObject { global $conf; - $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation"; + $sql = "SELECT piece_num, doc_date,code_journal, journal_label, doc_ref, doc_type,"; + $sql .= " date_creation, tms as date_modification, date_export, date_validated as date_validation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".$piecenum; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -1608,6 +1625,10 @@ class BookKeeping extends CommonObject $this->doc_ref = $obj->doc_ref; $this->doc_type = $obj->doc_type; $this->date_creation = $obj->date_creation; + $this->date_modification = $obj->date_modification; + $this->date_export = $obj->date_export; + $this->date_validation = $obj->date_validated; + $this->date_validation = $obj->date_validation; } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(__METHOD__.$this->error, LOG_ERR); @@ -1663,7 +1684,8 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num,"; + $sql .= " date_creation, tms as date_modification, date_export, date_validated as date_validation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " WHERE piece_num = ".$piecenum; $sql .= " AND entity IN (".getEntity('accountancy').")"; @@ -1696,6 +1718,10 @@ class BookKeeping extends CommonObject $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; $line->date_creation = $obj->date_creation; + $line->date_modification = $obj->date_modification; + $line->date_export = $obj->date_export; + $line->date_validation = $obj->date_validated; + $line->date_validation = $obj->date_validation; $this->linesmvt[] = $line; } @@ -1723,7 +1749,8 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,"; - $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num,"; + $sql .= " date_validated as date_validation"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE entity IN (".getEntity('accountancy').")"; @@ -1758,6 +1785,8 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; + $line->date_validation = $obj->date_validated; + $line->date_validation = $obj->date_validation; $this->linesexport[] = $line; } @@ -2091,4 +2120,9 @@ class BookKeepingLine * @var integer|string $date_export; */ public $date_export; + + /** + * @var integer|string $date_validation; + */ + public $date_validation; }