Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2017-07-15 21:25:14 +02:00
commit 75ec7a309c
38 changed files with 1442 additions and 952 deletions

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -16,7 +16,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
/** /**
@ -377,28 +376,28 @@ print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From') . ': '; print $langs->trans('From') . ' ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to') . ': '; print $langs->trans('to') . ' ';
print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
print '</div>'; print '</div>';
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>'; print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From'); print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to'); print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print '</div>'; print '</div>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From'); print $langs->trans('From').' ';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
@ -411,7 +410,7 @@ else
} }
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('to'); print $langs->trans('to').' ';
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
@ -455,7 +454,10 @@ print "</tr>\n";
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
foreach ($object->lines as $line ) { $i=0;
while ($i < min($num, $limit))
{
$line = $object->lines[$i];
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
@ -481,6 +483,8 @@ foreach ($object->lines as $line ) {
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>'; print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
$i++;
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';

View File

@ -92,7 +92,7 @@ if (! empty($search_doc_date)) {
} }
if (!GETPOST('button_removefilter_x','alpha') && !GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers if (! GETPOST('button_removefilter_x','alpha') && ! GETPOST('button_removefilter.x','alpha') && ! GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{ {
if (! empty($search_accountancy_code_start)) { if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte'] = $search_accountancy_code_start; $filter['t.numero_compte'] = $search_accountancy_code_start;
@ -160,7 +160,6 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By"
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
@ -173,7 +172,9 @@ $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $f
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$nbtotalofrecords = $result;
$num=count($object->lines);
if ($action == 'delmouv') { if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1);
@ -204,7 +205,7 @@ if ($action == 'delbookkeepingyear') {
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">' . $langs->trans("ViewFlatList") . '</a>'; $viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">' . $langs->trans("ViewFlatList") . '</a>';
@ -236,7 +237,7 @@ print '<td class="liste_titre"><input type="text" size="7" class="flat" name="se
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_account" value="' . $search_label_account . '"/></td>'; print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_account" value="' . $search_label_account . '"/></td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>'; print '<td class="liste_titre" align="center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
print '<td class="liste_titre" align="right" colspan="2">'; print '<td class="liste_titre" align="right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0); $searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
@ -250,7 +251,7 @@ print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_re
print_liste_field_titre($langs->trans("Label")); print_liste_field_titre($langs->trans("Label"));
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
@ -263,7 +264,10 @@ $sous_total_debit = 0;
$sous_total_credit = 0; $sous_total_credit = 0;
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty $displayed_account_number = null; // Start with undefined to be able to distinguish with empty
foreach ( $object->lines as $line ) { $i=0;
while ($i < min($num, $limit))
{
$line = $object->lines[$i];
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
@ -323,10 +327,11 @@ foreach ( $object->lines as $line ) {
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Comptabilise le sous-total // Comptabilise le sous-total
$sous_total_debit += $line->debit; $sous_total_debit += $line->debit;
$sous_total_credit += $line->credit; $sous_total_credit += $line->credit;
$i++;
} }
// Affiche un Sous-Total du dernier compte comptable affiché // Affiche un Sous-Total du dernier compte comptable affiché

View File

@ -176,7 +176,7 @@ class BookKeeping extends CommonObject
if (empty($this->credit)) $this->credit = 0; if (empty($this->credit)) $this->credit = 0;
// Check parameters // Check parameters
if (empty($this->numero_compte) || $this->numero_compte == '-1') if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined')
{ {
$langs->load("errors"); $langs->load("errors");
if (in_array($this->doc_type, array('bank', 'expense_report'))) if (in_array($this->doc_type, array('bank', 'expense_report')))
@ -803,7 +803,7 @@ class BookKeeping extends CommonObject
if (! empty($limit)) { if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset); $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
} }
$this->lines = array (); $this->lines = array();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

File diff suppressed because it is too large Load Diff

View File

@ -36,12 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
$langs->load("compta"); $langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$langs->load("trips");
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -53,6 +48,7 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
$now = dol_now(); $now = dol_now();
@ -90,7 +86,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$idpays = $mysoc->country_id; $idpays = $mysoc->country_id;
$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, ";
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva"; //$sql .= " ct.accountancy_code_buy as account_tva";
@ -105,26 +101,31 @@ $sql .= " AND erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes') if ($in_bookkeeping == 'already')
$sql .= " AND er.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
if ($in_bookkeeping == 'notyet')
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
$sql .= " ORDER BY er.date_debut"; $sql .= " ORDER BY er.date_debut";
dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result);
// Variables
$account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef");
$account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
$taber = array (); $taber = array ();
$tabht = array (); $tabht = array ();
$tabtva = array (); $tabtva = array ();
$def_tva = array (); $def_tva = array ();
$tabttc = array (); $tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabuser = array (); $tabuser = array ();
$num = $db->num_rows($result);
// Variables
$account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined';
$account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -135,6 +136,8 @@ if ($result) {
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat);
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
@ -146,9 +149,19 @@ if ($result) {
$taber[$obj->rowid]["ref"] = $obj->ref; $taber[$obj->rowid]["ref"] = $obj->ref;
$taber[$obj->rowid]["comments"] = $obj->comments; $taber[$obj->rowid]["comments"] = $obj->comments;
$taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid;
// Avoid warnings
if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0;
if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_fees] += $obj->total_ht; $tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array (
'id' => $obj->uid, 'id' => $obj->uid,
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
@ -166,7 +179,7 @@ if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
foreach ($taber as $key => $val) foreach ($taber as $key => $val) // Loop on each expense report
{ {
$errorforline = 0; $errorforline = 0;
@ -177,7 +190,6 @@ if ($action == 'writebookkeeping') {
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -187,8 +199,8 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0; $bookkeeping->debit = ($mt <= 0) ? $mt : 0;
@ -203,7 +215,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -220,8 +232,6 @@ if ($action == 'writebookkeeping') {
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
@ -235,8 +245,8 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = $accountingaccount->label;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
@ -251,7 +261,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -268,9 +278,15 @@ if ($action == 'writebookkeeping') {
// VAT // VAT
if (! $errorforline) if (! $errorforline)
{ {
// var_dump($tabtva); $listoftax=array(0, 1, 2);
foreach ( $tabtva[$key] as $k => $mt ) { foreach($listoftax as $numtax)
if ($mt) { {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ( $arrayofvat[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label // get compte id and label
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -281,8 +297,8 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
@ -297,7 +313,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -306,6 +322,7 @@ if ($action == 'writebookkeeping') {
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
} }
} }
}
} }
} }
} }
@ -326,7 +343,7 @@ if ($action == 'writebookkeeping') {
} }
} }
if (empty($error) && count($tabpay)) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} }
elseif (count($tabpay) == $error) elseif (count($tabpay) == $error)
@ -339,6 +356,21 @@ if ($action == 'writebookkeeping') {
} }
$action=''; $action='';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookeeping='.$in_bookeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
exit;
}
} }
/* /*
@ -350,7 +382,7 @@ $form = new Form($db);
$userstatic = new User($db); $userstatic = new User($db);
// Export // Export
/*if ($action == 'export_csv') { /*if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -469,26 +501,32 @@ if (empty($action) || $action == 'view') {
$builddate = time(); $builddate = time();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { // Button to write into Ledger
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>'; if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
} else { print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />'; print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}*/ }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
}
else {
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
}
//print '<input type="button" class="butAction" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
print '</div>'; print '</div>';
print ' print '
<script type="text/javascript"> <script type="text/javascript">
function launch_export() { function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv"); $("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click(); $("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val(""); $("div.fiche div.tabBar form input[name=\"action\"]").val("");
} }
@ -510,7 +548,8 @@ if (empty($action) || $action == 'view') {
print "<td></td>"; print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("Label") . "</td>"; print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Credit") . "</td>";
@ -540,6 +579,7 @@ if (empty($action) || $action == 'view') {
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>"; print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
$userstatic->id = $tabuser[$key]['id']; $userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name']; $userstatic->name = $tabuser[$key]['name'];
// Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@ -547,7 +587,10 @@ if (empty($action) || $action == 'view') {
print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>';
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print '</td>';
// Subledger account
print "<td>";
print '</td>';
$userstatic->id = $tabuser[$key]['id']; $userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name']; $userstatic->name = $tabuser[$key]['name'];
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>"; print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>";
@ -557,28 +600,6 @@ if (empty($action) || $action == 'view') {
} }
} }
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '<tr class="oddeven">';
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
// Third party // Third party
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -587,19 +608,63 @@ if (empty($action) || $action == 'view') {
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>"; print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
$userstatic->id = $tabuser[$key]['id']; $userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name']; $userstatic->name = $tabuser[$key]['name'];
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// Subledger account
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>';
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print '</td>';
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>"; print "</tr>";
} }
// VAT
$listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ( $arrayofvat[$key] as $k => $mt ) {
if ($mt) {
print '<tr class="oddeven">';
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
// Account
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
print "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
}
} }
print "</table>"; print "</table>";

View File

@ -36,11 +36,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
$langs->load("compta"); $langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -52,6 +48,7 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
$now = dol_now(); $now = dol_now();
@ -89,7 +86,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$idpays = $mysoc->country_id; $idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,";
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva"; //$sql .= " ct.accountancy_code_buy as account_tva";
@ -109,26 +106,30 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes') if ($in_bookkeeping == 'already')
$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
if ($in_bookkeeping == 'notyet')
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql); dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result);
// Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
$tabfac = array (); $tabfac = array ();
$tabht = array (); $tabht = array ();
$tabtva = array (); $tabtva = array ();
$def_tva = array (); $def_tva = array ();
$tabttc = array (); $tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabcompany = array (); $tabcompany = array ();
$num = $db->num_rows($result);
// Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
@ -139,9 +140,9 @@ if ($result) {
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
else else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
} }
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
@ -166,10 +167,14 @@ if ($result) {
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
$tabcompany[$obj->rowid] = array ( $tabcompany[$obj->rowid] = array (
'id' => $obj->socid, 'id' => $obj->socid,
'name' => $obj->name, 'name' => $obj->name,
@ -188,8 +193,7 @@ if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
foreach ($tabfac as $key => $val) // Loop on each invoice foreach ($tabfac as $key => $val) { // Loop on each invoice
{
$errorforline = 0; $errorforline = 0;
$db->begin(); $db->begin();
@ -197,12 +201,6 @@ if ($action == 'writebookkeeping') {
$companystatic = new Societe($db); $companystatic = new Societe($db);
$invoicestatic = new FactureFournisseur($db); $invoicestatic = new FactureFournisseur($db);
$invoicestatic->id = $key;
$invoicestatic->ref = (string) $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta = $tabcompany[$key]['code_compta'];
@ -211,6 +209,12 @@ if ($action == 'writebookkeeping') {
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key;
$invoicestatic->ref = (string) $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
// Thirdparty // Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
@ -226,8 +230,8 @@ if ($action == 'writebookkeeping') {
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount");
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0; $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
@ -242,7 +246,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -259,8 +263,6 @@ if ($action == 'writebookkeeping') {
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
@ -271,12 +273,12 @@ if ($action == 'writebookkeeping') {
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
@ -291,7 +293,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -309,9 +311,15 @@ if ($action == 'writebookkeeping') {
// var_dump($tabtva); // var_dump($tabtva);
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabtva[$key] as $k => $mt ) { $listoftax=array(0, 1, 2);
foreach($listoftax as $numtax)
{
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ( $arrayofvat[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -322,8 +330,8 @@ if ($action == 'writebookkeeping') {
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->debit = ($mt > 0) ? $mt : 0;
@ -338,7 +346,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -350,6 +358,7 @@ if ($action == 'writebookkeeping') {
} }
} }
} }
}
if (! $errorforline) if (! $errorforline)
{ {
@ -367,7 +376,7 @@ if ($action == 'writebookkeeping') {
} }
} }
if (empty($error) && count($tabpay)) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} }
elseif (count($tabpay) == $error) elseif (count($tabpay) == $error)
@ -378,7 +387,23 @@ if ($action == 'writebookkeeping') {
{ {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
} }
$action=''; $action='';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookeeping='.$in_bookeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
exit;
}
} }
/* /*
@ -387,9 +412,6 @@ if ($action == 'writebookkeeping') {
$form = new Form($db); $form = new Form($db);
$companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
// Export // Export
if ($action == 'exportcsv') { if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@ -397,20 +419,40 @@ if ($action == 'exportcsv') {
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
foreach ( $tabfac as $key => $val ) { $companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
foreach ( $tabfac as $key => $val )
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key; $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
$invoicestatic->ref = $val["refsologest"]; $invoicestatic->ref = $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"]; $invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"]; $invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); $invoicestatic->description = dol_trunc($val["description"], 32);
$date = dol_print_date($val["date"], 'day'); $date = dol_print_date($val["date"], 'day');
$companystatic->id = $tabcompany[$key]['id']; // Third party
$companystatic->name = $tabcompany[$key]['name']; foreach ( $tabttc[$key] as $k => $mt ) {
$companystatic->client = $tabcompany[$key]['code_client']; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsuppliersologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print "\n";
}
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
@ -428,12 +470,18 @@ if ($action == 'exportcsv') {
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal_label . '"' ; print '"' . $journal . '"' ;
print "\n"; print "\n";
} }
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
@ -442,35 +490,17 @@ if ($action == 'exportcsv') {
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep; print " " . $sep;
print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal_label . '"' ; print '"' . $journal . '"' ;
print "\n"; print "\n";
} }
} }
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsuppliersologest"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal_label . '"' ;
print "\n";
}
} }
} }
}
if (empty($action) || $action == 'view') { if (empty($action) || $action == 'view') {
@ -481,7 +511,6 @@ if (empty($action) || $action == 'view') {
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
$builddate = time(); $builddate = time();
//$description = $langs->trans("DescPurchasesJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
@ -489,18 +518,13 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
} }
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0); $listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/
// Button to write into Ledger // Button to write into Ledger
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
@ -542,7 +566,8 @@ if (empty($action) || $action == 'view') {
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
@ -550,19 +575,52 @@ if (empty($action) || $action == 'view') {
$r = ''; $r = '';
$invoicestatic = new FactureFournisseur($db); $invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key; $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->ref = $val["refsologest"]; $invoicestatic->ref = $val["refsologest"];
$invoicestatic->refsupplier = $val["refsuppliersologest"]; $invoicestatic->refsupplier = $val["refsuppliersologest"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$date = dol_print_date($val["date"], 'day'); $date = dol_print_date($val["date"], 'day');
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->supplier_code = $tabcompany[$key]['code_supplier'];
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
}
else print $accountoshow;
print '</td>';
// Subledger account
print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
}
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
@ -573,6 +631,7 @@ if (empty($action) || $action == 'view') {
print "<td><!-- Product --></td>"; print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
// Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@ -581,10 +640,12 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
// Subledger account
print "<td>";
print '</td>';
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>";
// print "<td>" . $accountingaccount->label . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
@ -592,50 +653,37 @@ if (empty($action) || $action == 'view') {
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { $listoftax = array(0, 1, 2);
if ($mt) { foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ( $arrayofvat[$key] as $k => $mt ) {
if ($mt) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td><!-- VAT --></td>"; print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
// Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
{ {
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "</td>"; // Subledger account
print "<td>";
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
print "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
} }
}
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} }
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
// print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';
// print "</td>";
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
} }
} }

View File

@ -39,12 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
$langs->load("commercial"); $langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -56,6 +51,7 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
$now = dol_now(); $now = dol_now();
@ -94,7 +90,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$idpays = $mysoc->country_id; $idpays = $mysoc->country_id;
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_sell as account_tva"; //$sql .= " ct.accountancy_code_sell as account_tva";
@ -115,7 +111,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND fd.product_type IN (0,1)"; $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
if ($in_bookkeeping == 'yes') if ($in_bookkeeping == 'already')
$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
if ($in_bookkeeping == 'notyet')
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
@ -127,13 +125,15 @@ if ($result) {
$tabtva = array (); $tabtva = array ();
$def_tva = array (); $def_tva = array ();
$tabttc = array (); $tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabcompany = array (); $tabcompany = array ();
$num = $db->num_rows($result); $num = $db->num_rows($result);
// Variables // Variables
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
$i = 0; $i = 0;
while ( $i < $num ) { while ( $i < $num ) {
@ -145,13 +145,15 @@ if ($result) {
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
else else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
} }
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
@ -185,10 +187,14 @@ if ($result) {
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
$tabcompany[$obj->rowid] = array ( $tabcompany[$obj->rowid] = array (
'id' => $obj->socid, 'id' => $obj->socid,
'name' => $obj->name, 'name' => $obj->name,
@ -207,7 +213,7 @@ if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
foreach ( $tabfac as $key => $val ) { // Loop on each invoice foreach ($tabfac as $key => $val) { // Loop on each invoice
$errorforline = 0; $errorforline = 0;
@ -258,7 +264,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -285,7 +291,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->date_create = $now; $bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
@ -305,7 +311,7 @@ if ($action == 'writebookkeeping') {
{ {
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
} }
else else
{ {
@ -323,41 +329,49 @@ if ($action == 'writebookkeeping') {
// var_dump($tabtva); // var_dump($tabtva);
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabtva[$key] as $k => $mt ) { $listoftax=array(0, 1, 2);
if ($mt) { foreach($listoftax as $numtax)
$bookkeeping = new BookKeeping($db); {
$bookkeeping->doc_date = $val["date"]; $arrayofvat = $tabtva;
$bookkeeping->doc_ref = $val["ref"]; if ($numtax == 1) $arrayofvat = $tablocaltax1;
$bookkeeping->date_create = $now; if ($numtax == 2) $arrayofvat = $tablocaltax2;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user); foreach ( $arrayofvat[$key] as $k => $mt ) {
if ($result < 0) { if ($mt) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists $bookkeeping = new BookKeeping($db);
{ $bookkeeping->doc_date = $val["date"];
$error++; $bookkeeping->doc_ref = $val["ref"];
$errorforline++; $bookkeeping->date_create = $now;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); $bookkeeping->doc_type = 'customer_invoice';
} $bookkeeping->fk_doc = $key;
else $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
{ $bookkeeping->thirdparty_code = $companystatic->code_client;
$error++; $bookkeeping->subledger_account = '';
$errorforline++; $bookkeeping->subledger_label = '';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); $bookkeeping->numero_compte = $k;
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$result = $bookkeeping->create($user);
if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
{
$error++;
$errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
} }
} }
} }
@ -394,6 +408,21 @@ if ($action == 'writebookkeeping') {
} }
$action=''; $action='';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookeeping='.$in_bookeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
exit;
}
} }
@ -410,84 +439,87 @@ if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db); $companystatic = new Client($db);
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val )
$companystatic->id = $tabcompany[$key]['id']; {
$companystatic->name = $tabcompany[$key]['name']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key; $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];
$date = dol_print_date($val["date"], 'day'); $date = dol_print_date($val["date"], 'day');
foreach ( $tabttc[$key] as $k => $mt ) { // Third party
foreach ($tabttc[$key] as $k => $mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"';
print "\n";
}
// Product / Service
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
if ($mt) {
print '"' . $key . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print " " . $sep;
print '"' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ; print '"' . $sell_journal . '"';
print "\n"; print "\n";
} }
}
// Product / Service // VAT
foreach ( $tabht[$key] as $k => $mt ) { $listoftax = array(0, 1, 2);
$accountingaccount = new AccountingAccount($db); foreach ($listoftax as $numtax) {
$accountingaccount->fetch(null, $k, true); $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
if ($numtax == 2) $arrayofvat = $tablocaltax2;
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '"' . $key . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep; print " " . $sep;
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep; print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
print '"' . utf8_decode (dol_trunc($companystatic->name, 16) ) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ; print '"' . $sell_journal . '"';
print "\n"; print "\n";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print " " . $sep;
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key]. '"' . $sep;
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ). ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $sell_journal . '"' ;
print "\n";
} }
} }
}
} }
} }
@ -500,13 +532,14 @@ if (empty($action) || $action == 'view') {
$periodlink = ''; $periodlink = '';
$exportlink = ''; $exportlink = '';
$builddate = time(); $builddate = time();
//$description = $langs->trans("DescSellsJournal") . '<br>';
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
else else
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
$listofchoices=array('already'=>$langs->trans("AlreadyInGeneralLedger"), 'notyet'=>$langs->trans("NotYetInGeneralLedger"));
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal; $varlink = 'id_journal=' . $id_journal;
@ -553,6 +586,7 @@ if (empty($action) || $action == 'view') {
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("Label") . "</td>"; print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Credit") . "</td>";
@ -578,7 +612,17 @@ if (empty($action) || $action == 'view') {
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->customer_code = $tabcompany[$key]['code_client'];
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
}
else print $accountoshow;
print '</td>';
// Subledger account
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@ -586,12 +630,10 @@ if (empty($action) || $action == 'view') {
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} }
else print $accountoshow; else print $accountoshow;
// print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
print '</td>'; print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>"; print "</tr>";
} }
@ -605,6 +647,7 @@ if (empty($action) || $action == 'view') {
print "<td><!-- Product --></td>"; print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>"; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>"; print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
// Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@ -613,7 +656,11 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
// print "<td>" . $accountingaccount->label . "</td>"; // Subledger account
print "<td>";
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
@ -622,26 +669,36 @@ if (empty($action) || $action == 'view') {
} }
// VAT // VAT
foreach ( $tabtva[$key] as $k => $mt ) { $listoftax = array(0, 1, 2);
if ($mt) { foreach ($listoftax as $numtax) {
print '<tr class="oddeven">'; $arrayofvat = $tabtva;
print "<td><!-- VAT --></td>"; if ($numtax == 1) $arrayofvat = $tablocaltax1;
print "<td>" . $date . "</td>"; if ($numtax == 2) $arrayofvat = $tablocaltax2;
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>"; foreach ( $arrayofvat[$key] as $k => $mt ) {
$accountoshow = length_accountg($k); if ($mt) {
if (empty($accountoshow) || $accountoshow == 'NotDefined') print '<tr class="oddeven">';
{ print "<td><!-- VAT --></td>";
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>'; print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
// Account
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
print "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
} }
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
print "</td>";
// print "<td>" . $langs->trans("VAT") . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
} }
} }
} }

View File

@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
@ -46,17 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
$langs->load("banks"); $langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy"));
$langs->load("bills");
$langs->load("categories");
$langs->load("companies");
$langs->load("margins");
$langs->load("salaries");
$langs->load("loan");
$langs->load("donations");
$langs->load("trips");
$langs->load("members");
$langs->load("compta");
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref','alpha'); $ref = GETPOST('ref','alpha');
@ -84,6 +75,7 @@ $debit=GETPOST("debit",'alpha');
$credit=GETPOST("credit",'alpha'); $credit=GETPOST("credit",'alpha');
$type=GETPOST("type",'alpha'); $type=GETPOST("type",'alpha');
$account=GETPOST("account",'int'); $account=GETPOST("account",'int');
$accountancy_code=GETPOST('accountancy_code', 'alpha');
$bid=GETPOST("bid","int"); $bid=GETPOST("bid","int");
$search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int'));
$search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int'));
@ -276,11 +268,11 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier)
$amount = - price2num($_POST["adddebit"]); $amount = - price2num($_POST["adddebit"]);
} }
$dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
$operation=$_POST["operation"]; $operation = GETPOST("operation",'alpha');
$num_chq=$_POST["num_chq"]; $num_chq = GETPOST("num_chq",'alpha');
$label=$_POST["label"]; $label = GETPOST("label",'alpha');
$cat1=$_POST["cat1"]; $cat1 = GETPOST("cat1",'alpha');
if (! $dateop) { if (! $dateop) {
$error++; $error++;
@ -290,15 +282,24 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier)
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors');
} }
if (! $label) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors');
}
if (! $amount) { if (! $amount) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
} }
/*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
$error++;
}*/
if (! $error) if (! $error)
{ {
$object->fetch($id); $object->fetch($id);
$insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user); $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code);
if ($insertid > 0) if ($insertid > 0)
{ {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
@ -331,6 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formaccounting = new FormAccounting($db);
$companystatic=new Societe($db); $companystatic=new Societe($db);
$bankaccountstatic=new Account($db); $bankaccountstatic=new Account($db);
@ -365,6 +367,7 @@ if (!empty($debit)) $param.='&debit='.$debit;
if (!empty($credit)) $param.='&credit='.$credit; if (!empty($credit)) $param.='&credit='.$credit;
if (!empty($account)) $param.='&account='.$account; if (!empty($account)) $param.='&account='.$account;
if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve);
if ($search_conciliated != '') $param.='&search_conciliated='.urlencode($search_conciliated);
if (!empty($bid)) $param.='&bid='.$bid; if (!empty($bid)) $param.='&bid='.$bid;
if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int');
if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int');
@ -408,19 +411,32 @@ if ($id > 0 || ! empty($ref))
dol_fiche_end(); dol_fiche_end();
/* /*
* Buttons actions * Buttons actions
*/ */
if ($action != 'reconcile') if ($action != 'reconcile')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
{ {
if ($user->rights->banque->modifier) { if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&accountid='.$account.'">'.$langs->trans("AddBankRecord").'</a>'; {
} else { if ($user->rights->banque->modifier) {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&accountid='.$account.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$account).'">'.$langs->trans("AddBankRecord").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
}
else // If direct entries is not done using miscellaneous payments
{
if ($user->rights->banque->modifier) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param.'">'.$langs->trans("AddBankRecord").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
} }
} }
else else
@ -431,7 +447,7 @@ if ($id > 0 || ! empty($ref))
if ($object->canBeConciliated() > 0) { if ($object->canBeConciliated() > 0) {
// If not cash account and can be reconciliate // If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) { if ($user->rights->banque->consolidate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile'.$param.'">'.$langs->trans("Conciliate").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
} else { } else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>'; print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
} }
@ -637,6 +653,60 @@ if ($resql)
// print '</td></tr></table>'; // print '</td></tr></table>';
} }
// Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline')
{
print load_fiche_titre($langs->trans("AddBankRecordLong"),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>&nbsp;</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Numero").'</td>';
print '<td colspan="2">'.$langs->trans("Description").'</td>';
print '<td align=right>'.$langs->trans("Debit").'</td>';
print '<td align=right>'.$langs->trans("Credit").'</td>';
/*if (! empty($conf->accounting->enabled))
{
print '<td align="center">';
print $langs->trans("AccountAccounting");
print '</td>';
}*/
print '<td colspan="2" align="center">&nbsp;</td>';
print '</tr>';
print '<tr '.$bcnd[false].'>';
print '<td class="nowrap" colspan="2">';
$form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction');
print '</td>';
print '<td class="nowrap">';
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1);
print '</td><td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
print '<td colspan="2">';
print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($options) {
print '<br>'.$langs->trans("Rubrique").': ';
print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
}
print '</td>';
print '<td align="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit").'"></td>';
print '<td align="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST("addcredit").'"></td>';
/*if (! empty($conf->accounting->enabled))
{
print '<td align="center">';
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
print '</td>';
}*/
print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print '</table>';
print '<br>';
}
/// ajax to adjust value date with plus and less picto /// ajax to adjust value date with plus and less picto
print ' print '

View File

@ -39,7 +39,7 @@ class Account extends CommonObject
public $element = 'bank_account'; public $element = 'bank_account';
public $table_element = 'bank_account'; public $table_element = 'bank_account';
public $picto = 'account'; public $picto = 'account';
/** /**
* @var int Use id instead of rowid * @var int Use id instead of rowid
* @deprecated * @deprecated
@ -394,9 +394,10 @@ class Account extends CommonObject
* @param User $user User that create * @param User $user User that create
* @param string $emetteur Name of cheque writer * @param string $emetteur Name of cheque writer
* @param string $banque Bank of cheque writer * @param string $banque Bank of cheque writer
* @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on.
* @return int Rowid of added entry, <0 if KO * @return int Rowid of added entry, <0 if KO
*/ */
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='')
{ {
// Deprecatîon warning // Deprecatîon warning
if (is_numeric($oper)) { if (is_numeric($oper)) {
@ -456,6 +457,7 @@ class Account extends CommonObject
$accline->fk_user_author = $user->id; $accline->fk_user_author = $user->id;
$accline->fk_account = $this->rowid; $accline->fk_account = $this->rowid;
$accline->fk_type = $oper; $accline->fk_type = $oper;
$accline->numero_compte = $accountancycode;
if ($num_chq) { if ($num_chq) {
$accline->num_chq = $num_chq; $accline->num_chq = $num_chq;
@ -538,7 +540,7 @@ class Account extends CommonObject
$now=dol_now(); $now=dol_now();
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (";
$sql.= "datec"; $sql.= "datec";
$sql.= ", ref"; $sql.= ", ref";
@ -619,14 +621,14 @@ class Account extends CommonObject
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
if ($result < 0) $error++; if ($result < 0) $error++;
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('BANKACCOUNT_CREATE',$user); $result=$this->call_trigger('BANKACCOUNT_CREATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
} }
else else
{ {
@ -670,9 +672,9 @@ class Account extends CommonObject
global $langs,$conf, $hookmanager; global $langs,$conf, $hookmanager;
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters
$this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->state_id = ($this->state_id?$this->state_id:$this->state_id);
$this->country_id = ($this->country_id?$this->country_id:$this->country_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id);
@ -739,7 +741,7 @@ class Account extends CommonObject
if ($result < 0) $error++; if ($result < 0) $error++;
} }
} }
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Call trigger // Call trigger
@ -754,7 +756,7 @@ class Account extends CommonObject
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_print_error($this->db); dol_print_error($this->db);
} }
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -906,7 +908,7 @@ class Account extends CommonObject
$this->date_creation = $this->db->jdate($obj->date_creation); $this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_update = $this->db->jdate($obj->date_update); $this->date_update = $this->db->jdate($obj->date_update);
// Retreive all extrafield for thirdparty // Retreive all extrafield for thirdparty
// fetch optionals attributes and labels // fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -983,15 +985,15 @@ class Account extends CommonObject
global $conf; global $conf;
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
// Delete link between tag and bank account // Delete link between tag and bank account
if (! $error) if (! $error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_account = ".$this->id; $sql.= " WHERE fk_account = ".$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql)
{ {
@ -999,15 +1001,15 @@ class Account extends CommonObject
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
} }
} }
if (! $error) if (! $error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
// Remove extrafields // Remove extrafields
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
@ -1020,13 +1022,13 @@ class Account extends CommonObject
} }
} }
} }
else else
{ {
$error++; $error++;
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
} }
} }
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
@ -1433,7 +1435,7 @@ class Account extends CommonObject
* - DeskCode * - DeskCode
* *
* Some countries show less or more bank account properties to the user * Some countries show less or more bank account properties to the user
* *
* @param int $includeibanbic 1=Return also key for IBAN and BIC * @param int $includeibanbic 1=Return also key for IBAN and BIC
* @return array * @return array
* @see useDetailedBBAN * @see useDetailedBBAN
@ -1554,7 +1556,7 @@ class AccountLine extends CommonObject
var $element='bank'; var $element='bank';
var $table_element='bank'; var $table_element='bank';
var $picto = 'generic'; var $picto = 'generic';
var $id; var $id;
var $ref; var $ref;
var $datec; var $datec;
@ -1683,8 +1685,9 @@ class AccountLine extends CommonObject
$sql .= ", num_chq"; $sql .= ", num_chq";
$sql .= ", fk_account"; $sql .= ", fk_account";
$sql .= ", fk_type"; $sql .= ", fk_type";
$sql .= ",emetteur,banque"; $sql .= ", emetteur,banque";
$sql .= ", rappro"; $sql .= ", rappro";
$sql .= ", numero_compte";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'".$this->db->idate($this->datec)."'"; $sql .= "'".$this->db->idate($this->datec)."'";
$sql .= ", '".$this->db->idate($this->dateo)."'"; $sql .= ", '".$this->db->idate($this->dateo)."'";
@ -1698,6 +1701,7 @@ class AccountLine extends CommonObject
$sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null");
$sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null");
$sql .= ", ".(int) $this->rappro; $sql .= ", ".(int) $this->rappro;
$sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''");
$sql .= ")"; $sql .= ")";
dol_syslog(get_class($this)."::insert", LOG_DEBUG); dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@ -1842,7 +1846,7 @@ class AccountLine extends CommonObject
function update_conciliation(User $user, $cat) function update_conciliation(User $user, $cat)
{ {
global $conf; global $conf;
$this->db->begin(); $this->db->begin();
// Check statement field // Check statement field
@ -1854,7 +1858,7 @@ class AccountLine extends CommonObject
return -1; return -1;
} }
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET";
$sql.= " rappro = 1"; $sql.= " rappro = 1";
$sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'";
@ -2042,7 +2046,7 @@ class AccountLine extends CommonObject
return $result; return $result;
} }
/** /**
* Return label of status (activity, closed) * Return label of status (activity, closed)
* *
@ -2053,7 +2057,7 @@ class AccountLine extends CommonObject
{ {
return $this->LibStatut($this->status,$mode); return $this->LibStatut($this->status,$mode);
} }
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
@ -2097,6 +2101,6 @@ class AccountLine extends CommonObject
if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"');
}*/ }*/
} }
} }

View File

@ -325,14 +325,14 @@ class PaymentVarious extends CommonObject
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'".$this->db->idate($this->datep)."'"; $sql.= "'".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", '".$this->sens."'"; $sql.= ", '".$this->db->escape($this->sens)."'";
$sql.= ", ".$this->amount; $sql.= ", ".$this->amount;
$sql.= ", '".$this->type_payment."'"; $sql.= ", '".$this->db->escape($this->type_payment)."'";
$sql.= ", '".$this->num_payment."'"; $sql.= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", '".$this->accountancy_code."'"; $sql.= ", '".$this->db->escape($this->accountancy_code)."'";
$sql.= ", '".$user->id."'"; $sql.= ", ".$user->id;
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
$sql.= ", NULL"; $sql.= ", NULL";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
@ -342,7 +342,6 @@ class PaymentVarious extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various");
if ($this->id > 0) if ($this->id > 0)

View File

@ -122,7 +122,7 @@ if ($action=="dl" && $numref > 0)
{ {
// TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP // TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP
$log = ''; $log = '';
$outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label; $outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label;
$outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers"); $outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers");
$outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers"); $outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers");
@ -130,7 +130,7 @@ if ($action=="dl" && $numref > 0)
dol_mkdir($outdir); dol_mkdir($outdir);
dol_mkdir($outdirinvoices); dol_mkdir($outdirinvoices);
dol_mkdir($outdirsupplierinvoices); dol_mkdir($outdirsupplierinvoices);
//$zipname = $object->label.'-'.$numref . '.zip'; //$zipname = $object->label.'-'.$numref . '.zip';
//$zip = new ZipArchive(); //$zip = new ZipArchive();
//$zip->open($zipname, ZipArchive::OVERWRITE); //$zip->open($zipname, ZipArchive::OVERWRITE);
@ -138,7 +138,7 @@ if ($action=="dl" && $numref > 0)
$sql = $sqlrequestforbankline; $sql = $sqlrequestforbankline;
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
$resd = $db->query($sql); $resd = $db->query($sql);
if ($resd) { if ($resd) {
$numd = $db->num_rows($resd); $numd = $db->num_rows($resd);
@ -146,7 +146,7 @@ if ($action=="dl" && $numref > 0)
if ($numd > 0) if ($numd > 0)
{ {
$objd = $db->fetch_object($resd); $objd = $db->fetch_object($resd);
$log.='Transaction '.$objd->rowid; $log.='Transaction '.$objd->rowid;
$links = $object->get_url($objd->rowid); $links = $object->get_url($objd->rowid);
@ -165,7 +165,7 @@ if ($action=="dl" && $numref > 0)
{ {
$facturestatic->fetch($billid); $facturestatic->fetch($billid);
$subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice'); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice');
$arrayofinclusion=array(); // TODO Find a way to get doc ODT or other $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other
// TODO Use get_exdir // TODO Use get_exdir
$arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/');
@ -202,7 +202,7 @@ if ($action=="dl" && $numref > 0)
{ {
$facturestatic->fetch($billid); $facturestatic->fetch($billid);
$subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier'); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier');
$arrayofinclusion=array(); // TODO Find a way to get doc ODT or other $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other
// TODO Use get_exdir // TODO Use get_exdir
$arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/');
@ -227,7 +227,7 @@ if ($action=="dl" && $numref > 0)
dol_copy($srcfile, $destfile); dol_copy($srcfile, $destfile);
} }
} }
} }
break; break;
case "payment_expensereport": case "payment_expensereport":
/*$subdir = dol_sanitizeFileName($objd->refe); /*$subdir = dol_sanitizeFileName($objd->refe);
@ -246,7 +246,7 @@ if ($action=="dl" && $numref > 0)
} }
} }
$log.="\n"; $log.="\n";
/*if (! empty($upload_dir)) /*if (! empty($upload_dir))
{ {
$files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1);
@ -259,24 +259,24 @@ if ($action=="dl" && $numref > 0)
} else { } else {
$log .= $key . ',' . $langs->trans("Nofile") . "\n"; $log .= $key . ',' . $langs->trans("Nofile") . "\n";
} }
}*/ }*/
} }
} }
$db->free($resd); $db->free($resd);
//$zip->addFromString('log '.$numref.'.csv', $log); //$zip->addFromString('log '.$numref.'.csv', $log);
//$zip->close(); //$zip->close();
// /Then download the zipped file. // /Then download the zipped file.
/*header('Content-Type: application/zip'); /*header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $zipname); header('Content-disposition: attachment; filename=' . $zipname);
header('Content-Length: ' . filesize($zipname)); header('Content-Length: ' . filesize($zipname));
readfile($zipname); readfile($zipname);
exit;*/ exit;*/
} }
@ -329,18 +329,18 @@ if (empty($numref))
dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account'); dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
dol_fiche_end(); dol_fiche_end();
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($object->canBeConciliated() > 0) { if ($object->canBeConciliated() > 0) {
// If not cash account and can be reconciliate // If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) { if ($user->rights->banque->consolidate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile'.$param.'">'.$langs->trans("Conciliate").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile&search_conciliated=0'.$param.'">'.$langs->trans("Conciliate").'</a>';
} else { } else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>'; print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
} }
@ -348,7 +348,7 @@ if (empty($numref))
print '</div>'; print '</div>';
print '<br><br>'; print '<br><br>';
print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows);
@ -481,7 +481,7 @@ else
//$mesprevnext.=' &nbsp; '; //$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>'; $mesprevnext.='<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$mesprevnext.='</ul></div>'; $mesprevnext.='</ul></div>';
$title=$langs->trans("AccountStatement").' '.$numref.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'); $title=$langs->trans("AccountStatement").' '.$numref.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts');
print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png');
//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1);
@ -520,7 +520,7 @@ else
// Recherche les ecritures pour le releve // Recherche les ecritures pour le releve
$sql = $sqlrequestforbankline; $sql = $sqlrequestforbankline;
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
@ -553,7 +553,7 @@ else
print img_edit_add() ."</a>"; print img_edit_add() ."</a>";
print "</td>\n"; print "</td>\n";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">'; print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
// Type and num // Type and num
if ($objp->fk_type == 'SOLD') { if ($objp->fk_type == 'SOLD') {
$type_label='&nbsp;'; $type_label='&nbsp;';
@ -753,9 +753,9 @@ else
print "</tr>\n"; print "</tr>\n";
print "</table>"; print "</table>";
print "</div>"; print "</div>";
print "</form>\n"; print "</form>\n";
// Add a download button // Add a download button
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Started a rewrite to make this feature more Dolibarr compliant. Still need dev to be completed. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Started a rewrite to make this feature more Dolibarr compliant. Still need dev to be completed.
{ {

View File

@ -29,15 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
$langs->load("compta"); $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
$langs->load("banks");
$langs->load("bills"); // Get parameters
$langs->load("users"); $id = GETPOST('id', 'int');
$langs->load("accountancy"); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$id=GETPOST("id",'int');
$action=GETPOST('action','alpha');
$cancel=GETPOST('cancel','alpha');
$accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$label=GETPOST("label","alpha"); $label=GETPOST("label","alpha");
$sens=GETPOST("sens","int"); $sens=GETPOST("sens","int");
@ -61,115 +60,139 @@ $hookmanager->initHooks(array('variouscard','globalcard'));
* Actions * Actions
*/ */
if (! empty($cancel)) $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{ {
header("Location: index.php"); if ($cancel)
exit;
}
if ($action == 'add' && empty($cancel))
{
$error=0;
$datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
$datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
if (empty($datev)) $datev=$datep;
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->datev=$datev;
$object->datep=$datep;
$object->amount=price2num(GETPOST("amount"));
$object->label=GETPOST("label");
$object->note=GETPOST("note");
$object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0;
$object->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id;
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : "";
if (empty($datep) || empty($datev))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); if ($action != 'addlink')
$error++;
}
if (empty($object->type_payment) || $object->type_payment < 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++;
}
if (empty($object->amount))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++;
}
if (! empty($conf->banque->enabled) && ! $object->accountid > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
$error++;
}
if (! $error)
{
$db->begin();
$ret=$object->create($user);
if ($ret > 0)
{ {
$db->commit(); $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1);
header("Location: index.php"); header("Location: ".$urltogo);
exit; exit;
} }
else if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref);
{ $action='';
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action="create";
}
} }
$action='create'; if ($action == 'add')
}
if ($action == 'delete')
{
$result=$object->fetch($id);
if ($object->rappro == 0)
{ {
$db->begin(); $error=0;
$ret=$object->delete($user); $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
if ($ret > 0) $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
if (empty($datev)) $datev=$datep;
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->datev=$datev;
$object->datep=$datep;
$object->amount=price2num(GETPOST("amount"));
$object->label=GETPOST("label");
$object->note=GETPOST("note");
$object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0;
$object->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id;
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : "";
$object->sens=GETPOST('sens');
if (empty($datep) || empty($datev))
{ {
if ($object->fk_bank) $langs->load('errors');
{ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$accountline=new AccountLine($db); $error++;
$result=$accountline->fetch($object->fk_bank); }
if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) if (empty($object->type_payment) || $object->type_payment < 0)
} {
$langs->load('errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++;
}
if (empty($object->amount))
{
$langs->load('errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++;
}
if (! empty($conf->banque->enabled) && ! $object->accountid > 0)
{
$langs->load('errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
$error++;
}
if (! empty($conf->accounting->enabled) && ! $object->accountancy_code)
{
$langs->load('errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
$error++;
}
if ($result >= 0) if (! $error)
{
$db->begin();
$ret=$object->create($user);
if ($ret > 0)
{ {
$db->commit(); $db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); header("Location: index.php");
exit; exit;
} }
else else
{ {
$object->error=$accountline->error; $db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action="create";
}
}
$action='create';
}
if ($action == 'delete')
{
$result=$object->fetch($id);
if ($object->rappro == 0)
{
$db->begin();
$ret=$object->delete($user);
if ($ret > 0)
{
if ($object->fk_bank)
{
$accountline=new AccountLine($db);
$result=$accountline->fetch($object->fk_bank);
if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
if ($result >= 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php');
exit;
}
else
{
$object->error=$accountline->error;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
$db->rollback(); $db->rollback();
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
$db->rollback(); setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else
{
setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
}
} }
@ -200,8 +223,9 @@ if ($id)
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create')
{ {
print '<form name="salary" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png');
@ -269,7 +293,7 @@ if ($action == 'create')
// Accountancy account // Accountancy account
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
print '<td>'; print '<td>';
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
print '</td></tr>'; print '</td></tr>';
@ -292,7 +316,7 @@ if ($action == 'create')
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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
@ -16,9 +17,9 @@
*/ */
/** /**
* \file htdocs/compta/bank/various_payment/index.php * \file htdocs/compta/bank/various_payment/index.php
* \ingroup bank * \ingroup bank
* \brief List of various payments * \brief List of various payments
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';
@ -34,6 +35,8 @@ $socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'banque', '', '', ''); $result = restrictedArea($user, 'banque', '', '', '');
$optioncss = GETPOST('optioncss','alpha');
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$search_ref = GETPOST('search_ref','int'); $search_ref = GETPOST('search_ref','int');
$search_user = GETPOST('search_user','alpha'); $search_user = GETPOST('search_user','alpha');
@ -50,11 +53,10 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortfield) $sortfield="v.datep"; if (! $sortfield) $sortfield="v.datep";
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
$optioncss = GETPOST('optioncss','alpha');
$filtre=$_GET["filtre"]; $filtre=GETPOST("filtre",'alpha');
if (empty($_REQUEST['typeid'])) if (! GETPOST('typeid'))
{ {
$newfiltre=str_replace('filtre=','',$filtre); $newfiltre=str_replace('filtre=','',$filtre);
$filterarray=explode('-',$newfiltre); $filterarray=explode('-',$newfiltre);
@ -66,7 +68,7 @@ if (empty($_REQUEST['typeid']))
} }
else else
{ {
$typeid=$_REQUEST['typeid']; $typeid=GETPOST('typeid');
} }
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
@ -240,9 +242,12 @@ if ($result)
$colspan=4; $colspan=4;
if (! empty($conf->banque->enabled)) $colspan++; if (! empty($conf->banque->enabled)) $colspan++;
print '<tr class="liste_total"><td colspan="'.$colspan.'" class="liste_total">'.$langs->trans("Total").'</td>'; print '<tr class="liste_total">';
print '<td colspan="'.$colspan.'" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total)."</td>"; print '<td class="liste_total" align="right">'.price($total)."</td>";
print "<td></td></tr>"; print '<td></td>';
print '<td></td>';
print '</tr>';
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -54,8 +54,9 @@ if (empty($year))
$year_current = $year; $year_current = $year;
$year_start = $year; $year_start = $year;
} }
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); $date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) );
$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) );
// Quarter // Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{ {
@ -92,12 +93,9 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges'); $result = restrictedArea($user, 'tax', '', '', 'charges');
/**
/*
* View * View
*/ */
$morequerystring=''; $morequerystring='';
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
foreach($listofparams as $param) foreach($listofparams as $param)
@ -118,6 +116,7 @@ $paymentfourn_static=new PaiementFourn($db);
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">'; $fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">'; $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch.=' <input type="hidden" name="localTaxType" value="'.$local.'">';
$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
@ -196,9 +195,8 @@ $total = 0;
$i=0; $i=0;
// Load arrays of datas // Load arrays of datas
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); $x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); $x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy');
echo '<table class="noborder" width="100%">'; echo '<table class="noborder" width="100%">';

View File

@ -44,7 +44,7 @@ $action=GETPOST('action','aZ09');
// Security check // Security check
$socid = GETPOST("socid","int"); $socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'salaries', '', '', 'payment');
$object = new PaymentSalary($db); $object = new PaymentSalary($db);

View File

@ -181,11 +181,12 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
} }
/** /**
* Gets VAT to collect for the given year (and given quarter or month) * Gets Tax to collect for the given year (and given quarter or month)
* The function gets the VAT in split results, as the VAT declaration asks * The function gets the Tax in split results, as the Tax declaration asks
* to report the amounts for different VAT rates as different lines. * to report the amounts for different Tax rates as different lines.
* This function also accounts recurrent invoices. * This function also accounts recurrent invoices.
* *
* @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2'
* @param DoliDB $db Database handler object * @param DoliDB $db Database handler object
* @param int $y Year * @param int $y Year
* @param int $q Quarter * @param int $q Quarter
@ -196,7 +197,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
* @param int $m Month * @param int $m Month
* @return array List of quarters with vat * @return array List of quarters with vat
*/ */
function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
{ {
global $conf; global $conf;
@ -210,8 +211,6 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$fk_facture2='fk_facture'; $fk_facture2='fk_facture';
$fk_payment='fk_paiement'; $fk_payment='fk_paiement';
$total_tva='total_tva'; $total_tva='total_tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$paymenttable='paiement'; $paymenttable='paiement';
$paymentfacturetable='paiement_facture'; $paymentfacturetable='paiement_facture';
$invoicefieldref='facnumber'; $invoicefieldref='facnumber';
@ -224,13 +223,20 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$fk_facture2='fk_facturefourn'; $fk_facture2='fk_facturefourn';
$fk_payment='fk_paiementfourn'; $fk_payment='fk_paiementfourn';
$total_tva='tva'; $total_tva='tva';
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
$paymenttable='paiementfourn'; $paymenttable='paiementfourn';
$paymentfacturetable='paiementfourn_facturefourn'; $paymentfacturetable='paiementfourn_facturefourn';
$invoicefieldref='ref'; $invoicefieldref='ref';
} }
if ( strpos( $type, 'localtax' ) === 0 ) {
$f_rate = $type . '_tx';
} else {
$f_rate = 'tva_tx';
}
$total_localtax1='total_localtax1';
$total_localtax2='total_localtax2';
// CAS DES BIENS // CAS DES BIENS
// Define sql request // Define sql request
@ -238,7 +244,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
{ {
// Count on delivery date (use invoice date as delivery is unknown) // Count on delivery date (use invoice date as delivery is unknown)
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " d.date_start as date_start, d.date_end as date_end,";
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
@ -273,7 +279,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
else // Option vat on delivery for goods (payments) and payments for services else // Option vat on delivery for goods (payments) and payments for services
{ {
// Count on delivery date (use invoice date as delivery is unknown) // Count on delivery date (use invoice date as delivery is unknown)
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " d.date_start as date_start, d.date_end as date_end,";
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,";
@ -378,7 +384,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
{ {
// Count on invoice date // Count on invoice date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " d.date_start as date_start, d.date_end as date_end,";
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
@ -413,7 +419,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
else // Option vat on delivery for goods (payments) and payments for services else // Option vat on delivery for goods (payments) and payments for services
{ {
// Count on payments date // Count on payments date
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
$sql.= " d.date_start as date_start, d.date_end as date_end,"; $sql.= " d.date_start as date_start, d.date_end as date_end,";
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
@ -522,7 +528,7 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql=''; $sql='';
// Count on payments date // Count on payments date
$sql = "SELECT e.rowid, d.product_type as dtype, e.rowid as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; $sql = "SELECT e.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,";
$sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, ";
$sql.= " e.date_debut as date_start, e.date_fin as date_end,"; $sql.= " e.date_debut as date_start, e.date_fin as date_end,";
$sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, s.nom as company_name, s.rowid as company_id, d.fk_c_type_fees as type,"; $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, s.nom as company_name, s.rowid as company_id, d.fk_c_type_fees as type,";
@ -622,3 +628,24 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
return $list; return $list;
} }
/**
* Gets VAT to collect for the given year (and given quarter or month)
* The function gets the VAT in split results, as the VAT declaration asks
* to report the amounts for different VAT rates as different lines.
* This function also accounts recurrent invoices.
*
* @param DoliDB $db Database handler object
* @param int $y Year
* @param int $q Quarter
* @param string $date_start Start date
* @param string $date_end End date
* @param int $modetax 0 or 1 (option vat on debit)
* @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices)
* @param int $m Month
* @return array List of quarters with vat
*/
function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
{
return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m);
}

View File

@ -193,9 +193,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/don/stats/index.php?leftmenu=donations&amp;mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/don/stats/index.php?leftmenu=donations&amp;mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__);
-- Special expenses -- Special expenses
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&amp;mainmenu=accountancy', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read)', '', 0, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&amp;mainmenu=accountancy', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read)', '', 0, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&amp;mainmenu=accountancy', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&amp;mainmenu=accountancy', 'Salaries', 1, 'salaries', '$user->rights->salaries->payment->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&amp;action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&amp;action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->payment->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'accountancy', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->payment->read', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'accountancy', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/index.php?leftmenu=tax_loan&amp;mainmenu=accountancy', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'accountancy', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/index.php?leftmenu=tax_loan&amp;mainmenu=accountancy', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/loan/card.php?leftmenu=tax_loan&amp;action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/loan/card.php?leftmenu=tax_loan&amp;action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__);
--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); --insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'accountancy', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__);

View File

@ -904,9 +904,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if (! empty($conf->salaries->enabled)) if (! empty($conf->salaries->enabled))
{ {
$langs->load("salaries"); $langs->load("salaries");
$newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&amp;mainmenu=accountancy",$langs->trans("Salaries"),1,$user->rights->salaries->read, '', $mainmenu, 'tax_salary'); $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&amp;mainmenu=accountancy",$langs->trans("Salaries"),1,$user->rights->salaries->payment->read, '', $mainmenu, 'tax_salary');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->write); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->payment->write);
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->payment->read);
} }
// Loan // Loan
@ -993,7 +993,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql.= " WHERE entity = ".$conf->entity; $sql.= " WHERE entity = ".$conf->entity;
$sql.= " AND active = 1"; $sql.= " AND active = 1";
$sql.= " ORDER BY label"; $sql.= " ORDER BY label DESC";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -1119,8 +1119,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
// Journaux // Journaux
//if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report",$langs->trans("SellsJournal"),1,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report",$langs->trans("SellsJournal"),1,$user->rights->compta->resultat->lire, '', '', '', 50);
if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report",$langs->trans("PurchasesJournal"),1,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report",$langs->trans("PurchasesJournal"),1,$user->rights->compta->resultat->lire, '', '', '', 51);
} }
} }

View File

@ -1141,7 +1141,26 @@ class pdf_crabe extends ModelePDFFactures
} }
//} //}
// VAT // VAT
// Situations totals migth be wrong on huge amounts
if ($object->situation_cycle_ref && $object->situation_counter > 1) {
$sum_pdf_tva = 0;
foreach($this->tva as $tvakey => $tvaval){
$sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
}
if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
foreach($this->tva as $tvakey => $tvaval) {
$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
}
}
}
foreach($this->tva as $tvakey => $tvaval) foreach($this->tva as $tvakey => $tvaval)
{ {
if ($tvakey != 0) // On affiche pas taux 0 if ($tvakey != 0) // On affiche pas taux 0

View File

@ -3,7 +3,7 @@
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* 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

View File

@ -96,12 +96,14 @@ class modFournisseur extends DolibarrModules
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
/* For supplier invoice, we must not have default pdf template on. In most cases, we need to join PDF from supplier, not have a document generated.
$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF"; $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "canelle"; $this->const[$r][2] = "canelle";
$this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF'; $this->const[$r][3] = 'Nom du gestionnaire de generation des factures fournisseur en PDF';
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
*/
$this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER"; $this->const[$r][0] = "INVOICE_SUPPLIER_ADDON_NUMBER";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
@ -272,12 +274,12 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][5] = 'approve2'; $this->rights[$r][5] = 'approve2';
} }
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
//-------- //--------
$r=0; $r=0;

View File

@ -48,7 +48,7 @@ class modSalaries extends DolibarrModules
global $conf; global $conf;
$this->db = $db; $this->db = $db;
$this->numero = 510; $this->numero = 510; // Perms from 501..519
$this->family = "hr"; $this->family = "hr";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
@ -97,7 +97,7 @@ class modSalaries extends DolibarrModules
$r=0; $r=0;
$r++; $r++;
$this->rights[$r][0] = 511; $this->rights[$r][0] = 501;
$this->rights[$r][1] = 'Read employee contracts/salaries'; $this->rights[$r][1] = 'Read employee contracts/salaries';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
@ -105,21 +105,29 @@ class modSalaries extends DolibarrModules
$this->rights[$r][5] = ''; $this->rights[$r][5] = '';
$r++; $r++;
$this->rights[$r][0] = 512; $this->rights[$r][0] = 502;
$this->rights[$r][1] = 'Create/modify employee contracts/salaries'; $this->rights[$r][1] = 'Create/modify employee contracts/salaries';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'write'; $this->rights[$r][4] = 'write';
$this->rights[$r][5] = ''; $this->rights[$r][5] = '';
$r++; $r++;
$this->rights[$r][0] = 513; $this->rights[$r][0] = 511;
$this->rights[$r][1] = 'Read payment of salaries';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'payment';
$this->rights[$r][5] = 'read';
$r++;
$this->rights[$r][0] = 512;
$this->rights[$r][1] = 'Create/modify payment of salaries'; $this->rights[$r][1] = 'Create/modify payment of salaries';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'write'; $this->rights[$r][4] = 'payment';
$this->rights[$r][5] = ''; $this->rights[$r][5] = 'write';
$r++; $r++;
$this->rights[$r][0] = 514; $this->rights[$r][0] = 514;
$this->rights[$r][1] = 'Delete contracts/salaries'; $this->rights[$r][1] = 'Delete contracts/salaries';
@ -140,8 +148,8 @@ class modSalaries extends DolibarrModules
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
//-------- //--------
$r=0; $r=0;

View File

@ -420,7 +420,7 @@ class ExpenseReport extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id";
if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'"; if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'";
else $sql.= " WHERE d.rowid = ".$id; else $sql.= " WHERE d.rowid = ".$id;
$sql.= $restrict; //$sql.= $restrict;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql) ; $resql = $this->db->query($sql) ;

View File

@ -135,7 +135,7 @@ CREATE TABLE llx_product_lot_extrafields
ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object); ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object);
ALTER TABLE llx_website_page MODIFY content MEDIUMTEXT; ALTER TABLE llx_website_page MODIFY COLUMN content MEDIUMTEXT;
CREATE TABLE llx_product_warehouse_properties CREATE TABLE llx_product_warehouse_properties
( (
@ -161,7 +161,7 @@ ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (accou
ALTER TABLE llx_expensereport_det ADD COLUMN fk_code_ventilation integer DEFAULT 0; ALTER TABLE llx_expensereport_det ADD COLUMN fk_code_ventilation integer DEFAULT 0;
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr tinyint;
ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx;
@ -174,11 +174,10 @@ ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT
ALTER TABLE llx_supplier_proposaldet ADD COLUMN fk_unit integer DEFAULT NULL; ALTER TABLE llx_supplier_proposaldet ADD COLUMN fk_unit integer DEFAULT NULL;
ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx;
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr TINYINT;
ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT 0; ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT 0;
create table llx_resource_extrafields create table llx_resource_extrafields
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
@ -207,6 +206,8 @@ ALTER TABLE llx_overwrite_trans ADD COLUMN entity integer DEFAULT 1 NOT NULL AFT
ALTER TABLE llx_mailing_cibles ADD COLUMN error_text varchar(255); ALTER TABLE llx_mailing_cibles ADD COLUMN error_text varchar(255);
ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL;
-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET DEFAULT 'system';
-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET NOT NULL;
create table llx_user_employment create table llx_user_employment
( (
@ -241,12 +242,12 @@ ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_refuse (fk_user_app
DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm); DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm);
-- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate. -- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate.
drop table tmp_links_double; DROP TABLE tmp_links_double;
--select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2; --select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2;
create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2); CREATE TABLE tmp_links_double AS (SELECT objectid, label, MAX(rowid) AS max_rowid, COUNT(rowid) AS count_rowid FROM llx_links WHERE label IS NOT NULL GROUP BY objectid, label HAVING COUNT(rowid) >= 2);
--select * from tmp_links_double; --select * from tmp_links_double;
delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_links_double); --update to avoid duplicate, delete to delete DELETE FROM llx_links WHERE (rowid, label) IN (SELECT max_rowid, label FROM tmp_links_double); --update to avoid duplicate, delete to delete
drop table tmp_links_double; DROP TABLE tmp_links_double;
ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label);
@ -257,8 +258,7 @@ ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity);
ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer; ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer;
UPDATE llx_accounting_account SET account_parent = 0 WHERE account_parent = '';
UPDATE llx_accounting_account set account_parent = 0 where account_parent = '';
-- VMYSQL4.3 ALTER TABLE llx_product_price MODIFY COLUMN date_price DATETIME NULL; -- VMYSQL4.3 ALTER TABLE llx_product_price MODIFY COLUMN date_price DATETIME NULL;
-- VPGSQL8.2 ALTER TABLE llx_product_price ALTER COLUMN date_price DROP NOT NULL; -- VPGSQL8.2 ALTER TABLE llx_product_price ALTER COLUMN date_price DROP NOT NULL;
@ -269,10 +269,8 @@ ALTER TABLE llx_product_customer_price ADD COLUMN default_vat_code varchar(10) a
ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10) after tva_tx; ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10) after tva_tx;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx; ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx;
ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); ALTER TABLE llx_events MODIFY COLUMN ip varchar(250);
UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur';
UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client';

View File

@ -122,6 +122,8 @@ ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255);
ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255);
ALTER TABLE llx_bank ADD COLUMN numero_compte varchar(32) NULL;
-- VMYSQL4.1 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer DEFAULT NULL; -- VMYSQL4.1 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer DEFAULT NULL;
-- VPGSQL8.2 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer; -- VPGSQL8.2 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer;

View File

@ -20,3 +20,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte);
ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal);
-- TODO Add a key for unicity

View File

@ -32,6 +32,7 @@ create table llx_bank
fk_type varchar(6), -- TIP,VIR,PRE,CB,CHQ,... (Code in llx_c_paiement) fk_type varchar(6), -- TIP,VIR,PRE,CB,CHQ,... (Code in llx_c_paiement)
num_releve varchar(50), num_releve varchar(50),
num_chq varchar(50), num_chq varchar(50),
numero_compte varchar(32) NULL, -- FEC:CompteNum | account number
rappro tinyint default 0, rappro tinyint default 0,
note text, note text,
fk_bordereau integer DEFAULT 0, fk_bordereau integer DEFAULT 0,

View File

@ -28,7 +28,14 @@ OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accoun
OtherInfo=Other information OtherInfo=Other information
DeleteCptCategory=Remove accounting account from group DeleteCptCategory=Remove accounting account from group
ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group ? ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group ?
JournalizationInLedgerStatus=Status of journalization
AlreadyInGeneralLedger=Already journalized in ledgers AlreadyInGeneralLedger=Already journalized in ledgers
NotYetInGeneralLedger=Not yet journalized in ledgers
MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup
MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup
MainAccountForUsersNotDefined=Main accounting account for users not defined in setup
MainAccountForVatPaymentNotDefined=Main accounting account for VAT payment not defined in setup
AccountancyArea=Accountancy area AccountancyArea=Accountancy area
AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: AccountancyAreaDescIntro=Usage of the accountancy module is done in several step:
@ -45,7 +52,7 @@ AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for
AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s. AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s.
AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s. AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s.
AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s. AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s.
AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. AccountancyAreaDescMisc=STEP %s: Define mandatory default account and default accounting accounts for miscellaneous transactions. For this, use the menu entry %s.
AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s. AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s.
AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s.
AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s.
@ -83,7 +90,7 @@ ValidTransaction=Validate transaction
WriteBookKeeping=Journalize transactions in Ledger WriteBookKeeping=Journalize transactions in Ledger
Bookkeeping=Ledger Bookkeeping=Ledger
AccountBalance=Account balance AccountBalance=Account balance
ObjectsRef=Source object ref
CAHTF=Total purchase supplier before tax CAHTF=Total purchase supplier before tax
TotalExpenseReport=Total expense report TotalExpenseReport=Total expense report
InvoiceLines=Lines of invoices to bind InvoiceLines=Lines of invoices to bind
@ -154,7 +161,7 @@ DelBookKeeping=Delete record of the Ledger
FinanceJournal=Finance journal FinanceJournal=Finance journal
ExpenseReportsJournal=Expense reports journal ExpenseReportsJournal=Expense reports journal
DescFinanceJournal=Finance journal including all the types of payments by bank account DescFinanceJournal=Finance journal including all the types of payments by bank account
DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger. DescJournalOnlyBindedVisible=This is a view of record that are bound to accountancy account and can be recorded into the Ledger.
VATAccountNotDefined=Account for VAT not defined VATAccountNotDefined=Account for VAT not defined
ThirdpartyAccountNotDefined=Account for third party not defined ThirdpartyAccountNotDefined=Account for third party not defined
ProductAccountNotDefined=Account for product not defined ProductAccountNotDefined=Account for product not defined
@ -170,6 +177,8 @@ AddCompteFromBK=Add accounting accounts to the group
ReportThirdParty=List third party account ReportThirdParty=List third party account
DescThirdPartyReport=Consult here the list of the third party customers and suppliers and their accounting accounts DescThirdPartyReport=Consult here the list of the third party customers and suppliers and their accounting accounts
ListAccounts=List of the accounting accounts ListAccounts=List of the accounting accounts
UnknownAccountForThirdparty=Unknown third party account. We will use %s
UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error
Pcgtype=Class of account Pcgtype=Class of account
Pcgsubtype=Subclass of account Pcgsubtype=Subclass of account

View File

@ -584,7 +584,7 @@ Module50100Desc=Point of sales module (POS).
Module50200Name=Paypal Module50200Name=Paypal
Module50200Desc=Module to offer an online payment page by credit card with Paypal Module50200Desc=Module to offer an online payment page by credit card with Paypal
Module50400Name=Accounting (advanced) Module50400Name=Accounting (advanced)
Module50400Desc=Accounting management (double entries) Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers)
Module54000Name=PrintIPP Module54000Name=PrintIPP
Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installe on server). Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installe on server).
Module55000Name=Poll, Survey or Vote Module55000Name=Poll, Survey or Vote
@ -750,8 +750,10 @@ Permission401=Read discounts
Permission402=Create/modify discounts Permission402=Create/modify discounts
Permission403=Validate discounts Permission403=Validate discounts
Permission404=Delete discounts Permission404=Delete discounts
Permission510=Read Salaries Permission501=Read employee contracts/salaries
Permission512=Create/modify salaries Permission502=Create/modify employee contracts/salaries
Permission511=Read payment of salaries
Permission512=Create/modify payment of salaries
Permission514=Delete salaries Permission514=Delete salaries
Permission517=Export salaries Permission517=Export salaries
Permission520=Read Loans Permission520=Read Loans

View File

@ -151,7 +151,7 @@ CheckRejectedAndInvoicesReopened=Check returned and invoices reopened
BankAccountModelModule=Document templates for bank accounts BankAccountModelModule=Document templates for bank accounts
DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only. DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only.
DocumentModelBan=Template to print a page with BAN information. DocumentModelBan=Template to print a page with BAN information.
NewVariousPayment=New miscellaneous payment NewVariousPayment=New miscellaneous payments
VariousPayment=Miscellaneous payment VariousPayment=Miscellaneous payments
VariousPayments=Miscellaneous payments VariousPayments=Miscellaneous payments
ShowVariousPayment=Show miscellaneous payment ShowVariousPayment=Show miscellaneous payments

View File

@ -191,9 +191,9 @@ ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - V
ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup)
ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT
ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties
ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accouting account on third party is not defined.
ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties
ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined.
CloneTax=Clone a social/fiscal tax CloneTax=Clone a social/fiscal tax
ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment
CloneTaxForNextMonth=Clone it for next month CloneTaxForNextMonth=Clone it for next month

View File

@ -1,6 +1,6 @@
# Dolibarr language file - Source file is en_US - salaries # Dolibarr language file - Source file is en_US - salaries
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Dedicated accounting account defined on user card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated user accouting account on user is not defined SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined.
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses
Salary=Salary Salary=Salary
Salaries=Salaries Salaries=Salaries

View File

@ -258,10 +258,11 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject"))); print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject")));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
dol_fiche_head(); dol_fiche_head(array(), '');
print '<table class="border centpercent">'."\n"; print '<table class="border centpercent">'."\n";
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
@ -277,7 +278,7 @@ if ($action == 'create')
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="add" value="'.$langs->trans("Create").'"> &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>'; print '<div class="center"><input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'"> &nbsp; <input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"></div>';
print '</form>'; print '</form>';
} }

View File

@ -511,7 +511,8 @@ if (empty($reshook))
$error = 0; $error = 0;
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef=''; $predef='';
$ref_fourn = GETPOST('fourn_ref');
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
$date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
@ -599,7 +600,7 @@ if (empty($reshook))
$price_base_type = $productsupplier->fourn_price_base_type; $price_base_type = $productsupplier->fourn_price_base_type;
$type = $productsupplier->type; $type = $productsupplier->type;
$label = $productsupplier->label; $label = $productsupplier->label;
$desc = $productsupplier->description; $desc = $productsupplier->description;
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));

View File

@ -2797,6 +2797,7 @@ class SupplierProposalLine extends CommonObjectLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0;
if (empty($this->fk_unit)) $this->fk_unit=0; if (empty($this->fk_unit)) $this->fk_unit=0;
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
@ -2981,6 +2982,7 @@ class SupplierProposalLine extends CommonObjectLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0;
if (empty($this->fk_unit)) $this->fk_unit=0; if (empty($this->fk_unit)) $this->fk_unit=0;
if (empty($this->subprice)) $this->subprice=0;
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;

View File

@ -46,8 +46,17 @@ $cancel = GETPOST('cancel','alpha');
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0) $socid = $user->societe_id;
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); $feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
if ($user->id == $id) $feature2=''; // A user can always read its own card // Ok if user->rights->salaries->read or user->rights->salaries->payment->write or user->rights->hrm->read
$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2);
$ok=false;
if ($user->id == $id) $ok=true; // A user can always read its own card
if ($user->rights->salaries->read) $ok=true;
if ($user->rights->salaries->payment->write) $ok=true;
if ($user->rights->hrm->read) $ok=true;
if (! $ok)
{
accessforbidden();
}
$object = new User($db); $object = new User($db);
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
@ -61,6 +70,42 @@ if ($id > 0 || ! empty($ref))
* Actions * Actions
*/ */
if ($action == 'add' && ! $cancel)
{
// Modification
$account = new UserBankAccount($db);
$account->userid = $object->id;
$account->bank = $_POST["bank"];
$account->label = $_POST["label"];
$account->courant = $_POST["courant"];
$account->clos = $_POST["clos"];
$account->code_banque = $_POST["code_banque"];
$account->code_guichet = $_POST["code_guichet"];
$account->number = $_POST["number"];
$account->cle_rib = $_POST["cle_rib"];
$account->bic = $_POST["bic"];
$account->iban = $_POST["iban"];
$account->domiciliation = $_POST["domiciliation"];
$account->proprio = $_POST["proprio"];
$account->owner_address = $_POST["owner_address"];
$result = $account->create($user);
if (! $result)
{
setEventMessages($account->error, $account->errors, 'errors');
$action='edit'; // Force chargement page edition
}
else
{
$url=DOL_URL_ROOT.'/user/bank.php?id='.$object->id.'&bankid='.$bankid;
header('Location: '.$url);
exit;
}
}
if ($action == 'update' && ! $cancel) if ($action == 'update' && ! $cancel)
{ {
// Modification // Modification
@ -122,7 +167,7 @@ else
if (empty($account->userid)) $account->userid=$object->id; if (empty($account->userid)) $account->userid=$object->id;
if ($bankid && $action == 'edit' && $user->rights->user->user->creer) if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer)
{ {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -130,7 +175,7 @@ if ($bankid && $action == 'edit' && $user->rights->user->user->creer)
print '<input type="hidden" name="id" value="'.GETPOST("id",'int').'">'; print '<input type="hidden" name="id" value="'.GETPOST("id",'int').'">';
print '<input type="hidden" name="bankid" value="'.$bankid.'">'; print '<input type="hidden" name="bankid" value="'.$bankid.'">';
} }
if ($bankid && $action == 'create' && $user->rights->user->user->creer) if ($id && $action == 'create' && $user->rights->user->user->creer)
{ {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -140,7 +185,7 @@ if ($bankid && $action == 'create' && $user->rights->user->user->creer)
// View // View
if ($account->id && $action != 'edit') if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty
{ {
$title = $langs->trans("User"); $title = $langs->trans("User");
dol_fiche_head($head, 'bank', $title, -1, 'user'); dol_fiche_head($head, 'bank', $title, -1, 'user');
@ -150,24 +195,25 @@ if ($account->id && $action != 'edit')
if ($user->rights->user->user->lire || $user->admin) { if ($user->rights->user->user->lire || $user->admin) {
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
} }
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr><td class="titlefield">'.$langs->trans("xxx").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
print '<td></td></tr>'; print '<td>'.$object->login.'</td>';
print '</tr>';
print '</table>'; print '</table>';
print '</br>'; print '</br>';
print load_fiche_titre($langs->trans("BAN")); print load_fiche_titre($langs->trans("BAN"));
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
@ -237,7 +283,7 @@ if ($account->id && $action != 'edit')
} }
print "</div>"; print "</div>";
dol_fiche_end(); dol_fiche_end();
/* /*
@ -247,24 +293,27 @@ if ($account->id && $action != 'edit')
if ($user->rights->user->user->creer) if ($user->rights->user->user->creer)
{ {
if ($account->id > 0)
print '<a class="butAction" href="bank.php?id='.$object->id.'&bankid='.$account->id.'&action=edit">'.$langs->trans("Edit").'</a>'; print '<a class="butAction" href="bank.php?id='.$object->id.'&bankid='.$account->id.'&action=edit">'.$langs->trans("Edit").'</a>';
else
print '<a class="butAction" href="bank.php?id='.$object->id.'&bankid='.$account->id.'&action=create">'.$langs->trans("Create").'</a>';
} }
print '</div>'; print '</div>';
} }
// Edit // Edit
if ($id && $action == 'edit' && $user->rights->user->user->creer) if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer)
{ {
$title = $langs->trans("User"); $title = $langs->trans("User");
dol_fiche_head($head, 'bank', $title, 0, 'user'); dol_fiche_head($head, 'bank', $title, 0, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback,$user->rights->user->user->lire || $user->admin); dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
//print '<div class="fichecenter">'; //print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
@ -323,7 +372,7 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer)
print '</table>'; print '</table>';
//print '</div>'; //print '</div>';
dol_fiche_end(); dol_fiche_end();
print '<div align="center">'; print '<div align="center">';
@ -334,7 +383,9 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer)
} }
if ($id && $action == 'edit' && $user->rights->user->user->creer) print '</form>'; if ($id && $action == 'edit' && $user->rights->user->user->creer) print '</form>';
if ($id && $action == 'create' && $user->rights->user->user->creer) print '</form>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -73,7 +73,8 @@ class UserBankAccount extends Account
if ($this->db->affected_rows($resql)) if ($this->db->affected_rows($resql))
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib");
return 1;
return $this->update($user);
} }
} }
else else

View File

@ -104,7 +104,7 @@ function migrate_product_photospath($product)
global $conf; global $conf;
$dir = $conf->product->multidir_output[$product->entity]; $dir = $conf->product->multidir_output[$product->entity];
$origin = $dir .'/'. get_exdir($product->id,2) . $product->id ."/photos"; $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
$destin = $dir.'/'.dol_sanitizeFileName($product->ref); $destin = $dir.'/'.dol_sanitizeFileName($product->ref);
$error = 0; $error = 0;