Integrate module Accounting Expert

This commit is contained in:
aspangaro 2014-08-27 07:03:42 +02:00
parent c3fe0c1ae9
commit 71265558d2
47 changed files with 9309 additions and 437 deletions

View File

@ -0,0 +1,220 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/admin/account.php
* \ingroup Accounting Expert
* \brief List accounting account
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/accountingex/class/accountingaccount.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("compta");
$langs->load("accountingex@accountingex");
$mesg = '';
$action = GETPOST('action');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$limit = $conf->liste_limit;
$page = GETPOST("page", 'int');
if ($page == - 1) {
$page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
$sortfield = "aa.account_number";
if (! $sortorder)
$sortorder = "ASC";
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
$accounting = new AccountingAccount($db);
if ($action == 'disable') {
$accounting = $accounting->fetch($id);
if (! empty($accounting->id)) {
$result = $accounting->account_desactivate($id);
}
$action = 'update';
if ($result < 0) {
setEventMessage($accounting->error, 'errors');
}
} else if ($action == 'enable') {
$accounting = $accounting->fetch($id);
if (! empty($accounting->id)) {
$result = $accounting->account_activate($id);
}
$action = 'update';
if ($result < 0) {
setEventMessage($accounting->error, 'errors');
}
}
/*
* View
*
*/
llxHeader('', $langs->trans("ListAccounts"));
$pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa, " . MAIN_DB_PREFIX . "accounting_system as asy";
$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver;
if (strlen(trim($_GET["search_account"]))) {
$sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'";
}
if (strlen(trim($_GET["search_label"]))) {
$sql .= " AND aa.label like '%" . $_GET["search_label"] . "%'";
}
if (strlen(trim($_GET["search_accountparent"]))) {
$sql .= " AND aa.account_parent like '%" . $_GET["search_accountparent"] . "%'";
}
if (strlen(trim($_GET["search_pcgtype"]))) {
$sql .= " AND aa.pcg_type like '%" . $_GET["search_pcgtype"] . "%'";
}
if (strlen(trim($_GET["search_pcgsubtype"]))) {
$sql .= " AND aa.pcg_subtype like '%" . $_GET["search_pcgsubtype"] . "%'";
}
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountingex/admin/account.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
$i = 0;
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
print '<br/>';
print '<a class="butAction" href="./fiche.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
print '<br/><br/>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountNumber"), "account.php", "aa.account_number", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), "account.php", "aa.label", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Accountparent"), "account.php", "aa.account_parent", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Pcgtype"), "account.php", "aa.pcg_type", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Pcgsubtype"), "account.php", "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Active"), "account.php", "aa.active", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("&nbsp;");
print '</tr>';
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . GETPOST("search_accountparent") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . GETPOST("search_pcgtype") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . GETPOST("search_pcgsubtype") . '"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</tr>';
$var = True;
while ( $i < min($num, $limit) ) {
$obj = $db->fetch_object($resql);
$var = ! $var;
print '<tr ' . $bc[$var] . '>';
print '<td><a href="./fiche.php?id=' . $obj->rowid . '">' . $obj->account_number . '</td>';
print '<td>' . $obj->label . '</td>';
print '<td>' . $obj->account_parent . '</td>';
print '<td>' . $obj->pcg_type . '</td>';
print '<td>' . $obj->pcg_subtype . '</td>';
print '<td>';
if (empty($obj->active)) {
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
print '<td>';
if ($user->rights->accountingex->admin) {
print '<a href="./fiche.php?action=update&id=' . $obj->rowid . '">';
print img_edit();
print '</a>&nbsp;';
print '<a href="./fiche.php?action=delete&id=' . $obj->rowid . '">';
print img_delete();
print '</a>';
}
print '</td>' . "\n";
print "</tr>\n";
$i ++;
}
print "</table>";
print '</form>';
} else {
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -0,0 +1,176 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountingex/admin/export.php
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/admin.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$langs->load("compta");
$langs->load("bills");
$langs->load('admin');
$langs->load('accountingex@accountingex');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
// Other parameters ACCOUNTINGEX_*
$list = array (
'ACCOUNTINGEX_SEPARATORCSV'
);
/*
* Actions
*/
if ($action == 'update') {
$error = 0;
$modelcsv = GETPOST('modelcsv', 'int');
if (! empty($modelcsv)) {
if (! dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
foreach ( $list as $constname ) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
if (! $error) {
setEventMessage($langs->trans("SetupSaved"));
} else {
setEventMessage($langs->trans("Error"), 'errors');
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head(null);
dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
$var = True;
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
print '</tr>';
$var = ! $var;
print '<tr ' . $bc[$var] . '>';
print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
print "<td>";
print '<select class="flat" name="modelcsv" id="modelcsv">';
print '<option value="0"';
if ($conf->global->ACCOUNTINGEX_MODELCSV == 0) {
print ' selected="selected"';
}
print '>' . $langs->trans("Modelcsv_normal") . '</option>';
print '<option value="1"';
if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) {
print ' selected="selected"';
}
print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
print "</select>";
print "</td></tr>";
print "</table>";
print "<br>\n";
/*
* Params
*
*/
$list = array (
'ACCOUNTINGEX_SEPARATORCSV'
);
$num = count($list);
if ($num) {
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
}
foreach ( $list as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td>' . $label . '</td>';
// Value
print '<td>';
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}
print '</form>';
print "</table>\n";
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,297 @@
<?PHP
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/admin/fiche.php
* \ingroup Accounting Expert
* \brief Page fiche de compte
*/
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/accountingex/class/accountingaccount.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("bills");
$langs->load("accountingex@accountingex");
$mesg = '';
$action = GETPOST('action');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
$accounting = new AccountingAccount($db);
// action
if ($action == 'add') {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
$result = $db->query($sql);
$obj = $db->fetch_object($result);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->pcg_type = GETPOST('pcg_type');
$accounting->pcg_subtype = GETPOST('pcg_subtype');
$accounting->account_number = GETPOST('account_number', 'int');
$accounting->account_parent = GETPOST('account_parent', 'int');
$accounting->label = GETPOST('label', 'alpha');
$accounting->active = 1;
$res = $accounting->create($user);
if ($res == 0) {
} else {
if ($res == - 3) {
$_error = 1;
$action = "create";
}
if ($res == - 4) {
$_error = 2;
$action = "create";
}
}
Header("Location: account.php");
} elseif ($action == 'edit') {
if (! GETPOST('cancel', 'alpha')) {
$result = $accounting->fetch($id);
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
$result2 = $db->query($sql);
$obj = $db->fetch_object($result2);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->pcg_type = GETPOST('pcg_type');
$accounting->pcg_subtype = GETPOST('pcg_subtype');
$accounting->account_number = GETPOST('account_number', 'int');
$accounting->account_parent = GETPOST('account_parent', 'int');
$accounting->label = GETPOST('label', 'alpha');
$result = $accounting->update($user);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
} else {
$mesg = $object->error;
}
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
}
} else if ($action == 'delete') {
$result = $accounting->fetch($id);
if (! empty($accounting->id)) {
$result = $accounting->delete($user);
if ($result > 0) {
Header("Location: account.php");
}
}
if ($result < 0) {
setEventMessage($accounting->error, 'errors');
}
}
/*
* View
*
*/
llxheader('', $langs->trans('AccountAccounting'));
$form = new Form($db);
$htmlacc = new FormVentilation($db);
if ($action == 'create') {
print_fiche_titre($langs->trans('NewAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td>';
print $htmlacc->select_account($accounting->account_parent, 'account_parent');
print '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>';
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
print '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
print '</td></tr>';
print '</table>';
print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> &nbsp; &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center';
print '</form>';
} else if ($id) {
$rowid = $id;
$account = $accounting->fetch($rowid);
if ($account > 0) {
dol_htmloutput_mesg($mesg);
$head = account_prepare_head($accounting);
if ($action == 'update') {
// WYSIWYG Editor
$htmlacc = new FormVentilation($db);
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
$soc = new Societe($db);
if ($object->socid) {
$soc->fetch($object->socid);
}
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="edit">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<table class="border" width="100%">';
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td>';
print $htmlacc->select_account($accounting->account_parent, 'account_parent');
print '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>';
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
print '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
print '</td></tr>';
print '</table>';
print '<br><center><input type="submit" class="button" value="' . $langs->trans("Save") . '"> &nbsp; ';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '</center>';
print '</form>';
print '</div>';
} else {
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<table class="border" width="100%">';
// Account number
print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
print '<td>' . $accounting->account_number . '</td>';
print '<td align="right" width="25%">' . $linkback . '</td></tr>';
print '<tr><td>' . $langs->trans("Label") . '</td>';
print '<td colspan="2">' . $accounting->label . '</td></tr>';
$accp = new AccountingAccount($db);
if (! empty($accounting->account_parent)) {
$accp->fetch($accounting->account_parent, '');
}
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
print '<tr><td>' . $langs->trans("Active") . '</td>';
print '<td colspan="2">';
if (empty($accounting->active)) {
print img_picto($langs->trans("Disabled"), 'switch_off');
} else {
print img_picto($langs->trans("Activated"), 'switch_on');
}
print '</td></tr>';
print '</table>';
print '</div>';
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($user->rights->accountingex->admin) {
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
} else {
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
}
if ($user->rights->accountingex->admin) {
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
} else {
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
}
print '</div>';
}
} else {
dol_print_error($db);
}
}
llxFooter();
$db->close();

View File

@ -0,0 +1,197 @@
<?php
/*
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@fidurex.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* \file htdocs/compta/accountingex/liste.php
* \ingroup compta
* \brief Page IMPORT COMPTE COMPTABLE
*/
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/accountingex/class/accountingaccount.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// langs
$langs->load("compta");
$langs->load("bills");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
llxHeader('', $langs->trans("ImportAccount"));
$to_import = GETPOST("mesCasesCochees");
if ($_POST["action"] == 'import') {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (is_array($to_import) && count($to_import) > 0) {
print '<div><font color="red">' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
$result = $db->query($sql);
if ($result && ($db->num_rows($result) > 0)) {
$obj = $db->fetch_object($result);
$cpt = 0;
foreach ( $to_import as $maLigneCochee ) {
$accounting = new AccountingAccount($db);
$monLabel = GETPOST('intitule' . $maLigneCochee);
$monParentAccount = GETPOST('AccountParent' . $maLigneCochee);
$monType = GETPOST('pcgType' . $maLigneCochee);
$monSubType = GETPOST('pcgSubType' . $maLigneCochee);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->account_number = $maLigneCochee;
$accounting->label = $monLabel;
$accounting->account_parent = $monParentAccount;
$accounting->pcg_type = $monType;
$accounting->pcg_subtype = $monSubType;
$accounting->active = 1;
$result = $accounting->create($user);
if ($result > 0) {
setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs');
} else {
setEventMessage($accounting->error, 'errors');
}
$cpt ++;
}
} else {
setEventMessage($langs->trans('AccountPlanNotFoundCheckSetting'), 'errors');
}
} else {
print '<div><font color="red">' . $langs->trans("AnyLineImport") . '</font></div>';
}
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
/*
* list accounting account from product
*
*/
$page = GETPOST("page");
if ($page < 0)
$page = 0;
$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION;
$offset = $limit * $page;
$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
$sql .= " WHERE p.accountancy_code_sell >=0";
$sql .= " GROUP BY accounting ";
$sql .= ")";
$sql .= "UNION ALL(SELECT p.rowid as product_id, p.accountancy_code_buy as accounting ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
$sql .= " WHERE p.accountancy_code_buy >=0";
$sql .= " GROUP BY accounting ";
$sql .= ") ";
$sql .= " ORDER BY accounting DESC " . $db->plimit($limit + 1, $offset);
dol_syslog('accountingex/admin/importaccounts.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
print_barre_liste($langs->trans("ImportAccount"), $page, "importaccounts.php", "", $sortfield, $sortorder, '', $num_lignes);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>' . $langs->trans("accountingaccount") . '</td>';
print '<td>' . $langs->trans("label") . '</td>';
print '<td>' . $langs->trans("parentaccount") . '</td>';
print '<td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td align="center">' . $langs->trans("Import") . '</td>';
print '</tr>';
$form = new Form($db);
$htmlacc = new FormVentilation($db);
print '<form action="importaccounts.php" method="post">' . "\n";
print '<input type="hidden" name="action" value="import">';
$var = True;
while ( $i < min($num_lignes, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
print "<tr $bc[$var]>";
print '<td align="left">';
print $objp->accounting;
print '</td>';
print '<td align="left">';
print '<input name="intitule" size="70" value="">';
print '</td>';
// Colonne choix du compte
print '<td>';
print $htmlacc->select_account($accounting->account_parent, 'AccountParent');
print '</td>';
print '<td>';
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcgType');
print '</td>';
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcgSubType');
print '</td>';
// Colonne choix ligne a ventiler
$checked = ('intitule' == 'O') ? ' checked=checked' : '';
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" ' . $checked . ' value="' . $objp->accounting . '"/>';
print '</td>';
print '</tr>';
$i ++;
}
print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="' . $langs->trans("Import") . '"></td></tr>';
print '</table>';
print '</form>';
} else {
print $db->error();
}
llxFooter();
$db->close();

View File

View File

@ -0,0 +1,301 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountingex/admin/index.php
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/admin.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$langs->load("compta");
$langs->load("bills");
$langs->load('admin');
$langs->load('accountingex@accountingex');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
// Other parameters COMPTA_* & ACCOUNTINGEX_*
$list = array (
'ACCOUNTINGEX_LIMIT_LIST_VENTILATION',
'ACCOUNTINGEX_LENGTH_GACCOUNT',
'ACCOUNTINGEX_LENGTH_AACCOUNT',
'COMPTA_ACCOUNT_CUSTOMER',
'COMPTA_ACCOUNT_SUPPLIER',
'COMPTA_PRODUCT_BUY_ACCOUNT',
'COMPTA_PRODUCT_SOLD_ACCOUNT',
'COMPTA_SERVICE_BUY_ACCOUNT',
'COMPTA_SERVICE_SOLD_ACCOUNT',
'ACCOUNTINGEX_ACCOUNT_SUSPENSE',
'ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH'
);
/*
* Actions
*/
$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
if ($action == 'update')
{
$error = 0;
$compta_modes = array(
'RECETTES-DEPENSES',
'CREANCES-DETTES'
);
$compta_mode = GETPOST('compta_mode','alpha');
if (in_array($compta_mode,$compta_modes)) {
if (!dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error++;
}
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
} else {
setEventMessage($langs->trans("Error"), 'mesgs');
}
}
if ($action == 'setlistsortdone') {
$setlistsortdone = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
} else {
setEventMessage($langs->trans("Error"), 'mesgs');
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head($accounting);
dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
// Cas du parametre COMPTA_MODE
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
print "</tr>\n";
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
// Write info on way to count VAT
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
//{
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
//}
//else
//{
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
//}
print "</td></tr>\n";
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
print '</form>';
print "</table>\n";
print "<br>\n";
/*
* Define Chart of accounts
*/
print '<table class="noborder" width="100%">';
$var = True;
print '<tr class="liste_titre">';
print '<td colspan="3">';
print $langs->trans("Chartofaccounts") . '</td>';
print "</tr>\n";
$var = ! $var;
print '<tr ' . $bc[$var] . '>';
print "<td>" . $langs->trans("Selectchartofaccounts") . "</td>";
print "<td>";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT rowid, pcg_version, fk_pays, label, active";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " WHERE active = 1";
$sql .= " AND fk_pays = " . $mysoc->country_id;
dol_syslog('accountingex/admin/index.php:: $sql=' . $sql);
$resql = $db->query($sql);
$var = True;
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ( $i < $num ) {
$var = ! $var;
$row = $db->fetch_row($resql);
print '<option value="' . $row[0] . '"';
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected="selected"' : '';
print '>' . $row[1] . ' - ' . $row[3] . '</option>';
$i ++;
}
}
print "</select>";
print "</td></tr>";
print "</table>";
print "<br>\n";
/*
* Others params
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
foreach ($list as $key)
{
$var=!$var;
print '<tr '.$bc[$var].' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="'.$key.'">'.$label.'</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td></tr>';
}
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO") . '</td>';
if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE") . '</td>';
if (! empty($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '</form>';
print "</table>\n";
print '<br /><br /><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
llxFooter();
$db->close();

View File

@ -0,0 +1,176 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountingex/admin/journaux.php
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/admin.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/core/lib/bank.lib.php");
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load('accountingex@accountingex');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
// Other parameters ACCOUNTINGEX_*
$list = array (
'ACCOUNTINGEX_SELL_JOURNAL',
'ACCOUNTINGEX_PURCHASE_JOURNAL',
'ACCOUNTINGEX_SOCIAL_JOURNAL',
'ACCOUNTINGEX_CASH_JOURNAL',
'ACCOUNTINGEX_MISCELLANEOUS_JOURNAL'
);
/*
* Actions
*/
if ($action == 'update') {
$error = 0;
foreach ( $list as $constname ) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
if (! $error) {
setEventMessage($langs->trans("SetupSaved"));
} else {
setEventMessage($langs->trans("Error"), 'errors');
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head(null);
dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron');
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('Journaux') . '</td>';
print "</tr>\n";
foreach ( $list as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="' . $key . '">' . $label . '</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}
print '</form>';
print "</table>\n";
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<br />';
// Bank account
$sql = "SELECT ba.rowid, ba.ref , ba.label, ba.bank , ba.account_number, ba.code_journal ";
$sql .= " FROM ".MAIN_DB_PREFIX."lx_bank_account as ba";
$sql .= " WHERE ba.clos = 0" ;
$sql .= " ORDER BY label";
dol_syslog('accountingex/admin/journaux.php:: $sql='.$sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('JournauxTresorerie') . '</td>';
print "</tr>\n";
$form2 = new Form($db);
$account = new Account($db);
foreach ( $resql as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="' . $key . '">' . $label . '</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}
print '</table>';
print '</div>';
print '<br>';
llxFooter();
$db->close();

View File

@ -0,0 +1,149 @@
<?PHP
/*
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@fidurex.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/admin/productaccount.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
dol_include_once("/product/class/product.class.php");
$langs->load("companies");
$langs->load("compta");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
llxHeader('', $langs->trans("Accounts"));
$form = new Form($db);
print '<input type="button" class="button" style="float: right;" value="Renseigner les comptes comptables produits manquant" onclick="launch_export();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell as codesell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1";
dol_syslog('accountingex/admin/productaccount.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
/*
* view
*/
print '<br><br>';
print '<table class="noborder" width="100%">';
print '<td align="left">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("Label") . '</td>';
print '<td align="left">' . $langs->trans("Description") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
$var = True;
while ( $i < min($num, 250) ) {
$obj = $db->fetch_object($resql);
$var = ! $var;
$compta_prodsell = $obj->accountancy_code_sell;
if (empty($compta_prodsell)) {
if ($obj->product_type == 0)
$compta_prodsell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
else
$compta_prodsell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
}
$compta_prodbuy = $obj->accountancy_code_buy;
if (empty($compta_prodbuy)) {
if ($obj->product_type == 0)
$compta_prodbuy = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
else
$compta_prodbuy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
}
$product_static = new Product($db);
print "<tr $bc[$var]>";
// Ref produit
$product_static->ref = $objp->p . ref;
$product_static->id = $objp->rowid;
$product_static->type = $objp->type;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
print '<td align="left">' . $obj->ref . '</td>';
print '<td align="left">' . $obj->label . '</td>';
print '<td align="left">' . $obj->description . '</td>';
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
print '<td align="left">' . $compta_prodbuy . '</td>';
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
print '<td align="left">' . $compta_prodsell . '</td>';
print "</tr>\n";
$i ++;
}
print "</table>";
$db->free($resql);
} else {
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -0,0 +1,253 @@
<?PHP
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@fidurex.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/admin/thirdpartyaccount.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
$langs->load("companies");
$langs->load("compta");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->admin)
accessforbidden();
// Date range
$year = GETPOST("year");
if (empty($year)) {
$year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now());
$year_start = $year_current;
} else {
$year_current = $year;
$month_current = strftime("%m", dol_now());
$year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q = GETPOST("q") ? GETPOST("q") : 0;
if ($q == 0) {
// We define date_start and date_end
$year_end = $year_start;
$month_start = GETPOST("month") ? GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (! GETPOST('month')) {
if (! GETPOST("year") && $month_start > $month_current) {
$year_start --;
$year_end --;
}
$month_end = $month_start - 1;
if ($month_end < 1)
$month_end = 12;
else
$year_end ++;
} else
$month_end = $month_start;
$date_start = dol_get_first_day($year_start, $month_start, false);
$date_end = dol_get_last_day($year_end, $month_end, false);
}
if ($q == 1) {
$date_start = dol_get_first_day($year_start, 1, false);
$date_end = dol_get_last_day($year_start, 3, false);
}
if ($q == 2) {
$date_start = dol_get_first_day($year_start, 4, false);
$date_end = dol_get_last_day($year_start, 6, false);
}
if ($q == 3) {
$date_start = dol_get_first_day($year_start, 7, false);
$date_end = dol_get_last_day($year_start, 9, false);
}
if ($q == 4) {
$date_start = dol_get_first_day($year_start, 10, false);
$date_end = dol_get_last_day($year_start, 12, false);
}
} else {
}
llxHeader();
$form = new Form($db);
$nomlink = '';
$periodlink = '';
$exportlink = '';
$nom = $langs->trans("ReportThirdParty");
$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);
$description = $langs->trans("DescThirdPartyReport");
$builddate = time();
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
$sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta as compta , ";
$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country ";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "facture as f";
$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND s.fk_pays = cp.rowid";
if (! empty($date_start) && ! empty($date_end))
$sql .= " AND f.datec >= '" . $db->idate($date_start) . "' AND f.datec <= '" . $db->idate($date_end) . "'";
$sql .= " AND f.entity = " . $conf->entity;
if ($socid)
$sql .= " AND f.fk_soc = " . $socid;
$sql .= " GROUP BY name";
$sql .= ")";
$sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta_fournisseur as compta , ";
$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country ";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as ff";
$sql .= ", " . MAIN_DB_PREFIX . "c_country as cp";
$sql .= " WHERE ff.fk_soc = s.rowid";
$sql .= " AND s.fk_pays = cp.rowid";
if (! empty($date_start) && ! empty($date_end))
$sql .= " AND ff.datec >= '" . $db->idate($date_start) . "' AND ff.datec <= '" . $db->idate($date_end) . "'";
$sql .= " AND ff.entity = " . $conf->entity;
if ($socid)
$sql .= " AND f.fk_soc = " . $socid;
$sql .= " GROUP BY name";
$sql .= ")";
$sql .= "ORDER BY name ASC";
dol_syslog('accountingex/admin/thirdpartyaccount.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
// export csv
if (GETPOST('action') == 'export_csv') {
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=export_csv.csv');
$obj = $db->fetch_object($resql);
$var = ! $var;
print '"' . $obj->compta . '",';
print '"' . $obj->address . '",';
print '"' . $obj->zip . '",';
print '"' . $obj->town . '",';
print '"' . $obj->country . '",';
print '"' . $obj->phone . '",';
print '"' . $obj->fax . '",';
print "\n";
$i ++;
}
/*
* View
*/
$thirdpartystatic = new Societe($db);
print '<br><br>';
print '<table class="noborder" width="100%">';
print "</table>\n";
print '</td><td valign="top" width="70%" class="notopnoleftnoright"></td>';
print '</tr><tr><td colspan=2>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td align="left">' . $langs->trans("ThirdParties") . '</td>';
print '<td align="left">' . $langs->trans("AccountNumber") . '</td>';
print '<td align="left">' . $langs->trans("RaisonSociale") . '</td>';
print '<td align="left">' . $langs->trans("Address") . '</td>';
print '<td align="left">' . $langs->trans("Zip") . '</td>';
print '<td align="left">' . $langs->trans("Town") . '</td>';
print '<td align="left">' . $langs->trans("Country") . '</td>';
print '<td align="left">' . $langs->trans("Contact") . '</td>';
print '<td align="left">' . $langs->trans("Phone") . '</td>';
print '<td align="left">' . $langs->trans("Fax") . '</td></tr>';
$var = True;
while ( $obj = $db->fetch_object($resql) ) {
$var = ! $var;
print "<tr $bc[$var]>";
print '<td>';
$thirdpartystatic->id = $obj->rowid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->client = $obj->client;
$thirdpartystatic->canvas = $obj->canvas;
$thirdpartystatic->status = $obj->status;
print $thirdpartystatic->getNomUrl(1);
print '</td>';
print '<td align="left">' . $obj->compta . '</td>' . "\n";
print '<td align="left"></td>';
print '<td align="left">' . $obj->address . '</td>';
print '<td align="left">' . $obj->zip . '</td>';
print '<td align="left">' . $obj->town . '</td>';
print '<td align="left">' . $obj->country . '</td>';
print '<td align="left"></td>';
print '<td align="left">' . $obj->phone . '</td>';
print '<td align="left">' . $obj->fax . '</td>';
print "</tr>\n";
$i ++;
}
print "</table>";
$db->free($resql);
} else {
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -0,0 +1,143 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/bookkeeping/balancebymonth.php
* \ingroup Accounting Expert
* \brief Balance by month
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/date.lib.php");
dol_include_once("accountingex/core/lib/account.lib.php");
// Langs
$langs->load("main");
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("accountingex@accountingex");
// Filter
$year = $_GET["year"];
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
/*
* View
*/
llxHeader('', $langs->trans("CustomersVentilation"));
$textprevyear = "<a href=\"balancebymonth.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
$textnextyear = " <a href=\"balancebymonth.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
print_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear);
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
dol_syslog('accountingex/bookkeeping/balancebymonth.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
$nbfac = $row[0];
$db->free($result);
}
$y = $year_current;
$var = true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width=150>' . $langs->trans("Intitule") . '</td><td align="center">' . $langs->trans("JanuaryMin") . '</td><td align="center">' . $langs->trans("FebruaryMin") . '</td><td align="center">' . $langs->trans("MarchMin") . '</td><td align="center">' . $langs->trans("AprilMin") . '</td><td align="center">' . $langs->trans("MayMin") . '</td><td align="center">' . $langs->trans("JuneMin") . '</td><td align="center">' . $langs->trans("JulyMin") . '</td><td align="center">' . $langs->trans("AugustMin") . '</td><td align="center">' . $langs->trans("SeptemberMin") . '</td><td align="center">' . $langs->trans("OctoberMin") . '</td><td align="center">' . $langs->trans("NovemberMin") . '</td><td align="center">' . $langs->trans("DecemberMin") . '</td><td align="center"><b>Total</b></td></tr>';
$sql = "SELECT bk.numero_compte AS 'compte',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk";
$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " GROUP BY bk.numero_compte";
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td width="14%">' . length_accountg($row[0]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[1]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[2]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[3]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[4]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[5]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[6]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[7]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[8]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[9]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[10]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[11]) . '</td>';
print '<td align="right" width="6.5%">' . price($row[12]) . '</td>';
print '<td align="right" width="8%"><b>' . price($row[13]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror();
}
print "</table>\n";
llxFooter();
$db->close();

View File

@ -0,0 +1,385 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/bookkeeping/fiche.php
* \ingroup Accounting Expert
* \brief Page to show account
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("accountingex/class/bookkeeping.class.php");
// Langs
$langs->load("accountingex@accountingex");
// Security check
$id = GETPOST('id', 'int');
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$action = GETPOST('action');
$piece_num = GETPOST("piece_num");
$mesg = '';
$numero_compte = GETPOST('numero_compte');
$code_tiers = GETPOST('code_tiers');
$label_compte = GETPOST('label_compte');
$debit = price2num(GETPOST('debit'));
$credit = price2num(GETPOST('credit'));
if ($action == "confirm_update") {
$error = 0;
if ((intval($debit) != 0) && (intval($credit) != 0)) {
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
$error ++;
}
if (empty($error)) {
$book = new BookKeeping($db);
$result = $book->fetch($id);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
$book->numero_compte = $numero_compte;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
$book->debit = $debit;
$book->credit = $credit;
if (! empty($debit)) {
$book->montant = $debit;
$book->sens = 'D';
}
if (! empty($credit)) {
$book->montant = $credit;
$book->sens = 'C';
}
$result = $book->update();
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
setEventMessage($langs->trans('Saved'), 'mesgs');
$action = '';
}
}
}
}
else if ($action == "add") {
$error = 0;
if ((intval($debit) != 0) && (intval($credit) != 0)) {
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
$error ++;
}
if (empty($error)) {
$book = new BookKeeping($db);
$book->numero_compte = $numero_compte;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
$book->debit = $debit;
$book->credit = $credit;
$book->doc_date = GETPOST('doc_date');
$book->doc_type = GETPOST('doc_type');
$book->piece_num = $piece_num;
$book->doc_ref = GETPOST('doc_ref');
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = GETPOST('fk_doc');
$book->fk_docdet = GETPOST('fk_docdet');
if (! empty($debit)) {
$book->montant = $debit;
$book->sens = 'D';
}
if (! empty($credit)) {
$book->montant = $credit;
$book->sens = 'C';
}
$result = $book->create_std($user);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
setEventMessage($langs->trans('Saved'), 'mesgs');
$action = '';
}
}
}
else if ($action == "confirm_delete") {
$book = new BookKeeping($db);
$result = $book->fetch($id);
$piece_num = $book->piece_num;
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
$result = $book->delete($user);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
}
}
$action = '';
}
else if ($action == "confirm_create") {
$book = new BookKeeping($db);
$book->label_compte = '';
$book->debit = 0;
$book->credit = 0;
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
$book->doc_type = GETPOST('doc_type');
$book->piece_num = GETPOST('next_num_mvt');
$book->doc_ref = GETPOST('doc_ref');
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = 0;
$book->fk_docdet = 0;
$book->montant = 0;
$result = $book->create_std($user);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
setEventMessage($langs->trans('Saved'), 'mesgs');
$action = '';
$piece_num = $book->piece_num;
}
}
llxHeader();
$html = new Form($db);
$nbligne = 0;
/*
* Confirmation to delete the command
*/
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
if ($action == 'create') {
print_fiche_titre($langs->trans("CreateMvts"));
$code_journal_array = array (
$conf->global->ACCOUNTINGEX_SELL_JOURNAL => $conf->global->ACCOUNTINGEX_SELL_JOURNAL,
$conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL => $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL,
$conf->global->ACCOUNTINGEX_BANK_JOURNAL => $conf->global->ACCOUNTINGEX_BANK_JOURNAL,
$conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL => $conf->global->ACCOUNTINGEX_SOCIAL_JOURNAL
);
$book = new BookKeeping($db);
$next_num_mvt = $book->next_num_mvt();
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="post">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<table class="border" width="100%">';
print '<tr class="pair">';
print '<td>' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $next_num_mvt . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<td>' . $langs->trans("Docdate") . '</td>';
print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>';
print '</tr>';
print '<tr class="pair">';
print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
print '</tr>';
print '<tr class="pair">';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
print '</tr>';
print '</table>';
print '<br>';
print '<input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
print '</form>';
} else {
$book = new BookKeeping($db);
$result = $book->fetch_per_mvt($piece_num);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
}
if (! empty($book->piece_num)) {
print_fiche_titre($langs->trans("UpdateMvts"));
print '<table class="border" width="100%">';
print '<tr class="pair">';
print '<td>' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $book->piece_num . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<td>' . $langs->trans("Docdate") . '</td>';
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>';
print '</tr>';
print '<tr class="pair">';
print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $book->code_journal . '</td>';
print '</tr>';
print '<tr class="impair">';
print '<td>' . $langs->trans("Docref") . '</td>';
print '<td>' . $book->doc_ref . '</td>';
print '</tr>';
print '<tr class="pair">';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td>' . $book->doc_type . '</td>';
print '</tr>';
print '</table>';
$result = $book->fetch_all_per_mvt($piece_num);
if ($result < 0) {
setEventMessage($book->errors, 'errors');
} else {
print_fiche_titre($langs->trans("ListeMvts"));
print "<table class=\"noborder\" width=\"100%\">";
if (count($book->linesmvt) > 0) {
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Numerocompte"));
print_liste_field_titre($langs->trans("Code_tiers"));
print_liste_field_titre($langs->trans("Labelcompte"));
print_liste_field_titre($langs->trans("Debit"));
print_liste_field_titre($langs->trans("Credit"));
print_liste_field_titre($langs->trans("Amount"));
print_liste_field_titre($langs->trans("Sens"));
print '<td></td>';
print "</tr>\n";
foreach ( $book->linesmvt as $line ) {
$var = ! $var;
print "<tr $bc[$var]>";
if ($action == 'update' && $line->id == $id) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
print '<input type="hidden" name="action" value="confirm_update">' . "\n";
print '<td><input type="text" size="6" name="numero_compte" value="' . $line->numero_compte . '"/></td>';
print '<td><input type="text" size="15" name="code_tiers" value="' . $line->code_tiers . '"/></td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
print '<td><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
print '<td>' . $line->montant . '</td>';
print '<td>' . $line->sens . '</td>';
print '<td>';
if ($user->rights->accountingex->access) {
print '<input type="submit" class="button" value="' . $langs->trans("Update") . '">';
}
print '</form>';
print '</td>';
} else {
print '<td>' . $line->numero_compte . '</td>';
print '<td>' . $line->code_tiers . '</td>';
print '<td>' . $line->label_compte . '</td>';
print '<td>' . $line->debit . '</td>';
print '<td>' . $line->credit . '</td>';
print '<td>' . $line->montant . '</td>';
print '<td>' . $line->sens . '</td>';
print '<td>';
if ($user->rights->accoutingex->access) {
print '<a href="./fiche.php?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
print img_edit();
print '</a>&nbsp;';
print '<a href="./fiche.php?action=delete&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
print img_delete();
print '</a>';
}
print '</td>';
}
print "</tr>\n";
}
if ($action == "" || $action == 'add') {
$var = ! $var;
print "<tr $bc[$var]>";
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="action" value="add">' . "\n";
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
print '<input type="hidden" name="doc_ref" value="' . $book->doc_ref . '">' . "\n";
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
print '<td><input type="text" size="6" name="numero_compte" value="' . $numero_compte . '"/></td>';
print '<td><input type="text" size="15" name="code_tiers" value="' . $code_tiers . '"/></td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
print '<td><input type="text" size="6" name="debit" value="' . price($debit) . '"/></td>';
print '<td><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
print '<td></td>';
print '<td></td>';
print '<td><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
print '</tr>';
}
print "</table>";
}
}
} else {
print_fiche_titre($langs->trans("NoRecords"));
}
}
llxFooter();
$db->close();

View File

@ -0,0 +1,226 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/bookkeeping/liste.php
* \ingroup Accounting Expert
* \brief List operation of book keeping
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/accountingex/class/html.formventilation.class.php");
dol_include_once("/accountingex/class/bookkeeping.class.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha');
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "bk.rowid";
$offset = $conf->liste_limit * $page;
$formventilation = new FormVentilation($db);
/*
* Action
*/
if ($action == 'delbookkeeping') {
$import_key = GETPOST('importkey', 'alpha');
if (! empty($import_key)) {
$object = new BookKeeping($db);
$result = $object->delete_by_importkey($import_key);
Header("Location: liste.php");
if ($result < 0) {
setEventMessage($object->errors, 'errors');
}
}
} // export csv
else if ($action == 'export_csv') {
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=export_csv.csv');
$object = new BookKeeping($db);
$result = $object->export_bookkeping('ebp');
if ($result < 0) {
setEventMessage($object->errors, 'errors');
}
foreach ( $object->linesexport as $line ) {
print $line->id . ',';
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
print '"' . $line->code_journal . '",';
print '"' . $line->numero_compte . '",';
print '"' . substr($line->code_journal, 0, 2) . '",';
print '"' . substr($line->doc_ref, 0, 40) . '",';
print '"' . $line->num_piece . '",';
print '"' . $line->montant . '",';
print '"' . $line->sens . '",';
print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
print '"' . $conf->currency . '",';
print "\n";
}
}
else {
llxHeader('', $langs->trans("Accounting") . ' - ' . $langs->trans("Bookkeeping"));
/*
* List
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk";
if (dol_strlen(trim(GETPOST("search_doc_type")))) {
$sql .= " WHERE bk.doc_type LIKE '%" . GETPOST("search_doc_type") . "%'";
if (dol_strlen(trim(GETPOST("search_doc_ref")))) {
$sql .= " AND bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'";
}
}
if (dol_strlen(trim(GETPOST("search_doc_ref")))) {
$sql .= " WHERE bk.doc_ref LIKE '%" . GETPOST("search_doc_ref") . "%'";
}
if (dol_strlen(trim(GETPOST("search_compte")))) {
$sql .= " WHERE bk.numero_compte LIKE '%" . GETPOST("search_compte") . "%'";
}
if (dol_strlen(trim(GETPOST("search_tiers")))) {
$sql .= " WHERE bk.code_tiers LIKE '%" . GETPOST("search_tiers") . "%'";
}
if (dol_strlen(trim(GETPOST("search_journal")))) {
$sql .= " WHERE bk.code_journal LIKE '%" . GETPOST("search_journal") . "%'";
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset);
dol_syslog('accountingex/bookkeeping/liste.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste($langs->trans("Bookkeeping"), $page, "liste.php", "", $sortfield, $sortorder, '', $num);
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="delbookkeeping">';
print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey'));
print '<div class="inline-block divButAction"><input type="submit" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
print '</form>';
print '<a href="./fiche.php?action=create" class="butAction">Nouveau mouvement comptable</a>';
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="export_csv">';
print '<input type="submit" class="button" style="float: right;" value="Export CSV" />';
print '</form>';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("&nbsp;");
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="liste.php" method="GET">';
print '<td><input type="text" name="search_doc_type" value="' . $_GET["search_doc_type"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td><input type="text" name="search_doc_ref" value="' . $_GET["search_doc_ref"] . '"></td>';
print '<td><input type="text" name="search_compte" value="' . $_GET["search_compte"] . '"></td>';
print '<td><input type="text" name="search_tiers" value="' . $_GET["search_tiers"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td><input type="text" name="search_journal" size="3" value="' . $_GET["search_journal"] . '"></td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</form>';
print '</tr>';
$var = True;
while ( $i < min($num, $conf->liste_limit) ) {
$obj = $db->fetch_object($resql);
$var = ! $var;
print "<tr $bc[$var]>";
print '<td>' . $obj->doc_type . '</td>';
print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . length_accountg($obj->numero_compte) . '</td>';
print '<td>' . length_accounta($obj->code_tiers) . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td align="right">' . price($obj->debit) . '</td>';
print '<td align="right">' . price($obj->credit) . '</td>';
print '<td align="right">' . price($obj->montant) . '</td>';
print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td><a href="./fiche.php?piece_num=' . $obj->piece_num . '">' . img_edit() . '</a></td>';
print "</tr>\n";
$i ++;
}
print "</table>";
$db->free($resql);
} else {
dol_print_error($db);
}
}
llxFooter();
$db->close();

View File

@ -0,0 +1,137 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/bookkeeping/listebyyear.php
* \ingroup Accounting Expert
* \brief Book keeping by year
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/date.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Langs
$langs->load("accountingex@accountingex");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
// Filter
$year = GETPOST("year", 'int');
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "bk.rowid";
$offset = $conf->liste_limit * $page;
llxHeader('', $langs->trans("Bookkeeping"));
$textprevyear = "<a href=\"listebyyear.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
$textnextyear = " <a href=\"listebyyear.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
/*
* Mode Liste
*
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens, bk.code_journal";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping as bk";
// $sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y,1,false))."'";
// $sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y,12,false))."'";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset);
dol_syslog('accountingex/bookkeeping/listebyyear.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste($langs->trans("Bookkeeping") . " $textprevyear " . $langs->trans("Year") . " $year_start $textnextyear", $page, $_SERVER['PHP_SELF'], "", $sortfield, $sortorder, '', $num);
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder);
print_liste_field_titre("&nbsp;");
print "</tr>\n";
$var = True;
while ( $i < min($num, $conf->liste_limit) ) {
$obj = $db->fetch_object($resql);
$var = ! $var;
print "<tr $bc[$var]>";
print '<td>' . $obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date($db->jdate($obj->doc_date)) . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . length_accountg($obj->numero_compte) . '</td>';
print '<td>' . length_accounta($obj->code_tiers) . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td align="right">' . price($obj->debit) . '</td>';
print '<td align="right">' . price($obj->credit) . '</td>';
print '<td align="right">' . price($obj->montant) . '</td>';
print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td><a href="./fiche.php?action=update&id=' . $obj->rowid . '">' . img_edit() . '</a></td>';
print "</tr>\n";
$i ++;
}
print "</table>";
$db->free($resql);
} else {
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -1,5 +1,7 @@
<?php
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
@ -16,20 +18,18 @@
*/
/**
* \file htdocs/accountancy/class/accountancysystem.class.php
* \ingroup accounting
* \brief File of class to manage accountancy systems
* \file accountingex/class/accountancysystem.class.php
* \ingroup Accounting Expert
* \brief File of class to manage accountancy systems
*/
/** \class AccountancySystem
* \brief Classe to manage accountancy systems
/**
* \class AccountancySystem
* \brief Classe to manage accountancy systems
*/
class AccountancySystem
{
class AccountancySystem {
var $db;
var $error;
var $rowid;
var $fk_pcg_version;
var $pcg_type;
@ -37,58 +37,48 @@ class AccountancySystem
var $label;
var $account_number;
var $account_parent;
/**
* Constructor
* Constructor
*
* @param DoliDB $db Database handler
* @param DoliDB $db handler
*/
function __construct($db)
{
function __construct($db) {
$this->db = $db;
}
/**
* Insert accountancy system name into database
* Insert accountancy system name into database
*
* @param User $user User making insert
* @return int <0 if KO, Id of line if OK
* @param User $user making insert
* @return int if KO, Id of line if OK
*/
function create($user)
{
$now=dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
$sql.= " (date_creation, fk_user_author, numero,intitule)";
$sql.= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->numero."','".$this->intitule."')";
function create($user) {
$now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
$sql .= " (date_creation, fk_user_author, numero,intitule)";
$sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->intitule . "')";
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system");
if ($id > 0)
{
if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system");
if ($id > 0) {
$this->id = $id;
$result = $this->id;
}
else
{
$result = -2;
$this->error="AccountancySystem::Create Erreur $result";
} else {
$result = - 2;
$this->error = "AccountancySystem::Create Erreur $result";
dol_syslog($this->error, LOG_ERR);
}
}
else
{
$result = -1;
$this->error="AccountancySystem::Create Erreur $result";
} else {
$result = - 1;
$this->error = "AccountancySystem::Create Erreur $result";
dol_syslog($this->error, LOG_ERR);
}
return $result;
}
}
}

View File

@ -0,0 +1,416 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/class/Accountingaccount.class.php
* \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable
*/
/**
* \class AccountingAccount
* \brief Classe permettant la gestion des comptes generaux de compta
*/
class AccountingAccount {
var $db;
var $id;
var $rowid;
var $datec; // Creation date
var $fk_pcg_version;
var $pcg_type;
var $pcg_subtype;
var $account_number;
var $account_parent;
var $label;
var $fk_user_author;
var $fk_user_modif;
var $active;
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* \param id id compte (0 par defaut)
*/
function __construct($db, $rowid = '') {
$this->db = $db;
if ($rowid != '')
return $this->fetch($rowid);
}
/**
* \brief Load record in memory
*/
function fetch($rowid = null, $account_number = null) {
if ($rowid || $account_number) {
$sql = "SELECT * FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE ";
if ($rowid) {
$sql .= " rowid = '" . $rowid . "'";
} elseif ($account_number) {
$sql .= " account_number = '" . $account_number . "'";
}
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
} else {
return null;
}
}
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->datec = $obj->datec;
$this->tms = $obj->tms;
$this->fk_pcg_version = $obj->fk_pcg_version;
$this->pcg_type = $obj->pcg_type;
$this->pcg_subtype = $obj->pcg_subtype;
$this->account_number = $obj->account_number;
$this->account_parent = $obj->account_parent;
$this->label = $obj->label;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active;
return $obj->rowid;
}
/**
* \brief insert line in accountingaccount
* \param user utilisateur qui effectue l'insertion
*/
function create($user, $notrigger = 0) {
global $conf, $langs;
$error = 0;
// Clean parameters
if (isset($this->fk_pcg_version))
$this->fk_pcg_version = trim($this->fk_pcg_version);
if (isset($this->pcg_type))
$this->pcg_type = trim($this->pcg_type);
if (isset($this->pcg_subtype))
$this->pcg_subtype = trim($this->pcg_subtype);
if (isset($this->account_number))
$this->account_number = trim($this->account_number);
if (isset($this->account_parent))
$this->account_parent = trim($this->account_parent);
if (isset($this->label))
$this->label = trim($this->label);
if (isset($this->fk_user_author))
$this->fk_user_author = trim($this->fk_user_author);
if (isset($this->active))
$this->active = trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount(";
$sql .= "datec";
$sql .= ", entity";
$sql .= ", fk_pcg_version";
$sql .= ", pcg_type";
$sql .= ", pcg_subtype";
$sql .= ", account_number";
$sql .= ", account_parent";
$sql .= ", label";
$sql .= ", fk_user_author";
$sql .= ", active";
$sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity;
$sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'");
$sql .= ", " . (! isset($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'");
$sql .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'");
$sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'");
$sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'");
$sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'");
$sql .= ", " . $user->id;
$sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'");
$sql .= ")";
$this->db->begin();
dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount");
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Update record
*
* @param User $user update
* @return int if KO, >0 if OK
*/
function update($user) {
global $langs;
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null");
$sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null");
$sql .= " , pcg_subtype = " . ($this->pcg_subtype ? "'" . $this->db->escape($this->pcg_subtype) . "'" : "null");
$sql .= " , account_number = '" . $this->account_number . "'";
$sql .= " , account_parent = '" . $this->account_parent . "'";
$sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null");
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = '" . $this->active . "'";
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return - 1;
}
}
/**
* Check usage of accounting code
*
* @param User $user update
* @return int if KO, >0 if OK
*/
function checkUsage() {
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
$sql .= "UNION";
$sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " WHERE fk_code_ventilation=" . $this->id . ")";
dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0) {
$this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse');
return 0;
} else {
return 1;
}
} else {
$this->error = $this->db->lasterror();
return - 1;
}
}
/**
* Delete object in database
*
* @param User $user that deletes
* @param int $notrigger triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0) {
global $conf, $langs;
$error = 0;
$result = $this->checkUsage();
if ($result > 0) {
$this->db->begin();
if (! $error) {
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount";
$sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
} else {
return - 1;
}
}
/**
* Information on record
*
* @param int $id of record
* @return void
*/
function info($id) {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a';
$sql .= ' WHERE a.rowid = ' . $id;
dol_syslog(get_class($this) . '::info sql=' . $sql);
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->tms);
}
$this->db->free($result);
} else {
dol_print_error($this->db);
}
}
/**
* Account desactivate
*
* @param User $user update
* @return int if KO, >0 if OK
*/
function account_desactivate($id) {
global $langs;
$result = $this->checkUsage();
if ($result > 0) {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= "SET active = '0'";
$sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return - 1;
}
} else {
return - 1;
}
}
/**
* Account activate
*
* @param User $user update
* @return int if KO, >0 if OK
*/
function account_activate($id) {
global $langs;
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= "SET active = '1'";
$sql .= " WHERE rowid = ".$this->db->escape($id);
dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return - 1;
}
}
}

View File

@ -0,0 +1,672 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/class/bookkeeping.class.php
* \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable
*/
/**
* \class BookKeeping
* \brief Classe permettant la gestion des comptes generaux de compta
*/
class BookKeeping {
var $db;
var $id;
var $doc_date;
var $doc_type;
var $doc_ref;
var $date_create;
var $fk_doc;
var $fk_docdet;
var $code_tiers;
var $numero_compte;
var $label_compte;
var $debit;
var $credit;
var $montant;
var $sens;
var $fk_user_author;
var $code_journal;
var $piece_num;
var $linesexport = array ();
var $linesmvt = array ();
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* \param id id compte (0 par defaut)
*/
function BookKeeping($db) {
$this->db = $db;
}
/**
* \brief Load record in memory
*/
function fetch_per_mvt($piecenum) {
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type FROM " . MAIN_DB_PREFIX . "bookkeeping WHERE ";
$sql .= " piece_num = '" . $piecenum . "'";
dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
$this->piece_num = $obj->piece_num;
$this->code_journal = $obj->code_journal;
$this->doc_date = $this->db->jdate($obj->doc_date);
$this->doc_ref = $obj->doc_ref;
$this->doc_type = $obj->doc_type;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
return - 1;
}
return 1;
}
/**
* \brief Load record in memory
*/
function fetch($id) {
$sql = "SELECT rowid, doc_date, doc_type, ";
$sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, ";
$sql .= "numero_compte, label_compte, debit, credit, ";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$sql .= " WHERE rowid = '" . $id . "'";
dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->doc_date = $this->db->jdate($obj->doc_date);
$this->doc_type = $obj->doc_type;
$this->doc_ref = $obj->doc_ref;
$this->fk_doc = $obj->fk_doc;
$this->fk_docdet = $obj->fk_docdet;
$this->code_tiers = $obj->code_tiers;
$this->numero_compte = $obj->numero_compte;
$this->label_compte = $obj->label_compte;
$this->debit = $obj->debit;
$this->credit = $obj->credit;
$this->montant = $obj->montant;
$this->sens = $obj->sens;
$this->code_journal = $obj->code_journal;
$this->piece_num = $obj->piece_num;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR);
return - 1;
}
return 1;
}
/**
* \brief Return next num mvt
*/
function next_num_mvt() {
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "bookkeeping";
dol_syslog(get_class($this) . "next_num_mvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
return $obj->max;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
return - 1;
}
}
/**
* \brief Load record in memory
*/
function fetch_all_per_mvt($piecenum) {
$sql = "SELECT rowid, doc_date, doc_type, ";
$sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, ";
$sql .= "numero_compte, label_compte, debit, credit, ";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$sql .= " WHERE piece_num = '" . $piecenum . "'";
dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
while ( $obj = $this->db->fetch_object($result) ) {
$line = new BookKeepingLine();
$line->id = $obj->rowid;
$line->doc_date = $this->db->jdate($obj->doc_date);
$line->doc_type = $obj->doc_type;
$line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers;
$line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->sens = $obj->sens;
$line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num;
$this->linesmvt[] = $line;
}
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR);
return - 1;
}
return 1;
}
/**
* \brief Insere une ligne dans bookkeeping
* \param user utilisateur qui effectue l'insertion
*/
function create() {
global $conf, $user, $langs;
$this->piece_num = 0;
// first check if line not yet in bookkeeping
$sql = "SELECT count(*)";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
$sql .= " AND fk_docdet = " . $this->fk_docdet;
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$row = $this->db->fetch_array($resql);
if ($row[0] == 0) {
// Determine piece_num
$sqlnum = "SELECT piece_num";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum);
if ($resqlnum) {
$objnum = $this->db->fetch_object($resqlnum);
$this->piece_num = $objnum->piece_num;
}
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
if (empty($this->piece_num)) {
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
$sqlnum .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
$resqlnum = $this->db->query($sqlnum);
if ($resqlnum) {
$objnum = $this->db->fetch_object($resqlnum);
$this->piece_num = $objnum->maxpiecenum;
}
}
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
if (empty($this->piece_num)) {
$this->piece_num = 1;
}
$now = dol_now();
if (empty($this->date_create))
$this->date_create = $now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "bookkeeping (doc_date, ";
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
$sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)";
$sql .= " VALUES ('" . $this->doc_date . "','" . $this->doc_type . "','" . $this->doc_ref . "'," . $this->fk_doc . ",";
$sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',";
$sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '";
$sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . "bookkeeping");
if ($id > 0) {
$this->id = $id;
$result = 0;
} else {
$result = - 2;
dol_syslog("BookKeeping::Create Erreur $result lecture ID");
}
} else {
$result = - 1;
dol_syslog("BookKeeping::Create Erreur $result INSERT Mysql");
}
} else {
$result = - 3;
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql");
}
} else {
$result = - 5;
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql");
}
return $result;
}
/**
* \brief Delete bookkepping by importkey
*/
function delete_by_importkey($importkey) {
$this->db->begin();
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$sql .= " WHERE import_key = '" . $importkey . "'";
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Create object into database
*
* @param User $user that creates
* @param int $notrigger triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function create_std($user, $notrigger = 0) {
global $conf, $langs;
$error = 0;
// Clean parameters
if (isset($this->doc_type))
$this->doc_type = trim($this->doc_type);
if (isset($this->doc_ref))
$this->doc_ref = trim($this->doc_ref);
if (isset($this->fk_doc))
$this->fk_doc = trim($this->fk_doc);
if (isset($this->fk_docdet))
$this->fk_docdet = trim($this->fk_docdet);
if (isset($this->code_tiers))
$this->code_tiers = trim($this->code_tiers);
if (isset($this->numero_compte))
$this->numero_compte = trim($this->numero_compte);
if (isset($this->label_compte))
$this->label_compte = trim($this->label_compte);
if (isset($this->debit))
$this->debit = trim($this->debit);
if (isset($this->credit))
$this->credit = trim($this->credit);
if (isset($this->montant))
$this->montant = trim($this->montant);
if (isset($this->sens))
$this->sens = trim($this->sens);
if (isset($this->fk_user_author))
$this->fk_user_author = trim($this->fk_user_author);
if (isset($this->import_key))
$this->import_key = trim($this->import_key);
if (isset($this->code_journal))
$this->code_journal = trim($this->code_journal);
if (isset($this->piece_num))
$this->piece_num = trim($this->piece_num);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "bookkeeping(";
$sql .= "doc_date,";
$sql .= "doc_type,";
$sql .= "doc_ref,";
$sql .= "fk_doc,";
$sql .= "fk_docdet,";
$sql .= "code_tiers,";
$sql .= "numero_compte,";
$sql .= "label_compte,";
$sql .= "debit,";
$sql .= "credit,";
$sql .= "montant,";
$sql .= "sens,";
$sql .= "fk_user_author,";
$sql .= "import_key,";
$sql .= "code_journal,";
$sql .= "piece_num";
$sql .= ") VALUES (";
$sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ",";
$sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ",";
$sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ",";
$sql .= " " . (! isset($this->fk_doc) ? 'NULL' : "'" . $this->fk_doc . "'") . ",";
$sql .= " " . (! isset($this->fk_docdet) ? 'NULL' : "'" . $this->fk_docdet . "'") . ",";
$sql .= " " . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ",";
$sql .= " " . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ",";
$sql .= " " . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ",";
$sql .= " " . (! isset($this->debit) ? 'NULL' : "'" . $this->debit . "'") . ",";
$sql .= " " . (! isset($this->credit) ? 'NULL' : "'" . $this->credit . "'") . ",";
$sql .= " " . (! isset($this->montant) ? 'NULL' : "'" . $this->montant . "'") . ",";
$sql .= " " . (! isset($this->sens) ? 'NULL' : "'" . $this->db->escape($this->sens) . "'") . ",";
$sql .= " " . $user->id . ",";
$sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ",";
$sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ",";
$sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . "";
$sql .= ")";
$this->db->begin();
dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "bookkeeping");
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::create_std " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Update object into database
*
* @param User $user that modifies
* @param int $notrigger triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user = 0, $notrigger = 0) {
global $conf, $langs;
$error = 0;
// Clean parameters
if (isset($this->doc_type))
$this->doc_type = trim($this->doc_type);
if (isset($this->doc_ref))
$this->doc_ref = trim($this->doc_ref);
if (isset($this->fk_doc))
$this->fk_doc = trim($this->fk_doc);
if (isset($this->fk_docdet))
$this->fk_docdet = trim($this->fk_docdet);
if (isset($this->code_tiers))
$this->code_tiers = trim($this->code_tiers);
if (isset($this->numero_compte))
$this->numero_compte = trim($this->numero_compte);
if (isset($this->label_compte))
$this->label_compte = trim($this->label_compte);
if (isset($this->debit))
$this->debit = trim($this->debit);
if (isset($this->credit))
$this->credit = trim($this->credit);
if (isset($this->montant))
$this->montant = trim($this->montant);
if (isset($this->sens))
$this->sens = trim($this->sens);
if (isset($this->fk_user_author))
$this->fk_user_author = trim($this->fk_user_author);
if (isset($this->import_key))
$this->import_key = trim($this->import_key);
if (isset($this->code_journal))
$this->code_journal = trim($this->code_journal);
if (isset($this->piece_num))
$this->piece_num = trim($this->piece_num);
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = "UPDATE " . MAIN_DB_PREFIX . "bookkeeping SET";
$sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ",";
$sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ",";
$sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ",";
$sql .= " fk_doc=" . (isset($this->fk_doc) ? $this->fk_doc : "null") . ",";
$sql .= " fk_docdet=" . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ",";
$sql .= " code_tiers=" . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ",";
$sql .= " numero_compte=" . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ",";
$sql .= " label_compte=" . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ",";
$sql .= " debit=" . (isset($this->debit) ? $this->debit : "null") . ",";
$sql .= " credit=" . (isset($this->credit) ? $this->credit : "null") . ",";
$sql .= " montant=" . (isset($this->montant) ? $this->montant : "null") . ",";
$sql .= " sens=" . (isset($this->sens) ? "'" . $this->db->escape($this->sens) . "'" : "null") . ",";
$sql .= " fk_user_author=" . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ",";
$sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ",";
$sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ",";
$sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . "";
$sql .= " WHERE rowid=" . $this->id;
$this->db->begin();
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
if (! $error) {
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user that deletes
* @param int $notrigger triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0) {
global $conf, $langs;
$error = 0;
$this->db->begin();
if (! $error) {
if (! $notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
}
if (! $error) {
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "bookkeeping";
$sql .= " WHERE rowid=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* \brief Delete bookkepping by importkey
*/
function export_bookkeping($model = 'ebp') {
$sql = "SELECT rowid, doc_date, doc_type, ";
$sql .= "doc_ref, fk_doc, fk_docdet, code_tiers, ";
$sql .= "numero_compte, label_compte, debit, credit, ";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "bookkeeping ";
$resql = $this->db->query($sql);
dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->linesexport = array ();
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$line = new BookKeepingLine();
$line->id = $obj->rowid;
$line->doc_date = $this->db->jdate($obj->doc_date);
$line->doc_type = $obj->doc_type;
$line->doc_ref = $obj->doc_ref;
$line->fk_doc = $obj->fk_doc;
$line->fk_docdet = $obj->fk_docdet;
$line->code_tiers = $obj->code_tiers;
$line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->sens = $obj->sens;
$line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num;
$this->linesexport[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR);
return - 1;
}
}
}
class BookKeepingLine {
var $id;
var $doc_date;
var $doc_type;
var $doc_ref;
var $fk_doc;
var $fk_docdet;
var $code_tiers;
var $numero_compte;
var $label_compte;
var $debit;
var $credit;
var $montant;
var $sens;
var $fk_user_author;
var $code_journal;
var $piece_num;
}

View File

@ -0,0 +1,246 @@
<?php
/* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/class/html.formventilation.class.php
* \brief Class for HML form
*/
class FormVentilation extends Form {
var $db;
var $error;
/**
* Constructor
*
* @param DoliDB $db handler
*/
function __construct($db) {
$this->db = $db;
return 1;
}
/**
* Return select filter with date of transaction
*
* @param string $htmlname of input
* @param string $selectedkey value
* @return string select input
*/
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) {
global $langs;
$date_array = array ();
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'bookkeeping ';
$sql .= ' ORDER BY import_key DESC';
$out = '<SELECT name="' . $htmlname . '">';
dol_syslog(get_class($this) . "::select_bookkeeping_importkey sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$num = $this->db->num_rows($resql);
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$selected = '';
if ($selectedkey == $obj->import_key) {
$selected = ' selected="selected" ';
}
$out .= '<OPTION value="' . $obj->import_key . '"' . $selected . '>' . $obj->import_key . '</OPTION>';
$i ++;
}
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
return - 1;
}
$out .= '</SELECT>';
return $out;
}
/**
* Return list of the accounts with label
*
* @param string $selectedid pcg_type
* @param string $htmlname of combo list
* @param int $showempty en empty line
*
* @return string with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) {
global $conf, $user, $langs;
$out = '';
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1";
$sql .= " ORDER BY aa.account_number";
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty)
$out .= '<option value="-1"></option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$label = $obj->account_number . ' - ' . $obj->label;
// Remember guy's we store in database llx_facturedet the rowid of accountingaccount and not the account_number
// Bacause same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $obj->rowid) {
// $out .= '<option value="' . $obj->account_number . '" selected="selected">' . $label . '</option>';
$out .= '<option value="' . $obj->rowid . '" selected="selected">' . $label . '</option>';
} else {
// $out .= '<option value="' . $obj->account_number . '">' . $label . '</option>';
$out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
}
$i ++;
}
}
$out .= '</select>';
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
return - 1;
}
$this->db->free($resql);
return $out;
}
/**
* Return list of pcg with label
*
* @param string $selectedid pcg_type
* @param string $htmlname of combo list
* @param int $showempty en empty line
*
* @return string with HTML select
*/
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) {
global $conf, $user, $langs;
$out = '';
$sql = "SELECT DISTINCT pcg_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " ORDER BY pcg_type";
dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty)
$out .= '<option value="-1"></option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$label = $obj->pcg_type;
if (($selectid != '') && $selectid == $obj->pcg_type) {
$out .= '<option value="' . $obj->pcg_type . '" selected="selected">' . $label . '</option>';
} else {
$out .= '<option value="' . $obj->pcg_type . '">' . $label . '</option>';
}
$i ++;
}
}
$out .= '</select>';
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_pcgtype " . $this->error, LOG_ERR);
return - 1;
}
$this->db->free($resql);
return $out;
}
/**
* Return subtype list of pcg with label
*
* @param string $selectedid pcg_type
* @param string $htmlname of combo list
* @param int $showempty en empty line
*
* @return string with HTML select
*/
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) {
global $conf, $user, $langs;
$out = '';
$sql = "SELECT DISTINCT pcg_subtype ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount ";
$sql .= " ORDER BY pcg_subtype";
dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$out .= ajax_combobox($htmlname, $event);
$out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
if ($showempty)
$out .= '<option value="-1"></option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$label = $obj->pcg_subtype;
if (($selectid != '') && $selectid == $obj->pcg_subtype) {
$out .= '<option value="' . $obj->pcg_subtype . '" selected="selected">' . $label . '</option>';
} else {
$out .= '<option value="' . $obj->pcg_subtype . '">' . $label . '</option>';
}
$i ++;
}
}
$out .= '</select>';
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR);
return - 1;
}
$this->db->free($resql);
return $out;
}
}

View File

@ -0,0 +1,146 @@
<?PHP
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@fidurex.fr>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/customer/fiche.php
* \ingroup Accounting Expert
* \brief Page fiche ventilation
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/compta/facture/class/facture.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("bills");
$langs->load("accountingex@accountingex");
$action = GETPOST('action', 'alpha');
$codeventil = GETPOST('codeventil');
$id = GETPOST('id');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
/*
* Actions
*/
if ($action == 'ventil' && $user->rights->accountingex->access) {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
dol_syslog("/accountingex/customer/fiche.php sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql) {
setEventMessage($db->lasterror(), 'errors');
}
}
llxHeader("", "", "FicheVentilation");
if ($cancel == $langs->trans("Cancel")) {
$action = '';
}
/*
* Create
*/
$form = new Form($db);
$facture_static = new Facture($db);
$formventilation = new FormVentilation($db);
if (! empty($id)) {
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
$sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,";
$sql .= " l.fk_code_ventilation, aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
dol_syslog("/accountingex/customer/fiche.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
if ($num_lignes) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">';
print_fiche_titre($langs->trans("Ventilation"));
print '<table class="border" width="100%">';
// Ref facture
print '<tr><td>' . $langs->trans("Invoice") . '</td>';
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->facid;
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
print '</tr>';
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . nl2br($objp->description) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" class="button" value="' . $langs->trans("Update") . '"></td></tr>';
print '</table>';
print '</form>';
} else {
print "Error";
}
} else {
print "Error";
}
} else {
print "Error ID incorrect";
}
llxFooter();
$db->close();

View File

View File

@ -0,0 +1,353 @@
<?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/customer/index.php
* \ingroup Accounting Expert
* \brief Page accueil clients ventilation comptable
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/date.lib.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
// Filter
$year = $_GET["year"];
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
// Validate History
$action = GETPOST('action');
if ($action == 'validatehistory') {
$error = 0;
$db->begin();
if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0";
} else {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0";
}
dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Dispatched'), 'mesgs');
}
}
/*
* View
*/
llxHeader('', $langs->trans("CustomersVentilation"));
$textprevyear = "<a href=\"index.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
$textnextyear = " <a href=\"index.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
print_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
print '<b>' . $langs->trans("DescVentilCustomer") . '</b>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
$nbfac = $row[0];
$db->free($result);
}
$y = $year_current;
$var = true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" align="left">' . $langs->trans("Intitule") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',";
$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$sql .= " GROUP BY fd.fk_code_ventilation";
dol_syslog("/accountingex/customer/index.php sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . $row[0] . '</td>';
print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';
print '<td align="right">' . price($row[4]) . '</td>';
print '<td align="right">' . price($row[5]) . '</td>';
print '<td align="right">' . price($row[6]) . '</td>';
print '<td align="right">' . price($row[7]) . '</td>';
print '<td align="right">' . price($row[8]) . '</td>';
print '<td align="right">' . price($row[9]) . '</td>';
print '<td align="right">' . price($row[10]) . '</td>';
print '<td align="right">' . price($row[11]) . '</td>';
print '<td align="right">' . price($row[12]) . '</td>';
print '<td align="right">' . price($row[13]) . '</td>';
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror(); // affiche la derniere erreur sql
}
print "</table>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Total',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,fd.total_ht,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,fd.total_ht,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,fd.total_ht,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,fd.total_ht,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,fd.total_ht,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,fd.total_ht,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,fd.total_ht,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,fd.total_ht,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,fd.total_ht,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,fd.total_ht,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,fd.total_ht,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,fd.total_ht,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(fd.total_ht),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
dol_syslog('accountingext/customer/index.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . $row[0] . '</td>';
print '<td align="right">' . price($row[1]) . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';
print '<td align="right">' . price($row[4]) . '</td>';
print '<td align="right">' . price($row[5]) . '</td>';
print '<td align="right">' . price($row[6]) . '</td>';
print '<td align="right">' . price($row[7]) . '</td>';
print '<td align="right">' . price($row[8]) . '</td>';
print '<td align="right">' . price($row[9]) . '</td>';
print '<td align="right">' . price($row[10]) . '</td>';
print '<td align="right">' . price($row[11]) . '</td>';
print '<td align="right">' . price($row[12]) . '</td>';
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror(); // affiche la derniere erreur sql
}
print "</table>\n";
if (! empty($conf->margin->enabled)) {
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JanuaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("FebruaryMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MarchMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AprilMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("MayMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JuneMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("JulyMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("AugustMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td width="60" align="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td width="60" align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=3,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=4,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=5,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=6,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=7,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=8,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=9,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=10,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=11,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(f.datef)=12,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
dol_syslog('accountingext/customer/index.php:: $sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . $row[0] . '</td>';
print '<td align="right">' . price($row[1]) . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';
print '<td align="right">' . price($row[4]) . '</td>';
print '<td align="right">' . price($row[5]) . '</td>';
print '<td align="right">' . price($row[6]) . '</td>';
print '<td align="right">' . price($row[7]) . '</td>';
print '<td align="right">' . price($row[8]) . '</td>';
print '<td align="right">' . price($row[9]) . '</td>';
print '<td align="right">' . price($row[10]) . '</td>';
print '<td align="right">' . price($row[11]) . '</td>';
print '<td align="right">' . price($row[12]) . '</td>';
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror(); // affiche la derniere erreur sql
}
print "</table>\n";
}
print "</table>\n";
print '</td></tr></table>';
llxFooter();
$db->close();

View File

@ -0,0 +1,232 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/customer/lignes.php
* \ingroup Accounting Expert
* \brief Page of detail of the lines of ventilation of invoices customers
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/accountingex/class/html.formventilation.class.php");
dol_include_once("/compta/facture/class/facture.class.php");
dol_include_once("/product/class/product.class.php");
// langs
$langs->load("bills");
$langs->load("compta");
$langs->load("main");
$langs->load("accountingex@accountingex");
$account_parent = GETPOST('account_parent');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$formventilation = new FormVentilation($db);
// change account
$changeaccount = GETPOST('changeaccount');
$is_search = GETPOST('button_search_x');
if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=" . $account_parent;
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountingex/customer/lignes.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
setEventMessage($db->lasterror(), 'errors');
}
if (! $error) {
$db->commit();
setEventMessage($langs->trans('Save'), 'mesgs');
} else {
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
}
}
/*
* View
*/
llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched"));
$page = GETPOST("page");
if ($page < 0)
$page = 0;
if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION;
} elseif ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) {
$limit = $conf->liste_limit;
} else {
$limit = $conf->liste_limit;
}
$offset = $limit * $page;
$sql = "SELECT l.rowid , f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.qty, l.tva_tx, l.fk_code_ventilation, aa.label, aa.account_number,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa";
$sql .= " , " . MAIN_DB_PREFIX . "facturedet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " AND aa.rowid = l.fk_code_ventilation";
if (strlen(trim(GETPOST("search_facture")))) {
$sql .= " AND f.facnumber like '%" . GETPOST("search_facture") . "%'";
}
if (strlen(trim(GETPOST("search_ref")))) {
$sql .= " AND p.ref like '%" . GETPOST("search_ref") . "%'";
}
if (strlen(trim(GETPOST("search_label")))) {
$sql .= " AND p.label like '%" . GETPOST("search_label") . "%'";
}
if (strlen(trim(GETPOST("search_desc")))) {
$sql .= " AND l.description like '%" . GETPOST("search_desc") . "%'";
}
if (strlen(trim(GETPOST("search_account")))) {
$sql .= " AND aa.account_number like '%" . GETPOST("search_account") . "%'";
}
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$sql .= " ORDER BY l.rowid";
if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE > 0) {
$sql .= " DESC ";
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountingex/customer/linges.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lignes);
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<table class="noborder" width="100%">';
print '<br><br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount");
print $formventilation->select_account($account_parent, 'account_parent', 1);
print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '"/></div>';
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td align="left">' . $langs->trans("Amount") . '</td>';
print '<td colspan="2" align="left">' . $langs->trans("Account") . '</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="' . GETPOST("search_facture") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . GETPOST("search_ref") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . GETPOST("search_desc") . '"></td>';
print '<td align="right">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
print '<td align="center">&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">';
print '</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
$facture_static = new Facture($db);
$product_static = new Product($db);
$var = True;
while ( $objp = $db->fetch_object($result) ) {
$var = ! $var;
$codeCompta = $objp->account_number . ' ' . $objp->label;
print "<tr $bc[$var]>";
// Ref facture
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->facid;
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
// Ref produit
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
print '<td align="left">' . price($objp->total_ht) . '</td>';
print '<td align="left">' . $codeCompta . '</td>';
print '<td>' . $objp->rowid . '</td>';
print '<td><a href="./fiche.php?id=' . $objp->rowid . '">';
print img_edit();
print '</a></td>';
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>";
$i ++;
}
} else {
print $db->error();
}
print "</table></form>";
$db->close();
llxFooter();

View File

@ -0,0 +1,246 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/customer/liste.php
* \ingroup Accounting Expert
* \brief Page de ventilation des lignes de facture clients
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/compta/facture/class/facture.class.php");
dol_include_once("/product/class/product.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("main");
$langs->load("accountingex@accountingex");
$action = GETPOST('action');
$codeventil = GETPOST('codeventil', 'array');
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$formventilation = new FormVentilation($db);
llxHeader('', $langs->trans("Ventilation"));
/*
* Action
*/
if ($action == 'ventil') {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($codeventil) && ! empty($mesCasesCochees)) {
print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = split("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1];
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
dol_syslog("/accountingex/customer/liste.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
} else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
}
$cpt ++;
}
} else {
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
}
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
/*
* Customer Invoice lines
*/
$page = GETPOST('page');
if ($page < 0)
$page = 0;
if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) {
$limit = $conf->liste_limit;
} else {
$limit = $conf->liste_limit;
}
$offset = $limit * $page;
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell";
$sql .= " , aa.rowid as aarowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_sell = aa.account_number";
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$sql .= " ORDER BY l.rowid";
if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO > 0) {
$sql .= " DESC ";
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountingex/customer/liste.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
print_barre_liste($langs->trans("InvoiceLines"), $page, "liste.php", "", $sortfield, $sortorder, '', $num_lignes);
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td align="right">' . $langs->trans("Amount") . '</td>';
print '<td align="right">' . $langs->trans("AccountAccounting") . '</td>';
print '<td align="center">' . $langs->trans("IntoAccount") . '</td>';
print '<td align="center">' . $langs->trans("Ventilate") . '</td>';
print '</tr>';
$facture_static = new Facture($db);
$product_static = new Product($db);
$form = new Form($db);
$var = True;
while ( $i < min($num_lignes, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
// product_type: 0 = service ? 1 = product
// if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
// issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
$code_sell_notset = '';
if (empty($objp->code_sell)) {
$code_sell_notset = 'color:red';
if (! empty($objp->type)) {
if ($objp->type == 1) {
$objp->code_sell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
} else {
$objp->code_sell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
}
} else {
$code_sell_notset = 'color:blue';
if ($objp->type == 1) {
$objp->code_sell = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
} else {
$objp->code_sell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
}
}
}
print "<tr $bc[$var]>";
// Ref facture
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->facid;
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
// Ref produit
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
print '<td align="center" style="' . $code_sell_notset . '">';
print $objp->code_sell;
print '</td>';
// Colonne choix du compte
print '<td align="center">';
print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1);
print '</td>';
// Colonne choix ligne a ventiler
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->code_sell ? "checked" : "") . '/>';
print '</td>';
print '</tr>';
$i ++;
}
print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></td></tr>';
print '</table>';
print '</form>';
} else {
print $db->error();
}
$db->close();
llxFooter();

View File

@ -0,0 +1,568 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/journal/bankjournal.php
* \ingroup Accounting Expert
* \brief Page with sells journal
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
dol_include_once("/core/lib/bank.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/societe/class/societe.class.php");
dol_include_once("/adherents/class/adherent.class.php");
dol_include_once("/compta/sociales/class/chargesociales.class.php");
dol_include_once("/compta/paiement/class/paiement.class.php");
dol_include_once("/compta/tva/class/tva.class.php");
dol_include_once("/fourn/class/paiementfourn.class.php");
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/fourn/class/fournisseur.class.php");
dol_include_once("/accountingex/class/bookkeeping.class.php");
dol_include_once("/societe/class/client.class.php");
// Langs
$langs->load("companies");
$langs->load("other");
$langs->load("compta");
$langs->load("bank");
$langs->load('bills');
$langs->load("accountingex@accountingex");
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$action = GETPOST('action');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
/*
* View
*/
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,";
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid";
// To isolate the cash of the other accounts
$sql .= " WHERE ba.courant <> 2";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ba.entity = " . $conf->entity;
}
if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
$sql .= " ORDER BY b.datev";
$object = new Account($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$societestatic = new Societe($db);
$chargestatic = new ChargeSociales($db);
$paymentvatstatic = new TVA($db);
dol_syslog("accountingex/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// Variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$cptsociale = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$tabpay = array ();
$tabbq = array ();
$tabtp = array ();
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
);
$tabtype = array ();
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
// Controls
$compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)')
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
if ($obj->label == '(CustomerInvoicePayment)')
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH;
// Variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
$tabpay[$obj->rowid]["ref"] = $obj->label;
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
} else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
}
$links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->nom = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
} else {
$chargestatic->lib = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
} else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
}*/
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$i ++;
}
} else {
dol_print_error($db);
}
/*
* Actions
*/
// Write bookkeeping
if ($action == 'writeBookKeeping') {
$error = 0;
foreach ( $tabpay as $key => $val ) {
// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->doc_type = 'bank';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->intitule;
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_BANK_JOURNAL;
if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
} else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sqlmid .= " WHERE payf.fk_bank=" . $key;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
}
$result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
}
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->doc_type = 'banque';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_BANK_JOURNAL;
if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sqlmid .= " WHERE payf.fk_bank=" . $key;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'company') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else {
$bookkeeping->doc_ref = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
}
$result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
}
}
if (empty($error)) {
setEventMessage($langs->trans('Success'), 'mesgs');
}
}
// export csv
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_banque.csv');
$companystatic = new Client($db);
if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
// Bank
print $date . $sep;
print $conf->global->ACCOUNTINGEX_BANK_JOURNAL . $sep;
foreach ( $tabbq[$key] as $k => $mt ) {
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $val["type_payment"] . $sep;
print $sep;
}
print "\n";
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_BANK_JOURNAL . $sep;
if ($val["lib"] == '(SupplierInvoicePayment)') {
print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep;
} else {
print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep;
}
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $val["type_payment"] . $sep;
print $sep;
print "\n";
}
}
}
} else // Modèle Export Classique
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep;
// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Bank") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
}
print "\n";
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $companystatic->name . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
}
}
} else {
$form = new Form($db);
llxHeader('', $langs->trans("BankJournal"));
$nom = $langs->trans("BankJournal");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$description = $langs->trans("DescBankJournal") . '<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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writeBookKeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
/*
* Show result array
*/
print '<br><br>';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>";
print "<td>" . $langs->trans("PaymentMode") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";
$var = true;
$r = '';
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
if ($val["lib"] == '(SupplierInvoicePayment)')
$reflabel = $langs->trans('SupplierInvoicePayment');
if ($val["lib"] == '(CustomerInvoicePayment)')
$reflabel = $langs->trans('CustomerInvoicePayment');
// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
if (1) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $reflabel . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $langs->trans('Bank') . "</td>";
print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $val["soclib"] . "</td>";
print "<td>" . length_accounta($k) . "</td>";
print "<td>" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")</td>";
print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
}
}
$var = ! $var;
}
print "</table>";
// End of page
llxFooter();
}
$db->close();

View File

@ -0,0 +1,544 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/journal/cashjournal.php
* \ingroup Accounting Expert
* \brief Page with cash journal
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
dol_include_once("/core/lib/bank.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/societe/class/societe.class.php");
dol_include_once("/adherents/class/adherent.class.php");
dol_include_once("/compta/sociales/class/chargesociales.class.php");
dol_include_once("/compta/paiement/class/paiement.class.php");
dol_include_once("/compta/tva/class/tva.class.php");
dol_include_once("/fourn/class/paiementfourn.class.php");
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/fourn/class/fournisseur.class.php");
dol_include_once("/accountingex/class/bookkeeping.class.php");
// Langs
$langs->load("companies");
$langs->load("other");
$langs->load("compta");
$langs->load("bank");
$langs->load("accountingex@accountingex");
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$action = GETPOST('action');
/*
* View
*/
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$sql = "SELECT b.rowid , b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, soc.code_compta, ba.courant,";
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, ba.account_number, bu1.type as typeop";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank b";
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account ba on b.fk_account=ba.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe soc on bu1.url_id=soc.rowid";
// Code opération type caisse
$sql .= " WHERE ba.courant = 2";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ba.entity = " . $conf->entity;
}
if ($date_start && $date_end)
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
$sql .= " ORDER BY b.datev";
$object = new Account($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$societestatic = new Societe($db);
$chargestatic = new ChargeSociales($db);
$paymentvatstatic = new TVA($db);
dol_syslog("accountingex/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// les variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$cptsociale = (! empty($conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTINGEX_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$tabpay = array ();
$tabbq = array ();
$tabtp = array ();
$tabcompany = array ();
$tabtype = array ();
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
// controls
$compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)')
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
if ($obj->label == '(CustomerInvoicePayment)')
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH;
// variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["ref"] = $obj->label;
$tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) {
$tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
} else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
}
$links = $object->get_url($obj->rowid);
foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
} else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->nom = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
} else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
} else {
$chargestatic->lib = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
} else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
}*/
}
$tabbq[$obj->rowid][$compta_bank] += $obj->amount;
// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
$i ++;
}
} else {
dol_print_error($db);
}
/*
* Actions
*/
// write bookkeeping
if ($action == 'writeBookKeeping') {
$error = 0;
foreach ( $tabpay as $key => $val ) {
// cash
foreach ( $tabbq[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->doc_type = 'cash';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->intitule;
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_CASH_JOURNAL;
if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
} else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sqlmid .= " WHERE payf.fk_bank=" . $key;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
}
$result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
}
// third party
foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->doc_type = 'cash';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_CASH_JOURNAL;
if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') {
$sqlmid = 'SELECT facf.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sqlmid .= " WHERE payf.fk_bank=" . $key;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'company') {
$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sqlmid .= " WHERE pay.fk_bank=" . $key;
dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->facnumber;
}
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
} else {
$bookkeeping->doc_ref = $k;
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
}
$result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
}
}
if (empty($error)) {
setEventMessage($langs->trans('Success'), 'mesgs');
}
}
// export csv
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition:attachment;filename=journal_caisse.csv');
if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
// Cash
print $date . $sep;
print $conf->global->ACCOUNTINGEX_CASH_JOURNAL . $sep;
foreach ( $tabbq[$key] as $k => $mt ) {
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print price($mt) . $sep;
}
print utf8_decode($langs->trans("CashPayment")) . $sep;
print $val["ref"] . $sep;
print "\n";
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_CASH_JOURNAL . $sep;
if ($obj->label == '(SupplierInvoicePayment)') {
print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep;
} else {
print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep;
}
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print price($mt) . $sep;
print $langs->trans("ThirdParty") . $sep;
print $val["ref"] . $sep;
print "\n";
}
}
}
} else // Modèle Export Classique
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
// Cash
foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Cash") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
}
print "\n";
// Third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("ThirdParty") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
}
}
} else {
$form = new Form($db);
llxHeader('', $langs->trans("CashJournal"), '');
$nom = $langs->trans("CashJournal");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$description = $langs->trans("DescCashJournal") . '<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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writeBookKeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
/*
* Show result array
*/
print '<br><br>';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";
$var = true;
$r = '';
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
// Cash
foreach ( $tabbq[$key] as $k => $mt ) {
if (1) {
print "<tr " . $bc[$var] . " >";
print "<td>" . $date . "</td>";
print "<td>" . $val["lib"] . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
// third party
foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $val["soclib"] . "</td>";
print "<td>" . length_accounta($k) . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
}
}
$var = ! $var;
}
print "</table>";
// End of page
llxFooter();
}
$db->close();

View File

View File

@ -0,0 +1,58 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/journal/index.php
* \ingroup Accounting Expert
* \brief Index
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
llxHeader('', 'Journaux', '');
$form = new Form($db);
// End of page
$db->close();
llxFooter();
?>

View File

@ -0,0 +1,482 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/journal/purchasesjournal.php
* \ingroup Accounting Expert
* \brief Page with purchases journal
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/fourn/class/fournisseur.class.php");
dol_include_once("/accountingex/class/bookkeeping.class.php");
dol_include_once("/accountingex/class/accountingaccount.class.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$action = GETPOST('action');
/*
* View
*/
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,";
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,";
$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn f ON f.rowid = fd.fk_facture_fourn";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.fk_statut > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = " . $conf->entity;
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
else
$sql .= " AND f.type IN (0,1,2,3)";
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
$sql .= " ORDER BY f.datef";
dol_syslog('accountingex/journal/purchasesjournal.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// les variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER)) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef");
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
$tabttc = array ();
$tabcompany = array ();
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
// contrôles
$compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour;
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->COMPTA_PRODUCT_BUY_ACCOUNT)) ? $conf->global->COMPTA_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef");
else
$compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
}
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->ref;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->description;
$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_fournisseur' => $obj->code_compta_fournisseur
);
$i ++;
}
} else {
dol_print_error($db);
}
/*
* Actions
*/
// Bookkeeping Write
if ($action == 'writebookkeeping') {
$now = dol_now();
foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur'];
$bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL;
$bookkeeping->create();
}
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$compte = new AccountingAccount($db);
if ($compte->fetch(null, $k)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = dol_trunc($val["description"], 128);
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL;
$bookkeeping->create();
}
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = $langs->trans("VAT");
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL;
$bookkeeping->create();
}
}
}
}
// export csv
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_achats.csv');
if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($val["description"], 32) . $sep;
print $val["ref"];
print "\n";
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
print $date . $sep;
print $conf->global->ACCOUNTINGEX_PURCHASE_JOURNAL . $sep;
print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep;
foreach ( $tabttc[$key] as $k => $mt ) {
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode($companystatic->name) . $sep;
print $val["ref"];
}
print "\n";
}
} else // Modèle Export Classique
{
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}
}
// Third party
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode($companystatic->name) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
}
print "\n";
}
}
} else {
llxHeader('', '', '');
$form = new Form($db);
$nom = $langs->trans("PurchasesJournal");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$description = $langs->trans("DescPurchasesJournal") . '<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded");
else
$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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
/*
* Show result array
*/
print '<br><br>';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
// /print "<td>".$langs->trans("JournalNum")."</td>";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>";
print "<t><td>" . $langs->trans("Type") . "</td><td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";
$var = true;
$r = '';
$invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db);
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$date = dol_print_date($db->jdate($val["date"]), 'day');
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . " >";
// print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $invoicestatic->description . "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . " >";
// print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td><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>";
}
}
print "<tr " . $bc[$var] . ">";
// Third party
// print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
foreach ( $tabttc[$key] as $k => $mt ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . length_accounta($k);
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>";
$var = ! $var;
}
print "</table>";
// End of page
llxFooter();
}
$db->close();

View File

@ -0,0 +1,490 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/journal/sellsjournal.php
* \ingroup Accounting Expert
* \brief Page with sells journal
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/report.lib.php");
dol_include_once("/core/lib/date.lib.php");
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/compta/facture/class/facture.class.php");
dol_include_once("/societe/class/client.class.php");
dol_include_once("/accountingex/class/bookkeeping.class.php");
dol_include_once("/accountingex/class/accountingaccount.class.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
$date_startyear = GETPOST('date_startyear');
$date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$action = GETPOST('action');
/*
* View
*/
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0];
$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,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$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 .= " FROM " . MAIN_DB_PREFIX . "facturedet fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture f ON f.rowid = fd.fk_facture";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = " . $conf->entity;
}
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql .= " AND f.type IN (0,1,2)";
else
$sql .= " AND f.type IN (0,1,2,3)";
$sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
$sql .= " ORDER BY f.datef";
dol_syslog('accountingex/journal/sellsjournal.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
$tabttc = array ();
$tabcompany = array ();
$num = $db->num_rows($result);
$i = 0;
$resligne = array ();
while ( $i < $num ) {
$obj = $db->fetch_object($result);
// les variables
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER)) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
else
$compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
}
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
// la ligne facture
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->description;
$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
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($tabtva[$obj->rowid][$compta_tva]))
$tabtva[$obj->rowid][$compta_tva] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
);
$i ++;
}
} else {
dol_print_error($db);
}
/*
* Action
*/
// Bookkeeping Write
if ($action == 'writebookkeeping') {
$now = dol_now();
foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER;
$bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL;
$bookkeeping->create();
}
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
$compte = new AccountingAccount($db);
if ($compte->fetch(null, $k)) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($val["description"], 128);
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL;
$bookkeeping->create();
}
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
$bookkeeping->date_create = $now;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->fk_compte = $compte->id;
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $langs->trans("VAT");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTINGEX_SELL_JOURNAL;
$bookkeeping->create();
}
}
}
}
// export csv
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTINGEX_SEPARATORCSV;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_ventes.csv');
$companystatic = new Client($db);
if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
print $date . $sep;
print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
print length_accountg($conf->global->COMPTA_ACCOUNT_CUSTOMER) . $sep;
foreach ( $tabttc[$key] as $k => $mt ) {
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode($companystatic->name) . $sep;
}
print $val["ref"];
print "\n";
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print dol_trunc($val["description"], 32) . $sep;
print $val["ref"];
print "\n";
}
}
// TVA
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTINGEX_SELL_JOURNAL . $sep;
print length_accountg(html_entity_decode($k)) . $sep;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
}
} else // Modèle Export Classique
{
foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
$date = dol_print_date($db->jdate($val["date"]), 'day');
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode($companystatic->name) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
}
print "\n";
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . dol_trunc($val["description"], 32) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
}
}
}
}
} else {
$form = new Form($db);
llxHeader('', $langs->trans("SellsJournal"));
$nom = $langs->trans("SellsJournal");
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate = time();
$description = $langs->trans("DescSellsJournal") . '<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded");
else
$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);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
/*
* Show result array
*/
print '<br><br>';
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("Account") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";
$var = true;
$r = '';
$invoicestatic = new Facture($db);
$companystatic = new Client($db);
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$date = dol_print_date($db->jdate($val["date"]), 'day');
print "<tr " . $bc[$var] . ">";
// Third party
// print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
foreach ( $tabttc[$key] as $k => $mt ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
print "<td>" . length_accounta($k);
print "</td><td>" . $langs->trans("ThirdParty");
print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
}
print "</tr>";
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . ">";
// print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $invoicestatic->description . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";
}
}
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . ">";
// print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</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>";
}
}
$var = ! $var;
}
print "</table>";
// End of page
llxFooter();
}
$db->close();

View File

@ -0,0 +1,149 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file accountingex/supplier/fiche.php
* \ingroup Accountign Expert
* \brief Page fiche ventilation
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
$action = GETPOST('action');
$id = GETPOST('id', 'int');
$codeventil = GETPOST('codeventil');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
if ($action == 'ventil' && $user->rights->accountingex->access) {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
dol_syslog('accountingex/journal/sellsjournal.php:: $sql=' . $sql);
$resql = $db->query($sql);
if (! $resql) {
setEventMessage($db->lasterror(), 'errors');
}
}
/*
* View
*/
llxHeader("", "", "FicheVentilation");
if ($cancel == $langs->trans("Cancel")) {
$action = '';
}
/*
* Create
*/
$form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db);
$formventilation = new FormVentilation($db);
if ($_GET["id"]) {
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
$sql .= ", aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
if ($num_lignes) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">';
print_fiche_titre($langs->trans("Ventilation"));
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
// ref invoice
print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
$facturefournisseur_static->ref = $objp->facnumber;
$facturefournisseur_static->id = $objp->facid;
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
print '</tr>';
print '<tr><td width="20%">Ligne</td>';
print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" class="button" value="' . $langs->trans("Update") . '"></td></tr>';
print '</table>';
print '</form>';
} else {
print "Error 1";
}
} else {
print "Error 2";
}
} else {
print "Error ID incorrect";
}
llxFooter();
$db->close();

View File

View File

@ -0,0 +1,272 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/supplier/index.php
* \ingroup Accounting Expert
* \brief Page accueil ventilation
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/core/lib/date.lib.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
// Filter
$year = $_GET["year"];
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
// Validate History
$action = GETPOST('action');
if ($action == 'validatehistory') {
$error = 0;
$db->begin();
if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0";
} else {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accountingaccount as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " SET fd.fk_code_ventilation = accnt.rowid";
$sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS;
$sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number";
$sql1 .= " AND fd.fk_code_ventilation = 0";
}
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
} else {
$db->commit();
setEventMessage($langs->trans('Dispatched'), 'mesgs');
}
}
/*
* View
*/
llxHeader('', $langs->trans("SuppliersVentilation"));
$textprevyear = "<a href=\"index.php?year=" . ($year_current - 1) . "\">" . img_previous() . "</a>";
$textnextyear = " <a href=\"index.php?year=" . ($year_current + 1) . "\">" . img_next() . "</a>";
print_fiche_titre($langs->trans("VentilationComptableSupplier") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
print '<b>' . $langs->trans("DescVentilSupplier") . '</b>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
$y = $year_current;
$var = true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td align="left">' . $langs->trans("Account") . '</td>';
print '<td align="left">' . $langs->trans("Intitule") . '</td>';
print '<td align="center">' . $langs->trans("JanuaryMin") . '</td>';
print '<td align="center">' . $langs->trans("FebruaryMin") . '</td>';
print '<td align="center">' . $langs->trans("MarchMin") . '</td>';
print '<td align="center">' . $langs->trans("AprilMin") . '</td>';
print '<td align="center">' . $langs->trans("MayMin") . '</td>';
print '<td align="center">' . $langs->trans("JuneMin") . '</td>';
print '<td align="center">' . $langs->trans("JulyMin") . '</td>';
print '<td align="center">' . $langs->trans("AugustMin") . '</td>';
print '<td align="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td align="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td align="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td align="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT IF(aa.account_number IS NULL, 'Non pointe', aa.account_number) AS 'code comptable',";
$sql .= " IF(aa.label IS NULL, 'Non pointe', aa.label) AS 'Intitulé',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND ff.fk_statut > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity = '" . $conf->entity . "'";
}
$sql .= " GROUP BY ffd.fk_code_ventilation";
dol_syslog('/accountingex/supplier/index.php:: sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . $row[0] . '</td>';
print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>';
print '<td align="right">' . price($row[4]) . '</td>';
print '<td align="right">' . price($row[5]) . '</td>';
print '<td align="right">' . price($row[6]) . '</td>';
print '<td align="right">' . price($row[7]) . '</td>';
print '<td align="right">' . price($row[8]) . '</td>';
print '<td align="right">' . price($row[9]) . '</td>';
print '<td align="right">' . price($row[10]) . '</td>';
print '<td align="right">' . price($row[11]) . '</td>';
print '<td align="right">' . price($row[12]) . '</td>';
print '<td align="right">' . price($row[13]) . '</td>';
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror(); // affiche la derniere erreur sql
}
print "</table>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width=150>' . $langs->trans("Total") . '</td>';
print '<td align="center">' . $langs->trans("JanuaryMin") . '</td>';
print '<td align="center">' . $langs->trans("FebruaryMin") . '</td>';
print '<td align="center">' . $langs->trans("MarchMin") . '</td>';
print '<td align="center">' . $langs->trans("AprilMin") . '</td>';
print '<td align="center">' . $langs->trans("MayMin") . '</td>';
print '<td align="center">' . $langs->trans("JuneMin") . '</td>';
print '<td align="center">' . $langs->trans("JulyMin") . '</td>';
print '<td align="center">' . $langs->trans("AugustMin") . '</td>';
print '<td align="center">' . $langs->trans("SeptemberMin") . '</td>';
print '<td align="center">' . $langs->trans("OctoberMin") . '</td>';
print '<td align="center">' . $langs->trans("NovemberMin") . '</td>';
print '<td align="center">' . $langs->trans("DecemberMin") . '</td>';
print '<td align="center"><b>' . $langs->trans("Total") . '</b></td></tr>';
$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS 'Total',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=1,ffd.total_ht,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=2,ffd.total_ht,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=3,ffd.total_ht,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=4,ffd.total_ht,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=5,ffd.total_ht,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=6,ffd.total_ht,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=7,ffd.total_ht,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=8,ffd.total_ht,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=9,ffd.total_ht,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=10,ffd.total_ht,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=11,ffd.total_ht,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(ff.datef)=12,ffd.total_ht,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(ffd.total_ht),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " AND ff.fk_statut > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND ff.entity = '" . $conf->entity . "'";
}
dol_syslog('/accountingex/supplier/index.php:: sql=' . $sql);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
$row = $db->fetch_row($resql);
print '<tr><td>' . $row[0] . '</td>';
print '<td align="center">' . $row[1] . '</td>';
print '<td align="center">' . price($row[2]) . '</td>';
print '<td align="center">' . price($row[3]) . '</td>';
print '<td align="center">' . price($row[4]) . '</td>';
print '<td align="center">' . price($row[5]) . '</td>';
print '<td align="center">' . price($row[6]) . '</td>';
print '<td align="center">' . price($row[7]) . '</td>';
print '<td align="center">' . price($row[8]) . '</td>';
print '<td align="center">' . price($row[9]) . '</td>';
print '<td align="center">' . price($row[10]) . '</td>';
print '<td align="center">' . price($row[11]) . '</td>';
print '<td align="center">' . price($row[12]) . '</td>';
print '<td align="center"><b>' . price($row[13]) . '</b></td>';
print '</tr>';
$i ++;
}
$db->free($resql);
} else {
print $db->lasterror(); // show last sql error
}
print "</table>\n";
llxFooter();
$db->close();

View File

@ -0,0 +1,232 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>a
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/supplier/lignes.php
* \ingroup Accounting Expert
* \brief Page of detail of the lines of ventilation of invoices suppliers
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/accountingex/class/html.formventilation.class.php");
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/product/class/product.class.php");
dol_include_once("/core/lib/date.lib.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$formventilation = new FormVentilation($db);
$changeaccount = GETPOST('changeaccount');
$is_search = GETPOST('button_search_x');
if (is_array($changeaccount) && count($changeaccount) > 0 && empty($is_search)) {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
dol_syslog('accountingex/supplier/lignes.php::changeaccount sql= ' . $sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
setEventMessage($db->lasterror(), 'errors');
}
if (! $error) {
$db->commit();
setEventMessage($langs->trans('Save'), 'mesgs');
} else {
$db->rollback();
setEventMessage($db->lasterror(), 'errors');
}
}
/*
* View
*/
llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched"));
$page = $_GET["page"];
if ($page < 0)
$page = 0;
if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) {
$limit = $conf->liste_limit;
} else {
$limit = $conf->liste_limit;
}
$offset = $limit * $page;
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.total_ht , l.qty, l.rowid, l.tva_tx, aa.label, aa.account_number, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa";
$sql .= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " AND aa.rowid = l.fk_code_ventilation";
if (strlen(trim($_GET["search_facture"]))) {
$sql .= " AND f.facnumber like '%" . $_GET["search_facture"] . "%'";
}
if (strlen(trim($_GET["search_ref"]))) {
$sql .= " AND p.ref like '%" . $_GET["search_ref"] . "%'";
}
if (strlen(trim($_GET["search_label"]))) {
$sql .= " AND p.label like '%" . $_GET["search_label"] . "%'";
}
if (strlen(trim($_GET["search_desc"]))) {
$sql .= " AND l.description like '%" . $_GET["search_desc"] . "%'";
}
if (strlen(trim($_GET["search_account"]))) {
$sql .= " AND aa.account_number like '%" . $_GET["search_account"] . "%'";
}
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$sql .= " ORDER BY l.rowid";
if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE > 0) {
$sql .= " DESC ";
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountingex/supplier/lignes.php::list sql= ' . $sql1);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, "lignes.php", "", $sortfield, $sortorder, '', $num_lignes);
print '<td align="left"><b>' . $langs->trans("DescVentilDoneSupplier") . '</b></td>';
print '<form method="GET" action="lignes.php">';
print '<table class="noborder" width="100%">';
print '<br><br><div class="inline-block divButAction">'. $langs->trans("ChangeAccount");
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="butAction" value="' . $langs->trans("Validate") . '" /></div>';
print '<tr class="liste_titre"><td>' . $langs->trans("Invoice") . '</td>';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td align="left">' . $langs->trans("Amount") . '</td>';
print '<td colspan="2" align="left">' . $langs->trans("Account") . '</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="' . $_GET["search_facture"] . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . GETPOST("search_ref") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . GETPOST("search_desc") . '"></td>';
print '<td align="right">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
print '<td align="center">&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" alt="' . $langs->trans("Search") . '">';
print '</td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
$facturefournisseur_static = new FactureFournisseur($db);
$product_static = new Product($db);
$var = True;
while ( $i < min($num_lignes, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
$codeCompta = $objp->account_number . ' ' . $objp->label;
print "<tr $bc[$var]>";
// Ref Invoice
$facturefournisseur_static->ref = $objp->facnumber;
$facturefournisseur_static->id = $objp->facid;
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
// Ref Product
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
print '<td align="left">' . price($objp->total_ht) . '</td>';
print '<td align="left">' . $codeCompta . '</td>';
print '<td>' . $objp->rowid . '</td>';
print '<td><a href="./fiche.php?id=' . $objp->rowid . '">';
print img_edit();
print '</a></td>';
print '<td align="center"><input type="checkbox" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>";
$i ++;
}
} else {
print $db->error();
}
print "</table></form>";
$db->close();
llxFooter();

View File

@ -0,0 +1,227 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/supplier/liste.php
* \ingroup Accounting Expert
* \brief Page de ventilation des lignes de facture
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
// Class
dol_include_once("/fourn/class/fournisseur.facture.class.php");
dol_include_once("/fourn/class/fournisseur.product.class.php");
dol_include_once("/accountingex/class/html.formventilation.class.php");
// Langs
$langs->load("compta");
$langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountingex@accountingex");
$action = GETPOST('action');
$codeventil = GETPOST('codeventil', 'array');
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accountingex->access)
accessforbidden();
$formventilation = new FormVentilation($db);
llxHeader('', $langs->trans("Ventilation"));
/*
* Action
*/
if ($action == 'ventil') {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = split("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1];
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
dol_syslog('accountingext/supplier/liste.php:: sql=' . $sql);
if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
} else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
}
$cpt ++;
}
} else {
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
}
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
/*
* Supplier Invoice Lines
*
*/
$page = GETPOST('page');
if ($page < 0)
$page = 0;
if (! empty($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTINGEX_LIMIT_LIST_VENTILATION <= 0) {
$limit = $conf->liste_limit;
} else {
$limit = $conf->liste_limit;
}
$offset = $limit * $page;
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
$sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = '" . $conf->entity . "'";
}
$sql .= " ORDER BY l.rowid";
if ($conf->global->ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO > 0) {
$sql .= " DESC ";
}
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountingext/supplier/liste.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num_lignes = $db->num_rows($result);
$i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
print_barre_liste($langs->trans("InvoiceLines"), $page, "liste.php", "", $sortfield, $sortorder, '', $num_lignes);
print '<td align="left"><br><b>' . $langs->trans("DescVentilTodoSupplier") . '</b></br></td>';
print '<form action="liste.php" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>Facture</td>';
print '<td align="left">' . $langs->trans("Ref") . '</td>';
print '<td align="left">' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td align="right">' . $langs->trans("Amount") . '</td>';
print '<td align="right">' . $langs->trans("Compte") . '</td>';
print '<td align="center">' . $langs->trans("IntoAccount") . '</td>';
print '<td align="center">' . $langs->trans("Ventilate") . '</td>';
print "</tr>\n";
$facturefourn_static = new FactureFournisseur($db);
$productfourn_static = new ProductFournisseur($db);
$form = new Form($db);
$var = True;
while ( $i < min($num_lignes, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
print "<tr $bc[$var]>";
// Ref facture
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
// Ref facture supplier
$productfourn_static->ref = $objp->product_ref;
$productfourn_static->id = $objp->product_id;
$productfourn_static->type = $objp->type;
print '<td>';
if ($productfourn_static->id)
print $productfourn_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
// print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.$objp->ref.'</a></td>';
// print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.$objp->ref_supplier.'</a></td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<td>' . stripslashes(nl2br($objp->description)) . '</td>';
print '<td align="right">';
print price($objp->price);
print '</td>';
print '<td align="right">';
print $objp->code_buy;
print '</td>';
// Colonne choix du compte
print '<td align="center">';
print $formventilation->select_account($objp->aarowid, 'codeventil[]', 1);
print '</td>';
// Colonne choix ligne a ventiler
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->code_buy ? "checked" : "") . '/>';
print '</td>';
print "</tr>";
$i ++;
}
print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventiler") . '"></td></tr>';
print "</table>";
print '</form>';
} else {
print $db->error();
}
llxFooter();
$db->close();

View File

@ -1,260 +0,0 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/accounting.php
* \ingroup compta
* \brief Page to setup accountancy module
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->load('admin');
$langs->load('compta');
if (!$user->admin)
accessforbidden();
$action = GETPOST('action','alpha');
$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
if ($action == 'setcomptamode')
{
$compta_mode = GETPOST('compta_mode','alpha');
$res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'setchart')
{
$chartofaccounts = GETPOST('chartofaccounts','alpha');
$res = dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
if ($action == 'update' || $action == 'add')
{
$constname = GETPOST('constname','alpha');
$constvalue = GETPOST('constvalue','alpha');
$consttype = GETPOST('consttype','alpha');
$constnote = GETPOST('constnote','alpha');
$res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
/*if ($action == 'delete')
{
if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
{
print $db->error();
}
}*/
/*
* Affichage page
*/
llxHeader();
$form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
print '<br>';
print '<table class="noborder" width="100%">';
// Cas du parametre COMPTA_MODE
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setcomptamode">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
print "</tr>\n";
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
// Write info on way to count VAT
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
{
// print "<br>\n";
// print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
}
else
{
// print "<br>\n";
// print nl2br($langs->trans('OptionModeTrueInfoExpert'));
}
print "</td></tr>\n";
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
print '</form>';
print "</table>\n";
/*
* Define Chart of accounts
*
*/
if (! empty($conf->global->ACCOUNTING_SELECTCHART) && ! empty($conf->accounting->enabled))
{
print '<br>';
print_titre($langs->trans("Definechartofaccounts"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<table class="noborder" width="100%">';
$var=True;
print '<tr class="liste_titre">';
print '<td>';
print '<input type="hidden" name="action" value="setchart">';
print $langs->trans("Chartofaccounts").'</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'>';
print "<td>".$langs->trans("Selectchartofaccounts")."</td>";
print "<td>";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
print '<option value="0">'.$langs->trans("DoNotSuggestChart").'</option>';
$sql = "SELECT rowid, pcg_version, fk_pays, label, active";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_system";
$sql.= " WHERE active = 1";
$sql.= " AND fk_pays = ".$mysoc->country_id;
$var=True;
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$var=!$var;
$row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"';
print $conf->global->CHARTOFACCOUNTS == $row[0] ? ' selected="selected"':'';
print '>'.$row[1].' - '.$row[3].'</option>';
$i++;
}
}
print "</select>";
print "</td></tr>";
print "</table>";
print "</form>";
}
print "<br>\n";
// Cas des autres parametres COMPTA_*
$list=array('COMPTA_PRODUCT_BUY_ACCOUNT','COMPTA_PRODUCT_SOLD_ACCOUNT','COMPTA_SERVICE_BUY_ACCOUNT','COMPTA_SERVICE_SOLD_ACCOUNT',
'COMPTA_VAT_ACCOUNT','COMPTA_ACCOUNT_CUSTOMER','COMPTA_ACCOUNT_SUPPLIER'
);
$num=count($list);
if ($num)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
}
foreach ($list as $key)
{
$var=!$var;
print '<form action="accounting.php" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="consttype" value="string">';
print '<input type="hidden" name="constname" value="'.$key.'">';
print '<tr '.$bc[$var].' class="value">';
// Param
$libelle = $langs->trans($key);
print '<td>'.$libelle;
//print ' ('.$key.')';
print "</td>\n";
// Value
print '<td>';
print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
print "</td></tr>\n";
print '</form>';
$i++;
}
if ($num)
{
print "</table>\n";
}
$db->close();
llxFooter();

View File

@ -0,0 +1,188 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file accountingex/core/lib/account.lib.php
* \ingroup Accounting Expert
* \brief Ensemble de fonctions de base pour les comptes comptables
*/
/**
* Prepare array with list of tabs
*
* @param Object $object to tabs
* @return array of tabs to shoc
*/
function admin_accounting_prepare_head($object) {
global $langs, $conf;
$h = 0;
$head = array ();
$head[$h][0] = dol_buildpath('/accountancy/admin/index.php', 1);
$head[$h][1] = $langs->trans("Configuration");
$head[$h][2] = 'general';
$h ++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin');
$head[$h][0] = dol_buildpath('/accountancy/admin/journaux.php', 1);
$head[$h][1] = $langs->trans("Journaux");
$head[$h][2] = 'journal';
$h ++;
$head[$h][0] = dol_buildpath('/accountancy/admin/export.php', 1);
$head[$h][1] = $langs->trans("Export");
$head[$h][2] = 'export';
$h ++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_admin', 'remove');
return $head;
}
/**
* Prepare array with list of tabs
*
* @param Object $object to tabs
* @return array of tabs to shoc
*/
function accounting_prepare_head($object) {
global $langs, $conf;
$h = 0;
$head = array ();
$head[$h][0] = dol_buildpath('/accountancy/admin/fiche.php', 1) . '?id=' . $object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h ++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove');
return $head;
}
/**
* Return general account with defined length
*
* @param $account
*
* @return $account
*/
function length_accountg($account) {
global $conf, $langs;
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
if (! empty($g)) {
// Clean parameters
$i = strlen($account);
if ($i >= 2) {
while ( $i < $g ) {
$account .= '0';
$i ++;
}
return $account;
} else {
return $account;
}
} else {
return $account;
}
}
/**
* Return auxiliary account with defined length
*
* @param $account
*
* @return $account
*/
function length_accounta($accounta) {
global $conf, $langs;
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
if (! empty($a)) {
// Clean parameters
$i = strlen($accounta);
if ($i >= 2) {
while ( $i < $a ) {
$accounta .= '0';
$i ++;
}
return $accounta;
} else {
return $accounta;
}
} else {
return $accounta;
}
}
/**
* Return account with defined length for Sage export software
*
* @param $account
*
* @return $account
*/
function length_exportsage($txt, $len, $end) {
// $txt = utf8_decode($txt);
// problem with this function, but we need to have the number of letter
if (strlen($txt) == $len) {
$res = $txt;
}
elseif (strlen($txt) > $len) {
$res = substr($txt, 0, $len);
}
else {
if ($end == 1) {
$res = $txt;
} else {
$res = "";
}
for($i = strlen($txt); $i <= ($len - 1); $i ++) {
$res .= " ";
}
if ($end == 0) {
$res .= $txt;
}
}
return $res;
}

View File

@ -1,9 +1,8 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
*
* 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
@ -20,154 +19,573 @@
*/
/**
* \defgroup accounting Module accounting
* \brief Module to include accounting features
* \file htdocs/core/modules/modAccounting.class.php
* \ingroup accounting
* \brief Fichier de description et activation du module Comptabilite Expert
* \file accountingex/core/modules/modAccountingExpert.class.php
* \ingroup Accounting Expert
* \brief Module to activate Accounting Expert module
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Classe de description et activation du module Comptabilite Expert
* \class modAccountingExpert
* \brief Description and activation class for module accounting expert
*/
class modAccounting extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
* Constructor.
* Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
* @param DoliDB $db
*/
function __construct($db)
{
global $conf;
$this->db = $db;
$this->numero = 50400 ;
$this->db = $db;
$this->numero = 50400;
$this->family = "financial";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion complete de comptabilite (doubles parties)";
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Advanced manage of accounting";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
//$this->version = 'dolibarr';
$this->version = "development";
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->version = 'development';
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
$this->special = 0;
// Config pages
$this->config_page_url = array("accounting.php");
// Dependancies
$this->depends = array("modFacture","modBanque","modTax");
$this->requiredby = array();
$this->conflictwith = array("modComptabilite");
$this->langfiles = array("compta");
// Constants
$this->const = array(0=>array('MAIN_COMPANY_CODE_ALWAYS_REQUIRED','chaine','1','With this constants on, third party code is always required whatever is numbering module behaviour',0,'current',1),
1=>array('MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED','chaine','1','With this constants on, bank account number is always required',0,'current',1),
); // List of particular constants to add when module is enabled
$this->picto = 'accountingex@accountingex';
// Defined if the directory /mymodule/inc/triggers/ contains triggers or not
// $this->triggers = 1;
// Data directories to create when module is enabled
$this->dirs = array("/accounting/temp");
$this->dirs = array (
'/accountingex/temp'
);
// Config pages
$this->config_page_url = array('index.php@accounting');
// Dependencies
$this->depends = array ("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array (); // List of modules id to disable if this one is disabled
$this->conflictwith = array ("modComptabilite"); // List of modules are in conflict with this module
$this->phpmin = array (
5,
2
); // Minimum version of PHP required by module
$this->need_dolibarr_version = array (
3,
4
); // Minimum version of Dolibarr required by module
$this->langfiles = array (
"accountingex@accountingex"
);
// Constants
$this->const = array ();
$this->const[1] = array (
"MAIN_COMPANY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, third party code is always required whatever is numbering module behaviour"
);
$this->const[2] = array (
"MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, bank account number is always required"
);
$this->const[1] = array (
"ACCOUNTING_SEPARATORCSV",
"string",
","
);
$this->const[2] = array (
"ACCOUNTING_ACCOUNT_SUSPENSE",
"chaine",
"471"
);
$this->const[3] = array (
"ACCOUNTING_SELL_JOURNAL",
"chaine",
"VTE"
);
$this->const[4] = array (
"ACCOUNTING_PURCHASE_JOURNAL",
"chaine",
"ACH"
);
$this->const[5] = array (
"ACCOUNTING_SOCIAL_JOURNAL",
"chaine",
"SOC"
);
$this->const[6] = array (
"ACCOUNTING_CASH_JOURNAL",
"chaine",
"CAI"
);
$this->const[7] = array (
"ACCOUNTING_MISCELLANEOUS_JOURNAL",
"chaine",
"OD"
);
$this->const[8] = array (
"ACCOUNTING_BANK_JOURNAL",
"chaine",
"BQ"
); // Deprecated Move into llx_bank_account
$this->const[9] = array (
"ACCOUNTING_ACCOUNT_TRANSFER_CASH",
"chaine",
"58"
);
$this->const[10] = array (
"CHARTOFACCOUNTS",
"chaine",
"2"
);
$this->const[11] = array (
"ACCOUNTING_MODELCSV",
"chaine",
"0"
);
$this->const[12] = array (
"ACCOUNTING_LENGTH_GACCOUNT",
"chaine",
""
);
$this->const[13] = array (
"ACCOUNTING_LENGTH_AACCOUNT",
"chaine",
""
);
$this->const[14] = array (
"ACCOUNTING_LIMIT_LIST_VENTILATION",
"chaine",
"50"
);
$this->const[15] = array (
"ACCOUNTING_LIST_SORT_VENTILATION_TODO",
"yesno",
"1"
);
$this->const[16] = array (
"ACCOUNTING_LIST_SORT_VENTILATION_DONE",
"yesno",
"1"
);
// Tabs
$this->tabs = array();
// Css
$this->module_parts = array (
'css' => array (
'/accountingex/css/accountingex.css.php'
)
);
// Boxes
$this->boxes = array();
$this->boxes = array ();
// Permissions
$this->rights = array();
$this->rights_class = 'accounting';
$r=0;
$this->rights[$r][0] = 50401;
$this->rights[$r][1] = 'Lire le plan de compte';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'plancompte';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 50402;
$this->rights[$r][1] = 'Creer/modifier un plan de compte';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'plancompte';
$this->rights[$r][5] = 'creer';
$r++;
$this->rights[$r][0] = 50403;
$this->rights[$r][1] = 'Cloturer plan de compte';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'plancompte';
$this->rights[$r][5] = 'cloturer';
$r++;
$this->rights[$r][0] = 50411;
$this->rights[$r][1] = 'Lire les mouvements comptables';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'mouvements';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 50412;
$this->rights[$r][1] = 'Creer/modifier/annuler les mouvements comptables';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvements';
$this->rights[$r][5] = 'creer';
$r++;
$this->rights[$r][0] = 50415;
$this->rights[$r][1] = 'Lire CA, bilans, resultats, journaux, grands livres';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'comptarapport';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights = array (); // Permission array used by this module
$r = 0;
$this->rights[$r][0] = 150001; // Permission id (must not be already used)
$this->rights[$r][1] = 'Acces_module'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'access'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r ++;
$this->rights[$r][0] = 150002; // Permission id (must not be already used)
$this->rights[$r][1] = 'Administration_module'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'admin'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r ++;
$this->rights[$r][0] = 150010; // Permission id (must not be already used)
$this->rights[$r][1] = 'Développement'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'dev'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r ++;
// Main menu entries
$this->menus = array ();
$r = 0;
$this->menu[$r] = array (
'fk_menu' => 0,
'type' => 'top',
'titre' => 'Accounting',
'mainmenu' => 'accounting',
'leftmenu' => '0',
'url' => '/accountingex/customer/index.php',
'langs' => 'accountingex@accountingex',
'position' => 100,
'perms' => '$user->rights->accountingex->access',
'enabled' => '$conf->accountingexpert->enabled',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting',
'type' => 'left',
'titre' => 'CustomersVentilation',
'leftmenu' => 'CustomersVentilation',
'mainmenu' => 'accounting',
'url' => '/accountingex/customer/index.php',
'langs' => 'accountingex@accountingex',
'position' => 101,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation',
'type' => 'left',
'titre' => 'ToDispatch',
'leftmenu' => 'ToDispatchCustomer',
'mainmenu' => 'accounting',
'url' => '/accountingex/customer/liste.php',
'langs' => 'accountingex@accountingex',
'position' => 102,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=CustomersVentilation',
'type' => 'left',
'titre' => 'Dispatched',
'leftmenu' => 'DispatchedCustomer',
'mainmenu' => 'accounting',
'url' => '/accountingex/customer/lignes.php',
'langs' => 'accountingex@accountingex',
'position' => 103,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting',
'type' => 'left',
'titre' => 'SuppliersVentilation',
'leftmenu' => 'SuppliersVentilation',
'mainmenu' => 'accounting',
'url' => '/accountingex/supplier/index.php',
'langs' => 'accountingex@accountingex',
'position' => 110,
'enabled' => '$conf->fournisseur->enabled',
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation',
'type' => 'left',
'titre' => 'ToDispatch',
'leftmenu' => 'ToDispatchSupplier',
'mainmenu' => 'accounting',
'url' => '/accountingex/supplier/liste.php',
'langs' => 'accountingex@accountingex',
'position' => 111,
'enabled' => '$conf->fournisseur->enabled',
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=SuppliersVentilation',
'type' => 'left',
'titre' => 'Dispatched',
'leftmenu' => 'DispatchedSupplier',
'mainmenu' => 'accounting',
'url' => '/accountingex/supplier/lignes.php',
'langs' => 'accountingex@accountingex',
'position' => 112,
'enabled' => '$conf->fournisseur->enabled',
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting',
'type' => 'left',
'titre' => 'Journaux',
'leftmenu' => 'Journaux',
'mainmenu' => 'accounting',
// 'url'=>'',
'langs' => 'accountingex@accountingex',
'position' => 120,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux',
'type' => 'left',
'titre' => 'SellsJournal',
'leftmenu' => 'SellsJournal',
'mainmenu' => 'accounting',
'url' => '/accountingex/journal/sellsjournal.php',
'langs' => 'accountingex@accountingex',
'position' => 121,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux',
'type' => 'left',
'titre' => 'PurchasesJournal',
'leftmenu' => 'PurchasesJournal',
'mainmenu' => 'accounting',
'url' => '/accountingex/journal/purchasesjournal.php',
'langs' => 'accountingex@accountingex',
'position' => 122,
'enabled' => '$conf->fournisseur->enabled',
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux',
'type' => 'left',
'titre' => 'CashJournal',
'leftmenu' => 'CashJournal',
'mainmenu' => 'accounting',
'url' => '/accountingex/journal/cashjournal.php',
'langs' => 'accountingex@accountingex',
'position' => 123,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Journaux',
'type' => 'left',
'titre' => 'BankJournal',
'leftmenu' => 'BankJournal',
'mainmenu' => 'accounting',
'url' => '/accountingex/journal/bankjournal.php',
'langs' => 'accountingex@accountingex',
'position' => 200,
'enabled' => '$conf->banque->enabled',
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting',
'type' => 'left',
'titre' => 'Bookkeeping',
'leftmenu' => 'Bookkeeping',
'mainmenu' => 'accounting',
'url' => '/accountingex/bookkeeping/liste.php',
'langs' => 'accountingex@accountingex',
'position' => 300,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping',
'type' => 'left',
'titre' => 'ByYear',
'leftmenu' => 'ByYear',
'mainmenu' => 'accounting',
'url' => '/accountingex/bookkeeping/listebyyear.php',
'langs' => 'accountingex@accountingex',
'position' => 301,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Bookkeeping',
'type' => 'left',
'titre' => 'AccountBalanceByMonth',
'leftmenu' => 'AccountBalanceByMonth',
'mainmenu' => 'accounting',
'url' => '/accountingex/bookkeeping/balancebymonth.php',
'langs' => 'accountingex@accountingex',
'position' => 302,
'enabled' => 1,
'perms' => 1,
'target' => '',
'user' => 0
);
$r ++;
// Parameters Menu
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting',
'type' => 'left',
'titre' => 'Parameters',
'leftmenu' => 'Parameters',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/index.php',
'langs' => 'accountingex@accountingex',
'position' => 400,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters',
'type' => 'left',
'titre' => 'Globalparameters',
'leftmenu' => 'Globalparameters',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/index.php',
'langs' => 'accountingex@accountingex',
'position' => 401,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters',
'type' => 'left',
'titre' => 'Chartofaccounts',
'leftmenu' => 'Chartofaccounts',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/account.php',
'langs' => 'accountingex@accountingex',
'position' => 402,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Globalparameters',
'type' => 'left',
'titre' => 'Menuaccount',
'leftmenu' => 'Menuaccount',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/account.php',
'langs' => 'accountingex@accountingex',
'position' => 403,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters',
'type' => 'left',
'titre' => 'Menuthirdpartyaccount',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/thirdpartyaccount.php',
'langs' => 'accountingex@accountingex',
'position' => 404,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=accounting,fk_leftmenu=Parameters',
'type' => 'left',
'titre' => 'MenuTools',
'mainmenu' => 'accounting',
'url' => '/accountingex/admin/productaccount.php',
'langs' => 'accountingex@accountingex',
'position' => 405,
'enabled' => 1,
'perms' => '$user->rights->accountingex->admin',
'target' => '',
'user' => 0
);
$r ++;
}
/**
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
// Prevent pb of modules not correctly disabled
//$this->remove($options);
*/
function init($options='')
{
$sql = array();
return $this->_init($sql,$options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_init($sql,$options);
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
global $conf;
$sql = array("DELETE FROM ".MAIN_DB_PREFIX."const where name='MAIN_COMPANY_CODE_ALWAYS_REQUIRED' and entity IN ('0','".$conf->entity."')");
return $this->_remove($sql,$options);
}
}
}

View File

@ -14,14 +14,12 @@
-- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as defailt NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active;
-- Defined only to have specific list for countries that can't use generic list (like argentina that need type A or B)
ALTER TABLE llx_c_typent ADD COLUMN fk_country integer NULL AFTER libelle;
@ -29,10 +27,36 @@ INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang)
INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4);
ALTER TABLE llx_user ADD COLUMN fk_user_creat integer AFTER tms;
ALTER TABLE llx_user ADD COLUMN fk_user_modif integer AFTER fk_user_creat;
-- Add module accounting Expert
ALTER TABLE llx_bookkeeping RENAME TO llx_accounting_bookkeeping; -- To update old user of module Accounting Expert
CREATE TABLE llx_accounting_bookkeeping
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
doc_date date NOT NULL,
doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur
doc_ref varchar(30) NOT NULL, -- facture_client/reglement_client/... reference number
fk_doc integer NOT NULL, -- facture_client/reglement_client/... rowid
fk_docdet integer NOT NULL, -- facture_client/reglement_client/... line rowid
code_tiers varchar(24), -- code tiers
numero_compte varchar(32) DEFAULT NULL,
label_compte varchar(128) NOT NULL,
debit double NOT NULL,
credit double NOT NULL,
montant double NOT NULL,
sens varchar(1) DEFAULT NULL,
fk_user_author integer NOT NULL,
import_key varchar(14),
code_journal varchar(10) DEFAULT NULL,
piece_num integer NOT NULL
) ENGINE=innodb;
ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active;
ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number;
ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity;
@ -40,7 +64,6 @@ ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec;
ALTER TABLE llx_accountingaccount add column fk_user_author integer DEFAULT NULL AFTER label;
ALTER TABLE llx_accountingaccount add column fk_user_modif integer DEFAULT NULL AFTER fk_user_author;
-- Drop old table
DROP TABLE llx_compta;
DROP TABLE llx_compta_account;
@ -61,8 +84,6 @@ ALTER TABLE llx_product MODIFY COLUMN accountancy_code_buy varchar(32);
ALTER TABLE llx_user MODIFY COLUMN accountancy_code varchar(32);
ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number;
ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_date;

View File

@ -0,0 +1,39 @@
-- ============================================================================
-- Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
-- Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ============================================================================
CREATE TABLE llx_accounting_bookkeeping
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
doc_date date NOT NULL,
doc_type varchar(30) NOT NULL, -- facture_client/reglement_client/facture_fournisseur/reglement_fournisseur
doc_ref varchar(30) NOT NULL, -- facture_client/reglement_client/... reference number
fk_doc integer NOT NULL, -- facture_client/reglement_client/... rowid
fk_docdet integer NOT NULL, -- facture_client/reglement_client/... line rowid
code_tiers varchar(24), -- code tiers
numero_compte varchar(32) DEFAULT NULL,
label_compte varchar(128) NOT NULL,
debit double NOT NULL,
credit double NOT NULL,
montant double NOT NULL,
sens varchar(1) DEFAULT NULL,
fk_user_author integer NOT NULL,
import_key varchar(14),
code_journal varchar(10) DEFAULT NULL,
piece_num integer NOT NULL
) ENGINE=innodb;

View File

@ -0,0 +1,161 @@
# Dolibarr language file - en_US - Accounting Expert
CHARSET=UTF-8
Module150000Name=Accounting Expert
Module150000Desc=Advanced management of the accounting
Accounting=Accounting
Globalparameters=Global parameters
Chartofaccounts=Chart of accounts
Fiscalyear=Fiscal years
Menuaccount=Accounting accounts
Menuthirdpartyaccount=Thirdparty accounts
MenuTools=Tools
ConfigAccountingExpert=Configuration of the module accounting expert
Journaux=Journaux
Exports=Exports
About=About
Contributors=Contributors
Investors=Investors
Modelcsv=Model of export
Selectmodelcsv=Select a model of export
Modelcsv_normal=Classic export
Modelcsv_CEGID=Export towards CEGID Expert
BackToChartofaccounts=Return chart of accounts
Definechartofaccounts=Define a chart of accounts
Selectchartofaccounts=Select a chart of accounts
Validate=Validate
Addanaccount=Add an accounting account
AccountAccounting=Accounting account
Ventilation=Ventilation
ToDispatch=To dispatch
Dispatched=Dispatched
CustomersVentilation=Ventilation customers
SuppliersVentilation=Ventilation suppliers
TradeMargin=Trade margin
Reports=Reports
ByCustomerInvoice=By invoices customers
ByMonth=By Month
NewAccount=New accounting account
Update=Update
List=List
Create=Create
UpdateAccount=Modification of an accounting account
UpdateMvts=Modification of a movement
WriteBookKeeping=Record accounts in general ledger
Bookkeeping=General ledger
AccountBalanceByMonth=Account balance by month
VentilationComptable=Accounting ventilation
VentilationComptableSupplier=Accounting ventilation supplier
Intitule=Label
Line=Line
CAHTF=Total purchase supplier HT
InvoiceLines=Lines of invoice to be ventilated
InvoiceLinesDone=Ventilated lines of invoice
IntoAccount=In the accounting account
Ventilate=Ventilate
VentilationAuto=Automatic ventilation
Processing=Processing
EndProcessing=The end of processing
AnyLineVentilate=Any lines to ventilate
SelectedLines=Selected lines
Lineofinvoice=Line of invoice
VentilatedinAccount=Ventilated successfully in the accounting account
NotVentilatedinAccount=Not ventilated in the accounting account
ACCOUNTINGEX_SEPARATORCSV=Separator CSV
ACCOUNTINGEX_LIMIT_LIST_VENTILATION=Number of elements to be ventilated shown by page (maximum recommended : 50)
ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Begin the sorting of the pages of ventilation "Has to ventilate" by the most recent elements
ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Begin the sorting of the pages of ventilation "Ventilated" by the most recent elements
AccountLength=Length of the accounting accounts shown in Dolibarr
AccountLengthDesc=Function allowing to feign a length of accounting account by replacing spaces by the zero figure. This function touches only the display, it does not modify the accounting accounts registered in Dolibarr. For the export, this function is necessary to be compatible with certain software.
ACCOUNTINGEX_LENGTH_GACCOUNT=Length of the general accounts
ACCOUNTINGEX_LENGTH_AACCOUNT=Length of the third party accounts
ACCOUNTINGEX_SELL_JOURNAL=Sell journal
ACCOUNTINGEX_PURCHASE_JOURNAL=Purchase journal
ACCOUNTINGEX_BANK_JOURNAL=Bank journal
ACCOUNTINGEX_CASH_JOURNAL=Cash journal
ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Miscellaneous journal
ACCOUNTINGEX_SOCIAL_JOURNAL=Social journal
ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=Account of transfer
ACCOUNTINGEX_ACCOUNT_SUSPENSE=Account of wait
COMPTA_PRODUCT_BUY_ACCOUNT=Accounting account by default for bought products (if not defined in the product sheet)
COMPTA_PRODUCT_SOLD_ACCOUNT=Accounting account by default for the sold products (if not defined in the product sheet)
COMPTA_SERVICE_BUY_ACCOUNT=Accounting account by default for the bought services (if not defined in the service sheet)
COMPTA_SERVICE_SOLD_ACCOUNT=Accounting account by default for the sold services (if not defined in the service sheet)
Doctype=Type of document
Docdate=Date
Docref=Reference
Numerocompte=Account
Code_tiers=Thirdparty
Labelcompte=Label account
Debit=Debit
Credit=Credit
Amount=Amount
Sens=Sens
Codejournal=Journal
DelBookKeeping=Delete the records of the general ledger
SellsJournal=Sells journal
PurchasesJournal=Purchases journal
DescSellsJournal=Sells journal
DescPurchasesJournal=Purchases journal
BankJournal=Bank journal
DescBankJournal=Banl journal including all the types of payments other than cash
CashJournal=Cash journal
DescCashJournal=Cash journal including the type of payment cash
CashPayment=Cash Payment
SupplierInvoicePayment=Payment of invoice supplier
CustomerInvoicePayment=Payment of invoice customer
ThirdPartyAccount=Thirdparty account
NumMvts=Number of movement
ListeMvts=List of the movement
ErrorDebitCredit=Debit and Credit cannot have a value at the same time
ReportThirdParty=List thirdparty account
DescThirdPartyReport=Consult here the list of the thirdparty customers and the suppliers and their accounting accounts
ListAccounts=List of the accounting accounts
Pcgversion=Version of the plan
Pcgtype=Class of account
Pcgsubtype=Under class of account
Accountparent=Root of the account
Active=Statement
NewFiscalYear=New fiscal year
DescVentilCustomer=Consult here the annual accounting ventilation of your invoices customers
TotalVente=Total turnover HT
TotalMarge=Total sales margin
DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their accounting account
DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounting account
ChangeAccount=Change the accounting account for lines selected by the account:
Vide=-
DescVentilSupplier=Consult here the annual accounting ventilation of your invoices suppliers
DescVentilTodoSupplier=Ventilate your lines of invoice supplier with an accounting account
DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account
ValidateHistory=Validate Automatically
ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used
FicheVentilation=Ventilation card

View File

@ -0,0 +1,161 @@
# Dolibarr language file - es_ES - Experto de la contabilidad
CHARSET=UTF-8
Module150000Name= Desglose contable
Module150000Desc= Gestión desglose contable
Accounting=Contabilidad
Globalparameters=Configuración global
Chartofaccounts=Cuentas
Fiscalyear=Los años fiscales
Menuaccount=Contabilidad Cuentas
Menuthirdpartyaccount=Cuentas de terceros
MenuTools=Instrumentos
ConfigAccountingExpert=Módulo de configuración experto en contabilidad
Journaux=Periódicos
Exports=Exportaciones
About=acerca de
Contributors=Contributors
Investors=Investors
Modelcsv=Plantilla de Exportación
Selectmodelcsv=Seleccione una plantilla de exportación
Modelcsv_normal=clásico exportación
Modelcsv_CEGID=Exportar a Cegid Expert
BackToChartofaccounts=Plan contable Volver
Definechartofaccounts=Definir la contabilidad
Selectchartofaccounts=Seleccione una contabilidad
Validate=validar
Addanaccount=Añadir una cuenta contable
AccountAccounting=cuenta de Contabilidad
Ventilation=ventilación
ToDispatch=Para llevar a cabo
Dispatched=Realizado
CustomersVentilation=Los clientes de ventilación
SuppliersVentilation=proveedores de ventilación
TradeMargin=margen de beneficio
Reports=relaciones
ByCustomerInvoice=Por las facturas de los clientes
ByMonth=por mes
NewAccount=Nueva cuenta contable
Update=Actualización
List=lista
Create=crear
UpdateAccount=Editar una cuenta
UpdateMvts=Modificación de un movimiento
WriteBookKeeping=Asientos contables en el libro mayor
Bookkeeping=libro mayor
AccountBalanceByMonth=Saldo Mensual
VentilationComptable=desglose de Contabilidad
VentilationComptableSupplier=Proveedor de cuentas de ventilación
Intitule=título
Line=línea
CAHTF=Total HT proveedor compra
InvoiceLines=Líneas de factura para ventilar
InvoiceLinesDone=Líneas de factura rotos
IntoAccount=En la cuenta
Ventilate=ventilar
VentilationAuto=ventilación automática
Processing=Tratamiento
EndProcessing=Final del tratamiento
AnyLineVentilate=No hay línea para ventilar
SelectedLines=Las líneas seleccionadas
Lineofinvoice=Línea de la factura
VentilatedinAccount=Ventilada con éxito en la cuenta contable
NotVentilatedinAccount=Cuenta sin ventilación en la contabilidad
ACCOUNTINGEX_SEPARATORCSV=separador CSV
ACCOUNTINGEX_LIMIT_LIST_VENTILATION=(El máximo recomendado: 50) Número de elementos que se muestran por página para ventilar
ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Páginas de inicio de clasificación de ventilación "desglose" de las pruebas más recientes
ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Páginas de inicio de clasificación de ventilación "ventilada" por la evidencia más reciente
AccountLength=Cuentas contables longitud mostrada en Dolibarr
AccountLengthDesc=Función para simular una longitud de cuenta contable sustituyendo espacios con el número cero. Esta función sólo afecta a la pantalla, no cambia las cuentas contables registrados en Dolibarr. Para la exportación, esta función se requiere para ser compatible con algunos programas.
ACCOUNTINGEX_LENGTH_GACCOUNT=Longitud de las cuentas generales
ACCOUNTINGEX_LENGTH_AACCOUNT=Duración de subcuentas
ACCOUNTINGEX_SELL_JOURNAL=Diario de Ventas
ACCOUNTINGEX_PURCHASE_JOURNAL=Diario de Compras
ACCOUNTINGEX_BANK_JOURNAL=Diario del Banco
ACCOUNTINGEX_CASH_JOURNAL=Diario de Caso
ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Diario de Operaciones diversas
ACCOUNTINGEX_SOCIAL_JOURNAL=Diario Social
ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=En caso de transferencia
ACCOUNTINGEX_ACCOUNT_SUSPENSE=Cuenta Suspense
COMPTA_PRODUCT_BUY_ACCOUNT=Cuenta predeterminada de contabilidad para los productos comprados (si no se define en el producto)
COMPTA_PRODUCT_SOLD_ACCOUNT=Cuenta predeterminada de contabilidad para los productos vendidos (si no se define en el producto)
COMPTA_SERVICE_BUY_ACCOUNT=Cuenta predeterminada de contabilidad para los servicios adquiridos (si no está definido en la hoja de servicio)
COMPTA_SERVICE_SOLD_ACCOUNT=Cuenta predeterminada de contabilidad para servicios vendidos (si no se define en la ficha de servicio)
Doctype=Tipo de documento
Docdate=fecha
Docref=referencia
Numerocompte=cuenta
Code_tiers=tercera
Labelcompte=cuenta de fraseología
Debit=débito
Credit=crédito
Amount=cantidad
Sens=sentido
Codejournal=periódico
DelBookKeeping=Eliminar el libro mayor
SellsJournal=Sell journal
PurchasesJournal=Purchase journal
DescSellsJournal=Sell journal
DescPurchasesJournal=Purchase journal
BankJournal=Diario de banco
DescBankJournal=Descripción de la revista del Banco
CashJournal=Libro de Caja
DescCashJournal=Descripción Libro de Caja
CashPayment=especies Reglas
SupplierInvoicePayment=Reglamento Factura
CustomerInvoicePayment=Factura del cliente Reglamento
ThirdPartyAccount=Thirdparty account
NumMvts=Number of movement
ListeMvts=List of the movement
ErrorDebitCredit=Debit and Credit cannot have a value at the same time
ReportThirdParty=List thirdparty account
DescThirdPartyReport=Consult here the list of the thirdparty customers and the suppliers and their accounting accounts
ListAccounts=List of the accounting accounts
Pcgversion=Version of the plan
Pcgtype=Class of account
Pcgsubtype=Under class of account
Accountparent=Root of the account
Active=Statement
NewFiscalYear=New fiscal year
DescVentilCustomer=Consult here the annual accounting ventilation of your invoices customers
TotalVente=Total turnover HT
TotalMarge=Total sales margin
DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their accounting account
DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounting account
ChangeAccount=Change the accounting account for lines selected by the account:
Vide=-
DescVentilSupplier=Consult here the annual accounting ventilation of your invoices suppliers
DescVentilTodoSupplier=Ventilate your lines of invoice supplier with an accounting account
DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account
ValidateHistory=Validate Automatically
ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used
FicheVentilation=Ventilation card

View File

@ -0,0 +1,161 @@
# Dolibarr language file - fr_FR - Accounting Expert
CHARSET=UTF-8
Module150000Name=Comptabilité Expert
Module150000Desc=Gestion avancée de la comptabilité
Accounting=Comptabilité
Globalparameters=Paramètres globaux
Chartofaccounts=Plan comptable
Fiscalyear=Exercices fiscaux
Menuaccount=Comptes comptables
Menuthirdpartyaccount=Comptes tiers
MenuTools=Outils
ConfigAccountingExpert=Configuration du module comptabilité expert
Journaux=Journaux
Exports=Exports
About=A propos
Contributors=Contributeurs
Investors=Investisseurs
Modelcsv=Modèle d'export
Selectmodelcsv=Sélectionnez un modèle d'export
Modelcsv_normal=Export classique
Modelcsv_CEGID=Export vers CEGID Expert
BackToChartofaccounts=Retour plan comptable
Definechartofaccounts=Définir un plan comptable
Selectchartofaccounts=Sélectionnez un plan comptable
Validate=Valider
Addanaccount=Ajouter un compte comptable
AccountAccounting=Compte comptable
Ventilation=Ventilation
ToDispatch=A effectuer
Dispatched=Effectuée
CustomersVentilation=Ventilation clients
SuppliersVentilation=Ventilation fournisseurs
TradeMargin=Marge commerciale
Reports=Rapports
ByCustomerInvoice=Par factures clients
ByMonth=Par mois
NewAccount=Nouveau compte comptable
Update=Mettre à jour
List=Liste
Create=Créer
UpdateAccount=Modification d'un compte
UpdateMvts=Modification d'un mouvement
WriteBookKeeping=Comptabiliser les écritures dans le grand livre
Bookkeeping=Grand livre
AccountBalanceByMonth=Balance mensuelle
VentilationComptable=Ventilation comptable
VentilationComptableSupplier=Ventilation comptable fournisseur
Intitule=Intitulé
Line=Ligne
CAHTF=Total achat fournisseur HT
InvoiceLines=Lignes de facture à ventiler
InvoiceLinesDone=Lignes de facture ventilées
IntoAccount=Dans le compte comptable
Ventilate=Ventiler
VentilationAuto=Ventilation automatique
Processing=Traitement en cours
EndProcessing=Fin de traitement
AnyLineVentilate=Aucune ligne à ventiler
SelectedLines=Lignes sélectionnées
Lineofinvoice=Ligne de facture
VentilatedinAccount=Ventilée avec succès dans le compte comptable
NotVentilatedinAccount=Non ventilée dans le compte comptable
ACCOUNTINGEX_SEPARATORCSV=Séparateur CSV
ACCOUNTINGEX_LIMIT_LIST_VENTILATION=Nombre d'éléments à ventiler affichés par page (maximum conseillé : 50)
ACCOUNTINGEX_LIST_SORT_VENTILATION_TODO=Commencer le tri des pages de ventilation "A ventiler" par les éléments les plus récents
ACCOUNTINGEX_LIST_SORT_VENTILATION_DONE=Commencer le tri des pages de ventilation "Ventilées" par les éléments les plus récents
AccountLength=Longueur des comptes comptables affichés dans Dolibarr
AccountLengthDesc=Fonction permettant de simuler une longueur de compte comptable en remplaçant les espaces par le chiffre zéro. Cette fonction touche uniquement à l'affichage, elle ne modifie pas les comptes comptables enregistrés dans Dolibarr. Pour l'export, cette fonction est nécessaire pour être compatible avec certains logiciels.
ACCOUNTINGEX_LENGTH_GACCOUNT=Longueur des comptes généraux
ACCOUNTINGEX_LENGTH_AACCOUNT=Longueur des comptes tiers
ACCOUNTINGEX_SELL_JOURNAL=Journal des Ventes
ACCOUNTINGEX_PURCHASE_JOURNAL=Journal des Achats
ACCOUNTINGEX_BANK_JOURNAL=Journal de Banque
ACCOUNTINGEX_CASH_JOURNAL=Journal de Caisse
ACCOUNTINGEX_MISCELLANEOUS_JOURNAL=Journal des Opérations Diverses
ACCOUNTINGEX_SOCIAL_JOURNAL=Journal Social
ACCOUNTINGEX_ACCOUNT_TRANSFER_CASH=Compte de transfert espèce
ACCOUNTINGEX_ACCOUNT_SUSPENSE=Compte d'attente
COMPTA_PRODUCT_BUY_ACCOUNT=Compte comptable par défaut pour les produits achetés (si non défini dans la fiche produit)
COMPTA_PRODUCT_SOLD_ACCOUNT=Compte comptable par défaut pour les produits vendus (si non défini dans la fiche produit)
COMPTA_SERVICE_BUY_ACCOUNT=Compte comptable par défaut pour les services achetés (si non défini dans la fiche service)
COMPTA_SERVICE_SOLD_ACCOUNT=Compte comptable par défaut pour les services vendus (si non défini dans la fiche service)
Doctype=Type de document
Docdate=Date
Docref=Référence
Numerocompte=Compte
Code_tiers=Tiers
Labelcompte=Libellé compte
Debit=Débit
Credit=Crédit
Amount=Montant
Sens=Sens
Codejournal=Journal
DelBookKeeping=Supprimer les écritures du grand livre
SellsJournal=Journal des ventes
PurchasesJournal=Journal des achats
DescSellsJournal=Journal des ventes
DescPurchasesJournal=Journal des achats
BankJournal=Journal de banque
DescBankJournal=Journal de banque comprenant tous les types de règlements autres que espèce
CashJournal=Journal de caisse
DescCashJournal=Journal de caisse comprenant le type de règlement "espèce"
CashPayment=Règlement espèce
SupplierInvoicePayment=Règlement de facture fournisseur
CustomerInvoicePayment=Règlement de facture client
ThirdPartyAccount=Compte tiers
NumMvts=Numero de mouvement
ListeMvts=Liste du mouvement
ErrorDebitCredit=Debit et Credit ne peuvent avoir une valeur en même temps
ReportThirdParty=Liste compte tiers
DescThirdPartyReport=Consultez ici la liste des tiers clients et fournisseurs et leurs codes comptables
ListAccounts=Liste des comptes comptables
Pcgversion=Version du plan
Pcgtype=Classe de compte
Pcgsubtype=Sous classe de compte
Accountparent=Racine du compte
Active=État
NewFiscalYear=Nouvel exercice fiscal
DescVentilCustomer=Consultez ici la ventilation comptable annuelle de vos factures clients
TotalVente=Total chiffre affaires HT
TotalMarge=Total marge commerciale
DescVentilDoneCustomer=Consultez ici la liste des lignes de factures clients et leur compte comptable
DescVentilTodoCustomer=Ventilez vos lignes de facture client avec un compte comptable
ChangeAccount=Changer le compte comptable pour les lignes sélectionnées par le compte :
Vide=-
DescVentilSupplier=Consultez ici la ventilation comptable annuelle de vos factures fournisseurs
DescVentilTodoSupplier=Ventilez vos lignes de facture fournisseur avec un compte comptable
DescVentilDoneSupplier=Consultez ici la liste des lignes de factures fournisseur et leur compte comptable
ValidateHistory=Valider Automatiquement
ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas supprimer ce compte comptable car il est utilisé
FicheVentilation=Fiche ventilation

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B