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

develop

Conflicts:
	htdocs/core/class/html.form.class.php
This commit is contained in:
Laurent Destailleur 2017-05-29 10:43:26 +02:00
commit 452579150d
49 changed files with 1201 additions and 1180 deletions

View File

@ -4,6 +4,9 @@ English Dolibarr ChangeLog
***** ChangeLog for 6.0.0 compared to 5.0.* *****
For developers:
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
WARNING:
Following changes may create regression for some external modules, but were necessary to make Dolibarr better:

View File

@ -27,7 +27,6 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("compta");

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("errors");
$langs->load("admin");
@ -1258,8 +1258,8 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
$formaccountancy = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value)
{
if ($fieldlist[$field] == 'country')
@ -1400,7 +1400,7 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
if (! empty($conf->accounting->enabled))
{
$accountancy_account = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0);
print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
}
else
{

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@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
@ -19,7 +19,7 @@
/**
* \file htdocs/accountancy/admin/card.php
* \ingroup Advanced accountancy
* \ingroup Advanced accountancy
* \brief Card of accounting account
*/
@ -27,7 +27,6 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$error = 0;
@ -59,7 +58,7 @@ if (GETPOST('cancel'))
header("Location: ".$urltogo);
exit;
}
if ($action == 'add' && $user->rights->accounting->chartofaccount)
{
if (! $cancel) {
@ -86,7 +85,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
} else {
$account_parent = GETPOST('account_parent','int');
}
$object->fk_pcg_version = $obj->pcg_version;
$object->pcg_type = GETPOST('pcg_type');
$object->pcg_subtype = GETPOST('pcg_subtype');
@ -95,7 +94,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->account_category = GETPOST('account_category');
$object->label = GETPOST('label', 'alpha');
$object->active = 1;
$res = $object->create($user);
if ($res == - 3) {
$error = 1;
@ -124,9 +123,9 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
} else if ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (! $cancel) {
$result = $object->fetch($id);
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
$result2 = $db->query($sql);
$obj = $db->fetch_object($result2);
@ -156,9 +155,9 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$object->account_parent = $account_parent;
$object->account_category = GETPOST('account_category');
$object->label = GETPOST('label', 'alpha');
$result = $object->update($user);
if ($result > 0) {
$urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: " . $urltogo);
@ -196,7 +195,6 @@ $helpurl = '';
llxheader('', $title, $helpurl);
$form = new Form($db);
$htmlacc = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$accountsystem = new AccountancySystem($db);
@ -205,13 +203,13 @@ $accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
// Create mode
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccountingAccount'));
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">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Chart of account
@ -219,8 +217,7 @@ if ($action == 'create') {
print '<td>';
print $accountsystem->ref;
print '</td></tr>';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"></td></tr>';
@ -232,7 +229,7 @@ if ($action == 'create') {
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td>';
print $htmlacc->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print '</td></tr>';
// Category
@ -245,72 +242,69 @@ if ($action == 'create') {
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type','alpha'):$object->pcg_type).'">';
//print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1);
print '</td></tr>';
// Chart of acounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$object->pcg_subtype).'">';
//print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else if ($id) {
$result = $object->fetch($id);
if ($result > 0) {
dol_htmloutput_mesg($mesg);
$head = accounting_prepare_head($object);
// Edit mode
if ($action == 'update')
{
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 '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<table class="border" width="100%">';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
// Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td>';
print $htmlacc->select_account($object->account_parent, 'account_parent', 1);
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>';
//print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1);
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type','alpha'):$object->pcg_type).'">';
print '</td></tr>';
@ -318,29 +312,27 @@ if ($action == 'create') {
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$object->pcg_subtype).'">';
//print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else {
// View mode
$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 class="titlefield">' . $langs->trans("AccountNumber") . '</td>';
print '<td>' . $object->account_number . '</td>';
@ -378,31 +370,30 @@ if ($action == 'create') {
} else {
print img_picto($langs->trans("Activated"), 'switch_on');
}*/
print '</td></tr>';
print '</table>';
dol_fiche_end();
/*
* Actions buttons
*/
print '<div class="tabsAction">';
if (! empty($user->rights->accounting->chartofaccount)) {
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 (! empty($user->rights->accounting->chartofaccount)) {
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 {

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$langs->load("errors");
$langs->load("admin");
@ -982,7 +982,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value)
{
@ -1125,7 +1125,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
{
$fieldname = $fieldlist[$field];
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
}
else
{

View File

@ -32,7 +32,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("compta");
$langs->load("bills");
@ -117,7 +117,7 @@ if ($action == 'update') {
llxHeader();
$form = new Form($db);
$formaccountancy = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$linkback = '';
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
@ -142,7 +142,7 @@ foreach ( $list_account as $key ) {
print '<td>' . $label . '</td>';
// Value
print '<td>'; // Do not force align=right, or it align also the content of the select box
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
}

View File

@ -1,8 +1,7 @@
<?php
/*
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@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
@ -28,7 +27,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// langs
$langs->load("compta");
@ -65,22 +64,22 @@ if ($_POST["action"] == 'import') {
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('label' . $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;
@ -126,10 +125,10 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="action" value="import">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>' . $langs->trans("AccountAccouting") . '</td>';
print '<td>' . $langs->trans("label") . '</td>';
@ -138,44 +137,43 @@ if ($result) {
print '<td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td align="center">' . $langs->trans("Import") . '</td>';
print '</tr>';
$form = new Form($db);
$htmlacc = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$var = true;
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td align="left">';
print $objp->accounting;
print '</td>';
print '<td align="left">';
print '<input name="label" size="30" value="">';
print '</td>';
// Colonne choix du compte
print '<td>';
print $htmlacc->select_account($accounting->account_parent, 'AccountParent');
print $formaccounting->select_account($accounting->account_parent, 'AccountParent');
print '</td>';
print '<td>';
print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcgType');
print '<input type="text" name="pcgType" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$accounting->pcg_type).'">';
print '</td>';
print '<td>';
print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcgSubType');
print '<input type="text" name="pcgSubType" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype','alpha'):$accounting->pcg_subtype).'">';
print '</td>';
// Colonne choix ligne a ventiler
$checked = ('label' == 'O') ? ' checked' : '';
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" ' . $checked . ' value="' . $objp->accounting . '"/>';
print '</td>';
print '</tr>';
$i ++;
}

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* 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) 2014 Juanjo Menent <jmenent@2byte.es>
* 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
@ -31,8 +31,6 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
$langs->load("compta");
$langs->load("bills");
@ -160,7 +158,6 @@ if ($action == 'setdisabledirectinput') {
llxHeader();
$form = new Form($db);
$formaccountancy = new FormVentilation($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');

View File

@ -1,207 +0,0 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* 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) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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/accountancy/admin/journal.php
* \ingroup Advanced accountancy
* \brief Setup page to configure accounting expert module
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
$langs->load("compta");
$langs->load("bills");
$langs->load("admin");
$langs->load("accountancy");
$langs->load("salaries");
// Security check
if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
{
accessforbidden();
}
$action = GETPOST('action', 'alpha');
// Other parameters ACCOUNTING_*
$list = array (
'ACCOUNTING_SELL_JOURNAL',
'ACCOUNTING_PURCHASE_JOURNAL',
'ACCOUNTING_SOCIAL_JOURNAL',
'ACCOUNTING_MISCELLANEOUS_JOURNAL',
'ACCOUNTING_EXPENSEREPORT_JOURNAL'
);
/*
* Actions
*/
if ($action == 'update') {
$error = 0;
// Save vars
foreach ($list as $constname)
{
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
}
}
// Save bank account journals
$arrayofbankaccount = GETPOST('bank_account', 'array');
foreach($arrayofbankaccount as $key => $code)
{
$bankaccount = new Account($db);
$res = $bankaccount->fetch($key);
if ($res > 0)
{
$bankaccount->accountancy_journal = $code;
$bankaccount->update($user);
}
else
{
$error++;
break;
}
}
if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
$head = admin_accounting_prepare_head(null);
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">';
dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans('Journaux') . '</td>';
print "</tr>\n";
foreach ( $list as $key ) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td width="50%"><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>\n";
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans('JournalFinancial') . ' ('.$langs->trans('Opened').')</td>';
print "</tr>\n";
// Bank account
$sql = "SELECT rowid, ref, label, number, account_number, accountancy_journal";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank_account";
$sql .= " WHERE entity = " . $conf->entity;
$sql .= " AND clos = 0";
$sql .= " ORDER BY label";
$resql = $db->query($sql);
if ($resql) {
$numr = $db->num_rows($resql);
$i = 0;
if ($numr > 0)
$bankaccountstatic = new Account($db);
while ( $i < $numr ) {
$objp = $db->fetch_object($resql);
$bankaccountstatic->rowid = $objp->rowid;
$bankaccountstatic->id = $objp->rowid;
$bankaccountstatic->ref = $objp->ref;
$bankaccountstatic->label = $objp->label;
$bankaccountstatic->number = $objp->number;
$bankaccountstatic->account_number = $objp->account_number;
$bankaccountstatic->accountancy_journal = $objp->accountancy_journal;
print '<tr class="oddeven value">';
// Param
print '<td width="50%"><label for="' . $objp->rowid . '">' . $langs->trans("Journal");
print ' - '.$bankaccountstatic->getNomUrl(1);
print '</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="' . $objp->rowid . '" name="bank_account['.$objp->rowid.']" value="' . $objp->accountancy_journal . '">';
print '</td></tr>';
$i ++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print "</table>\n";
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '</form>';
llxFooter();
$db->close();

View File

@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@ -184,7 +184,7 @@ if ($action == 'update') {
* View
*/
$form = new FormVentilation($db);
$form = new FormAccounting($db);
// Defaut AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid

View File

@ -28,8 +28,8 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs
@ -61,7 +61,7 @@ $offset = $limit * $page;
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
@ -186,10 +186,10 @@ else {
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
print $langs->trans('From');
print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' ';
print $langs->trans('to');
print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print '</td>';
print '<td align="right" class="liste_titre">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);

View File

@ -27,9 +27,8 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("accountancy");
@ -215,7 +214,6 @@ else if ($action == "confirm_create") {
llxHeader();
$html = new Form($db);
$formventilation = new FormVentilation($db);
$formaccountancy = new FormAccounting($db);
/*
@ -389,10 +387,10 @@ if ($action == 'create') {
if ($action == 'update' && $line->id == $id) {
print '<td>';
print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print '</td>';
print '<td>';
print $formventilation->select_auxaccount($line->code_tiers, 'code_tiers', 1);
print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1);
print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
@ -433,10 +431,10 @@ if ($action == 'create') {
if ($action == "" || $action == 'add') {
print '<tr class="oddeven">';
print '<td>';
print $formventilation->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print '</td>';
print '<td>';
print $formventilation->select_auxaccount($code_tiers, 'code_tiers', 1);
print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1);
print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
print '<td align="right"><input type="text" class="right maxwidth50" name="debit" value="' . price($debit) . '"/></td>';

View File

@ -28,10 +28,10 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("accountancy");
@ -94,7 +94,7 @@ if ($sortfield == "") $sortfield = "t.rowid";
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
@ -292,7 +292,6 @@ $title_page = $langs->trans("Bookkeeping");
llxHeader('', $title_page);
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
@ -322,8 +321,8 @@ if ($action == 'delbookkeepingyear') {
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formventilation->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array');
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1);
$form_question['delyear'] = array (
'name' => 'delyear',
@ -386,17 +385,17 @@ print '</td>';
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
print '<td class="liste_titre">';
print $langs->trans('From');
print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
print '<br>';
print $langs->trans('to');
print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
print '</td>';
print '<td class="liste_titre">';
print $langs->trans('From');
print $formventilation->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
print '<br>';
print $langs->trans('to');
print $formventilation->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';

View File

@ -29,8 +29,8 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs
@ -75,7 +75,7 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
@ -188,7 +188,7 @@ if ($action == 'delbookkeepingyear') {
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$form_question['delyear'] = array (
'name' => 'delyear',

View File

@ -29,7 +29,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("accountancy");
@ -67,7 +67,7 @@ $search_code_journal = GETPOST('search_code_journal', 'alpha');
$object = new BookKeeping($db);
$form = new Form($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
// Filter
if (empty($search_date_start)) {
@ -182,15 +182,15 @@ print $form->select_date($search_date_end, 'date_end');
print '</div>';
print '<div class="liste_titre">';
print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': ';
print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
print $formaccounting->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': ';
print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
print $formaccounting->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
print '</div>';
print '<div class="liste_titre">';
print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1);
print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1);
print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1);
print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1);
print '</div>';
print "<table class=\"noborder\" width=\"100%\">";

View File

@ -1053,23 +1053,23 @@ class BookKeeping extends CommonObject
*/
function deleteByYearAndJournal($delyear='', $journal='') {
global $conf;
if (empty($delyear) && empty($journal))
{
return -1;
}
$this->db->begin();
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql.= " WHERE 1 = 1";
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$resql = $this->db->query($sql);
if (! $resql) {
$this->errors[] = "Error " . $this->db->lasterror();
foreach ( $this->errors as $errmsg ) {
@ -1083,7 +1083,7 @@ class BookKeeping extends CommonObject
$this->db->commit();
return 1;
}
/**
* Delete bookkepping by piece number
*
@ -1092,17 +1092,17 @@ class BookKeeping extends CommonObject
*/
function deleteMvtNum($piecenum) {
global $conf;
$this->db->begin();
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$resql = $this->db->query($sql);
if (! $resql) {
$this->errors[] = "Error " . $this->db->lasterror();
foreach ( $this->errors as $errmsg ) {
@ -1116,7 +1116,7 @@ class BookKeeping extends CommonObject
$this->db->commit();
return 1;
}
/**
* Load an object from its id and create a new one in database
*
@ -1130,27 +1130,27 @@ class BookKeeping extends CommonObject
global $user;
$error = 0;
$object = new Accountingbookkeeping($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
// Reset object
$object->id = 0;
// Clear fields
// ...
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
$error ++;
$this->errors = $object->errors;
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
// End
if (! $error) {
$this->db->commit();
@ -1158,11 +1158,11 @@ class BookKeeping extends CommonObject
return $object->id;
} else {
$this->db->rollback();
return - 1;
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
@ -1171,9 +1171,9 @@ class BookKeeping extends CommonObject
*/
public function initAsSpecimen() {
global $user;
$now=dol_now();
$this->id = 0;
$this->doc_date = $now;
$this->doc_type = '';
@ -1192,7 +1192,7 @@ class BookKeeping extends CommonObject
$this->code_journal = '';
$this->piece_num = '';
}
/**
* Load an accounting document into memory from database
*
@ -1201,17 +1201,17 @@ class BookKeeping extends CommonObject
*/
public function fetchPerMvt($piecenum) {
global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
dol_syslog(get_class($this) . "::" . __METHOD__, 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);
@ -1222,10 +1222,10 @@ class BookKeeping extends CommonObject
dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR);
return - 1;
}
return 1;
}
/**
* Return next number movement
*
@ -1233,8 +1233,8 @@ class BookKeeping extends CommonObject
*/
public function getNextNumMvt()
{
global $conf;
global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
@ -1243,16 +1243,16 @@ class BookKeeping extends CommonObject
if ($result) {
$obj = $this->db->fetch_object($result);
if ($obj) $result = $obj->max;
if (empty($result)) $result = 1;
return $result;
if ($obj) $result = $obj->max;
if (empty($result)) $result = 1;
return $result;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR);
return - 1;
}
}
/**
* Load all informations of accountancy document
*
@ -1260,26 +1260,26 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, >0 if OK
*/
function fetch_all_per_mvt($piecenum) {
global $conf;
global $conf;
$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 . $this->table_element;
$sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
dol_syslog(get_class($this) . "::" . __METHOD__, 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;
@ -1294,7 +1294,7 @@ class BookKeeping extends CommonObject
$line->sens = $obj->sens;
$line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num;
$this->linesmvt[] = $line;
}
} else {
@ -1302,10 +1302,10 @@ class BookKeeping extends CommonObject
dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR);
return - 1;
}
return 1;
}
/**
* Export bookkeping
*
@ -1313,28 +1313,28 @@ class BookKeeping extends CommonObject
* @return int Result
*/
function export_bookkeping($model = 'ebp') {
global $conf;
global $conf;
$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 . $this->table_element;
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
dol_syslog(get_class($this) . "::export_bookkeping", 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;
@ -1349,11 +1349,11 @@ class BookKeeping extends CommonObject
$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();

View File

@ -1,383 +0,0 @@
<?php
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2016 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/accountancy/class/html.formventilation.class.php
* \ingroup Advanced accountancy
* \brief File of class with all html predefined components
*/
/**
* Class to manage generation of HTML components for bank module
*/
class FormVentilation extends Form
{
private $options_cache = array();
/**
* Return select filter with date of transaction
*
* @param string $htmlname Name of select field
* @param string $selectedkey Value
* @return string HTML edit field
*/
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') {
$options = array();
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= ' ORDER BY import_key DESC';
dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
return - 1;
}
while ($obj = $this->db->fetch_object($resql)) {
$options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext');
}
return Form::selectarray($htmlname, $options, $selectedkey);
}
/**
* Return list of accounts with label by chart of accounts
*
* @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
* @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @return string String with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
{
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$out = '';
$options = array();
if ($usecache && ! empty($this->options_cache[$usecache]))
{
$options = $this->options_cache[$usecache];
$selected=$selectid;
}
else
{
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account 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", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
return -1;
}
$out .= ajax_combobox($htmlname, $event);
$selected = 0;
while ($obj = $this->db->fetch_object($resql))
{
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->account_number;
}
if ($select_out == 1) {
$select_value_out = $obj->account_number;
}
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning
if ($selectid != '' && $selectid == $select_value_in) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected = $select_value_out;
}
$options[$select_value_out] = $label;
}
$this->db->free($resql);
if ($usecache)
{
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
return $out;
}
/**
* Return list of accounts with label by class of accounts
*
* @param string $selectid Preselected pcg_type
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
* @return string String with HTML select
*/
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) {
global $conf;
$sql = "SELECT DISTINCT pcg_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account 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 .= " ORDER BY pcg_type";
dol_syslog(get_class($this) . "::select_pcgtype", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgtype ".$this->error, LOG_ERR);
return -1;
}
$options = array();
$out = ajax_combobox($htmlname, $event);
while ($obj = $this->db->fetch_object($resql))
{
if ($obj->pcg_type != '-1')
{
$options[$obj->pcg_type] = $obj->pcg_type;
}
}
$out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
$this->db->free($resql);
return $out;
}
/**
* Return list of accounts with label by sub_class of accounts
*
* @param string $selectid Preselected pcg_type
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
* @return string String with HTML select
*/
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array())
{
global $conf;
$sql = "SELECT DISTINCT pcg_subtype ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account 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 .= " ORDER BY pcg_subtype";
dol_syslog(get_class($this) . "::select_pcgsubtype", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
return -1;
}
$options = array();
$out = ajax_combobox($htmlname, $event);
while ($obj = $this->db->fetch_object($resql))
{
if ($obj->pcg_type != '-1')
{
$options[$obj->pcg_subtype] = $obj->pcg_subtype;
}
}
$out .= Form::selectarray($htmlname, $options, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth200');
$this->db->free($resql);
return $out;
}
/**
* Return list of auxilary thirdparty accounts
*
* @param string $selectid Preselected pcg_type
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
* @return string String with HTML select
*/
function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
$aux_account = array();
// Auxiliary customer account
$sql = "SELECT DISTINCT code_compta, nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
$sql .= " ORDER BY code_compta";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta)) {
$aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
}
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Auxiliary supplier account
$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
$sql .= " ORDER BY code_compta_fournisseur";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta_fournisseur)) {
$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
}
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Build select
$out = ajax_combobox($htmlname, $event);
$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
return $out;
}
/**
* Return HTML combo list of years existing into book keepping
*
* @param string $selected Preselected value
* @param string $htmlname Name of HTML select object
* @param int $useempty Affiche valeur vide dans liste
* @param string $output_format (html/opton (for option html only)/array (to return options arrays
* @return string/array
*/
function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
{
global $conf;
$out_array = array();
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " ORDER BY date_format(doc_date,'%Y')";
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$out_array[$obj->dtyear] = $obj->dtyear;
}
$this->db->free($resql);
if ($output_format == 'html') {
return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
} else {
return $out_array;
}
}
/**
* Return HTML combo list of years existing into book keepping
*
* @param string $selected Preselected value
* @param string $htmlname Name of HTML select object
* @param int $useempty Affiche valeur vide dans liste
* @param string $output_format Html/option (for option html only)/array (to return options arrays
* @return string/array
*/
function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
{
global $conf,$langs;
$out_array = array();
$sql = "SELECT DISTINCT code_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " ORDER BY code_journal";
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$out_array[$obj->code_journal] = $obj->code_journal?$obj->code_journal:$langs->trans("NotDefined"); // TODO Not defined is accepted ? We should avoid this, shouldn't we ?
}
$this->db->free($resql);
if ($output_format == 'html') {
return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
} else {
return $out_array;
}
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2017 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
@ -26,7 +26,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("bills");
@ -39,9 +39,7 @@ $id = GETPOST('id');
// Security check
if ($user->societe_id > 0)
accessforbidden();
/*
* Actions
*/
@ -84,7 +82,7 @@ if ($cancel == $langs->trans("Cancel")) {
*/
$form = new Form($db);
$facture_static = new Facture($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
@ -96,50 +94,50 @@ if (! empty($id)) {
$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;
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
if ($num_lines) {
$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 load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup');
dol_fiche_head();
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 $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else {
print "Error";

View File

@ -28,7 +28,7 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -77,7 +77,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
/*
@ -254,14 +254,14 @@ if ($result) {
print $langs->trans("DescVentilDoneCustomer") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account($account_parent, 'account_parent', 1);
print $formaccounting->select_account($account_parent, 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
@ -278,7 +278,7 @@ if ($result) {
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print "</td></tr>\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
@ -303,16 +303,16 @@ if ($result) {
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->rowid;
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
$product_static->type = $objp->product_type;
$product_static->label = $objp->product_label;
print '<tr class="oddeven">';
print '<td>' . $objp->rowid . '</td>';
// Ref Invoice
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
@ -324,13 +324,13 @@ if ($result) {
print $product_static->getNomUrl(1);
if ($objp->product_label) print '<br>'.$objp->product_label;
print '</td>';
print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
print '</td>';
print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="center">' . price($objp->tva_tx) . '</td>';
print '<td>';
@ -338,20 +338,20 @@ if ($result) {
print img_edit();
print '</a>';
print '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print "</tr>";
$i ++;
}
print "</table>";
print "</div>";
if ($nbtotalofrecords > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
}

View File

@ -30,7 +30,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -85,7 +85,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
@ -101,7 +101,7 @@ if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction !=
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_lineid = '';
$search_lineid = '';
$search_ref = '';
$search_invoice = '';
$search_label = '';
@ -241,7 +241,7 @@ if ($result) {
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@ -254,8 +254,7 @@ if ($result) {
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -264,16 +263,16 @@ if ($result) {
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
if ($msg) print $msg.'<br>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// We add search filter
@ -309,7 +308,7 @@ if ($result) {
if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
print "</tr>\n";
$facture_static = new Facture($db);
$product_static = new Product($db);
$form = new Form($db);
@ -330,7 +329,7 @@ if ($result) {
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype;
$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
@ -350,30 +349,30 @@ if ($result) {
if (! empty($objp->code_sell)) {
$objp->code_sell_p = $objp->code_sell; // Code on product
} else {
$code_sell_p_notset = 'color:orange';
$code_sell_p_notset = 'color:orange';
}
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
// $objp->code_sell_p is now code of product/service
// $objp->code_sell_l is now default code of product/service
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
// Ref Invoice
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
// Ref Product
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
if ($objp->product_label) print '<br>'.$objp->product_label;
print '</td>';
print '<td class="tdoverflowonsmartphone">';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
@ -383,14 +382,14 @@ if ($result) {
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
// Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" align="right">';
print price($objp->tva_tx_line);
print '</td>';
// Current account
print '<td align="center" style="' . $code_sell_p_notset . '">';
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
@ -403,7 +402,7 @@ if ($result) {
// Suggested accounting account
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';
print '<td align="center">';
@ -414,7 +413,7 @@ if ($result) {
}
print '</table>';
print "</div>";
print '</form>';
} else {
print $db->error();

View File

@ -30,7 +30,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("bills");
@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
// Create
$form = new Form($db);
$expensereport_static = new ExpenseReport($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
@ -135,7 +135,7 @@ if (! empty($id)) {
print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
print '<tr><td>' . $langs->trans("Account") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';

View File

@ -27,7 +27,7 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -74,7 +74,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
/*
@ -226,7 +226,7 @@ if ($result) {
print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = '';

View File

@ -29,7 +29,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -83,7 +83,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$accounting = new AccountingAccount($db);
@ -343,7 +343,7 @@ if ($result) {
// Suggested accounting account
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';
print '<td align="center">';

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2017 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>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* 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
@ -30,7 +30,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Langs
$langs->load("bills");
@ -52,11 +52,11 @@ if ($user->societe_id > 0)
if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) {
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$resql = $db->query($sql);
if (! $resql) {
setEventMessages($db->lasterror(), null, 'errors');
@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
// Create
$form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db);
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
@ -107,41 +107,41 @@ if (! empty($id)) {
if ($num_lines) {
$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 load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup');
dol_fiche_head();
print '<table class="border" width="100%">';
// 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%">' . $langs->trans("Line") . '</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 $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>';
} else {
print "Error";

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* 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
@ -27,7 +27,7 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@ -76,7 +76,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
/*
@ -237,7 +237,7 @@ if ($result) {
print $langs->trans("DescVentilDoneSupplier") . '<br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
$moreforfilter = '';

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -30,7 +30,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@ -85,7 +85,7 @@ if ($user->societe_id > 0)
if (! $user->rights->accounting->bind->write)
accessforbidden();
$formventilation = new FormVentilation($db);
$formaccounting = new FormAccounting($db);
$accounting = new AccountingAccount($db);
// TODO: we should need to check if result is a really exist accountaccount rowid.....
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
@ -238,11 +238,11 @@ if ($result) {
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
@ -251,8 +251,7 @@ if ($result) {
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -261,15 +260,15 @@ if ($result) {
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
if ($msg) print $msg.'<br>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -329,7 +328,7 @@ if ($result) {
$productfourn_static->id = $objp->product_id;
$productfourn_static->type = $objp->type;
$productfourn_static->label = $objp->product_label;
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->type;
@ -347,14 +346,14 @@ if ($result) {
$objp->aarowid_suggest = $aarowid_p;
}
if ($objp->code_buy_l == -1) $objp->code_buy_l='';
if (! empty($objp->code_buy)) {
$objp->code_buy_p = $objp->code_buy; // Code on product
} else {
$code_buy_p_notset = 'color:orange';
}
if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red';
// $objp->code_buy_p is now code of product/service
// $objp->code_buy_l is now default code of product/service
@ -362,23 +361,23 @@ if ($result) {
// Line id
print '<td>' . $objp->rowid . '</td>';
// Ref Invoice
print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label;
print '</td>';
print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
// Ref product
print '<td>';
if ($productfourn_static->id)
print $productfourn_static->getNomUrl(1);
if ($objp->product_label) print '<br>'.$objp->product_label;
print '</td>';
// Description
print '<td>';
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
@ -409,9 +408,9 @@ if ($result) {
// Suggested accounting account
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';
// Colonne choix ligne a ventiler
print '<td align="center">';
print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.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
@ -36,7 +36,13 @@ class AdherentType extends CommonObject
public $table_element = 'adherent_type';
public $element = 'adherent_type';
public $picto = 'group';
/**
* @var string
* @deprecated Use label
* @see label
*/
public $libelle;
/** @var string Label */
public $label;
/**
@ -81,12 +87,13 @@ class AdherentType extends CommonObject
global $conf;
$this->statut=(int) $this->statut;
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label));
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= "libelle";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->libelle)."'";
$sql.= "'".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
@ -117,12 +124,12 @@ class AdherentType extends CommonObject
$error=0;
$this->libelle=trim($this->libelle);
$this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label));
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET ";
$sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->libelle) ."',";
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = '".$this->db->escape($this->vote)."',";
@ -307,7 +314,7 @@ class AdherentType extends CommonObject
{
return '';
}
/**
* getMailOnValid
*

View File

@ -106,7 +106,7 @@ class Members extends DolibarrApi
$sql.= ' AND t.fk_adherent_type='.$typeid;
}
// Add sql filters
if ($sqlfilters)
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
@ -115,7 +115,7 @@ class Members extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
@ -132,9 +132,10 @@ class Members extends DolibarrApi
{
$i=0;
$num = $db->num_rows($result);
while ($i < min($limit, $num))
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($result);
$member = new Adherent($this->db);
if($member->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($member);

View File

@ -0,0 +1,322 @@
<?php
/* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
/**
* API class for members types
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class MembersTypes extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'label'
);
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
}
/**
* Get properties of a member type object
*
* Return an array with member type informations
*
* @param int $id ID of member type
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
{
if(! DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401);
}
$membertype = new AdherentType($this->db);
$result = $membertype->fetch($id);
if( ! $result ) {
throw new RestException(404, 'member type not found');
}
if( ! DolibarrApi::_checkAccessToResource('member',$membertype->id,'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
return $this->_cleanObjectDatas($membertype);
}
/**
* List members types
*
* Get a list of members types
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')"
* @return array Array of member type objects
*
* @throws RestException
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
if(! DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401);
}
$sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')';
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
if ($result)
{
$i=0;
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$membertype = new AdherentType($this->db);
if ($membertype->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($membertype);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve member type list : '.$db->lasterror());
}
if ( ! count($obj_ret)) {
throw new RestException(404, 'No member type found');
}
return $obj_ret;
}
/**
* Create member type object
*
* @param array $request_data Request data
* @return int ID of member type
*/
function post($request_data = null)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
}
// Check mandatory fields
$result = $this->_validate($request_data);
$membertype = new AdherentType($this->db);
foreach($request_data as $field => $value) {
$membertype->$field = $value;
}
if ($membertype->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
}
return $membertype->id;
}
/**
* Update member type
*
* @param int $id ID of member type to update
* @param array $request_data Datas
* @return int
*/
function put($id, $request_data = null)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
}
$membertype = new AdherentType($this->db);
$result = $membertype->fetch($id);
if( ! $result ) {
throw new RestException(404, 'member type not found');
}
if( ! DolibarrApi::_checkAccessToResource('member',$membertype->id,'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
// Process the status separately because it must be updated using
// the validate() and resiliate() methods of the class AdherentType.
$membertype->$field = $value;
}
// If there is no error, update() returns the number of affected rows
// so if the update is a no op, the return value is zero.
if ($membertype->update(DolibarrApiAccess::$user) >= 0)
return $this->get($id);
return false;
}
/**
* Delete member type
*
* @param int $id member type ID
* @return array
*/
function delete($id)
{
if (! DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401);
}
$membertype = new AdherentType($this->db);
$result = $membertype->fetch($id);
if( ! $result ) {
throw new RestException(404, 'member type not found');
}
if ( ! DolibarrApi::_checkAccessToResource('member',$membertype->id,'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (! $membertype->delete($membertype->id)) {
throw new RestException(401,'error when deleting member type');
}
return array(
'success' => array(
'code' => 200,
'message' => 'member type deleted'
)
);
}
/**
* Validate fields before creating an object
*
* @param array|null $data Data to validate
* @return array
*
* @throws RestException
*/
function _validate($data)
{
$membertype = array();
foreach (MembersTypes::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$membertype[$field] = $data[$field];
}
return $membertype;
}
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
unset($object->cotisation);
unset($object->libelle);
unset($object->import_key);
unset($object->array_options);
unset($object->linkedObjectsIds);
unset($object->context);
unset($object->canvas);
unset($object->fk_project);
unset($object->contact);
unset($object->contact_id);
unset($object->thirdparty);
unset($object->user);
unset($object->origin);
unset($object->origin_id);
unset($object->ref_ext);
unset($object->country);
unset($object->country_id);
unset($object->country_code);
unset($object->barcode_type);
unset($object->barcode_type_code);
unset($object->barcode_type_label);
unset($object->barcode_type_coder);
unset($object->mode_reglement_id);
unset($object->cond_reglement_id);
unset($object->cond_reglement);
unset($object->fk_delivery_address);
unset($object->shipping_method_id);
unset($object->modelpdf);
unset($object->fk_account);
unset($object->note_public);
unset($object->note_private);
unset($object->fk_incoterms);
unset($object->libelle_incoterms);
unset($object->location_incoterms);
unset($object->name);
unset($object->lastname);
unset($object->firstname);
unset($object->civility_id);
unset($object->total_ht);
unset($object->total_tva);
unset($object->total_localtax1);
unset($object->total_localtax2);
unset($object->total_ttc);
return $object;
}
}

View File

@ -1,10 +1,10 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* 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
@ -55,7 +55,7 @@ $pagenext = $page + 1;
if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="d.lastname"; }
$label=GETPOST("libelle","alpha");
$label=GETPOST("label","alpha");
$subscription=GETPOST("subscription","int");
$vote=GETPOST("vote","int");
$comment=GETPOST("comment");
@ -93,17 +93,17 @@ if ($action == 'add' && $user->rights->adherent->configurer)
{
$object = new AdherentType($db);
$object->libelle = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
if ($object->libelle)
if ($object->label)
{
$id=$object->create($user);
if ($id > 0)
@ -131,7 +131,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
{
$object = new AdherentType($db);
$object->id = $rowid;
$object->libelle = trim($label);
$object->label = trim($label);
$object->subscription = (int) trim($subscription);
$object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid);
@ -171,7 +171,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
{
//dol_fiche_head('');
$sql = "SELECT d.rowid, d.libelle, d.subscription, d.vote";
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql.= " WHERE d.entity IN (".getEntity().")";
@ -180,11 +180,11 @@ if (! $rowid && $action != 'create' && $action != 'edit')
{
$num = $db->num_rows($result);
$nbtotalofrecords = $num;
$i = 0;
$param = '';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -193,14 +193,14 @@ if (! $rowid && $action != 'create' && $action != 'edit')
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit);
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Ref").'</th>';
print '<th>'.$langs->trans("Label").'</th>';
@ -214,7 +214,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$objp = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td><a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a></td>';
print '<td>'.dol_escape_htmltag($objp->libelle).'</td>';
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
print '<td align="center">'.yn($objp->subscription).'</td>';
print '<td align="center">'.yn($objp->vote).'</td>';
if ($user->rights->adherent->configurer)
@ -226,7 +226,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
}
print "</table>";
print '</div>';
print '</form>';
}
else
@ -256,7 +256,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print '<tbody>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40"></td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40"></td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription",1,1);
@ -316,10 +316,10 @@ if ($rowid > 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
@ -347,7 +347,7 @@ if ($rowid > 0)
print '</table>';
print '</div>';
dol_fiche_end();
@ -460,7 +460,7 @@ if ($rowid > 0)
{
$membertype=new AdherentType($db);
$result=$membertype->fetch($type);
$titre.=" (".$membertype->libelle.")";
$titre.=" (".$membertype->label.")";
}
$param="&rowid=".$rowid;
@ -478,12 +478,12 @@ if ($rowid > 0)
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input class="flat" type="hidden" name="rowid" value="'.$rowid.'" size="12"></td>';
print '<br>';
print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -548,7 +548,7 @@ if ($rowid > 0)
// Type
/*print '<td class="nowrap">';
$membertypestatic->id=$objp->type_id;
$membertypestatic->libelle=$objp->type;
$membertypestatic->label=$objp->type;
print $membertypestatic->getNomUrl(1,12);
print '</td>';
*/
@ -613,7 +613,7 @@ if ($rowid > 0)
print "</table>\n";
print '</div>';
print '</form>';
if ($num > $conf->liste_limit)
{
print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
@ -652,7 +652,7 @@ if ($rowid > 0)
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40" value="'.dol_escape_htmltag($object->libelle).'"></td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription",$object->subscription,1);

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("errors");
$langs->load("admin");
@ -1662,7 +1662,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value)
{
@ -1811,7 +1811,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{
$fieldname = $fieldlist[$field];
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
}
else
{

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2014-2017 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
@ -26,7 +26,7 @@ require '../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("admin");
$langs->load("loan");
@ -77,7 +77,7 @@ if ($action == 'update')
llxHeader();
$form = new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup');
@ -106,7 +106,7 @@ foreach ($list as $key)
print '<td>';
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
}
else
{

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("errors");
$langs->load("admin");
@ -841,7 +841,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value)
{

View File

@ -26,7 +26,7 @@ require '../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("admin");
$langs->load("salaries");
@ -76,7 +76,7 @@ if ($action == 'update')
llxHeader('',$langs->trans('SalariesSetup'));
$form = new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
@ -109,7 +109,7 @@ foreach ($list as $key)
print '<td>';
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
}
else
{

View File

@ -27,7 +27,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load('admin');
@ -113,7 +113,7 @@ if ($action == 'update') {
llxHeader();
$form=new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
@ -216,7 +216,7 @@ foreach ($list as $key)
print '<td>';
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
}
else
{

View File

@ -0,0 +1,100 @@
<?php
/* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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/>.
*/
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
/**
* API class for events type (content of the actioncomm dictionary)
*
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class DictionaryEvents extends DolibarrApi
{
/**
* Constructor
*/
function __construct()
{
global $db;
$this->db = $db;
}
/**
* Get the list of events types.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param string $type To filter on type of event
* @param string $module To filter on module events
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return List of events types
*
* @throws RestException
*/
function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $sqlfilters = '')
{
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql.= " WHERE t.active = 1";
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of events types : '.$this->db->lasterror());
}
return $list;
}
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.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
@ -143,10 +144,9 @@ foreach ($modulesdir as $dir)
*
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
*
* @todo : take care of externals module!
* @todo : use getElementProperties() function ?
*/
$dir_part = DOL_DOCUMENT_ROOT.'/'.$moduledirforclass.'/class/';
$dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
$handle_part=@opendir(dol_osencode($dir_part));
if (is_resource($handle_part))

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
*
* 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
@ -23,14 +23,14 @@
/**
* API class for Agenda Events
*
* @access protected
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
class AgendaEvents extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
);
@ -40,7 +40,7 @@ class AgendaEvents extends DolibarrApi
*/
public $actioncomm;
/**
* Constructor
*/
@ -55,61 +55,61 @@ class AgendaEvents extends DolibarrApi
* Get properties of a Agenda Events object
*
* Return an array with Agenda Events informations
*
*
* @param int $id ID of Agenda Events
* @return array|mixed Data without useless information
*
* @throws RestException
*/
function get($id)
{
{
if(! DolibarrApiAccess::$user->rights->agenda->myactions->read) {
throw new RestException(401, "Insuffisant rights to read an event");
}
$result = $this->actioncomm->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Agenda Events not found');
}
if(! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) {
throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
if( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->actioncomm->fetchObjectLinked();
return $this->_cleanObjectDatas($this->actioncomm);
}
/**
* List Agenda Events
*
*
* Get a list of Agenda Events
*
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $user_ids User ids filter field (owners of event). Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.date_creation:<:'20160101')"
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')"
* @return array Array of Agenda Events objects
*/
function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0, $sqlfilters = '') {
function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
// case of external user
$socid = 0;
if (! empty(DolibarrApiAccess::$user->societe_id)) $socid = DolibarrApiAccess::$user->societe_id;
if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.id as rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
$sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')';
@ -121,7 +121,7 @@ class AgendaEvents extends DolibarrApi
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
@ -130,7 +130,7 @@ class AgendaEvents extends DolibarrApi
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
@ -143,7 +143,7 @@ class AgendaEvents extends DolibarrApi
}
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
@ -181,7 +181,7 @@ class AgendaEvents extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
// Check mandatory fields
$result = $this->_validate($request_data);
@ -198,18 +198,18 @@ class AgendaEvents extends DolibarrApi
if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors));
}
return $this->actioncomm->id;
}
/**
* Update Agenda Event general fields (won't touch lines of expensereport)
*
* @param int $id Id of Agenda Event to update
* @param array $request_data Datas
*
* @return int
* @param array $request_data Datas
*
* @return int
*/
/*
function put($id, $request_data = NULL) {
@ -219,12 +219,12 @@ class AgendaEvents extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) {
throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
$result = $this->expensereport->fetch($id);
if( ! $result ) {
throw new RestException(404, 'expensereport not found');
}
if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@ -232,19 +232,19 @@ class AgendaEvents extends DolibarrApi
if ($field == 'id') continue;
$this->expensereport->$field = $value;
}
if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id);
return false;
}
*/
/**
* Delete Agenda Event
*
* @param int $id Agenda Event ID
*
*
* @return array
*/
function delete($id)
@ -252,49 +252,49 @@ class AgendaEvents extends DolibarrApi
if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) {
throw new RestException(401, "Insuffisant rights to delete your Agenda Event");
}
$result = $this->actioncomm->fetch($id);
if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) {
throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
if( ! $result ) {
throw new RestException(404, 'Agenda Event not found');
}
if( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Agenda Event deleted'
)
);
}
/**
* Validate fields before create or update object
*
*
* @param array $data Array with data to verify
* @return array
* @return array
* @throws RestException
*/
function _validate($data)
{
$event = array();
foreach (Events::$FIELDS as $field) {
foreach (AgendaEvents::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$event[$field] = $data[$field];
}
return $event;
}

View File

@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
@ -281,8 +280,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
$form = new Form($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccountancy2 = New FormAccounting($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
@ -511,7 +509,7 @@ if ($action == 'create')
{
print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->account_number, 'account_number', 1, '', 1, 1);
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
print '</td></tr>';
}
else
@ -525,7 +523,7 @@ if ($action == 'create')
{
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
print '</td></tr>';
}
@ -957,43 +955,42 @@ else
//print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Accountancy code
$tdextra = ' class="titlefieldcreate"';
if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
$tdextra = ' class="fieldrequired titlefieldcreate"';
}
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if (!empty($conf->accounting->enabled)) {
print $formaccountancy->select_account($object->account_number, 'account_number', 1, '', 1, 1);
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
} else {
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
}
print '</td></tr>';
// Accountancy journal
if (! empty($conf->accounting->enabled))
{
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
print '</td></tr>';
}
print '</table>';
if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
{
print '<br>';
//print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// If bank account

View File

@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
$langs->load("compta");
@ -180,7 +180,7 @@ if ($action == 'delete')
llxHeader("",$langs->trans("VariousPayment"));
$form = new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
if ($id)
{
@ -271,9 +271,9 @@ if ($action == 'create')
{
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
print '<td>';
print $formaccountancy->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
print '</td></tr>';
}
}
else // For external software
{
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';

View File

@ -429,23 +429,23 @@ class Form
if ($direction > 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-right: 3px !important;'; }
$classfortooltip='classfortooltip';
$s='';$textfordialog='';
$htmltext=str_replace('"',"&quot;",$htmltext);
if ($tooltiptrigger != '')
if ($tooltiptrigger != '')
{
$classfortooltip='classfortooltiponclick';
$textfordialog.='<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.'" class="classfortooltiponclicktext">'.$htmltext.'</div>';
}
if ($tooltipon == 2 || $tooltipon == 3)
if ($tooltipon == 2 || $tooltipon == 3)
{
$paramfortooltipimg=' class="'.$classfortooltip.' inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'"';
if ($tooltiptrigger == '') $paramfortooltipimg.=' title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on img tag to store tooltip
else $paramfortooltipimg.=' dolid="'.$tooltiptrigger.'"';
}
else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag
if ($tooltipon == 1 || $tooltipon == 3)
if ($tooltipon == 1 || $tooltipon == 3)
{
$paramfortooltiptd=' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" ';
if ($tooltiptrigger == '') $paramfortooltiptd.=' title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip
@ -496,7 +496,7 @@ class Form
$alt = '';
if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp");
//For backwards compatibility
if ($type == '0') $type = 'info';
elseif ($type == '1') $type = 'help';
@ -1076,6 +1076,8 @@ class Form
$resql=$this->db->query($sql);
if ($resql)
{
$events = null;
if ($conf->use_javascript_ajax && ! $forcecombo)
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
@ -3448,7 +3450,7 @@ class Form
$cat = new Categorie($this->db);
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid);
}
$output = '<select class="flat" name="'.$htmlname.'">';
$outarray=array();
if (is_array($cate_arbo))
@ -4921,7 +4923,7 @@ class Form
* @param int $iSecond Default preselected duration (number of seconds or '')
* @param int $disabled Disable the combo box
* @param string $typehour If 'select' then input hour and input min is a combo,
* if 'text' input hour is in text and input min is a text,
* if 'text' input hour is in text and input min is a text,
* if 'textselect' input hour is in text and input min is a combo
* @param integer $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it
@ -4966,7 +4968,7 @@ class Form
if ($typehour!='text') $retstring.=' '.$langs->trans('HourShort');
else $retstring.=':';
// Minutes
if ($minunderhours) $retstring.='<br>';
else $retstring.="&nbsp;";
@ -4986,7 +4988,7 @@ class Form
{
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
}
if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort');
//$retstring.="&nbsp;";
@ -5908,6 +5910,10 @@ class Form
{
$ret.=$object->ref.'<br>'.$object->label;
}
else if (in_array($object->element, array('adherent_type')))
{
$ret.=$object->label;
}
else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref);
@ -6211,7 +6217,7 @@ class Form
return $out;
}
/**
* Return HTML to show the search and clear seach button
*
@ -6220,7 +6226,7 @@ class Form
function showFilterButtons()
{
global $conf, $langs;
$out='<div class="nowrap">';
$out.='<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
$out.='<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
@ -6239,7 +6245,7 @@ class Form
function showCheckAddButtons($cssclass='checkforaction', $calljsfunction=0)
{
global $conf, $langs;
$out='';
if (! empty($conf->use_javascript_ajax)) $out.='<div class="inline-block checkallactions"><input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions"></div>';
$out.='<script type="text/javascript">

View File

@ -1,5 +1,9 @@
<?php
/* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.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
@ -28,7 +32,7 @@
class FormAccounting extends Form
{
private $options_cache = array();
private $options_cache = array();
var $db;
var $error;
@ -205,5 +209,222 @@ class FormAccounting extends Form
print $out;
}
/**
* Return select filter with date of transaction
*
* @param string $htmlname Name of select field
* @param string $selectedkey Value
* @return string HTML edit field
*/
function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') {
$options = array();
$sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping';
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= ' ORDER BY import_key DESC';
dol_syslog(get_class($this) . "::select_bookkeeping_importkey", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_bookkeeping_importkey " . $this->error, LOG_ERR);
return - 1;
}
while ($obj = $this->db->fetch_object($resql)) {
$options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext');
}
return Form::selectarray($htmlname, $options, $selectedkey);
}
/**
* Return list of accounts with label by chart of accounts
*
* @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
* @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @return string String with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
{
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$out = '';
$options = array();
if ($usecache && ! empty($this->options_cache[$usecache]))
{
$options = $this->options_cache[$usecache];
$selected=$selectid;
}
else
{
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account 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", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
return -1;
}
$out .= ajax_combobox($htmlname, $event);
$selected = 0;
while ($obj = $this->db->fetch_object($resql))
{
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->account_number;
}
if ($select_out == 1) {
$select_value_out = $obj->account_number;
}
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning
if ($selectid != '' && $selectid == $select_value_in) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected = $select_value_out;
}
$options[$select_value_out] = $label;
}
$this->db->free($resql);
if ($usecache)
{
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
return $out;
}
/**
* Return list of auxilary thirdparty accounts
*
* @param string $selectid Preselected pcg_type
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
* @return string String with HTML select
*/
function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
$aux_account = array();
// Auxiliary customer account
$sql = "SELECT DISTINCT code_compta, nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
$sql .= " ORDER BY code_compta";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta)) {
$aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
}
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Auxiliary supplier account
$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (" . getEntity("societe", 1) . ")";
$sql .= " ORDER BY code_compta_fournisseur";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta_fournisseur)) {
$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
}
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Build select
$out = ajax_combobox($htmlname, $event);
$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
return $out;
}
/**
* Return HTML combo list of years existing into book keepping
*
* @param string $selected Preselected value
* @param string $htmlname Name of HTML select object
* @param int $useempty Affiche valeur vide dans liste
* @param string $output_format (html/opton (for option html only)/array (to return options arrays
* @return string/array
*/
function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
{
global $conf;
$out_array = array();
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
$sql .= " ORDER BY date_format(doc_date,'%Y')";
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$out_array[$obj->dtyear] = $obj->dtyear;
}
$this->db->free($resql);
if ($output_format == 'html') {
return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
} else {
return $out_array;
}
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* 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
@ -27,7 +27,7 @@
* Prepare array with list of admin tabs
*
* @param AccountingAccount $object Object instance we show card
* @return array Array of tabs to show
* @return array Array of tabs to show
*/
function admin_accounting_prepare_head(AccountingAccount $object=null)
{
@ -41,11 +41,6 @@ function admin_accounting_prepare_head(AccountingAccount $object=null)
$head[$h][2] = 'general';
$h ++;
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/journals.php';
$head[$h][1] = $langs->trans("Journaux");
$head[$h][2] = 'journal';
$h ++;
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php';
$head[$h][1] = $langs->trans("ExportOptions");
$head[$h][2] = 'export';
@ -91,35 +86,6 @@ function accounting_prepare_head(AccountingAccount $object)
return $head;
}
/**
* Prepare array with list of tabs
*
* @param AccountingAccount $object Accounting account
* @return array Array of tabs to show
*/
function accounting_journal_prepare_head(AccountingJournal $object)
{
global $langs, $conf;
$h = 0;
$head = array ();
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/journals_card.php?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_journal');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_journal', 'remove');
return $head;
}
/**
* Return accounting account without zero on the right
*
@ -129,7 +95,7 @@ function accounting_journal_prepare_head(AccountingJournal $object)
function clean_account($account)
{
$account = rtrim($account,"0");
return $account;
}
@ -144,9 +110,9 @@ function length_accountg($account)
global $conf;
if ($account < 0 || empty($account)) return '';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
if (! empty($g)) {
// Clean parameters
@ -179,9 +145,9 @@ function length_accounta($accounta)
global $conf, $langs;
if ($accounta < 0 || empty($accounta)) return '';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
if (! empty($a)) {
// Clean parameters

View File

@ -102,14 +102,14 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
/**
* Get list of entity id to use
*
* @param string $element Current element
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
* @param string $element Current element
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
* 'product', 'productprice', 'stock',
* 'propal', 'supplier_proposal', 'facture', 'facture_fourn',
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
* 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey',
* 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project',
* 'email_template', 'event',
* 'email_template', 'event',
* @param int $shared 0=Return id of entity, 1=Return id entity + shared entities
* @return mixed Entity id(s) to use
*/
@ -121,7 +121,7 @@ function getEntity($element=false, $shared=0)
if ($element == 'actioncomm') $element='agenda';
if ($element == 'fichinter') $element='intervention';
if ($element == 'categorie') $element='category';
if (is_object($mc))
{
return $mc->getEntity($element, $shared);
@ -240,7 +240,7 @@ function dol_shutdown()
* Return value of a param into GET or POST supervariable.
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by the main when loading the user.
*
*
* @param string $paramname Name of parameter to found
* @param string $check Type of check
* ''=no check (deprecated)
@ -257,29 +257,29 @@ function dol_shutdown()
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'.
* @return string|string[] Value found (string or array), or '' if check fails
*
*
* @TODO Set default value for check to alpha. Check all WYSIWYG edition (email and description...) is still ok with rich text.
*/
function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
{
global $mysoc,$user,$conf;
if (empty($paramname)) return 'BadFirstParameterForGETPOST';
if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:'');
elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:'';
elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:'';
elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:'');
elseif ($method==4) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:(isset($_COOKIE[$paramname])?$_COOKIE[$paramname]:''));
else return 'BadThirdParameterForGETPOST';
if (empty($method) || $method == 3 || $method == 4)
{
$relativepathstring = $_SERVER["PHP_SELF"];
if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
$relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
$relativepathstring = preg_replace('/^\//', '', $relativepathstring);
// Code for search criteria persistence.
// Retrieve values if restore_lastsearch_values is set and there is saved values
if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here
@ -347,16 +347,16 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
}
}
}
}
}
if (empty($check) && ! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2)
{
dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param not defined, when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param not defined, when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
// Enable this line to know who call the GETPOST with empty $check parameter.
//var_dump(debug_backtrace()[0]);
}
if (! empty($check))
{
// Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
@ -460,7 +460,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
// We save search key only if:
// - not empty, or
// - if value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not).
//if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname]))
if (! empty($out))
{
@ -468,7 +468,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
}
}
}
return $out;
}
@ -478,13 +478,13 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
* This prefix is unique for instance and avoid conflict between multi-instances,
* even when having two instances with one root dir or two instances in virtual servers.
*
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
* @return string A calculated prefix
*/
function dol_getprefix($mode='')
{
global $conf;
// If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email
if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
{
@ -632,7 +632,7 @@ function dol_clone($object)
//$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable
$myclone=unserialize(serialize($object));
return $myclone;
}
@ -1137,7 +1137,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
global $conf, $form, $user, $langs;
$error = 0;
$maxvisiblephotos=1;
$showimage=1;
$showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0);
@ -1209,7 +1209,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$fileimage = $file.'_preview.png'; // If PDF has 1 page
$fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page
$relativepathimage = $relativepath.'_preview.png';
// Si fichier PDF existe
if (file_exists($file))
{
@ -1252,7 +1252,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$morehtmlleft.='</div>';
}
}
if (! $phototoshow && $conf->browser->layout != 'phone') // Show No photo link (picto of pbject)
{
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">';
@ -1274,12 +1274,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
}
}
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
if ($object->element == 'societe')
{
if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE))
if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE))
{
$morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
}
@ -1306,7 +1306,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt;
}
elseif ($object->element == 'contrat' || $object->element == 'contract')
elseif ($object->element == 'contrat' || $object->element == 'contract')
{
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4);
@ -1317,14 +1317,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$morehtmlstatus.=$tmptxt;
}
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
// Add label
if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task')
{
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>';
}
if ($object->element != 'product' && $object->element != 'bookmark')
if ($object->element != 'product' && $object->element != 'bookmark')
{
$morehtmlref.='<div class="refidno">';
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
@ -1336,7 +1336,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$morehtmlref.=$langs->trans("TechnicalID").': '.$object->id;
$morehtmlref.='</div>';
}
print '<div class="'.($onlybanner?'arearefnobottom ':'arearef ').'heightref valignmiddle" width="100%">';
print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
print '</div>';
@ -3098,7 +3098,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv=0, $admin='1')
{
return img_picto($text, 'info', 'class="hideonsmartphone"');
}
return ($nodiv?'':'<div class="'.(empty($admin)?'':($admin=='1'?'info':$admin)).' hideonsmartphone">').'<span class="fa fa-info-circle" title="'.dol_escape_htmltag($admin?$langs->trans('InfoAdmin'):$langs->trans('Note')).'"></span> '.$text.($nodiv?'':'</div>');
}
@ -3296,7 +3296,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
$field1=trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep'
//var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1);
// If field is used as sort criteria we use a specific css class liste_titre_sel
// Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom")
if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./","",$field1))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>';
@ -3444,7 +3444,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
* @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder)
* @param string $sortfield Field to sort on ('' by default)
* @param string $sortorder Order to sort ('' by default)
* @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
* @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
* @param int $num Number of records found by select with limit+1
* @param int|string $totalnboflines Total number of records/lines for all pages (if known). Use a negative value of number to not show number. Use '' if unknown.
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
@ -3968,7 +3968,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
{
$conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
}
// Search local taxes
if (! empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY))
{
@ -4213,7 +4213,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
/**
* Return vat rate of a product in a particular selling country or default country vat if product is unknown
* Function called by get_default_tva
*
*
* @param int $idprod Id of product or 0 if not a predefined product
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" order/invoice)
@ -4251,7 +4251,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
}
else
{
// TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
// TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
// May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on
}
}
@ -5023,9 +5023,9 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
global $conf, $langs;
if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
if (empty($outputlangs)) $outputlangs=$langs;
// Make substitution for language keys
if (is_object($outputlangs))
{
@ -5033,10 +5033,10 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
{
$msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1;
$text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
$text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
}
}
// Make substitition for array $substitutionarray
foreach ($substitutionarray as $key => $value)
{
@ -5049,7 +5049,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
/**
* Complete the $substitutionarray with more entries.
* Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called.
* Can also add substitution keys coming from external module that had set the "substitutions=1" into module_part array. In this case, method completesubstitutionarray provided by module is called.
*
* @param array $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs Output language
@ -5070,7 +5070,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
{
// TODO
}
// Add a substitution key for each extrafields, using key __EXTRA_XXX__
if (is_object($object) && is_array($object->array_options))
{
@ -5082,7 +5082,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
$substitutionarray['%EXTRA_'.$keyshort.'%']=$val;
}
}
// Check if there is external substitution to do, requested by plugins
$dirsubstitutions=array_merge(array(),(array) $conf->modules_parts['substitutions']);
@ -5618,8 +5618,8 @@ function dol_eval($s, $returnvalue=0, $hideerrors=1)
global $rights;
global $object;
global $mysoc;
global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object
global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object
global $soc; // For backward compatibility
//print $s."<br>\n";
@ -5830,7 +5830,7 @@ function printCommonFooter($zone='private')
this.href=this.href+\'&page_y=\'+page_y;
});'."\n";
print '});'."\n";
if (empty($conf->dol_use_jmobile))
{
print '<!-- Set handler to switch left menu page (menuhider) -->'."\n";
@ -5840,7 +5840,7 @@ function printCommonFooter($zone='private')
print " $('.login_block').toggle();";
print '});'."\n";
}
print '</script>'."\n";
}
@ -6003,9 +6003,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
{
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
}
$value = preg_replace('/\s*\|\s*/','|', $value);
$crits = explode(' ', $value);
$res = '';
if (! is_array($fields)) $fields = array($fields);
@ -6128,7 +6128,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
*
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs.
* @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php)
* @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php)
* @param string $param More param on http links
* @return string|array Output string with href link or array with all components of link
*/
@ -6142,8 +6142,8 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param=''
//$mime_preview[]='vnd.oasis.opendocument.presentation';
//$mime_preview[]='archive';
$num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
if ($alldata == 1)
if ($alldata == 1)
{
if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), );
else return array();

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Benoit Bruchard <benoitb21@gmail.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Benoit Bruchard <benoitb21@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
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load("admin");
$langs->load("donations");
@ -199,7 +199,7 @@ else if ($action == 'setart885') {
$dir = "../../core/modules/dons/";
$form=new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -364,7 +364,7 @@ print '<label for="DONATION_ACCOUNTINGACCOUNT">' . $label . '</label></td>';
print '<td>';
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
}
else
{
@ -401,7 +401,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('Parameters') . '</td>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART200") . '</td>';
if (! empty($conf->global->DONATION_ART200)) {
@ -414,7 +414,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART238") . '</td>';
if (! empty($conf->global->DONATION_ART238)) {
@ -427,7 +427,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '</a></td>';
}
print '</tr>';
print '<tr class="oddeven">';
print '<td width="80%">' . $langs->trans("DONATION_ART885") . '</td>';
if (! empty($conf->global->DONATION_ART885)) {

View File

@ -214,22 +214,22 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic
ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT '';
DELETE FROM llx_const where name = 'ADHERENT_BANK_USE_AUTO';
DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__;
UPDATE llx_const set value='moono-lisa' where value = 'moono' AND name = 'FCKEDITOR_SKIN';
UPDATE llx_const SET value = __ENCRYPT('moono-lisa')__ WHERE value = __ENCRYPT('moono')__ AND name = __ENCRYPT('FCKEDITOR_SKIN')__;
ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx;
ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx;
ALTER TABLE llx_user ADD COLUMN model_pdf varchar(255);
ALTER TABLE llx_usergroup ADD COLUMN model_pdf varchar(255);
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('PRODUCT_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/products')__, 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('CONTRACT_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/contracts')__, 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('USERGROUP_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/usergroups')__, 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('USER_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/users')__, 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, '1', 'chaine', 0, 'Enable overwrote of translation');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('MAIN_ENABLE_OVERWRITE_TRANSLATION')__, 1, __ENCRYPT('1')__, 'chaine', 0, 'Enable overwrote of translation');
ALTER TABLE llx_chargesociales ADD COLUMN ref varchar(16);
ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL;
@ -348,3 +348,4 @@ ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer;
DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm);
ALTER TABLE llx_inventory ADD COLUMN ref varchar(48);

View File

@ -257,7 +257,7 @@ Formula=Formula
ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries)
ExportNotSupported=The export format setuped is not supported into this page
BookeppingLineAlreayExists=Lines already existing into bookeeping
NoJournalDefined=No journal defined
Binded=Lines bound
ToBind=Lines to bind

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
/* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@ -235,7 +235,7 @@ if (empty($reshook))
$form = new Form($db);
$formproject = new FormProjets($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
@ -337,19 +337,19 @@ if ($action == 'create')
// Accountancy_account_capital
print '<tr><td class="titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1);
print $formaccounting->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1);
print '</td></tr>';
// Accountancy_account_insurance
print '<tr><td>'.$langs->trans("LoanAccountancyInsuranceCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
print $formaccounting->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
print '</td></tr>';
// Accountancy_account_interest
print '<tr><td>'.$langs->trans("LoanAccountancyInterestCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
print $formaccounting->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
print '</td></tr>';
}
else // For external software
@ -541,7 +541,7 @@ if ($id > 0)
{
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1);
print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1);
}
else
{
@ -566,7 +566,7 @@ if ($id > 0)
{
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1);
}
else
{
@ -591,7 +591,7 @@ if ($id > 0)
{
if (! empty($conf->accounting->enabled))
{
print $formaccountancy->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1);
print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1);
}
else
{

View File

@ -1,20 +1,20 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2014-2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.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
@ -52,7 +52,8 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/p
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
$langs->load("products");
$langs->load("other");
@ -272,7 +273,7 @@ if (empty($reshook))
$object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished');
$object->fk_unit = GETPOST('units');
$accountancy_code_sell = GETPOST('accountancy_code_sell');
$accountancy_code_buy = GETPOST('accountancy_code_buy');
@ -399,7 +400,7 @@ if (empty($reshook))
$accountancy_code_sell = GETPOST('accountancy_code_sell');
$accountancy_code_buy = GETPOST('accountancy_code_buy');
if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
@ -808,7 +809,7 @@ llxHeader('', $title, $helpurl);
$form = new Form($db);
$formfile = new FormFile($db);
$formproduct = new FormProduct($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
// Load object modBarCodeProduct
$res=0;
@ -1107,21 +1108,21 @@ else
// Accountancy codes
print '<table class="border" width="100%">';
if (! empty($conf->accounting->enabled))
{
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td>';
print $formaccountancy->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, '');
print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, '');
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
print $formaccountancy->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
print '</td></tr>';
}
}
else // For external software
{
// Accountancy_code_sell
@ -1406,15 +1407,15 @@ else
// Accountancy_code_sell
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
print '</td></tr>';
// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
print '</td></tr>';
}
}
else // For external software
{
// Accountancy_code_sell
@ -1531,8 +1532,12 @@ else
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancySellCode");
print '</td><td colspan="2">';
if (! empty($conf->accounting->enabled)) {
print length_accountg($object->accountancy_code_sell);
if (! empty($conf->accounting->enabled))
{
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$object->accountancy_code_sell);
print $accountingaccount->getNomUrl(0,1,1,'',1);
} else {
print $object->accountancy_code_sell;
}
@ -1542,8 +1547,12 @@ else
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancyBuyCode");
print '</td><td colspan="2">';
if (! empty($conf->accounting->enabled)) {
print length_accountg($object->accountancy_code_buy);
if (! empty($conf->accounting->enabled))
{
$accountingaccount2 = new AccountingAccount($db);
$accountingaccount2->fetch('',$object->accountancy_code_buy);
print $accountingaccount2->getNomUrl(0,1,1,'',1);
} else {
print $object->accountancy_code_buy;
}