Merge branch 'develop' into develop
@ -4,6 +4,9 @@ English Dolibarr ChangeLog
|
|||||||
|
|
||||||
***** ChangeLog for 6.0.0 compared to 5.0.* *****
|
***** ChangeLog for 6.0.0 compared to 5.0.* *****
|
||||||
|
|
||||||
|
For developers:
|
||||||
|
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
|
||||||
|
|
||||||
WARNING:
|
WARNING:
|
||||||
|
|
||||||
Following changes may create regression for some external modules, but were necessary to make Dolibarr better:
|
Following changes may create regression for some external modules, but were necessary to make Dolibarr better:
|
||||||
|
|||||||
@ -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/admin.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
|
||||||
|
|
||||||
// Langs
|
// Langs
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
|
|||||||
@ -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/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.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.'/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("errors");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
@ -1258,7 +1258,7 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
|
|
||||||
$formadmin = new FormAdmin($db);
|
$formadmin = new FormAdmin($db);
|
||||||
$formcompany = new FormCompany($db);
|
$formcompany = new FormCompany($db);
|
||||||
$formaccountancy = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
foreach ($fieldlist as $field => $value)
|
foreach ($fieldlist as $field => $value)
|
||||||
{
|
{
|
||||||
@ -1400,7 +1400,7 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
if (! empty($conf->accounting->enabled))
|
if (! empty($conf->accounting->enabled))
|
||||||
{
|
{
|
||||||
$accountancy_account = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0);
|
$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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* 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 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/accountancy/admin/card.php
|
* \file htdocs/accountancy/admin/card.php
|
||||||
* \ingroup Advanced accountancy
|
* \ingroup Advanced accountancy
|
||||||
* \brief Card of accounting account
|
* \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 . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.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/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';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
@ -196,7 +195,6 @@ $helpurl = '';
|
|||||||
llxheader('', $title, $helpurl);
|
llxheader('', $title, $helpurl);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$htmlacc = new FormVentilation($db);
|
|
||||||
$formaccounting = new FormAccounting($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
$accountsystem = new AccountancySystem($db);
|
$accountsystem = new AccountancySystem($db);
|
||||||
@ -220,7 +218,6 @@ if ($action == 'create') {
|
|||||||
print $accountsystem->ref;
|
print $accountsystem->ref;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
// Account number
|
// Account number
|
||||||
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
|
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>';
|
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"></td></tr>';
|
||||||
@ -232,7 +229,7 @@ if ($action == 'create') {
|
|||||||
// Account parent
|
// Account parent
|
||||||
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Category
|
// Category
|
||||||
@ -245,14 +242,12 @@ if ($action == 'create') {
|
|||||||
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
||||||
print '<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 '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Chart of acounts subtype
|
// Chart of acounts subtype
|
||||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||||
print '<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 '<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 '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -298,19 +293,18 @@ if ($action == 'create') {
|
|||||||
// Account parent
|
// Account parent
|
||||||
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Category
|
// Category
|
||||||
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
|
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Chart of accounts type
|
// Chart of accounts type
|
||||||
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
|
||||||
print '<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 '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type','alpha'):$object->pcg_type).'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -318,7 +312,6 @@ if ($action == 'create') {
|
|||||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||||
print '<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 '<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 '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -333,7 +326,6 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// View mode
|
// View mode
|
||||||
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
|
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
|
||||||
|
|
||||||
@ -388,7 +380,6 @@ if ($action == 'create') {
|
|||||||
/*
|
/*
|
||||||
* Actions buttons
|
* Actions buttons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if (! empty($user->rights->accounting->chartofaccount)) {
|
if (! empty($user->rights->accounting->chartofaccount)) {
|
||||||
|
|||||||
@ -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/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.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.'/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("errors");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
@ -982,7 +982,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
|
|||||||
|
|
||||||
$formadmin = new FormAdmin($db);
|
$formadmin = new FormAdmin($db);
|
||||||
$formcompany = new FormCompany($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)
|
foreach ($fieldlist as $field => $value)
|
||||||
{
|
{
|
||||||
@ -1125,7 +1125,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex
|
|||||||
{
|
{
|
||||||
$fieldname = $fieldlist[$field];
|
$fieldname = $fieldlist[$field];
|
||||||
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
|
$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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -32,7 +32,7 @@ require '../../main.inc.php';
|
|||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.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 . '/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("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -117,7 +117,7 @@ if ($action == 'update') {
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formaccountancy = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
$linkback = '';
|
$linkback = '';
|
||||||
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
|
print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy');
|
||||||
@ -142,7 +142,7 @@ foreach ( $list_account as $key ) {
|
|||||||
print '<td>' . $label . '</td>';
|
print '<td>' . $label . '</td>';
|
||||||
// Value
|
// Value
|
||||||
print '<td>'; // Do not force align=right, or it align also the content of the select box
|
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 '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2013-2014 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -28,7 +27,7 @@ require '../../main.inc.php';
|
|||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.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
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
@ -140,7 +139,7 @@ if ($result) {
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$htmlacc = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
$var = true;
|
$var = true;
|
||||||
while ( $i < min($num_lines, $limit) ) {
|
while ( $i < min($num_lines, $limit) ) {
|
||||||
@ -157,19 +156,18 @@ if ($result) {
|
|||||||
|
|
||||||
// Colonne choix du compte
|
// Colonne choix du compte
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $htmlacc->select_account($accounting->account_parent, 'AccountParent');
|
print $formaccounting->select_account($accounting->account_parent, 'AccountParent');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
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 '<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>';
|
print '</td>';
|
||||||
|
|
||||||
// Colonne choix ligne a ventiler
|
// Colonne choix ligne a ventiler
|
||||||
|
|
||||||
$checked = ('label' == 'O') ? ' checked' : '';
|
$checked = ('label' == 'O') ? ' checked' : '';
|
||||||
|
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,8 +31,6 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.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/html.formventilation.class.php';
|
|
||||||
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -160,7 +158,6 @@ if ($action == 'setdisabledirectinput') {
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formaccountancy = new FormVentilation($db);
|
|
||||||
|
|
||||||
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
|
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
|
||||||
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
|
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
|
||||||
|
|||||||
@ -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();
|
|
||||||
@ -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/report.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.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 . '/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 . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ if ($action == 'update') {
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new FormVentilation($db);
|
$form = new FormAccounting($db);
|
||||||
|
|
||||||
// Defaut AccountingAccount RowId Product / Service
|
// Defaut AccountingAccount RowId Product / Service
|
||||||
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
|
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
|
||||||
|
|||||||
@ -28,8 +28,8 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.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';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||||
|
|
||||||
// Langs
|
// Langs
|
||||||
@ -61,7 +61,7 @@ $offset = $limit * $page;
|
|||||||
|
|
||||||
$object = new BookKeeping($db);
|
$object = new BookKeeping($db);
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
@ -186,10 +186,10 @@ else {
|
|||||||
print '<tr class="liste_titre_filter">';
|
print '<tr class="liste_titre_filter">';
|
||||||
print '<td class="liste_titre" colspan="5">';
|
print '<td class="liste_titre" colspan="5">';
|
||||||
print $langs->trans('From');
|
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 ' ';
|
||||||
print $langs->trans('to');
|
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>';
|
||||||
print '<td align="right" class="liste_titre">';
|
print '<td align="right" class="liste_titre">';
|
||||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||||
|
|||||||
@ -27,9 +27,8 @@ require '../../main.inc.php';
|
|||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
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 . '/accountancy/class/accountingjournal.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||||
|
|
||||||
// Langs
|
// Langs
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
@ -215,7 +214,6 @@ else if ($action == "confirm_create") {
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$formventilation = new FormVentilation($db);
|
|
||||||
$formaccountancy = new FormAccounting($db);
|
$formaccountancy = new FormAccounting($db);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -389,10 +387,10 @@ if ($action == 'create') {
|
|||||||
if ($action == 'update' && $line->id == $id) {
|
if ($action == 'update' && $line->id == $id) {
|
||||||
|
|
||||||
print '<td>';
|
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 '<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>';
|
||||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></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>';
|
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') {
|
if ($action == "" || $action == 'add') {
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>';
|
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 '<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>';
|
||||||
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></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>';
|
print '<td align="right"><input type="text" class="right maxwidth50" name="debit" value="' . price($debit) . '"/></td>';
|
||||||
|
|||||||
@ -28,10 +28,10 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.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 . '/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
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
@ -94,7 +94,7 @@ if ($sortfield == "") $sortfield = "t.rowid";
|
|||||||
|
|
||||||
$object = new BookKeeping($db);
|
$object = new BookKeeping($db);
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
@ -292,7 +292,6 @@ $title_page = $langs->trans("Bookkeeping");
|
|||||||
llxHeader('', $title_page);
|
llxHeader('', $title_page);
|
||||||
|
|
||||||
// List
|
// List
|
||||||
|
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
$nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||||
@ -322,8 +321,8 @@ if ($action == 'delbookkeepingyear') {
|
|||||||
if (empty($delyear)) {
|
if (empty($delyear)) {
|
||||||
$delyear = dol_print_date(dol_now(), '%Y');
|
$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');
|
||||||
$journal_array = $formventilation->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array');
|
$journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1);
|
||||||
|
|
||||||
$form_question['delyear'] = array (
|
$form_question['delyear'] = array (
|
||||||
'name' => 'delyear',
|
'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"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print $langs->trans('From');
|
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 '<br>';
|
||||||
print $langs->trans('to');
|
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>';
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print $langs->trans('From');
|
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 '<br>';
|
||||||
print $langs->trans('to');
|
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>';
|
||||||
print '<td class="liste_titre">';
|
print '<td class="liste_titre">';
|
||||||
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
|
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
|
||||||
|
|||||||
@ -29,8 +29,8 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.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';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||||
|
|
||||||
// Langs
|
// 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);
|
$object = new BookKeeping($db);
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ if ($action == 'delbookkeepingyear') {
|
|||||||
if (empty($delyear)) {
|
if (empty($delyear)) {
|
||||||
$delyear = dol_print_date(dol_now(), '%Y');
|
$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 (
|
$form_question['delyear'] = array (
|
||||||
'name' => 'delyear',
|
'name' => 'delyear',
|
||||||
|
|||||||
@ -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/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
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
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
@ -67,7 +67,7 @@ $search_code_journal = GETPOST('search_code_journal', 'alpha');
|
|||||||
|
|
||||||
$object = new BookKeeping($db);
|
$object = new BookKeeping($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
if (empty($search_date_start)) {
|
if (empty($search_date_start)) {
|
||||||
@ -182,15 +182,15 @@ print $form->select_date($search_date_end, 'date_end');
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="liste_titre">';
|
print '<div class="liste_titre">';
|
||||||
print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': ';
|
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 $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>';
|
||||||
print '<div class="liste_titre">';
|
print '<div class="liste_titre">';
|
||||||
print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
|
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 $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 '</div>';
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
|
|
||||||
|
|||||||
@ -1067,7 +1067,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql.= " WHERE 1 = 1";
|
$sql.= " WHERE 1 = 1";
|
||||||
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
|
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
|
||||||
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
|
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);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
@ -1099,7 +1099,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql = "DELETE";
|
$sql = "DELETE";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$sql .= " WHERE piece_num = " . $piecenum;
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
@ -1202,10 +1202,10 @@ class BookKeeping extends CommonObject
|
|||||||
public function fetchPerMvt($piecenum) {
|
public function fetchPerMvt($piecenum) {
|
||||||
global $conf;
|
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 .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$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);
|
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -1233,7 +1233,7 @@ class BookKeeping extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getNextNumMvt()
|
public function getNextNumMvt()
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
@ -1243,9 +1243,9 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
if ($obj) $result = $obj->max;
|
if ($obj) $result = $obj->max;
|
||||||
if (empty($result)) $result = 1;
|
if (empty($result)) $result = 1;
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR);
|
||||||
@ -1260,7 +1260,7 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch_all_per_mvt($piecenum) {
|
function fetch_all_per_mvt($piecenum) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||||
@ -1268,7 +1268,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$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);
|
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -1313,14 +1313,14 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int Result
|
* @return int Result
|
||||||
*/
|
*/
|
||||||
function export_bookkeping($model = 'ebp') {
|
function export_bookkeping($model = 'ebp') {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$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);
|
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,7 +26,7 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
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
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -40,8 +40,6 @@ $id = GETPOST('id');
|
|||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -84,7 +82,7 @@ if ($cancel == $langs->trans("Cancel")) {
|
|||||||
*/
|
*/
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$facture_static = new Facture($db);
|
$facture_static = new Facture($db);
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
if (! empty($id)) {
|
if (! empty($id)) {
|
||||||
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
|
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
|
||||||
@ -128,7 +126,7 @@ if (! empty($id)) {
|
|||||||
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
|
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
|
||||||
print '<td>' . nl2br($objp->description) . '</td></tr>';
|
print '<td>' . nl2br($objp->description) . '</td></tr>';
|
||||||
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><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 '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
// 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 . '/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -254,12 +254,12 @@ if ($result) {
|
|||||||
print $langs->trans("DescVentilDoneCustomer") . '<br>';
|
print $langs->trans("DescVentilDoneCustomer") . '<br>';
|
||||||
|
|
||||||
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<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>';
|
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
|
||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre_filter">';
|
print '<tr class="liste_titre_filter">';
|
||||||
|
|||||||
@ -30,7 +30,7 @@ require '../../main.inc.php';
|
|||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.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 . '/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 . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$accounting = new AccountingAccount($db);
|
$accounting = new AccountingAccount($db);
|
||||||
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
|
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
|
||||||
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_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
|
// 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
|
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_ref = '';
|
||||||
$search_invoice = '';
|
$search_invoice = '';
|
||||||
$search_label = '';
|
$search_label = '';
|
||||||
@ -255,7 +255,6 @@ if ($result) {
|
|||||||
//if ($massaction == 'presend') $arrayofmassactions=array();
|
//if ($massaction == 'presend') $arrayofmassactions=array();
|
||||||
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
|
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
|
||||||
|
|
||||||
|
|
||||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||||
print '<input type="hidden" name="action" value="ventil">';
|
print '<input type="hidden" name="action" value="ventil">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
@ -273,7 +272,7 @@ if ($result) {
|
|||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|
||||||
// We add search filter
|
// We add search filter
|
||||||
@ -350,7 +349,7 @@ if ($result) {
|
|||||||
if (! empty($objp->code_sell)) {
|
if (! empty($objp->code_sell)) {
|
||||||
$objp->code_sell_p = $objp->code_sell; // Code on product
|
$objp->code_sell_p = $objp->code_sell; // Code on product
|
||||||
} else {
|
} 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';
|
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
|
||||||
|
|
||||||
@ -403,7 +402,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Suggested accounting account
|
// Suggested accounting account
|
||||||
print '<td align="center">';
|
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>';
|
||||||
|
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
|
|||||||
@ -30,7 +30,7 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
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
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
|
|||||||
// Create
|
// Create
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$expensereport_static = new ExpenseReport($db);
|
$expensereport_static = new ExpenseReport($db);
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
if (! empty($id)) {
|
if (! empty($id)) {
|
||||||
$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
|
$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 '<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 '<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 '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
// 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 . '/expensereport/class/expensereport.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
@ -74,7 +74,7 @@ if ($user->societe_id > 0)
|
|||||||
if (! $user->rights->accounting->bind->write)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -226,7 +226,7 @@ if ($result) {
|
|||||||
print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
|
print $langs->trans("DescVentilDoneExpenseReport") . '<br>';
|
||||||
|
|
||||||
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<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>';
|
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
|
||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|||||||
@ -29,7 +29,7 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
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 . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$accounting = new AccountingAccount($db);
|
$accounting = new AccountingAccount($db);
|
||||||
|
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Suggested accounting account
|
// Suggested accounting account
|
||||||
print '<td align="center">';
|
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>';
|
||||||
|
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
* 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 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ require '../../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
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
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) {
|
|||||||
// Create
|
// Create
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$facturefournisseur_static = new FactureFournisseur($db);
|
$facturefournisseur_static = new FactureFournisseur($db);
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
if (! empty($id)) {
|
if (! empty($id)) {
|
||||||
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
|
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
|
||||||
@ -130,7 +130,7 @@ if (! empty($id)) {
|
|||||||
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
|
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
|
||||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||||
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><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 '</td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
/* 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) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,7 +27,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
// 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 . '/fourn/class/fournisseur.facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -237,7 +237,7 @@ if ($result) {
|
|||||||
print $langs->trans("DescVentilDoneSupplier") . '<br>';
|
print $langs->trans("DescVentilDoneSupplier") . '<br>';
|
||||||
|
|
||||||
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<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>';
|
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
|
||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* 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) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s
|
* 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,7 @@ require '../../main.inc.php';
|
|||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
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 . '/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 . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.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)
|
if (! $user->rights->accounting->bind->write)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$formventilation = new FormVentilation($db);
|
$formaccounting = new FormAccounting($db);
|
||||||
$accounting = new AccountingAccount($db);
|
$accounting = new AccountingAccount($db);
|
||||||
// TODO: we should need to check if result is a really exist accountaccount rowid.....
|
// 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);
|
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
|
||||||
@ -252,7 +252,6 @@ if ($result) {
|
|||||||
//if ($massaction == 'presend') $arrayofmassactions=array();
|
//if ($massaction == 'presend') $arrayofmassactions=array();
|
||||||
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
|
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
|
||||||
|
|
||||||
|
|
||||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||||
print '<input type="hidden" name="action" value="ventil">';
|
print '<input type="hidden" name="action" value="ventil">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
@ -409,7 +408,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Suggested accounting account
|
// Suggested accounting account
|
||||||
print '<td align="center">';
|
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>';
|
||||||
|
|
||||||
// Colonne choix ligne a ventiler
|
// Colonne choix ligne a ventiler
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -37,6 +37,12 @@ class AdherentType extends CommonObject
|
|||||||
public $element = 'adherent_type';
|
public $element = 'adherent_type';
|
||||||
public $picto = 'group';
|
public $picto = 'group';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
* @deprecated Use label
|
||||||
|
* @see label
|
||||||
|
*/
|
||||||
|
public $libelle;
|
||||||
/** @var string Label */
|
/** @var string Label */
|
||||||
public $label;
|
public $label;
|
||||||
/**
|
/**
|
||||||
@ -81,12 +87,13 @@ class AdherentType extends CommonObject
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$this->statut=(int) $this->statut;
|
$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 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
|
||||||
$sql.= "libelle";
|
$sql.= "libelle";
|
||||||
$sql.= ", entity";
|
$sql.= ", entity";
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
$sql.= "'".$this->db->escape($this->libelle)."'";
|
$sql.= "'".$this->db->escape($this->label)."'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
@ -117,12 +124,12 @@ class AdherentType extends CommonObject
|
|||||||
|
|
||||||
$error=0;
|
$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 = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
|
||||||
$sql.= "SET ";
|
$sql.= "SET ";
|
||||||
$sql.= "statut = ".$this->statut.",";
|
$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.= "subscription = '".$this->db->escape($this->subscription)."',";
|
||||||
$sql.= "note = '".$this->db->escape($this->note)."',";
|
$sql.= "note = '".$this->db->escape($this->note)."',";
|
||||||
$sql.= "vote = '".$this->db->escape($this->vote)."',";
|
$sql.= "vote = '".$this->db->escape($this->vote)."',";
|
||||||
|
|||||||
@ -132,9 +132,10 @@ class Members extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$i=0;
|
$i=0;
|
||||||
$num = $db->num_rows($result);
|
$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);
|
$member = new Adherent($this->db);
|
||||||
if($member->fetch($obj->rowid)) {
|
if($member->fetch($obj->rowid)) {
|
||||||
$obj_ret[] = $this->_cleanObjectDatas($member);
|
$obj_ret[] = $this->_cleanObjectDatas($member);
|
||||||
|
|||||||
322
htdocs/adherents/class/api_memberstypes.class.php
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -55,7 +55,7 @@ $pagenext = $page + 1;
|
|||||||
if (! $sortorder) { $sortorder="DESC"; }
|
if (! $sortorder) { $sortorder="DESC"; }
|
||||||
if (! $sortfield) { $sortfield="d.lastname"; }
|
if (! $sortfield) { $sortfield="d.lastname"; }
|
||||||
|
|
||||||
$label=GETPOST("libelle","alpha");
|
$label=GETPOST("label","alpha");
|
||||||
$subscription=GETPOST("subscription","int");
|
$subscription=GETPOST("subscription","int");
|
||||||
$vote=GETPOST("vote","int");
|
$vote=GETPOST("vote","int");
|
||||||
$comment=GETPOST("comment");
|
$comment=GETPOST("comment");
|
||||||
@ -93,17 +93,17 @@ if ($action == 'add' && $user->rights->adherent->configurer)
|
|||||||
{
|
{
|
||||||
$object = new AdherentType($db);
|
$object = new AdherentType($db);
|
||||||
|
|
||||||
$object->libelle = trim($label);
|
$object->label = trim($label);
|
||||||
$object->subscription = (int) trim($subscription);
|
$object->subscription = (int) trim($subscription);
|
||||||
$object->note = trim($comment);
|
$object->note = trim($comment);
|
||||||
$object->mail_valid = (boolean) trim($mail_valid);
|
$object->mail_valid = (boolean) trim($mail_valid);
|
||||||
$object->vote = (boolean) trim($vote);
|
$object->vote = (boolean) trim($vote);
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) $error++;
|
||||||
|
|
||||||
if ($object->libelle)
|
if ($object->label)
|
||||||
{
|
{
|
||||||
$id=$object->create($user);
|
$id=$object->create($user);
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
@ -131,7 +131,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
|
|||||||
{
|
{
|
||||||
$object = new AdherentType($db);
|
$object = new AdherentType($db);
|
||||||
$object->id = $rowid;
|
$object->id = $rowid;
|
||||||
$object->libelle = trim($label);
|
$object->label = trim($label);
|
||||||
$object->subscription = (int) trim($subscription);
|
$object->subscription = (int) trim($subscription);
|
||||||
$object->note = trim($comment);
|
$object->note = trim($comment);
|
||||||
$object->mail_valid = (boolean) trim($mail_valid);
|
$object->mail_valid = (boolean) trim($mail_valid);
|
||||||
@ -171,7 +171,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
|
|||||||
{
|
{
|
||||||
//dol_fiche_head('');
|
//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.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
||||||
$sql.= " WHERE d.entity IN (".getEntity().")";
|
$sql.= " WHERE d.entity IN (".getEntity().")";
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
|
|||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
print '<tr class="oddeven">';
|
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><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->subscription).'</td>';
|
||||||
print '<td align="center">'.yn($objp->vote).'</td>';
|
print '<td align="center">'.yn($objp->vote).'</td>';
|
||||||
if ($user->rights->adherent->configurer)
|
if ($user->rights->adherent->configurer)
|
||||||
@ -256,7 +256,7 @@ if ($action == 'create')
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tbody>';
|
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 '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
|
||||||
print $form->selectyesno("subscription",1,1);
|
print $form->selectyesno("subscription",1,1);
|
||||||
@ -460,7 +460,7 @@ if ($rowid > 0)
|
|||||||
{
|
{
|
||||||
$membertype=new AdherentType($db);
|
$membertype=new AdherentType($db);
|
||||||
$result=$membertype->fetch($type);
|
$result=$membertype->fetch($type);
|
||||||
$titre.=" (".$membertype->libelle.")";
|
$titre.=" (".$membertype->label.")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$param="&rowid=".$rowid;
|
$param="&rowid=".$rowid;
|
||||||
@ -548,7 +548,7 @@ if ($rowid > 0)
|
|||||||
// Type
|
// Type
|
||||||
/*print '<td class="nowrap">';
|
/*print '<td class="nowrap">';
|
||||||
$membertypestatic->id=$objp->type_id;
|
$membertypestatic->id=$objp->type_id;
|
||||||
$membertypestatic->libelle=$objp->type;
|
$membertypestatic->label=$objp->type;
|
||||||
print $membertypestatic->getNomUrl(1,12);
|
print $membertypestatic->getNomUrl(1,12);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
*/
|
*/
|
||||||
@ -652,7 +652,7 @@ if ($rowid > 0)
|
|||||||
|
|
||||||
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
|
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 '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
|
||||||
print $form->selectyesno("subscription",$object->subscription,1);
|
print $form->selectyesno("subscription",$object->subscription,1);
|
||||||
|
|||||||
@ -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/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.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.'/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("errors");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
@ -1662,7 +1662,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
|
|
||||||
$formadmin = new FormAdmin($db);
|
$formadmin = new FormAdmin($db);
|
||||||
$formcompany = new FormCompany($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)
|
foreach ($fieldlist as $field => $value)
|
||||||
{
|
{
|
||||||
@ -1811,7 +1811,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
{
|
{
|
||||||
$fieldname = $fieldlist[$field];
|
$fieldname = $fieldlist[$field];
|
||||||
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
|
$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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,7 +26,7 @@ require '../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.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");
|
$langs->load("admin");
|
||||||
$langs->load("loan");
|
$langs->load("loan");
|
||||||
@ -77,7 +77,7 @@ if ($action == 'update')
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$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>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup');
|
print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup');
|
||||||
@ -106,7 +106,7 @@ foreach ($list as $key)
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.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.'/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("errors");
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
@ -841,7 +841,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
|||||||
|
|
||||||
$formadmin = new FormAdmin($db);
|
$formadmin = new FormAdmin($db);
|
||||||
$formcompany = new FormCompany($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)
|
foreach ($fieldlist as $field => $value)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,7 +26,7 @@ require '../main.inc.php';
|
|||||||
|
|
||||||
// Class
|
// Class
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.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");
|
$langs->load("admin");
|
||||||
$langs->load("salaries");
|
$langs->load("salaries");
|
||||||
@ -76,7 +76,7 @@ if ($action == 'update')
|
|||||||
llxHeader('',$langs->trans('SalariesSetup'));
|
llxHeader('',$langs->trans('SalariesSetup'));
|
||||||
|
|
||||||
$form = new Form($db);
|
$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>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
|
print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
|
||||||
@ -109,7 +109,7 @@ foreach ($list as $key)
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.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');
|
$langs->load('admin');
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ if ($action == 'update') {
|
|||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
$form=new Form($db);
|
$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>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
|
print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
|
||||||
@ -216,7 +216,7 @@ foreach ($list as $key)
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
100
htdocs/api/class/api_dictionaryevents.class.php
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?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) 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -143,10 +144,9 @@ foreach ($modulesdir as $dir)
|
|||||||
*
|
*
|
||||||
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
|
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
|
||||||
*
|
*
|
||||||
* @todo : take care of externals module!
|
|
||||||
* @todo : use getElementProperties() function ?
|
* @todo : use getElementProperties() function ?
|
||||||
*/
|
*/
|
||||||
$dir_part = DOL_DOCUMENT_ROOT.'/'.$moduledirforclass.'/class/';
|
$dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
|
||||||
|
|
||||||
$handle_part=@opendir(dol_osencode($dir_part));
|
$handle_part=@opendir(dol_osencode($dir_part));
|
||||||
if (is_resource($handle_part))
|
if (is_resource($handle_part))
|
||||||
|
|||||||
@ -41,29 +41,15 @@ function printBookmarksList($aDb, $aLangs)
|
|||||||
$langs->load("bookmarks");
|
$langs->load("bookmarks");
|
||||||
|
|
||||||
$url= $_SERVER["PHP_SELF"].(! empty($_SERVER["QUERY_STRING"])?'?'.$_SERVER["QUERY_STRING"]:'');
|
$url= $_SERVER["PHP_SELF"].(! empty($_SERVER["QUERY_STRING"])?'?'.$_SERVER["QUERY_STRING"]:'');
|
||||||
// TODO Add post param to $url
|
|
||||||
|
|
||||||
$ret = '';
|
$ret = '';
|
||||||
|
|
||||||
// Menu bookmark
|
// Menu bookmark
|
||||||
/*
|
|
||||||
$ret.= '<div class="menu_titre">';
|
|
||||||
$ret.= '<table class="nobordernopadding" width="100%" summary="bookmarkstable"><tr><td>';
|
|
||||||
$ret.= '<a class="vmenu" href="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans('Bookmarks').'</a>';
|
|
||||||
$ret.= '</td><td align="right">';
|
|
||||||
if ($user->rights->bookmark->creer)
|
|
||||||
{
|
|
||||||
$ret.= '<a class="vsmenu addbookmarkpicto" href="'.DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url).'">';
|
|
||||||
$ret.=img_object($langs->trans('AddThisPageToBookmarks'),'bookmark');
|
|
||||||
$ret.= '</a>';
|
|
||||||
}
|
|
||||||
$ret.= '</td></tr></table>';
|
|
||||||
$ret.= '</div>';
|
|
||||||
*/
|
|
||||||
$ret.= '<div class="menu_top"></div>'."\n";
|
$ret.= '<div class="menu_top"></div>'."\n";
|
||||||
|
|
||||||
$ret.= '<!-- form with POST method by default --><form id="actionbookmark" name="actionbookmark" method="POST" action="">';
|
$ret.= '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n";
|
||||||
$ret.= '<select name="bookmark" id="boxbookmark" class="flat boxcombo vmenusearchselectcombo">';
|
$ret.= '<form id="actionbookmark" name="actionbookmark" method="POST" action="">';
|
||||||
|
$ret.= '<select name="bookmark" id="boxbookmark" class="flat boxcombo vmenusearchselectcombo" alt="Bookmarks">';
|
||||||
$ret.= '<option hidden value="listbookmarks" class="optiongrey" selected rel="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans('Bookmarks').'</option>';
|
$ret.= '<option hidden value="listbookmarks" class="optiongrey" selected rel="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans('Bookmarks').'</option>';
|
||||||
$ret.= '<option value="listbookmark" class="optionblue" rel="'.dol_escape_htmltag(DOL_URL_ROOT.'/bookmarks/list.php').'">'.dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
|
$ret.= '<option value="listbookmark" class="optionblue" rel="'.dol_escape_htmltag(DOL_URL_ROOT.'/bookmarks/list.php').'">'.dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
|
||||||
// Url to go on create new bookmark page
|
// Url to go on create new bookmark page
|
||||||
@ -77,19 +63,18 @@ function printBookmarksList($aDb, $aLangs)
|
|||||||
{
|
{
|
||||||
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
||||||
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity IN (".getEntity('bookmarks',1).")";
|
||||||
$sql.= " ORDER BY position";
|
$sql.= " ORDER BY position";
|
||||||
if ($resql = $db->query($sql) )
|
if ($resql = $db->query($sql) )
|
||||||
{
|
{
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $conf->global->BOOKMARKS_SHOW_IN_MENU && $obj = $db->fetch_object($resql))
|
while ($i < $conf->global->BOOKMARKS_SHOW_IN_MENU && $obj = $db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
//$ret.='<div class="menu_contenu">';
|
$ret.='<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1?' target="_blank"':'').' rel="'.dol_escape_htmltag($obj->url).'">';
|
||||||
$ret.='<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1?' target="_blank"':'').' rel="'.dol_escape_htmltag($obj->url).'">'.img_picto('','object_bookmark').' '.$obj->title.'</option>';
|
//$ret.='<span class="fa fa-print">aa</span>';
|
||||||
/*$ret.='<a class="vsmenu" title="'.$obj->title.'" href="'.$obj->url.'"'.($obj->target == 1?' target="_blank"':'').'>';
|
$ret.=img_picto('','object_bookmark').' ';
|
||||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $ret.=' '.img_object('','bookmark').' ';
|
$ret.=$obj->title;
|
||||||
$ret.= dol_trunc($obj->title, 20).'</a><br>';*/
|
$ret.='</option>';
|
||||||
//$ret.='</div>';
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,17 +94,17 @@ class AgendaEvents extends DolibarrApi
|
|||||||
* @param int $limit Limit for list
|
* @param int $limit Limit for list
|
||||||
* @param int $page Page number
|
* @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 $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
|
* @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;
|
global $db, $conf;
|
||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
// case of external user
|
// case of external user
|
||||||
$socid = 0;
|
$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
|
// If the internal user must only see his customers, force searching by him
|
||||||
$search_sale = 0;
|
$search_sale = 0;
|
||||||
@ -290,7 +290,7 @@ class AgendaEvents extends DolibarrApi
|
|||||||
function _validate($data)
|
function _validate($data)
|
||||||
{
|
{
|
||||||
$event = array();
|
$event = array();
|
||||||
foreach (Events::$FIELDS as $field) {
|
foreach (AgendaEvents::$FIELDS as $field) {
|
||||||
if (!isset($data[$field]))
|
if (!isset($data[$field]))
|
||||||
throw new RestException(400, "$field field missing");
|
throw new RestException(400, "$field field missing");
|
||||||
$event[$field] = $data[$field];
|
$event[$field] = $data[$field];
|
||||||
|
|||||||
@ -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 . '/compta/bank/class/account.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.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->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 . '/core/class/html.formaccounting.class.php';
|
||||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.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);
|
$form = new Form($db);
|
||||||
$formbank = new FormBank($db);
|
$formbank = new FormBank($db);
|
||||||
$formcompany = new FormCompany($db);
|
$formcompany = new FormCompany($db);
|
||||||
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
|
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
|
||||||
if (! empty($conf->accounting->enabled)) $formaccountancy2 = New FormAccounting($db);
|
|
||||||
|
|
||||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
$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 '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -525,7 +523,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||||
print '<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 '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,7 +968,7 @@ else
|
|||||||
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
|
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if (!empty($conf->accounting->enabled)) {
|
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 {
|
} else {
|
||||||
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
|
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
|
||||||
}
|
}
|
||||||
@ -981,13 +979,12 @@ else
|
|||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
|
||||||
print '<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 '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
|
if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
|
||||||
{
|
{
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|||||||
@ -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.'/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.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';
|
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||||
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
@ -180,7 +180,7 @@ if ($action == 'delete')
|
|||||||
llxHeader("",$langs->trans("VariousPayment"));
|
llxHeader("",$langs->trans("VariousPayment"));
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
|
if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
|
||||||
|
|
||||||
if ($id)
|
if ($id)
|
||||||
{
|
{
|
||||||
@ -271,7 +271,7 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
|
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else // For external software
|
else // For external software
|
||||||
|
|||||||
@ -33,7 +33,7 @@ top_httphead('text/html'); // TODO Use a json mime type
|
|||||||
|
|
||||||
global $user, $db, $langs, $conf;
|
global $user, $db, $langs, $conf;
|
||||||
|
|
||||||
$time = (int) GETPOST('time'); // Use the time parameter that is always increased by time_update, even if call is late
|
$time = (int) GETPOST('time','int'); // Use the time parameter that is always increased by time_update, even if call is late
|
||||||
//$time=dol_now();
|
//$time=dol_now();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5904,6 +5904,10 @@ class Form
|
|||||||
{
|
{
|
||||||
$ret.=$object->ref.'<br>'.$object->label;
|
$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);
|
else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -28,7 +32,7 @@
|
|||||||
class FormAccounting extends Form
|
class FormAccounting extends Form
|
||||||
{
|
{
|
||||||
|
|
||||||
private $options_cache = array();
|
private $options_cache = array();
|
||||||
|
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
@ -205,5 +209,222 @@ class FormAccounting extends Form
|
|||||||
|
|
||||||
print $out;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,7 +27,7 @@
|
|||||||
* Prepare array with list of admin tabs
|
* Prepare array with list of admin tabs
|
||||||
*
|
*
|
||||||
* @param AccountingAccount $object Object instance we show card
|
* @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)
|
function admin_accounting_prepare_head(AccountingAccount $object=null)
|
||||||
{
|
{
|
||||||
@ -41,11 +41,6 @@ function admin_accounting_prepare_head(AccountingAccount $object=null)
|
|||||||
$head[$h][2] = 'general';
|
$head[$h][2] = 'general';
|
||||||
$h ++;
|
$h ++;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/journal.php';
|
|
||||||
$head[$h][1] = $langs->trans("Journaux");
|
|
||||||
$head[$h][2] = 'journal';
|
|
||||||
$h ++;
|
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php';
|
$head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/export.php';
|
||||||
$head[$h][1] = $langs->trans("ExportOptions");
|
$head[$h][1] = $langs->trans("ExportOptions");
|
||||||
$head[$h][2] = 'export';
|
$head[$h][2] = 'export';
|
||||||
@ -91,35 +86,6 @@ function accounting_prepare_head(AccountingAccount $object)
|
|||||||
return $head;
|
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
|
* Return accounting account without zero on the right
|
||||||
*
|
*
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function dol_basename($pathfile)
|
|||||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
|
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
|
||||||
* @see dol_dir_list_indatabase
|
* @see dol_dir_list_indatabase
|
||||||
*/
|
*/
|
||||||
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false)
|
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0)
|
||||||
{
|
{
|
||||||
global $db, $hookmanager;
|
global $db, $hookmanager;
|
||||||
global $object;
|
global $object;
|
||||||
@ -483,6 +483,8 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile='', $newmask=0)
|
|||||||
|
|
||||||
dol_delete_file($tmpdestfile);
|
dol_delete_file($tmpdestfile);
|
||||||
|
|
||||||
|
// Create $newpathoftmpdestfile from $newpathofsrcfile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* 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) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2015 Benoit Bruchard <benoitb21@gmail.com>
|
* Copyright (C) 2015 Benoit Bruchard <benoitb21@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -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 . '/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.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("admin");
|
||||||
$langs->load("donations");
|
$langs->load("donations");
|
||||||
@ -199,7 +199,7 @@ else if ($action == 'setart885') {
|
|||||||
|
|
||||||
$dir = "../../core/modules/dons/";
|
$dir = "../../core/modules/dons/";
|
||||||
$form=new Form($db);
|
$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');
|
llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
|
||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
$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>';
|
print '<td>';
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -289,11 +289,11 @@ div.comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin-top: 10px;
|
margin-top: 20px;
|
||||||
font-size:16px;
|
font-size:16px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #4965B3;
|
color: rgb(100,60,20);
|
||||||
text-shadow: 1px 1px 1px #c0c0c0;
|
/* text-shadow: 1px 1px 1px #c0c0c0; */
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.bg1 {
|
tr.bg1 {
|
||||||
@ -345,15 +345,15 @@ ul {
|
|||||||
|
|
||||||
.button {
|
.button {
|
||||||
background: #fcfcfc;
|
background: #fcfcfc;
|
||||||
border: 1px solid #d0d0d0;
|
border: 1px solid #e0e0e0;
|
||||||
padding: 0.3em 0.7em;
|
padding: 0.3em 0.7em;
|
||||||
margin: 0 0.5em;
|
margin: 0 0.5em;
|
||||||
-moz-border-radius:0 5px 0 5px;
|
-moz-border-radius: 5px 5px 5px 5px;
|
||||||
-webkit-border-radius:0 5px 0 5px;
|
-webkit-border-radius: 5px 5px 5px 5px;
|
||||||
border-radius:0 5px 0 5px;
|
border-radius: 5px 5px 5px 5px;
|
||||||
-moz-box-shadow: 2px 2px 3px #CCC;
|
-moz-box-shadow: 2px 2px 3px #ddd;
|
||||||
-webkit-box-shadow: 2px 2px 3px #CCC;
|
-webkit-box-shadow: 2px 2px 3px #ddd;
|
||||||
box-shadow: 2px 2px 3px #CCC;
|
box-shadow: 2px 2px 3px #ddd;
|
||||||
}
|
}
|
||||||
a.button:hover {
|
a.button:hover {
|
||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
@ -368,3 +368,12 @@ a.button:hover {
|
|||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.valignmiddle {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.valigntextbottom {
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ if (! is_writable($conffile))
|
|||||||
|
|
||||||
if (! empty($force_install_message))
|
if (! empty($force_install_message))
|
||||||
{
|
{
|
||||||
print '<div><table><tr><td valign="middle"><img src="../theme/common/information.png" style="height:40px;"></td><td valign="middle">'.$langs->trans($force_install_message).'</td></tr></table>';
|
print '<div><br>'.$langs->trans($force_install_message).'</div>';
|
||||||
|
|
||||||
/*print '<script type="text/javascript">';
|
/*print '<script type="text/javascript">';
|
||||||
print ' jQuery(document).ready(function() {
|
print ' jQuery(document).ready(function() {
|
||||||
@ -109,8 +109,8 @@ if (! empty($force_install_message))
|
|||||||
<table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>">
|
<table class="nobordernopadding<?php if ($force_install_noedit) print ' hidewhennoedit'; ?>">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="label" align="center">
|
<td colspan="3" class="label">
|
||||||
<h3><?php echo $langs->trans("WebServer"); ?></h3>
|
<h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/globe.svg" width="20" alt="webserver"> <?php echo $langs->trans("WebServer"); ?></h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ if (! empty($force_install_message))
|
|||||||
$dolibarr_main_document_root = detect_dolibarr_main_document_root();
|
$dolibarr_main_document_root = detect_dolibarr_main_document_root();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="minwidth300"
|
class="minwidth300"
|
||||||
value="<?php print $dolibarr_main_document_root ?>"
|
value="<?php print $dolibarr_main_document_root ?>"
|
||||||
@ -156,7 +156,7 @@ if (! empty($force_install_message))
|
|||||||
$dolibarr_main_data_root = detect_dolibarr_main_data_root($dolibarr_main_document_root);
|
$dolibarr_main_data_root = detect_dolibarr_main_data_root($dolibarr_main_document_root);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="minwidth300"
|
class="minwidth300"
|
||||||
value="<?php print $dolibarr_main_data_root ?>"
|
value="<?php print $dolibarr_main_data_root ?>"
|
||||||
@ -210,7 +210,7 @@ if (! empty($force_install_message))
|
|||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tdtop label"><?php echo $langs->trans("ForceHttps"); ?></td>
|
<td class="tdtop label"><?php echo $langs->trans("ForceHttps"); ?></td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
name="main_force_https"
|
name="main_force_https"
|
||||||
<?php if (!empty($force_install_mainforcehttps)) {
|
<?php if (!empty($force_install_mainforcehttps)) {
|
||||||
@ -232,15 +232,15 @@ if (! empty($force_install_message))
|
|||||||
<!-- Dolibarr database -->
|
<!-- Dolibarr database -->
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="label" align="center"><br>
|
<td colspan="3" class="label"><br>
|
||||||
<h3><?php echo $langs->trans("DolibarrDatabase"); ?></h3>
|
<h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/database.svg" width="20" alt="webserver"> <?php echo $langs->trans("DolibarrDatabase"); ?></h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?>
|
<td class="label tdtop"><b> <?php echo $langs->trans("DatabaseName"); ?>
|
||||||
</b></td>
|
</b></td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text" id="db_name"
|
<input type="text" id="db_name"
|
||||||
name="db_name"
|
name="db_name"
|
||||||
value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
|
value="<?php echo (!empty($dolibarr_main_db_name)) ? $dolibarr_main_db_name : ($force_install_database ? $force_install_database : 'dolibarr'); ?>"
|
||||||
@ -371,9 +371,9 @@ if (! empty($force_install_message))
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td class="label" valign="top"><?php echo $langs->trans("DatabasePrefix"); ?>
|
<td class="label tdtop"><?php echo $langs->trans("DatabasePrefix"); ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text" id="db_prefix"
|
<input type="text" id="db_prefix"
|
||||||
name="db_prefix"
|
name="db_prefix"
|
||||||
value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
|
value="<?php echo(!empty($force_install_prefix) ? $force_install_prefix : (!empty($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : 'llx_')); ?>"
|
||||||
@ -386,9 +386,9 @@ if (! empty($force_install_message))
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td class="label" valign="top"><?php echo $langs->trans("CreateDatabase"); ?>
|
<td class="label tdtop"><?php echo $langs->trans("CreateDatabase"); ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="db_create_database"
|
id="db_create_database"
|
||||||
name="db_create_database"
|
name="db_create_database"
|
||||||
@ -405,9 +405,9 @@ if (! empty($force_install_message))
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b>
|
<td class="label tdtop"><b><?php echo $langs->trans("Login"); ?></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text" id="db_user"
|
<input type="text" id="db_user"
|
||||||
name="db_user"
|
name="db_user"
|
||||||
value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
|
value="<?php print (!empty($force_install_databaselogin)) ? $force_install_databaselogin : $dolibarr_main_db_user; ?>"
|
||||||
@ -420,9 +420,9 @@ if (! empty($force_install_message))
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
|
<td class="label tdtop"><b><?php echo $langs->trans("Password"); ?></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="password" id="db_pass" autocomplete="off"
|
<input type="password" id="db_pass" autocomplete="off"
|
||||||
name="db_pass"
|
name="db_pass"
|
||||||
value="<?php
|
value="<?php
|
||||||
@ -442,9 +442,9 @@ if (! empty($force_install_message))
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td class="label" valign="top"><?php echo $langs->trans("CreateUser"); ?>
|
<td class="label tdtop"><?php echo $langs->trans("CreateUser"); ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="db_create_user" name="db_create_user"
|
id="db_create_user" name="db_create_user"
|
||||||
<?php if (!empty($force_install_createuser)) {
|
<?php if (!empty($force_install_createuser)) {
|
||||||
@ -466,14 +466,14 @@ if (! empty($force_install_message))
|
|||||||
$force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
|
$force_install_databaserootpass = parse_database_pass($force_install_databaserootpass);
|
||||||
?>
|
?>
|
||||||
<tr class="hidesqlite hideroot">
|
<tr class="hidesqlite hideroot">
|
||||||
<td colspan="3" class="label" align="center"><br>
|
<td colspan="3" class="label"><br>
|
||||||
<h3><?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
|
<h3><img class="valigntextbottom" src="../theme/common/octicons/lib/svg/shield.svg" width="20" alt="webserver"> <?php echo $langs->trans("DatabaseSuperUserAccess"); ?></h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="hidesqlite hideroot">
|
<tr class="hidesqlite hideroot">
|
||||||
<td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b></td>
|
<td class="label tdtop"><b><?php echo $langs->trans("Login"); ?></b></td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="db_user_root"
|
id="db_user_root"
|
||||||
name="db_user_root"
|
name="db_user_root"
|
||||||
@ -496,9 +496,9 @@ if (! empty($force_install_message))
|
|||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="hidesqlite hideroot">
|
<tr class="hidesqlite hideroot">
|
||||||
<td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
|
<td class="label tdtop"><b><?php echo $langs->trans("Password"); ?></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="label" valign="top">
|
<td class="label tdtop">
|
||||||
<input type="password"
|
<input type="password"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
id="db_pass_root"
|
id="db_pass_root"
|
||||||
|
|||||||
@ -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 '';
|
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_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_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_user ADD COLUMN model_pdf varchar(255);
|
||||||
ALTER TABLE llx_usergroup 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 (__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 ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', '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 ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', '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 ('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('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 ref varchar(16);
|
||||||
ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL;
|
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);
|
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);
|
||||||
@ -18,6 +18,7 @@ ErrorFailToCreateFile=Failed to create file '<b>%s</b>'.
|
|||||||
ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
|
ErrorFailToRenameDir=Failed to rename directory '<b>%s</b>' into '<b>%s</b>'.
|
||||||
ErrorFailToCreateDir=Failed to create directory '<b>%s</b>'.
|
ErrorFailToCreateDir=Failed to create directory '<b>%s</b>'.
|
||||||
ErrorFailToDeleteDir=Failed to delete directory '<b>%s</b>'.
|
ErrorFailToDeleteDir=Failed to delete directory '<b>%s</b>'.
|
||||||
|
ErrorFailToMakeReplacementInto=Failed to make replacement into file '<b>%s</b>'.
|
||||||
ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as contact for this type.
|
ErrorThisContactIsAlreadyDefinedAsThisType=This contact is already defined as contact for this type.
|
||||||
ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only.
|
ErrorCashAccountAcceptsOnlyCashMoney=This bank account is a cash account, so it accepts payments of type cash only.
|
||||||
ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different.
|
ErrorFromToAccountsMustDiffers=Source and targets bank accounts must be different.
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# Dolibarr language file - Source file is en_US - loan
|
# Dolibarr language file - Source file is en_US - loan
|
||||||
ModuleBuilderDesc=This tools give you utilites to build or edit your own module.
|
ModuleBuilderDesc=This tools give you utilites to build or edit your own module.
|
||||||
|
EnterNameOfModuleDesc=Enter name of the module to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...)
|
||||||
ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): <strong>%s</strong>
|
ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): <strong>%s</strong>
|
||||||
ModuleBuilderDesc3=Generated/editable modules found: <strong>%s</strong> (they are detected as editable when the file <strong>%s</strong> exists in root of module directory).
|
ModuleBuilderDesc3=Generated/editable modules found: <strong>%s</strong> (they are detected as editable when the file <strong>%s</strong> exists in root of module directory).
|
||||||
NewModule=New module
|
NewModule=New module
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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>
|
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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/loan.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.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.'/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.'/projet/class/project.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formproject = new FormProjets($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");
|
$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
|
||||||
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
|
||||||
@ -337,19 +337,19 @@ if ($action == 'create')
|
|||||||
// Accountancy_account_capital
|
// Accountancy_account_capital
|
||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_account_insurance
|
// Accountancy_account_insurance
|
||||||
print '<tr><td>'.$langs->trans("LoanAccountancyInsuranceCode").'</td>';
|
print '<tr><td>'.$langs->trans("LoanAccountancyInsuranceCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_account_interest
|
// Accountancy_account_interest
|
||||||
print '<tr><td>'.$langs->trans("LoanAccountancyInterestCode").'</td>';
|
print '<tr><td>'.$langs->trans("LoanAccountancyInterestCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else // For external software
|
else // For external software
|
||||||
@ -541,7 +541,7 @@ if ($id > 0)
|
|||||||
{
|
{
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -566,7 +566,7 @@ if ($id > 0)
|
|||||||
{
|
{
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -591,7 +591,7 @@ if ($id > 0)
|
|||||||
{
|
{
|
||||||
if (! empty($conf->accounting->enabled))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
221
htdocs/modulebuilder/README.md
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
Dolibarr Module Template (aka My Module)
|
||||||
|
========================================
|
||||||
|
|
||||||
|
This is a full featured module template for Dolibarr.
|
||||||
|
It's a tool for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development.
|
||||||
|
|
||||||
|
If you're not a module developer you have no use for this.
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
[Module tutorial](http://wiki.dolibarr.org/index.php/Module_development)
|
||||||
|
|
||||||
|
[Dolibarr development](http://wiki.dolibarr.org/index.php/Developer_documentation)
|
||||||
|
|
||||||
|
### Translations
|
||||||
|
|
||||||
|
Dolibarr uses [Transifex](http://transifex.com) to manage it's translations.
|
||||||
|
|
||||||
|
This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory.
|
||||||
|
|
||||||
|
For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation).
|
||||||
|
|
||||||
|
There is a [Transifex project](http://transifex.com/projects/p/dolibarr-module-template) for this module.
|
||||||
|
|
||||||
|
Install
|
||||||
|
-------
|
||||||
|
|
||||||
|
### Manually
|
||||||
|
|
||||||
|
- Make sure Dolibarr (>= 3.3.x) is already installed and configured on your workstation or development server.
|
||||||
|
|
||||||
|
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
|
||||||
|
|
||||||
|
- Find the following lines:
|
||||||
|
```php
|
||||||
|
//$dolibarr_main_url_root_alt ...
|
||||||
|
//$dolibarr_main_document_root_alt ...
|
||||||
|
```
|
||||||
|
|
||||||
|
- Uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
|
||||||
|
|
||||||
|
For example :
|
||||||
|
|
||||||
|
- UNIX:
|
||||||
|
```php
|
||||||
|
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||||
|
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
|
||||||
|
$dolibarr_main_url_root_alt = '/custom';
|
||||||
|
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
|
||||||
|
```
|
||||||
|
|
||||||
|
- Windows:
|
||||||
|
```php
|
||||||
|
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||||
|
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
|
||||||
|
$dolibarr_main_url_root_alt = '/custom';
|
||||||
|
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about the ```conf.php``` file take a look at the conf.php.example file.
|
||||||
|
|
||||||
|
*Note that for Dolibarr versions before 3.5, the ```$dolibarr_main_url_root_alt``` has to be an absolute path*
|
||||||
|
|
||||||
|
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
|
||||||
|
|
||||||
|
*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)*
|
||||||
|
```sh
|
||||||
|
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
|
||||||
|
```
|
||||||
|
|
||||||
|
- Install [Composer](https://getcomposer.org) dependencies:
|
||||||
|
```sh
|
||||||
|
composer install
|
||||||
|
```
|
||||||
|
|
||||||
|
Follow the [final steps](#final_steps).
|
||||||
|
|
||||||
|
### Using [Composer](https://getcomposer.org)
|
||||||
|
Require this repository from Dolibarr's composer:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://github.com/dolibarr/dolibarr-module-template"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"dolibarr/mymodule": "dev-master"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Run
|
||||||
|
```sh
|
||||||
|
composer update
|
||||||
|
```
|
||||||
|
|
||||||
|
Follow the [final steps](#final_steps).
|
||||||
|
|
||||||
|
### <a name="final_steps"></a>Final steps
|
||||||
|
|
||||||
|
From your browser:
|
||||||
|
|
||||||
|
- Log into Dolibarr as a super-administrator
|
||||||
|
- Under "Setup" -> "Other setup", set ```MAIN_FEATURES_LEVEL``` to ```2```
|
||||||
|
- Go to "Setup" -> "Modules"
|
||||||
|
- The module is under one of the tabs
|
||||||
|
- You should now be able to enable the new module and start coding ;)
|
||||||
|
|
||||||
|
Provided tools
|
||||||
|
--------------
|
||||||
|
|
||||||
|
### Starting a new module
|
||||||
|
|
||||||
|
A [script](dev/newmodule.sh) allows you to rename most of the code to your own module name.
|
||||||
|
It requires ```find```, ```sed``` and ```rename``` commands on your system.
|
||||||
|
Just make sure you provide a CamelCase name.
|
||||||
|
```sh
|
||||||
|
./dev/newmodule.sh [NewName]
|
||||||
|
```
|
||||||
|
|
||||||
|
Some work still has to be done manually:
|
||||||
|
- Rename the directory holding the code
|
||||||
|
- Maybe rename some other bits (Search for 'my' in filenames and code)
|
||||||
|
- Update your module ID in the module descriptor
|
||||||
|
- Update your language files
|
||||||
|
- Keywords based on the module ID
|
||||||
|
- String referencing the template
|
||||||
|
- Remove the features you don't plan to use
|
||||||
|
- Fill the copyright notices at the top of each file
|
||||||
|
- Add your logo: see [images README](dev/img/README.md) for specifications
|
||||||
|
- Start a new GIT history
|
||||||
|
```
|
||||||
|
git checkout --orphan [new_branch_name]
|
||||||
|
```
|
||||||
|
- Build an awesome module ;)
|
||||||
|
|
||||||
|
### Composer scripts
|
||||||
|
|
||||||
|
Only the main commands are listed here.
|
||||||
|
See the [composer comments](composer-comments.md) or the [composer.json](composer.json) itself for more informations.
|
||||||
|
|
||||||
|
#### Check
|
||||||
|
|
||||||
|
Run a linter, a PHP compatibility version checker and checks coding style.
|
||||||
|
```sh
|
||||||
|
composer check
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Test
|
||||||
|
|
||||||
|
Run unit and functional tests.
|
||||||
|
```sh
|
||||||
|
composer test
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Doc
|
||||||
|
Build code and user documentation.
|
||||||
|
|
||||||
|
#### Release
|
||||||
|
|
||||||
|
Run the checks and tests then build a distribution ZIP.
|
||||||
|
```sh
|
||||||
|
composer release
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Git hooks
|
||||||
|
|
||||||
|
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
|
||||||
|
These are just wrappers calling composer scripts.
|
||||||
|
They ensure best practices are followed during module development.
|
||||||
|
|
||||||
|
Install:
|
||||||
|
```sh
|
||||||
|
composer git_hooks_install
|
||||||
|
```
|
||||||
|
|
||||||
|
Remove:
|
||||||
|
```sh
|
||||||
|
composer git_hooks_remove
|
||||||
|
```
|
||||||
|
|
||||||
|
## Publishing the module
|
||||||
|
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
|
||||||
|
Templates for required images and texts are [provided](dev/dolistore).
|
||||||
|
Check the dedicated [README](dev/dolistore/README.md) for more informations.
|
||||||
|
|
||||||
|
Contributions
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Feel free to contribute and report defects on our [issue tracker](http://github.com/Dolibarr/dolibarr-module-template/issues).
|
||||||
|
|
||||||
|
Licenses
|
||||||
|
--------
|
||||||
|
|
||||||
|
### Main code
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
GPLv3 or (at your option) any later version.
|
||||||
|
|
||||||
|
See [COPYING](COPYING) for more information.
|
||||||
|
|
||||||
|
### Other Licenses
|
||||||
|
|
||||||
|
#### [Parsedown](http://parsedown.org/)
|
||||||
|
|
||||||
|
Used to display this README in the module's about page.
|
||||||
|
Licensed under MIT.
|
||||||
|
|
||||||
|
#### [GNU Licenses logos](https://www.gnu.org/graphics/license-logos.html)
|
||||||
|
|
||||||
|
Public domain
|
||||||
|
|
||||||
|
#### Documentation
|
||||||
|
|
||||||
|
All texts and readmes.
|
||||||
|
|
||||||
|

|
||||||
@ -32,15 +32,15 @@ $langs->load("other");
|
|||||||
$action=GETPOST('action','alpha');
|
$action=GETPOST('action','alpha');
|
||||||
$confirm=GETPOST('confirm','alpha');
|
$confirm=GETPOST('confirm','alpha');
|
||||||
$module=GETPOST('module');
|
$module=GETPOST('module');
|
||||||
$tab=GETPOST('tab');
|
|
||||||
if (empty($module)) $module='initmodule';
|
if (empty($module)) $module='initmodule';
|
||||||
if (empty($tab)) $tab='description';
|
if (empty($tab)) $tab='description';
|
||||||
|
|
||||||
|
$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha'));
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed');
|
if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed');
|
||||||
|
|
||||||
$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha'));
|
|
||||||
|
|
||||||
// Dir for custom dirs
|
// Dir for custom dirs
|
||||||
$tmp=explode(',', $dolibarr_main_document_root_alt);
|
$tmp=explode(',', $dolibarr_main_document_root_alt);
|
||||||
@ -55,35 +55,59 @@ $FILEFLAG='modulebuilder.txt';
|
|||||||
|
|
||||||
if ($dircustom && $action == 'initmodule' && $modulename)
|
if ($dircustom && $action == 'initmodule' && $modulename)
|
||||||
{
|
{
|
||||||
$srcfile = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
|
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
|
||||||
$destfile = $dircustom.'/'.$modulename;
|
$destdir = $dircustom.'/'.$modulename;
|
||||||
$result = dolCopyDir($srcfile, $destfile, 0, 0);
|
|
||||||
|
$arrayreplacement=array(
|
||||||
|
'mymodule'=>strtolower($modulename),
|
||||||
|
'MyModule'=>$modulename
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = dolCopyDir($srcdir, $destdir, 0, 0);
|
||||||
//dol_mkdir($destfile);
|
//dol_mkdir($destfile);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($langs->trans("ErrorFailedToCopyDir"), null, 'errors');
|
$langs->load("errors");
|
||||||
|
setEventMessages($langs->trans("ErrorFailToCopyDir", $srcdir, $destdir), null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit PHP files
|
// Edit PHP files
|
||||||
$listofphpfilestoedit = dol_dir_list($destfile, 'files', 1, '\.php$', 'fullname', SORT_ASC, 0, true);
|
if (! $error)
|
||||||
foreach($listofphpfilestoedit as $phpfileval)
|
|
||||||
{
|
{
|
||||||
$arrayreplacement=array(
|
$listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.php$', '', 'fullname', SORT_ASC, 0, 1);
|
||||||
'mymodule'=>$modulename
|
foreach($listofphpfilestoedit as $phpfileval)
|
||||||
);
|
{
|
||||||
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
var_dump($phpfileval['fullname']);
|
||||||
var_dump($phpfileval);
|
|
||||||
var_dump($result);
|
$arrayreplacement=array(
|
||||||
|
'mymodule'=>strtolower($modulename),
|
||||||
|
'MyModule'=>$modulename,
|
||||||
|
'MYMODULE'=>strtoupper($modulename),
|
||||||
|
'My module'=>$modulename,
|
||||||
|
'htdocs/modulebuilder/template/'=>'',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||||
|
//var_dump($result);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
setEventMessages('ModuleInitialized', null);
|
setEventMessages('ModuleInitialized', null);
|
||||||
|
$module=$modulename;
|
||||||
|
$modulename = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -96,6 +120,7 @@ $text=$langs->trans("ModuleBuilder");
|
|||||||
print load_fiche_titre($text, '', 'title_setup');
|
print load_fiche_titre($text, '', 'title_setup');
|
||||||
|
|
||||||
$listofmodules=array();
|
$listofmodules=array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder
|
if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder
|
||||||
{
|
{
|
||||||
@ -161,7 +186,10 @@ if ($module == 'initmodule')
|
|||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="initmodule">';
|
print '<input type="hidden" name="action" value="initmodule">';
|
||||||
print '<input type="hidden" name="module" value="initmodule">';
|
print '<input type="hidden" name="module" value="initmodule">';
|
||||||
print '<input type="text" name="modulename" value="" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
|
|
||||||
|
print $langs->trans("EnterNameOfModuleDesc").'<br><br>';
|
||||||
|
|
||||||
|
print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
|
||||||
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
|
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,221 +1,6 @@
|
|||||||
Dolibarr Module Template (aka My Module)
|
# MYMODULE FOR DOLIBARR ERP CRM
|
||||||
========================================
|
|
||||||
|
|
||||||
This is a full featured module template for Dolibarr.
|
## Features
|
||||||
It's a tool for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development.
|
MyModuleDescription
|
||||||
|
|
||||||
If you're not a module developer you have no use for this.
|
Other modules are available on <a href="https://www.dolistore.com target="_new">Dolistore.com</a>.
|
||||||
|
|
||||||
Documentation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
[Module tutorial](http://wiki.dolibarr.org/index.php/Module_development)
|
|
||||||
|
|
||||||
[Dolibarr development](http://wiki.dolibarr.org/index.php/Developer_documentation)
|
|
||||||
|
|
||||||
### Translations
|
|
||||||
|
|
||||||
Dolibarr uses [Transifex](http://transifex.com) to manage it's translations.
|
|
||||||
|
|
||||||
This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory.
|
|
||||||
|
|
||||||
For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation).
|
|
||||||
|
|
||||||
There is a [Transifex project](http://transifex.com/projects/p/dolibarr-module-template) for this module.
|
|
||||||
|
|
||||||
Install
|
|
||||||
-------
|
|
||||||
|
|
||||||
### Manually
|
|
||||||
|
|
||||||
- Make sure Dolibarr (>= 3.3.x) is already installed and configured on your workstation or development server.
|
|
||||||
|
|
||||||
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
|
|
||||||
|
|
||||||
- Find the following lines:
|
|
||||||
```php
|
|
||||||
//$dolibarr_main_url_root_alt ...
|
|
||||||
//$dolibarr_main_document_root_alt ...
|
|
||||||
```
|
|
||||||
|
|
||||||
- Uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
|
|
||||||
|
|
||||||
For example :
|
|
||||||
|
|
||||||
- UNIX:
|
|
||||||
```php
|
|
||||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
|
||||||
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
|
|
||||||
$dolibarr_main_url_root_alt = '/custom';
|
|
||||||
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
|
|
||||||
```
|
|
||||||
|
|
||||||
- Windows:
|
|
||||||
```php
|
|
||||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
|
||||||
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
|
|
||||||
$dolibarr_main_url_root_alt = '/custom';
|
|
||||||
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information about the ```conf.php``` file take a look at the conf.php.example file.
|
|
||||||
|
|
||||||
*Note that for Dolibarr versions before 3.5, the ```$dolibarr_main_url_root_alt``` has to be an absolute path*
|
|
||||||
|
|
||||||
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
|
|
||||||
|
|
||||||
*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)*
|
|
||||||
```sh
|
|
||||||
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
|
|
||||||
```
|
|
||||||
|
|
||||||
- Install [Composer](https://getcomposer.org) dependencies:
|
|
||||||
```sh
|
|
||||||
composer install
|
|
||||||
```
|
|
||||||
|
|
||||||
Follow the [final steps](#final_steps).
|
|
||||||
|
|
||||||
### Using [Composer](https://getcomposer.org)
|
|
||||||
Require this repository from Dolibarr's composer:
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "vcs",
|
|
||||||
"url": "https://github.com/dolibarr/dolibarr-module-template"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"dolibarr/mymodule": "dev-master"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Run
|
|
||||||
```sh
|
|
||||||
composer update
|
|
||||||
```
|
|
||||||
|
|
||||||
Follow the [final steps](#final_steps).
|
|
||||||
|
|
||||||
### <a name="final_steps"></a>Final steps
|
|
||||||
|
|
||||||
From your browser:
|
|
||||||
|
|
||||||
- Log into Dolibarr as a super-administrator
|
|
||||||
- Under "Setup" -> "Other setup", set ```MAIN_FEATURES_LEVEL``` to ```2```
|
|
||||||
- Go to "Setup" -> "Modules"
|
|
||||||
- The module is under one of the tabs
|
|
||||||
- You should now be able to enable the new module and start coding ;)
|
|
||||||
|
|
||||||
Provided tools
|
|
||||||
--------------
|
|
||||||
|
|
||||||
### Starting a new module
|
|
||||||
|
|
||||||
A [script](dev/newmodule.sh) allows you to rename most of the code to your own module name.
|
|
||||||
It requires ```find```, ```sed``` and ```rename``` commands on your system.
|
|
||||||
Just make sure you provide a CamelCase name.
|
|
||||||
```sh
|
|
||||||
./dev/newmodule.sh [NewName]
|
|
||||||
```
|
|
||||||
|
|
||||||
Some work still has to be done manually:
|
|
||||||
- Rename the directory holding the code
|
|
||||||
- Maybe rename some other bits (Search for 'my' in filenames and code)
|
|
||||||
- Update your module ID in the module descriptor
|
|
||||||
- Update your language files
|
|
||||||
- Keywords based on the module ID
|
|
||||||
- String referencing the template
|
|
||||||
- Remove the features you don't plan to use
|
|
||||||
- Fill the copyright notices at the top of each file
|
|
||||||
- Add your logo: see [images README](dev/img/README.md) for specifications
|
|
||||||
- Start a new GIT history
|
|
||||||
```
|
|
||||||
git checkout --orphan [new_branch_name]
|
|
||||||
```
|
|
||||||
- Build an awesome module ;)
|
|
||||||
|
|
||||||
### Composer scripts
|
|
||||||
|
|
||||||
Only the main commands are listed here.
|
|
||||||
See the [composer comments](composer-comments.md) or the [composer.json](composer.json) itself for more informations.
|
|
||||||
|
|
||||||
#### Check
|
|
||||||
|
|
||||||
Run a linter, a PHP compatibility version checker and checks coding style.
|
|
||||||
```sh
|
|
||||||
composer check
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Test
|
|
||||||
|
|
||||||
Run unit and functional tests.
|
|
||||||
```sh
|
|
||||||
composer test
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Doc
|
|
||||||
Build code and user documentation.
|
|
||||||
|
|
||||||
#### Release
|
|
||||||
|
|
||||||
Run the checks and tests then build a distribution ZIP.
|
|
||||||
```sh
|
|
||||||
composer release
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Git hooks
|
|
||||||
|
|
||||||
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
|
|
||||||
These are just wrappers calling composer scripts.
|
|
||||||
They ensure best practices are followed during module development.
|
|
||||||
|
|
||||||
Install:
|
|
||||||
```sh
|
|
||||||
composer git_hooks_install
|
|
||||||
```
|
|
||||||
|
|
||||||
Remove:
|
|
||||||
```sh
|
|
||||||
composer git_hooks_remove
|
|
||||||
```
|
|
||||||
|
|
||||||
## Publishing the module
|
|
||||||
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
|
|
||||||
Templates for required images and texts are [provided](dev/dolistore).
|
|
||||||
Check the dedicated [README](dev/dolistore/README.md) for more informations.
|
|
||||||
|
|
||||||
Contributions
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Feel free to contribute and report defects on our [issue tracker](http://github.com/Dolibarr/dolibarr-module-template/issues).
|
|
||||||
|
|
||||||
Licenses
|
|
||||||
--------
|
|
||||||
|
|
||||||
### Main code
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
GPLv3 or (at your option) any later version.
|
|
||||||
|
|
||||||
See [COPYING](COPYING) for more information.
|
|
||||||
|
|
||||||
### Other Licenses
|
|
||||||
|
|
||||||
#### [Parsedown](http://parsedown.org/)
|
|
||||||
|
|
||||||
Used to display this README in the module's about page.
|
|
||||||
Licensed under MIT.
|
|
||||||
|
|
||||||
#### [GNU Licenses logos](https://www.gnu.org/graphics/license-logos.html)
|
|
||||||
|
|
||||||
Public domain
|
|
||||||
|
|
||||||
#### Documentation
|
|
||||||
|
|
||||||
All texts and readmes.
|
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file admin/about.php
|
* \file htdocs/modulebuilder/template/admin/about.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief About page of module MyModule.
|
* \brief About page of module MyModule.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file admin/setup.php
|
* \file htdocs/modulebuilder/template/admin/setup.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief Example module setup page.
|
* \brief Example module setup page.
|
||||||
*
|
*
|
||||||
@ -57,8 +57,8 @@ $page_name = "MyModuleSetup";
|
|||||||
llxHeader('', $langs->trans($page_name));
|
llxHeader('', $langs->trans($page_name));
|
||||||
|
|
||||||
// Subheader
|
// Subheader
|
||||||
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
|
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
|
||||||
. $langs->trans("BackToModuleList") . '</a>';
|
|
||||||
print load_fiche_titre($langs->trans($page_name), $linkback);
|
print load_fiche_titre($langs->trans($page_name), $linkback);
|
||||||
|
|
||||||
// Configuration header
|
// Configuration header
|
||||||
|
|||||||
@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
|
||||||
* 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 class/MyTrigger.php
|
|
||||||
* \ingroup mymodule
|
|
||||||
* \brief Compatibility class for triggers in Dolibarr < 3.7.
|
|
||||||
*
|
|
||||||
* Hack for compatibility with Dolibarr versions < 3.7.
|
|
||||||
* Remove this and extend DolibarrTriggers directly from interface_99_modMyModule_MyTrigger.class.php
|
|
||||||
* if you don't intend to support these versions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// We ignore the PSR1.Classes.ClassDeclaration.MultipleClasses rule.
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
$dolibarr_version = versiondolibarrarray();
|
|
||||||
if ($dolibarr_version[0] < 3 || ($dolibarr_version[0] == 3 && $dolibarr_version[1] < 7)) { // DOL_VERSION < 3.7
|
|
||||||
/**
|
|
||||||
* Class MyTrigger
|
|
||||||
*
|
|
||||||
* For Dolibarr < 3.7.
|
|
||||||
*/
|
|
||||||
abstract class MyTrigger
|
|
||||||
{
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/**
|
|
||||||
* Class MyTrigger
|
|
||||||
*
|
|
||||||
* For Dolibarr >= 3.7
|
|
||||||
*/
|
|
||||||
abstract class MyTrigger extends DolibarrTriggers
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file class/actions_mymodule.class.php
|
* \file htdocs/modulebuilder/template/class/actions_mymodule.class.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief Example hook overload.
|
* \brief Example hook overload.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,361 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
|
||||||
* 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 class/myclass.class.php
|
|
||||||
* \ingroup mymodule
|
|
||||||
* \brief Example CRUD (Create/Read/Update/Delete) class.
|
|
||||||
*
|
|
||||||
* Put detailed description here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Includes */
|
|
||||||
//require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
|
|
||||||
//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
|
||||||
//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Put your class' description here
|
|
||||||
*/
|
|
||||||
class MyClass // extends CommonObject
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var DoliDb Database handler */
|
|
||||||
private $db;
|
|
||||||
/** @var string Error code or message */
|
|
||||||
public $error;
|
|
||||||
/** @var array Several error codes or messages */
|
|
||||||
public $errors = array();
|
|
||||||
/** @var string Id to identify managed object */
|
|
||||||
//public $element='myelement';
|
|
||||||
/** @var string Name of table without prefix where object is stored */
|
|
||||||
//public $table_element='mytable';
|
|
||||||
/** @var int An example ID */
|
|
||||||
public $id;
|
|
||||||
/** @var mixed An example property */
|
|
||||||
public $prop1;
|
|
||||||
/** @var mixed An example property */
|
|
||||||
public $prop2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param DoliDb $db Database handler
|
|
||||||
*/
|
|
||||||
public function __construct($db)
|
|
||||||
{
|
|
||||||
$this->db = $db;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create object into database
|
|
||||||
*
|
|
||||||
* @param User $user User that create
|
|
||||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
|
||||||
* @return int <0 if KO, Id of created object if OK
|
|
||||||
*/
|
|
||||||
public function create($user, $notrigger = 0)
|
|
||||||
{
|
|
||||||
global $conf, $langs;
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
// Clean parameters
|
|
||||||
if (isset($this->prop1)) {
|
|
||||||
$this->prop1 = trim($this->prop1);
|
|
||||||
}
|
|
||||||
if (isset($this->prop2)) {
|
|
||||||
$this->prop2 = trim($this->prop2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check parameters
|
|
||||||
// Put here code to add control on parameters values
|
|
||||||
// Insert request
|
|
||||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "mytable(";
|
|
||||||
$sql.= " field1,";
|
|
||||||
$sql.= " field2";
|
|
||||||
|
|
||||||
$sql.= ") VALUES (";
|
|
||||||
$sql.= " '" . $this->prop1 . "',";
|
|
||||||
$sql.= " '" . $this->prop2 . "'";
|
|
||||||
|
|
||||||
$sql.= ")";
|
|
||||||
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if (! $resql) {
|
|
||||||
$error ++;
|
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "mytable");
|
|
||||||
|
|
||||||
if (! $notrigger) {
|
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
|
||||||
// want this action call a trigger.
|
|
||||||
//// Call triggers
|
|
||||||
//include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
|
|
||||||
//$interface=new Interfaces($this->db);
|
|
||||||
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
|
|
||||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
//// End call triggers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit or rollback
|
|
||||||
if ($error) {
|
|
||||||
foreach ($this->errors as $errmsg) {
|
|
||||||
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
|
|
||||||
$this->error.=($this->error ? ', ' . $errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
|
||||||
|
|
||||||
return -1 * $error;
|
|
||||||
} else {
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load object in memory from database
|
|
||||||
*
|
|
||||||
* @param int $id Id object
|
|
||||||
* @return int <0 if KO, >0 if OK
|
|
||||||
*/
|
|
||||||
public function fetch($id)
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
$sql = "SELECT";
|
|
||||||
$sql.= " t.rowid,";
|
|
||||||
$sql.= " t.field1,";
|
|
||||||
$sql.= " t.field2";
|
|
||||||
//...
|
|
||||||
$sql.= " FROM " . MAIN_DB_PREFIX . "mytable as t";
|
|
||||||
$sql.= " WHERE t.rowid = " . $id;
|
|
||||||
|
|
||||||
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
if ($this->db->num_rows($resql)) {
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
|
||||||
$this->prop1 = $obj->field1;
|
|
||||||
$this->prop2 = $obj->field2;
|
|
||||||
//...
|
|
||||||
}
|
|
||||||
$this->db->free($resql);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
|
||||||
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update object into database
|
|
||||||
*
|
|
||||||
* @param User $user User that modify
|
|
||||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
|
||||||
* @return int <0 if KO, >0 if OK
|
|
||||||
*/
|
|
||||||
public function update($user = 0, $notrigger = 0)
|
|
||||||
{
|
|
||||||
global $conf, $langs;
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
// Clean parameters
|
|
||||||
if (isset($this->prop1)) {
|
|
||||||
$this->prop1 = trim($this->prop1);
|
|
||||||
}
|
|
||||||
if (isset($this->prop2)) {
|
|
||||||
$this->prop2 = trim($this->prop2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check parameters
|
|
||||||
// Put here code to add control on parameters values
|
|
||||||
// Update request
|
|
||||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "mytable SET";
|
|
||||||
$sql.= " field1=" . (isset($this->field1) ? "'" . $this->db->escape($this->field1) . "'" : "null") . ",";
|
|
||||||
$sql.= " field2=" . (isset($this->field2) ? "'" . $this->db->escape($this->field2) . "'" : "null") . "";
|
|
||||||
|
|
||||||
$sql.= " WHERE rowid=" . $this->id;
|
|
||||||
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if (! $resql) {
|
|
||||||
$error ++;
|
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
if (! $notrigger) {
|
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
|
||||||
// want this action call a trigger.
|
|
||||||
//// Call triggers
|
|
||||||
//include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
|
|
||||||
//$interface=new Interfaces($this->db);
|
|
||||||
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
|
||||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
//// End call triggers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit or rollback
|
|
||||||
if ($error) {
|
|
||||||
foreach ($this->errors as $errmsg) {
|
|
||||||
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
|
|
||||||
$this->error.=($this->error ? ', ' . $errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
|
||||||
|
|
||||||
return -1 * $error;
|
|
||||||
} else {
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete object in database
|
|
||||||
*
|
|
||||||
* @param User $user User that delete
|
|
||||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
|
||||||
* @return int <0 if KO, >0 if OK
|
|
||||||
*/
|
|
||||||
public function delete($user, $notrigger = 0)
|
|
||||||
{
|
|
||||||
global $conf, $langs;
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
if (! $notrigger) {
|
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
|
||||||
// want this action call a trigger.
|
|
||||||
//// Call triggers
|
|
||||||
//include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
|
|
||||||
//$interface=new Interfaces($this->db);
|
|
||||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
|
||||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
//// End call triggers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "mytable";
|
|
||||||
$sql.= " WHERE rowid=" . $this->id;
|
|
||||||
|
|
||||||
dol_syslog(__METHOD__ . " sql=" . $sql);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if (! $resql) {
|
|
||||||
$error ++;
|
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit or rollback
|
|
||||||
if ($error) {
|
|
||||||
foreach ($this->errors as $errmsg) {
|
|
||||||
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
|
|
||||||
$this->error.=($this->error ? ', ' . $errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
|
||||||
|
|
||||||
return -1 * $error;
|
|
||||||
} else {
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load an object from its id and create a new one in database
|
|
||||||
*
|
|
||||||
* @param int $fromid Id of object to clone
|
|
||||||
* @return int New id of clone
|
|
||||||
*/
|
|
||||||
public function createFromClone($fromid)
|
|
||||||
{
|
|
||||||
global $user, $langs;
|
|
||||||
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
$object = new SkeletonClass($this->db);
|
|
||||||
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
// Load source object
|
|
||||||
$object->fetch($fromid);
|
|
||||||
$object->id = 0;
|
|
||||||
$object->statut = 0;
|
|
||||||
|
|
||||||
// Clear fields
|
|
||||||
// ...
|
|
||||||
// Create clone
|
|
||||||
$result = $object->create($user);
|
|
||||||
|
|
||||||
// Other options
|
|
||||||
if ($result < 0) {
|
|
||||||
$this->error = $object->error;
|
|
||||||
$error ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
// Do something
|
|
||||||
}
|
|
||||||
|
|
||||||
// End
|
|
||||||
if (! $error) {
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
return $object->id;
|
|
||||||
} else {
|
|
||||||
$this->db->rollback();
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise object with example values
|
|
||||||
* Id must be 0 if object instance is a specimen
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function initAsSpecimen()
|
|
||||||
{
|
|
||||||
$this->id = 0;
|
|
||||||
$this->prop1 = 'prop1';
|
|
||||||
$this->prop2 = 'prop2';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
607
htdocs/modulebuilder/template/class/myobject.class.php
Normal file
@ -0,0 +1,607 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
|
*
|
||||||
|
* 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/modulebuilder/template/class/myobject.class.php
|
||||||
|
* \ingroup mymodule othermodule1 othermodule2
|
||||||
|
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Put here all includes required by your class file
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
|
||||||
|
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
|
||||||
|
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MyModuleObject
|
||||||
|
*
|
||||||
|
* Put here description of your class.
|
||||||
|
*/
|
||||||
|
class MyModuleObject extends CommonObject
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string Id to identify managed object
|
||||||
|
*/
|
||||||
|
public $element = 'mymoduleobject';
|
||||||
|
/**
|
||||||
|
* @var string Name of table without prefix where object is stored
|
||||||
|
*/
|
||||||
|
public $table_element = 'mymoduleobject';
|
||||||
|
/**
|
||||||
|
* @var array Array with all fields and their property
|
||||||
|
*/
|
||||||
|
public $picto = 'generic';
|
||||||
|
/**
|
||||||
|
* @var array Array with all fields and their property
|
||||||
|
*/
|
||||||
|
public $fields;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed Sample property 1
|
||||||
|
*/
|
||||||
|
public $prop1;
|
||||||
|
/**
|
||||||
|
* @var mixed Sample property 2
|
||||||
|
*/
|
||||||
|
public $prop2;
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
|
|
||||||
|
public $table_element_line = 'mymoduleobjectdet';
|
||||||
|
public $class_element_line = 'MyModuleObjectline';
|
||||||
|
public $fk_element = 'fk_mymoduleobject';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var MyModuleObjectLine[] Lines
|
||||||
|
*/
|
||||||
|
public $lines = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDb $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct(DoliDB $db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create object into database
|
||||||
|
*
|
||||||
|
* @param User $user User that creates
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, Id of created object if OK
|
||||||
|
*/
|
||||||
|
public function create(User $user, $notrigger = false)
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
if (isset($this->prop1)) {
|
||||||
|
$this->prop1 = trim($this->prop1);
|
||||||
|
}
|
||||||
|
if (isset($this->prop2)) {
|
||||||
|
$this->prop2 = trim($this->prop2);
|
||||||
|
}
|
||||||
|
//...
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
// Put here code to add control on parameters values
|
||||||
|
|
||||||
|
// Insert request
|
||||||
|
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
|
||||||
|
$sql .= ' field1,';
|
||||||
|
$sql .= ' field2';
|
||||||
|
//...
|
||||||
|
$sql .= ') VALUES (';
|
||||||
|
$sql .= ' \'' . $this->prop1 . '\',';
|
||||||
|
$sql .= ' \'' . $this->prop2 . '\'';
|
||||||
|
//...
|
||||||
|
$sql .= ')';
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql) {
|
||||||
|
$error ++;
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||||
|
|
||||||
|
if (!$notrigger) {
|
||||||
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
|
// want this action to call a trigger.
|
||||||
|
|
||||||
|
//// Call triggers
|
||||||
|
//$result=$this->call_trigger('MYOBJECT_CREATE',$user);
|
||||||
|
//if ($result < 0) $error++;
|
||||||
|
//// End call triggers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit or rollback
|
||||||
|
if ($error) {
|
||||||
|
$this->db->rollback();
|
||||||
|
|
||||||
|
return - 1 * $error;
|
||||||
|
} else {
|
||||||
|
$this->db->commit();
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load object in memory from the database
|
||||||
|
*
|
||||||
|
* @param int $id Id object
|
||||||
|
* @param string $ref Ref
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
|
*/
|
||||||
|
public function fetch($id, $ref = null)
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$sql = 'SELECT';
|
||||||
|
$sql .= ' t.rowid,';
|
||||||
|
$sql .= ' t.field1,';
|
||||||
|
$sql .= ' t.field2';
|
||||||
|
//...
|
||||||
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("mymoduleobject", 1) . ")";
|
||||||
|
}
|
||||||
|
if (null !== $ref) {
|
||||||
|
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
||||||
|
} else {
|
||||||
|
$sql .= ' AND t.rowid = ' . $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$numrows = $this->db->num_rows($resql);
|
||||||
|
if ($numrows) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$this->id = $obj->rowid;
|
||||||
|
$this->prop1 = $obj->field1;
|
||||||
|
$this->prop2 = $obj->field2;
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve all extrafields for invoice
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
/*
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
$extrafields=new ExtraFields($this->db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||||
|
$this->fetch_optionals($this->id,$extralabels);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $this->fetch_lines();
|
||||||
|
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
if ($numrows) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
|
return - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load object in memory from the database
|
||||||
|
*
|
||||||
|
* @param string $sortorder Sort Order
|
||||||
|
* @param string $sortfield Sort field
|
||||||
|
* @param int $limit offset limit
|
||||||
|
* @param int $offset offset limit
|
||||||
|
* @param array $filter filter array
|
||||||
|
* @param string $filtermode filter mode (AND or OR)
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$sql = 'SELECT';
|
||||||
|
$sql .= ' t.rowid,';
|
||||||
|
$sql .= ' t.field1,';
|
||||||
|
$sql .= ' t.field2';
|
||||||
|
//...
|
||||||
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
||||||
|
|
||||||
|
// Manage filter
|
||||||
|
$sqlwhere = array();
|
||||||
|
if (count($filter) > 0) {
|
||||||
|
foreach ($filter as $key => $value) {
|
||||||
|
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("mymoduleobject", 1) . ")";
|
||||||
|
}
|
||||||
|
if (count($sqlwhere) > 0) {
|
||||||
|
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||||
|
}
|
||||||
|
if (!empty($sortfield)) {
|
||||||
|
$sql .= $this->db->order($sortfield,$sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($limit)) {
|
||||||
|
$sql .= ' ' . $this->db->plimit($limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
$line = new self($this->db);
|
||||||
|
|
||||||
|
$line->id = $obj->rowid;
|
||||||
|
$line->prop1 = $obj->field1;
|
||||||
|
$line->prop2 = $obj->field2;
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
return $num;
|
||||||
|
} else {
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
|
return - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update object into database
|
||||||
|
*
|
||||||
|
* @param User $user User that modifies
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
public function update(User $user, $notrigger = false)
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
if (isset($this->prop1)) {
|
||||||
|
$this->prop1 = trim($this->prop1);
|
||||||
|
}
|
||||||
|
if (isset($this->prop2)) {
|
||||||
|
$this->prop2 = trim($this->prop2);
|
||||||
|
}
|
||||||
|
//...
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
// Put here code to add a control on parameters values
|
||||||
|
|
||||||
|
// Update request
|
||||||
|
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
||||||
|
$sql .= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").",";
|
||||||
|
$sql .= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null")."";
|
||||||
|
//...
|
||||||
|
$sql .= ' WHERE rowid=' . $this->id;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql) {
|
||||||
|
$error ++;
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error && !$notrigger) {
|
||||||
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
|
// want this action calls a trigger.
|
||||||
|
|
||||||
|
//// Call triggers
|
||||||
|
//$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
|
||||||
|
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||||
|
//// End call triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit or rollback
|
||||||
|
if ($error) {
|
||||||
|
$this->db->rollback();
|
||||||
|
|
||||||
|
return - 1 * $error;
|
||||||
|
} else {
|
||||||
|
$this->db->commit();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete object in database
|
||||||
|
*
|
||||||
|
* @param User $user User that deletes
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
public function delete(User $user, $notrigger = false)
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
if (!$notrigger) {
|
||||||
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
|
// want this action calls a trigger.
|
||||||
|
|
||||||
|
//// Call triggers
|
||||||
|
//$result=$this->call_trigger('MYOBJECT_DELETE',$user);
|
||||||
|
//if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
|
||||||
|
//// End call triggers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If you need to delete child tables to, you can insert them here
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
|
||||||
|
$sql .= ' WHERE rowid=' . $this->id;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql) {
|
||||||
|
$error ++;
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit or rollback
|
||||||
|
if ($error) {
|
||||||
|
$this->db->rollback();
|
||||||
|
|
||||||
|
return - 1 * $error;
|
||||||
|
} else {
|
||||||
|
$this->db->commit();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an object from its id and create a new one in database
|
||||||
|
*
|
||||||
|
* @param int $fromid Id of object to clone
|
||||||
|
*
|
||||||
|
* @return int New id of clone
|
||||||
|
*/
|
||||||
|
public function createFromClone($fromid)
|
||||||
|
{
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
global $user;
|
||||||
|
$error = 0;
|
||||||
|
$object = new MyModuleObject($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__ . ' ' . implode(',', $this->errors), LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// End
|
||||||
|
if (!$error) {
|
||||||
|
$this->db->commit();
|
||||||
|
|
||||||
|
return $object->id;
|
||||||
|
} else {
|
||||||
|
$this->db->rollback();
|
||||||
|
|
||||||
|
return - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a link to the object card (with optionaly the picto)
|
||||||
|
*
|
||||||
|
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||||
|
* @param string $option On what the link point to
|
||||||
|
* @param int $notooltip 1=Disable tooltip
|
||||||
|
* @param int $maxlen Max length of visible user name
|
||||||
|
* @param string $morecss Add more css on link
|
||||||
|
* @return string String with URL
|
||||||
|
*/
|
||||||
|
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
|
||||||
|
{
|
||||||
|
global $db, $conf, $langs;
|
||||||
|
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||||
|
global $menumanager;
|
||||||
|
|
||||||
|
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
$companylink = '';
|
||||||
|
|
||||||
|
$label = '<u>' . $langs->trans("MyModule") . '</u>';
|
||||||
|
$label.= '<br>';
|
||||||
|
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
|
||||||
|
|
||||||
|
$url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id;
|
||||||
|
|
||||||
|
$linkclose='';
|
||||||
|
if (empty($notooltip))
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||||
|
{
|
||||||
|
$label=$langs->trans("ShowProject");
|
||||||
|
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||||
|
}
|
||||||
|
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
|
||||||
|
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||||
|
}
|
||||||
|
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
|
||||||
|
|
||||||
|
$linkstart = '<a href="'.$url.'"';
|
||||||
|
$linkstart.=$linkclose.'>';
|
||||||
|
$linkend='</a>';
|
||||||
|
|
||||||
|
if ($withpicto)
|
||||||
|
{
|
||||||
|
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||||
|
if ($withpicto != 2) $result.=' ';
|
||||||
|
}
|
||||||
|
$result.= $linkstart . $this->ref . $linkend;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le libelle du status d'un user (actif, inactif)
|
||||||
|
*
|
||||||
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
|
* @return string Label of status
|
||||||
|
*/
|
||||||
|
function getLibStatut($mode=0)
|
||||||
|
{
|
||||||
|
return $this->LibStatut($this->status,$mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the status
|
||||||
|
*
|
||||||
|
* @param int $status Id status
|
||||||
|
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
|
||||||
|
* @return string Label of status
|
||||||
|
*/
|
||||||
|
static function LibStatut($status,$mode=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
if ($mode == 0)
|
||||||
|
{
|
||||||
|
$prefix='';
|
||||||
|
if ($status == 1) return $langs->trans('Enabled');
|
||||||
|
if ($status == 0) return $langs->trans('Disabled');
|
||||||
|
}
|
||||||
|
if ($mode == 1)
|
||||||
|
{
|
||||||
|
if ($status == 1) return $langs->trans('Enabled');
|
||||||
|
if ($status == 0) return $langs->trans('Disabled');
|
||||||
|
}
|
||||||
|
if ($mode == 2)
|
||||||
|
{
|
||||||
|
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||||
|
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||||
|
}
|
||||||
|
if ($mode == 3)
|
||||||
|
{
|
||||||
|
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
|
||||||
|
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
|
||||||
|
}
|
||||||
|
if ($mode == 4)
|
||||||
|
{
|
||||||
|
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
|
||||||
|
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
|
||||||
|
}
|
||||||
|
if ($mode == 5)
|
||||||
|
{
|
||||||
|
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||||
|
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||||
|
}
|
||||||
|
if ($mode == 6)
|
||||||
|
{
|
||||||
|
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||||
|
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise object with example values
|
||||||
|
* Id must be 0 if object instance is a specimen
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function initAsSpecimen()
|
||||||
|
{
|
||||||
|
$this->id = 0;
|
||||||
|
$this->prop1 = 'prop1';
|
||||||
|
$this->prop2 = 'prop2';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MyModuleObjectLine
|
||||||
|
*/
|
||||||
|
class MyModuleObjectLine
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int ID
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
/**
|
||||||
|
* @var mixed Sample line property 1
|
||||||
|
*/
|
||||||
|
public $prop1;
|
||||||
|
/**
|
||||||
|
* @var mixed Sample line property 2
|
||||||
|
*/
|
||||||
|
public $prop2;
|
||||||
|
}
|
||||||
292
htdocs/modulebuilder/template/class/myobject_api_class.class.php
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
<?php
|
||||||
|
/* 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
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/modulebuilder/template/class/myobject_api_class.class.php
|
||||||
|
* \ingroup mymodule
|
||||||
|
* \brief File for API management of myobject.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API class for mymodule myobject
|
||||||
|
*
|
||||||
|
* @smart-auto-routing false
|
||||||
|
* @access protected
|
||||||
|
* @class DolibarrApiAccess {@requires user,external}
|
||||||
|
*/
|
||||||
|
class MyObjectApi extends DolibarrApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
|
*/
|
||||||
|
static $FIELDS = array(
|
||||||
|
'name'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var MyObject $myobject {@type MyObject}
|
||||||
|
*/
|
||||||
|
public $myobject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @url GET myobject/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
global $db, $conf;
|
||||||
|
$this->db = $db;
|
||||||
|
$this->myobject = new MyObject($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get properties of a myobject object
|
||||||
|
*
|
||||||
|
* Return an array with myobject informations
|
||||||
|
*
|
||||||
|
* @param int $id ID of myobject
|
||||||
|
* @return array|mixed data without useless information
|
||||||
|
*
|
||||||
|
* @url GET myobject/{id}
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
function get($id)
|
||||||
|
{
|
||||||
|
if(! DolibarrApiAccess::$user->rights->myobject->read) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->myobject->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'MyObject not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_cleanObjectDatas($this->myobject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List myobjects
|
||||||
|
*
|
||||||
|
* Get a list of myobjects
|
||||||
|
*
|
||||||
|
* @param int $mode Use this param to filter list
|
||||||
|
* @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.ref:like:'SO-%') and (t.date_creation:<:'20160101') or (t.import_key:=:'20160101')"
|
||||||
|
* @return array Array of myobject objects
|
||||||
|
*
|
||||||
|
* @url GET /myobjects/
|
||||||
|
*/
|
||||||
|
function index($mode, $sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
|
||||||
|
global $db, $conf;
|
||||||
|
|
||||||
|
$obj_ret = array();
|
||||||
|
|
||||||
|
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
||||||
|
|
||||||
|
// If the internal user must only see his customers, force searching by him
|
||||||
|
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
||||||
|
|
||||||
|
$sql = "SELECT s.rowid";
|
||||||
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."myobject as s";
|
||||||
|
|
||||||
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||||
|
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||||
|
|
||||||
|
// Example of use $mode
|
||||||
|
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
||||||
|
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
||||||
|
|
||||||
|
$sql.= ' AND s.entity IN ('.getEntity('myobject', 1).')';
|
||||||
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
||||||
|
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
||||||
|
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
// Insert sale filter
|
||||||
|
if ($search_sale > 0)
|
||||||
|
{
|
||||||
|
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
$myobject_static = new MyObject($db);
|
||||||
|
if($myobject_static->fetch($obj->rowid)) {
|
||||||
|
$obj_ret[] = parent::_cleanObjectDatas($myobject_static);
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new RestException(503, 'Error when retrieve myobject list');
|
||||||
|
}
|
||||||
|
if( ! count($obj_ret)) {
|
||||||
|
throw new RestException(404, 'No myobject found');
|
||||||
|
}
|
||||||
|
return $obj_ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create myobject object
|
||||||
|
*
|
||||||
|
* @param array $request_data Request datas
|
||||||
|
* @return int ID of myobject
|
||||||
|
*
|
||||||
|
* @url POST myobject/
|
||||||
|
*/
|
||||||
|
function post($request_data = NULL)
|
||||||
|
{
|
||||||
|
if(! DolibarrApiAccess::$user->rights->myobject->create) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
// Check mandatory fields
|
||||||
|
$result = $this->_validate($request_data);
|
||||||
|
|
||||||
|
foreach($request_data as $field => $value) {
|
||||||
|
$this->myobject->$field = $value;
|
||||||
|
}
|
||||||
|
if( ! $this->myobject->create(DolibarrApiAccess::$user)) {
|
||||||
|
throw new RestException(500);
|
||||||
|
}
|
||||||
|
return $this->myobject->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update myobject
|
||||||
|
*
|
||||||
|
* @param int $id Id of myobject to update
|
||||||
|
* @param array $request_data Datas
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @url PUT myobject/{id}
|
||||||
|
*/
|
||||||
|
function put($id, $request_data = NULL)
|
||||||
|
{
|
||||||
|
if(! DolibarrApiAccess::$user->rights->myobject->create) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->myobject->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'MyObject not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($request_data as $field => $value) {
|
||||||
|
$this->myobject->$field = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->myobject->update($id, DolibarrApiAccess::$user))
|
||||||
|
return $this->get ($id);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete myobject
|
||||||
|
*
|
||||||
|
* @param int $id MyObject ID
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @url DELETE myobject/{id}
|
||||||
|
*/
|
||||||
|
function delete($id)
|
||||||
|
{
|
||||||
|
if(! DolibarrApiAccess::$user->rights->myobject->supprimer) {
|
||||||
|
throw new RestException(401);
|
||||||
|
}
|
||||||
|
$result = $this->myobject->fetch($id);
|
||||||
|
if( ! $result ) {
|
||||||
|
throw new RestException(404, 'MyObject not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !$this->myobject->delete($id))
|
||||||
|
{
|
||||||
|
throw new RestException(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'success' => array(
|
||||||
|
'code' => 200,
|
||||||
|
'message' => 'MyObject deleted'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate fields before create or update object
|
||||||
|
*
|
||||||
|
* @param array $data Data to validate
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
function _validate($data)
|
||||||
|
{
|
||||||
|
$myobject = array();
|
||||||
|
foreach (MyObjectApi::$FIELDS as $field) {
|
||||||
|
if (!isset($data[$field]))
|
||||||
|
throw new RestException(400, "$field field missing");
|
||||||
|
$myobject[$field] = $data[$field];
|
||||||
|
}
|
||||||
|
return $myobject;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) <year> <name of author>
|
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
@ -13,309 +14,28 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup mymodule MyModule module
|
* \defgroup mymodule Module MyModule
|
||||||
* \brief MyModule module descriptor.
|
* \brief MyModule module descriptor.
|
||||||
*
|
*
|
||||||
* Put detailed description here.
|
* \file htdocs/mymodule/core/modules/modMyModule.class.php
|
||||||
|
* \ingroup mymodule
|
||||||
|
* \brief Description and activation file for module MyModule
|
||||||
*/
|
*/
|
||||||
|
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||||
|
|
||||||
/**
|
|
||||||
* \file core/modules/modMyModule.class.php
|
|
||||||
* \ingroup mymodule
|
|
||||||
* \brief Example module description and activation file.
|
|
||||||
*
|
|
||||||
* Put detailed description here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
|
|
||||||
|
|
||||||
// The class name should start with a lower case mod for Dolibarr to pick it up
|
// The class name should start with a lower case mod for Dolibarr to pick it up
|
||||||
// so we ignore the Squiz.Classes.ValidClassName.NotCamelCaps rule.
|
// so we ignore the Squiz.Classes.ValidClassName.NotCamelCaps rule.
|
||||||
// @codingStandardsIgnoreStart
|
// @codingStandardsIgnoreStart
|
||||||
/**
|
/**
|
||||||
* Description and activation class for module MyModule
|
* Description and activation class for module MyModule
|
||||||
*/
|
*/
|
||||||
class modMyModule extends DolibarrModules
|
class modMyModule extends DolibarrModules
|
||||||
{
|
{
|
||||||
/** @var DoliDB Database handler */
|
|
||||||
public $db;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int numero Module unique ID
|
|
||||||
* @see http://wiki.dolibarr.org/index.php/List_of_modules_id Available ranges
|
|
||||||
*/
|
|
||||||
public $numero = 500000;
|
|
||||||
|
|
||||||
/** @var string Text key to reference module (for permissions, menus, etc.) */
|
|
||||||
public $rights_class = 'mymodule';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Module family.
|
|
||||||
* Used to group modules in module setup page.
|
|
||||||
* Can be one of 'crm', 'financial', 'hr', 'projects', 'products', 'ecm', 'technic', 'other'
|
|
||||||
*/
|
|
||||||
public $family = 'other';
|
|
||||||
|
|
||||||
/** @var int Module position in the family */
|
|
||||||
public $module_position = 500;
|
|
||||||
|
|
||||||
/** @var array Provide a custom family and options */
|
|
||||||
public $familyinfo = array(
|
|
||||||
// 'myownfamily' => array(
|
|
||||||
// 'position' => '001',
|
|
||||||
// 'label' => 'MyOwnFamily'
|
|
||||||
// )
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var string Module name */
|
|
||||||
public $name = "My Module";
|
|
||||||
|
|
||||||
/** @var string Module short description */
|
|
||||||
public $description = "Description of module MyModule";
|
|
||||||
|
|
||||||
/** @var string Module long description */
|
|
||||||
public $descriptionlong = "A very long description. Can be a full HTML content";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Module editor name
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
public $editor_name = "My Company";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Module editor website
|
|
||||||
* @since 4.0
|
|
||||||
*/
|
|
||||||
public $editor_url = "http://www.example.com";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Module version string
|
|
||||||
* Special values to hide the module behind MAIN_FEATURES_LEVEL: development, experimental
|
|
||||||
* @see https://semver.org
|
|
||||||
*/
|
|
||||||
public $version = 'development';
|
|
||||||
|
|
||||||
/** @var string Key used in llx_const table to save module status enabled/disabled */
|
|
||||||
public $const_name = 'MAIN_MODULE_MYMODULE';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Module logo
|
|
||||||
* Should be named object_mymodule.png and store under mymodule/img
|
|
||||||
*/
|
|
||||||
public $picto = 'mymodule@mymodule';
|
|
||||||
|
|
||||||
/** @var array Define module parts */
|
|
||||||
public $module_parts = array(
|
|
||||||
/** @var bool Module ships triggers in mymodule/core/triggers */
|
|
||||||
'triggers' => true,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships login in mymodule/core/login
|
|
||||||
* @todo: example
|
|
||||||
*/
|
|
||||||
'login' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships substitution functions
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'substitutions' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships menu handlers
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'menus' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships theme in mymodule/theme
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'theme' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module shipped templates in mymodule/core/tpl overload core ones
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'tpl' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships barcode functions
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'barcode' => false,
|
|
||||||
/**
|
|
||||||
* @var bool Module ships models
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'models' => false,
|
|
||||||
/** @var string[] List of module shipped custom CSS relative file paths */
|
|
||||||
'css' => array(
|
|
||||||
'mymodule/css/mycss.css.php'
|
|
||||||
),
|
|
||||||
/** @var string[] List of module shipped custom JavaScript relative file paths */
|
|
||||||
'js' => array(
|
|
||||||
'mymodule/js/myjs.js.php'
|
|
||||||
),
|
|
||||||
/**
|
|
||||||
* @var string[] List of hook contexts managed by the module
|
|
||||||
* @ todo example
|
|
||||||
*/
|
|
||||||
'hooks' => array(),
|
|
||||||
/**
|
|
||||||
* @var array List of default directory names to force
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
'dir' => array(),
|
|
||||||
/**
|
|
||||||
* @var array List of workflow contexts managed by the module
|
|
||||||
*/
|
|
||||||
'workflow' => array(),
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var string Data directories to create when module is enabled */
|
|
||||||
public $dirs = array(
|
|
||||||
'/mymodule/temp'
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var array Configuration page declaration */
|
|
||||||
public $config_page_url = 'setup.php@mymodule';
|
|
||||||
|
|
||||||
/** @var bool Control module visibility */
|
|
||||||
public $hidden = false;
|
|
||||||
|
|
||||||
/** @var string[] List of class names of modules to enable when this one is enabled */
|
|
||||||
public $depends = array();
|
|
||||||
|
|
||||||
/** @var string[] List of class names of modules to disable when this one is disabled */
|
|
||||||
public $requiredby = array();
|
|
||||||
|
|
||||||
/** @var string List of class names of modules this module conflicts with */
|
|
||||||
public $conflictwith = array();
|
|
||||||
|
|
||||||
/** @var int[] Minimum PHP version required by this module */
|
|
||||||
public $phpmin = array(5, 3);
|
|
||||||
|
|
||||||
/** @var int[] Minimum Dolibarr version required by this module */
|
|
||||||
public $need_dolibarr_version = array(3, 2);
|
|
||||||
|
|
||||||
/** @var string[] List of language files */
|
|
||||||
public $langfiles = array('mymodule@mymodule');
|
|
||||||
|
|
||||||
/** @var array Indexed list of constants options */
|
|
||||||
public $const = array(
|
|
||||||
0 => array(
|
|
||||||
/** @var string Constant name */
|
|
||||||
'MYMODULE_MYNEWCONST1',
|
|
||||||
/**
|
|
||||||
* @var string Constant type
|
|
||||||
* @todo Are there other types than 'chaine'?
|
|
||||||
*/
|
|
||||||
'chaine',
|
|
||||||
/** @var string Constant initial value */
|
|
||||||
'myvalue',
|
|
||||||
/** @var string Constant description */
|
|
||||||
'This is a configuration constant',
|
|
||||||
/** @var bool Constant visibility */
|
|
||||||
true,
|
|
||||||
/**
|
|
||||||
* @var string Multi-company entities
|
|
||||||
* 'current' or 'allentities'
|
|
||||||
*/
|
|
||||||
'current',
|
|
||||||
/** @var bool Delete constant when module is disabled */
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string List of pages to add as tab in a specific view
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $tabs = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Dictionaries declared by the module
|
|
||||||
*@todo example
|
|
||||||
*/
|
|
||||||
public $dictionaries = array();
|
|
||||||
|
|
||||||
/** @var array Indexed list of boxes options */
|
|
||||||
public $boxes = array(
|
|
||||||
0 => array(
|
|
||||||
'file' => 'mybox@mymodule',
|
|
||||||
'note' => '',
|
|
||||||
'enabledbydefaulton' => 'Home'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of cronjobs options
|
|
||||||
* @todo: example
|
|
||||||
*/
|
|
||||||
public $cronjobs = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of permissions options
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $rights = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of menu options
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $menu = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export IDs
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_code = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export names
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_label = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export enabling conditions
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_enabled = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export required permissions
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_permission = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export fields
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_fields_array = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export entities
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_entities_array = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export SQL queries start
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_sql_start = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array Indexed list of export SQL queries end
|
|
||||||
* @todo example
|
|
||||||
*/
|
|
||||||
public $export_sql_end = array();
|
|
||||||
|
|
||||||
/** @var bool Module only enabled / disabled in main company when multi-company is in use */
|
|
||||||
public $core_enabled = false;
|
|
||||||
|
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
/**
|
/**
|
||||||
* Constructor. Define names, constants, directories, boxes, permissions
|
* Constructor. Define names, constants, directories, boxes, permissions
|
||||||
@ -324,61 +44,90 @@ class modMyModule extends DolibarrModules
|
|||||||
*/
|
*/
|
||||||
public function __construct($db)
|
public function __construct($db)
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
// DolibarrModules is abstract in Dolibarr < 3.8
|
$this->db = $db;
|
||||||
if (is_callable('parent::__construct')) {
|
|
||||||
parent::__construct($db);
|
|
||||||
} else {
|
|
||||||
global $db;
|
|
||||||
$this->db = $db;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Declare custom family with translated label
|
// Id for module (must be unique).
|
||||||
//$this->familyinfo = array(
|
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
|
||||||
// 'myownfamily' => array(
|
$this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
|
||||||
// 'position' => '001',
|
// Key text used to identify module (for permissions, menus, etc...)
|
||||||
// 'label' => $langs->trans("MyOwnFamily")
|
$this->rights_class = 'mymodule';
|
||||||
// )
|
|
||||||
//);
|
|
||||||
|
|
||||||
// Lazy automatic module naming from class names
|
// Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other'
|
||||||
//$this->name = preg_replace('/^mod/i', '', get_class($this));
|
// It is used to group modules by family in module setup page
|
||||||
|
$this->family = "other";
|
||||||
|
// Module position in the family
|
||||||
|
$this->module_position = 500;
|
||||||
|
// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
|
||||||
|
//$this->familyinfo = array('myownfamily' => array('position' => '001', 'label' => $langs->trans("MyOwnFamily")));
|
||||||
|
|
||||||
// Lazy automatic constant naming from module name
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
//$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
|
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||||
|
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
|
$this->description = "MyModuleDescription";
|
||||||
|
$this->descriptionlong = "MyModuleDescription (Long)";
|
||||||
|
$this->editor_name = 'Editor name';
|
||||||
|
$this->editor_url = 'https://www.example.com';
|
||||||
|
|
||||||
// Examples for complex types
|
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
|
||||||
|
$this->version = '1.0';
|
||||||
|
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||||
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||||
|
// Name of image file used for this module.
|
||||||
|
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
|
||||||
|
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
|
||||||
|
$this->picto='generic';
|
||||||
|
|
||||||
|
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
|
||||||
|
// for default path (eg: /mymodule/core/xxxxx) (0=disable, 1=enable)
|
||||||
|
// for specific path of parts (eg: /mymodule/core/modules/barcode)
|
||||||
|
// for specific css file (eg: /mymodule/css/mymodule.css.php)
|
||||||
//$this->module_parts = array(
|
//$this->module_parts = array(
|
||||||
// Set here all hooks context managed by module
|
// 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
|
||||||
// 'hooks' => array('hookcontext1','hookcontext2'),
|
// 'login' => 0, // Set this to 1 if module has its own login method directory (core/login)
|
||||||
// To force the default directories names
|
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)
|
||||||
// 'dir' => array('output' => 'othermodulename'),
|
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
|
||||||
// Set here all workflow context managed by module
|
// 'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
|
||||||
// Don't forget to depend on modWorkflow!
|
// 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
|
||||||
// The description translation key will be descWORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2
|
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
|
||||||
// You will be able to check if it is enabled with the $conf->global->WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2 constant
|
// 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
|
||||||
// Implementation is up to you and is usually done in a trigger.
|
// 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file
|
||||||
// 'workflow' => array(
|
// 'js' => array('/mymodule/js/mymodule.js'), // Set this to relative path of js file if module must load a js on all pages
|
||||||
// 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' => array(
|
// 'hooks' => array('hookcontext1','hookcontext2',...) // Set here all hooks context managed by module. You can also set hook context 'all'
|
||||||
// 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
|
// 'dir' => array('output' => 'othermodulename'), // To force the default directories names
|
||||||
// 'picto' => 'yourpicto@mymodule',
|
// 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module
|
||||||
// 'warning' => 'WarningTextTranslationKey',
|
// );
|
||||||
// ),
|
$this->module_parts = array();
|
||||||
// ),
|
|
||||||
//);
|
|
||||||
|
|
||||||
|
// Data directories to create when module is enabled.
|
||||||
|
// Example: this->dirs = array("/mymodule/temp");
|
||||||
|
$this->dirs = array();
|
||||||
|
|
||||||
|
// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
|
||||||
|
$this->config_page_url = array("setup.php@mymodule");
|
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
$this->hidden = false; // A condition to hide module
|
||||||
|
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
|
||||||
|
$this->requiredby = array(); // List of module ids to disable if this one is disabled
|
||||||
|
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
|
||||||
|
$this->phpmin = array(5,0); // Minimum version of PHP required by module
|
||||||
|
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
|
||||||
|
$this->langfiles = array("mymodule@mymodule");
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
|
||||||
|
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
|
||||||
|
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
|
||||||
|
// );
|
||||||
|
$this->const = array();
|
||||||
|
|
||||||
// Array to add new pages in new tabs
|
// Array to add new pages in new tabs
|
||||||
// Example:
|
// Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1
|
||||||
//$this->tabs = array(
|
// 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
|
||||||
// // To add a new tab identified by code tabname1
|
// 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
|
||||||
// 'objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__',
|
// where objecttype can be
|
||||||
// // To add another new tab identified by code tabname2
|
|
||||||
// 'objecttype:+tabname2:Title2:langfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__',
|
|
||||||
// // To remove an existing tab identified by code tabname
|
|
||||||
// 'objecttype:-tabname'
|
|
||||||
//);
|
|
||||||
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
|
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
|
||||||
// 'contact' to add a tab in contact view
|
// 'contact' to add a tab in contact view
|
||||||
// 'contract' to add a tab in contract view
|
// 'contract' to add a tab in contract view
|
||||||
@ -398,317 +147,142 @@ class modMyModule extends DolibarrModules
|
|||||||
// 'stock' to add a tab in stock view
|
// 'stock' to add a tab in stock view
|
||||||
// 'thirdparty' to add a tab in third party view
|
// 'thirdparty' to add a tab in third party view
|
||||||
// 'user' to add a tab in user view
|
// 'user' to add a tab in user view
|
||||||
|
$this->tabs = array();
|
||||||
|
|
||||||
// Dictionaries
|
if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled))
|
||||||
if (! isset($conf->mymodule->enabled)) {
|
{
|
||||||
$conf->mymodule=new stdClass();
|
$conf->mymodule=new stdClass();
|
||||||
$conf->mymodule->enabled = 0;
|
$conf->mymodule->enabled=0;
|
||||||
}
|
}
|
||||||
//$this->dictionaries = array();
|
|
||||||
/* Example:
|
// Dictionaries
|
||||||
$this->dictionaries=array(
|
$this->dictionaries=array();
|
||||||
'langs'=>'mymodule@mymodule',
|
/* Example:
|
||||||
// List of tables we want to see into dictonary editor
|
$this->dictionaries=array(
|
||||||
'tabname'=>array(
|
'langs'=>'mylangfile@mymodule',
|
||||||
MAIN_DB_PREFIX."table1",
|
'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor
|
||||||
MAIN_DB_PREFIX."table2",
|
'tablib'=>array("Table1","Table2","Table3"), // Label of tables
|
||||||
MAIN_DB_PREFIX."table3"
|
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields
|
||||||
),
|
'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order
|
||||||
// Label of tables
|
'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary)
|
||||||
'tablib'=>array("Table1","Table2","Table3"),
|
'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record)
|
||||||
// Query to select fields
|
'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert)
|
||||||
'tabsql'=>array(
|
'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid')
|
||||||
'SELECT f.rowid as rowid, f.code, f.label, f.active'
|
'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) // Condition to show each dictionary
|
||||||
. ' FROM ' . MAIN_DB_PREFIX . 'table1 as f',
|
);
|
||||||
'SELECT f.rowid as rowid, f.code, f.label, f.active'
|
*/
|
||||||
. ' FROM ' . MAIN_DB_PREFIX . 'table2 as f',
|
|
||||||
'SELECT f.rowid as rowid, f.code, f.label, f.active'
|
// Boxes
|
||||||
. ' FROM ' . MAIN_DB_PREFIX . 'table3 as f'
|
// Add here list of php file(s) stored in core/boxes that contains class to show a box.
|
||||||
),
|
$this->boxes = array(); // List of boxes
|
||||||
// Sort order
|
// Example:
|
||||||
'tabsqlsort'=>array("label ASC","label ASC","label ASC"),
|
//$this->boxes=array(
|
||||||
// List of fields (result of select to show dictionary)
|
// 0=>array('file'=>'myboxa.php@mymodule','note'=>'','enabledbydefaulton'=>'Home'),
|
||||||
'tabfield'=>array("code,label","code,label","code,label"),
|
// 1=>array('file'=>'myboxb.php@mymodule','note'=>''),
|
||||||
// List of fields (list of fields to edit a record)
|
// 2=>array('file'=>'myboxc.php@mymodule','note'=>'')
|
||||||
'tabfieldvalue'=>array("code,label","code,label","code,label"),
|
//);
|
||||||
// List of fields (list of fields for insert)
|
|
||||||
'tabfieldinsert'=>array("code,label","code,label","code,label"),
|
|
||||||
// Name of columns with primary key (try to always name it 'rowid')
|
|
||||||
'tabrowid'=>array("rowid","rowid","rowid"),
|
|
||||||
// Condition to show each dictionary
|
|
||||||
'tabcond'=>array(
|
|
||||||
$conf->mymodule->enabled,
|
|
||||||
$conf->mymodule->enabled,
|
|
||||||
$conf->mymodule->enabled
|
|
||||||
)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Cronjobs
|
// Cronjobs
|
||||||
// List of cron jobs entries to add
|
$this->cronjobs = array(); // List of cron jobs entries to add
|
||||||
//$this->cronjobs = array();
|
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true),
|
||||||
// Example:
|
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'test'=>true)
|
||||||
// $this->cronjobs = array(
|
// );
|
||||||
// 0 => array(
|
|
||||||
// 'label' => 'My label',
|
|
||||||
// 'jobtype' => 'method',
|
|
||||||
// 'class' => '/dir/class/file.class.php',
|
|
||||||
// 'objectname' => 'MyClass',
|
|
||||||
// 'method' => 'myMethod',
|
|
||||||
// 'parameters' => '',
|
|
||||||
// 'comment' => 'Comment',
|
|
||||||
// 'frequency' => 2,
|
|
||||||
// 'unitfrequency' => 3600,
|
|
||||||
// 'test' => true
|
|
||||||
// ),
|
|
||||||
// 1 => array(
|
|
||||||
// 'label' => 'My label',
|
|
||||||
// 'jobtype' => 'command',
|
|
||||||
// 'command' => '',
|
|
||||||
// 'parameters' => '',
|
|
||||||
// 'comment' => 'Comment',
|
|
||||||
// 'frequency' => 1,
|
|
||||||
// 'unitfrequency' => 3600 * 24,
|
|
||||||
// 'test' => true
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
//$r = 0;
|
$this->rights = array(); // Permission array used by this module
|
||||||
// Add here list of permission defined by
|
$r=0;
|
||||||
// an id, a label, a boolean and two constant strings.
|
|
||||||
// Example:
|
|
||||||
//// Permission id (must not be already used)
|
|
||||||
//$this->rights[$r][0] = 2000;
|
|
||||||
//// Permission label
|
|
||||||
//$this->rights[$r][1] = 'Permision label';
|
|
||||||
//// Permission by default for new user (0/1)
|
|
||||||
//$this->rights[$r][3] = 1;
|
|
||||||
//// In php code, permission will be checked by test
|
|
||||||
//// if ($user->rights->permkey->level1->level2)
|
|
||||||
//$this->rights[$r][4] = 'level1';
|
|
||||||
//// In php code, permission will be checked by test
|
|
||||||
//// if ($user->rights->permkey->level1->level2)
|
|
||||||
//$this->rights[$r][5] = 'level2';
|
|
||||||
//$r++;
|
|
||||||
// Main menu entries
|
|
||||||
|
|
||||||
// Menu entries
|
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
|
||||||
|
// Example:
|
||||||
|
// $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
|
||||||
|
// $this->rights[$r][1] = 'Permision label'; // Permission label
|
||||||
|
// $this->rights[$r][3] = 1; // Permission by default for new user (0/1)
|
||||||
|
// $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
|
// $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
|
||||||
|
// $r++;
|
||||||
|
|
||||||
|
// Main menu entries
|
||||||
|
$this->menu = array(); // List of menus to add
|
||||||
|
$r=0;
|
||||||
|
|
||||||
|
// Add here entries to declare new menus
|
||||||
|
//
|
||||||
// Example to declare a new Top Menu entry and its Left menu entry:
|
// Example to declare a new Top Menu entry and its Left menu entry:
|
||||||
//$this->menu[]=array(
|
// $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
// // Put 0 if this is a top menu
|
// 'type'=>'top', // This is a Top menu entry
|
||||||
// 'fk_menu'=>0,
|
// 'titre'=>'MyModule top menu',
|
||||||
// // This is a Top menu entry
|
// 'mainmenu'=>'mymodule',
|
||||||
// 'type'=>'top',
|
// 'leftmenu'=>'mymodule',
|
||||||
// Menu's title. FIXME: use a translation key
|
// 'url'=>'/mymodule/pagetop.php',
|
||||||
// 'titre'=>'MyModule top menu',
|
// 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
// This menu's mainmenu ID
|
// 'position'=>100,
|
||||||
// 'mainmenu'=>'mymodule',
|
// 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
||||||
// This menu's leftmenu ID
|
// 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
// 'leftmenu'=>'mymodule',
|
// 'target'=>'',
|
||||||
// 'url'=>'/mymodule/pagetop.php',
|
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
// // Lang file to use (without .lang) by module.
|
// $r++;
|
||||||
// // File must be in langs/code_CODE/ directory.
|
|
||||||
// 'langs'=>'mylangfile',
|
|
||||||
// 'position'=>100,
|
|
||||||
// // Define condition to show or hide menu entry.
|
|
||||||
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
|
||||||
// 'enabled'=>'$conf->mymodule->enabled',
|
|
||||||
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
|
|
||||||
// // if you want your menu with a permission rules
|
|
||||||
// 'perms'=>'1',
|
|
||||||
// 'target'=>'',
|
|
||||||
// // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
// 'user'=>2
|
|
||||||
//);
|
|
||||||
//$this->menu[]=array(
|
|
||||||
// // Use r=value where r is index key used for the parent menu entry
|
|
||||||
// // (higher parent must be a top menu entry)
|
|
||||||
// 'fk_menu'=>'r=0',
|
|
||||||
// // This is a Left menu entry
|
|
||||||
// 'type'=>'left',
|
|
||||||
// Menu's title. FIXME: use a translation key
|
|
||||||
// 'titre'=>'MyModule left menu',
|
|
||||||
// This menu's mainmenu ID
|
|
||||||
// 'mainmenu'=>'mymodule',
|
|
||||||
// This menu's leftmenu ID
|
|
||||||
// 'leftmenu'=>'mymodule',
|
|
||||||
// 'url'=>'/mymodule/pagelevel1.php',
|
|
||||||
// // Lang file to use (without .lang) by module.
|
|
||||||
// // File must be in langs/code_CODE/ directory.
|
|
||||||
// 'langs'=>'mylangfile',
|
|
||||||
// 'position'=>100,
|
|
||||||
// // Define condition to show or hide menu entry.
|
|
||||||
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
|
||||||
// 'enabled'=>'$conf->mymodule->enabled',
|
|
||||||
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
|
|
||||||
// // if you want your menu with a permission rules
|
|
||||||
// 'perms'=>'1',
|
|
||||||
// 'target'=>'',
|
|
||||||
// // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
// 'user'=>2
|
|
||||||
//);
|
|
||||||
//
|
//
|
||||||
// Example to declare a Left Menu entry into an existing Top menu entry:
|
// Example to declare a Left Menu entry into an existing Top menu entry:
|
||||||
//$this->menu[]=array(
|
// $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
// // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
|
// 'type'=>'left', // This is a Left menu entry
|
||||||
// 'fk_menu'=>'fk_mainmenu=mainmenucode',
|
// 'titre'=>'MyModule left menu',
|
||||||
// // This is a Left menu entry
|
// 'mainmenu'=>'xxx',
|
||||||
// 'type'=>'left',
|
// 'leftmenu'=>'mymodule',
|
||||||
// Menu's title. FIXME: use a translation key
|
// 'url'=>'/mymodule/pagelevel2.php',
|
||||||
// 'titre'=>'MyModule left menu',
|
// 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
// This menu's mainmenu ID
|
// 'position'=>100,
|
||||||
// 'mainmenu'=>'mainmenucode',
|
// 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
// This menu's leftmenu ID
|
// 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
// 'leftmenu'=>'mymodule',
|
// 'target'=>'',
|
||||||
// 'url'=>'/mymodule/pagelevel2.php',
|
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
// // Lang file to use (without .lang) by module.
|
// $r++;
|
||||||
// // File must be in langs/code_CODE/ directory.
|
|
||||||
// 'langs'=>'mylangfile',
|
|
||||||
// 'position'=>100,
|
|
||||||
// // Define condition to show or hide menu entry.
|
|
||||||
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
|
|
||||||
// // Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
|
||||||
// 'enabled'=>'$conf->mymodule->enabled',
|
|
||||||
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
|
|
||||||
// // if you want your menu with a permission rules
|
|
||||||
// 'perms'=>'1',
|
|
||||||
// 'target'=>'',
|
|
||||||
// // 0=Menu for internal users, 1=external users, 2=both
|
|
||||||
// 'user'=>2
|
|
||||||
//);
|
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
//$r = 0;
|
$r=1;
|
||||||
|
|
||||||
// Example:
|
// Example:
|
||||||
//$this->export_code[$r]=$this->rights_class.'_'.$r;
|
// $this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||||
//// Translation key (used only if key ExportDataset_xxx_z not found)
|
// $this->export_label[$r]='MyModule'; // Translation key (used only if key ExportDataset_xxx_z not found)
|
||||||
//$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
|
// $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.
|
||||||
//// Condition to show export in list (ie: '$user->id==3').
|
// $this->export_icon[$r]='generic:MyModule'; // Put here code of icon then string for translation key of module name
|
||||||
//// Set to 1 to always show when module is enabled.
|
// $this->export_permission[$r]=array(array("mymodule","level1","level2"));
|
||||||
//$this->export_enabled[$r]='1';
|
// $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef');
|
||||||
//$this->export_permission[$r]=array(array("facture","facture","export"));
|
// $this->export_TypeFields_array[$r]=array('t.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text');
|
||||||
//$this->export_fields_array[$r]=array(
|
// $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product');
|
||||||
// 's.rowid'=>"IdCompany",
|
// $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
|
||||||
// 's.nom'=>'CompanyName',
|
// $this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||||
// 's.address'=>'Address',
|
// $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
|
||||||
// 's.cp'=>'Zip',
|
// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
|
||||||
// 's.ville'=>'Town',
|
// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
|
||||||
// 's.fk_pays'=>'Country',
|
// $this->export_sql_order[$r] .=' ORDER BY s.nom';
|
||||||
// 's.tel'=>'Phone',
|
// $r++;
|
||||||
// 's.siren'=>'ProfId1',
|
|
||||||
// 's.siret'=>'ProfId2',
|
|
||||||
// 's.ape'=>'ProfId3',
|
|
||||||
// 's.idprof4'=>'ProfId4',
|
|
||||||
// 's.code_compta'=>'CustomerAccountancyCode',
|
|
||||||
// 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
|
|
||||||
// 'f.rowid'=>"InvoiceId",
|
|
||||||
// 'f.facnumber'=>"InvoiceRef",
|
|
||||||
// 'f.datec'=>"InvoiceDateCreation",
|
|
||||||
// 'f.datef'=>"DateInvoice",
|
|
||||||
// 'f.total'=>"TotalHT",
|
|
||||||
// 'f.total_ttc'=>"TotalTTC",
|
|
||||||
// 'f.tva'=>"TotalVAT",
|
|
||||||
// 'f.paye'=>"InvoicePaid",
|
|
||||||
// 'f.fk_statut'=>'InvoiceStatus',
|
|
||||||
// 'f.note'=>"InvoiceNote",
|
|
||||||
// 'fd.rowid'=>'LineId',
|
|
||||||
// 'fd.description'=>"LineDescription",
|
|
||||||
// 'fd.price'=>"LineUnitPrice",
|
|
||||||
// 'fd.tva_tx'=>"LineVATRate",
|
|
||||||
// 'fd.qty'=>"LineQty",
|
|
||||||
// 'fd.total_ht'=>"LineTotalHT",
|
|
||||||
// 'fd.total_tva'=>"LineTotalTVA",
|
|
||||||
// 'fd.total_ttc'=>"LineTotalTTC",
|
|
||||||
// 'fd.date_start'=>"DateStart",
|
|
||||||
// 'fd.date_end'=>"DateEnd",
|
|
||||||
// 'fd.fk_product'=>'ProductId',
|
|
||||||
// 'p.ref'=>'ProductRef'
|
|
||||||
//);
|
|
||||||
//$this->export_entities_array[$r]=array('s.rowid'=>"company",
|
|
||||||
// 's.nom'=>'company',
|
|
||||||
// 's.address'=>'company',
|
|
||||||
// 's.cp'=>'company',
|
|
||||||
// 's.ville'=>'company',
|
|
||||||
// 's.fk_pays'=>'company',
|
|
||||||
// 's.tel'=>'company',
|
|
||||||
// 's.siren'=>'company',
|
|
||||||
// 's.siret'=>'company',
|
|
||||||
// 's.ape'=>'company',
|
|
||||||
// 's.idprof4'=>'company',
|
|
||||||
// 's.code_compta'=>'company',
|
|
||||||
// 's.code_compta_fournisseur'=>'company',
|
|
||||||
// 'f.rowid'=>"invoice",
|
|
||||||
// 'f.facnumber'=>"invoice",
|
|
||||||
// 'f.datec'=>"invoice",
|
|
||||||
// 'f.datef'=>"invoice",
|
|
||||||
// 'f.total'=>"invoice",
|
|
||||||
// 'f.total_ttc'=>"invoice",
|
|
||||||
// 'f.tva'=>"invoice",
|
|
||||||
// 'f.paye'=>"invoice",
|
|
||||||
// 'f.fk_statut'=>'invoice',
|
|
||||||
// 'f.note'=>"invoice",
|
|
||||||
// 'fd.rowid'=>'invoice_line',
|
|
||||||
// 'fd.description'=>"invoice_line",
|
|
||||||
// 'fd.price'=>"invoice_line",
|
|
||||||
// 'fd.total_ht'=>"invoice_line",
|
|
||||||
// 'fd.total_tva'=>"invoice_line",
|
|
||||||
// 'fd.total_ttc'=>"invoice_line",
|
|
||||||
// 'fd.tva_tx'=>"invoice_line",
|
|
||||||
// 'fd.qty'=>"invoice_line",
|
|
||||||
// 'fd.date_start'=>"invoice_line",
|
|
||||||
// 'fd.date_end'=>"invoice_line",
|
|
||||||
// 'fd.fk_product'=>'product',
|
|
||||||
// 'p.ref'=>'product'
|
|
||||||
//);
|
|
||||||
//$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
|
||||||
//$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
|
|
||||||
// . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
|
|
||||||
//$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
|
|
||||||
// . 'product as p on (fd.fk_product = p.rowid)';
|
|
||||||
//$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
|
|
||||||
// . 'AND f.rowid = fd.fk_facture';
|
|
||||||
//$r++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when module is enabled.
|
* Function called when module is enabled.
|
||||||
* The init function add constants, boxes, permissions and menus
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||||
* (defined in constructor) into Dolibarr database.
|
* It also creates data directories
|
||||||
* It also creates data directories
|
|
||||||
*
|
*
|
||||||
* @param string $options Options when enabling module ('', 'noboxes')
|
* @param string $options Options when enabling module ('', 'noboxes')
|
||||||
* @return int 1 if OK, 0 if KO
|
* @return int 1 if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function init($options = '')
|
public function init($options='')
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
$result = $this->loadTables();
|
$this->_load_tables('/mymodule/sql/');
|
||||||
|
|
||||||
return $this->_init($sql, $options);
|
return $this->_init($sql, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create tables, keys and data required by module
|
|
||||||
* Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
|
|
||||||
* and create data commands must be stored in directory /mymodule/sql/
|
|
||||||
* This function is called by this->init
|
|
||||||
*
|
|
||||||
* @return int <=0 if KO, >0 if OK
|
|
||||||
*/
|
|
||||||
private function loadTables()
|
|
||||||
{
|
|
||||||
return $this->_load_tables('/mymodule/sql/');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when module is disabled.
|
* Function called when module is disabled.
|
||||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||||
* Data directories are not deleted
|
* Data directories are not deleted
|
||||||
*
|
*
|
||||||
* @param string $options Options when enabling module ('', 'noboxes')
|
* @param string $options Options when enabling module ('', 'noboxes')
|
||||||
* @return int 1 if OK, 0 if KO
|
* @return int 1 if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
public function remove($options = '')
|
public function remove($options = '')
|
||||||
{
|
{
|
||||||
@ -716,4 +290,5 @@ class modMyModule extends DolibarrModules
|
|||||||
|
|
||||||
return $this->_remove($sql, $options);
|
return $this->_remove($sql, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file core/triggers/interface_99_modMyModule_MyTrigger.class.php
|
* \file core/triggers/interface_99_modMyModule_Triggers.class.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief Example trigger.
|
* \brief Example trigger.
|
||||||
*
|
*
|
||||||
@ -30,17 +30,16 @@
|
|||||||
* - The file must stay in core/triggers
|
* - The file must stay in core/triggers
|
||||||
* - The class name must be InterfaceMytrigger
|
* - The class name must be InterfaceMytrigger
|
||||||
* - The constructor method must be named InterfaceMytrigger
|
* - The constructor method must be named InterfaceMytrigger
|
||||||
* - The name property name must be Mytrigger
|
* - The name property name must be MyTrigger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Includes */
|
require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT . dol_buildpath('/mymodule/class/MyTrigger.php', 1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InterfaceMytrigger
|
* Class of triggers for MyModule module
|
||||||
*/
|
*/
|
||||||
class InterfaceMytrigger extends MyTrigger
|
class InterfaceMyModuleTrigger extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var DoliDB Database handler
|
* @var DoliDB Database handler
|
||||||
@ -58,9 +57,7 @@ class InterfaceMytrigger extends MyTrigger
|
|||||||
|
|
||||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
$this->family = "demo";
|
$this->family = "demo";
|
||||||
$this->description = "Triggers of this module are empty functions."
|
$this->description = "MyModule triggers.";
|
||||||
. "They have no effect."
|
|
||||||
. "They are provided for tutorial purpose only.";
|
|
||||||
// 'development', 'experimental', 'dolibarr' or version
|
// 'development', 'experimental', 'dolibarr' or version
|
||||||
$this->version = 'development';
|
$this->version = 'development';
|
||||||
$this->picto = 'mymodule@mymodule';
|
$this->picto = 'mymodule@mymodule';
|
||||||
@ -86,58 +83,18 @@ class InterfaceMytrigger extends MyTrigger
|
|||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Trigger version
|
|
||||||
*
|
|
||||||
* @return string Version of trigger file
|
|
||||||
*/
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
$langs->load("admin");
|
|
||||||
|
|
||||||
if ($this->version == 'development') {
|
|
||||||
return $langs->trans("Development");
|
|
||||||
} elseif ($this->version == 'experimental') {
|
|
||||||
return $langs->trans("Experimental");
|
|
||||||
} elseif ($this->version == 'dolibarr') {
|
|
||||||
return DOL_VERSION;
|
|
||||||
} elseif ($this->version) {
|
|
||||||
return $this->version;
|
|
||||||
} else {
|
|
||||||
return $langs->trans("Unknown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @codingStandardsIgnoreStart
|
|
||||||
/**
|
|
||||||
* Compatibility trigger function for Dolibarr < 3.7
|
|
||||||
*
|
|
||||||
* @param int $action Trigger action
|
|
||||||
* @param CommonObject $object Object trigged from
|
|
||||||
* @param User $user User that trigged
|
|
||||||
* @param Translate $langs Translations handler
|
|
||||||
* @param Conf $conf Configuration
|
|
||||||
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
|
||||||
* @deprecated Replaced by DolibarrTriggers::runTrigger()
|
|
||||||
*/
|
|
||||||
public function run_trigger($action, $object, $user, $langs, $conf)
|
|
||||||
{
|
|
||||||
return $this->runTrigger($action, $object, $user, $langs, $conf);
|
|
||||||
}
|
|
||||||
// @codingStandardsIgnoreEnd
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
* All functions "runTrigger" are triggered if file
|
* All functions "runTrigger" are triggered if file
|
||||||
* is inside directory core/triggers
|
* is inside directory core/triggers
|
||||||
*
|
*
|
||||||
* @param string $action Event action code
|
* @param string $action Event action code
|
||||||
* @param CommonObject $object Object
|
* @param CommonObject $object Object
|
||||||
* @param User $user Object user
|
* @param User $user Object user
|
||||||
* @param Translate $langs Object langs
|
* @param Translate $langs Object langs
|
||||||
* @param Conf $conf Object conf
|
* @param Conf $conf Object conf
|
||||||
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
|
||||||
{
|
{
|
||||||
|
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 360 B |
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file js/mymodule.js.php
|
* \file htdocs/modulebuilder/template/js/mymodule.js.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief Example JavaScript.
|
* \brief Example JavaScript.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) <year> <name of author>
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
@ -13,21 +13,20 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file myobject_list.php
|
* \file htdocs/modulebuilder/template/myobject_card.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule othermodule1 othermodule2
|
||||||
* \brief Page with list of myobject.
|
* \brief This file is an example of a php page
|
||||||
*
|
* Put here some comments
|
||||||
* List of myobject
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
||||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||||
@ -36,28 +35,31 @@
|
|||||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||||
|
|
||||||
// Change the following lines to use the correct relative path (../, ../../, etc)
|
// Change this following line to use the correct relative path (../, ../../, etc)
|
||||||
|
$res=0;
|
||||||
|
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
|
||||||
|
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
|
||||||
|
if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||||
|
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||||
|
if (! $res) die("Include of main fails");
|
||||||
|
// Change this following line to use the correct relative path from htdocs
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||||
|
dol_include_once('/mymodule/class/myobject_class.class.php');
|
||||||
|
|
||||||
// Load Dolibarr environment
|
// Load traductions files requiredby by page
|
||||||
if (false === (@include '../../main.inc.php')) { // From htdocs directory
|
$langs->load("mymodule");
|
||||||
require '../../../main.inc.php'; // From "custom" directory
|
$langs->load("other");
|
||||||
}
|
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
||||||
dol_include_once('/mymodule/class/myclass.class.php');
|
|
||||||
|
|
||||||
// Load translation files required by the page
|
|
||||||
$langs->load("mymodule@mymodule");
|
|
||||||
|
|
||||||
// Get parameters
|
// Get parameters
|
||||||
$action = GETPOST('action','alpha');
|
|
||||||
$confirm = GETPOST('confirm','alpha');
|
|
||||||
|
|
||||||
$id = GETPOST('id','int');
|
$id = GETPOST('id','int');
|
||||||
|
$action = GETPOST('action','alpha');
|
||||||
|
$cancel = GETPOST('cancel');
|
||||||
$backtopage = GETPOST('backtopage');
|
$backtopage = GETPOST('backtopage');
|
||||||
// TODO Add here list of search params
|
|
||||||
$myparam = GETPOST('myparam','alpha');
|
$myparam = GETPOST('myparam','alpha');
|
||||||
|
|
||||||
|
$search_field1=GETPOST("search_field1");
|
||||||
|
$search_field2=GETPOST("search_field2");
|
||||||
|
|
||||||
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
@ -67,7 +69,8 @@ if ($user->societe_id > 0)
|
|||||||
}
|
}
|
||||||
//$result = restrictedArea($user, 'mymodule', $id);
|
//$result = restrictedArea($user, 'mymodule', $id);
|
||||||
|
|
||||||
$object = new Skeleton_Class($db);
|
|
||||||
|
$object = new MyObject_Class($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
@ -77,7 +80,8 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('skeleton'));
|
$hookmanager->initHooks(array('mymodule'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -86,7 +90,6 @@ $hookmanager->initHooks(array('skeleton'));
|
|||||||
* Put here all code to do according to value of "action" parameter
|
* Put here all code to do according to value of "action" parameter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$parameters=array();
|
$parameters=array();
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
@ -206,15 +209,16 @@ if (empty($reshook))
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VIEW
|
* VIEW
|
||||||
*
|
*
|
||||||
* Put here all code to build page
|
* Put here all code to build page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader('', $langs->trans('MyPageName'), '');
|
llxHeader('','MyPageName','');
|
||||||
|
|
||||||
|
|
||||||
// Put here content of your page
|
// Put here content of your page
|
||||||
@ -293,54 +297,308 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
{
|
{
|
||||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||||
|
|
||||||
$head = commande_prepare_head($object);
|
$head = mymodule_prepare_head($object);
|
||||||
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order');
|
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order');
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("MyModule"));
|
$formconfirm = '';
|
||||||
|
|
||||||
dol_fiche_head();
|
|
||||||
|
|
||||||
|
// Confirmation to delete
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
|
||||||
print $formconfirm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Confirmation of action xxxx
|
||||||
|
if ($action == 'xxx')
|
||||||
|
{
|
||||||
|
$formquestion=array();
|
||||||
|
/*
|
||||||
|
$formquestion = array(
|
||||||
|
// 'text' => $langs->trans("ConfirmClone"),
|
||||||
|
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
||||||
|
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
|
||||||
|
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1)));
|
||||||
|
}*/
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $formconfirm) {
|
||||||
|
$parameters = array('lineid' => $lineid);
|
||||||
|
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
|
||||||
|
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print form confirm
|
||||||
|
print $formconfirm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Object card
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
|
$linkback = '<a href="' . DOL_URL_ROOT . '/mymodule/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
|
||||||
|
|
||||||
|
|
||||||
|
$morehtmlref='<div class="refidno">';
|
||||||
|
/*
|
||||||
|
// Ref bis
|
||||||
|
$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1);
|
||||||
|
$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1);
|
||||||
|
// Thirdparty
|
||||||
|
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
|
||||||
|
// Project
|
||||||
|
if (! empty($conf->projet->enabled))
|
||||||
|
{
|
||||||
|
$langs->load("projects");
|
||||||
|
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||||
|
if ($user->rights->mymodule->creer)
|
||||||
|
{
|
||||||
|
if ($action != 'classify')
|
||||||
|
{
|
||||||
|
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
|
if ($action == 'classify') {
|
||||||
|
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
||||||
|
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||||
|
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||||
|
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||||
|
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||||
|
$morehtmlref.='</form>';
|
||||||
|
} else {
|
||||||
|
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (! empty($object->fk_project)) {
|
||||||
|
$proj = new Project($db);
|
||||||
|
$proj->fetch($object->fk_project);
|
||||||
|
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
|
||||||
|
$morehtmlref.=$proj->ref;
|
||||||
|
$morehtmlref.='</a>';
|
||||||
|
} else {
|
||||||
|
$morehtmlref.='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$morehtmlref.='</div>';
|
||||||
|
|
||||||
|
|
||||||
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||||
|
|
||||||
|
|
||||||
|
print '<div class="fichecenter">';
|
||||||
|
print '<div class="fichehalfleft">';
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
print '<table class="border centpercent">'."\n";
|
print '<table class="border centpercent">'."\n";
|
||||||
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||||
// LIST_OF_TD_LABEL_FIELDS_VIEW
|
// LIST_OF_TD_LABEL_FIELDS_VIEW
|
||||||
|
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
$cols = 2;
|
||||||
|
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
print '<div class="fichehalfright">';
|
||||||
|
print '<div class="ficheaddleft">';
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
print '<table class="border centpercent">';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
print '</div>';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<div class="clearboth"></div><br>';
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons for actions
|
||||||
print '<div class="tabsAction">'."\n";
|
if ($action != 'presend' && $action != 'editline') {
|
||||||
$parameters=array();
|
print '<div class="tabsAction">'."\n";
|
||||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$parameters=array();
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
$reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
if ($user->rights->mymodule->write)
|
if ($user->rights->mymodule->write)
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->rights->mymodule->delete)
|
if ($user->rights->mymodule->delete)
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
print '</div>'."\n";
|
||||||
}
|
}
|
||||||
print '</div>'."\n";
|
|
||||||
|
|
||||||
|
|
||||||
// Example 2 : Adding links to objects
|
// Select mail models is same action as presend
|
||||||
// Show links to link elements
|
if (GETPOST('modelselected')) {
|
||||||
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('skeleton'));
|
$action = 'presend';
|
||||||
//$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
}
|
||||||
|
|
||||||
|
if ($action != 'presend')
|
||||||
|
{
|
||||||
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
|
// Documents
|
||||||
|
$comref = dol_sanitizeFileName($object->ref);
|
||||||
|
$relativepath = $comref . '/' . $comref . '.pdf';
|
||||||
|
$filedir = $conf->mymodule->dir_output . '/' . $comref;
|
||||||
|
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||||
|
$genallowed = $user->rights->mymodule->creer;
|
||||||
|
$delallowed = $user->rights->mymodule->supprimer;
|
||||||
|
print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||||
|
|
||||||
|
|
||||||
|
// Show links to link elements
|
||||||
|
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
|
||||||
|
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||||
|
|
||||||
|
|
||||||
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
// List of actions on element
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||||
|
$formactions = new FormActions($db);
|
||||||
|
$somethingshown = $formactions->showactions($object, 'order', $socid);
|
||||||
|
|
||||||
|
print '</div></div></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action presend
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if ($action == 'presend')
|
||||||
|
{
|
||||||
|
$object->fetch_projet();
|
||||||
|
|
||||||
|
$ref = dol_sanitizeFileName($object->ref);
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||||
|
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||||
|
$file = $fileparams['fullname'];
|
||||||
|
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
|
||||||
|
$newlang = $_REQUEST['lang_id'];
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
||||||
|
$newlang = $object->thirdparty->default_lang;
|
||||||
|
|
||||||
|
if (!empty($newlang))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate('', $conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
$outputlangs->load('commercial');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build document if it not exists
|
||||||
|
if (! $file || ! is_readable($file)) {
|
||||||
|
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result <= 0) {
|
||||||
|
dol_print_error($db, $object->error, $object->errors);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
|
||||||
|
$file = $fileparams['fullname'];
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
|
||||||
|
print '<div class="clearboth"></div>';
|
||||||
|
print '<br>';
|
||||||
|
print load_fiche_titre($langs->trans('SendOrderByMail'));
|
||||||
|
|
||||||
|
dol_fiche_head('');
|
||||||
|
|
||||||
|
// Cree l'objet formulaire mail
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
|
||||||
|
$formmail = new FormMail($db);
|
||||||
|
$formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang);
|
||||||
|
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
|
||||||
|
|
||||||
|
if($formmail->fromtype === 'user'){
|
||||||
|
$formmail->fromid = $user->id;
|
||||||
|
|
||||||
|
}
|
||||||
|
$formmail->trackid='ord'.$object->id;
|
||||||
|
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
|
||||||
|
{
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
|
||||||
|
}
|
||||||
|
$formmail->withfrom = 1;
|
||||||
|
$liste = array();
|
||||||
|
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
|
||||||
|
$liste [$key] = $value;
|
||||||
|
$formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
|
||||||
|
$formmail->withtocc = $liste;
|
||||||
|
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
|
||||||
|
if (empty($object->ref_client)) {
|
||||||
|
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__');
|
||||||
|
} else if (! empty($object->ref_client)) {
|
||||||
|
$formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)');
|
||||||
|
}
|
||||||
|
$formmail->withfile = 2;
|
||||||
|
$formmail->withbody = 1;
|
||||||
|
$formmail->withdeliveryreceipt = 1;
|
||||||
|
$formmail->withcancel = 1;
|
||||||
|
// Tableau des substitutions
|
||||||
|
$formmail->setSubstitFromObject($object);
|
||||||
|
$formmail->substit ['__ORDERREF__'] = $object->ref;
|
||||||
|
|
||||||
|
$custcontact = '';
|
||||||
|
$contactarr = array();
|
||||||
|
$contactarr = $object->liste_contact(- 1, 'external');
|
||||||
|
|
||||||
|
if (is_array($contactarr) && count($contactarr) > 0)
|
||||||
|
{
|
||||||
|
foreach ($contactarr as $contact)
|
||||||
|
{
|
||||||
|
if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) { // TODO Use code and not label
|
||||||
|
$contactstatic = new Contact($db);
|
||||||
|
$contactstatic->fetch($contact ['id']);
|
||||||
|
$custcontact = $contactstatic->getFullName($langs, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($custcontact)) {
|
||||||
|
$formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tableau des parametres complementaires
|
||||||
|
$formmail->param['action'] = 'send';
|
||||||
|
$formmail->param['models'] = 'order_send';
|
||||||
|
$formmail->param['models_id']=GETPOST('modelmailselected','int');
|
||||||
|
$formmail->param['orderid'] = $object->id;
|
||||||
|
$formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
|
||||||
|
|
||||||
|
// Init list of files
|
||||||
|
if (GETPOST("mode") == 'init') {
|
||||||
|
$formmail->clear_attached_files();
|
||||||
|
$formmail->add_attached_files($file, basename($file), dol_mimetype($file));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show form
|
||||||
|
print $formmail->get_form();
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) <year> <name of author>
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
@ -13,21 +13,20 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file myobject_list.php
|
* \file htdocs/modulebuilder/template/myobject_list.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule othermodule1 othermodule2
|
||||||
* \brief Page with list of myobject.
|
* \brief This file is an example of a php page
|
||||||
*
|
* Put here some comments
|
||||||
* List of myobject
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
||||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||||
@ -36,31 +35,39 @@
|
|||||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||||
|
|
||||||
// Change the following lines to use the correct relative path (../, ../../, etc)
|
// Change this following line to use the correct relative path (../, ../../, etc)
|
||||||
|
$res=0;
|
||||||
// Load Dolibarr environment
|
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
|
||||||
if (false === (@include '../../main.inc.php')) { // From htdocs directory
|
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
|
||||||
require '../../../main.inc.php'; // From "custom" directory
|
if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||||
}
|
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||||
|
if (! $res) die("Include of main fails");
|
||||||
|
// Change this following line to use the correct relative path from htdocs
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
dol_include_once('/mymodule/class/myclass.class.php');
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
|
dol_include_once('/mymodule/class/skeleton_class.class.php');
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load traductions files requiredby by page
|
||||||
$langs->load("mymodule@mymodule");
|
$langs->load("mymodule");
|
||||||
|
$langs->load("other");
|
||||||
|
|
||||||
// Get parameters
|
$action=GETPOST('action','alpha');
|
||||||
$action = GETPOST('action','alpha');
|
$massaction=GETPOST('massaction','alpha');
|
||||||
$massaction = GETPOST('massaction','alpha');
|
$show_files=GETPOST('show_files','int');
|
||||||
$show_files = GETPOST('show_files','int');
|
$confirm=GETPOST('confirm','alpha');
|
||||||
$confirm = GETPOST('confirm','alpha');
|
$toselect = GETPOST('toselect', 'array');
|
||||||
$toselect = GETPOST('toselect', 'array');
|
|
||||||
|
|
||||||
$id = GETPOST('id','int');
|
$id = GETPOST('id','int');
|
||||||
$backtopage = GETPOST('backtopage');
|
$backtopage = GETPOST('backtopage');
|
||||||
// TODO Add here list of search params
|
|
||||||
$myparam = GETPOST('myparam','alpha');
|
$myparam = GETPOST('myparam','alpha');
|
||||||
|
|
||||||
|
$search_all=trim(GETPOST("sall"));
|
||||||
|
$search_field1=GETPOST("search_field1");
|
||||||
|
$search_field2=GETPOST("search_field2");
|
||||||
|
$search_myfield=GETPOST('search_myfield');
|
||||||
|
$optioncss = GETPOST('optioncss','alpha');
|
||||||
|
|
||||||
// Load variable for pagination
|
// Load variable for pagination
|
||||||
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
|
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
|
||||||
$sortfield = GETPOST('sortfield','alpha');
|
$sortfield = GETPOST('sortfield','alpha');
|
||||||
@ -74,11 +81,12 @@ if (! $sortfield) $sortfield="t.rowid"; // Set here default search field
|
|||||||
if (! $sortorder) $sortorder="ASC";
|
if (! $sortorder) $sortorder="ASC";
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
|
$socid=0;
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
|
$socid = $user->societe_id;
|
||||||
//accessforbidden();
|
//accessforbidden();
|
||||||
}
|
}
|
||||||
//$result = restrictedArea($user, 'mymodule', $id);
|
|
||||||
|
|
||||||
// Initialize technical object to manage context to save list fields
|
// Initialize technical object to manage context to save list fields
|
||||||
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist';
|
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist';
|
||||||
@ -87,14 +95,41 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymoduleli
|
|||||||
$hookmanager->initHooks(array('mymodulelist'));
|
$hookmanager->initHooks(array('mymodulelist'));
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
// Load object if id or ref is provided as parameter
|
// fetch optionals attributes and labels
|
||||||
$object = new MyClass($db);
|
$extralabels = $extrafields->fetch_name_optionals_label('mymodule');
|
||||||
if (($id > 0 || ! empty($ref)) && $action != 'add') {
|
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||||
$result = $object->fetch($id, $ref);
|
|
||||||
if ($result < 0) dol_print_error($db);
|
// List of fields to search into when doing a "search in all"
|
||||||
|
$fieldstosearchall = array(
|
||||||
|
't.ref'=>'Ref',
|
||||||
|
't.note_public'=>'NotePublic',
|
||||||
|
);
|
||||||
|
if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate";
|
||||||
|
|
||||||
|
// Definition of fields for list
|
||||||
|
$arrayfields=array(
|
||||||
|
't.field1'=>array('label'=>"Field1", 'checked'=>1),
|
||||||
|
't.field2'=>array('label'=>"Field2", 'checked'=>1),
|
||||||
|
//'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
|
||||||
|
't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
|
||||||
|
't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
||||||
|
//'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
||||||
|
);
|
||||||
|
// Extra fields
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
foreach($extrafields->attribute_label as $key => $val)
|
||||||
|
{
|
||||||
|
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$object=new Skeleton_Class($db);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ACTIONS
|
* ACTIONS
|
||||||
*
|
*
|
||||||
@ -116,10 +151,10 @@ if (empty($reshook))
|
|||||||
// Purge search criteria
|
// Purge search criteria
|
||||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
|
||||||
{
|
{
|
||||||
$search_field1='';
|
$search_field1='';
|
||||||
$search_field2='';
|
$search_field2='';
|
||||||
$search_date_creation='';
|
$search_date_creation='';
|
||||||
$search_date_update='';
|
$search_date_update='';
|
||||||
$toselect='';
|
$toselect='';
|
||||||
$search_array_options=array();
|
$search_array_options=array();
|
||||||
}
|
}
|
||||||
@ -134,18 +169,24 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VIEW
|
* VIEW
|
||||||
*
|
*
|
||||||
* Put here all code to build page
|
* Put here all code to build page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader('', $langs->trans('MyPageName'), '');
|
$now=dol_now();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
|
//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
|
||||||
|
$help_url='';
|
||||||
|
$title = $langs->trans('MyModuleListTitle');
|
||||||
|
|
||||||
// Put here content of your page
|
// Put here content of your page
|
||||||
// Example 1: Adding jquery code
|
|
||||||
|
// Example : Adding jquery code
|
||||||
print '<script type="text/javascript" language="javascript">
|
print '<script type="text/javascript" language="javascript">
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
function init_myfunc()
|
function init_myfunc()
|
||||||
@ -161,15 +202,368 @@ jQuery(document).ready(function() {
|
|||||||
</script>';
|
</script>';
|
||||||
|
|
||||||
|
|
||||||
|
$sql = "SELECT";
|
||||||
|
$sql.= " t.rowid,";
|
||||||
|
$sql.= " t.field1,";
|
||||||
|
$sql.= " t.field2";
|
||||||
|
// Add fields from extrafields
|
||||||
|
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
|
||||||
|
// Add fields from hooks
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||||
|
$sql.= " WHERE 1 = 1";
|
||||||
|
//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
|
||||||
|
if ($search_field1) $sql.= natural_search("field1",$search_field1);
|
||||||
|
if ($search_field2) $sql.= natural_search("field2",$search_field2);
|
||||||
|
if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
|
||||||
|
// Add where from extra fields
|
||||||
|
foreach ($search_array_options as $key => $val)
|
||||||
|
{
|
||||||
|
$crit=$val;
|
||||||
|
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||||
|
$typ=$extrafields->attribute_type[$tmpkey];
|
||||||
|
$mode=0;
|
||||||
|
if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
|
||||||
|
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
|
||||||
|
{
|
||||||
|
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
|
$sql.=$db->order($sortfield,$sortorder);
|
||||||
|
|
||||||
// TODO
|
// Count total nb of records
|
||||||
|
$nbtotalofrecords = '';
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
|
$result = $db->query($sql);
|
||||||
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql.= $db->plimit($limit+1, $offset);
|
||||||
|
|
||||||
|
dol_syslog($script_file, LOG_DEBUG);
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
// Direct jump if only one record found
|
||||||
|
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$id = $obj->rowid;
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
llxHeader('', $title, $help_url);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1);
|
||||||
|
if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2);
|
||||||
|
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||||
|
// Add $param from extra fields
|
||||||
|
foreach ($search_array_options as $key => $val)
|
||||||
|
{
|
||||||
|
$crit=$val;
|
||||||
|
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||||
|
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayofmassactions = array(
|
||||||
|
'presend'=>$langs->trans("SendByMail"),
|
||||||
|
'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
|
);
|
||||||
|
if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||||
|
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||||
|
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="action" value="list">';
|
||||||
|
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 '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
|
||||||
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
|
||||||
|
|
||||||
|
if ($sall)
|
||||||
|
{
|
||||||
|
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||||
|
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||||
|
}
|
||||||
|
|
||||||
|
$moreforfilter = '';
|
||||||
|
$moreforfilter.='<div class="divsearchfield">';
|
||||||
|
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
|
||||||
|
$moreforfilter.= '</div>';
|
||||||
|
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||||
|
else $moreforfilter = $hookmanager->resPrint;
|
||||||
|
|
||||||
|
if (! empty($moreforfilter))
|
||||||
|
{
|
||||||
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
|
print $moreforfilter;
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|
||||||
|
// Fields title
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
// LIST_OF_TD_TITLE_FIELDS
|
||||||
|
//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder);
|
||||||
|
//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder);
|
||||||
|
// Extra fields
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
foreach($extrafields->attribute_label as $key => $val)
|
||||||
|
{
|
||||||
|
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||||
|
{
|
||||||
|
$align=$extrafields->getAlignFlag($key);
|
||||||
|
$sortonfield = "ef.".$key;
|
||||||
|
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
|
||||||
|
print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Hook fields
|
||||||
|
$parameters=array('arrayfields'=>$arrayfields);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||||
|
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
|
||||||
|
//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
// Fields title search
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
// LIST_OF_TD_TITLE_SEARCH
|
||||||
|
//if (! empty($arrayfields['t.field1']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field1" value="'.$search_field1.'" size="10"></td>';
|
||||||
|
//if (! empty($arrayfields['t.field2']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" name="search_field2" value="'.$search_field2.'" size="10"></td>';
|
||||||
|
// Extra fields
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
foreach($extrafields->attribute_label as $key => $val)
|
||||||
|
{
|
||||||
|
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||||
|
{
|
||||||
|
$align=$extrafields->getAlignFlag($key);
|
||||||
|
$typeofextrafield=$extrafields->attribute_type[$key];
|
||||||
|
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||||
|
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
|
||||||
|
{
|
||||||
|
$crit=$val;
|
||||||
|
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||||
|
$searchclass='';
|
||||||
|
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
|
||||||
|
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
|
||||||
|
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fields from hook
|
||||||
|
$parameters=array('arrayfields'=>$arrayfields);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
if (! empty($arrayfields['t.datec']['checked']))
|
||||||
|
{
|
||||||
|
// Date creation
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
if (! empty($arrayfields['t.tms']['checked']))
|
||||||
|
{
|
||||||
|
// Date modification
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
/*if (! empty($arrayfields['u.statut']['checked']))
|
||||||
|
{
|
||||||
|
// Status
|
||||||
|
print '<td class="liste_titre" align="center">';
|
||||||
|
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
|
||||||
|
print '</td>';
|
||||||
|
}*/
|
||||||
|
// Action column
|
||||||
|
print '<td class="liste_titre" align="right">';
|
||||||
|
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||||
|
print $searchpicto;
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Detect if we need a fetch on each output line
|
||||||
|
$needToFetchEachLine=0;
|
||||||
|
foreach ($extrafields->attribute_computed as $key => $val)
|
||||||
|
{
|
||||||
|
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Example 2: Adding links to objects
|
$i=0;
|
||||||
// The class must extend CommonObject for this method to be available
|
$totalarray=array();
|
||||||
$somethingshown = $form->showLinkedObjectBlock($myobject);
|
while ($i < min($num, $limit))
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
// Show here line of result
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
// LIST_OF_TD_FIELDS_LIST
|
||||||
|
/*
|
||||||
|
if (! empty($arrayfields['t.field1']['checked']))
|
||||||
|
{
|
||||||
|
print '<td>'.$obj->field1.'</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
if (! empty($arrayfields['t.field2']['checked']))
|
||||||
|
{
|
||||||
|
print '<td>'.$obj->field2.'</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}*/
|
||||||
|
// Extra fields
|
||||||
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
foreach($extrafields->attribute_label as $key => $val)
|
||||||
|
{
|
||||||
|
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||||
|
{
|
||||||
|
print '<td';
|
||||||
|
$align=$extrafields->getAlignFlag($key);
|
||||||
|
if ($align) print ' align="'.$align.'"';
|
||||||
|
print '>';
|
||||||
|
$tmpkey='options_'.$key;
|
||||||
|
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fields from hook
|
||||||
|
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
// Date creation
|
||||||
|
if (! empty($arrayfields['t.datec']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center">';
|
||||||
|
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
// Date modification
|
||||||
|
if (! empty($arrayfields['t.tms']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center">';
|
||||||
|
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
// Status
|
||||||
|
/*
|
||||||
|
if (! empty($arrayfields['u.statut']['checked']))
|
||||||
|
{
|
||||||
|
$userstatic->statut=$obj->statut;
|
||||||
|
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Action column
|
||||||
|
print '<td class="nowrap" align="center">';
|
||||||
|
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
{
|
||||||
|
$selected=0;
|
||||||
|
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||||
|
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show total line
|
||||||
|
if (isset($totalarray['totalhtfield']))
|
||||||
|
{
|
||||||
|
print '<tr class="liste_total">';
|
||||||
|
$i=0;
|
||||||
|
while ($i < $totalarray['nbfield'])
|
||||||
|
{
|
||||||
|
$i++;
|
||||||
|
if ($i == 1)
|
||||||
|
{
|
||||||
|
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||||
|
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||||
|
}
|
||||||
|
elseif ($totalarray['totalhtfield'] == $i) print '<td align="right">'.price($totalarray['totalht']).'</td>';
|
||||||
|
elseif ($totalarray['totalvatfield'] == $i) print '<td align="right">'.price($totalarray['totalvat']).'</td>';
|
||||||
|
elseif ($totalarray['totalttcfield'] == $i) print '<td align="right">'.price($totalarray['totalttc']).'</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
|
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
|
print '</table>'."\n";
|
||||||
|
print '</div>'."\n";
|
||||||
|
|
||||||
|
print '</form>'."\n";
|
||||||
|
|
||||||
|
|
||||||
|
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
|
||||||
|
{
|
||||||
|
// Show list of available documents
|
||||||
|
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||||
|
$urlsource.=str_replace('&','&',$param);
|
||||||
|
|
||||||
|
$filedir=$diroutputmassaction;
|
||||||
|
$genallowed=$user->rights->facture->lire;
|
||||||
|
$delallowed=$user->rights->facture->lire;
|
||||||
|
|
||||||
|
print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
|
|||||||
165
htdocs/modulebuilder/template/scripts/myobject.php
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/* Copyright (C) 2007-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
|
*
|
||||||
|
* 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/modulebuilder/template/scripts/myobject.php
|
||||||
|
* \ingroup mymodule
|
||||||
|
* \brief This file is an example for a command line script to work on MyObject
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sapi_type = php_sapi_name();
|
||||||
|
$script_file = basename(__FILE__);
|
||||||
|
$path=dirname(__FILE__).'/';
|
||||||
|
|
||||||
|
// Test if batch mode
|
||||||
|
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||||
|
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Global variables
|
||||||
|
$version='1.0';
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------- START OF YOUR CODE HERE --------------------
|
||||||
|
@set_time_limit(0); // No timeout for this script
|
||||||
|
define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
|
||||||
|
|
||||||
|
// Include and load Dolibarr environment variables
|
||||||
|
require_once($path."../../htdocs/master.inc.php");
|
||||||
|
// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file).
|
||||||
|
// $user is created but empty.
|
||||||
|
|
||||||
|
//$langs->setDefaultLang('en_US'); // To change default language of $langs
|
||||||
|
$langs->load("main"); // To load language file for default language
|
||||||
|
|
||||||
|
// Load user and its permissions
|
||||||
|
$result=$user->fetch('','admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||||
|
if (! $result > 0) { dol_print_error('',$user->error); exit; }
|
||||||
|
$user->getrights();
|
||||||
|
|
||||||
|
|
||||||
|
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
||||||
|
if (! isset($argv[1])) { // Check parameters
|
||||||
|
print "Usage: ".$script_file." param1 param2 ...\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
print '--- start'."\n";
|
||||||
|
print 'Argument 1='.$argv[1]."\n";
|
||||||
|
print 'Argument 2='.$argv[2]."\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Start of transaction
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
|
||||||
|
// Examples for manipulating class MyObject
|
||||||
|
dol_include_once("/mymodule/class/myobject.class.php");
|
||||||
|
$myobject=new MyObject($db);
|
||||||
|
|
||||||
|
// Example for inserting creating object in database
|
||||||
|
/*
|
||||||
|
dol_syslog($script_file." CREATE", LOG_DEBUG);
|
||||||
|
$myobject->prop1='value_prop1';
|
||||||
|
$myobject->prop2='value_prop2';
|
||||||
|
$id=$myobject->create($user);
|
||||||
|
if ($id < 0) { $error++; dol_print_error($db,$myobject->error); }
|
||||||
|
else print "Object created with id=".$id."\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Example for reading object from database
|
||||||
|
/*
|
||||||
|
dol_syslog($script_file." FETCH", LOG_DEBUG);
|
||||||
|
$result=$myobject->fetch($id);
|
||||||
|
if ($result < 0) { $error; dol_print_error($db,$myobject->error); }
|
||||||
|
else print "Object with id=".$id." loaded\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Example for updating object in database ($myobject must have been loaded by a fetch before)
|
||||||
|
/*
|
||||||
|
dol_syslog($script_file." UPDATE", LOG_DEBUG);
|
||||||
|
$myobject->prop1='newvalue_prop1';
|
||||||
|
$myobject->prop2='newvalue_prop2';
|
||||||
|
$result=$myobject->update($user);
|
||||||
|
if ($result < 0) { $error++; dol_print_error($db,$myobject->error); }
|
||||||
|
else print "Object with id ".$myobject->id." updated\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Example for deleting object in database ($myobject must have been loaded by a fetch before)
|
||||||
|
/*
|
||||||
|
dol_syslog($script_file." DELETE", LOG_DEBUG);
|
||||||
|
$result=$myobject->delete($user);
|
||||||
|
if ($result < 0) { $error++; dol_print_error($db,$myobject->error); }
|
||||||
|
else print "Object with id ".$myobject->id." deleted\n";
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// An example of a direct SQL read without using the fetch method
|
||||||
|
/*
|
||||||
|
$sql = "SELECT field1, field2";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."myobject";
|
||||||
|
$sql.= " WHERE field3 = 'xxx'";
|
||||||
|
$sql.= " ORDER BY field1 ASC";
|
||||||
|
|
||||||
|
dol_syslog($script_file, LOG_DEBUG);
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
// You can use here results
|
||||||
|
print $obj->field1;
|
||||||
|
print $obj->field2;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------- END OF YOUR CODE --------------------
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
print '--- end ok'."\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '--- end error code='.$error."\n";
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close(); // Close $db database opened handler
|
||||||
|
|
||||||
|
exit($error);
|
||||||
@ -1,203 +0,0 @@
|
|||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
|
||||||
* 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 scripts/myscript.php
|
|
||||||
* \ingroup mymodule
|
|
||||||
* \brief Example command line script.
|
|
||||||
*
|
|
||||||
* Put detailed description here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$sapi_type = php_sapi_name();
|
|
||||||
$script_file = basename(__FILE__);
|
|
||||||
$path = dirname(__FILE__) . '/';
|
|
||||||
|
|
||||||
// Test if batch mode
|
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
|
||||||
echo "Error: You are using PHP for CGI. To execute ";
|
|
||||||
echo $script_file;
|
|
||||||
echo " from command line, you must use PHP for CLI mode.\n";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global variables
|
|
||||||
$version = '1.0.0';
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* -------------------- YOUR CODE STARTS HERE --------------------
|
|
||||||
*/
|
|
||||||
/* Set this define to 0 if you want to allow execution of your script
|
|
||||||
* even if dolibarr setup is "locked to admin user only". */
|
|
||||||
define('EVEN_IF_ONLY_LOGIN_ALLOWED', 0);
|
|
||||||
|
|
||||||
/* Include Dolibarr environment
|
|
||||||
* Customize to your needs
|
|
||||||
*/
|
|
||||||
require_once $path . '../../../master.inc.php';
|
|
||||||
/* After this $db, $conf, $langs, $mysoc, $user and other Dolibarr utility variables should be defined.
|
|
||||||
* Warning: this still requires a valid htdocs/conf.php file
|
|
||||||
*/
|
|
||||||
|
|
||||||
global $conf, $db, $langs, $mysoc, $user;
|
|
||||||
|
|
||||||
// No timeout for this script
|
|
||||||
@set_time_limit(0);
|
|
||||||
|
|
||||||
// Set the default language
|
|
||||||
//$langs->setDefaultLang('en_US');
|
|
||||||
|
|
||||||
// Load translations for the default language
|
|
||||||
$langs->load("main");
|
|
||||||
|
|
||||||
/* User and permissions loading
|
|
||||||
* Loads user for login 'admin'.
|
|
||||||
* Comment out to run as anonymous user. */
|
|
||||||
$result = $user->fetch('', 'admin');
|
|
||||||
if (! $result > 0) {
|
|
||||||
dol_print_error('', $user->error);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$user->getrights();
|
|
||||||
|
|
||||||
// Display banner and help
|
|
||||||
echo "***** " . $script_file . " (" . $version . ") pid=" . getmypid() . " *****\n";
|
|
||||||
dol_syslog($script_file . " launched with arg " . join(',', $argv));
|
|
||||||
if (! isset($argv[1])) {
|
|
||||||
// Check parameters
|
|
||||||
echo "Usage: " . $script_file . " param1 param2 ...\n";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
echo '--- start' . "\n";
|
|
||||||
echo 'Argument 1=' . $argv[1] . "\n";
|
|
||||||
echo 'Argument 2=' . $argv[2] . "\n";
|
|
||||||
|
|
||||||
// Start database transaction
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
// Examples for manipulating a class
|
|
||||||
require_once '../class/myclass.class.php';
|
|
||||||
$myobject = new MyClass($db);
|
|
||||||
|
|
||||||
// Example for inserting creating object in database
|
|
||||||
/*
|
|
||||||
dol_syslog($script_file . " CREATE", LOG_DEBUG);
|
|
||||||
$myobject->prop1 = 'value_prop1';
|
|
||||||
$myobject->prop2 = 'value_prop2';
|
|
||||||
$id = $myobject->create($user);
|
|
||||||
if ($id < 0) {
|
|
||||||
$error++;
|
|
||||||
dol_print_error($db, $myobject->error);
|
|
||||||
} else {
|
|
||||||
echo "Object created with id=" . $id . "\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Example for reading object from database
|
|
||||||
/*
|
|
||||||
dol_syslog($script_file . " FETCH", LOG_DEBUG);
|
|
||||||
$result = $myobject->fetch($id);
|
|
||||||
if ($result < 0) {
|
|
||||||
$error;
|
|
||||||
dol_print_error($db, $myobject->error);
|
|
||||||
} else {
|
|
||||||
echo "Object with id=" . $id . " loaded\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Example for updating object in database
|
|
||||||
// ($myobject must have been loaded by a fetch before)
|
|
||||||
/*
|
|
||||||
dol_syslog($script_file . " UPDATE", LOG_DEBUG);
|
|
||||||
$myobject->prop1 = 'newvalue_prop1';
|
|
||||||
$myobject->prop2 = 'newvalue_prop2';
|
|
||||||
$result = $myobject->update($user);
|
|
||||||
if ($result < 0) {
|
|
||||||
$error++;
|
|
||||||
dol_print_error($db, $myobject->error);
|
|
||||||
} else {
|
|
||||||
echo "Object with id " . $myobject->id . " updated\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Example for deleting object in database
|
|
||||||
// ($myobject must have been loaded by a fetch before)
|
|
||||||
/*
|
|
||||||
dol_syslog($script_file . " DELETE", LOG_DEBUG);
|
|
||||||
$result = $myobject->delete($user);
|
|
||||||
if ($result < 0) {
|
|
||||||
$error++;
|
|
||||||
dol_print_error($db, $myobject->error);
|
|
||||||
} else {
|
|
||||||
echo "Object with id " . $myobject->id . " deleted\n";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// An example of a direct SQL read without using the fetch method
|
|
||||||
/*
|
|
||||||
$sql = "SELECT field1, field2";
|
|
||||||
$sql.= " FROM " . MAIN_DB_PREFIX . "c_pays";
|
|
||||||
$sql.= " WHERE field3 = 'xxx'";
|
|
||||||
$sql.= " ORDER BY field1 ASC";
|
|
||||||
|
|
||||||
dol_syslog($script_file . " sql=" . $sql, LOG_DEBUG);
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
if ($num) {
|
|
||||||
while ($i < $num) {
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
if ($obj) {
|
|
||||||
// You can use here results
|
|
||||||
echo $obj->field1;
|
|
||||||
echo $obj->field2;
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$error++;
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* --------------------- YOUR CODE ENDS HERE ----------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Error management
|
|
||||||
if (! $error) {
|
|
||||||
$db->commit();
|
|
||||||
echo '--- end ok' . "\n";
|
|
||||||
$exit_status = 0; // UNIX no errors exit status
|
|
||||||
} else {
|
|
||||||
echo '--- end error code=' . $error . "\n";
|
|
||||||
$db->rollback();
|
|
||||||
$exit_status = 1; // UNIX general error exit status
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close database handler
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
// Return exit status code
|
|
||||||
return $exit_status;
|
|
||||||
@ -14,6 +14,6 @@
|
|||||||
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
INSERT INTO llx_mytable VALUES (
|
INSERT INTO llx_myobject VALUES (
|
||||||
1, 1, 'mydata'
|
1, 1, 'mydata'
|
||||||
);
|
);
|
||||||
|
|||||||
@ -14,4 +14,4 @@
|
|||||||
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
ALTER TABLE llx_mytable ADD UNIQUE INDEX uk_fk_othertable (fk_othertable);
|
ALTER TABLE llx_myobject ADD UNIQUE INDEX uk_fk_othertable (fk_othertable);
|
||||||
@ -14,7 +14,7 @@
|
|||||||
-- You should have received a copy of the GNU General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
CREATE TABLE llx_mytable(
|
CREATE TABLE llx_myobject(
|
||||||
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
|
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
|
||||||
entity INTEGER DEFAULT 1 NOT NULL,
|
entity INTEGER DEFAULT 1 NOT NULL,
|
||||||
fk_othertable INTEGER NOT NULL,
|
fk_othertable INTEGER NOT NULL,
|
||||||
@ -17,20 +17,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file test/unit/MyClassTest.php
|
* \file test/unit/MyObjectTest.php
|
||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief Example PHPUnit test.
|
* \brief PHPUnit test for MyObject class.
|
||||||
*
|
|
||||||
* Put detailed description here.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace test\unit;
|
namespace test\unit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MyClassTest
|
* Class MyObjectTest
|
||||||
* @package Testmymodule
|
* @package Testmymodule
|
||||||
*/
|
*/
|
||||||
class MyClassTest extends \PHPUnit_Framework_TestCase
|
class MyObjectTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Global test setup
|
* Global test setup
|
||||||
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?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) 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) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
|
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
|
||||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2013-2016 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2013-2016 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2012-2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
* 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 Cédric Gross <c.gross@kreiz-it.fr>
|
||||||
* Copyright (C) 2014-2015 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2014-2015 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
* 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
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -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->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->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.'/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("products");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -808,7 +809,7 @@ llxHeader('', $title, $helpurl);
|
|||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
$formproduct = new FormProduct($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
|
// Load object modBarCodeProduct
|
||||||
$res=0;
|
$res=0;
|
||||||
@ -1113,13 +1114,13 @@ else
|
|||||||
// Accountancy_code_sell
|
// Accountancy_code_sell
|
||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_code_buy
|
// Accountancy_code_buy
|
||||||
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else // For external software
|
else // For external software
|
||||||
@ -1406,13 +1407,13 @@ else
|
|||||||
// Accountancy_code_sell
|
// Accountancy_code_sell
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_code_buy
|
// Accountancy_code_buy
|
||||||
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
print '<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>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else // For external software
|
else // For external software
|
||||||
@ -1531,8 +1532,12 @@ else
|
|||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
print $langs->trans("ProductAccountancySellCode");
|
print $langs->trans("ProductAccountancySellCode");
|
||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
if (! empty($conf->accounting->enabled)) {
|
if (! empty($conf->accounting->enabled))
|
||||||
print length_accountg($object->accountancy_code_sell);
|
{
|
||||||
|
$accountingaccount = new AccountingAccount($db);
|
||||||
|
$accountingaccount->fetch('',$object->accountancy_code_sell);
|
||||||
|
|
||||||
|
print $accountingaccount->getNomUrl(0,1,1,'',1);
|
||||||
} else {
|
} else {
|
||||||
print $object->accountancy_code_sell;
|
print $object->accountancy_code_sell;
|
||||||
}
|
}
|
||||||
@ -1542,8 +1547,12 @@ else
|
|||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
print $langs->trans("ProductAccountancyBuyCode");
|
print $langs->trans("ProductAccountancyBuyCode");
|
||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
if (! empty($conf->accounting->enabled)) {
|
if (! empty($conf->accounting->enabled))
|
||||||
print length_accountg($object->accountancy_code_buy);
|
{
|
||||||
|
$accountingaccount2 = new AccountingAccount($db);
|
||||||
|
$accountingaccount2->fetch('',$object->accountancy_code_buy);
|
||||||
|
|
||||||
|
print $accountingaccount2->getNomUrl(0,1,1,'',1);
|
||||||
} else {
|
} else {
|
||||||
print $object->accountancy_code_buy;
|
print $object->accountancy_code_buy;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,6 +181,13 @@ if (! empty($conf->global->STRIPE_SECURITY_TOKEN))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Common variables
|
||||||
|
$creditor=$mysoc->name;
|
||||||
|
$paramcreditor='STRIPE_CREDITOR_'.$suffix;
|
||||||
|
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
|
||||||
|
else if (! empty($conf->global->STRIPE_CREDITOR)) $creditor=$conf->global->STRIPE_CREDITOR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -218,9 +225,11 @@ if ($action == 'charge')
|
|||||||
dol_syslog("Create customer", LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Create customer", LOG_DEBUG, 0, '_stripe');
|
||||||
$customer = \Stripe\Customer::create(array(
|
$customer = \Stripe\Customer::create(array(
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'card' => $stripeToken
|
'description' => ($email?'Customer for '.$email:null),
|
||||||
// TODO
|
'metadata' => array('ipaddress'=>$_SERVER['REMOTE_ADDR']),
|
||||||
|
'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?)
|
||||||
));
|
));
|
||||||
|
// TODO Add 'business_vat_id' ?
|
||||||
|
|
||||||
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe');
|
||||||
$charge = \Stripe\Charge::create(array(
|
$charge = \Stripe\Charge::create(array(
|
||||||
@ -228,7 +237,8 @@ if ($action == 'charge')
|
|||||||
'amount' => price2num($amount, 'MU'),
|
'amount' => price2num($amount, 'MU'),
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'description' => 'Stripe payment: '.$FULLTAG,
|
'description' => 'Stripe payment: '.$FULLTAG,
|
||||||
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars
|
'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name),
|
||||||
|
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt
|
||||||
));
|
));
|
||||||
} catch(\Stripe\Error\Card $e) {
|
} catch(\Stripe\Error\Card $e) {
|
||||||
// Since it's a decline, \Stripe\Error\Card will be caught
|
// Since it's a decline, \Stripe\Error\Card will be caught
|
||||||
@ -330,12 +340,6 @@ if (empty($conf->global->STRIPE_LIVE))
|
|||||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
|
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode'),'','warning');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common variables
|
|
||||||
$creditor=$mysoc->name;
|
|
||||||
$paramcreditor='STRIPE_CREDITOR_'.$suffix;
|
|
||||||
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
|
|
||||||
else if (! empty($conf->global->STRIPE_CREDITOR)) $creditor=$conf->global->STRIPE_CREDITOR;
|
|
||||||
|
|
||||||
print '<span id="dolpaymentspan"></span>'."\n";
|
print '<span id="dolpaymentspan"></span>'."\n";
|
||||||
print '<div class="center">'."\n";
|
print '<div class="center">'."\n";
|
||||||
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 460 B |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 1.1 KiB |
@ -1782,7 +1782,7 @@ font.vsmenudisabled { font-size:<?php print $fontsize ?>px; font-family: <?php p
|
|||||||
a.vsmenu:link, a.vsmenu:visited { color: #<?php echo $colortextbackvmenu; ?>; white-space: nowrap; }
|
a.vsmenu:link, a.vsmenu:visited { color: #<?php echo $colortextbackvmenu; ?>; white-space: nowrap; }
|
||||||
font.vsmenudisabledmargin { margin: 1px 1px 1px 6px; }
|
font.vsmenudisabledmargin { margin: 1px 1px 1px 6px; }
|
||||||
|
|
||||||
a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:<?php print $fontsizesmaller ?>px; font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; font-weight: normal; color: #666666; text-decoration: none; }
|
a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:<?php print $fontsizesmaller ?>px; font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; font-weight: normal; color: #aaa; text-decoration: none; }
|
||||||
|
|
||||||
.vmenu div.blockvmenufirst, .vmenu div.blockvmenulogo, .vmenu div.blockvmenusearchphone, .vmenu div.blockvmenubookmarks
|
.vmenu div.blockvmenufirst, .vmenu div.blockvmenulogo, .vmenu div.blockvmenusearchphone, .vmenu div.blockvmenubookmarks
|
||||||
{
|
{
|
||||||
@ -1815,6 +1815,7 @@ div.blockvmenusearchphone
|
|||||||
}
|
}
|
||||||
div.blockvmenubookmarks
|
div.blockvmenubookmarks
|
||||||
{
|
{
|
||||||
|
padding-top: 10px !important;
|
||||||
padding-bottom: 16px !important;
|
padding-bottom: 16px !important;
|
||||||
}
|
}
|
||||||
div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks, div.blockvmenuend
|
div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks, div.blockvmenuend
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 79 B |
@ -1805,7 +1805,7 @@ font.vsmenudisabled { font-size:<?php print $fontsize ?>px; font-family: <?php p
|
|||||||
a.vsmenu:link, a.vsmenu:visited { color: #<?php echo $colortextbackvmenu; ?>; white-space: nowrap; }
|
a.vsmenu:link, a.vsmenu:visited { color: #<?php echo $colortextbackvmenu; ?>; white-space: nowrap; }
|
||||||
font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; }
|
font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; }
|
||||||
|
|
||||||
a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:<?php print $fontsizesmaller ?>px; font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; font-weight: normal; color: #666666; text-decoration: none; }
|
a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { font-size:<?php print $fontsizesmaller ?>px; font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; font-weight: normal; color: #999; text-decoration: none; }
|
||||||
|
|
||||||
div.blockvmenulogo
|
div.blockvmenulogo
|
||||||
{
|
{
|
||||||
|
|||||||