diff --git a/ChangeLog b/ChangeLog index 68e9674d0da..c76617b2f8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.0 compared to 5.0.* ***** +For developers: +NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... + WARNING: Following changes may create regression for some external modules, but were necessary to make Dolibarr better: diff --git a/htdocs/.gitignore b/htdocs/.gitignore index 1650ea7e5ae..9d1e0435f86 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -4,6 +4,7 @@ /dolimed* /ecommerce* /extensions* +/forceproject* /google* /lead /multicompany* diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index d3556135972..c2b6997d96e 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -27,7 +27,6 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("compta"); @@ -56,7 +55,6 @@ if (! $user->rights->accounting->chartofaccount) accessforbidden(); $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); -$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if ($page == - 1) { $page = 0; @@ -64,10 +62,8 @@ if ($page == - 1) { $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) - $sortfield = "aa.account_number"; -if (! $sortorder) - $sortorder = "ASC"; +if (! $sortfield) $sortfield = "aa.account_number"; +if (! $sortorder) $sortorder = "ASC"; $arrayfields=array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), @@ -80,6 +76,9 @@ $arrayfields=array( $accounting = new AccountingAccount($db); +// Initialize technical object to manage context to save list fields +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'accountingaccountlist'; + /* * Actions @@ -146,6 +145,7 @@ if (empty($reshook)) /* * View */ + $form=new Form($db); llxHeader('', $langs->trans("ListAccounts")); @@ -171,7 +171,6 @@ if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_la if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent); if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype); - $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -193,22 +192,29 @@ if ($resql) $params=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($search_account) $params.= '&search_account='.urlencode($search_account); - if ($search_label) $params.= '&search_label='.urlencode($search_label); - if ($search_accountparent) $params.= '&search_accountparent='.urlencode($search_accountparent); - if ($search_pcgtype) $params.= '&search_pcgtype='.urlencode($search_pcgtype); - if ($search_pcgsubtype) $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); + if ($search_account) $params.= '&search_account='.urlencode($search_account); + if ($search_label) $params.= '&search_label='.urlencode($search_label); + if ($search_accountparent) $params.= '&search_accountparent='.urlencode($search_accountparent); + if ($search_pcgtype) $params.= '&search_pcgtype='.urlencode($search_pcgtype); + if ($search_pcgsubtype) $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); if ($optioncss != '') $param.='&optioncss='.$optioncss; - print '
'; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $htmlbuttonadd = '' . $langs->trans("Addanaccount") . ''; print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $htmlbuttonadd); // Box to select active chart of account - $var = ! $var; print $langs->trans("Selectchartofaccounts") . " : "; print ''; } - elseif ($fieldlist[$field]=='unit') { - print ''; - $units = array( - 'mm' => $langs->trans('SizeUnitmm'), - 'cm' => $langs->trans('SizeUnitcm'), - 'point' => $langs->trans('SizeUnitpoint'), - 'inch' => $langs->trans('SizeUnitinch') - ); - print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); - print ''; - } - // Le type de taxe locale - elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') - { - print ''; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); - print ''; - } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { print ''; if (! empty($conf->accounting->enabled)) { $accountancy_account = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); - print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 3522460e07b..73e3fdf6dd9 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ /** * \file htdocs/accountancy/admin/card.php - * \ingroup Advanced accountancy + * \ingroup Advanced accountancy * \brief Card of accounting account */ @@ -27,7 +27,6 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $error = 0; @@ -59,7 +58,7 @@ if (GETPOST('cancel')) header("Location: ".$urltogo); exit; } - + if ($action == 'add' && $user->rights->accounting->chartofaccount) { if (! $cancel) { @@ -86,7 +85,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) } else { $account_parent = GETPOST('account_parent','int'); } - + $object->fk_pcg_version = $obj->pcg_version; $object->pcg_type = GETPOST('pcg_type'); $object->pcg_subtype = GETPOST('pcg_subtype'); @@ -95,7 +94,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->account_category = GETPOST('account_category'); $object->label = GETPOST('label', 'alpha'); $object->active = 1; - + $res = $object->create($user); if ($res == - 3) { $error = 1; @@ -124,9 +123,9 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) } else if ($action == 'edit' && $user->rights->accounting->chartofaccount) { if (! $cancel) { $result = $object->fetch($id); - + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); $obj = $db->fetch_object($result2); @@ -156,9 +155,9 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category'); $object->label = GETPOST('label', 'alpha'); - + $result = $object->update($user); - + if ($result > 0) { $urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id); header("Location: " . $urltogo); @@ -196,7 +195,6 @@ $helpurl = ''; llxheader('', $title, $helpurl); $form = new Form($db); -$htmlacc = new FormVentilation($db); $formaccounting = new FormAccounting($db); $accountsystem = new AccountancySystem($db); @@ -205,13 +203,13 @@ $accountsystem->fetch($conf->global->CHARTOFACCOUNTS); // Create mode if ($action == 'create') { print load_fiche_titre($langs->trans('NewAccountingAccount')); - + print '' . "\n"; print ''; print ''; - + dol_fiche_head(); - + print ''; // Chart of account @@ -219,8 +217,7 @@ if ($action == 'create') { print ''; - - + // Account number print ''; print ''; @@ -232,7 +229,7 @@ if ($action == 'create') { // Account parent print ''; print ''; // Category @@ -245,72 +242,69 @@ if ($action == 'create') { print ''; print ''; // Chart of acounts subtype print ''; print ''; - + print '
'; print $accountsystem->ref; print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Accountparent") . ''; - 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 '
' . $langs->trans("Pcgtype") . ''; print ''; - //print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1); print '
' . $langs->trans("Pcgsubtype") . ''; print ''; - //print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print ''; } else if ($id) { $result = $object->fetch($id); - + if ($result > 0) { dol_htmloutput_mesg($mesg); - + $head = accounting_prepare_head($object); - + // Edit mode if ($action == 'update') { dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print '
' . "\n"; print ''; print ''; print ''; print ''; - + print ''; - + // Account number print ''; print ''; - + // Label print ''; print ''; - + // Account parent print ''; print ''; // Category - print ''; + print ''; print ''; + $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); + print ''; // Chart of accounts type print ''; print ''; @@ -318,29 +312,27 @@ if ($action == 'create') { print ''; print ''; - + print '
' . $langs->trans("AccountNumber") . '
' . $langs->trans("Label") . '
' . $langs->trans("Accountparent") . ''; - print $htmlacc->select_account($object->account_parent, 'account_parent', 1); + print $formaccounting->select_account($object->account_parent, 'account_parent', 1); print '
'.$langs->trans("AccountingCategory").'
'.$langs->trans("AccountingCategory").''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); - print '
' . $langs->trans("Pcgtype") . ''; - //print $htmlacc->select_pcgtype($object->pcg_type, 'pcg_type', 1); print ''; print '
' . $langs->trans("Pcgsubtype") . ''; print ''; - //print $htmlacc->select_pcgsubtype($object->pcg_subtype, 'pcg_subtype', 1); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; } else { - // View mode $linkback = '' . $langs->trans("BackToChartofaccounts") . ''; - + dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); - + print ''; - + // Account number print ''; print ''; @@ -378,31 +370,30 @@ if ($action == 'create') { } else { print img_picto($langs->trans("Activated"), 'switch_on'); }*/ - + print ''; - + print '
' . $langs->trans("AccountNumber") . '' . $object->account_number . '
'; - + dol_fiche_end(); - + /* * Actions buttons */ - print '
'; - + if (! empty($user->rights->accounting->chartofaccount)) { print '' . $langs->trans('Modify') . ''; } else { print '' . $langs->trans('Modify') . ''; } - + if (! empty($user->rights->accounting->chartofaccount)) { print '' . $langs->trans('Delete') . ''; } else { print '' . $langs->trans('Delete') . ''; } - + print '
'; } } else { diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index c0fa895ae4c..e78737c3fb9 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -451,13 +451,8 @@ $formadmin=new FormAdmin($db); llxHeader(); -$titre=$langs->trans("DictionarySetup"); +$titre=$langs->trans($tablib[$id]); $linkback=''; -if ($id) -{ - $titre.=' - '.$langs->trans($tablib[$id]); - $linkback=''.$langs->trans("BackToDictionaryList").''; -} $titlepicto='title_setup'; print load_fiche_titre($titre,$linkback,$titlepicto); @@ -982,7 +977,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); foreach ($fieldlist as $field => $value) { @@ -1125,7 +1120,7 @@ function fieldListAccountingCategories($fieldlist, $obj='', $tabname='', $contex { $fieldname = $fieldlist[$field]; $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); - print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 4b733bee5a6..aaf98a0fa8b 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -32,7 +32,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("compta"); $langs->load("bills"); @@ -117,12 +117,11 @@ if ($action == 'update') { llxHeader(); $form = new Form($db); -$formaccountancy = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); -print '
'; print $langs->trans("DefaultBindingDesc").'
'; print '
'; @@ -142,7 +141,7 @@ foreach ( $list_account as $key ) { print '' . $label . ''; // Value print ''; // 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 ''; print ''; } diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 4a6c82cb581..1bb1bf178b3 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -1,8 +1,7 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +27,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // langs $langs->load("compta"); @@ -65,22 +64,22 @@ if ($_POST["action"] == 'import') { if (is_array($to_import) && count($to_import) > 0) { print '
' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '
'; $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - + $result = $db->query($sql); if ($result && ($db->num_rows($result) > 0)) { - + $obj = $db->fetch_object($result); - + $cpt = 0; foreach ( $to_import as $maLigneCochee ) { - + $accounting = new AccountingAccount($db); - + $monLabel = GETPOST('label' . $maLigneCochee); $monParentAccount = GETPOST('AccountParent' . $maLigneCochee); $monType = GETPOST('pcgType' . $maLigneCochee); $monSubType = GETPOST('pcgSubType' . $maLigneCochee); - + $accounting->fk_pcg_version = $obj->pcg_version; $accounting->account_number = $maLigneCochee; $accounting->label = $monLabel; @@ -126,10 +125,10 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - + print '
' . "\n"; print ''; - + print ''; print ''; print ''; @@ -138,44 +137,43 @@ if ($result) { print ''; print ''; print ''; - + $form = new Form($db); - $htmlacc = new FormVentilation($db); - + $formaccounting = new FormAccounting($db); + $var = true; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); print ''; - + print ''; - + print ''; - + // Colonne choix du compte print ''; - + print ''; - + print ''; - + // Colonne choix ligne a ventiler - $checked = ('label' == 'O') ? ' checked' : ''; - + print ''; - + print ''; $i ++; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 899aaa1a3d2..0e1f67a0e61 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,11 +1,11 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,8 +31,6 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; $langs->load("compta"); $langs->load("bills"); @@ -160,7 +158,6 @@ if ($action == 'setdisabledirectinput') { llxHeader(); $form = new Form($db); -$formaccountancy = new FormVentilation($db); $linkback = '' . $langs->trans("BackToModuleList") . ''; print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php deleted file mode 100644 index 8e19a3e3e87..00000000000 --- a/htdocs/accountancy/admin/journal.php +++ /dev/null @@ -1,207 +0,0 @@ - - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - * - */ - -/** - * \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 = '' . $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup'); - -$head = admin_accounting_prepare_head(null); - -print ''; -print ''; -print ''; - -dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron'); - -print '
' . $langs->trans("AccountAccouting") . '' . $langs->trans("label") . '' . $langs->trans("Pcgsubtype") . '' . $langs->trans("Import") . '
'; print $objp->accounting; print ''; print ''; print ''; - print $htmlacc->select_account($accounting->account_parent, 'AccountParent'); + print $formaccounting->select_account($accounting->account_parent, 'AccountParent'); print ''; - print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcgType'); + print ''; print ''; - print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcgSubType'); + print ''; print ''; print ''; print '
'; -print ''; -print ''; -print "\n"; - -foreach ( $list as $key ) { - - print ''; - - // Param - $label = $langs->trans($key); - print ''; - - // Value - print ''; -} - -print "
' . $langs->trans('Journaux') . '
'; - print ''; - print '
\n"; - -print '
'; - -print ''; -print ''; -print ''; -print "\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 ''; - - // Param - print ''; - - // Value - print ''; - - $i ++; - } - $db->free($resql); -} -else -{ - dol_print_error($db); -} - -print "
' . $langs->trans('JournalFinancial') . ' ('.$langs->trans('Opened').')
'; - print ''; - print '
\n"; - -dol_fiche_end(); - -print '
'; - -print '
'; - -llxFooter(); -$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 359a8b40c12..fcb44c6f858 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -184,7 +184,7 @@ if ($action == 'update') { * View */ -$form = new FormVentilation($db); +$form = new FormAccounting($db); // Defaut AccountingAccount RowId Product / Service // at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 9e5be25eb73..34db60f7a0f 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -28,8 +28,8 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; // Langs @@ -61,7 +61,7 @@ $offset = $limit * $page; $object = new BookKeeping($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); @@ -98,7 +98,7 @@ if (! empty($search_accountancy_code_end)) { * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test 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_accountancy_code_start = ''; $search_accountancy_code_end = ''; @@ -137,7 +137,7 @@ if ($action == 'export_csv') { } else { - $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); + $title_page = $langs->trans("AccountBalance") . (($search_date_start || $search_date_end) ? ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end) : ''); llxHeader('', $title_page); @@ -160,7 +160,7 @@ else { print '
'; $button = ''; - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, 0, 'title_accountancy', 0, $button); + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); $moreforfilter = ''; @@ -186,10 +186,10 @@ else { print ''; print ''; print $langs->trans('From'); - print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); + print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); print ' '; print $langs->trans('to'); - print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); + print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, ''); print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 7ee3e6bb4fe..4443fb959b2 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -27,9 +27,8 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("accountancy"); @@ -215,7 +214,6 @@ else if ($action == "confirm_create") { llxHeader(); $html = new Form($db); -$formventilation = new FormVentilation($db); $formaccountancy = new FormAccounting($db); /* @@ -389,10 +387,10 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; - 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 ''; print ''; - print $formventilation->select_auxaccount($line->code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1); print ''; print ''; print ''; @@ -433,10 +431,10 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; - 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 ''; print ''; - print $formventilation->select_auxaccount($code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 0c49ac0e1ba..369dd7afcec 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -28,10 +28,10 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("accountancy"); @@ -94,7 +94,7 @@ if ($sortfield == "") $sortfield = "t.rowid"; $object = new BookKeeping($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); @@ -292,7 +292,6 @@ $title_page = $langs->trans("Bookkeeping"); llxHeader('', $title_page); // List - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); @@ -322,8 +321,8 @@ if ($action == 'delbookkeepingyear') { if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } - $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formventilation->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array'); + $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); $form_question['delyear'] = array ( 'name' => 'delyear', @@ -386,17 +385,17 @@ print ''; print ''; print ''; print $langs->trans('From'); -print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); print '
'; print $langs->trans('to'); -print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print ''; print ''; 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 '
'; 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 ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index eb8a53561d2..6b329e421ad 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -29,8 +29,8 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; // Langs @@ -75,7 +75,7 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_ $object = new BookKeeping($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); @@ -188,7 +188,7 @@ if ($action == 'delbookkeepingyear') { if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); } - $year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); + $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); $form_question['delyear'] = array ( 'name' => 'delyear', diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index 263f293043a..5fba55f2eba 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("accountancy"); @@ -67,7 +67,7 @@ $search_code_journal = GETPOST('search_code_journal', 'alpha'); $object = new BookKeeping($db); $form = new Form($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); // Filter if (empty($search_date_start)) { @@ -182,15 +182,15 @@ print $form->select_date($search_date_end, 'date_end'); print ''; print '
'; print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': '; -print $formventilation->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, ''); print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': '; -print $formventilation->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, ''); print '
'; print '
'; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formventilation->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); +print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formventilation->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); +print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); print '
'; print ""; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a59d92eb63a..5d9e7a9910a 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -54,18 +54,15 @@ class BookKeeping extends CommonObject * @var string Name of table without prefix where object is stored */ public $table_element = 'accounting_bookkeeping'; - - + public $entity = 1; - - + /** * * @var BookKeepingLine[] Lines */ public $lines = array (); - - + /** * * @var int ID @@ -89,10 +86,10 @@ class BookKeeping extends CommonObject public $import_key; public $code_journal; public $piece_num; - + /** */ - + /** * Constructor * @@ -101,7 +98,7 @@ class BookKeeping extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; } - + /** * Create object into database * @@ -110,12 +107,12 @@ class BookKeeping extends CommonObject * @return int <0 if KO, Id of created object if OK */ public function create(User $user, $notrigger = false) { - global $conf, $langs; - + global $conf, $langs; + dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + // Clean parameters if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); @@ -177,15 +174,14 @@ class BookKeeping extends CommonObject { $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); } - + return -1; } - - + $this->db->begin(); - + $this->piece_num = 0; - + // First check if line not yet already in bookkeeping $sql = "SELECT count(*) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -193,10 +189,10 @@ class BookKeeping extends CommonObject $sql .= " AND fk_doc = " . $this->fk_doc; $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $resql = $this->db->query($sql); - + if ($resql) { $row = $this->db->fetch_object($resql); if ($row->nb == 0) @@ -207,8 +203,8 @@ class BookKeeping extends CommonObject $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object - $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -219,8 +215,8 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + $sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -232,12 +228,12 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $this->piece_num = 1; } - + $now = dol_now(); if (empty($this->date_create)) { $this->date_create = $now; } - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " ("; $sql .= "doc_date"; $sql .= ", doc_type"; @@ -275,7 +271,7 @@ class BookKeeping extends CommonObject $sql .= "," . $this->piece_num; $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -308,7 +304,7 @@ class BookKeeping extends CommonObject $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + if (! $error) { if (! $notrigger) { @@ -321,7 +317,7 @@ class BookKeeping extends CommonObject // // End call triggers } } - + // Commit or rollback if ($error) { $this->db->rollback(); @@ -331,7 +327,7 @@ class BookKeeping extends CommonObject return $result; } } - + /** * Create object into database * @@ -341,11 +337,11 @@ class BookKeeping extends CommonObject */ public function createStd(User $user, $notrigger = false) { dol_syslog(__METHOD__, LOG_DEBUG); - + $error = 0; - + // Clean parameters - + if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -393,10 +389,10 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql .= 'doc_date,'; @@ -435,19 +431,19 @@ class BookKeeping extends CommonObject $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; - + $this->db->begin(); - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $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. @@ -458,7 +454,7 @@ class BookKeeping extends CommonObject // // End call triggers } } - + // Commit or rollback if ($error) { $this->db->rollback(); @@ -470,7 +466,7 @@ class BookKeeping extends CommonObject return $this->id; } } - + /** * Load object in memory from the database * @@ -481,9 +477,9 @@ class BookKeeping extends CommonObject */ public function fetch($id, $ref = null) { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -510,15 +506,15 @@ class BookKeeping extends CommonObject } 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->doc_date = $this->db->jdate($obj->doc_date); $this->doc_type = $obj->doc_type; $this->doc_ref = $obj->doc_ref; @@ -537,7 +533,7 @@ class BookKeeping extends CommonObject $this->piece_num = $obj->piece_num; } $this->db->free($resql); - + if ($numrows) { return 1; } else { @@ -565,9 +561,9 @@ class BookKeeping extends CommonObject */ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - + + dol_syslog(__METHOD__, LOG_DEBUG); + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -622,16 +618,16 @@ class BookKeeping extends CommonObject $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -648,16 +644,16 @@ class BookKeeping extends CommonObject $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } @@ -677,9 +673,9 @@ class BookKeeping extends CommonObject */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.doc_date,"; @@ -723,7 +719,7 @@ class BookKeeping extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } - + if (! empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } @@ -731,16 +727,16 @@ class BookKeeping extends CommonObject $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -757,20 +753,20 @@ class BookKeeping extends CommonObject $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -785,9 +781,9 @@ class BookKeeping extends CommonObject */ public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { global $conf; - + dol_syslog(__METHOD__, LOG_DEBUG); - + $sql = 'SELECT'; $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; @@ -817,9 +813,9 @@ class BookKeeping extends CommonObject if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } - + $sql .= ' GROUP BY t.numero_compte'; - + if (! empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } @@ -827,30 +823,30 @@ class BookKeeping extends CommonObject $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } $this->lines = array (); - + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - + while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->numero_compte = $obj->numero_compte; $line->debit = $obj->debit; $line->credit = $obj->credit; $this->lines[] = $line; } $this->db->free($resql); - + return $num; } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Update object into database * @@ -861,11 +857,10 @@ class BookKeeping extends CommonObject */ public function update(User $user, $notrigger = false) { $error = 0; - + dol_syslog(__METHOD__, LOG_DEBUG); - + // Clean parameters - if (isset($this->doc_type)) { $this->doc_type = trim($this->doc_type); } @@ -911,10 +906,10 @@ class BookKeeping extends CommonObject if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } - + // Check parameters // Put here code to add a control on parameters values - + // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; @@ -934,16 +929,16 @@ class BookKeeping extends CommonObject $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); $sql .= ' WHERE rowid=' . $this->id; - + $this->db->begin(); - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + if (! $error && ! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -953,19 +948,19 @@ class BookKeeping extends CommonObject // 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 * @@ -976,27 +971,27 @@ class BookKeeping extends CommonObject */ 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 (! $error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql .= ' WHERE rowid=' . $this->id; - + $resql = $this->db->query($sql); if (! $resql) { $error ++; @@ -1004,19 +999,19 @@ class BookKeeping extends CommonObject dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } } - + // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return 1; } } - + /** * Delete bookkepping by importkey * @@ -1025,25 +1020,25 @@ class BookKeeping extends CommonObject */ function deleteByImportkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); dol_syslog(get_class($this)."::delete Error " . $this->db->lasterror(), LOG_ERR); $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } - + /** * Delete bookkepping by year * @@ -1053,23 +1048,23 @@ class BookKeeping extends CommonObject */ function deleteByYearAndJournal($delyear='', $journal='') { global $conf; - + if (empty($delyear) && empty($journal)) { return -1; } - + $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql.= " WHERE 1 = 1"; if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -1079,11 +1074,11 @@ class BookKeeping extends CommonObject $this->db->rollback(); return -1; } - + $this->db->commit(); return 1; } - + /** * Delete bookkepping by piece number * @@ -1092,17 +1087,17 @@ class BookKeeping extends CommonObject */ function deleteMvtNum($piecenum) { global $conf; - + $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + $resql = $this->db->query($sql); - + if (! $resql) { $this->errors[] = "Error " . $this->db->lasterror(); foreach ( $this->errors as $errmsg ) { @@ -1112,11 +1107,11 @@ class BookKeeping extends CommonObject $this->db->rollback(); return - 1; } - + $this->db->commit(); return 1; } - + /** * Load an object from its id and create a new one in database * @@ -1126,43 +1121,43 @@ class BookKeeping extends CommonObject */ public function createFromClone($fromid) { dol_syslog(__METHOD__, LOG_DEBUG); - + global $user; $error = 0; $object = new Accountingbookkeeping($this->db); - + $this->db->begin(); - + // Load source object $object->fetch($fromid); // Reset object $object->id = 0; - + // Clear fields // ... - + // Create clone $result = $object->create($user); - + // Other options if ($result < 0) { $error ++; $this->errors = $object->errors; dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } - + // End if (! $error) { $this->db->commit(); - + return $object->id; } else { $this->db->rollback(); - + return - 1; } } - + /** * Initialise object with example values * Id must be 0 if object instance is a specimen @@ -1171,9 +1166,9 @@ class BookKeeping extends CommonObject */ public function initAsSpecimen() { global $user; - + $now=dol_now(); - + $this->id = 0; $this->doc_date = $now; $this->doc_type = ''; @@ -1192,7 +1187,7 @@ class BookKeeping extends CommonObject $this->code_journal = ''; $this->piece_num = ''; } - + /** * Load an accounting document into memory from database * @@ -1201,17 +1196,17 @@ class BookKeeping extends CommonObject */ public function fetchPerMvt($piecenum) { global $conf; - - $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; + + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + $this->piece_num = $obj->piece_num; $this->code_journal = $obj->code_journal; $this->doc_date = $this->db->jdate($obj->doc_date); @@ -1222,10 +1217,10 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Return next number movement * @@ -1233,26 +1228,26 @@ class BookKeeping extends CommonObject */ public function getNextNumMvt() { - global $conf; - + global $conf; + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - if ($obj) $result = $obj->max; - if (empty($result)) $result = 1; - return $result; + if ($obj) $result = $obj->max; + if (empty($result)) $result = 1; + return $result; } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::getNextNumMvt " . $this->error, LOG_ERR); return - 1; } } - + /** * Load all informations of accountancy document * @@ -1260,26 +1255,26 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ function fetch_all_per_mvt($piecenum) { - global $conf; - + global $conf; + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; - $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; - + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - + while ( $obj = $this->db->fetch_object($result) ) { - + $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -1294,7 +1289,7 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesmvt[] = $line; } } else { @@ -1302,10 +1297,10 @@ class BookKeeping extends CommonObject dol_syslog(get_class($this) . "::" . __METHOD__ . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Export bookkeping * @@ -1313,28 +1308,28 @@ class BookKeeping extends CommonObject * @return int Result */ function export_bookkeping($model = 'ebp') { - global $conf; - + global $conf; + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; - + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); - + $resql = $this->db->query($sql); - + if ($resql) { $this->linesexport = array (); - + $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -1349,11 +1344,11 @@ class BookKeeping extends CommonObject $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesexport[] = $line; } $this->db->free($resql); - + return $num; } else { $this->error = "Error " . $this->db->lasterror(); @@ -1433,8 +1428,7 @@ class BookKeeping extends CommonObject return $out; } - - + /** * Description of a root accounting account * @@ -1442,10 +1436,10 @@ class BookKeeping extends CommonObject * @return string Root account */ function get_compte_racine($account = null) - { + { global $conf; $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT root.account_number, root.label as label"; $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"; @@ -1456,7 +1450,7 @@ class BookKeeping extends CommonObject $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1464,9 +1458,9 @@ class BookKeeping extends CommonObject if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); } - + return $obj->label; - + } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); @@ -1483,9 +1477,9 @@ class BookKeeping extends CommonObject * @return string Account desc */ function get_compte_desc($account = null) - { + { global $conf; - + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; @@ -1495,7 +1489,7 @@ class BookKeeping extends CommonObject $sql .= " AND aa.active = 1"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1503,12 +1497,10 @@ class BookKeeping extends CommonObject if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); } - - if(empty($obj->category)){ + if(empty($obj->category)){ return $obj->label; }else{ return $obj->label.' ('.$obj->category.')'; - } } else { $this->error = "Error " . $this->db->lasterror(); diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php deleted file mode 100644 index 112bde76038..00000000000 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ /dev/null @@ -1,383 +0,0 @@ - - * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2015 Ari Elbaz (elarifr) - * Copyright (C) 2016 Marcos García - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \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; - } - } -} diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index baa70bf51e8..eca3be1d477 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("bills"); @@ -39,9 +39,7 @@ $id = GETPOST('id'); // Security check if ($user->societe_id > 0) accessforbidden(); - - - + /* * Actions */ @@ -84,7 +82,7 @@ if ($cancel == $langs->trans("Cancel")) { */ $form = new Form($db); $facture_static = new Facture($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); if (! empty($id)) { $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,"; @@ -96,50 +94,50 @@ if (! empty($id)) { $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture"; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy - + dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); - + if ($result) { $num_lines = $db->num_rows($result); $i = 0; - + if ($num_lines) { - + $objp = $db->fetch_object($result); - + print '' . "\n"; print ''; print ''; - + print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup'); - + dol_fiche_head(); - + print '
'; - + // Ref facture print ''; $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print ''; print ''; - + print ''; print ''; print ''; print '
' . $langs->trans("Invoice") . '' . $facture_static->getNomUrl(1) . '
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; - print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; } else { print "Error"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 52b3a31d6f0..f3763dd9ca0 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -28,7 +28,7 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -77,7 +77,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); /* @@ -254,14 +254,14 @@ if ($result) { print $langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formventilation->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '
'; $moreforfilter = ''; - - print '
'; + + print '
'; print ''."\n"; - + print ''; print ''; print ''; @@ -278,7 +278,7 @@ if ($result) { $searchpicto=$form->showFilterButtons(); print $searchpicto; print "\n"; - + print ''; print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); @@ -303,16 +303,16 @@ if ($result) { $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->rowid; - + $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->product_type; $product_static->label = $objp->product_label; - + print ''; print ''; - + // Ref Invoice print ''; @@ -324,13 +324,13 @@ if ($result) { print $product_static->getNomUrl(1); if ($objp->product_label) print '
'.$objp->product_label; print ''; - + print ''; - + print ''; print ''; print ''; - + print ''; - + print ''; - + print ''; print ""; $i ++; } - + print "
' . $objp->rowid . '' . $facture_static->getNomUrl(1) . ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description); print '' . price($objp->total_ht) . '' . price($objp->tva_tx) . ''; @@ -338,20 +338,20 @@ if ($result) { print img_edit(); print ''; print '' . $objp->country .'' . $objp->tva_intra . '
"; print "
"; - + if ($nbtotalofrecords > $limit) { print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index bbd875e0dbf..8af289f2c99 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -30,7 +30,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -85,7 +85,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $accounting = new AccountingAccount($db); $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); @@ -101,7 +101,7 @@ if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { - $search_lineid = ''; + $search_lineid = ''; $search_ref = ''; $search_invoice = ''; $search_label = ''; @@ -241,7 +241,7 @@ if ($result) { $i = 0; $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -254,8 +254,7 @@ if ($result) { //if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); //if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); - - + print '
' . "\n"; print ''; if ($optioncss != '') print ''; @@ -264,16 +263,16 @@ if ($result) { print ''; print ''; print ''; - + print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print $langs->trans("DescVentilTodoCustomer") . '

'; if ($msg) print $msg.'
'; - + $moreforfilter = ''; - - print '
'; + + print '
'; print ''."\n"; // We add search filter @@ -309,7 +308,7 @@ if ($result) { if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"'); print "\n"; - + $facture_static = new Facture($db); $product_static = new Product($db); $form = new Form($db); @@ -330,7 +329,7 @@ if ($result) { $facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - + $code_sell_p_notset = ''; $objp->aarowid_suggest = $objp->aarowid; @@ -350,30 +349,30 @@ if ($result) { if (! empty($objp->code_sell)) { $objp->code_sell_p = $objp->code_sell; // Code on product } else { - $code_sell_p_notset = 'color:orange'; + $code_sell_p_notset = 'color:orange'; } if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red'; - + // $objp->code_sell_p is now code of product/service // $objp->code_sell_l is now default code of product/service - + print ''; // Line id print ''; - + // Ref Invoice print ''; print ''; - + // Ref Product print ''; - + print ''; - + // Vat rate if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; print ''; - + // Current account print ''; print '
' . $objp->rowid . '' . $facture_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; if ($product_static->id) print $product_static->getNomUrl(1); if ($objp->product_label) print '
'.$objp->product_label; print '
'; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; @@ -383,14 +382,14 @@ if ($result) { print ''; print price($objp->total_ht); print ''; print price($objp->tva_tx_line); print ''; print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown")); @@ -403,7 +402,7 @@ if ($result) { // Suggested accounting account print ''; - 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 ''; @@ -414,7 +413,7 @@ if ($result) { } print '
'; print "
"; - + print ''; } else { print $db->error(); diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php index 52440385e50..e37b35f1003 100644 --- a/htdocs/accountancy/expensereport/card.php +++ b/htdocs/accountancy/expensereport/card.php @@ -30,7 +30,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("bills"); @@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) { // Create $form = new Form($db); $expensereport_static = new ExpenseReport($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); if (! empty($id)) { $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,"; @@ -135,7 +135,7 @@ if (! empty($id)) { print '' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . ''; print '' . $langs->trans("Account") . ''; - print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print ''; print ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index a38194356bd..c062d4e09c2 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -167,7 +167,7 @@ print '
'; //print '
'; // TODO Remove this. Should be done always. -if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; +if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; //print '
'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 6d0ffbd4476..b3936bbf1a6 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -27,7 +27,7 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -74,7 +74,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); /* @@ -226,7 +226,7 @@ if ($result) { print $langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 72316e4c4d6..b1a86c96838 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -83,7 +83,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $accounting = new AccountingAccount($db); @@ -343,7 +343,7 @@ if ($result) { // Suggested accounting account print ''; - 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 ''; print ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index d1602bedf00..ea98d678671 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; @@ -63,7 +64,10 @@ $langs->load("accountancy"); $langs->load("trips"); $langs->load("hrm"); +// Old system menu $id_bank_account = GETPOST('id_account', 'int'); +// Multi journal +$code_journal = GETPOST('code_journal', 'alpha'); $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); @@ -83,9 +87,9 @@ if ($user->societe_id > 0 && empty($id_bank_account)) /* * Actions */ - + $error = 0; - + $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; @@ -134,9 +138,21 @@ $paymentsalstatic = new PaymentSalary($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); // Get code of finance journal -$bank_code_journal = new Account($db); -$result = $bank_code_journal->fetch($id_bank_account); -$journal = $bank_code_journal->accountancy_journal; +$journal = ''; +$bankstatic = new Account($db); +$bankstatic->fetch($id_bank_account); +$bankstatic->rowid; +$bankstatic->number; +$bankstatic->label; +$bankstatic->fk_accountancy_journal; + +$accountingjournalstatic = new AccountingJournal($db); +if(! empty($id_bank_account)) { + $accountingjournalstatic->fetch($bankstatic->fk_accountancy_journal); +} else { + $accountingjournalstatic->fetch('',$code_journal); +} +$journal = $accountingjournalstatic->code; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); @@ -179,7 +195,7 @@ if ($result) { 'name' => $obj->name, 'code_compta' => $compta_soc, ); - + $compta_user = (! empty($obj->accountancy_code) ? $obj->accountancy_code : $account_employee); $tabuser[$obj->rowid] = array ( @@ -205,8 +221,8 @@ if ($result) { if (is_array($links)) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport'))) // So we excluded 'company' here + + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert'))) // So we excluded 'company' here { // We save tabtype for a future use, to remember what kind of payment it is $tabtype[$obj->rowid] = $links[$key]['type']; @@ -330,11 +346,11 @@ if (! $error && $action == 'writebookkeeping') { $error = 0; foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank - + $errorforline = 0; - + $db->begin(); - + // Bank if (! $errorforline) { @@ -473,6 +489,9 @@ if (! $error && $action == 'writebookkeeping') { } $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; + } else if ($tabtype[$key] == 'banktransfert') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? $bookkeeping->doc_ref = $k; @@ -705,17 +724,17 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); - + llxHeader('', $langs->trans("FinanceJournal")); - $nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1); + $nom = $langs->trans("FinanceJournal") . ' - ' . $bankstatic->getNomUrl(1); $builddate = time(); //$description = $langs->trans("DescFinanceJournal") . '
'; $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); $varlink = 'id_account=' . $id_bank_account; - + journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { @@ -852,9 +871,9 @@ if (empty($action) || $action == 'view') { else print $accountoshow; print ""; if ($val['soclib'] == '') { - print "" . $bank_code_journal->label . " - " . $val["ref"] . ""; + print "" . $bankstatic->label . " - " . $val["ref"] . ""; } else { - print "" . $bank_code_journal->label . " - " . $val['soclib'] . ""; + print "" . $bankstatic->label . " - " . $val['soclib'] . ""; } print "" . $val["type_payment"] . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index b7c5979aa7a..47a99c88496 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -1,11 +1,11 @@ * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; // Langs $langs->load("bills"); @@ -52,11 +52,11 @@ if ($user->societe_id > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (! GETPOST('cancel', 'alpha')) { if ($codeventil < 0) $codeventil = 0; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; - + $resql = $db->query($sql); if (! $resql) { setEventMessages($db->lasterror(), null, 'errors'); @@ -85,7 +85,7 @@ if ($cancel == $langs->trans("Cancel")) { // Create $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); if (! empty($id)) { $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; @@ -107,41 +107,41 @@ if (! empty($id)) { if ($num_lines) { $objp = $db->fetch_object($result); - + print '
' . "\n"; print ''; print ''; - + print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup'); - + dol_fiche_head(); - + print ''; - + // ref invoice print ''; $facturefournisseur_static->ref = $objp->facnumber; $facturefournisseur_static->id = $objp->facid; print ''; print ''; - + print ''; print ''; print ''; print ''; print ''; print '
' . $langs->trans("BillsSuppliers") . '' . $facturefournisseur_static->getNomUrl(1) . '
' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->description)) . '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; - print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; - + dol_fiche_end(); - + print '
'; print ''; print '     '; print ''; print '
'; - + print '
'; } else { print "Error"; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 1a95262f861..2757b6d8aec 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; @@ -76,7 +76,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); /* @@ -237,7 +237,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 061e465b1e7..9c822425a1c 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -1,10 +1,10 @@ - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent s - * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -85,7 +85,7 @@ if ($user->societe_id > 0) if (! $user->rights->accounting->bind->write) accessforbidden(); -$formventilation = new FormVentilation($db); +$formaccounting = new FormAccounting($db); $accounting = new AccountingAccount($db); // TODO: we should need to check if result is a really exist accountaccount rowid..... $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); @@ -238,11 +238,11 @@ if ($result) { $i = 0; $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), @@ -251,8 +251,7 @@ if ($result) { //if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); //if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); - - + print '
' . "\n"; print ''; if ($optioncss != '') print ''; @@ -261,15 +260,15 @@ if ($result) { print ''; print ''; print ''; - + print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print $langs->trans("DescVentilTodoCustomer") . '

'; if ($msg) print $msg.'
'; - + $moreforfilter = ''; - + print '
'; print ''."\n"; @@ -329,7 +328,7 @@ if ($result) { $productfourn_static->id = $objp->product_id; $productfourn_static->type = $objp->type; $productfourn_static->label = $objp->product_label; - + $facturefourn_static->ref = $objp->ref; $facturefourn_static->id = $objp->facid; $facturefourn_static->type = $objp->type; @@ -347,14 +346,14 @@ if ($result) { $objp->aarowid_suggest = $aarowid_p; } if ($objp->code_buy_l == -1) $objp->code_buy_l=''; - + if (! empty($objp->code_buy)) { $objp->code_buy_p = $objp->code_buy; // Code on product } else { $code_buy_p_notset = 'color:orange'; } if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red'; - + // $objp->code_buy_p is now code of product/service // $objp->code_buy_l is now default code of product/service @@ -362,23 +361,23 @@ if ($result) { // Line id print ''; - + // Ref Invoice print ''; print ''; - + print ''; - + // Ref product print ''; - + // Description print ''; - + // Colonne choix ligne a ventiler print ''; - print ''; + print ''; print ''; print ''; } else @@ -525,7 +523,7 @@ if ($action == 'create') { print ''; print ''; } @@ -957,43 +955,42 @@ else //print '
'; - + print '
' . $objp->rowid . '' . $facturefourn_static->getNomUrl(1) . ''; print $objp->invoice_label; print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; if ($productfourn_static->id) print $productfourn_static->getNomUrl(1); if ($objp->product_label) print '
'.$objp->product_label; print '
'; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); @@ -409,9 +408,9 @@ if ($result) { // Suggested accounting account print ''; - 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 ''; print 'aarowid ? "checked" : "") . '/>'; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index d6ee9958162..a7775332812 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2016 Charlie Benke +/* Copyright (C) 2002 Rodolphe Quiedeville + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2016 Charlie Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,13 @@ class AdherentType extends CommonObject public $table_element = 'adherent_type'; public $element = 'adherent_type'; public $picto = 'group'; - + + /** + * @var string + * @deprecated Use label + * @see label + */ + public $libelle; /** @var string Label */ public $label; /** @@ -81,12 +87,13 @@ class AdherentType extends CommonObject global $conf; $this->statut=(int) $this->statut; + $this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label)); $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; $sql.= "libelle"; $sql.= ", entity"; $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->libelle)."'"; + $sql.= "'".$this->db->escape($this->label)."'"; $sql.= ", ".$conf->entity; $sql.= ")"; @@ -117,12 +124,12 @@ class AdherentType extends CommonObject $error=0; - $this->libelle=trim($this->libelle); + $this->label=(!empty($this->libelle)?trim($this->libelle):trim($this->label)); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; $sql.= "SET "; $sql.= "statut = ".$this->statut.","; - $sql.= "libelle = '".$this->db->escape($this->libelle) ."',"; + $sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "note = '".$this->db->escape($this->note)."',"; $sql.= "vote = '".$this->db->escape($this->vote)."',"; @@ -307,7 +314,7 @@ class AdherentType extends CommonObject { return ''; } - + /** * getMailOnValid * diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 9ea36bf579a..3b1bda41250 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -106,7 +106,7 @@ class Members extends DolibarrApi $sql.= ' AND t.fk_adherent_type='.$typeid; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -115,7 +115,7 @@ class Members extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -132,9 +132,10 @@ class Members extends DolibarrApi { $i=0; $num = $db->num_rows($result); - while ($i < min($limit, $num)) + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($result); $member = new Adherent($this->db); if($member->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($member); diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php new file mode 100644 index 00000000000..18c828eb9e5 --- /dev/null +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -0,0 +1,322 @@ + + * + * 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 . + */ + +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; + } + +} diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 083ab4bda3b..31a40e96669 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -1,10 +1,10 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2015 Alexandre Spangaro +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="d.lastname"; } -$label=GETPOST("libelle","alpha"); +$label=GETPOST("label","alpha"); $subscription=GETPOST("subscription","int"); $vote=GETPOST("vote","int"); $comment=GETPOST("comment"); @@ -93,17 +93,17 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object = new AdherentType($db); - $object->libelle = trim($label); - $object->subscription = (int) trim($subscription); - $object->note = trim($comment); - $object->mail_valid = (boolean) trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->label = trim($label); + $object->subscription = (int) trim($subscription); + $object->note = trim($comment); + $object->mail_valid = (boolean) trim($mail_valid); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - if ($object->libelle) + if ($object->label) { $id=$object->create($user); if ($id > 0) @@ -131,7 +131,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) { $object = new AdherentType($db); $object->id = $rowid; - $object->libelle = trim($label); + $object->label = trim($label); $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = (boolean) trim($mail_valid); @@ -171,7 +171,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle, d.subscription, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql.= " WHERE d.entity IN (".getEntity().")"; @@ -180,11 +180,11 @@ if (! $rowid && $action != 'create' && $action != 'edit') { $num = $db->num_rows($result); $nbtotalofrecords = $num; - + $i = 0; $param = ''; - + print ''; if ($optioncss != '') print ''; print ''; @@ -193,14 +193,14 @@ if (! $rowid && $action != 'create' && $action != 'edit') print ''; print ''; print ''; - + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); - + $moreforfilter = ''; - + print '
'; print ''."\n"; - + print ''; print ''; print ''; @@ -214,7 +214,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $objp = $db->fetch_object($result); print ''; print ''; - print ''; + print ''; print ''; print ''; if ($user->rights->adherent->configurer) @@ -226,7 +226,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') } print "
'.$langs->trans("Ref").''.$langs->trans("Label").'
'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.''.dol_escape_htmltag($objp->libelle).''.dol_escape_htmltag($objp->label).''.yn($objp->subscription).''.yn($objp->vote).'
"; print '
'; - + print ''; } else @@ -256,7 +256,7 @@ if ($action == 'create') print ''; print ''; - print ''; + print ''; print ''; - + print '
'; print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); - + $moreforfilter = ''; - + print '
'; print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription",1,1); @@ -316,10 +316,10 @@ if ($rowid > 0) $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'rowid', $linkback); - + print '
'; print '
'; - + print ''; print '
'.$langs->trans("SubscriptionRequired").''; @@ -347,7 +347,7 @@ if ($rowid > 0) print '
'; print '
'; - + dol_fiche_end(); @@ -460,7 +460,7 @@ if ($rowid > 0) { $membertype=new AdherentType($db); $result=$membertype->fetch($type); - $titre.=" (".$membertype->libelle.")"; + $titre.=" (".$membertype->label.")"; } $param="&rowid=".$rowid; @@ -478,12 +478,12 @@ if ($rowid > 0) print '
'; print '
'."\n"; @@ -548,7 +548,7 @@ if ($rowid > 0) // Type /*print ''; */ @@ -613,7 +613,7 @@ if ($rowid > 0) print "
'; $membertypestatic->id=$objp->type_id; - $membertypestatic->libelle=$objp->type; + $membertypestatic->label=$objp->type; print $membertypestatic->getNomUrl(1,12); print '
\n"; print ''; print ''; - + if ($num > $conf->liste_limit) { print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,''); @@ -652,7 +652,7 @@ if ($rowid > 0) print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; print $form->selectyesno("subscription",$object->subscription,1); diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 8ed1e3cd9ac..afe60acff2e 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -166,7 +166,7 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); $head = bank_admin_prepare_head(null); -dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), 0, 'account'); +dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); $var=true; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 2d03c51e34d..794483350f1 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -71,7 +71,7 @@ print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup') $head = bank_admin_prepare_head(null); -dol_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), 0, 'account'); +dol_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), -1, 'account'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index fd1da0c328b..bc55eb4b9f6 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -27,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; @@ -71,7 +72,7 @@ if ($action == 'updateMask') if ($action == 'setmod') { - dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON",$value,'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON",$value, 'chaine', 0, '', $conf->entity); } if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') @@ -105,7 +106,7 @@ $linkback=''.$langs->trans("BackToM print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); $head = bank_admin_prepare_head(null); -dol_fiche_head($head, 'checkreceipts', $langs->trans("BankSetupModule"), 0, 'account'); +dol_fiche_head($head, 'checkreceipts', $langs->trans("BankSetupModule"), -1, 'account'); /* * Numbering module diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index a4680f4d16e..d60144a3492 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -32,6 +32,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 37c0b9bccde..4c0a9572761 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -24,6 +24,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 28db9ef8b49..913fcf75de6 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -1662,7 +1662,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); foreach ($fieldlist as $field => $value) { @@ -1811,7 +1811,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { $fieldname = $fieldlist[$field]; $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); - print $formaccountancy->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d31b788a1ab..3c89960ede6 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index b8626827595..eefe5747abd 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index d89c9711e3f..77230dc3f68 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index d99fd9456d9..3ce82ce59cb 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 143c54ec24d..74081266f43 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -30,6 +30,7 @@ */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index 86d963ed54f..c3e8bad9f6d 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("admin"); $langs->load("loan"); @@ -77,7 +77,7 @@ if ($action == 'update') llxHeader(); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup'); @@ -106,7 +106,7 @@ foreach ($list as $key) print ''; 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 { diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index b9e5df738ad..caea3bef9f7 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -841,7 +841,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccountancy = new FormVentilation($db); + if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); foreach ($fieldlist as $field => $value) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index d318566ff61..21e3afb3921 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * 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 @@ -68,7 +69,7 @@ llxHeader('',$langs->trans("Setup"),$help_url); print ''."\n".''; $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); @@ -165,6 +166,7 @@ foreach ($modulesdir as $dir) // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { + if (!is_array($familyinfo)) $familyinfo=array(); $familyinfo = array_merge($familyinfo, $objMod->familyinfo); $familykey = key($objMod->familyinfo); } else { @@ -305,13 +307,13 @@ if ($objMod->isCoreOrExternalModule() == 'external') // Define text of description of module $text=''; - + if ($mode == 'desc') { if ($moduledesc) $text.=$moduledesc.'

'; - + $text.=''.$langs->trans("Version").': '.$version; - + $textexternal=''; if ($objMod->isCoreOrExternalModule() == 'external') { @@ -346,8 +348,8 @@ if ($mode == 'desc') $text.=''.$langs->trans("LastActivationIP").': '; $text.= $ip; $text.='
'; - } - + } + $moduledesclong=$objMod->getDescLong(); if ($moduledesclong) $text.='

'.$moduledesclong.'
'; } @@ -360,9 +362,9 @@ if ($mode == 'feature') $text.='
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby); else $text.=$langs->trans("None"); - + $text.='


'; - + $text.=''.$langs->trans("AddRemoveTabs").': '; if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) { @@ -375,9 +377,9 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddDictionaries").': '; if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) { @@ -389,9 +391,9 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddBoxes").': '; if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) { @@ -403,27 +405,27 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddModels").': '; if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) { $text.=$langs->trans("Yes"); } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddSubstitutions").': '; if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) { $text.=$langs->trans("Yes"); } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddSheduledJobs").': '; if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) { @@ -435,55 +437,72 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddTriggers").': '; if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) { $text.=$langs->trans("Yes"); } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddHooks").': '; if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) { - $i=0; - foreach($objMod->module_parts['hooks'] as $val) + $i=0; + foreach($objMod->module_parts['hooks'] as $key => $val) { - $text.=($i?', ':'').($val); - $i++; + if ($key == 'entity') continue; + + // For special values + if ($key == 'data') + { + if (is_array($val)) + { + foreach($val as $value) + { + $text.=($i?', ':'').($value); + $i++; + } + + continue; + } + } + + $text.=($i?', ':'').($val); + $i++; } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddPermissions").': '; if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) { $i=0; foreach($objMod->rights as $val) { - $text.=($i?', ':'').($val[1]); - $i++; + $text.=($i?', ':'').($val[1]); + $i++; } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddMenus").': '; if (isset($objMod->menu) && ! empty($objMod->menu)) // objMod can be an array or just an int 1 { $text.=$langs->trans("Yes"); } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddExportProfiles").': '; if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) { @@ -495,9 +514,9 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddImportProfiles").': '; if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) { @@ -509,9 +528,9 @@ if ($mode == 'feature') } } else $text.=$langs->trans("No"); - + $text.='
'; - + $text.='
'.$langs->trans("AddOtherPagesOrServices").': '; $text.=$langs->trans("DetectionNotPossible"); } diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 6a9884e263c..7c8413a28a6 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; $langs->load("admin"); diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php index 8f115d3963b..85603de2ae5 100644 --- a/htdocs/admin/salaries.php +++ b/htdocs/admin/salaries.php @@ -26,7 +26,7 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("admin"); $langs->load("salaries"); @@ -76,7 +76,7 @@ if ($action == 'update') llxHeader('',$langs->trans('SalariesSetup')); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup'); @@ -109,7 +109,7 @@ foreach ($list as $key) print '
'; 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 { diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index de128184d18..d408657ac8c 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 030a507ce20..acce3a38c7c 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -29,6 +29,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 345f622a533..8a8d2a181a4 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/supplier_proposal.lib.php'; $langs->load("admin"); @@ -274,7 +275,7 @@ foreach ($dirmodels as $reldir) while (($file = readdir($handle))!==false) { - if (substr($file, 0, 21) == 'mod_supplier_proposal_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 22) == 'mod_supplier_proposal_' && substr($file, dol_strlen($file)-3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file)-4); diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index dbdce59c3c5..59796919a8b 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -27,7 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load('admin'); @@ -113,7 +113,7 @@ if ($action == 'update') { llxHeader(); $form=new Form($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup'); @@ -216,7 +216,7 @@ foreach ($list as $key) print ''; 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 { diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index c22a12fee61..218ab58467e 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -43,12 +43,29 @@ if ($action == 'setproductionmode') if (dolibarr_set_const($db, 'API_PRODUCTION_MODE', $status, 'chaine', 0, '', $conf->entity) > 0) { - $result = dol_mkdir($conf->api->dir_temp); - if ($result < 0) - { - setEventMessages($langs->trans("ErrorFaildToCreateDir", $conf->api->dir_temp), null, 'errors'); - } - else + $error=0; + + if ($status == 1) + { + $result = dol_mkdir($conf->api->dir_temp); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailedToCreateDir", $conf->api->dir_temp), null, 'errors'); + $error++; + } + } + else + { + // Delete the cache file otherwise it does not update + $result = dol_delete_file($conf->api->dir_temp.'/routes.php'); + if ($result < 0) + { + setEventMessages($langs->trans("ErrorFailedToDeleteFile", $conf->api->dir_temp.'/routes.php'), null, 'errors'); + $error++; + } + } + + if (!$error) { header("Location: ".$_SERVER["PHP_SELF"]); exit; diff --git a/htdocs/api/class/api_dictionaryevents.class.php b/htdocs/api/class/api_dictionaryevents.class.php new file mode 100644 index 00000000000..23d7e8e5dba --- /dev/null +++ b/htdocs/api/class/api_dictionaryevents.class.php @@ -0,0 +1,100 @@ + + * + * 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 . + */ + +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; + } + +} diff --git a/htdocs/api/index.php b/htdocs/api/index.php index fa96da6b139..1e04590da14 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -1,6 +1,7 @@ +/* Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -143,10 +144,9 @@ foreach ($modulesdir as $dir) * * Search files named api_.class.php into /htdocs//class directory * - * @todo : take care of externals module! * @todo : use getElementProperties() function ? */ - $dir_part = DOL_DOCUMENT_ROOT.'/'.$moduledirforclass.'/class/'; + $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); $handle_part=@opendir(dol_osencode($dir_part)); if (is_resource($handle_part)) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 376df238a95..dccd98ebe96 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -23,14 +23,14 @@ /** * API class for Agenda Events * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class AgendaEvents extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( ); @@ -40,7 +40,7 @@ class AgendaEvents extends DolibarrApi */ public $actioncomm; - + /** * Constructor */ @@ -55,61 +55,61 @@ class AgendaEvents extends DolibarrApi * Get properties of a Agenda Events object * * Return an array with Agenda Events informations - * + * * @param int $id ID of Agenda Events * @return array|mixed Data without useless information * * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); } - + $result = $this->actioncomm->fetch($id); if( ! $result ) { throw new RestException(404, 'Agenda Events not found'); } - + if(! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - + if( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $this->actioncomm->fetchObjectLinked(); return $this->_cleanObjectDatas($this->actioncomm); } /** * List Agenda Events - * + * * Get a list of Agenda Events - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number * @param string $user_ids User ids filter field (owners of event). Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.date_creation:<:'20160101')" + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')" * @return array Array of Agenda Events objects */ - function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0, $sqlfilters = '') { + function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; - + $obj_ret = array(); // case of external user $socid = 0; - if (! empty(DolibarrApiAccess::$user->societe_id)) $socid = DolibarrApiAccess::$user->societe_id; - + if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; + // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - + $sql = "SELECT t.id as rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; $sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')'; @@ -121,7 +121,7 @@ class AgendaEvents extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -130,7 +130,7 @@ class AgendaEvents extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -143,7 +143,7 @@ class AgendaEvents extends DolibarrApi } $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -181,7 +181,7 @@ class AgendaEvents extends DolibarrApi if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - + // Check mandatory fields $result = $this->_validate($request_data); @@ -198,18 +198,18 @@ class AgendaEvents extends DolibarrApi if ($this->actioncomm->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating event", array_merge(array($this->actioncomm->error), $this->actioncomm->errors)); } - + return $this->actioncomm->id; } - + /** * Update Agenda Event general fields (won't touch lines of expensereport) * * @param int $id Id of Agenda Event to update - * @param array $request_data Datas - * - * @return int + * @param array $request_data Datas + * + * @return int */ /* function put($id, $request_data = NULL) { @@ -219,12 +219,12 @@ class AgendaEvents extends DolibarrApi if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - + $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -232,19 +232,19 @@ class AgendaEvents extends DolibarrApi if ($field == 'id') continue; $this->expensereport->$field = $value; } - + if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); - + return false; } */ - + /** * Delete Agenda Event * * @param int $id Agenda Event ID - * + * * @return array */ function delete($id) @@ -252,49 +252,49 @@ class AgendaEvents extends DolibarrApi if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - + $result = $this->actioncomm->fetch($id); - + if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - + if( ! $result ) { throw new RestException(404, 'Agenda Event not found'); } - + if( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); } - + return array( 'success' => array( 'code' => 200, 'message' => 'Agenda Event deleted' ) ); - + } - + /** * Validate fields before create or update object - * + * * @param array $data Array with data to verify - * @return array + * @return array * @throws RestException */ function _validate($data) { $event = array(); - foreach (Events::$FIELDS as $field) { + foreach (AgendaEvents::$FIELDS as $field) { if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $event[$field] = $data[$field]; - + } return $event; } diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index fd3c1ec9825..f98c48b1aba 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -3,8 +3,8 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Vinícius Nogueira - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro * @@ -42,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; @@ -195,7 +195,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_num_releve=''; $search_conciliated=''; $thirdparty=''; - + $account=""; if ($id > 0 || ! empty($ref)) $account=$object->id; } @@ -345,7 +345,7 @@ $paymentsupplierstatic=new PaiementFourn($db); $paymentvatstatic=new TVA($db); $paymentsalstatic=new PaymentSalary($db); $donstatic=new Don($db); -$expensereportstatic=new ExpenseReport($db); +$paymentexpensereportstatic=new PaymentExpenseReport($db); $bankstatic=new Account($db); $banklinestatic=new AccountLine($db); @@ -436,7 +436,6 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Conciliate").''; } } - print ''; } } @@ -548,9 +547,9 @@ if ($resql) { $var=True; $num = $db->num_rows($resql); - + $arrayofselected=is_array($toselect)?$toselect:array(); - + // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -559,16 +558,14 @@ if ($resql) //if ($user->rights->bank->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - - + // Confirmation delete if ($action == 'delete') { $text=$langs->trans('ConfirmDeleteTransaction'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } - - + // Lines of title fields print '
'."\n"; if ($optioncss != '') print ''; @@ -582,7 +579,7 @@ if ($resql) print ''; print ''; if (GETPOST('bid')) print ''; - + // Form to reconcile if ($user->rights->banque->consolidate && $action == 'reconcile') { @@ -657,11 +654,10 @@ if ($resql) }); }); - - '; - + '; + $i = 0; - + // Title $bankcateg=new BankCateg($db); $morehtml='
'; @@ -669,7 +665,7 @@ if ($resql) $morehtml.=''; $morehtml.='/'.$nbtotalofpages.' '; $morehtml.='
'; - + $picto='title_bank'; if ($id > 0 || ! empty($ref)) $picto=''; if (GETPOST("bid")) @@ -681,13 +677,12 @@ if ($resql) { print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); } - + // We can add page now to param if ($page != '') $param.='&page='.urlencode($page); - - + $moreforfilter = ''; - + $moreforfilter.='
'; $moreforfilter .= $langs->trans('DateOperationShort').' : '; $moreforfilter .= '
'.$langs->trans('From') . ' '; @@ -695,7 +690,7 @@ if ($resql) //$moreforfilter .= ' - '; $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; - + $moreforfilter.='
'; $moreforfilter .= $langs->trans('DateValueShort').' : '; $moreforfilter .= '
'.$langs->trans('From') . ' '; @@ -703,7 +698,7 @@ if ($resql) //$moreforfilter .= ' - '; $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; @@ -715,10 +710,10 @@ if ($resql) print $moreforfilter; print '
'."\n"; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; @@ -803,7 +798,6 @@ if ($resql) print ''; print "\n"; - // Fields title print ''; if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); @@ -838,14 +832,13 @@ if ($resql) print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - + $balance = 0; // For balance $balancecalculated = false; - + // Loop on each record $sign = 1; - + $totalarray=array(); while ($i < min($num,$limit)) { @@ -885,9 +878,9 @@ if ($resql) $balancecalculated=true; } - + $balance = price2num($balance + ($sign * $objp->amount),'MT'); - + if (empty($cachebankaccount[$objp->bankid])) { $bankaccounttmp = new Account($db); @@ -899,8 +892,6 @@ if ($resql) { $bankaccount = $cachebankaccount[$objp->bankid]; } - - print ''; @@ -975,9 +966,9 @@ if ($resql) } elseif ($links[$key]['type']=='payment_expensereport') { - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - print ''; + $paymentexpensereportstatic->id=$links[$key]['url_id']; + $paymentexpensereportstatic->ref=$links[$key]['url_id']; + print ' '.$paymentexpensereportstatic->getNomUrl(2); } elseif ($links[$key]['type']=='banktransfert') { @@ -1012,19 +1003,19 @@ if ($resql) } elseif ($links[$key]['type']=='company') { - + } elseif ($links[$key]['type']=='user') { - + } elseif ($links[$key]['type']=='member') { - + } elseif ($links[$key]['type']=='sc') { - + } else { @@ -1044,11 +1035,10 @@ if ($resql) print ''; } } - print ''; if (! $i) $totalarray['nbfield']++; } - + // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { @@ -1089,7 +1079,7 @@ if ($resql) print '\n"; if (! $i) $totalarray['nbfield']++; } - + // Third party if (! empty($arrayfields['bu.label']['checked'])) { @@ -1114,7 +1104,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - + // Bank account if (! empty($arrayfields['ba.ref']['checked'])) { @@ -1123,7 +1113,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } - + // Debit if (! empty($arrayfields['b.debit']['checked'])) { @@ -1137,6 +1127,7 @@ if ($resql) if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; } + // Credit if (! empty($arrayfields['b.credit']['checked'])) { @@ -1150,7 +1141,7 @@ if ($resql) if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; } - + // Balance if (! empty($arrayfields['balance']['checked'])) { @@ -1169,8 +1160,9 @@ if ($resql) { print ''; } + if (! $i) $totalarray['nbfield']++; } - + if (! empty($arrayfields['b.num_releve']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - + // Action edit/delete print '
'.($objp->num_chq?$objp->num_chq:"")."-'; @@ -1197,7 +1189,7 @@ if ($resql) print ''; // Transaction reconciliated or edit link @@ -1254,7 +1246,7 @@ if ($resql) $i++; } - + // Show total line if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) { @@ -1277,7 +1269,7 @@ if ($resql) print "
"; print "
"; - + print ''; $db->free($resql); } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index a8263a74916..2cb90b6a44a 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; @@ -281,8 +280,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights-> $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); -if (! empty($conf->accounting->enabled)) $formaccountancy2 = New FormAccounting($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; @@ -511,7 +509,7 @@ if ($action == 'create') { print '
'.$langs->trans("AccountancyCode").''; - 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 '
'.$langs->trans("AccountancyJournal").''; - 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 '
'; - + // Accountancy code $tdextra = ' class="titlefieldcreate"'; - + if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) { $tdextra = ' class="fieldrequired titlefieldcreate"'; } - + print ''.$langs->trans("AccountancyCode").''; print ''; - + // Accountancy journal if (! empty($conf->accounting->enabled)) { print ''; print ''; } - + print '
'; if (!empty($conf->accounting->enabled)) { - print $formaccountancy->select_account($object->account_number, 'account_number', 1, '', 1, 1); + print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1); } else { print 'account_number).'">'; } print '
'.$langs->trans("AccountancyJournal").''; - 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 '
'; - - + if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT) { print '
'; - + //print '
'; - + print ''; // If bank account diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 4875ac593c6..20c49c71468 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $langs->load("compta"); @@ -180,7 +180,7 @@ if ($action == 'delete') llxHeader("",$langs->trans("VariousPayment")); $form = new Form($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); if ($id) { @@ -271,9 +271,9 @@ if ($action == 'create') { print ''; print ''; - } + } else // For external software { print ''; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 6bc4f628ba9..aa315e5c854 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -276,7 +276,7 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; - + // Ref print '
'.$langs->trans("AccountAccounting").''; - 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 '
'.$langs->trans("AccountAccounting").'
'.$langs->trans('NotePublic').''.$langs->trans('NotePublic').''; $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8,'90%'); @@ -288,7 +288,7 @@ if ($action == 'create') if (empty($user->societe_id)) { print '
'.$langs->trans('NotePrivate').''.$langs->trans('NotePrivate').''; $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8a4aae44c23..b739e551b9d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1405,7 +1405,7 @@ if (empty($reshook)) $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); - $prod_entry_mode = GETPOST('prod_entry_mode'); + $prod_entry_mode = GETPOST('prod_entry_mode','alpha'); if ($prod_entry_mode == 'free') { $idprod=0; @@ -2483,7 +2483,8 @@ if ($action == 'create') else { print '
'; - $tmp=' '; + if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp=' '; + else $tmp=' '; $text = $tmp.$langs->trans("InvoiceAvoir") . ' '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); @@ -3909,12 +3910,12 @@ else if ($id > 0 || ! empty($ref)) if ($object->situation_cycle_ref && $object->statut == 0) { print '
'; - print '
'; + print ''; print ''; print ''; print ''; - print ''; + print '
'; print ''; @@ -4185,7 +4186,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print ''; + print ''; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index b09bd7f60f3..cb43c05680b 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -141,7 +141,7 @@ if (empty($reshook)) if (GETPOST('cancel')) $action=''; // Set note - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 0881ce061dc..cdc5eb2e545 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -309,9 +309,11 @@ if (empty($reshook)) * View */ +$form=new Form($db); + + llxHeader('', $langs->trans("Payment")); -$form=new Form($db); if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') @@ -575,6 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //print ''; print ''; print ''; print "\n"; - + print ''; print ''; if (! empty($conf->global->DONATION_ART200)) { @@ -414,7 +414,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY)) print ''; } print ''; - + print ''; print ''; if (! empty($conf->global->DONATION_ART238)) { @@ -427,7 +427,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY)) print ''; } print ''; - + print ''; print ''; if (! empty($conf->global->DONATION_ART885)) { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index fe546cd1064..dff27139581 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2017 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -37,9 +37,12 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +if (! empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +} $langs->load("trips"); $langs->load("bills"); @@ -153,10 +156,10 @@ if (empty($reshook)) { if ($object->id > 0) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later + // Because createFromClone modifies the object, we must clone it so that we can restore it later if it fails $orig = clone $object; - $result=$object->createFromClone($socid); + $result=$object->createFromClone(GETPOST('fk_user_author','int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -647,14 +650,14 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->approve) { $object = new ExpenseReport($db); $object->fetch($id); - + $result = $object->setDeny($user,GETPOST('detail_refuse')); - + if ($result > 0) { // Define output language @@ -674,11 +677,11 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); @@ -714,10 +717,10 @@ if (empty($reshook)) array_push($mimetype,"application/pdf"); } */ - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -767,17 +770,17 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - + //var_dump($user->id == $object->fk_user_validator);exit; if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); - + if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author) { $result = $object->set_cancel($user,GETPOST('detail_cancel')); - + if ($result > 0) { // Define output language @@ -797,16 +800,16 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); @@ -891,7 +894,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); @@ -899,7 +902,7 @@ if (empty($reshook)) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { $result = $object->setStatut(0); - + if ($result > 0) { // Define output language @@ -919,7 +922,7 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -935,14 +938,14 @@ if (empty($reshook)) setEventMessages("NOT_AUTHOR", '', 'errors'); } } - + if ($action == 'set_paid' && $id > 0 && $user->rights->expensereport->to_paid) { $object = new ExpenseReport($db); $object->fetch($id); - + $result = $object->set_paid($id, $user); - + if ($result > 0) { // Define output language @@ -962,46 +965,46 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - + if ($result > 0) { // Send mail - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($user->id); $emailFrom = $expediteur->email; - + if ($emailFrom && $emailTo) { $filename=array(); $filedir=array(); $mimetype=array(); // SUBJECT $subject = $langs->transnoentities("ExpenseReportPaid"); - + // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); - + // CONTENT $message = "Bonjour {$destinataire->firstname},\n\n"; $message.= "Votre note de frais \"{$object->ref}\" vient d'être payée.\n"; $message.= "- Payeur : {$expediteur->firstname} {$expediteur->lastname}\n"; $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; $message.= "Bien cordialement,\n' SI"; - + // Generate pdf before attachment $object->setDocModel($user,""); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); - + if ($mailfile) { // SEND @@ -1055,45 +1058,44 @@ if (empty($reshook)) if ($action == "addline" && $user->rights->expensereport->creer) { $error = 0; - + $db->begin(); - + $object_ligne = new ExpenseReportLine($db); - + $vatrate = GETPOST('vatrate'); $object_ligne->comments = GETPOST('comments'); $qty = GETPOST('qty','int'); if (empty($qty)) $qty=1; $object_ligne->qty = $qty; - + $up=price2num(GETPOST('value_unit'),'MU'); $object_ligne->value_unit = $up; - + $object_ligne->date = $date; - + $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); - + // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. if (empty($vatrate)) $vatrate = "0.000"; $object_ligne->vatrate = price2num($vatrate); - + $object_ligne->fk_projet = $fk_projet; - - + if (! GETPOST('fk_c_type_fees') > 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $action=''; } - + if ($vatrate < 0 || $vatrate == '') { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); $action=''; } - + /* Projects are never required. To force them, check module forceproject if ($conf->projet->enabled) { @@ -1103,7 +1105,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors'); } }*/ - + // Si aucune date n'est rentrée if (empty($object_ligne->date) || $object_ligne->date=="--") { @@ -1116,21 +1118,21 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors'); } - + // S'il y'a eu au moins une erreur if (! $error) { $object_ligne->fk_expensereport = $_POST['fk_expensereport']; - + $type = 0; // TODO What if service ? $seller = ''; // seller is unknown $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); - + $object_ligne->vatrate = price2num($vatrate); $object_ligne->total_ttc = $tmp[2]; $object_ligne->total_ht = $tmp[0]; $object_ligne->total_tva = $tmp[1]; - + $result = $object_ligne->insert(); if ($result > 0) { @@ -1144,10 +1146,10 @@ if (empty($reshook)) $db->rollback(); } } - + $action=''; } - + if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes" && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); @@ -1157,7 +1159,7 @@ if (empty($reshook)) $object_ligne->fetch(GETPOST("rowid")); $total_ht = $object_ligne->total_ht; $total_tva = $object_ligne->total_tva; - + $result=$object->deleteline(GETPOST("rowid"), $user); if ($result >= 0) { @@ -1190,12 +1192,12 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + if ($action == "updateligne" && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); - + $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees'); $projet_id = $fk_projet; @@ -1207,7 +1209,7 @@ if (empty($reshook)) // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. if (empty($vatrate)) $vatrate = "0.000"; $vatrate = price2num($vatrate); - + if (! GETPOST('fk_c_type_fees') > 0) { $error++; @@ -1220,7 +1222,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); $action=''; } - + if (! $error) { // TODO Use update method of ExpenseReportLine @@ -1258,7 +1260,7 @@ if (empty($reshook)) } } } - + // Actions to build doc $upload_dir = $conf->expensereport->dir_output; $permissioncreate = $user->rights->expensereport->creer; @@ -1278,6 +1280,8 @@ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); $projecttmp = new Project($db); +$paymentexpensereportstatic=new PaymentExpenseReport($db); +$bankaccountstatic = new Account($db); // Create if ($action == 'create') @@ -1320,7 +1324,7 @@ if ($action == 'create') print $s; print ''; print ''; - + print ''; print ''; print ''; print '
'; print '
'; print ''; + print ''; print ''; print ''; @@ -741,11 +744,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $totalrecudeposits+=$deposits; $i++; } + if ($i > 1) { // Print total print ''; - print ''; + print ''; + if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 0ea91dc2857..68f59d03cfa 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Charlie BENKE @@ -331,23 +331,24 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', ''); - + + $morehtmlref='
'; + + $userstatic=new User($db); + $userstatic->fetch($object->fk_user); + + $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); + $morehtmlref.='
'; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + print '
'; print '
'; print '
'.$arraytitle.''.$langs->trans('Date').'
'.$langs->trans('TotalTTC').''.$langs->trans('TotalTTC').'
'; - // Employee - print ''; - // Label - print ''; + print ''; print ""; print '
'.$langs->trans("Employee").''; - $usersal=new User($db); - $usersal->fetch($object->fk_user); - print $usersal->getNomUrl(1); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DateStartPeriod").''; @@ -390,9 +391,9 @@ if ($id) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'; - + print ''; - + dol_fiche_end(); diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php index 7b24a0762f3..03a69a764cf 100644 --- a/htdocs/compta/salaries/document.php +++ b/htdocs/compta/salaries/document.php @@ -6,7 +6,7 @@ * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; $langs->load("other"); +$langs->load("users"); $langs->load("salaries"); +$langs->load('hrm'); $langs->load("companies"); $id = GETPOST('id','int'); @@ -83,7 +85,6 @@ $form = new Form($db); llxHeader("",$langs->trans("SalaryPayment")); - if ($object->id) { $object->fetch_thirdparty(); @@ -92,7 +93,6 @@ if ($object->id) dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), 0, 'payment'); - // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $totalsize=0; @@ -101,29 +101,34 @@ if ($object->id) $totalsize+=$file['size']; } + $linkback = ''.$langs->trans("BackToList").''; - print ''; + $morehtmlref='
'; - $linkback = ''.$langs->trans("BackToList").''; + $userstatic=new User($db); + $userstatic->fetch($object->fk_user); - // Ref - print '
'; + $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); + $morehtmlref.=''; - // Societe - //print ""; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); - print ''; - print ''; - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); - print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + print '
'; + print '
'; - print '
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - $modulepart = 'salaries'; - $permission = $user->rights->salaries->write; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + print ''; + + dol_fiche_end(); + + $modulepart = 'salaries'; + $permission = $user->rights->salaries->write; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } else diff --git a/htdocs/compta/salaries/info.php b/htdocs/compta/salaries/info.php index f15aac021ec..05dc7835b68 100644 --- a/htdocs/compta/salaries/info.php +++ b/htdocs/compta/salaries/info.php @@ -1,6 +1,7 @@ - * Copyright (C) 2015 Charlie BENKE + * Copyright (C) 2015 Charlie BENKE + * Copyright (C) 2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("compta"); $langs->load("bills"); +$langs->load("users"); $langs->load("salaries"); +$langs->load('hrm'); $id=GETPOST('id','int'); $action=GETPOST('action','aZ09'); @@ -46,21 +49,37 @@ $result = restrictedArea($user, 'salaries', '', '', ''); llxHeader("",$langs->trans("SalaryPayment")); -$salpayment = new PaymentSalary($db); -$result = $salpayment->fetch($id); -$salpayment->info($id); +$object = new PaymentSalary($db); +$object->fetch($id); +$object->info($id); -$head = salaries_prepare_head($salpayment); +$head = salaries_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("SalaryPayment"), 0, 'payment'); +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref='
'; + +$userstatic=new User($db); +$userstatic->fetch($object->fk_user); + +$morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); +$morehtmlref.='
'; + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + +print '
'; +print '
'; print '
'; -dol_print_object_info($salpayment); +dol_print_object_info($object); print '
'; print '
'; +dol_fiche_end(); + llxFooter(); $db->close(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f3f4e689467..fe93387cadb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -397,8 +397,8 @@ abstract class CommonObject //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."
\n"; $lastname=$this->lastname; $firstname=$this->firstname; - if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:''))); - + if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); + $ret=''; if ($option && $this->civility_id) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 561504f7845..640c784436a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -429,23 +429,23 @@ class Form if ($direction > 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-right: 3px !important;'; } $classfortooltip='classfortooltip'; - + $s='';$textfordialog=''; - + $htmltext=str_replace('"',""",$htmltext); - if ($tooltiptrigger != '') + if ($tooltiptrigger != '') { $classfortooltip='classfortooltiponclick'; $textfordialog.=''; } - if ($tooltipon == 2 || $tooltipon == 3) + if ($tooltipon == 2 || $tooltipon == 3) { $paramfortooltipimg=' class="'.$classfortooltip.' inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'"'; if ($tooltiptrigger == '') $paramfortooltipimg.=' title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on img tag to store tooltip else $paramfortooltipimg.=' dolid="'.$tooltiptrigger.'"'; } else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag - if ($tooltipon == 1 || $tooltipon == 3) + if ($tooltipon == 1 || $tooltipon == 3) { $paramfortooltiptd=' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" '; if ($tooltiptrigger == '') $paramfortooltiptd.=' title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip @@ -496,7 +496,7 @@ class Form $alt = ''; if ($tooltiptrigger) $alt=$langs->trans("ClickToShowHelp"); - + //For backwards compatibility if ($type == '0') $type = 'info'; elseif ($type == '1') $type = 'help'; @@ -577,16 +577,16 @@ class Form jQuery(".massaction").hide(); } } - + jQuery(document).ready(function () { initCheckForSelect(); jQuery(".checkforselect").click(function() { initCheckForSelect(); }); jQuery(".massactionselect").change(function() { - var massaction = $( this ).val(); + var massaction = $( this ).val(); var urlform = $( this ).closest("form").attr("action").replace("#show_files",""); - if (massaction == "builddoc") + if (massaction == "builddoc") { urlform = urlform + "#show_files"; } @@ -989,7 +989,7 @@ class Form $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out.=''; if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; @@ -1034,7 +1034,7 @@ class Form { global $conf,$user,$langs; - $out=''; + $out=''; $num=0; $outarray=array(); @@ -1077,7 +1077,7 @@ class Form if ($resql) { $events = null; - + if ($conf->use_javascript_ajax && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; @@ -3450,7 +3450,7 @@ class Form $cat = new Categorie($this->db); $cate_arbo = $cat->get_full_arbo($type,$excludeafterid); } - + $output = ''; } - + if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort'); //$retstring.=" "; @@ -5017,10 +5017,16 @@ class Form * @param string $sort 'ASC' or 'DESC' = Sort on label, '' or 'NONE' or 'POS' = Do not sort, we keep original order * @param string $morecss Add more class to css styles * @param int $addjscombo Add js combo +<<<<<<< HEAD * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set * @param int $disablebademail Check if an email is found into value and if not disable and colorize entry * @param int $nohtmlescape No html escaping. * @return string HTML select string +======= + * @param string $moreparamonempty Add more param on the empty option line. Not used if show_empty not set. + * @param int $disablebademail Check if an email is found into value and if not disable and colorize entry. + * @return string HTML select string. +>>>>>>> branch '5.0' of git@github.com:Dolibarr/dolibarr.git * @see multiselectarray */ static function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='', $addjscombo=0, $moreparamonempty='',$disablebademail=0, $nohtmlescape=0) @@ -5594,7 +5600,7 @@ class Form { $listofidcompanytoscan=$object->thirdparty->id; if (($object->thirdparty->parent > 0) && ! empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan.=','.$object->thirdparty->parent; - + $possiblelinks=array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal',1).')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande',1).')'), @@ -5606,7 +5612,7 @@ class Form 'invoice_supplier'=>array('enabled'=>$conf->fournisseur->facture->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn',1).')') ); } - + global $action; // Can complete the possiblelink array @@ -5845,7 +5851,7 @@ class Form //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); - + $navurl = $_SERVER["PHP_SELF"]; // Special case for project/task page if ($paramid == 'project_ref') @@ -5902,11 +5908,15 @@ class Form } else if (in_array($object->element, array('action', 'agenda'))) { - $ret.=$object->ref.'
'.$object->label; + $ret.=$object->ref.'
'.$object->label; + } + else if (in_array($object->element, array('adherent_type'))) + { + $ret.=$object->label; } else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); - - + + if ($morehtmlref) { $ret.=' '.$morehtmlref; @@ -6207,7 +6217,7 @@ class Form return $out; } - + /** * Return HTML to show the search and clear seach button * @@ -6216,7 +6226,7 @@ class Form function showFilterButtons() { global $conf, $langs; - + $out='
'; $out.=''; $out.=''; @@ -6235,7 +6245,7 @@ class Form function showCheckAddButtons($cssclass='checkforaction', $calljsfunction=0) { global $conf, $langs; - + $out=''; if (! empty($conf->use_javascript_ajax)) $out.='
'; $out.=''."\n"; } @@ -6000,9 +6003,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do } - + $value = preg_replace('/\s*\|\s*/','|', $value); - + $crits = explode(' ', $value); $res = ''; if (! is_array($fields)) $fields = array($fields); @@ -6125,7 +6128,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs. - * @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php) + * @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php) * @param string $param More param on http links * @return string|array Output string with href link or array with all components of link */ @@ -6139,8 +6142,8 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='' //$mime_preview[]='vnd.oasis.opendocument.presentation'; //$mime_preview[]='archive'; $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); - - if ($alldata == 1) + + if ($alldata == 1) { if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), ); else return array(); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b6b8d4ddd72..3f41e74b7f6 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -156,7 +156,6 @@ function dol_loginfunction($langs,$conf,$mysoc) // Note: $conf->css looks like '/theme/eldy/style.css.php' $conf->css = "/theme/".(GETPOST('theme','alpha')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; - //$themepath=dol_buildpath((empty($conf->global->MAIN_FORCETHEMEDIR)?'':$conf->global->MAIN_FORCETHEMEDIR).$conf->css,1); $themepath=dol_buildpath($conf->css,1); if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 3086e7d264a..1c919237f44 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -326,7 +326,6 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) $formother = new FormOther($db); - //$dirthemes=array(empty($conf->global->MAIN_FORCETHEMEDIR)?'/theme':$conf->global->MAIN_FORCETHEMEDIR.'/theme'); $dirthemes=array('/theme'); if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 521fd6831f2..6248f294476 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -802,7 +802,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("bills"); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); - $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); + $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire, '', $mainmenu, 'customers_bills_list'); if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills/', $leftmenu)) { @@ -830,7 +830,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("bills"); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); - $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, 'suppliers_bills_list'); if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) { $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft'); diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 2888b911700..c8d8be2461d 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -1,9 +1,9 @@ - * Copyright (C) 2012-2015 Juanjo Menent + * Copyright (C) 2012-2015 Juanjo Menent * Copyright (C) 2013-2017 Philippe Grand - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2015 Benoit Bruchard + * Copyright (C) 2015-2017 Alexandre Spangaro + * Copyright (C) 2015 Benoit Bruchard * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("admin"); $langs->load("donations"); @@ -199,7 +199,7 @@ else if ($action == 'setart885') { $dir = "../../core/modules/dons/"; $form=new Form($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); $linkback=''.$langs->trans("BackToModuleList").''; @@ -364,7 +364,7 @@ print '
'; if (! empty($conf->accounting->enabled)) { - print $formaccountancy->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1); + print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1); } else { @@ -401,7 +401,7 @@ if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY)) print '
' . $langs->trans('Parameters') . '
' . $langs->trans("DONATION_ART200") . '
' . $langs->trans("DONATION_ART238") . '
' . $langs->trans("DONATION_ART885") . '
'.$langs->trans("VALIDATOR").''; @@ -1376,7 +1380,7 @@ if ($action == 'create') if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } - + print '
'; @@ -1444,10 +1448,13 @@ else print '
'.$langs->trans("User").''; $userfee=new User($db); - $userfee->fetch($object->fk_user_author); - print $userfee->getNomUrl(-1); + if ($object->fk_user_author > 0) + { + $userfee->fetch($object->fk_user_author); + print $userfee->getNomUrl(-1); + } print '
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); @@ -1532,17 +1539,16 @@ else // Clone confirmation if ($action == 'clone') { // Create an array for form + $criteriaforfilter='hierarchyme'; + if (! empty($user->rights->expensereport->readall)) $criteriaforfilter=''; $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), + 'text' => '', + array('type' => 'other','name' => 'fk_user_author','label' => $langs->trans("SelectTargetUser"),'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int')> 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter)) ); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneExpenseReport'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - + if ($action == 'save') { $formconfirm=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("SaveTrip"),$langs->trans("ConfirmSaveTrip"),"confirm_validate","","",1); @@ -1592,13 +1598,10 @@ else // Print form confirm print $formconfirm; - - + // Expense report card - $linkback = ''.$langs->trans("BackToList").''; - - + $morehtmlref='
'; /* // Ref customer @@ -1639,15 +1642,13 @@ else } }*/ $morehtmlref.='
'; - - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + print '
'; print '
'; print '
'; - + print ''; // Author @@ -1659,10 +1660,10 @@ else $userauthor=new User($db); $result=$userauthor->fetch($object->fk_user_author); if ($result < 0) dol_print_error('',$userauthor->error); - print $userauthor->getNomUrl(-1); + elseif ($result > 0) print $userauthor->getNomUrl(-1); } print ''; - + print ''; print ''; print ''; } - // Amount - print ''; - print ''; - print ''; - $rowspan = 5; - if ($object->fk_statut < 3) $rowspan++; - elseif($object->fk_statut == 4) $rowspan+=2; - else $rowspan+=2; - if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2; - if($object->fk_statut==6) $rowspan+=2; - print ""; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - // Validation date print ''; print ''; @@ -1718,8 +1696,8 @@ else if ($object->fk_user_validator > 0) { $userfee=new User($db); - $userfee->fetch($object->fk_user_validator); - print $userfee->getNomUrl(-1); + $result = $userfee->fetch($object->fk_user_validator); + if ($result > 0) print $userfee->getNomUrl(-1); if (empty($userfee->email) || ! isValidEmail($userfee->email)) { $langs->load("errors"); @@ -1736,11 +1714,11 @@ else if ($object->fk_user_cancel > 0) { $userfee=new User($db); - $userfee->fetch($object->fk_user_cancel); - print $userfee->getNomUrl(-1); + $result = $userfee->fetch($object->fk_user_cancel); + if ($result > 0) print $userfee->getNomUrl(-1); } print ''; - + print ''; print ''; print ''; @@ -1758,11 +1736,11 @@ else if ($object->fk_user_approve > 0) { $userapp=new User($db); - $userapp->fetch($object->fk_user_approve); - print $userapp->getNomUrl(-1); + $result = $userapp->fetch($object->fk_user_approve); + if ($result > 0) print $userapp->getNomUrl(-1); } print ''; - + print ''; print ''; print ''; @@ -1775,10 +1753,10 @@ else print ''; print ''; - + print ''; print ''; print '
'.$langs->trans("Period").''; @@ -1677,29 +1678,6 @@ else print '
'.$langs->trans("AmountHT").''.price($object->total_ht).'
'.$langs->trans("AmountVAT").''.price($object->total_tva).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc).'
'.$langs->trans("DATE_SAVE").'
'.$langs->trans("MOTIF_CANCEL").''.$object->detail_cancel.'
'.$langs->trans("DateApprove").''.dol_print_date($object->date_approve,'dayhour').'
'.$langs->trans("REFUSEUR").''; $userfee=new User($db); - $userfee->fetch($object->fk_user_refuse); - print $userfee->getNomUrl(-1); + $result = $userfee->fetch($object->fk_user_refuse); + if ($result > 0) print $userfee->getNomUrl(-1); print '
'.$langs->trans("DATE_REFUS").''.dol_print_date($object->date_refuse,'dayhour'); @@ -1805,67 +1783,130 @@ else } // Other attributes - $cols = 3; + $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'; print '
'; print '
'; print '
'; - //print '
'; - - // List of payments - $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,"; - $sql.= "c.code as type_code,c.libelle as payment_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; + print '
'; + + print ''; + + // Amount + print ''; + print ''; + print ''; + $rowspan = 5; + if ($object->fk_statut < 3) $rowspan++; + elseif($object->fk_statut == 4) $rowspan+=2; + else $rowspan+=2; + if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2; + if($object->fk_statut==6) $rowspan+=2; + print ""; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // List of payments already done + $nbcols = 3; + if (! empty($conf->banque->enabled)) { + $nbrows ++; + $nbcols ++; + } + + print '
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'; + + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) { + print ''; + } + print ''; + print ''; + print ''; + + // Payments already done (from payment on this expensereport) + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; + $sql.= "c.code as p_code, c.libelle as payment_type,"; + $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; - $sql.= ", ".MAIN_DB_PREFIX."expensereport as e"; + $sql.= ", ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql.= " WHERE e.rowid = '".$id."'"; $sql.= " AND p.fk_expensereport = e.rowid"; $sql.= " AND e.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; $sql.= " ORDER BY dp"; - + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; - print '
' . $langs->trans('Payments') . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '' . $langs->trans('Amount') . ' 
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $var=True; while ($i < $num) { $objp = $db->fetch_object($resql); - - print "'; + + print ''; print '\n"; - $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->fk_typepayment; + $labeltype=$langs->trans("PaymentType".$objp->p_code)!=("PaymentType".$objp->p_code)?$langs->trans("PaymentType".$objp->p_code):$objp->fk_typepayment; print "\n"; - print '\n"; + if (! empty($conf->banque->enabled)) { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + $bankaccountstatic->number = $objp->banumber; + + if (! empty($conf->accounting->enabled)) { + $bankaccountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); + $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + } + + print ''; + } + print '"; print ""; $totalpaid += $objp->amount; $i++; } - + if ($object->paid == 0) { - print "\n"; - print "\n"; + print ''; + print ''; $remaintopay = $object->total_ttc - $totalpaid; - print ""; - print '\n"; + print ''; + print ''; } print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'
'; + $paymentexpensereportstatic->id = $objp->rowid; + $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp); + $paymentexpensereportstatic->ref = $objp->rowid; + $paymentexpensereportstatic->num_paiement = $objp->num_paiement; + $paymentexpensereportstatic->payment_code = $objp->payment_code; + print $paymentexpensereportstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$objp->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."'; + if ($bankaccountstatic->id) + print $bankaccountstatic->getNomUrl(1, 'transactions'); + print ''.price($objp->amount)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)."
".$langs->trans("AmountExpected")." :".price($object->total_ttc)."
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
".$langs->trans("RemainderToPay")." :'.price($remaintopay)."
'.$langs->trans("RemainderToPay").':'.price($remaintopay).'
"; $db->free($resql); @@ -1873,15 +1914,13 @@ else else { dol_print_error($db); - } - + } + print '
'; print '
'; print '
'; - + print '

'; - - print '
'; // Fetch Lines of current expense report $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; @@ -1898,18 +1937,17 @@ else $actiontouse='updateligne'; if (($object->fk_statut==0 || $object->fk_statut==99) && $action != 'editline') $actiontouse='addline'; - + print ''; print ''; print ''; print ''; print ''; - - + print '
'; print ''; - - $resql = $db->query($sql); + + $resql = $db->query($sql); if ($resql) { $num_lignes = $db->num_rows($resql); @@ -1989,7 +2027,7 @@ else print ''; } - + print ''; } @@ -2042,7 +2080,7 @@ else print ''; print ''; } - + print ''; print ''; - + print ''; print ''; - + // Select date print ''; + print ''; } - + // Select type print ''; print '"; - print '"; - print '"; - print '"; print "\n"; + $total+=$objp->total; $total_ttc+=$objp->total_ttc; $totalrecu+=$objp->am; @@ -304,7 +313,7 @@ if (GETPOST('action','aZ09') == 'create') if ($i > 1) { // Print total - print ""; + print ''; print ''; print ""; print ""; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index f7ed5b7575b..f8b638b079a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -104,6 +104,7 @@ ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text; ALTER TABLE llx_loan ADD COLUMN fk_projet integer DEFAULT NULL; ALTER TABLE llx_holiday ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_projet ADD COLUMN fk_user_modif integer; ALTER TABLE llx_projet_task_time ADD COLUMN datec date; ALTER TABLE llx_projet_task_time ADD COLUMN tms timestamp; @@ -214,22 +215,22 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; -DELETE FROM llx_const where name = 'ADHERENT_BANK_USE_AUTO'; +DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__; -UPDATE llx_const set value='moono-lisa' where value = 'moono' AND name = 'FCKEDITOR_SKIN'; +UPDATE llx_const SET value = __ENCRYPT('moono-lisa')__ WHERE value = __ENCRYPT('moono')__ AND name = __ENCRYPT('FCKEDITOR_SKIN')__; -ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx; -ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx; +ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) AFTER tva_tx; ALTER TABLE llx_user ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_usergroup ADD COLUMN model_pdf varchar(255); -INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('PRODUCT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/products', 'chaine', 0, ''); -INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('CONTRACT_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/contracts', 'chaine', 0, ''); -INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0, ''); -INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0, ''); +INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('PRODUCT_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/products')__, 'chaine', 0, ''); +INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('CONTRACT_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/contracts')__, 'chaine', 0, ''); +INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('USERGROUP_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/usergroups')__, 'chaine', 0, ''); +INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('USER_ADDON_PDF_ODT_PATH')__, 1, __ENCRYPT('DOL_DATA_ROOT/doctemplates/users')__, 'chaine', 0, ''); -INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, '1', 'chaine', 0, 'Enable overwrote of translation'); +INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES (__ENCRYPT('MAIN_ENABLE_OVERWRITE_TRANSLATION')__, 1, __ENCRYPT('1')__, 'chaine', 0, 'Enable overwrote of translation'); ALTER TABLE llx_chargesociales ADD COLUMN ref varchar(16); ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL; @@ -348,3 +349,4 @@ ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer; DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); +ALTER TABLE llx_inventory ADD COLUMN ref varchar(48); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index d50547b711b..8ca404d3a0e 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -30,6 +30,7 @@ create table llx_projet title varchar(255) NOT NULL, description text, fk_user_creat integer NOT NULL, -- createur du projet + fk_user_modif integer, public integer, -- project is public or not fk_statut integer DEFAULT 0 NOT NULL, -- open or close fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 4646c3b6eb9..264a45bca91 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -468,11 +468,11 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $db->close(); - // Actions for all version (not in database) + // Actions for all versions (not in database) migrate_delete_old_files($db, $langs, $conf); - migrate_delete_old_dir($db, $langs, $conf); + dol_mkdir(DOL_DATA_ROOT.'/bank'); migrate_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); } @@ -3941,7 +3941,11 @@ function migrate_delete_old_files($db,$langs,$conf) DOL_DOCUMENT_ROOT.'/core/modules/mailings/poire.modules.php', DOL_DOCUMENT_ROOT.'/core/modules/mailings/kiwi.modules.php', DOL_DOCUMENT_ROOT.'/core/modules/facture/pdf_crabe.modules.php', - DOL_DOCUMENT_ROOT.'/core/modules/facture/pdf_oursin.modules.php' + DOL_DOCUMENT_ROOT.'/core/modules/facture/pdf_oursin.modules.php', + + DOL_DOCUMENT_ROOT.'/compta/facture/class/api_invoice.class.php', + DOL_DOCUMENT_ROOT.'/commande/class/api_commande.class.php', + DOL_DOCUMENT_ROOT.'/user/class/api_user.class.php' ); foreach ($filetodeletearray as $filetodelete) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 92fe19676c0..5f3d4eef2da 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -168,7 +168,7 @@ DescThirdPartyReport=Consult here the list of the third party customers and supp ListAccounts=List of the accounting accounts Pcgtype=Class of account -Pcgsubtype=Under class of account +Pcgsubtype=Subclass of account TotalVente=Total turnover before tax TotalMarge=Total sales margin @@ -257,7 +257,7 @@ Formula=Formula ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) ExportNotSupported=The export format setuped is not supported into this page BookeppingLineAlreayExists=Lines already existing into bookeeping - +NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a170bc3f6e1..1ff0b9a9aa4 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -715,6 +715,7 @@ from=from toward=toward Access=Access SelectAction=Select action +SelectTargetUser=Select target user/employee HelpCopyToClipboard=Use Ctrl+C to copy to clipboard SaveUploadedFileWithMask=Save file on server with name "%s" (otherwise "%s") OriginFileName=Original filename @@ -741,8 +742,8 @@ Hello=Hello Sincerely=Sincerely DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? -NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked records -TooManyRecordForMassAction=Too many record selected for mass action. The action is restricted to a list of %s records. +NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked record +TooManyRecordForMassAction=Too many record selected for mass action. The action is restricted to a list of %s record. NoRecordSelected=No record selected MassFilesArea=Area for files built by mass actions ShowTempMassFilesArea=Show area of files built by mass actions diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 9c6902d3279..a51a392499b 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -88,5 +88,5 @@ NoTripsToExportCSV=No expense report to export for this period. ExpenseReportPayment=Expense report payment ExpenseReportsToApprove=Expense reports to approve ExpenseReportsToPay=Expense reports to pay -CloneExpenseReport=Clone expese report +CloneExpenseReport=Clone expense report ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ? \ No newline at end of file diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index b58bfb929d9..81d43e46ab0 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2017 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -235,7 +235,7 @@ if (empty($reshook)) $form = new Form($db); $formproject = new FormProjets($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); $title = $langs->trans("Loan") . ' - ' . $langs->trans("Card"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; @@ -337,19 +337,19 @@ if ($action == 'create') // Accountancy_account_capital print ''; print ''; // Accountancy_account_insurance print ''; print ''; // Accountancy_account_interest print ''; print ''; } else // For external software @@ -541,7 +541,7 @@ if ($id > 0) { if (! empty($conf->accounting->enabled)) { - print $formaccountancy->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1); + print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1); } else { @@ -566,7 +566,7 @@ if ($id > 0) { if (! empty($conf->accounting->enabled)) { - print $formaccountancy->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); + print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); } else { @@ -591,7 +591,7 @@ if ($id > 0) { if (! empty($conf->accounting->enabled)) { - print $formaccountancy->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1); + print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1); } else { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index da9e65f47ce..26f455131cd 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1005,8 +1005,18 @@ function top_httphead($contenttype='text/html') if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client); else header("Content-Type: ".$contenttype); - header("X-Content-Type-Options: nosniff"); - header("X-Frame-Options: SAMEORIGIN"); + // Security options + header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) + header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) + if (! empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) + { + // For example, to restrict script, object, frames or img to some domains + // script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; child-src https://youtube.com; img-src: https://static.example.com + // For example, to restrict everything to one domain, except object, ... + // default-src https://cdn.example.net; object-src 'none' + header("Content-Security-Policy: ".$conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY); + } + // On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1. /*if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { @@ -1121,7 +1131,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php' - //$themepath=dol_buildpath((empty($conf->global->MAIN_FORCETHEMEDIR)?'':$conf->global->MAIN_FORCETHEMEDIR).$conf->css,1); $themepath=dol_buildpath($conf->css,1); $themesubdir=''; if (! empty($conf->modules_parts['theme'])) // This slow down diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 8f39f695952..1918a9aa137 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -119,7 +119,7 @@ print load_fiche_titre($langs->trans("margesSetup"),$linkback,'title_setup'); $head = marges_admin_prepare_head(); -dol_fiche_head($head, 'parameters', $langs->trans("Margins"), 0, 'margin'); +dol_fiche_head($head, 'parameters', $langs->trans("Margins"), -1, 'margin'); print load_fiche_titre($langs->trans("MemberMainOptions"),'',''); print '
'.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; print ''; print ''; @@ -2078,11 +2116,11 @@ else print '
'; $form->select_date($date?$date:-1,'date'); @@ -2091,11 +2129,11 @@ else // Select project if (! empty($conf->projet->enabled)) { - print ''; - $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, 1); - print ''; + $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, 1); + print ''; select_type_fees_id($fk_c_type_fees,'fk_c_type_fees',1); @@ -2249,7 +2287,7 @@ if ($action != 'create' && $action != 'edit') } } - + // If status is Appoved // -------------------- @@ -2257,7 +2295,7 @@ if ($action != 'create' && $action != 'edit') { print ''; } - + // If bank module is used if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == 5) { @@ -2272,7 +2310,7 @@ if ($action != 'create' && $action != 'edit') } } - // If bank module is not used + // If bank module is not used if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) { //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index eb16583df26..d62de0596e1 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -256,17 +256,19 @@ class ExpenseReport extends CommonObject /** * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param int $fk_user_author Id of new user + * @return int New id of clone */ - function createFromClone($socid=0) + function createFromClone($fk_user_author) { global $user,$hookmanager; $error=0; + if (empty($fk_user_author)) $fk_user_author = $user->id; + $this->context['createfromclone'] = 'createfromclone'; - + $this->db->begin(); // get extrafields so they will be clone @@ -282,7 +284,7 @@ class ExpenseReport extends CommonObject $this->fk_statut=0; // Clear fields - $this->fk_user_author = $user->id; // Note fk_user_author is not the 'author' but the guy the expense report is for. + $this->fk_user_author = $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. $this->fk_user_valid = ''; $this->date_create = ''; $this->date_creation = ''; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 9fc8c7627dd..edd80a0bff5 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ class PaymentExpenseReport extends CommonObject { public $element='payment_expensereport'; //!< Id that identify managed objects public $table_element='payment_expensereport'; //!< Name of table without prefix where object is stored + public $picto = 'payment'; var $rowid; @@ -425,6 +426,32 @@ class PaymentExpenseReport extends CommonObject } + /** + * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return ''; + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @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 Libelle du statut + */ + function LibStatut($statut,$mode=0) + { + global $langs; + + return ''; + } + + /** * Initialise an instance with random values. * Used to build previews or test instances. @@ -613,4 +640,48 @@ class PaymentExpenseReport extends CommonObject return $result; } + + /** + * Tab information on object + * + * @param int $id Payment id + * @return void + */ + function info($id) + { + $sql = 'SELECT e.rowid, e.datec, e.fk_user_creat, e.fk_user_modif, e.tms'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as e'; + $sql.= ' WHERE e.rowid = '.$id; + + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_creat) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_creat); + $this->user_creation = $cuser; + } + if ($obj->fk_user_modif) + { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->tms); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } } diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index bc956955258..ce6e0da8c5a 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2017 Alexandre Spangaro * * 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 @@ -24,29 +24,25 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load('bills'); $langs->load('banks'); $langs->load('companies'); +$langs->load('trips'); -// Security check $id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm'); + +// Security check if ($user->societe_id) $socid=$user->societe_id; // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); -$payment = new PaymentExpenseReport($db); -if ($id > 0) -{ - $result=$payment->fetch($id); - if (! $result) dol_print_error($db,'Failed to get payment id '.$id); -} - +$object = new PaymentExpenseReport($db); /* * Actions @@ -57,7 +53,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensere { $db->begin(); - $result = $payment->delete($user); + $result = $object->delete($user); if ($result > 0) { $db->commit(); @@ -66,7 +62,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensere } else { - setEventMessages($payment->error, $payment->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } @@ -76,7 +72,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere { $db->begin(); - $result=$payment->valide(); + $result=$object->valide(); if ($result > 0) { @@ -99,12 +95,12 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere } } - header('Location: card.php?id='.$payment->id); + header('Location: card.php?id='.$object->id); exit; } else { - setEventMessages($payment->error, $payment->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } @@ -114,27 +110,27 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere * View */ -llxHeader(); +llxHeader('', $langs->trans("ExpenseReportPayment")); + +if ($id > 0) +{ + $result=$object->fetch($id); + if (! $result) dol_print_error($db,'Failed to get payment id '.$id); +} -$expensereport = new ExpenseReport($db); $form = new Form($db); -$h=0; +$head = payment_expensereport_prepare_head($object); -$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$id; -$head[$h][1] = $langs->trans("Card"); -$hselected = $h; -$h++; - -dol_fiche_head($head, $hselected, $langs->trans("ExpenseReportPayment"), 0, 'payment'); +dol_fiche_head($head, 'payment', $langs->trans("ExpenseReportPayment"), -1, 'payment'); /* * Confirm deleting of the payment */ if ($action == 'delete') { - print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); - + print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2); + } /* @@ -143,46 +139,62 @@ if ($action == 'delete') if ($action == 'valide') { $facid = $_GET['facid']; - print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); - + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); + } +$linkback = ''; +// $linkback = '' . $langs->trans("BackToList") . ''; -print ''; +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', ''); -// Ref -print ''; -print ''; +print '
'; +print '
'; -// Date -print '
'; +print '
'.$langs->trans('Ref').''; -print $form->showrefnav($payment,'id','',1,'rowid','id'); -print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'."\n"; + +// Date payment +print ''; // Mode -print ''; +print ''; // Number -print ''; +print ''; // Amount -print ''; +print ''; // Note -print ''; +print ''; +$disable_delete = 0; // Bank account if (! empty($conf->banque->enabled)) { - if ($payment->bank_account) + if ($object->bank_account) { $bankline=new AccountLine($db); - $bankline->fetch($payment->bank_line); + $bankline->fetch($object->bank_line); + if ($bankline->rappro) + { + $disable_delete = 1; + $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); + } print ''; print ''; print ''; + print ''; + + print ''; + print ''; + print ''; print ''; } @@ -190,13 +202,16 @@ if (! empty($conf->banque->enabled)) print '
'.$langs->trans('Date').''.dol_print_date($object->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('PaymentMode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$payment->num_payment.'
'.$langs->trans('Numero').''.$object->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'.$langs->trans('Note').''.nl2br($object->note).'
'.$langs->trans('BankTransactionLine').''; - print $bankline->getNomUrl(1,0,'showall'); + print $bankline->getNomUrl(1,0,'showconciliated'); + print '
'.$langs->trans('BankAccount').''; + $accountstatic=new Account($db); + $accountstatic->fetch($bankline->fk_account); + print $accountstatic->getNomUrl(1); print '
'; +print ''; + +dol_fiche_end(); + /* - * List of donations paid + * List of expense report paid */ -$disable_delete = 0; -$sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; +$sql = 'SELECT er.rowid as eid, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; $sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')'; @@ -210,12 +225,17 @@ if ($resql) $i = 0; $total = 0; - print '
'; + print '
'; + + print '
'; + print '
'; + print ''; print ''; - print ''; - print ''; + print ''; print ''; + print ''; + print ''; print "\n"; if ($num > 0) @@ -226,19 +246,28 @@ if ($resql) { $objp = $db->fetch_object($resql); - print ''; - // Ref + + $expensereport=new ExpenseReport($db); + $expensereport->fetch($objp->eid); + + // Expense report print '\n"; + // Expected to pay print ''; - // Status - print ''; + // Amount paid print ''; + + // Remain to pay + print ''; + + // Status + print ''; + print "\n"; if ($objp->paid == 1) // If at least one invoice is paid, disable delete { @@ -251,6 +280,8 @@ if ($resql) print "
'.$langs->trans('ExpenseReport').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('ExpectedToPay').''.$langs->trans('PayedByThisPayment').''.$langs->trans('RemainderToPay').''.$langs->trans('Status').'
'; - $expensereport->fetch($objp->did); print $expensereport->getNomUrl(1); print "'.price($objp->total_ttc).''.$expensereport->getLibStatut(4,$objp->amount).''.price($objp->amount).''.price($remaintopay).''.$expensereport->getLibStatut(4,$objp->amount).'
\n"; + print ''; + $db->free($resql); } else @@ -266,26 +297,13 @@ print ''; */ print '
'; -/* -if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) -{ - if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') - { - if ($user->rights->facture->paiement) - { - print ''.$langs->trans('Valid').''; - } - } -} -*/ - -if ($_GET['action'] == '') +if ($action == '') { if ($user->rights->expensereport->supprimer) { if (! $disable_delete) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { @@ -296,8 +314,6 @@ if ($_GET['action'] == '') print '
'; - - llxFooter(); $db->close(); diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php new file mode 100644 index 00000000000..bcecc54276b --- /dev/null +++ b/htdocs/expensereport/payment/info.php @@ -0,0 +1,81 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2013 Marcos García + * Copyright (C) 2015 Alexandre Spangaro + * + * 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 . + */ + +/** + * \file htdocs/expensereport/payment/info.php + * \ingroup Expense report + * \brief Tab payment info + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; + +$langs->load("bills"); +$langs->load("trips"); + +$id=GETPOST('id'); +$ref=GETPOST('ref', 'alpha'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); + +/* + * Actions + */ + +// None + + +/* + * View + */ + +llxHeader('', $langs->trans("Payment")); + +$object = new PaymentExpenseReport($db); +$object->fetch($id, $ref); +$object->info($object->id); + +$head = payment_expensereport_prepare_head($object); + +dol_fiche_head($head, 'info', $langs->trans("ExpenseReportPayment"), -1, 'payment'); + + +//$linkback = '' . $langs->trans("BackToList") . ''; + +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + + +print '
'; +print '
'; + +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; + +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 40c4fad2513..fdac304ffcb 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -29,8 +29,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); $langs->load("banks"); +$langs->load("trips"); -$chid=GETPOST("id"); +$chid=GETPOST("id",'int'); +$ref=GETPOST('ref','alpha'); $action=GETPOST('action','aZ09'); $amounts = array(); $accountid=GETPOST('accountid','int'); @@ -59,7 +61,7 @@ if ($action == 'add_payment') } $expensereport = new ExpenseReport($db); - $expensereport->fetch($chid); + $expensereport->fetch($chid, $ref); $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); @@ -160,7 +162,7 @@ if ($action == 'add_payment') } } - $_GET["action"]='create'; + $action='create'; } @@ -174,10 +176,10 @@ $form=new Form($db); // Form to create expense report payment -if (GETPOST('action','aZ09') == 'create') +if ($action == 'create' || empty($action)) { $expensereport = new ExpenseReport($db); - $expensereport->fetch($chid); + $expensereport->fetch($chid, $ref); $total = $expensereport->total_ttc; @@ -189,15 +191,20 @@ if (GETPOST('action','aZ09') == 'create') print ''; print ''; - dol_fiche_head(); + dol_fiche_head(null, '0', '', -1); - print ''; - - print ''; - - print ''; - print ''; - print ''; + $linkback = ''; + // $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($expensereport, 'ref', $linkback, 1, 'ref', 'ref', ''); + + print '
'; + print '
'; + + print '
'.$langs->trans("ExpenseReport").'
'.$langs->trans("Ref").''.$expensereport->ref.'
'.$langs->trans("Period").''.get_date_range($expensereport->date_debut,$expensereport->date_fin,"",$langs,0).'
'.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'
'."\n"; + + print ''; + print ''; $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; @@ -210,14 +217,18 @@ if (GETPOST('action','aZ09') == 'create') $sumpaid = $obj->total; $db->free(); } - print ''; - print ''; + print ''; + print ''; - print ''; - print "'; - print ''; - - print '
'.$langs->trans("Period").''.get_date_range($expensereport->date_debut,$expensereport->date_fin,"",$langs,0).'
'.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("Payment").'
'.$langs->trans("Date").''; + print '
'; + + print '
'; + + print '
'; + + print ''."\n"; + + print '
'.$langs->trans("Date").''; $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0; $form->select_date($datepayment,'','','','',"add_payment",1,1); @@ -251,6 +262,8 @@ if (GETPOST('action','aZ09') == 'create') print '
'; + print ''; + dol_fiche_end(); // List of expenses ereport not already paid completely @@ -273,16 +286,11 @@ if (GETPOST('action','aZ09') == 'create') { $objp = $expensereport; - - print '
'.price($objp->total_ttc)."'.price($sumpaid)."'.price($objp->total_ttc - $sumpaid)."'; if ($sumpaid < $objp->total_ttc) { @@ -296,6 +304,7 @@ if (GETPOST('action','aZ09') == 'create') print "
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."
'.$langs->trans("LoanAccountancyCapitalCode").''; - 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 '
'.$langs->trans("LoanAccountancyInsuranceCode").''; - 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 '
'.$langs->trans("LoanAccountancyInterestCode").''; - 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 '
'; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7cd86404afa..5c6690b44f2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,20 +1,20 @@ +/* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Auguria SARL * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2013-2016 Marcos García * Copyright (C) 2012-2013 Cédric Salvador - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2014 Cédric Gross * Copyright (C) 2014-2015 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2016 Meziane Sof + * Copyright (C) 2016 Meziane Sof * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,7 +52,8 @@ if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/p if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; $langs->load("products"); $langs->load("other"); @@ -272,7 +273,7 @@ if (empty($reshook)) $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); $object->fk_unit = GETPOST('units'); - + $accountancy_code_sell = GETPOST('accountancy_code_sell'); $accountancy_code_buy = GETPOST('accountancy_code_buy'); @@ -399,7 +400,7 @@ if (empty($reshook)) $accountancy_code_sell = GETPOST('accountancy_code_sell'); $accountancy_code_buy = GETPOST('accountancy_code_buy'); - + if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; } if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } @@ -808,7 +809,7 @@ llxHeader('', $title, $helpurl); $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); -if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db); // Load object modBarCodeProduct $res=0; @@ -1107,21 +1108,21 @@ else // Accountancy codes print '
'; - + if (! empty($conf->accounting->enabled)) { // Accountancy_code_sell print ''; print ''; // Accountancy_code_buy print ''; print ''; - } + } else // For external software { // Accountancy_code_sell @@ -1406,15 +1407,15 @@ else // Accountancy_code_sell print ''; print ''; // Accountancy_code_buy print ''; print ''; - } + } else // For external software { // Accountancy_code_sell @@ -1531,8 +1532,12 @@ else print '
'.$langs->trans("ProductAccountancySellCode").''; - 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 '
'.$langs->trans("ProductAccountancyBuyCode").''; - 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 '
'.$langs->trans("ProductAccountancySellCode").''; - 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 '
'.$langs->trans("ProductAccountancyBuyCode").''; - 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 '
'; print $langs->trans("ProductAccountancySellCode"); print ''; - if (! empty($conf->accounting->enabled)) { - print length_accountg($object->accountancy_code_sell); + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code_sell); + + print $accountingaccount->getNomUrl(0,1,1,'',1); } else { print $object->accountancy_code_sell; } @@ -1542,8 +1547,12 @@ else print '
'; print $langs->trans("ProductAccountancyBuyCode"); print ''; - if (! empty($conf->accounting->enabled)) { - print length_accountg($object->accountancy_code_buy); + if (! empty($conf->accounting->enabled)) + { + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('',$object->accountancy_code_buy); + + print $accountingaccount2->getNomUrl(0,1,1,'',1); } else { print $object->accountancy_code_buy; } diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index a430baafb59..01ae19c7032 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -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 @@ -218,17 +225,20 @@ if ($action == 'charge') dol_syslog("Create customer", LOG_DEBUG, 0, '_stripe'); $customer = \Stripe\Customer::create(array( 'email' => $email, - 'card' => $stripeToken - // TODO + 'description' => ($email?'Customer for '.$email:null), + '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'); $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => price2num($amount, 'MU'), 'currency' => $currency, '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) { // 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'); } -// 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 ''."\n"; print '
'."\n"; print ''."\n"; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index f8a1fb6be61..44524cd7acd 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -91,15 +91,11 @@ if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; -$page = GETPOST('page','int'); -if ($page == -1) { - $page = 0 ; -} +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$offset = $conf->liste_limit * $page ; +$offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3e995d83c83..33bba8f1404 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -956,7 +956,7 @@ div.vmenu, td.vmenu { } .side-nav { position: absolute; - z-index: 200; + z-index: 90; display: none; } div.blockvmenulogo @@ -4133,7 +4133,7 @@ span.noborderoncategories { /* ============================================================================== */ ul.ulselectedfields { - z-index: 100; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ + z-index: 95; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ } dl.dropdown { margin:0px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4fd3d736f04..a1851dc4a76 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -943,7 +943,7 @@ td.showDragHandle { position: fixed; top: 50px; - z-index: 200; + z-index: 90; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); @@ -1000,7 +1000,7 @@ div.login_block { position: auto; top: auto; - z-index: 200; + z-index: 90; } div.login_block { /* position: initial !important;*/ @@ -1010,7 +1010,7 @@ div.login_block { padding-left: 0 ! important; } #id-left { - z-index: 201; + z-index: 91; background: #FFF; border-right: 1px solid rgba(0,0,0,0.3); browser->layout, array('phone','tablet')) && ((GETPOST('testmenuhider') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) { ?> @@ -4224,7 +4224,7 @@ span.noborderoncategories { /* ============================================================================== */ ul.ulselectedfields { - z-index: 100; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ + z-index: 90; /* To have the select box appears on first plan even when near buttons are decorated by jmobile */ } dl.dropdown { margin:0px; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index cd9a16ea2b9..af73e1305bb 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -69,7 +69,7 @@ class UserGroup extends CommonObject /** - * Charge un objet group avec toutes ces caracteristiques (excpet ->members array) + * Charge un objet group avec toutes ces caracteristiques (except ->members array) * * @param int $id id du groupe a charger * @param string $groupname name du groupe a charger @@ -336,16 +336,16 @@ class UserGroup extends CommonObject $error++; dol_print_error($this->db); } - + if (! $error) { $this->context = array('audit'=>$langs->trans("PermissionsAdd")); - + // Call trigger $result=$this->call_trigger('GROUP_MODIFY',$user); if ($result < 0) { $error++; } // End call triggers - } + } } if ($error) { @@ -445,11 +445,11 @@ class UserGroup extends CommonObject $error++; dol_print_error($this->db); } - + if (! $error) { $this->context = array('audit'=>$langs->trans("PermissionsDelete")); - + // Call trigger $result=$this->call_trigger('GROUP_MODIFY',$user); if ($result < 0) { $error++; } @@ -815,7 +815,7 @@ class UserGroup extends CommonObject $muser=new User($this->db); $muser->fetch($val->id); $info2 = $muser->_load_ldap_info(); - $valueofldapfield[] = $muser->_load_ldap_dn($info2); + $valueofldapfield[] = $muser->_load_ldap_dn($info2); } $info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:''); } @@ -843,7 +843,11 @@ class UserGroup extends CommonObject $this->note='This is a note'; $this->datec=time(); $this->datem=time(); - $this->members=array($user->id); // Members of this group is just me + + // Members of this group is just me + $this->members=array( + $user->id => $user + ); } /** diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 4cec562ce44..8333acbbb79 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -119,9 +119,9 @@ $search_gender=GETPOST('search_gender','alpha'); $search_employee=GETPOST('search_employee','alpha'); $search_accountancy_code=GETPOST('search_accountancy_code','alpha'); $search_email=GETPOST('search_email','alpha'); -$search_statut=GETPOST('search_statut','alpha'); +$search_statut=GETPOST('search_statut','intcomma'); $search_thirdparty=GETPOST('search_thirdparty','alpha'); -$search_supervisor=GETPOST('search_supervisor','alpha'); +$search_supervisor=GETPOST('search_supervisor','intcomma'); $search_previousconn=GETPOST('search_previousconn','alpha'); $optioncss = GETPOST('optioncss','alpha'); @@ -148,7 +148,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 tests are required to be compatible with all browsers { $search_user=""; $search_login=""; @@ -204,8 +204,8 @@ else } if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); -if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$search_supervisor; -if ($search_thirdparty != '') $sql.=natural_search(array('s.nom'), $search_thirdparty); +if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$db->escape($search_supervisor); +if ($search_thirdparty != '') $sql.= natural_search(array('s.nom'), $search_thirdparty); if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); @@ -214,9 +214,9 @@ if (is_numeric($search_employee) && $search_employee >= 0) { $sql .= ' AND u.employee = '.(int) $search_employee; } if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); -if ($search_email != '') $sql.= natural_search("u.email", $search_email); -if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_email != '') $sql.= natural_search("u.email", $search_email); +if ($search_statut != '' && $search_statut >= 0) $sql.= " AND u.statut IN (".$db->escape($search_statut).")"; +if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields foreach ($search_array_options as $key => $val) { diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 6530a4f8536..0e906fe0738 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -173,7 +173,6 @@ else // Note: $conf->css looks like '/theme/eldy/style.css.php' $conf->css = "/theme/".(GETPOST('theme','alpha')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; -//$themepath=dol_buildpath((empty($conf->global->MAIN_FORCETHEMEDIR)?'':$conf->global->MAIN_FORCETHEMEDIR).$conf->css,1); $themepath=dol_buildpath($conf->css,1); if (! empty($conf->modules_parts['theme'])) // This slow down { diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 159323a9e83..dbd02ffdfc9 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -157,6 +157,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase $ok=true; $matches=array(); + // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. preg_match_all('/=\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) {