Skip to content
Snippets Groups Projects
Commit 671018c5 authored by aspangaro's avatar aspangaro
Browse files

New Accountancy Uniformize code & rename a constant

parent 873f33b8
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
......@@ -43,8 +43,12 @@ if (!$user->admin)
$action = GETPOST('action', 'alpha');
// Other parameters ACCOUNTING_EXPORT_*
$list = array (
// Parameters ACCOUNTING_EXPORT_*
$main_option = array (
'ACCOUNTING_EXPORT_PREFIX_SPEC'
);
$model_option = array (
'ACCOUNTING_EXPORT_SEPARATORCSV',
'ACCOUNTING_EXPORT_DATE',
'ACCOUNTING_EXPORT_PIECE',
......@@ -60,10 +64,18 @@ $list = array (
if ($action == 'update') {
$error = 0;
$format = GETPOST('format', 'alpha');
$modelcsv = GETPOST('modelcsv', 'int');
if (! empty($format)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', $format, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
} else {
$error ++;
}
if (! empty($modelcsv)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
......@@ -71,7 +83,15 @@ if ($action == 'update') {
$error ++;
}
foreach ( $list as $constname ) {
foreach ($main_option as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
foreach ($model_option as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
......@@ -106,9 +126,67 @@ print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
print '<table class="noborder" width="100%">';
$var = true;
/*
* Main Options
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('MainOptions') . '</td>';
print "</tr>\n";
$var = ! $var;
print '<tr ' . $bc[$var] . '>';
print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
if (! $conf->use_javascript_ajax)
{
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
}
else
{
print '<td>';
$listformat=array(
'csv'=>$langs->trans("csv"),
'txt'=>$langs->trans("txt")
);
print $form->selectarray("format",$listformat,$conf->global->ACCOUNTING_EXPORT_FORMAT,0);
print '</td>';
}
print "</td></tr>";
$num = count($main_option);
if ($num)
{
foreach ($main_option as $key) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
// Value
print '<td>';
print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
print '</td></tr>';
}
}
print "</table>\n";
print "<br>\n";
/*
* Export model
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
print '</tr>';
......@@ -143,8 +221,8 @@ print "<br>\n";
* Parameters
*/
$num = count($list);
if ($num)
$num2 = count($model_option);
if ($num2)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
......@@ -152,7 +230,7 @@ if ($num)
print "</tr>\n";
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
foreach ( $list as $key ) {
foreach ($model_option as $key) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
......
......@@ -16,7 +16,7 @@
* 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.
* GNU General Public License fr 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/>.
......@@ -25,7 +25,7 @@
/**
* \file htdocs/accountancy/journal/bankjournal.php
* \ingroup Accounting Expert
* \brief Page with sells journal
* \brief Page with bank journal
*/
require '../../main.inc.php';
......@@ -66,6 +66,8 @@ $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$action = GETPOST('action');
$now = dol_now();
// Security check
if ($user->societe_id > 0)
accessforbidden();
......@@ -421,10 +423,9 @@ if ($action == 'writeBookKeeping')
if ($action == 'export_csv')
{
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$bank_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
$journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_banque.csv');
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db);
......
......@@ -3,7 +3,7 @@
* 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 <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
*
......@@ -52,6 +52,8 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$now = dol_now();
// Security check
if ($user->societe_id > 0)
accessforbidden();
......@@ -156,7 +158,6 @@ if ($result) {
// Bookkeeping Write
if ($action == 'writebookkeeping') {
$now = dol_now();
foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) {
......@@ -246,15 +247,10 @@ $companystatic = new Fournisseur($db);
if ($action == 'export_csv')
{
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$purchase_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
header('Content-Type: text/csv');
if ($conf->global->EXPORT_PREFIX_SPEC)
$filename=$conf->global->EXPORT_PREFIX_SPEC."_"."journal_achats.csv";
else
$filename="journal_achats.csv";
header('Content-Disposition: attachment;filename='.$filename);
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) // Model Cegid Expert Export
{
$sep = ";";
......
......@@ -54,6 +54,8 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear');
$now = dol_now();
// Security check
if ($user->societe_id > 0)
accessforbidden();
......@@ -191,7 +193,6 @@ if ($result) {
// Bookkeeping Write
if ($action == 'writebookkeeping')
{
$now = dol_now();
foreach ($tabfac as $key => $val)
{
......@@ -275,14 +276,9 @@ if ($action == 'writebookkeeping')
if ($action == 'export_csv')
{
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
header('Content-Type: text/csv');
if ($conf->global->EXPORT_PREFIX_SPEC)
$filename=$conf->global->EXPORT_PREFIX_SPEC."_"."journal_ventes.csv";
else
$filename="journal_ventes.csv";
header('Content-Disposition: attachment;filename='.$filename);
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db);
......
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@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/>.
*/
$prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC;
$format = $conf->global->ACCOUNTING_EXPORT_FORMAT;
$date_export = dol_print_date($now, '%Y%m%d%H%M%S');
header('Content-Type: text/csv');
if ($prefix)
$filename = $prefix . "_" . "journal_" . $journal . $date_export . "." . $format;
else
$filename = "journal_" . $journal . $date_export . "." . $format;
header('Content-Disposition: attachment;filename='.$filename);
\ No newline at end of file
......@@ -23,3 +23,5 @@ INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXP
ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32);
ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32);
UPDATE llx_const SET name = __ENCRYPT('ACCOUNTING_EXPORT_PREFIX_SPEC')__ WHERE __DECRYPT('name')__ = 'EXPORT_PREFIX_SPEC';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment