diff --git a/ChangeLog b/ChangeLog index 610f34d669f..19ab1e0f49b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ English Dolibarr ChangeLog WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events. * Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from 'doaction' into 'sendMail'. * Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2dd71e8e2e6..7d73202eb79 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016-2017 Laurent Destailleur + * Copyright (C) 2016-2018 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 @@ -176,11 +176,10 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.acco $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; -// Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)"; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent"; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent"; $sql .= " WHERE asy.rowid = " . $pcgver; - +//print $sql; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent); @@ -256,7 +255,7 @@ if ($resql) else dol_print_error($db); print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; print '
'; print '
'; @@ -275,7 +274,7 @@ if ($resql) if (! empty($arrayfields['aa.pcg_type']['checked'])) print ''; if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; if (! empty($arrayfields['aa.active']['checked'])) print ' '; - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpicto; print ''; @@ -309,7 +308,7 @@ if ($resql) if (! empty($arrayfields['aa.account_number']['checked'])) { print ""; - print $accountstatic->getNomUrl(1); + print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1); print "\n"; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 82ba00a882c..61166f88d07 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -188,12 +188,10 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) } } + /* * View */ -$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card'); -$helpurl = ''; -llxheader('', $title, $helpurl); $form = new Form($db); $formaccounting = new FormAccounting($db); @@ -201,6 +199,11 @@ $formaccounting = new FormAccounting($db); $accountsystem = new AccountancySystem($db); $accountsystem->fetch($conf->global->CHARTOFACCOUNTS); +$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card'); +$helpurl = ''; +llxheader('', $title, $helpurl); + + // Create mode if ($action == 'create') { print load_fiche_titre($langs->trans('NewAccountingAccount')); @@ -330,7 +333,7 @@ else if ($id > 0 || $ref) { print ''; } else { // View mode - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr'); diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index ec1b20b15e9..44c816530dd 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -27,9 +27,8 @@ * \ingroup Advanced accountancy * \brief Setup page to configure accounting expert module */ -require '../../main.inc.php'; -// Class +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -65,39 +64,23 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { $error = 0; - $accounting_modes = array ( - 'RECETTES-DEPENSES', - 'CREANCES-DETTES' - ); + if (! $error) + { + foreach ($list as $constname) + { + $constvalue = GETPOST($constname, 'alpha'); - $accounting_mode = GETPOST('accounting_mode', 'alpha'); - - if (in_array($accounting_mode, $accounting_modes)) { - - if (! dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { - $error ++; - } - } else { - $error ++; + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + if ($error) { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } - if ($error) { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - - foreach ($list as $constname) - { - $constvalue = GETPOST($constname, 'alpha'); - - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; - } - } - if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index e07d0c24771..f6552d3d1e1 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -272,8 +272,8 @@ if ($result) $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref); if ($search_label > 0) $param.="&search_desc=".urlencode($search_label); if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); @@ -300,10 +300,10 @@ if ($result) print ''; print '' . $langs->trans('Options') . '' . $langs->trans('Description') . ''; print "\n"; - print ' ' . $langs->trans('OptionModeProductSell') . ''; + print ' ' . $langs->trans('OptionModeProductSell') . ''; print ''.$langs->trans('OptionModeProductSellDesc'); print "\n"; - print ' ' . $langs->trans('OptionModeProductBuy') . ''; + print ' ' . $langs->trans('OptionModeProductBuy') . ''; print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; print "\n"; @@ -328,9 +328,9 @@ if ($result) print ''; if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ''; // On sell - print ''; + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print ''; // On buy - print ''; + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print ''; // Current account print ''; print ''; @@ -348,11 +348,9 @@ if ($result) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder); - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $fieldtosortaccount="p.accountancy_code_buy"; - } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') $fieldtosortaccount="p.accountancy_code_buy"; else $fieldtosortaccount="p.accountancy_code_sell"; print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); @@ -410,9 +408,11 @@ if ($result) print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; } - print ''.$product_static->getLibStatut(3, 0).''; + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') + print ''.$product_static->getLibStatut(3, 0).''; - print ''.$product_static->getLibStatut(3, 1).''; + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') + print ''.$product_static->getLibStatut(3, 1).''; // Current accounting account print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index e9f50e77715..f655d245e86 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -36,26 +36,28 @@ $langs->load("accountancy"); $langs->load("bills"); $langs->load("compta"); +$action = GETPOST('action','aZ09'); + +$id = GETPOST('id', 'int'); // id of record +$mode = GETPOST('mode','aZ09'); // '' or 'tmp' +$piece_num = GETPOST("piece_num",'int'); // id of transaction (several lines share the same transaction id) + // Security check -$id = GETPOST('id', 'int'); if ($user->societe_id > 0) { accessforbidden(); } -$action = GETPOST('action','aZ09'); -$mode = GETPOST('mode','aZ09'); // '' or 'tmp' -$piece_num = GETPOST("piece_num"); $mesg = ''; -$account_number = GETPOST('account_number'); -$subledger_account = GETPOST('subledger_account'); +$account_number = GETPOST('account_number','alphanohtml'); +$subledger_account = GETPOST('subledger_account','alphanohtml'); if ($subledger_account == - 1) { $subledger_account = null; } -$label_compte = GETPOST('label_compte'); -$label_operation= GETPOST('label_operation'); -$debit = price2num(GETPOST('debit')); -$credit = price2num(GETPOST('credit')); +$label_compte = GETPOST('label_compte','alphanohtml'); +$label_operation= GETPOST('label_operation','alphanohtml'); +$debit = price2num(GETPOST('debit','alpha')); +$credit = price2num(GETPOST('credit','alpha')); $save = GETPOST('save','alpha'); if (! empty($save)) $action = 'add'; @@ -340,13 +342,14 @@ if ($action == 'create') dol_fiche_head(); print ''; - print ''; + + /*print ''; print ''; print ''; - print ''; + print '';*/ print ''; - print ''; + print ''; print ''; @@ -389,7 +392,7 @@ if ($action == 'create') if (! empty($book->piece_num)) { - $backlink = '' . $langs->trans('BackToList') . ''; + $backlink = '' . $langs->trans('BackToList') . ''; print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); @@ -422,7 +425,7 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print ''; + print ''; print '
' . $langs->trans("NumPiece") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . '' . $langs->trans("Docdate") . ''; print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print 'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'
'; print ''; if ($action == 'editdate') { @@ -445,7 +448,7 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; print ''; print ''; if ($action == 'editjournal') { @@ -468,7 +471,7 @@ if ($action == 'create') print $langs->trans('Docref'); print ''; if ($action != 'editdocref') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; print ''; print ''; if ($action == 'editdocref') { @@ -594,7 +597,7 @@ if ($action == 'create') print "\n"; - foreach ( $book->linesmvt as $line ) { + foreach ($book->linesmvt as $line) { print ''; $total_debit += $line->debit; $total_credit += $line->credit; @@ -673,10 +676,10 @@ if ($action == 'create') print ''; } print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 749033f8392..9a7ebf9716e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -39,8 +39,8 @@ $action = GETPOST('action', 'alpha'); $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type"); $search_doc_ref = GETPOST("search_doc_ref"); -$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_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int')); $search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int')); @@ -75,6 +75,8 @@ if ($search_accountancy_aux_code_end == - 1) { } $search_mvt_label = GETPOST('search_mvt_label', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha'); +$search_debit = GETPOST('search_debit', 'alpha'); +$search_credit = GETPOST('search_credit', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); // Load variable for pagination @@ -98,7 +100,7 @@ $form = new Form($db); if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int')) { - if (empty($search_date_start) && empty($search_date_end)) + if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values')) { $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; @@ -181,12 +183,12 @@ $filter = array (); if (! empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; $tmp=dol_getdate($search_date_start); - $param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year']; + $param .= '&search_date_startmonth=' . $tmp['mon'] . '&search_date_startday=' . $tmp['mday'] . '&search_date_startyear=' . $tmp['year']; } if (! empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; $tmp=dol_getdate($search_date_end); - $param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year']; + $param .= '&search_date_endmonth=' . $tmp['mon'] . '&search_date_endday=' . $tmp['mday'] . '&search_date_endyear=' . $tmp['year']; } if (! empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; @@ -195,51 +197,51 @@ if (! empty($search_doc_date)) { } if (! empty($search_doc_type)) { $filter['t.doc_type'] = $search_doc_type; - $param .= '&search_doc_type=' . $search_doc_type; + $param .= '&search_doc_type=' . urlencode($search_doc_type); } if (! empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . $search_doc_ref; + $param .= '&search_doc_ref=' . urlencode($search_doc_ref); } if (! empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; - $param .= '&search_accountancy_code=' . $search_accountancy_code; + $param .= '&search_accountancy_code=' . urlencode($search_accountancy_code); } if (! empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . $search_accountancy_code_start; + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (! empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); } if (! empty($search_accountancy_aux_code)) { $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; + $param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code); } if (! empty($search_accountancy_aux_code_start)) { $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; - $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; + $param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start); } if (! empty($search_accountancy_aux_code_end)) { $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; - $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; + $param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end); } if (! empty($search_mvt_label)) { $filter['t.label_operation'] = $search_mvt_label; - $param .= '&search_mvt_label=' . $search_mvt_label; + $param .= '&search_mvt_label=' . urlencode($search_mvt_label); } if (! empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . $search_direction; + $param .= '&search_direction=' . urlencode($search_direction); } if (! empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . $search_ledger_code; + $param .= '&search_ledger_code=' . urlencode($search_ledger_code); } if (! empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num=' . $search_mvt_num; + $param .= '&search_mvt_num=' . urlencode($search_mvt_num); } if (! empty($search_date_creation_start)) { $filter['t.date_creation>='] = $search_date_creation_start; @@ -263,11 +265,11 @@ if (! empty($search_date_modification_end)) { } if (! empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . $search_debit; + $param .= '&search_debit=' . urlencode($search_debit); } if (! empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . $search_credit; + $param .= '&search_credit=' . urlencode($search_credit); } if ($action == 'delbookkeeping') { @@ -460,11 +462,11 @@ if (! empty($arrayfields['t.doc_date']['checked'])) print ''; print '
'; print $langs->trans('From') . ' '; - print $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1); + print $form->select_date($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1); print '
'; print '
'; print $langs->trans('to') . ' '; - print $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1); + print $form->select_date($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1); print '
'; print ''; } @@ -612,7 +614,12 @@ if ($num > 0) // Piece number if (! empty($arrayfields['t.piece_num']['checked'])) { - print '' . $line->piece_num . ''; + print ''; + $object->id = $line->id; + $object->piece_num = $line->piece_num; + print $object->getNomUrl(1,'',0,'',1); + //print '' . $line->piece_num . ''; + print ''; if (! $i) $totalarray['nbfield']++; } @@ -732,7 +739,7 @@ print ''; // TODO Replace this with mass delete action print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index c450fb5bb63..04708fe7726 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -40,8 +40,8 @@ $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_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); +$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int')); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); @@ -51,8 +51,8 @@ $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; } -$search_label_account = GETPOST('search_label_account', 'alpha'); -$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); +$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); +$search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); @@ -102,11 +102,11 @@ $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'); + $options .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_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'); + $options .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); } if (! empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; @@ -120,12 +120,16 @@ if (! GETPOST('button_removefilter_x','alpha') && ! GETPOST('button_removefilter $options .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (! empty($search_label_account)) { - $filter['t.label_operation'] = $search_label_account; - $options .= '&search_label_account=' . urlencode($search_label_account); + $filter['t.label_compte'] = $search_label_account; + $options .= '&search_label_compte=' . urlencode($search_label_account); } - if (! empty($search_mvt_label)) { - $filter['t.label_operation'] = $search_mvt_label; - $options .= '&search_mvt_label=' . urlencode($search_mvt_label); + if (! empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $options .= '&search_doc_ref=' . urlencode($search_doc_ref); + } + if (! empty($search_label_operation)) { + $filter['t.label_operation'] = $search_label_operation; + $options .= '&search_label_operation=' . urlencode($search_label_operation); } if (! empty($search_direction)) { $filter['t.sens'] = $search_direction; @@ -148,9 +152,18 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_accountancy_code = ''; $search_accountancy_code_start = ''; $search_label_account = ''; - $search_mvt_label = ''; + $search_doc_ref = ''; + $search_label_operation = ''; $search_direction = ''; $search_ledger_code = ''; + $search_date_start=''; + $search_date_end=''; + $search_date_startyear=''; + $search_date_startmonth=''; + $search_date_startday=''; + $search_date_endyear=''; + $search_date_endmonth=''; + $search_date_endday=''; } if ($action == 'delmouvconfirm') { @@ -251,16 +264,16 @@ print '' . $object->select_account($search_accountancy_c print ''; print ''; print $langs->trans('From') . ': '; -print $form->select_date($search_date_start, 'date_start', 0, 0, 1); +print $form->select_date($search_date_start, 'search_date_start', 0, 0, 1); print '
'; print $langs->trans('to') . ': '; -print $form->select_date($search_date_end, 'date_end', 0, 0, 1); +print $form->select_date($search_date_end, 'search_date_end', 0, 0, 1); print ''; -print ''; -print ''; +print ''; +print ''; print ' '; print ' '; -print ''; +print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -270,7 +283,7 @@ print ''; print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF']); print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre("Piece", $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre("Label"); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 6b7e925832b..0b0d42b0075 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -384,14 +384,15 @@ class AccountingAccount extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $withlabel 0=No label, 1=Include label of account - * @param int $nourl 1=Disable url - * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $withlabel 0=No label, 1=Include label of account + * @param int $nourl 1=Disable url + * @param string $moretitle Add more text to title tooltip + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0) + function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0, $save_lastsearch_value=-1) { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -402,6 +403,11 @@ class AccountingAccount extends CommonObject $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $picto = 'billr'; $label=''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 13b25599280..a703e025c76 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -354,6 +354,67 @@ class BookKeeping extends CommonObject } } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("Transaction") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->piece_num; + + $url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowTransaction"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->piece_num; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + return $result; + } + /** * Create object into database * @@ -676,12 +737,12 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=' . $value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; - } elseif ($key == 't.label_operation') { - $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.credit' || $key == 't.debit') { + $sqlwhere[] = natural_search($key, $value, 1, 1); } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = natural_search($key, $value, 0, 1); } } } @@ -804,13 +865,14 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; + } elseif ($key == 't.credit' || $key == 't.debit') { + $sqlwhere[] = natural_search($key, $value, 1, 1); } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = natural_search($key, $value, 0, 1); } } } - $sql.= ' WHERE 1 = 1'; - $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; + $sql.= ' WHERE entity IN (' . getEntity('accountancy') . ')'; if (count($sqlwhere) > 0) { $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0eaa3efff8f..b5e7174f9b0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1001,13 +1001,7 @@ else } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; print "\n"; @@ -1277,13 +1271,7 @@ else print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit',$parameters); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 760791027cb..899ba0c9db7 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -463,24 +463,15 @@ class Adherent extends CommonObject $action='update'; - // Actions on extra fields (by external module) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('memberdao')); - $parameters=array('id'=>$this->id); - $action=''; - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; // Update password if (! $error && $this->pass) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index f1b44d3f1e7..75f518074b1 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -171,22 +171,15 @@ class AdherentType extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('membertypedao')); - $parameters=array('membertype'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 0021cac68b4..59fa9eeae2f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -80,7 +80,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'aZ09'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity); @@ -156,26 +156,26 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } } - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'int'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'aZ09'),'chaine',0,'',$conf->entity); // Local taxes - dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'aZ09'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'aZ09'),'chaine',0,'',$conf->entity); if($_POST["optionlocaltax1"]=="localtax1on") { @@ -185,9 +185,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } else { - dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','aZ09'),'chaine',0,'',$conf->entity); } - dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'aZ09'),'chaine',0,'',$conf->entity); } if($_POST["optionlocaltax2"]=="localtax2on") { @@ -197,9 +197,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } else { - dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','aZ09'),'chaine',0,'',$conf->entity); } - dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'aZ09'),'chaine',0,'',$conf->entity); } if ($action != 'updateedit' && ! $error) @@ -415,7 +415,7 @@ if ($action == 'edit' || $action == 'updateedit') // IDs of the company (country-specific) print ''; - print ''; + print ''; $langs->load("companies"); @@ -568,7 +568,7 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; print ''; - print ''; + print ''; print ''; print "\n"; @@ -601,7 +601,7 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'.$langs->trans("VATManagement").''.$langs->trans("Description").''.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; print ''; - print ''; + print ''; print ''; print "\n"; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php new file mode 100644 index 00000000000..5b532a3822f --- /dev/null +++ b/htdocs/admin/dav.php @@ -0,0 +1,163 @@ + + * + * 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/admin/dav.php + * \ingroup dav + * \brief Page to setup DAV server + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("agenda"); + +$def = array(); +$actionsave=GETPOST('save','alpha'); + +// Sauvegardes parametres +if ($actionsave) +{ + $i=0; + + $db->begin(); + + $i+=dolibarr_set_const($db,'XXX',trim(GETPOST('XXX','alpha')),'chaine',0,'',$conf->entity); + + if ($i >= 4) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + setEventMessages($langs->trans("SaveFailed"), null, 'errors'); + } +} + + + +/** + * View + */ + + +llxHeader('', $langs->trans("DAVSetup"), $wikihelp); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("DAVSetup"),$linkback,'title_setup'); + + +print '
'; +print ''; + +$head=dav_admin_prepare_head(); + +dol_fiche_head($head, 'webdav', '', -1, 'action'); + +print $langs->trans("WebDAVSetupDesc")."
\n"; +print "
\n"; + +/* +print '
'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").''.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").' 
'; + +print ''; +print ""; +print ""; +//print ""; +print ""; +print ""; + +print ''; +print '"; +print ''; +print ""; +print ""; + +print '
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")." 
'.$langs->trans("PasswordTogetVCalExport")."'; +if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +print ' 
'; +*/ + +dol_fiche_end(); + +/*print '
'; +print "trans("Save")."\">"; +print "
"; +*/ +print "\n"; + + +clearstatcache(); + +//if ($mesg) print "
$mesg
"; +print "
"; + + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + +// Show message +$message=''; +$url=''.$urlwithroot.'/dav/fileserver.php'; +$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url); +$message.='
'; +print $message; + +/*$message =$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAutoEvent",'systemauto','systemauto').'
'; + +print info_admin($message); +*/ + +/* +if (! empty($conf->use_javascript_ajax)) +{ + print "\n".''; +} +*/ + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ee09d3458a7..d8d2382a59f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -53,6 +53,7 @@ $code=GETPOST('code','alpha'); $allowed=$user->admin; if ($id == 7 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Tax page allowed to manager of chart account if ($id == 10 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Vat page allowed to manager of chart account +if ($id == 17 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with type of expense report and accounting account allowed to manager of chart account if (! $allowed) accessforbidden(); $acts[0] = "activate"; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 1999aab006c..74494ee09ea 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -266,7 +266,7 @@ if ($mode == 'overwrite') print '
'; print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); $urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation'; - print ' ('.$langs->trans("SeeAlso").': '.$langs->trans("Here").')
'; + print ' ('.$langs->trans("SeeAlso", ''.$langs->trans("Here").'').')
'; print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n"; print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."
\n"; print '
'; @@ -552,7 +552,9 @@ if ($mode == 'searchkey') if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { $transifexlangfile='$'; // $ means 'All' - $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; + //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; + $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; + print '   '.img_picto('FixOnTransifex', 'object_globe').''; } } diff --git a/htdocs/assets/class/asset_type.class.php b/htdocs/assets/class/asset_type.class.php index 9889ceeb5d1..d4d12916e9a 100644 --- a/htdocs/assets/class/asset_type.class.php +++ b/htdocs/assets/class/asset_type.class.php @@ -155,22 +155,15 @@ class AssetType extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('assettypedao')); - $parameters=array('assettype'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d8d5b10a2b5..71240d63d8f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -338,28 +338,23 @@ class Categorie extends CommonObject $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookModuleNamedao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_CREATE',$user); - if ($result < 0) { $error++; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } if ( ! $error ) { @@ -432,28 +427,23 @@ class Categorie extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO the hook duplicates the trigger !! - $hookmanager->initHooks(array('HookCategorydao')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; - // Call trigger - $result=$this->call_trigger('CATEGORY_MODIFY',$user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } - // End call triggers + if (! $error) + { + // Call trigger + $result=$this->call_trigger('CATEGORY_MODIFY',$user); + if ($result < 0) { $error++; $this->db->rollback(); return -1; } + // End call triggers + } $this->db->commit(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index f6a0417bbda..b79dee21478 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -368,13 +368,12 @@ if ($type == Categorie::TYPE_PRODUCT) print ''.$prod->label."\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -416,13 +415,12 @@ if ($type == Categorie::TYPE_SUPPLIER) print "\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -470,13 +468,12 @@ if($type == Categorie::TYPE_CUSTOMER) print "\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -524,13 +521,12 @@ if ($type == Categorie::TYPE_MEMBER) print ''.$member->firstname."\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -575,14 +571,12 @@ if ($type == Categorie::TYPE_CONTACT) print "\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_CONTACT) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -629,14 +623,12 @@ if ($type == Categorie::TYPE_ACCOUNT) print ''.$account->number."\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; @@ -682,14 +674,12 @@ if ($type == Categorie::TYPE_PROJECT) print ''.$project->title."\n"; // Link to delete from category print ''; - $typeid=$object->type; $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - if ($typeid == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; - if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; - if ($typeid == Categorie::TYPE_ACCOUNT) $permission=$user->rights->banque->configurer; - if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; + if ($type == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); + if ($type == Categorie::TYPE_SUPPLIER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_CUSTOMER) $permission=$user->rights->societe->creer; + if ($type == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->creer; + if ($type == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer; if ($permission) { print ""; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 7960bbd764d..5234a05db43 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -384,23 +384,15 @@ class ActionComm extends CommonObject { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } - else if ($reshook < 0) $error++; } if (! $error && ! $notrigger) @@ -865,23 +857,15 @@ class ActionComm extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('actioncommdao')); - $parameters=array('actcomm'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } - else if ($reshook < 0) $error++; // Now insert assignedusers if (! $error) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 7fd76b5d1a9..b507d9c72b9 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -115,13 +115,17 @@ class AgendaEvents extends DolibarrApi // 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; + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $sql = "SELECT t.id as rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index a200c6571b2..9221c7d2ede 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -234,7 +234,7 @@ $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " a.fk_element, a.elementtype,"; $sql.= " c.code as type_code, c.libelle as type_label,"; -$sql.= " sp.lastname, sp.firstname"; +$sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; @@ -602,9 +602,14 @@ if ($resql) print ''; if ($obj->fk_contact > 0) { + $contactstatic->id=$obj->fk_contact; + $contactstatic->email=$obj->email; $contactstatic->lastname=$obj->lastname; $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; + $contactstatic->phone_pro=$obj->phone_pro; + $contactstatic->phone_mobile=$obj->phone_mobile; + $contactstatic->phone_perso=$obj->phone_perso; + $contactstatic->country_id=$obj->country_id; print $contactstatic->getNomUrl(1,'',28); } else diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 4b01ddfaba8..f9fad78a1f0 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -106,12 +106,10 @@ if ($result) $newcardbutton=''.$langs->trans('NewMailing').''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num, '', 'title_generic.png', 0, $newcardbutton); - $i = 0; - $param = "&sall=".urlencode($sall); - if ($filteremail) $param.='&filteremail='.urlencode($filteremail); + $param = "&sall=".urlencode($sall); + if ($filteremail) $param.='&filteremail='.urlencode($filteremail); print '
'; if ($optioncss != '') print ''; @@ -121,7 +119,9 @@ if ($result) print ''; print ''; - $moreforfilter = ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num, '', 'title_generic.png', 0, $newcardbutton); + + $moreforfilter = ''; print '
'; print ''."\n"; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6e98329a4cc..68abd9f9a3f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1114,12 +1114,8 @@ class Propal extends CommonObject { $action='update'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -1130,9 +1126,8 @@ class Propal extends CommonObject } } } - else if ($reshook < 0) $error++; - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_CREATE',$user); @@ -3953,7 +3948,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_INSERT',$user); @@ -4136,7 +4131,7 @@ class PropaleLigne extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 57aa7ce8b04..b3757021ee8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1269,24 +1269,16 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('ORDER_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) + // Actions on extra fields + $result = $object->insertExtraFields('ORDER_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; + } } - if ($error) - $action = 'edit_extras'; + if ($error) $action = 'edit_extras'; } if ($action == 'set_thirdparty' && $user->rights->commande->creer) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index dd0e41ee836..0c63da5d4c2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4208,7 +4208,7 @@ class OrderLine extends CommonOrderLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEORDER_UPDATE',$user); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 397d9fd5d7b..c583e9180ff 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -381,7 +381,8 @@ if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPO if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); if (GETPOST("search_thirdparty",'int')) $param.='&thirdparty='.urlencode(GETPOST("search_thirdparty",'int')); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($action == 'reconcile') $param.='&action=reconcile'; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -420,19 +421,17 @@ if ($id > 0 || ! empty($ref)) if ($action != 'reconcile') { - //print '
'; - if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $newparam = $param; + $newparam = preg_replace('/search_conciliated=\d+/i','',$newparam); + $buttonreconcile = ''.$langs->trans("Conciliate").''; } else { $buttonreconcile = ''.$langs->trans("Conciliate").''; } } - - //print '
'; } } else @@ -990,12 +989,12 @@ if ($resql) { $tmpnbfieldbeforebalance=0; $tmpnbfieldafterbalance=0; - $balancefieldfound=false; + $balancefieldfound=0; foreach($arrayfields as $key => $val) { if ($key == 'balancebefore' || $key == 'balance') { - $balancefieldfound=true; + $balancefieldfound++; continue; } if (! empty($arrayfields[$key]['checked'])) @@ -1026,9 +1025,20 @@ if ($resql) print ''; } - print ''; + + if (! empty($arrayfields['balancebefore']['checked'])) + { + print ''; + } + if (! empty($arrayfields['balance']['checked'])) + { + print ''; + } + print '\n"; print "\n"; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print "
'; print ''; - print price(price2num($balance, 'MT'), 1, $langs); - print ''; + print price(price2num($balance, 'MT'), 1, $langs); + print ''; + print price(price2num($balance, 'MT'), 1, $langs); + print ''; print ''; print ' '; @@ -210,12 +218,12 @@ $account_to=''; $label=''; $amount=''; -if($error) +if ($error) { $account_from = GETPOST('account_from','int'); $account_to = GETPOST('account_to','int'); $label = GETPOST('label','alpha'); - $amount = GETPOST('amount','int'); + $amount = GETPOST('amount','alpha'); } print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_bank.png'); @@ -246,9 +254,9 @@ print ""; $form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "
"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7cd8b8e07b8..044ca7da392 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2117,7 +2117,7 @@ if (empty($reshook)) $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - + if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { if($fromElement == 'commande') @@ -2164,7 +2164,7 @@ if (empty($reshook)) $fk_prev_id = ''; $fk_unit = $originLine->fk_unit; $pu_ht_devise = $originLine->multicurrency_subprice; - + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise); if($res > 0){ $importCount++; @@ -2172,18 +2172,18 @@ if (empty($reshook)) $error++; } } - else{ - $error++; + else{ + $error++; } } - + if($error) { setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors'); } } } - + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -2209,22 +2209,15 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('invoicedao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('BILL_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error ++; + if (! $error) + { + // Actions on extra fields + $result = $object->insertExtraFields('BILL_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) @@ -4537,16 +4530,16 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); - + $compatibleImportElementsList = false; - if($user->rights->facture->creer - && $object->statut == Facture::STATUS_DRAFT + if($user->rights->facture->creer + && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) { $compatibleImportElementsList = array('commande'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList); - + // Show online payment link $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8759f2eebf3..aebce8e4b07 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1791,7 +1791,7 @@ class FactureLigneRec extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_REC_UPDATE',$user); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 77238e5b62d..343bbbe6414 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -750,35 +750,20 @@ class Facture extends CommonInvoice { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - /* - $hookmanager->initHooks(array('invoicedao')); - $parameters=array('invoiceid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - {*/ + // Actions on extra fields if (! $error) { $result=$this->insertExtraFields(); if ($result < 0) $error++; } - /*} - } - else if ($reshook < 0) $error++;*/ - if (! $error) - { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - } - } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } if (! $error) { @@ -4697,7 +4682,7 @@ class FactureLigne extends CommonInvoiceLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_UPDATE',$user); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6f96e74d345..33132620662 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -417,7 +417,8 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; - if (! $error) { + if (! $error) + { $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 32dfd03a8bf..8845d0bc8d7 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -90,12 +90,12 @@ $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_user = GETPOST('search_user','int'); $search_sale = GETPOST('search_sale','int'); -$day = GETPOST('day','int'); -$month = GETPOST('month','int'); -$year = GETPOST('year','int'); -$day_lim = GETPOST('day_lim','int'); -$month_lim = GETPOST('month_lim','int'); -$year_lim = GETPOST('year_lim','int'); +$search_day = GETPOST('search_day','int'); +$search_month = GETPOST('search_month','int'); +$search_year = GETPOST('search_year','int'); +$search_day_lim = GETPOST('search_day_lim','int'); +$search_month_lim = GETPOST('search_month_lim','int'); +$search_year_lim = GETPOST('search_year_lim','int'); $option = GETPOST('search_option'); if ($option == 'late') { @@ -218,14 +218,14 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','a $search_type=''; $search_country=''; $search_type_thirdparty=''; - $day=''; - $year=''; - $month=''; + $search_day=''; + $search_year=''; + $search_month=''; $option=''; $filter=''; - $day_lim=''; - $year_lim=''; - $month_lim=''; + $search_day_lim=''; + $search_year_lim=''; + $search_month_lim=''; $toselect=''; $search_array_options=array(); } @@ -443,31 +443,31 @@ if ($search_status != '' && $search_status >= 0) if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); -if ($month > 0) +if ($search_month > 0) { - if ($year > 0 && empty($day)) - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else if ($year > 0 && ! empty($day)) - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $serch_year))."'"; else $sql.= " AND date_format(f.datef, '%m') = '".$month."'"; } -else if ($year > 0) +else if ($search_year > 0) { - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if ($month_lim > 0) { - if ($year_lim > 0 && empty($day_lim)) - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'"; - else if ($year_lim > 0 && ! empty($day_lim)) - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; + if ($search_year_lim > 0 && empty($search_day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($search_year_lim,$search_month_lim,false))."' AND '".$db->idate(dol_get_last_day($search_year_lim,$search_month_lim,false))."'"; + else if ($search_year_lim > 0 && ! empty($search_day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_lim, $search_day_lim, $search_year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_lim, $search_day_lim, $search_year_lim))."'"; else - $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($month_lim)."'"; + $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$db->escape($search_month_lim)."'"; } -else if ($year_lim > 0) +else if ($search_year_lim > 0) { - $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($search_year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_lim,12,false))."'"; } if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; @@ -538,12 +538,12 @@ if ($resql) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall) $param.='&sall='.urlencode($sall); - if ($day) $param.='&day='.urlencode($day); - if ($month) $param.='&month='.urlencode($month); - if ($year) $param.='&year=' .urlencode($year); - if ($day_lim) $param.='&day_lim='.urlencode($day_lim); - if ($month_lim) $param.='&month_lim='.urlencode($month_lim); - if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year=' .urlencode($search_year); + if ($search_day_lim) $param.='&search_day_lim='.urlencode($search_day_lim); + if ($search_month_lim) $param.='&search_month_lim='.urlencode($search_month_lim); + if ($search_year_lim) $param.='&search_year_lim=' .urlencode($search_year_lim); if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer); if ($search_type != '') $param.='&search_type='.urlencode($search_type); @@ -558,9 +558,9 @@ if ($resql) if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_paymentmode > 0) $param.='search_paymentmode='.urlencode($search_paymentmode); - if ($show_files) $param.='&show_files=' .$show_files; - if ($option) $param.="&search_option=".$option; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($show_files) $param.='&show_files='.urlencode($show_files); + if ($option) $param.="&search_option=".urlencode($option); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -707,18 +707,18 @@ if ($resql) if (! empty($arrayfields['f.date']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; } // Date due if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year_lim?$search_year_lim:-1,'search_year_lim',1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print '
'.$langs->trans("Late"); print ''; } diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 70d52c3d9d3..3dc3e2777c2 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -28,15 +28,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year"); +$year=GETPOST("year","int"); if (empty($year)) { $year_current = strftime("%Y",dol_now()); @@ -45,43 +42,48 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q=GETPOST("q"); if (empty($q)) { - if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); } + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); + + /* * View */ @@ -98,6 +100,9 @@ foreach($listofparams as $param) llxHeader('','','','',0,0,'','',$morequerystring); + +$name=$langs->transcountry($local==1?"LT1ReportByCustomers":"LT2ReportByCustomers", $mysoc->country_code); + $fsearch.='
'; $fsearch.=' '; $fsearch.=' '; @@ -108,7 +113,6 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport if ($calc==0 || $calc==1) // Calculate on invoice for goods and services { - $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $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); @@ -126,7 +130,6 @@ if ($calc==0 || $calc==1) // Calculate on invoice for goods and services } if ($calc==2) // Invoice for goods, payment for services { - $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$langs->trans("CalcModeLT2Debt"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $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); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index cfcb117b0a8..39d8a1dfa6a 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -25,32 +25,58 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -$langs->loadLangs(array("other","compta","banks","bills","companies")); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $localTaxType=GETPOST('localTaxType', 'int'); +// Date range $year=GETPOST("year","int"); -if ($year == 0) +if (empty($year)) { - $year_current = strftime("%Y",time()); - $year_start = $year_current; + $year_current = strftime("%Y",dol_now()); + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q"); + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); + $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + } + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit -$modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha'); /** * print function @@ -103,6 +129,8 @@ function pt ($db, $sql, $date) * View */ +$form=new Form($db); +$company_static=new Societe($db); $tva = new Tva($db); if($localTaxType==1) { @@ -121,34 +149,35 @@ if($localTaxType==1) { $CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2; } +$description = ''; +// Show report header $name = $langs->trans("ReportByMonth"); $description = $langs->trans($LT); $calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' '; $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')
'; + +//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +$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); + $builddate=dol_now(); + llxHeader('', $name); -$textprevyear="".img_previous().""; -$textnextyear=" ".img_next().""; - +//$textprevyear="".img_previous().""; +//$textnextyear=" ".img_next().""; //print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'title_accountancy.png'); -report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); +//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); print '
'; -//print load_fiche_titre($langs->trans("Summary"), '', ''); +print '
'; -print ''; -print ''; - -print '
'; print load_fiche_titre($langs->transcountry($LTSummary,$mysoc->country_code), '', ''); -print ' '; -print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); -print '
'; print ''; print ''; @@ -163,16 +192,26 @@ if($CalcLT==1) { if($CalcLT==2) { print ""; } - print ""; print "\n"; print "\n"; -$y = $year_current ; +$tmp=dol_getdate($date_start); +$y = $tmp['year']; +$m = $tmp['mon']; +$tmp=dol_getdate($date_end); +$yend = $tmp['year']; +$mend = $tmp['mon']; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; -$i=0; -for ($m = 1 ; $m < 13 ; $m++ ) { +$i=0; $mcursor=0; +while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop +{ + $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + if ($m == 13) $y++; + if ($m > 12) $m -= 12; + $mcursor++; + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); @@ -187,20 +226,23 @@ for ($m = 1 ; $m < 13 ; $m++ ) { $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) { + if (! is_array($coll_listbuy) && $coll_listbuy == -1) + { $langs->load("errors"); print ''; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) { + if (! is_array($coll_listbuy) && $coll_listbuy == -2) + { print ''; break; } print ''; - print ''; - if($CalcLT==0) { + print ''; + + if ($CalcLT==0) { $x_coll = 0; foreach($coll_listsell as $vatrate=>$val) { $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; @@ -247,7 +289,8 @@ for ($m = 1 ; $m < 13 ; $m++ ) { print "\n"; $i++; - if ($i > 2) { + if ($i > 2) + { print ''; print ''; if($CalcLT==0) { @@ -272,7 +315,10 @@ print ''; print '
".$langs->transcountry($LTCustomer,$mysoc->country_code)."".$langs->trans("TotalToPay")." 
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'
'.$langs->trans("SubTotal").':
'; -print '
 '; + +print '
'; + +print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); /* * Payed @@ -281,18 +327,18 @@ print '
 '; $sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql.= " AND f.datev >= '".$db->idate($date_start)."'"; +$sql.= " AND f.datev <= '".$db->idate($date_end)."'"; $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); -print '
'; +print '
'; + +print '
'; -print ''; -print ''; llxFooter(); $db->close(); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 54183ef72b9..50bc87d4d27 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/compta/localtax/reglement.php + * \file htdocs/compta/localtax/list.php * \ingroup tax * \brief List of IRPF payments */ @@ -24,15 +24,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; -$langs->load("compta"); $langs->load("compta"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt=GETPOST("localTaxType"); + /* * View */ @@ -41,7 +41,13 @@ llxHeader(); $localtax_static = new Localtax($db); -print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code)); +$newcardbutton=''; +if ($user->rights->tax->charges->creer) +{ + $newcardbutton=''.$langs->trans('NewVATPayment').''; +} + +print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code), $newcardbutton); $sql = "SELECT rowid, amount, label, f.datev as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f "; @@ -66,7 +72,7 @@ if ($result) while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; $localtax_static->id=$obj->rowid; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 5e18c786c18..db316a1d6dc 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -38,10 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range @@ -63,29 +60,31 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q=GETPOST("q"); if (empty($q)) { - if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); } + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check @@ -118,11 +117,11 @@ $fsearch.=' '; $fsearch.=' '; $fsearch.=' '; +$name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code); $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { - $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode"); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $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); @@ -151,7 +150,6 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice } if ($conf->global->$calc==2) // Invoice for goods, payment for services { - $nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode"); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $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); diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index bd97101cc49..71376a566e1 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier * Copyright (C) 2014 Ferran Marcet * @@ -20,9 +20,9 @@ */ /** - * \file htdocs/compta/tva/clients.php - * \ingroup tax - * \brief Page des societes + * \file htdocs/compta/tva/clients.php + * \ingroup tax + * \brief Page of sales taxes */ require '../../main.inc.php'; @@ -32,71 +32,56 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); -$langs->load("other"); -$langs->load("admin"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); // Date range -$year=GETPOST("year"); -if (empty($year)) { +$year=GETPOST("year","int"); +if (empty($year)) +{ $year_current = strftime("%Y",dol_now()); $year_start = $year_current; } else { $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter -if (empty($date_start) || empty($date_end)) {// We define date_start and date_end +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ $q=GETPOST("q"); - if (empty($q)) { - if (isset($_REQUEST["month"])) { - $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); - $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); - } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { - $date_start=dol_get_first_day($year_start,1,false); - $date_end=dol_get_last_day($year_start,3,false); - } - if ($q==2) { - $date_start=dol_get_first_day($year_start,4,false); - $date_end=dol_get_last_day($year_start,6,false); - } - if ($q==3) { - $date_start=dol_get_first_day($year_start,7,false); - $date_end=dol_get_last_day($year_start,9,false); - } - if ($q==4) { - $date_start=dol_get_first_day($year_start,10,false); - $date_end=dol_get_last_day($year_start,12,false); + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } } -$min = price2num(GETPOST("min")); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid','int'); -if ($user->societe_id) { - $socid=$user->societe_id; -} +if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') @@ -135,6 +120,8 @@ $fsearch.=' '; $description=''; +// Show report header +$name=$langs->trans("VATReportByCustomers"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); @@ -150,68 +137,32 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); -// Affiche en-tete du rapport -if ($modetax==1) { // Calculate on invoice for goods and services - $name=$langs->trans("VATReportByCustomersInDueDebtMode"); - $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); - //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - $description.=$fsearch; - $description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; - $builddate=dol_now(); - //$exportlink=$langs->trans("NotYetAvailable"); +$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); +//$periodlink=($year_start?"".img_previous()." ".img_next()."":""); +$description.=$fsearch; +$description.='
' + . ' ' + . $langs->trans('SimpleReport') + . '' + . '
' + . ' ' + . $langs->trans('AddExtraReport') + . '' + . '
'; +$builddate=dol_now(); +//$exportlink=$langs->trans("NotYetAvailable"); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatcust.=' ('.$langs->trans("ToPay").')'; - } - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatsup.=' ('.$langs->trans("ToGetBack").')'; - } +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("Description"); +$amountcust=$langs->trans("AmountHT"); +if ($mysoc->tva_assuj) { + $vatcust.=' ('.$langs->trans("ToPay").')'; } -if ($modetax==0) { // Invoice for goods, payment for services - $name=$langs->trans("VATReportByCustomersInInputOutputMode"); - $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); - //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; - $builddate=dol_now(); - //$exportlink=$langs->trans("NotYetAvailable"); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatcust.=' ('.$langs->trans("ToPay").')'; - } - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatsup.=' ('.$langs->trans("ToGetBack").')'; - } +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$langs->trans("Description"); +$amountsup=$langs->trans("AmountHT"); +if ($mysoc->tva_assuj) { + $vatsup.=' ('.$langs->trans("ToGetBack").')'; } report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 0ccd7013ba4..1c9632fac61 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -27,31 +27,56 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -$langs->loadLangs(array("other","compta","banks","bills","companies","admin")); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); +// Date range $year=GETPOST("year","int"); -if ($year == 0) +if (empty($year)) { - $year_current = strftime("%Y",time()); - $year_start = $year_current; + $year_current = strftime("%Y",dol_now()); + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q"); + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); + $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + } + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit -$modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha'); - /** * print function @@ -104,10 +129,14 @@ function pt ($db, $sql, $date) * View */ +$form=new Form($db); +$company_static=new Societe($db); $tva = new Tva($db); -$name = $langs->trans("ReportByMonth"); +$description = ''; +// Show report header +$name = $langs->trans("ReportByMonth"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); @@ -124,17 +153,19 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); +$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); + $builddate=dol_now(); + llxHeader('', $name); - -$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"').""; -$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; - +//$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"').""; +//$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; //print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); -report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); +//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); print '
'; @@ -148,18 +179,26 @@ print ''; print ''.$langs->trans("Year")." ".$y.''; print ''.$langs->trans("VATToPay").''; print ''.$langs->trans("VATToCollect").''; -print ''.$langs->trans("TotalToPay").''; +print ''.$langs->trans("Balance").''; print ' '."\n"; print ''."\n"; - -$y = $year_current ; - +$tmp=dol_getdate($date_start); +$y = $tmp['year']; +$m = $tmp['mon']; +$tmp=dol_getdate($date_end); +$yend = $tmp['year']; +$mend = $tmp['mon']; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; -$i=0; -for ($m = 1 ; $m < 13 ; $m++ ) +$i=0; $mcursor=0; +while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { + $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + if ($m == 13) $y++; + if ($m > 12) $m -= 12; + $mcursor++; + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); @@ -215,7 +254,8 @@ for ($m = 1 ; $m < 13 ; $m++ ) print "\n"; $i++; - if ($i > 2) { + if ($i > 2) + { print ''; print ''.$langs->trans("SubTotal").':'; print ''.price($subtotalcoll).''; @@ -245,8 +285,8 @@ print load_fiche_titre($langs->trans("VATPaid"), '', ''); $sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql.= " AND f.datep >= '".$db->idate($date_start)."'"; +$sql.= " AND f.datep <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY dm ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); @@ -255,7 +295,6 @@ pt($db, $sql,$langs->trans("Year")." $y"); print '
'; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { /* @@ -267,8 +306,8 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; $sql1 .= " WHERE f.entity = " . $conf->entity; - $sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql1 .= " AND f.datev >= '" . $db->idate($date_start) . "'"; + $sql1 .= " AND f.datev <= '" . $db->idate($date_end) . "'"; $sql1 .= " GROUP BY dm ORDER BY dm ASC"; $result = $db->query($sql1); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 056e16b4d5b..e796ddacac7 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -35,7 +35,7 @@ $langs->load("compta"); $langs->load("bills"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php index 6d33c358af2..e572eb7e006 100644 --- a/htdocs/compta/tva/quadri.php +++ b/htdocs/compta/tva/quadri.php @@ -29,6 +29,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); + $year = GETPOST('year', 'int'); if ($year == 0 ) { @@ -40,7 +42,7 @@ if ($year == 0 ) } // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -259,7 +261,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") $x_paye_sum = 0; $x_paye_ht = 0; foreach($x_both as $rate => $both){ - + print ''; print "$rate%"; print "".price($both['coll']['totalht']).""; @@ -282,7 +284,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") $total = $total + $diff; $subtotal = $subtotal + $diff; - + print ''; print ''; print "".price($diff)."\n"; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 92b67dbfd6f..713cab1dc13 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -38,13 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); -$langs->load("trips"); -$langs->load("other"); -$langs->load("admin"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); // Date range $year=GETPOST("year","int"); @@ -67,26 +61,28 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check @@ -527,7 +523,7 @@ if (! is_array($x_coll) || ! is_array($x_paye)) // Print table headers for this quadri - expenses now print ''; print ''.$elementsup.''; - print ''.$langs->trans("Date").''; + print ''.$langs->trans("DateInvoice").''; if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; else print ''; print ''.$namesup.''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 7d024e6f096..560acabaee9 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -176,26 +176,26 @@ if (empty($reshook)) $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); $object->socid = GETPOST("socid",'int'); - $object->lastname = GETPOST("lastname"); - $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); - $object->poste = GETPOST("poste"); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); + $object->lastname = GETPOST("lastname",'alpha'); + $object->firstname = GETPOST("firstname",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); + $object->poste = GETPOST("poste",'alpha'); + $object->address = GETPOST("address",'alpha'); + $object->zip = GETPOST("zipcode",'alpha'); + $object->town = GETPOST("town",'alpha'); $object->country_id = GETPOST("country_id",'int'); $object->state_id = GETPOST("state_id",'int'); - $object->skype = GETPOST("skype"); + $object->skype = GETPOST("skype",'alpha'); $object->email = GETPOST("email",'alpha'); - $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); - $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->phone_pro = GETPOST("phone_pro",'alpha'); + $object->phone_perso = GETPOST("phone_perso",'alpha'); + $object->phone_mobile = GETPOST("phone_mobile",'alpha'); + $object->fax = GETPOST("fax",'alpha'); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); - $object->note_private = GETPOST("note_private"); + $object->note_public = GETPOST("note_public",'none'); + $object->note_private = GETPOST("note_private",'none'); $object->statut = 1; //Defult status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. @@ -340,33 +340,33 @@ if (empty($reshook)) $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); - $object->old_firstname = GETPOST("old_firstname"); + $object->old_lastname = GETPOST("old_lastname",'alpha'); + $object->old_firstname = GETPOST("old_firstname",'alpha'); $object->socid = GETPOST("socid",'int'); - $object->lastname = GETPOST("lastname"); - $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); - $object->poste = GETPOST("poste"); + $object->lastname = GETPOST("lastname",'alpha'); + $object->firstname = GETPOST("firstname",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); + $object->poste = GETPOST("poste",'alpha'); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); - $object->state_id = GETPOST("state_id",'int'); + $object->address = GETPOST("address",'alpha'); + $object->zip = GETPOST("zipcode",'alpha'); + $object->town = GETPOST("town",'alpha'); + $object->state_id = GETPOST("state_id",'int'); $object->fk_departement = GETPOST("state_id",'int'); // For backward compatibility $object->country_id = GETPOST("country_id",'int'); $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); - $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); - $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->phone_pro = GETPOST("phone_pro",'alpha'); + $object->phone_perso = GETPOST("phone_perso",'alpha'); + $object->phone_mobile = GETPOST("phone_mobile",'alpha'); + $object->fax = GETPOST("fax",'alpha'); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); - $object->note_private = GETPOST("note_private"); + $object->note_public = GETPOST("note_public",'none'); + $object->note_private = GETPOST("note_private",'none'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -541,9 +541,9 @@ else // Name print ''; - print 'lastname).'" autofocus="autofocus">'; + print 'lastname).'" autofocus="autofocus">'; print ''; - print 'firstname).'">'; + print 'firstname).'">'; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -595,8 +595,8 @@ else if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ' / '; - print $formcompany->select_ziptown((GETPOST("zipcode")?GETPOST("zipcode"):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6).' '; - print $formcompany->select_ziptown((GETPOST("town")?GETPOST("town"):$object->town),'town',array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode",'alpha')?GETPOST("zipcode",'alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6).' '; + print $formcompany->select_ziptown((GETPOST("town",'alpha')?GETPOST("town",'alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id')); print ''; // Country @@ -644,7 +644,7 @@ else // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { print ''; @@ -658,13 +658,13 @@ else // Instant message and no email print ''; - print 'jabberid).'">'; + print 'jabberid).'">'; // Skype if (! empty($conf->skype->enabled)) { print ''; - print 'skype).'">'; + print 'skype).'">'; } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 83ad411b4b6..898144f993a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -366,11 +366,8 @@ class Contact extends CommonObject $action='update'; - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('contactdao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -381,7 +378,6 @@ class Contact extends CommonObject } } } - else if ($reshook < 0) $error++; if (! $error && $this->user_id > 0) { diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 6e5ac327e9b..297f7821599 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -27,7 +27,7 @@ // Submit file/link -if (GETPOST('sendit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if (! empty($_FILES)) { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 8f7ee1287fe..419180d6830 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -191,7 +191,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party { - $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } elseif ($val) // Id du contact { @@ -221,7 +221,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party { - $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; } elseif ($val) // Id du contact { @@ -245,13 +245,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $fromtype = GETPOST('fromtype','alpha'); if ($fromtype === 'robot') { - $from = $conf->global->MAIN_MAIL_EMAIL_FROM .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; + $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; } elseif ($fromtype === 'user') { - $from = $user->getFullName($langs) .' <'.$user->email.'>'; + $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; } elseif ($fromtype === 'company') { - $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { $tmp=explode(',', $user->email_aliases); @@ -267,14 +267,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $obj = $db->fetch_object($resql); if ($obj) { - $from = $obj->label.' <'.$obj->email.'>'; + $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; } } else { - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; } - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>'; $message = GETPOST('message','none'); $subject = GETPOST('subject','none'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a620afd900b..4eceecbe655 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3576,19 +3576,6 @@ abstract class CommonObject } - /** - * Return if a country is inside the EEC (European Economic Community) - * @deprecated Use function isInEEC function instead - * - * @return boolean true = country inside EEC, false = country outside EEC - */ - function isInEEC() - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - return isInEEC($this); - } - - // -------------------- // TODO: All functions here must be redesigned and moved as they are not business functions but output functions // -------------------- @@ -5951,8 +5938,16 @@ abstract class CommonObject $e = 0; foreach($extrafields->attribute_label as $key=>$label) { - if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field - if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1 && abs($extrafields->attribute_list[$key]) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + $enabled = $extrafields->attribute_list[$key]; + if (empty($enabled)) continue; // 0 = Never visible field + if (! is_numeric($enabled)) + { + $enabled=dol_eval($enabled, 1); + if (empty($enabled)) continue; + else $enabled = 1; + } + + if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list // Load language if required if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); @@ -6005,11 +6000,11 @@ abstract class CommonObject $domData = ' data-element="extrafield"'; $domData .= ' data-targetelement="'.$this->element.'"'; $domData .= ' data-targetid="'.$this->id.'"'; - + $html_id = !empty($this->id) ? 'extrarow-'.$this->element.'_'.$key.'_'.$this->id : ''; - + $out .= ''; - + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } @@ -6797,14 +6792,16 @@ abstract class CommonObject */ public function fetchCommon($id, $ref = null, $morewhere = '') { - if (empty($id) && empty($ref)) return false; + if (empty($id) && empty($ref) && empty($morewhere)) return -1; $sql = 'SELECT '.$this->getFieldList(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - if (!empty($id)) $sql.= ' WHERE rowid = '.$id; - else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); - if ($morewhere) $sql.=$morewhere; + if (!empty($id)) $sql.= ' WHERE rowid = '.$id; + elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); + else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare + if ($morewhere) $sql.= $morewhere; + $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record $res = $this->db->query($sql); if ($res) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index bf9bcf587f8..0905223c4fe 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -144,7 +144,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibilty (0=never visible, 1=visible on list+forms, 2=list onyl, 3=form only) + * @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') * @param int $notused Deprecated. * @param string $computed Computed value * @param string $entity Entity of extrafields (for multicompany modules) @@ -152,7 +152,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $computed='', $entity='', $langfile='', $enabled='1') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -198,11 +198,11 @@ class ExtraFields * @param string $default_value Default value for field (in database) * @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option')) * @param string $perms Permission - * @param int $list Into list view by default + * @param string $list Into list view by default * @param string $computed Computed value * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0, $computed='') + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list='0', $computed='') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -288,7 +288,7 @@ class ExtraFields * @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibily + * @param string $list Visibily * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -297,7 +297,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') { global $conf,$user; @@ -306,7 +306,7 @@ class ExtraFields // Clean parameters if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -361,7 +361,7 @@ class ExtraFields $sql.= " ".$alwayseditable.","; $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " ".$list.","; + $sql.= " '".$this->db->escape($list)."',"; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; @@ -496,7 +496,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visibility + * @param string $list Visibility * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -605,7 +605,7 @@ class ExtraFields * @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check - * @param int $list Visiblity + * @param string $list Visiblity * @param int $notused Deprecated. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value @@ -614,7 +614,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); @@ -624,7 +624,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; if (empty($pos)) $pos=0; - if (empty($list)) $list=0; + if (empty($list)) $list='0'; if (empty($required)) $required=0; if (empty($unique)) $unique=0; if (empty($alwayseditable)) $alwayseditable=0; @@ -688,7 +688,7 @@ class ExtraFields $sql.= " ".$pos.","; $sql.= " '".$this->db->escape($alwayseditable)."',"; $sql.= " '".$this->db->escape($params)."',"; - $sql.= " ".$list.", "; + $sql.= " '".$this->db->escape($list)."', "; $sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; $sql .= " " . $user->id . ","; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index df6f389180f..0e125a7b944 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -862,9 +862,17 @@ class FormFile $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity); } - $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; - - $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) + // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) + // @TODO Why not showing by default all files by just removing the '[^\-]+' at end of regex ? + if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) + { + $filterforfilesearch = preg_quote(basename($modulesubdir),'/'); + } + else + { + $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; + } + $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview //var_dump($file_list); // For ajax treatment diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 1f2fb48f4cc..320b8cc1b63 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -635,9 +635,58 @@ function getFormeJuridiqueLabel($code) } } + +/** + * Return list of countries that are inside the EEC (European Economic Community) + * TODO Add a field into country dictionary. + * + * @return array Array of countries code in EEC + */ +function getCountriesInEEC() +{ + // List of all country codes that are in europe for european vat rules + // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 + $country_code_in_EEC=array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta + //'NO', // Norway + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom + //'CH', // Switzerland - No. Swizerland in not in EEC + ); + + return $country_code_in_EEC; +} + /** * Return if a country of an object is inside the EEC (European Economic Community) - * TODO Add a field into country dictionary. * * @param Object $object Object * @return boolean true = country inside EEC, false = country outside EEC @@ -646,43 +695,8 @@ function isInEEC($object) { if (empty($object->country_code)) return false; - // List of all country codes that are in europe for european vat rules - // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta - //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom - //'CH', // Switzerland - No. Swizerland in not in EEC - ); + $country_code_in_EEC = getCountriesInEEC(); + //print "dd".$this->country_code; return in_array($object->country_code, $country_code_in_EEC); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 538fa9defa6..a0d67e5072b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -545,10 +545,10 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU case 'array': if (! is_array($out) || empty($out)) $out=array(); break; - case 'nohtml': + case 'nohtml': // Recommended for most scalar parameters $out=dol_string_nohtmltag($out, 0); break; - case 'alphanohtml': // Recommended for search params + case 'alphanohtml': // Recommended for search parameters if (! is_array($out)) { $out=trim($out); @@ -939,7 +939,7 @@ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) * @param int $keepb 1=Preserve b tags (otherwise, remove them) * @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value) * @return string Escaped string - * @see dol_string_nohtmltag + * @see dol_string_nohtmltag, dol_string_nospecial, dol_string_unaccent */ function dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0) { diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index d2bc3b37183..26c31a4eee0 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -200,6 +200,12 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire { global $conf; + // If we use date_start and date_end, we must not use $y, $m, $q + if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + { + dol_print_error('', 'Bad value of input parameter for tax_by_date'); + } + $list=array(); if ($direction == 'sell') diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 2ce3cf9d9f6..9ffe92699d7 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -64,17 +64,17 @@ class modCron extends DolibarrModules //------------- $this->config_page_url = array("cron.php@cron"); - // Dependancies - //------------- + // Dependancies + //------------- $this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->langfiles = array("cron"); + $this->langfiles = array("cron"); - // Constants - //----------- - $this->const = array( + // Constants + //----------- + $this->const = array( 0=>array( 'CRON_KEY', 'chaine', diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index 0492209f3f0..cede86796a0 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -89,8 +89,8 @@ class modDav extends DolibarrModules 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array(''), // Set this to relative path of css file if module has its own css file - 'js' => array(''), // Set this to relative path of js file if module must load a js on all pages + 'css' => array(), // Set this to relative path of css file if module has its own css file + 'js' => array(), // Set this to relative path of js file if module must load a js on all pages 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' ); @@ -305,7 +305,7 @@ class modDav extends DolibarrModules */ public function init($options='') { - $this->_load_tables(); + //$this->_load_tables('/dav/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index e08983f9e10..5ecf859f603 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -252,7 +252,7 @@ else textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?> - + diff --git a/htdocs/dav/dav.lib.php b/htdocs/dav/dav.lib.php index 326ad7995b5..719fc2a5c99 100644 --- a/htdocs/dav/dav.lib.php +++ b/htdocs/dav/dav.lib.php @@ -38,3 +38,35 @@ if(!defined('CDAV_URI_KEY')) else define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']),0,8)); } + + + + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function dav_admin_prepare_head() +{ + global $db, $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/dav.php?id='.$object->id; + $head[$h][1] = $langs->trans("WebDAV"); + $head[$h][2] = 'webdav'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav','remove'); + + return $head; +} + diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 86bfe2e6823..4be83ffa30a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -396,7 +396,7 @@ class Don extends CommonObject } // Update extrafield - if (!$error) { + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -482,7 +482,7 @@ class Don extends CommonObject } // Update extrafield - if (!$error) + if (! $error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9c5aec63951..4d7db533e12 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -133,9 +133,7 @@ if ($resql) $newcardbutton=''.$langs->trans('NewDonation').''; - print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords, 'title_generic.png', 0, $newcardbutton); - - print ''."\n"; + print ''."\n"; if ($optioncss != '') print ''; print ''; print ''; @@ -144,7 +142,9 @@ if ($resql) print ''; print ''; - if ($search_all) + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords, 'title_generic.png', 0, $newcardbutton); + + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 719f738d081..89f1aee7b4b 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -164,20 +164,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('expeditiondao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 05328d57b05..dd3123930fe 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -311,23 +311,15 @@ class Expedition extends CommonObject } } - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('expeditiondao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error && ! $notrigger) { @@ -1105,7 +1097,7 @@ class Expedition extends CommonObject $error++; } - if (! $error) + if (! $error) { if (! $notrigger) { @@ -2690,19 +2682,21 @@ class ExpeditionLigne extends CommonObjectLine $this->errors[]=$this->db->lasterror()." - sql=$sql"; $error++; } - else + } + + if (! $error) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $this->errors[]=$this->error; - $error++; - } + $this->errors[]=$this->error; + $error++; } } } + if (! $error && ! $notrigger) { // Call trigger diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index e3218d5f578..ac1368660da 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -189,20 +189,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('SHIPMENT_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index eea3545bb07..33bf5245e62 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -288,20 +288,13 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('expensereportdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('FICHINTER_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) - $error++; + // Actions on extra fields + $result = $object->insertExtraFields('FICHINTER_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } if ($error) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 54565932521..2944220458d 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -73,7 +73,7 @@ $search_user = GETPOST('search_user','int'); $search_amount_ht = GETPOST('search_amount_ht','alpha'); $search_amount_vat = GETPOST('search_amount_vat','alpha'); $search_amount_ttc = GETPOST('search_amount_ttc','alpha'); -$search_status = (GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); +$search_status = (GETPOST('search_status','intcomma')!=''?GETPOST('search_status','intcomma'):GETPOST('statut','intcomma')); $month_start = GETPOST("month_start","int"); $year_start = GETPOST("year_start","int"); $month_end = GETPOST("month_end","int"); @@ -304,11 +304,7 @@ if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amoun // User if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; // Status -if ($search_status != '' && $search_status >= 0) -{ - if (strstr($search_status, ',')) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; - else $sql.=" AND d.fk_statut = ".$search_status; -} +if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b4a2b58a18e..01e7e1d7160 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -750,20 +750,12 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('interventiondao')); - $parameters=array('id'=>$object->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + $result=$object->insertExtraFields('INTERVENTION_MODIFY'); + if ($result < 0) { - $result=$object->insertExtraFields('INTERVENTION_MODIFY'); - if ($result < 0) - { - $error++; - } + $error++; } - else if ($reshook < 0) $error++; } if ($error) $action = 'edit_extras'; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 1204830fb0f..9f596e61279 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -253,7 +253,7 @@ class Fichinter extends CommonObject } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('FICHINTER_CREATE',$user); diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 0637afe8ff1..3ba0089070c 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -151,13 +151,23 @@ if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php s // Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) { - if (! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST']) - && (empty($_SERVER['HTTP_REFERER']) || ! preg_match('/'.preg_quote($_SERVER['HTTP_HOST'],'/').'/i', $_SERVER['HTTP_REFERER']))) + if (! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST'])) { - //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; - print "Access refused by CSRF protection in main.inc.php. Referer of form is outside server that serve the POST.\n"; - print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n"; - die; + $csrfattack=false; + if (empty($_SERVER['HTTP_REFERER'])) $csrfattack=true; // An evil browser was used + else + { + $tmpa=parse_url($_SERVER['HTTP_HOST']); + $tmpb=parse_url($_SERVER['HTTP_REFERER']); + if ((empty($tmpa['host'])?$tmpa['path']:$tmpa['host']) != (empty($tmpb['host'])?$tmpb['path']:$tmpb['host'])) $csrfattack=true; + } + if ($csrfattack) + { + //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; + print "Access refused by CSRF protection in main.inc.php. Referer of form is outside server that serve the POST.\n"; + print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n"; + die; + } } // Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on. } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index af36e6d572e..14b9a490da9 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -121,11 +121,13 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; + if (! $error) { $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) $error++; } + if ($error) $action = 'edit_extras'; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 04e22501b95..07788e55947 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3259,7 +3259,6 @@ class CommandeFournisseurLigne extends CommonOrderLine if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); if ($result < 0) { @@ -3347,7 +3346,6 @@ class CommandeFournisseurLigne extends CommonOrderLine { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); if ($result < 0) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2a9198f0380..35addb8ee13 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -444,23 +444,15 @@ class FactureFournisseur extends CommonInvoice { $action='create'; - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierinvoicedao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found + if ($result < 0) { - $result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found - if ($result < 0) - { - $error++; - } + $error++; } } - else if ($reshook < 0) $error++; if (! $error) { @@ -2830,7 +2822,9 @@ class SupplierInvoiceLine extends CommonObjectLine if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if ($this->insertExtraFields() < 0) { + $result = $this->insertExtraFields(); + if ($result < 0) + { $error++; } } @@ -2976,7 +2970,7 @@ class SupplierInvoiceLine extends CommonObjectLine } } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('LINEBILL_SUPPLIER_CREATE',$user); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 31574a4b3c0..89a508ea2ec 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -955,32 +955,19 @@ if (empty($reshook)) if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierorderdao')); - $parameters=array('id'=>$object->id); - - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); + if ($result < 0) { - $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); - - if ($result < 0) - { - $error++; - } - + $error++; } } - else if ($reshook < 0) $error++; } - else - { + + if ($error) $action = 'edit_extras'; - } } /* diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 1fe8d82fa87..6f0b4899d6e 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -55,12 +55,12 @@ $confirm=GETPOST('confirm','alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'supplierorderlist'; -$orderyear=GETPOST("orderyear","int"); -$ordermonth=GETPOST("ordermonth","int"); -$orderday=GETPOST("orderday","int"); -$deliveryyear=GETPOST("deliveryyear","int"); -$deliverymonth=GETPOST("deliverymonth","int"); -$deliveryday=GETPOST("deliveryday","int"); +$search_orderyear=GETPOST("search_orderyear","int"); +$search_ordermonth=GETPOST("search_ordermonth","int"); +$search_orderday=GETPOST("search_orderday","int"); +$search_deliveryyear=GETPOST("search_deliveryyear","int"); +$search_deliverymonth=GETPOST("search_deliverymonth","int"); +$search_deliveryday=GETPOST("search_deliveryday","int"); $sall=GETPOST('search_all', 'alphanohtml'); $search_product_category=GETPOST('search_product_category','int'); @@ -181,9 +181,6 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - $ordermonth=''; - $orderyear=''; - $orderday=''; $search_categ=''; $search_user=''; $search_sale=''; @@ -203,12 +200,12 @@ if (empty($reshook)) $search_total_ttc=''; $search_project_ref=''; $search_status=-1; - $orderyear=''; - $ordermonth=''; - $orderday=''; - $deliveryday=''; - $deliverymonth=''; - $deliveryyear=''; + $search_orderyear=''; + $search_ordermonth=''; + $search_orderday=''; + $search_deliveryday=''; + $search_deliverymonth=''; + $search_deliveryyear=''; $billed=''; $search_billed=''; $toselect=''; @@ -524,7 +521,7 @@ if ($search_refsupp) $sql.= natural_search("cf.ref_supplier", $search_refsupp); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_company) $sql .= natural_search('s.nom', $search_company); if ($search_request_author) $sql.=natural_search(array('u.lastname','u.firstname','u.login'), $search_request_author) ; -if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$search_billed; +if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed); //Required triple check because statut=0 means draft filter if (GETPOST('statut', 'intcomma') !== '') @@ -535,31 +532,31 @@ if ($search_status != '' && $search_status >= 0) { $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; } -if ($ordermonth > 0) +if ($search_ordermonth > 0) { - if ($orderyear > 0 && empty($orderday)) - $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($orderyear,$ordermonth,false))."' AND '".$db->idate(dol_get_last_day($orderyear,$ordermonth,false))."'"; - else if ($orderyear > 0 && ! empty($orderday)) - $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $ordermonth, $orderday, $orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $ordermonth, $orderday, $orderyear))."'"; + if ($search_orderyear > 0 && empty($search_orderday)) + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($search_orderyear,$search_ordermonth,false))."' AND '".$db->idate(dol_get_last_day($search_orderyear,$search_ordermonth,false))."'"; + else if ($search_orderyear > 0 && ! empty($search_orderday)) + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_ordermonth, $search_orderday, $search_orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_ordermonth, $search_orderday, $search_orderyear))."'"; else - $sql.= " AND date_format(cf.date_commande, '%m') = '".$ordermonth."'"; + $sql.= " AND date_format(cf.date_commande, '%m') = '".$db->escape($search_ordermonth)."'"; } -else if ($orderyear > 0) +else if ($search_orderyear > 0) { - $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($orderyear,1,false))."' AND '".$db->idate(dol_get_last_day($orderyear,12,false))."'"; + $sql.= " AND cf.date_commande BETWEEN '".$db->idate(dol_get_first_day($search_orderyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_orderyear,12,false))."'"; } -if ($deliverymonth > 0) +if ($search_deliverymonth > 0) { - if ($deliveryyear > 0 && empty($deliveryday)) - $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,$deliverymonth,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,$deliverymonth,false))."'"; - else if ($deliveryyear > 0 && ! empty($deliveryday)) - $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $deliverymonth, $deliveryday, $deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $deliverymonth, $deliveryday, $deliveryyear))."'"; - else - $sql.= " AND date_format(cf.date_livraison, '%m') = '".$deliverymonth."'"; + if ($search_deliveryyear > 0 && empty($search_deliveryday)) + $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_deliveryyear,$search_deliverymonth,false))."' AND '".$db->idate(dol_get_last_day($search_deliveryyear,$search_deliverymonth,false))."'"; + else if ($search_deliveryyear > 0 && ! empty($search_deliveryday)) + $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_eliverymonth, $search_deliveryday, $search_deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_deliverymonth, $search_deliveryday, $search_deliveryyear))."'"; + else + $sql.= " AND date_format(cf.date_livraison, '%m') = '".$db->escape($search_deliverymonth)."'"; } -else if ($deliveryyear > 0) +else if ($search_deliveryyear > 0) { - $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,1,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,12,false))."'"; + $sql.= " AND cf.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_deliveryyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_deliveryyear,12,false))."'"; } if ($search_town) $sql.= natural_search('s.town', $search_town); if ($search_zip) $sql.= natural_search("s.zip",$search_zip); @@ -614,12 +611,12 @@ if ($resql) if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall) $param.="&search_all=".$sall; - if ($orderday) $param.='&orderday='.$orderday; - if ($ordermonth) $param.='&ordermonth='.$ordermonth; - if ($orderyear) $param.='&orderyear='.$orderyear; - if ($deliveryday) $param.='&deliveryday='.$deliveryday; - if ($deliverymonth) $param.='&deliverymonth='.$deliverymonth; - if ($deliveryyear) $param.='&deliveryyear='.$deliveryyear; + if ($search_orderday) $param.='&search_orderday='.$search_orderday; + if ($search_ordermonth) $param.='&search_ordermonth='.$search_ordermonth; + if ($search_orderyear) $param.='&search_orderyear='.$search_orderyear; + if ($search_deliveryday) $param.='&search_deliveryday='.$search_deliveryday; + if ($search_deliverymonth) $param.='&search_deliverymonth='.$search_deliverymonth; + if ($search_deliveryyear) $param.='&search_deliveryyear='.$search_deliveryyear; if ($search_ref) $param.='&search_ref='.$search_ref; if ($search_company) $param.='&search_company='.$search_company; if ($search_user > 0) $param.='&search_user='.$search_user; @@ -822,18 +819,18 @@ if ($resql) if (! empty($arrayfields['cf.date_commande']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($orderyear?$orderyear:-1,'orderyear',1, 20, 5); + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_orderyear?$search_orderyear:-1,'search_orderyear',1, 20, 5); print ''; } // Date delivery if (! empty($arrayfields['cf.date_delivery']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($deliveryyear?$deliveryyear:-1,'deliveryyear',1, 20, 5); + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_deliveryyear?$search_deliveryyear:-1,'search_deliveryyear',1, 20, 5); print ''; } if (! empty($arrayfields['cf.total_ht']['checked'])) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d0d3b505245..35b81b39a71 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1459,35 +1459,21 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (!$error) + if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('supplierinvoicedao')); - $parameters=array('id'=>$object->id); - - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - - if (empty($reshook)) + // Actions on extra fields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); + if ($result < 0) { - - $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); - - if ($result < 0) - { - $error++; - } - + $error++; } } - else if ($reshook < 0) $error++; } - else - { + + if ($error) $action = 'edit_extras'; - } } if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cc5bb9bb55b..3397e6fced8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -85,7 +85,7 @@ if (! $sortorder) $sortorder="DESC"; $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref = GETPOST('search_ref','alpha'); +$search_ref = GETPOST('search_ref','alphanohtml'); $search_day_create = GETPOST('search_day_create','int'); $search_month_create = GETPOST('search_month_create','int'); $search_year_create = GETPOST('search_year_create','int'); @@ -185,7 +185,7 @@ $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset); // Ref if(!empty($search_ref)) { - $filter.= " AND cp.rowid = ".$db->escape($search_ref); + $filter.= " AND cp.rowid = ".(int) $db->escape($search_ref); } // Start date diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 86ce4580d9e..6345768e6a8 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -44,7 +44,7 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- Description of chart of account FR PCG99-BASE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG99-BASE', 'The base accountancy french plan', 1); --- Description of chart of account FR PCG14-BASE +-- Description of chart of account FR PCG14-DEV INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG14-DEV', 'The developed accountancy french plan 2014', 1); -- Description of chart of account BE PCMN-BASE diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index c9ef9ff828d..745d070b207 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -46,9 +46,19 @@ ALTER TABLE llx_inventory ADD COLUMN fk_user_modif integer; ALTER TABLE llx_inventory ADD COLUMN fk_user_valid integer; ALTER TABLE llx_inventory ADD COLUMN import_key varchar(14); +-- Missing Chart of accounts in migration 7.0.0 +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG14-DEV', 'The developed accountancy french plan 2014', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 6, 'PCG_SUISSE', 'Switzerland plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (140, 'PCN-LUXEMBURG', 'Plan comptable normalisĂ© Luxembourgeois', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 80, 'DK-STD', 'Standardkontoplan fra SKAT', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 10, 'PCT', 'The Tunisia plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 12, 'PCG', 'The Moroccan chart of accounts', 1); -- For 8.0 +-- delete old permission no more used +DELETE FROM llx_rights_def WHERE perms = 'main' and module = 'commercial'; + delete from llx_rights_def where perms IS NULL; delete from llx_user_rights where fk_user not IN (select rowid from llx_user); delete from llx_usergroup_rights where fk_usergroup not in (select rowid from llx_usergroup); @@ -403,3 +413,10 @@ create table llx_asset_type_extrafields ALTER TABLE llx_asset_type_extrafields ADD INDEX idx_asset_type_extrafields (fk_object); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1); + +UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' OR account_parent IS NULL; +ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0; +ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent); + +ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); + diff --git a/htdocs/install/mysql/tables/llx_accounting_account.key.sql b/htdocs/install/mysql/tables/llx_accounting_account.key.sql index 19a6c95447a..cf62da87daa 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.key.sql @@ -19,6 +19,7 @@ ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_fk_pcg_version (fk_pcg_version); +ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent); ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index aa82664f931..79215115cfb 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -29,7 +29,7 @@ create table llx_accounting_account pcg_type varchar(20) NOT NULL, -- First part of Key for predefined groups pcg_subtype varchar(20) NOT NULL, -- Second part of Key for predefined groups account_number varchar(32) NOT NULL, - account_parent varchar(32) DEFAULT '0', -- Hierarchic parent. TODO Move this as integer, it is a foreign key of llx_accounting_account.rowid + account_parent integer DEFAULT 0, -- Hierarchic parent. label varchar(255) NOT NULL, fk_accounting_category integer DEFAULT 0, -- ID of personalized group for report fk_user_author integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 5c3a318b796..9acf239ee64 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -35,7 +35,7 @@ create table llx_extrafields pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field - list integer DEFAULT 1, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing + list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing langs varchar(64), -- example: fileofmymodule@mymodule fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 7cef35ea5f0..c8973887d2d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -168,7 +168,6 @@ DelYear=Year to delete DelJournal=Journal to delete ConfirmDeleteMvt=This will delete all lines of the Ledger for year and/or from a specific journal. At least one criteria is required. ConfirmDeleteMvtPartial=This will delete the transaction from the Ledger (all lines related to same transaction will be deleted) -DelBookKeeping=Delete record of the Ledger FinanceJournal=Finance journal ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index aef32c1b653..efd33b05ba7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -450,7 +450,7 @@ ModuleCompanyCodePanicum=Return an empty accounting code. ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough).
Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required. UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... -WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be car also to your email provider sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). +WarningPHPMail=WARNING: It is often better to setup outgoing emails to use the email server of your provider instead of the default setup. Some email providers (like Yahoo) does not allow you to send an email from another server than their own server. Your current setup use the server of the application to send email and not the server of your email provider, so some recipients (the one compatible with the restrictive DMARC protocol), will ask your email provider if they can accept your email and some email providers (like Yahoo) may respond "no" because the server is not a server of them, so few of your sent Emails may not be accepted (be carefull also to your email provider sending quota).
If your Email provider (like Yahoo) has this restriction, you must change Email setup to choose the other method "SMTP server" and enter the SMTP server and credentials provided by your Email provider (ask your EMail provider to get SMTP credentials for your account). WarningPHPMail2=If your email SMTP provider need to restrict email client to some IP addresses (very rare), this is the IP address of your ERP CRM application: %s. ClickToShowDescription=Click to show description DependsOn=This module need the module(s) @@ -470,6 +470,7 @@ WatermarkOnDraftExpenseReports=Watermark on draft expense reports AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable) FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails +davDescription=Add a component to be a DAV server # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management @@ -1054,7 +1055,7 @@ AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" or "Save" button at bottom of page) -AccountantDesc=Edit on this page all known information of your accountant/auditor to manage (For this, click on "Modify" or "Save" button at bottom of page) +AccountantDesc=Edit on this page all known information about your accountant/bookkeeper AccountantFileNumber=File number DisplayDesc=You can choose each parameter related to the Dolibarr look and feel here AvailableModules=Available app/modules @@ -1780,6 +1781,7 @@ MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') SeveralLangugeVariatFound=Several language variants found +WebDavServer=URL of %s server : %s ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 4ab64a98224..f1e17a43cfe 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -112,7 +112,7 @@ ExportCal=Export calendar ExtSites=Import external calendars ExtSitesEnableThisTool=Show external calendars (defined into global setup) into agenda. Does not affect external calendars defined by users. ExtSitesNbOfAgenda=Number of calendars -AgendaExtNb=Calendar nb %s +AgendaExtNb=Calendar no. %s ExtSiteUrlAgenda=URL to access .ical file ExtSiteNoLabel=No Description VisibleTimeRange=Visible time range diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 122d1a2a69a..718821bfb26 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -286,8 +286,8 @@ Deposit=Down payment Deposits=Down payments DiscountFromCreditNote=Discount from credit note %s DiscountFromDeposit=Down payments from invoice %s -DiscountFromExcessReceived=Payments from excess received of invoice %s -DiscountFromExcessPaid=Payments from excess paid of invoice %s +DiscountFromExcessReceived=Payments in excess of invoice %s +DiscountFromExcessPaid=Payments in excess of invoice %s AbsoluteDiscountUse=This kind of credit can be used on invoice before its validation CreditNoteDepositUse=Invoice must be validated to use this kind of credits NewGlobalDiscount=New absolute discount @@ -348,10 +348,10 @@ NextDateToExecution=Date for next invoice generation NextDateToExecutionShort=Date next gen. DateLastGeneration=Date of latest generation DateLastGenerationShort=Date latest gen. -MaxPeriodNumber=Max nb of invoice generation -NbOfGenerationDone=Nb of invoice generation already done -NbOfGenerationDoneShort=Nb of generation done -MaxGenerationReached=Maximum nb of generations reached +MaxPeriodNumber=Max number of invoice generation +NbOfGenerationDone=Number of invoice generation already done +NbOfGenerationDoneShort=Number of generation done +MaxGenerationReached=Maximum number of generations reached InvoiceAutoValidate=Validate invoices automatically GeneratedFromRecurringInvoice=Generated from template recurring invoice %s DateIsNotEnough=Date not reached yet diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 25e2849b949..24724088e45 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -165,14 +165,19 @@ RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting SeePageForSetup=See menu %s for setup DepositsAreNotIncluded=- Down payment invoices are nor included DepositsAreIncluded=- Down payment invoices are included -LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF -LT1ReportByCustomersInInputOutputModeES=Report by third party RE +LT1ReportByCustomers=Report tax 2 by third party +LT2ReportByCustomers=Report tax 3 by third party +LT1ReportByCustomersES=Report by third party RE +LT2ReportByCustomersES=Report by third party IRPF VATReport=Sale tax report VATReportByPeriods=Sale tax report by period +VATReportByCustomers=Sale tax report by customer VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid VATReportByQuartersInInputOutputMode=Report by Sale tax rate of the tax collected and paid -LT1ReportByQuartersInInputOutputMode=Report by RE rate -LT2ReportByQuartersInInputOutputMode=Report by IRPF rate +LT1ReportByQuarters=Report tax 2 by rate +LT2ReportByQuarters=Report tax 3 by rate +LT1ReportByQuartersES=Report by RE rate +LT2ReportByQuartersES=Report by IRPF rate SeeVATReportInInputOutputMode=See report %sVAT encasement%s for a standard calculation SeeVATReportInDueDebtMode=See report %sVAT on flow%s for a calculation with an option on the flow RulesVATInServices=- For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment. diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 8947fcc47ac..ab319522db0 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -43,7 +43,7 @@ CronNoJobs=No jobs registered CronPriority=Priority CronLabel=Label CronNbRun=Nb. launch -CronMaxRun=Max nb. launch +CronMaxRun=Max number launch CronEach=Every JobFinished=Job launched and finished #Page card @@ -79,5 +79,5 @@ CronCannotLoadObject=Class file %s was loaded, but object %s was not found into UseMenuModuleToolsToAddCronJobs=Go into menu "Home - Admin tools - Scheduled jobs" to see and edit scheduled jobs. JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup -MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql' or 'pgsql'), 1, 'auto' or filename to build, nb of backup files to keep +MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql' or 'pgsql'), 1, 'auto' or filename to build, number of backup files to keep WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a8bb2ad50fd..1d29afa1fa5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -64,12 +64,14 @@ ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '% ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'. ErrorFailedToSaveFile=Error, failed to save file. ErrorCannotAddThisParentWarehouse=You are trying to add a parent warehouse which is already a child of current one -MaxNbOfRecordPerPage=Max nb of record per page +MaxNbOfRecordPerPage=Max number of record per page NotAuthorized=You are not authorized to do that. SetDate=Set date SelectDate=Select a date SeeAlso=See also %s SeeHere=See here +ClickHere=Click here +Here=Here Apply=Apply BackgroundColorByDefault=Default background color FileRenamed=The file was successfully renamed @@ -823,7 +825,6 @@ RelatedObjects=Related Objects ClassifyBilled=Classify billed ClassifyUnbilled=Classify unbilled Progress=Progress -ClickHere=Click here FrontOffice=Front office BackOffice=Back office View=View @@ -865,7 +866,7 @@ FileNotShared=File not shared to exernal public Project=Project Projects=Projects Rights=Permissions -LineNb=Line nb +LineNb=Line no. IncotermLabel=Incoterms # Week day Monday=Monday diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 8a8a9f20788..9f590ef3718 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -41,4 +41,4 @@ rateMustBeNumeric=Rate must be a numeric value markRateShouldBeLesserThan100=Mark rate should be lower than 100 ShowMarginInfos=Show margin infos CheckMargins=Margins detail -MarginPerSaleRepresentativeWarning=The report of margin per user use the link between third parties and sale representatives to calculate the margin of each salerepresentaive. Because some thirdparties may not have any ddiated sale representative and some thirdparties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). +MarginPerSaleRepresentativeWarning=The report of margin per user use the link between third parties and sale representatives to calculate the margin of each sale representative. Because some thirdparties may not have any ddiated sale representative and some thirdparties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 8a8346aac4a..e6e58498d1a 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -118,7 +118,7 @@ YourMembershipRequestWasReceived=Your membership was received. YourMembershipWasValidated=Your membership was validated YourSubscriptionWasRecorded=Your new subscription was recorded SubscriptionReminderEmail=Subscription reminder -YourMembershipWasCanceled=You membership was canceled +YourMembershipWasCanceled=Your membership was canceled CardContent=Content of your member card # Text of email templates ThisIsContentOfYourMembershipRequestWasReceived=We want to let you know that your membership request was received.

diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 5cc94c39309..85937ad827a 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -226,4 +226,4 @@ AllowCommentOnProject=Allow user comments on projects DontHavePermissionForCloseProject=You do not have permissions to close the project %s DontHaveTheValidateStatus=The project %s must be open to be closed RecordsClosed=%s project(s) closed -SendProjectRef=About project %s +SendProjectRef=Information project %s diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 2da76863d41..c600a2e9685 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -38,9 +38,9 @@ RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. YouCanAlsoTestWithPHPS=On develop environment, you may prefer to test the site with the PHP embedded web server (PHP 5.5 required) by running
php -S 0.0.0.0:8080 -t %s -CheckVirtualHostPerms=Check also that virtual host has %s on files into
%s -ReadPerm=Read permission -WritePerm=Write permission +CheckVirtualHostPerms=Check also that virtual host has permission %s on files into
%s +ReadPerm=Read +WritePerm=Write PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined @@ -73,7 +73,7 @@ AnotherContainer=Another container WEBSITE_USE_WEBSITE_ACCOUNTS=Enable the web site account table WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / thirdparty YouMustDefineTheHomePage=You must first define the default Home page -OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is intiliazed by grabbing it from an external page (WYSIWYG editor will not be available) +OnlyEditionOfSourceForGrabbedContentFuture=Note: only edition of HTML source will be possible when a page content is initiliazed by grabbing it from an external page (WYSIWYG editor will not be available) OnlyEditionOfSourceForGrabbedContent=Only edition of HTML source is possible when content was grabbed from an external site GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 0e61adcb279..b6b25424e65 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -202,20 +202,13 @@ if ($action == 'update_extras') if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('livraisondao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields('DELIVERY_MODIFY'); - if ($result < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } else if ($reshook < 0) + // Actions on extra fields + $result = $object->insertExtraFields('DELIVERY_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); $error++; + } } if ($error) diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index d0d24d39144..46b3c113ff2 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -540,7 +540,7 @@ class Livraison extends CommonObject global $conf; $error = 0; - if ($id > 0 && !$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if ($id > 0 && ! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $livraisonline = new LivraisonLigne($this->db); $livraisonline->array_options=$array_options; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0289fed4e14..359a7ea27a1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -73,7 +73,7 @@ if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* deprecated in PHP * * @param string $val Value * @param string $type 1=GET, 0=POST, 2=PHP_SELF - * @return int >0 if there is an injection + * @return int >0 if there is an injection, 0 if none */ function test_sql_and_script_inject($val, $type) { @@ -101,6 +101,7 @@ function test_sql_and_script_inject($val, $type) // More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet $inj += preg_match('/