diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index ff742c356c4..49dbb81e77d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -57,6 +57,12 @@ $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', 'alpha'); +$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); +$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha'); + +if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { + $action = 'delbookkeepingyear'; +} // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); @@ -105,6 +111,7 @@ if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search $arrayfields = array( // 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), + 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1), 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), @@ -112,10 +119,6 @@ $arrayfields = array( 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - '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'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -155,6 +158,8 @@ if (empty($reshook)) $search_date_endday = ''; $search_debit = ''; $search_credit = ''; + $search_lettering_code = ''; + $search_not_reconciled = ''; } // Must be after the remove filter action, before the export. @@ -209,9 +214,62 @@ if (empty($reshook)) $filter['t.credit'] = $search_credit; $param .= '&search_credit=' . urlencode($search_credit); } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } } -if ($action == 'delmouvconfirm') { +if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { + $import_key = GETPOST('importkey', 'alpha'); + + if (!empty($import_key)) { + $result = $object->deleteByImportkey($import_key); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } +} +if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) { + $delmonth = GETPOST('delmonth', 'int'); + $delyear = GETPOST('delyear', 'int'); + if ($delyear == -1) { + $delyear = 0; + } + $deljournal = GETPOST('deljournal', 'alpha'); + if ($deljournal == -1) { + $deljournal = 0; + } + + if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) + { + $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + setEventMessages("RecordDeleted", null, 'mesgs'); + } + + // Make a redirect to avoid to launch the delete later after a back button + header("Location: listbyaccount.php".($param ? '?'.$param : '')); + exit; + } + else + { + setEventMessages("NoRecordDeleted", null, 'warnings'); + } +} +if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) { $mvt_num = GETPOST('mvt_num', 'int'); if (!empty($mvt_num)) { @@ -219,8 +277,13 @@ if ($action == 'delmouvconfirm') { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - Header("Location: listbyaccount.php"); - exit(); + else + { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } + + header("Location: listbyaccount.php?noreset=1".($param ? '&'.$param : '')); + exit; } } @@ -262,22 +325,42 @@ if ($action == 'delmouv') { } if ($action == 'delbookkeepingyear') { $form_question = array(); - $delyear = GETPOST('delyear'); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } + $month_array = array(); + for ($i = 1; $i <= 12; $i++) { + $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); + } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); + $form_question['delmonth'] = array( + 'name' => 'delmonth', + 'type' => 'select', + 'label' => $langs->trans('DelMonth'), + 'values' => $month_array, + 'default' => '' + ); $form_question['delyear'] = array( - 'name' => 'delyear', - 'type' => 'select', - 'label' => $langs->trans('DelYear'), - 'values' => $year_array, - 'default' => $delyear + 'name' => 'delyear', + 'type' => 'select', + 'label' => $langs->trans('DelYear'), + 'values' => $year_array, + 'default' => $delyear + ); + $form_question['deljournal'] = array( + 'name' => 'deljournal', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component + 'label' => $langs->trans('DelJournal'), + 'value' => $journal_array, + 'default' => $deljournal ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); print $formconfirm; } @@ -304,35 +387,41 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); +// Reverse sort order +if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; +else $sortorder = "desc"; + +$moreforfilter = ''; + +// Accountancy account +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountAccounting').': '; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('From').' '; +$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= $langs->trans('to').' '; +$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -// Reverse sort order -if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; -else $sortorder = "desc"; +print '
'; +print $moreforfilter; +print '
'; print '
'; print ''; // Filters lines print ''; -// Accountancy account -print ''; -// Movement number -if (!empty($arrayfields['t.piece_num']['checked'])) -{ - print ''; + +// Code journal +if (!empty($arrayfields['t.code_journal']['checked'])) { + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { @@ -347,6 +436,11 @@ if (!empty($arrayfields['t.doc_date']['checked'])) { print ''; print ''; } +// Movement number +if (!empty($arrayfields['t.piece_num']['checked'])) +{ + print ''; +} // Ref document if (!empty($arrayfields['t.doc_ref']['checked'])) { print ''; @@ -363,9 +457,13 @@ if (!empty($arrayfields['t.debit']['checked'])) { if (!empty($arrayfields['t.credit']['checked'])) { print ''; } -// Code journal -if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; +// Lettering code +if (!empty($arrayfields['t.lettering_code']['checked'])) +{ + print ''; } // Fields from hook @@ -381,14 +479,14 @@ print ''; print "\n"; print ''; -print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); -if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); +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.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); -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.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -419,18 +517,42 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - // Affiche un Sous-Total par compte comptable + + $colspan = $totalarray['nbfield'] - 3; + $colspanend = $totalarray['nbfield'] - 7; + // Show a subtotal by accounting account if (isset($displayed_account_number)) { - print ''; - print "\n"; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Show balance of last shown account + $balance = $sous_total_debit - $sous_total_credit; + print ''; + print ''; + if ($balance > 0 ) + { + print ''; + print ''; + } + else + { + print ''; + print ''; + } + print ''; print ''; } // Show the break account - $colspan = 9; print ""; - print ''; @@ -440,11 +562,28 @@ while ($i < min($num, $limit)) //if (empty($displayed_account_number)) $displayed_account_number='-'; $sous_total_debit = 0; $sous_total_credit = 0; + + $colspan = 0; } print ''; - print ''; - if (!$i) $totalarray['nbfield']++; + + // Journal code + if (!empty($arrayfields['t.code_journal']['checked'])) + { + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $line->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Document date + if (!empty($arrayfields['t.doc_date']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Piece number if (!empty($arrayfields['t.piece_num']['checked'])) @@ -457,13 +596,6 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - // Document date - if (!empty($arrayfields['t.doc_date']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { @@ -565,16 +697,6 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } - // Journal code - if (!empty($arrayfields['t.code_journal']['checked'])) - { - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $line->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -591,25 +713,45 @@ while ($i < min($num, $limit)) } } print ''; + if (!$i) $totalarray['nbfield']++; // Comptabilise le sous-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; - if (!$i) $totalarray['nbfield']++; - print "\n"; $i++; } // Show sub-total of last shown account +$colspan = $totalarray['nbfield'] - 3; +$colspanend = $totalarray['nbfield'] - 8; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Show balance of last shown account +$balance = $sous_total_debit - $sous_total_credit; +print ''; +print ''; +if ($balance > 0 ) +{ + print ''; + print ''; +} +else +{ + print ''; + print ''; +} +print ''; print ''; // Show total line diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index eb3229efaee..adf2309ad07 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -121,6 +121,7 @@ InvoiceLinesDone=Bound lines of invoices ExpenseReportLines=Lines of expense reports to bind ExpenseReportLinesDone=Bound lines of expense reports IntoAccount=Bind line with the accounting account +TotalForAccount=Total for accounting account Ventilate=Bind
'; -print '
'; -print $langs->trans('From').' '; -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); -print '
'; -print '
'; -print $langs->trans('to').' '; -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); -print '
'; -print '
'; + print ''; + print '
'.$langs->trans("NotReconciled").''; + print '
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).'  
'.$langs->trans("TotalForAccount").' '.length_accountg($displayed_account_number).':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '
'; + print ''; if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print '
 '.$journaltoshow.''.dol_print_date($line->doc_date, 'day').''.dol_print_date($line->doc_date, 'day').''.$journaltoshow.'
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''; -print price($sous_total_debit - $sous_total_credit); -print ''.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).'
'.$langs->trans("Balance").':'; + print price($sous_total_debit - $sous_total_credit); + print ''; + print price($sous_total_credit - $sous_total_debit); + print '