diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php new file mode 100644 index 0000000000000000000000000000000000000000..16027a42af4b9e9fd22d0a1c5fe8bc665323f8e9 --- /dev/null +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -0,0 +1,281 @@ +<?php +/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> + * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * \file htdocs/accountancy/bookkeeping/balance.php + * \ingroup Accounting Expert + * \brief Balance of book keeping + */ +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'; + +// Langs +$langs->load("accountancy"); + +$page = GETPOST("page"); +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +$action = GETPOST('action', 'alpha'); +$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + +$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); +if ($search_accountancy_code_start == - 1) { + $search_accountancy_code_start = ''; +} +$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); +if ($search_accountancy_code_end == - 1) { + $search_accountancy_code_end = ''; +} + +if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) { + $action = 'export_csv'; +} + +$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; + +$offset = $limit * $page; + +$object = new BookKeeping($db); + +$formventilation = new FormVentilation($db); +$formother = new FormOther($db); +$form = new Form($db); + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_date_start = ''; + $search_date_end = ''; +} + +if (empty($search_date_start)) { + $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); + $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); +} +if ($sortorder == "") + $sortorder = "ASC"; +if ($sortfield == "") + $sortfield = "t.rowid"; + +$options = ''; +$filter = array (); +if (! empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); +} +if (! empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); +} +if (! empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; +} +if (! empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $options .= '&search_accountancy_code_end=' . $search_accountancy_code_end; +} + +/* + * Action + */ +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = 'bookkepping'; + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + + $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + foreach ( $object->lines as $line ) { + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; + // Model Cegid Expert Export + $date = dol_print_date($line->doc_date, '%d%m%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accountg($line->numero_compte) . $sep; + print ' ' . $sep; + print $line->sens . $sep; + print price($line->montant) . $sep; + print dol_trunc($line->label_compte, 32) . $sep; + print $line->doc_ref . $sep; + + /*print $line->piece_num . $sep; + print length_accounta($line->code_tiers) . $sep; + print . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep;*/ + + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + + // Std export + $date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); + print $date . $sep; + print $line->doc_ref . $sep; + print length_accounta($line->numero_compte) . $sep; + print length_accountg($line->code_tiers) . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + + /*print $line->piece_num . $sep; + print $line->label_compte . $sep; + print price($line->montant) . $sep; + print $line->sens . $sep;*/ + print $line->code_journal . $sep; + print "\n"; + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) { + + // Coala export + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + print $date . $sep; + print $line->code_journal . $sep; + print length_accounta($line->numero_compte) . $sep; + print $line->piece_num . $sep; + print $line->doc_ref . $sep; + print price($line->debit) . $sep; + print price($line->credit) . $sep; + print 'E' . $sep; + print length_accountg($line->code_tiers) . $sep; + print "\n"; + } + } +} + +else { + + $title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end); + + llxHeader('', $title_page); + + /* + * List + */ + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($nbtotalofrecords < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); + + print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; + print '<div class="tabsAction">' . "\n"; + print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>'; + + print '</div>'; + + print '<div class="liste_titre">'; + print $langs->trans('DateStart') . ': '; + print $form->select_date($search_date_start, 'date_start', 0, 0, 1); + print $langs->trans('DateEnd') . ': '; + print $form->select_date($search_date_end, 'date_end', 0, 0, 1); + print '</div>'; + + print '<table class="noborder" width="100%">'; + print '<tr class="liste_titre">'; + print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); + print "</tr>\n"; + + print '<tr class="liste_titre">'; + print '<td>'; + print $langs->trans('From'); + print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); + print '<br>'; + print $langs->trans('To'); + print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); + print '</td>'; + + print '<td> </td>'; + print '<td> </td>'; + print '<td> </td>'; + + print '<td align="right" class="liste_titre">'; + print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">'; + print ' '; + print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">'; + print '</td>'; + + print '</tr>'; + + $var = True; + + $total_debit = 0; + $total_credit = 0; + + foreach ( $object->lines as $line ) { + $var = ! $var; + + $total_debit += $line->debit; + $total_credit += $line->credit; + + print "<tr $bc[$var]>"; + + print '<td>' . length_accountg($line->numero_compte) . '</td>'; + print '<td align="right">' . price($line->debit) . '</td>'; + print '<td align="right">' . price($line->credit) . '</td>'; + print '<td align="right">' . price($line->credit - $line->debit) . '</td>'; + print '<td align="center">'; + print '</td>'; + print "</tr>\n"; + } + + print '<tr class="liste_total">'; + print '<td></td>'; + print '<td align="right">'; + print price($total_debit); + print '</td>'; + print '<td align="right">'; + print price($total_credit); + print '</td>'; + print '<td align="right">' . price($total_credit - $total_debit) . '</td>'; + print '<td align="right"></td>'; + print '</tr>'; + + print "</table>"; + print '</form>'; + + llxFooter(); +} +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index dbca9aeddd99cb248f71b0c7bc5fa8e2e4a7bd14..0015dfbf9e914d08ad7299e0472dc5d1b3f29d86 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2015-*2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify @@ -642,6 +642,86 @@ class BookKeeping extends CommonObject } } + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= " t.numero_compte,"; + $sql .= " SUM(t.debit) as debit,"; + $sql .= " SUM(t.credit) as credit"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + + // Manage filter + $sqlwhere = array (); + if (count($filter) > 0) { + foreach ( $filter as $key => $value ) { + if ($key == 't.doc_date') { + $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { + $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; + } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { + $sqlwhere[] = $key . '=' . $value; + } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; + } else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + + $sql .= ' GROUP BY t.numero_compte'; + + if (! empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (! empty($limit)) { + $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 * diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 86232bb2029627ccd63d9b5192324a60d1979a11..7d9778f72b800698fe3121fe3c2c8920cf7dd4fd 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -94,6 +94,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0 "; if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index dc7266603ca019f4d5741d9b3b044c09a17318d5..e4260388ac7e015b36c643cf541409620b1c5e91 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -57,7 +57,7 @@ if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder=($filter=='outofdate'?"ASC":"DESC"); } +if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index b43235ca1ecff2fd873c4d1b91d0866c8263829b..2b52372046b2df64136b2190816b97ce51dccb0d 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -1,8 +1,9 @@ <?php -/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> +/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> + * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,7 +159,7 @@ if ($action == 'edit') foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print '<tr '.$bc[$var].'>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>'; @@ -205,7 +206,7 @@ else foreach($delays as $delay) { $var=!$var; - $value=(! empty($conf->global->$delay['code'])?$conf->global->$delay['code']:0); + $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print '<tr '.$bc[$var].'>'; print '<td width="20px">'.img_object('',$delay['img']).'</td>'; print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 418e164bc94282d42a2a432ba7daf4550282f4dd..6c2b1f6a0277d7f3cc7637b0649498969d58e9d5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1,15 +1,16 @@ <?php -/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com> - * Copyright (C) 2011 Remy Younes <ryounes@gmail.com> - * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> - * Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> - * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> +/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> + * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2011 Remy Younes <ryounes@gmail.com> + * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> + * Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> + * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1146,7 +1147,7 @@ if ($id) { $showfield=1; $align="left"; - $valuetoshow=$obj->$fieldlist[$field]; + $valuetoshow=$obj->{$fieldlist[$field]}; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; @@ -1183,77 +1184,77 @@ if ($id) else if ($fieldlist[$field]=='libelle_facture') { $langs->load("bills"); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); $valuetoshow=nl2br($valuetoshow); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { $langs->load("propal"); $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') { $key=$langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') { $key=$langs->trans(strtoupper($obj->code)); - $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($key != strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_civility') { $key=$langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') { $langs->load('agenda'); $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') { $langs->load("bills"); $key=$langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') { $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') { $langs->load("orders"); $key=$langs->trans($obj->code); - $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; + $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->{$fieldlist[$field]}; } else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') { $langs->load("sendings"); $key=$langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]); + $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; @@ -1263,16 +1264,16 @@ if ($id) } else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow=$langs->trans($obj->$fieldlist[$field]); + $valuetoshow=$langs->trans($obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='short_label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->$fieldlist[$field]); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } else if ($fieldlist[$field]=='localtax1_type') { @@ -1484,7 +1485,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { if (! in_array('country',$fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->$fieldlist[$field]) ? $obj->$fieldlist[$field] : 0); + $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print '<td>'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '</td>'; @@ -1498,7 +1499,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'region_id') { - $region_id = (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:0); + $region_id = (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:0); print '<td>'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">'; print '</td>'; @@ -1513,21 +1514,21 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') elseif ($fieldlist[$field] == 'type_template') { print '<td>'; - print $form->selectarray('type_template', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('type_template', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '</td>'; } // Le type de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'element') { print '<td>'; - print $form->selectarray('element', $elementList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('element', $elementList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '</td>'; } // La source de l'element (pour les type de contact) elseif ($fieldlist[$field] == 'source') { print '<td>'; - print $form->selectarray('source', $sourceList,(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray('source', $sourceList,(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '</td>'; } elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm") @@ -1538,18 +1539,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm' || $fieldlist[$field] == 'deductible') { print '<td>'; - print $form->selectyesno($fieldlist[$field],(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''),1); + print $form->selectyesno($fieldlist[$field],(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''),1); print '</td>'; } elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { $align="left"; if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right print '<td align="'.$align.'">'; - print '<input type="text" class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="3" name="'.$fieldlist[$field].'">'; + print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="3" name="'.$fieldlist[$field].'">'; print '</td>'; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { - print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'</textarea></td>'; + print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea></td>'; } elseif (in_array($fieldlist[$field], array('content'))) { @@ -1560,18 +1561,18 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') else print '<td>'; if ($context != 'hide') { - //print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'</textarea>'; - $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); + //print '<textarea cols="3" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'</textarea>'; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); print $doleditor->Create(1); } else print ' '; print '</td>'; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print '<td><input type="text" class="flat" value="'.price((! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')).'" size="8" name="'.$fieldlist[$field].'"></td>'; + print '<td><input type="text" class="flat" value="'.price((! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')).'" size="8" name="'.$fieldlist[$field].'"></td>'; } - elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldlist[$field])) { - print '<td><input type="text" class="flat" value="'.(! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; + elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { + print '<td><input type="text" class="flat" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" size="10" name="'.$fieldlist[$field].'"></td>'; } elseif ($fieldlist[$field]=='unit') { print '<td>'; @@ -1581,14 +1582,14 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') 'point' => $langs->trans('SizeUnitpoint'), 'inch' => $langs->trans('SizeUnitinch') ); - print $form->selectarray('unit', $units, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), 0, 0, 0); + print $form->selectarray('unit', $units, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 0, 0, 0); print '</td>'; } // Le type de taxe locale elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type') { print '<td align="center">'; - print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'')); + print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); print '</td>'; } else @@ -1603,7 +1604,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field]=='accountancy_code_sell') $size='size="10" '; if ($fieldlist[$field]=='accountancy_code_buy') $size='size="10" '; if ($fieldlist[$field]=='sortorder') $size='size="2" '; - print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:'').'" name="'.$fieldlist[$field].'">'; + print '<input type="text" '.$size.' class="flat" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '</td>'; } } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 2adf79a61748c68bf8e60a6946d9b9d6c2007742..2100230fdb4afac2a25016c38b737ef9b8512b8e 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2015 Frederic France <frederic.france@free.fr> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +44,7 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); -// Supported OAUTH (a provider is supported when a file xxx_oauth2callback.php is available into htdocs/core/modules/oauth) +// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) $supportedoauth2array=array('OAUTH_GOOGLE_NAME'=>'google'); // API access parameters OAUTH @@ -346,14 +347,14 @@ foreach ($list as $key) $var = !$var; print '<tr '.$bc[$var].' class="value">'; print '<td><label for="'.$key[1].'">'.$langs->trans($key[1]).'</label></td>'; - print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.$conf->global->$key[1].'">'; + print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.$conf->global->{$key[1]}.'">'; print '</td></tr>'; // Api Secret $var = !$var; print '<tr '.$bc[$var].' class="value">'; print '<td><label for="'.$key[2].'">'.$langs->trans($key[2]).'</label></td>'; - print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.$conf->global->$key[2].'">'; + print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.$conf->global->{$key[2]}.'">'; print '</td></tr>'; } @@ -368,4 +369,4 @@ print '</form>'; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee5f1465e3f0903900fa83fc847993b2d37bacf6..d63c2536476e52d17d1338a8e231910b3fd5e2b1 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1,12 +1,13 @@ <?php -/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> - * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> - * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> - * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> - * Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr> +/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org> + * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> + * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> + * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro> + * Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -867,7 +868,7 @@ class ExtraFields } else { - $labeltoshow=$obj->$InfoFieldList[1]; + $labeltoshow=$obj->{$InfoFieldList[1]}; } $labeltoshow=dol_trunc($labeltoshow,45); @@ -888,12 +889,12 @@ class ExtraFields { if(!$notrans) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); - if ($translabel!=$obj->$InfoFieldList[1]) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel!=$obj->{$InfoFieldList[1]}) { $labeltoshow=dol_trunc($translabel,18); } else { - $labeltoshow=dol_trunc($obj->$InfoFieldList[1],18); + $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18); } } if (empty($labeltoshow)) $labeltoshow='(not defined)'; @@ -1044,7 +1045,7 @@ class ExtraFields $labeltoshow .= $obj->$field_toshow . ' '; } } else { - $labeltoshow = $obj->$InfoFieldList[1]; + $labeltoshow = $obj->{$InfoFieldList[1]}; } $labeltoshow = dol_trunc($labeltoshow, 45); @@ -1065,11 +1066,11 @@ class ExtraFields $out .= '/>' . $labeltoshow . '<br>'; } else { if (! $notrans) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); - if ($translabel != $obj->$InfoFieldList[1]) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel != $obj->{$InfoFieldList[1]}) { $labeltoshow = dol_trunc($translabel, 18); } else { - $labeltoshow = dol_trunc($obj->$InfoFieldList[1], 18); + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); } } if (empty($labeltoshow)) @@ -1263,13 +1264,13 @@ class ExtraFields else { $translabel=''; - if (!empty($obj->$InfoFieldList[1])) { - $translabel=$langs->trans($obj->$InfoFieldList[1]); + if (!empty($obj->{$InfoFieldList[1]})) { + $translabel=$langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel!=$obj->$InfoFieldList[1]) { + if ($translabel!=$obj->{$InfoFieldList[1]}) { $value=dol_trunc($translabel,18); }else { - $value=$obj->$InfoFieldList[1]; + $value=$obj->{$InfoFieldList[1]}; } } } @@ -1343,13 +1344,13 @@ class ExtraFields } } else { $translabel = ''; - if (! empty($obj->$InfoFieldList[1])) { - $translabel = $langs->trans($obj->$InfoFieldList[1]); + if (! empty($obj->{$InfoFieldList[1]})) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); } - if ($translabel != $obj->$InfoFieldList[1]) { + if ($translabel != $obj->{$InfoFieldList[1]}) { $value .= dol_trunc($translabel, 18) . '<BR>'; } else { - $value .= $obj->$InfoFieldList[1] . '<BR>'; + $value .= $obj->{$InfoFieldList[1]} . '<BR>'; } } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3728644a401460278259137526cc6edaa27a5b33..25b5712d3f4765ede482df83aa1b6eae8960757e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1,8 +1,9 @@ <?php -/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012-2015 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> +/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2012-2015 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2256,18 +2257,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu // Define $accessallowed if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_temp.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; } else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_temp.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file; } else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) { - if ($fuser->rights->$reg[1]->lire || $fuser->rights->$reg[1]->read || ($fuser->rights->$reg[1]->download)) $accessallowed=1; - $original_file=$conf->$reg[1]->dir_output.'/'.$fuser->id.'/'.$original_file; + if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1; + $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; } else { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index f2b13d79d0f910b359f3571c2e691a0519174a2d..deab2457c8be68a0106616744ccb3ea0b0c158ca 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -4,7 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> - * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> + * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1910,7 +1910,7 @@ function fetchObjectByElement($element_id, $element_type) global $db,$conf; $element_prop = getElementProperties($element_type); - if (is_array($element_prop) && $conf->$element_prop['module']->enabled) + if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) { dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0497b50308f9bb5df7089461132e573c0ab78000..4e6a219c0551f83370c1756cf009077b0f0066d9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -969,9 +969,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // General Ledger $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); + if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); - + // Reports $langs->load("compta"); diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php index 43232ed92f2b9ee22933a1ff5bc1a3894baf4fe7..623c131086bdf706d85467450ac92f59c1b0e805 100644 --- a/htdocs/core/modules/oauth/google_oauthcallback.php +++ b/htdocs/core/modules/oauth/google_oauthcallback.php @@ -45,7 +45,7 @@ $backtourl = GETPOST('backtourl', 'alpha'); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/google_oauthcallback.php'); /** diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7c6e965f7786a4c4e64bbc2b037c6cb041fdf0f1..5177e108f406345ec5c60fee23dd3160c796bbe1 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -75,7 +75,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - $urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php' + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' ); $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); $serviceFactory = new \OAuth\ServiceFactory(); @@ -113,7 +113,7 @@ class printing_printgcp extends PrintingDriver if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); if ($token_ok) { $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); @@ -122,10 +122,10 @@ class printing_printgcp extends PrintingDriver } /* if ($storage->hasAccessToken('Google')) { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); - $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); } else { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); }*/ } else { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); @@ -200,7 +200,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); @@ -338,7 +338,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getoauthcallback.php?service=google' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php?service=google' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); @@ -387,7 +387,7 @@ class printing_printgcp extends PrintingDriver $credentials = new Credentials( $this->google_id, $this->google_secret, - DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php' + DOL_MAIN_URL_ROOT.'/core/modules/oauth/google_oauthcallback.php' ); $serviceFactory = new \OAuth\ServiceFactory(); $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 3a3436c71a9813bfad54243877104c7917a6d25c..7912b4f189fcf867d8895883e556fcecc9886dc2 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -1,7 +1,8 @@ <?php -/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2012 Charles-Fr BENKE <charles.fr@benke.fr> +/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2012 Charles-Fr BENKE <charles.fr@benke.fr> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -131,11 +132,11 @@ class Export //print_r("$perm[0]-$perm[1]-$perm[2]<br>"); if (! empty($perm[2])) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; if (! $bool) break; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 2c17dd44f02609a98705c38d40bd40891a210c84..9a4d58aa65fa3b7529728a5569da02efc1ea41c6 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -1,5 +1,6 @@ <?php -/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,11 +107,11 @@ class Import //print_r("$perm[0]-$perm[1]-$perm[2]<br>"); if ($perm[2]) { - $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]}; } else { - $bool=$user->rights->$perm[0]->$perm[1]; + $bool=$user->rights->{$perm[0]}->{$perm[1]}; } if ($perm[0]=='user' && $user->admin) $bool=true; //print $bool." $perm[0]"."<br>";