Manual merge from 3.8 backported

This commit is contained in:
bobby 2016-01-14 18:24:02 +01:00
parent a0fc26fbd8
commit 19bec6b0b3
10 changed files with 1307 additions and 787 deletions

View File

@ -91,7 +91,7 @@ if ($action == "confirm_update") {
$book->sens = 'C'; $book->sens = 'C';
} }
$result = $book->update(); $result = $book->update($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
@ -214,6 +214,18 @@ if ($action == 'create') {
$conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
); );
$sql = 'SELECT DISTINCT accountancy_journal FROM '.MAIN_DB_PREFIX.'bank_account WHERE clos=0';
$resql=$db->query($sql);
if (!$resql) {
setEventMessages($db->lasterror,null,'errors');
} else {
while ($obj_bank=$db->fetch_object($resql)) {
if (!empty($obj_bank->accountancy_journal)) {
$code_journal_array[$obj_bank->accountancy_journal]=$obj_bank->accountancy_journal;
}
}
}
$book = new BookKeeping($db); $book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt(); $next_num_mvt = $book->getNextNumMvt();

View File

@ -43,17 +43,20 @@ $search_doc_ref = GETPOST("search_doc_ref");
$search_account = GETPOST("search_account"); $search_account = GETPOST("search_account");
$search_thirdparty = GETPOST("search_thirdparty"); $search_thirdparty = GETPOST("search_thirdparty");
$search_journal = GETPOST("search_journal"); $search_journal = GETPOST("search_journal");
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
if ($sortorder == "") if ($sortorder == "")
$sortorder = "ASC"; $sortorder = "ASC";
if ($sortfield == "") if ($sortfield == "")
$sortfield = "bk.rowid"; $sortfield = "t.rowid";
$offset = $limit * $page; $offset = $limit * $page;
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$form = new Form($db);
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{ {
@ -64,6 +67,33 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_journal = ""; $search_journal = "";
} }
$options='';
$filter = array ();
if (! empty($search_doc_type)) {
$filter['t.piece_num'] = $search_piece_num;
$options.='&amp;search_doc_type='.$search_piece_num;
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$options.='&amp;search_doc_ref='.$search_doc_ref;
}
}
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$options.='&amp;search_doc_ref='.$search_doc_ref;
}
if (! empty($search_account)) {
$filter['t.numero_compte'] = $search_account;
$options.='&amp;search_account='.$search_account;
}
if (! empty($search_thirdparty)) {
$filter['t.code_tiers'] = $search_thirdparty;
$options.='&amp;search_thirdparty='.$search_thirdparty;
}
if (! empty($search_journal)) {
$filter['t.code_journal'] = $search_journal;
$options.='&amp;search_journal='.$search_journal;
}
/* /*
* Action * Action
*/ */
@ -72,7 +102,6 @@ if ($action == 'delbookkeeping') {
$import_key = GETPOST('importkey', 'alpha'); $import_key = GETPOST('importkey', 'alpha');
if (! empty($import_key)) { if (! empty($import_key)) {
$object = new BookKeeping($db);
$result = $object->delete_by_importkey($import_key); $result = $object->delete_by_importkey($import_key);
Header("Location: list.php"); Header("Location: list.php");
if ($result < 0) { if ($result < 0) {
@ -84,32 +113,28 @@ if ($action == 'delbookkeeping') {
$delyear = GETPOST('delyear', 'int'); $delyear = GETPOST('delyear', 'int');
if (! empty($delyear)) { if (! empty($delyear)) {
$object = new BookKeeping($db);
$result = $object->delete_by_year($delyear); $result = $object->delete_by_year($delyear);
Header("Location: list.php"); Header("Location: list.php");
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} elseif ($action == 'delbookkeepingyear') { } elseif ($action == 'delmouvconfirm') {
$delyear = GETPOST('delyear', 'int'); $piece_num = GETPOST('piece_num', 'int');
if (! empty($delyear)) { if (! empty($piece_num)) {
$object = new BookKeeping($db); $result = $object->delete_piece_num($piece_num);
$result = $object->delete_by_year($delyear);
Header("Location: list.php"); Header("Location: list.php");
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} // Export } elseif ($action == 'export_csv') {
else if ($action == 'export_csv') { // Export
header('Content-Type: text/csv'); header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=export_csv.csv'); header('Content-Disposition: attachment;filename=export_csv.csv');
$object = new BookKeeping($db);
$result = $object->export_bookkeping('ebp'); $result = $object->export_bookkeping('ebp');
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -124,7 +149,7 @@ else if ($action == 'export_csv') {
print '"' . $line->numero_compte . '",'; print '"' . $line->numero_compte . '",';
print '"' . substr($line->code_journal, 0, 2) . '",'; print '"' . substr($line->code_journal, 0, 2) . '",';
print '"' . substr($line->doc_ref, 0, 40) . '",'; print '"' . substr($line->doc_ref, 0, 40) . '",';
print '"' . $line->num_piece . '",'; print '"' . $line->piece_num . '",';
print '"' . $line->debit . '",'; print '"' . $line->debit . '",';
print '"' . $line->credit . '",'; print '"' . $line->credit . '",';
print '"' . $conf->currency . '",'; print '"' . $conf->currency . '",';
@ -140,7 +165,7 @@ else if ($action == 'export_csv') {
print '"' . $line->numero_compte . '",'; print '"' . $line->numero_compte . '",';
print '"' . substr($line->code_journal, 0, 2) . '",'; print '"' . substr($line->code_journal, 0, 2) . '",';
print '"' . substr($line->doc_ref, 0, 40) . '",'; print '"' . substr($line->doc_ref, 0, 40) . '",';
print '"' . $line->num_piece . '",'; print '"' . $line->piece_num . '",';
print '"' . $line->montant . '",'; print '"' . $line->montant . '",';
print '"' . $line->sens . '",'; print '"' . $line->sens . '",';
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
@ -157,7 +182,7 @@ else if ($action == 'export_csv') {
print '"' . $line->numero_compte . '",'; print '"' . $line->numero_compte . '",';
print '"' . substr($line->code_journal, 0, 2) . '",'; print '"' . substr($line->code_journal, 0, 2) . '",';
print '"' . substr($line->doc_ref, 0, 40) . '",'; print '"' . substr($line->doc_ref, 0, 40) . '",';
print '"' . $line->num_piece . '",'; print '"' . $line->piece_num . '",';
print '"' . $line->montant . '",'; print '"' . $line->montant . '",';
print '"' . $line->sens . '",'; print '"' . $line->sens . '",';
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
@ -175,39 +200,25 @@ else {
* List * List
*/ */
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num "; $nbtotalofrecords = 0;
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
if (dol_strlen(trim($search_doc_type))) { if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$sql .= " WHERE bk.piece_num LIKE '%" . $search_piece_num . "%'";
if (dol_strlen(trim($search_doc_ref))) {
$sql .= " AND bk.doc_ref LIKE '%" . $search_doc_ref . "%'";
} }
} }
if (dol_strlen(trim($search_doc_ref))) {
$sql .= " WHERE bk.doc_ref LIKE '%" . $search_doc_ref . "%'"; $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
} if ($result < 0) {
if (dol_strlen(trim($search_account))) { setEventMessages($object->error, $object->errors, 'errors');
$sql .= " WHERE bk.numero_compte LIKE '%" . $search_account . "%'";
}
if (dol_strlen(trim($search_thirdparty))) {
$sql .= " WHERE bk.code_tiers LIKE '%" . $search_thirdparty . "%'";
}
if (dol_strlen(trim($search_journal))) {
$sql .= " WHERE bk.code_journal LIKE '%" . $search_journal . "%'";
} }
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?piece_num=' . GETPOST('piece_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
}
dol_syslog('accountancy/bookkeeping/list.php:: $sql=' . $sql); print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
/*print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; /*print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
@ -226,29 +237,25 @@ else {
print $formother->select_year(GETPOST('delyear'), 'delyear'); print $formother->select_year(GETPOST('delyear'), 'delyear');
print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>'; print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=export_csv">' . $langs->trans("Export") . '</a>';
print '</form>'; print '</form>';
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="export_csv">';
print '<input type="submit" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
print '</form>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "bk.piece_num", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -274,13 +281,12 @@ else {
$var = True; $var = True;
while ( $i < min($num, $conf->liste_limit) ) { foreach ( $object->lines as $line ) {
$obj = $db->fetch_object($resql);
$var = ! $var; $var = ! $var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
/* if ($old_piecenum!=$obj->piece_num) { /*if ($old_piecenum!=$obj->piece_num) {
$total_debit=0; $total_debit=0;
$total_credit=0; $total_credit=0;
} else { } else {
@ -289,36 +295,26 @@ else {
} }
*/ */
print '<td>' . $obj->piece_num . '</td>'; print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->piece_num . '</a></td>';
print '<td align="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>'; print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($obj->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($obj->code_tiers) . '</td>'; print '<td>' . length_accounta($line->code_tiers) . '</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>' . $line->label_compte . '</td>';
print '<td align="right">' . price($obj->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($obj->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($obj->montant) . '</td>'; print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $obj->sens . '</td>'; print '<td align="center">' . $line->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>'; print '<td>' . $line->code_journal . '</td>';
print '<td align="center"><a href="./card.php?piece_num=' . $obj->piece_num . '">' . img_edit() . '</a></td>'; print '<td align="center">';
print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>';
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&piece_num=' . $line->piece_num . '">' . img_delete() . '</a>';
print '</td>';
print "</tr>\n"; print "</tr>\n";
//$old_piecenum= $obj->piece_num;
$i ++;
} }
print "</table>"; print "</table>";
print '<div class="tabsAction">';
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
print '</div>';
$db->free($resql);
} else {
dol_print_error($db);
}
llxFooter(); llxFooter();
} }
$db->close(); $db->close();

View File

@ -23,12 +23,12 @@
* \ingroup Accounting Expert * \ingroup Accounting Expert
* \brief Book keeping by year * \brief Book keeping by year
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class // Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
// Langs // Langs
$langs->load("accountancy"); $langs->load("accountancy");
@ -36,93 +36,204 @@ $langs->load("accountancy");
$page = GETPOST("page"); $page = GETPOST("page");
$sortorder = GETPOST("sortorder"); $sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield"); $sortfield = GETPOST("sortfield");
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_type=GETPOST('search_doc_type','alpha');
$search_doc_date=dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_doc_ref=GETPOST('search_doc_ref','alpha');
$search_numero_compte=GETPOST('search_numero_compte','alpha');
$search_code_tiers=GETPOST('search_code_tiers','alpha');
$search_label_compte=GETPOST('search_label_compte','alpha');
$search_sens=GETPOST('search_sens','alpha');
$search_code_journal=GETPOST('search_code_journal','alpha');
$object = new BookKeeping($db);
$form = new Form($db);
// Filter // Filter
$year = GETPOST("year", 'int'); if (empty($search_date_start)) {
if ($year == 0) { $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$year_current = strftime("%Y", time()); $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
} }
if ($sortorder == "") if ($sortorder == "")
$sortorder = "ASC"; $sortorder = "ASC";
if ($sortfield == "") if ($sortfield == "")
$sortfield = "bk.rowid"; $sortfield = "t.rowid";
$offset = $limit * $page; $offset = $limit * $page;
llxHeader('', $langs->trans("Bookkeeping")); llxHeader('', $langs->trans("Bookkeeping"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; {
$search_doc_type = "";
$search_doc_date = "";
$search_doc_ref = "";
$search_numero_compte = "";
$search_code_tiers = "";
$search_label_compte = "";
$search_sens = "";
$search_code_journal = "";
}
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type;
$options .= '&amp;search_doc_type=' . $search_doc_type;
}
if (! empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
}
if (! empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$options .= '&amp;search_doc_ref=' . $search_doc_ref;
}
if (! empty($search_numero_compte)) {
$filter['t.numero_compte'] = $search_numero_compte;
$options .= '&amp;search_numero_compte=' . $search_numero_compte;
}
if (! empty($search_code_tiers)) {
$filter['t.code_tiers'] = $search_code_tiers;
$options .= '&amp;search_code_tiers=' . $search_code_tiers;
}
if (! empty($search_label_compte)) {
$filter['t.label_compte'] = $search_label_compte;
$options .= '&amp;search_label_compte=' . $search_label_compte;
}
if (! empty($search_sens)) {
$filter['t.sens'] = $search_sens;
$options .= '&amp;search_sens=' . $search_sens;
}
if (! empty($search_code_journal)) {
$filter['t.code_journal'] = $search_code_journal;
$options .= '&amp;search_code_journal=' . $search_code_journal;
}
/* /*
* Mode List * Mode List
*/ */
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal"; $nbtotalofrecords = 0;
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
// $sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y,1,false))."'"; $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0);
// $sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y,12,false))."'"; if ($nbtotalofrecords < 0) {
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); setEventMessages($object->error, $object->errors, 'errors');
}
}
dol_syslog('accountancy/bookkeeping/listbyyear.php:: $sql=' . $sql); $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
$resql = $db->query($sql); if ($result < 0) {
if ($resql) { setEventMessages($object->error, $object->errors, 'errors');
$num = $db->num_rows($resql); }
$i = 0;
print_barre_liste($langs->trans("Bookkeeping") . " $textprevyear " . $langs->trans("Year") . " $year_start $textnextyear", $page, $_SERVER['PHP_SELF'], "", $sortfield, $sortorder, '', $num); print_barre_liste($langs->trans("Bookkeeping") .' '. dol_print_date($search_date_start).'-'.dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords);
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder); print '<div class="liste_titre">';
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); print $langs->trans('DateStart') . ': ';
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); print $form->select_date($search_date_start, 'date_start');
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); print $langs->trans('DateEnd') . ': ';
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); print $form->select_date($search_date_end, 'date_end');
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); print '</div>';
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder); print "<table class=\"noborder\" width=\"100%\">";
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder);
print_liste_field_titre('');
print "</tr>\n";
$var = True; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder);
print '<th class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '"></td>';
print "</tr>\n";
print '<tr class="liste_titre">';
while ( $i < min($num, $conf->liste_limit) ) { print '<td class="liste_titre">';
$obj = $db->fetch_object($resql); print '<input type="text" size=7 class="flat" name="search_doc_type" value="'.$search_doc_type.'"/>';
print '</td>';
print '<td class="liste_titre">';
print $form->select_date($search_doc_date,'doc_date',0, 0, 1);
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_doc_ref" value="'.$search_doc_ref.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_numero_compte" value="'.$search_numero_compte.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_code_tiers" value="'.$search_code_tiers.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_label_compte" value="'.$search_label_compte.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=2 class="flat" name="search_sens" value="'.$search_sens.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size=3 class="flat" name="search_code_journal" value="'.$search_code_journal.'"/>';
print '</td>';
print '<td class="liste_titre">';
print '</td>';
print "</tr>\n";
$var = True;
foreach ( $object->lines as $line ) {
$var = ! $var; $var = ! $var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>' . $obj->doc_type . '</td>' . "\n"; print '<td>' . $line->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date($db->jdate($obj->doc_date)) . '</td>'; print '<td>' . dol_print_date($line->doc_date) . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($obj->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($obj->code_tiers) . '</td>'; print '<td>' . length_accounta($line->code_tiers) . '</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>' . $line->label_compte . '</td>';
print '<td align="right">' . price($obj->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($obj->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($obj->montant) . '</td>'; print '<td align="right">' . price($line->montant) . '</td>';
print '<td>' . $obj->sens . '</td>'; print '<td>' . $line->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>'; print '<td>' . $line->code_journal . '</td>';
print '<td><a href="./card.php?action=update&id=' . $obj->rowid . '">' . img_edit() . '</a></td>'; print '<td><a href="./card.php?action=update&amp;piece_num=' . $line->piece_num . '">' . img_edit() . '</a></td>';
print "</tr>\n"; print "</tr>\n";
$i ++;
}
print "</table>";
$db->free($resql);
} else {
dol_print_error($db);
} }
print "</table>";
print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -30,6 +30,11 @@
*/ */
class AccountingAccount extends CommonObject class AccountingAccount extends CommonObject
{ {
var $db;
var $error;
var $errors;
var $id;
var $rowid; var $rowid;
var $datec; // Creation date var $datec; // Creation date

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,7 @@
/** /**
* Class to manage generation of HTML components for bank module * Class to manage generation of HTML components for bank module
*/ */
class FormVentilation extends Form class FormVentilation extends Form {
{
var $db; var $db;
var $error; var $error;
@ -37,8 +36,7 @@ class FormVentilation extends Form
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db) {
{
$this->db = $db; $this->db = $db;
} }
@ -49,8 +47,7 @@ class FormVentilation extends Form
* @param string $selectedkey Value * @param string $selectedkey Value
* @return string HTML edit field * @return string HTML edit field
*/ */
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='') function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') {
{
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
$sql .= ' ORDER BY import_key DESC'; $sql .= ' ORDER BY import_key DESC';
@ -94,12 +91,11 @@ class FormVentilation extends Form
* @param array $event Event options * @param array $event Event options
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number * @param int $select_out set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by * @param int $aabase set accountingaccount base class to display empty=all or from 1 to 8 will display only account beginning by
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
{
global $conf; global $conf;
$out = ''; $out = '';
@ -128,10 +124,14 @@ class FormVentilation extends Form
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$label = $obj->account_number . ' - ' . $obj->label; $label = $obj->account_number . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength); $label = dol_trunc($label, $trunclength);
if ($select_in == 0 ) $select_value_in = $obj->rowid; if ($select_in == 0)
if ($select_in == 1 ) $select_value_in = $obj->account_number; $select_value_in = $obj->rowid;
if ($select_out == 0 ) $select_value_out = $obj->rowid; if ($select_in == 1)
if ($select_out == 1 ) $select_value_out = $obj->account_number; $select_value_in = $obj->account_number;
if ($select_out == 0)
$select_value_out = $obj->rowid;
if ($select_out == 1)
$select_value_out = $obj->account_number;
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning // Because same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $select_value_in) { if (($selectid != '') && $selectid == $select_value_in) {
@ -164,8 +164,7 @@ class FormVentilation extends Form
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) {
{
global $conf; global $conf;
$out = ''; $out = '';
@ -220,8 +219,7 @@ class FormVentilation extends Form
* *
* @return string String with HTML select * @return string String with HTML select
*/ */
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) {
{
global $conf; global $conf;
$out = ''; $out = '';

View File

@ -228,6 +228,9 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>'; print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder);
print '&nbsp;&nbsp;';
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';

View File

@ -343,7 +343,7 @@ if ($action == 'writebookkeeping')
} }
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -421,7 +421,7 @@ if ($action == 'writebookkeeping')
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} }
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');

View File

@ -182,7 +182,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -212,7 +212,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -243,7 +243,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');

View File

@ -217,7 +217,7 @@ if ($action == 'writebookkeeping')
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -247,7 +247,7 @@ if ($action == 'writebookkeeping')
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -279,7 +279,7 @@ if ($action == 'writebookkeeping')
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create(); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
$error ++; $error ++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -531,6 +531,7 @@ if ($action == 'export_csv')
print "</table>"; print "</table>";
// End of page
llxFooter(); llxFooter();
} }