diff --git a/COPYRIGHT b/COPYRIGHT index 04f0358a655..4275779fe2b 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -53,6 +53,7 @@ jQuery Tiptip 1.3 GPL and MIT License Yes jsGanttImproved 1.7.5.2 BSD License Yes JS library (to build Gantt reports) JsTimezoneDetect 1.0.6 MIT License Yes JS library to detect user timezone SwaggerUI 2.0.24 GPL-2+ Yes JS library to offer the REST API explorer +CodePress 0.9.6 LGPL Yes JS library to get code syntaxique coloration in a textarea. For licenses compatibility informations: http://www.gnu.org/licenses/licenses.en.html diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index e369081f7e1..905fd8b97ef 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -97,7 +97,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_account = ""; $search_label = ""; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 311aab692ff..c72ce8cc134 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -98,7 +98,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref = ''; $search_label = ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e742f4651cf..fb503c17ca0 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -98,7 +98,7 @@ if (! empty($search_accountancy_code_end)) { * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c6d84ec9b57..d05dc11ed26 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -72,15 +72,24 @@ if ($action == "confirm_update") { $error = 0; if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action='update'; } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action='update'; + } - if (empty($error)) { + if (! $error) + { $book = new BookKeeping($db); $result = $book->fetch($id, null, $mode); if ($result < 0) { + $error++; setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; @@ -120,12 +129,20 @@ if ($action == "confirm_update") { else if ($action == "add") { $error = 0; - if (empty($debit) && empty($credit)) { - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $error ++; + if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) + { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); + $action=''; + } + if (empty($account_number) || $account_number == '-1') + { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action=''; } - if (empty($error)) { + if (! $error) { $book = new BookKeeping($db); $book->numero_compte = $account_number; @@ -567,7 +584,7 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not @@ -583,8 +600,8 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '' . "\n"; print ''; @@ -622,7 +639,7 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 1, array (), 1, 1, ''); print ''; print ''; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not @@ -638,24 +655,30 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; } print ''; + if ($mode=='_tmp' && $action=='') { - print '
'; + print '
'; + print '
'; if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + print ''.$langs->trans("ValidTransaction").''; } else { - print ''.$langs->trans("ValidTransaction").''; + print ''; } + + print '   '; + print ''.$langs->trans("Cancel").''; + print "
"; } print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 114b765e658..93968644a8f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016 Laurent Destailleur +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2016-2017 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 @@ -16,7 +16,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -112,7 +111,7 @@ if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_mvt_num = ''; $search_doc_type = ''; @@ -377,28 +376,28 @@ print ''; print ''; print ''; print '
'; -print $langs->trans('From') . ': '; +print $langs->trans('From') . ' '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); print '
'; print '
'; -print $langs->trans('to') . ': '; +print $langs->trans('to') . ' '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); print '
'; print ''; print ''; print ''; print '
'; -print $langs->trans('From'); +print $langs->trans('From').' '; print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; -print $langs->trans('to'); +print $langs->trans('to').' '; print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
'; print ''; print ''; print '
'; -print $langs->trans('From'); +print $langs->trans('From').' '; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) @@ -411,7 +410,7 @@ else } print '
'; print '
'; -print $langs->trans('to'); +print $langs->trans('to').' '; // TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) @@ -455,7 +454,10 @@ print "\n"; $total_debit = 0; $total_credit = 0; -foreach ($object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -481,6 +483,8 @@ foreach ($object->lines as $line ) { print '' . img_delete() . ''; print ''; print "\n"; + + $i++; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index a1398df6fb2..1f43964bd0a 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -92,7 +92,7 @@ if (! empty($search_doc_date)) { } -if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +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 { if (! empty($search_accountancy_code_start)) { $filter['t.numero_compte'] = $search_accountancy_code_start; @@ -121,7 +121,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; @@ -160,7 +160,6 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By" llxHeader('', $title_page); // List - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); @@ -173,7 +172,9 @@ $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $f if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } -$nbtotalofrecords = $result; + +$num=count($object->lines); + if ($action == 'delmouv') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1); @@ -204,7 +205,7 @@ if ($action == 'delbookkeepingyear') { -print '
'; +print ''; $viewflat = ' ' . $langs->trans("ViewFlatList") . ''; @@ -236,7 +237,7 @@ print ''; print ' '; print ' '; -print ''; +print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -250,7 +251,7 @@ print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_re print_liste_field_titre($langs->trans("Label")); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="right"', $sortfield, $sortorder); +print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); print "\n"; @@ -263,7 +264,10 @@ $sous_total_debit = 0; $sous_total_credit = 0; $displayed_account_number = null; // Start with undefined to be able to distinguish with empty -foreach ( $object->lines as $line ) { +$i=0; +while ($i < min($num, $limit)) +{ + $line = $object->lines[$i]; $total_debit += $line->debit; $total_credit += $line->credit; @@ -323,10 +327,11 @@ foreach ( $object->lines as $line ) { print ''; print "\n"; - // Comptabilise le sous-total - $sous_total_debit += $line->debit; - $sous_total_credit += $line->credit; + // Comptabilise le sous-total + $sous_total_debit += $line->debit; + $sous_total_credit += $line->credit; + $i++; } // Affiche un Sous-Total du dernier compte comptable affiché diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index becb700761a..d10f621d9e3 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -86,7 +86,7 @@ $offset = $limit * $page; * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_doc_type = ""; $search_doc_date = ""; diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php index cddeff27651..41e1570ae83 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php @@ -22,7 +22,7 @@ /** * \file accounting/bookkeeping/thirdparty_lettrage.php - * \ingroup Accounting Expert + * \ingroup Advanced accountancy * \brief Onglet de gestion de parametrages des ventilations */ diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php index 7dfb7067a31..17f0194628d 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php @@ -22,8 +22,8 @@ /** * \file accounting/bookkeeping/thirdparty_lettrage.php - * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \ingroup Advanced accountancy + * \brief Tab to setup lettering */ // Dolibarr environment diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5c5fb022de9..1431df9f8a2 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -176,7 +176,7 @@ class BookKeeping extends CommonObject if (empty($this->credit)) $this->credit = 0; // Check parameters - if (empty($this->numero_compte) || $this->numero_compte == '-1') + if (empty($this->numero_compte) || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') { $langs->load("errors"); if (in_array($this->doc_type, array('bank', 'expense_report'))) @@ -803,7 +803,7 @@ class BookKeeping extends CommonObject if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } - $this->lines = array (); + $this->lines = array(); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 70d7a88c55b..97721669f91 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -19,8 +19,8 @@ /** * \file accountancy/class/bookkeeping.class.php - * \ingroup Accounting Expert - * \brief Fichier de la classe des comptes comptable + * \ingroup Advanced accountancy + * \brief File of class for lettering */ include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php"; diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index a10cd24adc4..d307169dfcc 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/customer/card.php - * \ingroup Accountancy - * \brief Card customer ventilation + * \file htdocs/accountancy/customer/card.php + * \ingroup Advanced accountancy + * \brief Card customer ventilation */ require '../../main.inc.php'; @@ -47,11 +47,11 @@ if ($user->societe_id > 0) if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (! GETPOST('cancel', 'alpha')) { if ($codeventil < 0) $codeventil = 0; - + $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql .= " SET fk_code_ventilation = " . $codeventil; $sql .= " WHERE rowid = " . $id; - + $resql = $db->query($sql); if (! $resql) { setEventMessages($db->lasterror(), null, 'errors'); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f1bea3bd4a1..b46739ca1c2 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/accountancy/customer/index.php + * \file htdocs/accountancy/customer/index.php * \ingroup Advanced accountancy - * \brief Home customer journalization page + * \brief Home customer journalization page */ require '../../main.inc.php'; @@ -363,7 +363,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. } print "\n"; - + if (! empty($conf->margin->enabled)) { print "
\n"; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index d6d006c6556..d48f81259df 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -85,7 +85,7 @@ $formaccounting = new FormAccounting($db); */ // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_lineid = ''; $search_ref = ''; @@ -153,7 +153,7 @@ print ''; - $return .= ''; - - if ($showempty) - $return .= ''; - - // Find if keys is in selected array value - if (is_array($selected_array) && count($selected_array)>0) { - $intersect_array = array_intersect_key($options_array, array_flip($selected_array)); - } else { - $intersect_array=array(); - } - - if (count($options_array) > 0) { - foreach ($options_array as $keyoption => $valoption) { - // If key is in intersect table then it have to e selected - $selected = ''; - if (count ( $intersect_array ) > 0) { - if (array_key_exists ( $keyoption, $intersect_array )) { - $selected = ' selected="selected"'; - } - } - $return .= '' . $valoption . ''; - } - } - - $return .= ''; - + $form=new Form($this->db); + $return = $form->multiselectarray($htmlname, $options_array, $selected_array,0,0,'',0,295); return $return; } @@ -448,7 +407,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } - return $this->advMultiselectarray ( $htmlname, $options_array, $selected_array ); + return $this->advMultiselectarray( $htmlname, $options_array, $selected_array ); } /** diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4668c6a56a4..b1d8aa03022 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1250,6 +1250,8 @@ $now = dol_now(); // Add new proposal if ($action == 'create') { + $currency_code = $conf->currency; + print load_fiche_titre($langs->trans("NewProp")); $soc = new Societe($db); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d7a4fd90533..29eb9ee068b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2362,7 +2362,7 @@ class Propal extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT.' ;'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); @@ -3502,7 +3502,7 @@ class Propal extends CommonObject /** * Class to manage commercial proposal lines */ -class PropaleLigne extends CommonObjectLine +class PropaleLigne extends CommonObjectLine { public $element='propaldet'; public $table_element='propaldet'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e9626a638b8..70953e58fbf 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -178,7 +178,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_categ=''; $search_user=''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3f08053007f..d7199e878ec 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -65,9 +65,8 @@ class Commande extends CommonOrder public $contactid; /** - * Status of the order. Check the following constants: + * Status of the order * @var int - * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED */ public $statut; /** diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8ce3ba7cd04..9e0b04ab6e9 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -162,7 +162,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $search_categ=''; $search_user=''; @@ -191,6 +191,11 @@ if (empty($reshook)) $toselect=''; $search_array_options=array(); } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } // Mass actions $objectclass='Commande'; @@ -371,7 +376,7 @@ if (empty($reshook)) } - $cmd->classifyBilled($user); + //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; @@ -754,7 +759,7 @@ if ($resql) //var_dump($_REQUEST); print ''; - print '
'; + print '
'; print ''; print ''; print ''; print ''; print '
'; print $langs->trans('DateInvoice'); @@ -776,7 +781,15 @@ if ($resql) print $langs->trans('ValidateInvoices'); print ''; - print $form->selectyesno('valdate_invoices', 1, 1); + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + print $form->selectyesno('valdate_invoices', 0, 1, 1); + print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + } + else + { + print $form->selectyesno('valdate_invoices', 0, 1); + } print '
'; @@ -838,7 +851,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -976,6 +989,7 @@ if ($resql) Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); print $form->selectarray('viewstatut', $liststatus, $viewstatut, -4); @@ -1033,7 +1047,7 @@ if ($resql) if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'],$_SERVER["PHP_SELF"],"c.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'],$_SERVER["PHP_SELF"],"c.fk_statut","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'],$_SERVER["PHP_SELF"],'c.facture','',$param,'align="center"',$sortfield,$sortorder,''); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print ''."\n"; $total=0; diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 1cf88c70121..3044ed9af47 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; @@ -46,17 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("banks"); -$langs->load("bills"); -$langs->load("categories"); -$langs->load("companies"); -$langs->load("margins"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); -$langs->load("compta"); +$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); @@ -84,6 +75,7 @@ $debit=GETPOST("debit",'alpha'); $credit=GETPOST("credit",'alpha'); $type=GETPOST("type",'alpha'); $account=GETPOST("account",'int'); +$accountancy_code=GETPOST('accountancy_code', 'alpha'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); @@ -178,7 +170,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_dt_start=''; $search_dt_end=''; @@ -276,11 +268,11 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $amount = - price2num($_POST["adddebit"]); } - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; + $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); + $operation = GETPOST("operation",'alpha'); + $num_chq = GETPOST("num_chq",'alpha'); + $label = GETPOST("label",'alpha'); + $cat1 = GETPOST("cat1",'alpha'); if (! $dateop) { $error++; @@ -290,15 +282,24 @@ if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); } + if (! $label) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Label")), null, 'errors'); + } if (! $amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); } + /*if (! empty($conf->accounting->enabled) && (empty($accountancy_code) || $accountancy_code == '-1')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + }*/ if (! $error) { $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $accountancy_code); if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -331,6 +332,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m $form = new Form($db); $formother = new FormOther($db); +$formaccounting = new FormAccounting($db); $companystatic=new Societe($db); $bankaccountstatic=new Account($db); @@ -365,6 +367,7 @@ if (!empty($debit)) $param.='&debit='.$debit; if (!empty($credit)) $param.='&credit='.$credit; if (!empty($account)) $param.='&account='.$account; if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); +if ($search_conciliated != '') $param.='&search_conciliated='.urlencode($search_conciliated); if (!empty($bid)) $param.='&bid='.$bid; if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); @@ -408,19 +411,32 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); + /* * Buttons actions */ + if ($action != 'reconcile') { print '
'; if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - if ($user->rights->banque->modifier) { - print ''.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; + if (! empty($conf->global->BANK_USE_VARIOUS_PAYMENT)) // If direct entries is done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } + else // If direct entries is not done using miscellaneous payments + { + if ($user->rights->banque->modifier) { + print ''.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } } } else @@ -431,7 +447,7 @@ if ($id > 0 || ! empty($ref)) if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -637,6 +653,60 @@ if ($resql) // print '
'; } + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + /*if (! empty($conf->accounting->enabled)) + { + print ''; + }*/ + print ''; + + print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''; + print $langs->trans("AccountAccounting"); + print ' 
'; + $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); + print ''; + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); + } + print '
'; + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print ''; + print '
'; + print ''; + print '
'; + print '
'; + } /// ajax to adjust value date with plus and less picto print ' diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b5a2177d798..945cc290f54 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -394,9 +394,10 @@ class Account extends CommonObject * @param User $user User that create * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') { // Deprecatîon warning if (is_numeric($oper)) { @@ -457,6 +458,7 @@ class Account extends CommonObject $accline->fk_user_author = $user->id; $accline->fk_account = $this->rowid; $accline->fk_type = $oper; + $accline->numero_compte = $accountancycode; if ($num_chq) { $accline->num_chq = $num_chq; @@ -1684,8 +1686,9 @@ class AccountLine extends CommonObject $sql .= ", num_chq"; $sql .= ", fk_account"; $sql .= ", fk_type"; - $sql .= ",emetteur,banque"; + $sql .= ", emetteur,banque"; $sql .= ", rappro"; + $sql .= ", numero_compte"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->dateo)."'"; @@ -1699,6 +1702,7 @@ class AccountLine extends CommonObject $sql .= ", ".($this->emetteur ? "'".$this->db->escape($this->emetteur)."'" : "null"); $sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null"); $sql .= ", ".(int) $this->rappro; + $sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''"); $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 939872ce7fd..9812269dcb6 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -325,14 +325,14 @@ class PaymentVarious extends CommonObject $sql.= " VALUES ("; $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", '".$this->sens."'"; + $sql.= ", '".$this->db->escape($this->sens)."'"; $sql.= ", ".$this->amount; - $sql.= ", '".$this->type_payment."'"; - $sql.= ", '".$this->num_payment."'"; + $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->accountancy_code."'"; - $sql.= ", '".$user->id."'"; + $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", ".$user->id; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; $sql.= ", ".$conf->entity; @@ -342,7 +342,6 @@ class PaymentVarious extends CommonObject $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); if ($this->id > 0) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 9d8cf29ee39..9bc8608692d 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -121,7 +121,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $statut = 'all'; $search_ref=''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 61a88aa9c2f..b9e1a506c18 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -122,7 +122,7 @@ if ($action=="dl" && $numref > 0) { // TODO Replace this with a standard builddoc action that use a document generation module to build the ZIP $log = ''; - + $outdir = $conf->bank->dir_temp.'/'.$numref.'-'.$object->label; $outdirinvoices = $outdir.'/'.$langs->trans("BillsCustomers"); $outdirsupplierinvoices = $outdir.'/'.$langs->trans("BillsSuppliers"); @@ -130,7 +130,7 @@ if ($action=="dl" && $numref > 0) dol_mkdir($outdir); dol_mkdir($outdirinvoices); dol_mkdir($outdirsupplierinvoices); - + //$zipname = $object->label.'-'.$numref . '.zip'; //$zip = new ZipArchive(); //$zip->open($zipname, ZipArchive::OVERWRITE); @@ -138,7 +138,7 @@ if ($action=="dl" && $numref > 0) $sql = $sqlrequestforbankline; $facturestatic=new Facture($db); - + $resd = $db->query($sql); if ($resd) { $numd = $db->num_rows($resd); @@ -146,7 +146,7 @@ if ($action=="dl" && $numref > 0) if ($numd > 0) { $objd = $db->fetch_object($resd); - + $log.='Transaction '.$objd->rowid; $links = $object->get_url($objd->rowid); @@ -165,7 +165,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -202,7 +202,7 @@ if ($action=="dl" && $numref > 0) { $facturestatic->fetch($billid); $subdir = get_exdir($facturestatic->id, 2, 0, 0, $facturestatic, 'invoice_supplier'); - + $arrayofinclusion=array(); // TODO Find a way to get doc ODT or other // TODO Use get_exdir $arrayofinclusion[]=preg_quote($facturestatic->ref.'.pdf','/'); @@ -227,7 +227,7 @@ if ($action=="dl" && $numref > 0) dol_copy($srcfile, $destfile); } } - } + } break; case "payment_expensereport": /*$subdir = dol_sanitizeFileName($objd->refe); @@ -246,7 +246,7 @@ if ($action=="dl" && $numref > 0) } } $log.="\n"; - + /*if (! empty($upload_dir)) { $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); @@ -259,24 +259,24 @@ if ($action=="dl" && $numref > 0) } else { $log .= $key . ',' . $langs->trans("Nofile") . "\n"; } - + }*/ } } - + $db->free($resd); - - + + //$zip->addFromString('log '.$numref.'.csv', $log); //$zip->close(); - + // /Then download the zipped file. /*header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=' . $zipname); header('Content-Length: ' . filesize($zipname)); - + readfile($zipname); - + exit;*/ } @@ -329,18 +329,18 @@ if (empty($numref)) dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - + dol_fiche_end(); - + print '
'; if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } @@ -348,7 +348,7 @@ if (empty($numref)) print '
'; print '

'; - + print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); @@ -481,7 +481,7 @@ else //$mesprevnext.='   '; $mesprevnext.=''; $mesprevnext.='
'; - + $title=$langs->trans("AccountStatement").' '.$numref.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); @@ -520,7 +520,7 @@ else // Recherche les ecritures pour le releve $sql = $sqlrequestforbankline; - + $result = $db->query($sql); if ($result) { @@ -553,7 +553,7 @@ else print img_edit_add() .""; print "\n"; print ''; - + // Type and num if ($objp->fk_type == 'SOLD') { $type_label=' '; @@ -753,9 +753,9 @@ else print "\n"; print ""; print "
"; - + print "\n"; - + // Add a download button if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Started a rewrite to make this feature more Dolibarr compliant. Still need dev to be completed. { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index e19deca91c9..f75c111094d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -29,15 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); -$langs->load("users"); -$langs->load("accountancy"); +$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); + +// Get parameters +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$id=GETPOST("id",'int'); -$action=GETPOST('action','alpha'); -$cancel=GETPOST('cancel','alpha'); $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $label=GETPOST("label","alpha"); $sens=GETPOST("sens","int"); @@ -61,115 +60,139 @@ $hookmanager->initHooks(array('variouscard','globalcard')); * Actions */ -if (! empty($cancel)) +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - header("Location: index.php"); - exit; -} - -if ($action == 'add' && empty($cancel)) -{ - $error=0; - - $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); - if (empty($datev)) $datev=$datep; - - $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; - $object->num_payment=GETPOST("num_payment"); - $object->fk_user_author=$user->id; - $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; - - if (empty($datep) || empty($datev)) + if ($cancel) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); - $error++; - } - if (empty($object->type_payment) || $object->type_payment < 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); - $error++; - } - if (empty($object->amount)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); - $error++; - } - if (! empty($conf->banque->enabled) && ! $object->accountid > 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); - $error++; - } - - if (! $error) - { - $db->begin(); - - $ret=$object->create($user); - if ($ret > 0) + if ($action != 'addlink') { - $db->commit(); - header("Location: index.php"); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); + header("Location: ".$urltogo); exit; } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action="create"; - } + if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); + $action=''; } - $action='create'; -} - -if ($action == 'delete') -{ - $result=$object->fetch($id); - - if ($object->rappro == 0) + if ($action == 'add') { - $db->begin(); + $error=0; - $ret=$object->delete($user); - if ($ret > 0) + $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); + $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + if (empty($datev)) $datev=$datep; + + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->note=GETPOST("note"); + $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->num_payment=GETPOST("num_payment"); + $object->fk_user_author=$user->id; + $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : ""; + $object->sens=GETPOST('sens'); + + if (empty($datep) || empty($datev)) { - if ($object->fk_bank) - { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) - } + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); + $error++; + } + if (empty($object->type_payment) || $object->type_payment < 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); + $error++; + } + if (empty($object->amount)) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); + $error++; + } + if (! empty($conf->banque->enabled) && ! $object->accountid > 0) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); + $error++; + } + if (! empty($conf->accounting->enabled) && ! $object->accountancy_code) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + } - if ($result >= 0) + if (! $error) + { + $db->begin(); + + $ret=$object->create($user); + if ($ret > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: index.php"); exit; } else { - $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + $action="create"; + } + } + + $action='create'; + } + + if ($action == 'delete') + { + $result=$object->fetch($id); + + if ($object->rappro == 0) + { + $db->begin(); + + $ret=$object->delete($user); + if ($ret > 0) + { + if ($object->fk_bank) + { + $accountline=new AccountLine($db); + $result=$accountline->fetch($object->fk_bank); + if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + } + + if ($result >= 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + exit; + } + else + { + $object->error=$accountline->error; + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } else { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } - else - { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); - } } @@ -200,8 +223,9 @@ if ($id) /* ************************************************************************** */ if ($action == 'create') { - print '
'; + print ''; print ''; + print ''; print ''; print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); @@ -269,7 +293,7 @@ if ($action == 'create') // Accountancy account if (! empty($conf->accounting->enabled)) { - print ''.$langs->trans("AccountAccounting").''; + print ''.$langs->trans("AccountAccounting").''; print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; @@ -292,7 +316,7 @@ if ($action == 'create') print '
'; print ''; - print '     '; + print '   '; print ''; print '
'; diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 5a3449cccb6..5bfd7536ed8 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 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 @@ -16,9 +17,9 @@ */ /** - * \file htdocs/compta/bank/various_payment/index.php - * \ingroup bank - * \brief List of various payments + * \file htdocs/compta/bank/various_payment/index.php + * \ingroup bank + * \brief List of various payments */ require '../../../main.inc.php'; @@ -34,6 +35,8 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '', '', ''); +$optioncss = GETPOST('optioncss','alpha'); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); @@ -50,11 +53,10 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="v.datep"; if (! $sortorder) $sortorder="DESC"; -$optioncss = GETPOST('optioncss','alpha'); -$filtre=$_GET["filtre"]; +$filtre=GETPOST("filtre",'alpha'); -if (empty($_REQUEST['typeid'])) +if (! GETPOST('typeid')) { $newfiltre=str_replace('filtre=','',$filtre); $filterarray=explode('-',$newfiltre); @@ -66,10 +68,10 @@ if (empty($_REQUEST['typeid'])) } else { - $typeid=$_REQUEST['typeid']; + $typeid=GETPOST('typeid'); } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; @@ -240,9 +242,12 @@ if ($result) $colspan=4; if (! empty($conf->banque->enabled)) $colspan++; - print ''.$langs->trans("Total").''; + print ''; + print ''.$langs->trans("Total").''; print ''.price($total).""; - print ""; + print ''; + print ''; + print ''; print ""; print '
'; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index de5e00045e7..e42e9f2325a 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="d.dated"; $year=GETPOST("year"); $month=GETPOST("month"); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_name=""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a2fb54ed45f..79b259e64ac 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4189,7 +4189,7 @@ else if ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print '
' . $langs->trans("ChangeIntoRepeatableInvoice") . '
'; + print '
' . $langs->trans("ChangeIntoRepeatableInvoice") . '
'; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a89760d8ffc..ca68d49759d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2044,7 +2044,12 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); return 0; } - + if (count($this->lines) <= 0) + { + $langs->load("errors"); + $this->error=$langs->trans("ErrorObjectMustHaveLinesToBeValidated", $this->ref); + return -1; + } if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate))) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 22306e498f2..d38ea012c3c 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -46,13 +46,18 @@ $langs->load('compta'); $langs->load('admin'); $langs->load('other'); +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$show_files = GETPOST('show_files','int'); +$confirm = GETPOST('confirm','alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search + // Security check $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); $lineid=GETPOST('lineid','int'); $ref=GETPOST('ref','alpha'); -$action=GETPOST('action', 'alpha'); if ($user->societe_id) $socid=$user->societe_id; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; @@ -112,7 +117,7 @@ $arrayfields=array( 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), 'f.frequency'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbGeneration"), 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), @@ -132,6 +137,9 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab * Actions */ +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -140,6 +148,9 @@ if (empty($reshook)) { if (GETPOST('cancel')) $action=''; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Set note include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once @@ -148,7 +159,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Do we click on purge search criteria ? - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=''; $search_societe=''; @@ -165,6 +176,14 @@ if (empty($reshook)) $search_array_options=array(); } + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ + // Create predefined invoice if ($action == 'add') { @@ -517,7 +536,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { @@ -905,7 +924,7 @@ if ($action == 'create') print ''; print ''; - dol_fiche_head(); + dol_fiche_head(null, '', '', 0); $rowspan=4; if (! empty($conf->projet->enabled)) $rowspan++; @@ -942,7 +961,7 @@ if ($action == 'create') '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -952,10 +971,10 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -963,7 +982,7 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; - print ''; + print ''; print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print ''; print ''; @@ -1007,12 +1026,14 @@ if ($action == 'create') print ""; - print '

'; + dol_fiche_end(); // Autogeneration $title = $langs->trans("Recurrence"); - print load_fiche_titre($title, '', 'calendar'); + print load_fiche_titre(' '.$title, '', ''); + + dol_fiche_head(null, '', '', 0); print ''; @@ -1040,7 +1061,8 @@ if ($action == 'create') print "
"; - print '

'; + dol_fiche_end(); + $title = $langs->trans("ProductsAndServices"); if (empty($conf->service->enabled)) @@ -1078,8 +1100,6 @@ if ($action == 'create') } print "\n"; - dol_fiche_end(); - print '
'; print '     '; print ''; @@ -1260,7 +1280,7 @@ else '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' ); $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { @@ -1323,7 +1343,7 @@ else print ''; print ''; - + // if "frequency" is empty or = 0, the reccurence is disabled print '
'.$title.'
'; print ''; print "\n"; + print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountHT"),$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountVAT"),$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RecurringInvoiceTemplate"),$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) - { - print_liste_field_titre($langs->trans("NbOfGenerationDone"),$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); - } - print_liste_field_titre($langs->trans("DateLastGeneration"),$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("NextDateToExecution"),$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre(''); // Field may contains ling text + if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; - - + + if ($num > 0) { $var=true; @@ -1800,26 +1828,67 @@ else { $objp = $db->fetch_object($resql); - print ''; - - print '\n"; - $companystatic->id=$objp->socid; $companystatic->name=$objp->name; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; + print ''; + + if (! empty($arrayfields['f.titre']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.total']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.tva']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + print ''."\n"; + } + if (! empty($arrayfields['f.frequency']['checked'])) + { + print ''; + } if (! empty($arrayfields['f.nb_gen_done']['checked'])) { - print ''; + print ''; } - print ''; - print ''; - + if (! empty($arrayfields['f.date_last_gen']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.date_when']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + } + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + } + // Action column print ''; + else + { + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; + } print "
'; @@ -1558,7 +1578,8 @@ else * List mode */ $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,"; - $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when"; + $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,"; + $sql.= " f.datec, f.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1570,10 +1591,10 @@ else } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); - if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency); if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); + if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency); if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; @@ -1605,23 +1626,24 @@ else } $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); + $sql.= $db->order($sortfield, $sortorder); + $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($socid) $param.='&socid='.$socid; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; @@ -1631,9 +1653,9 @@ else if ($search_ref) $param.='&search_ref=' .$search_ref; if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; + if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; - if ($search_frequency) $param.='&search_frequency=' .$search_frequency; + if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency; if ($option) $param.="&option=".$option; if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields @@ -1646,14 +1668,20 @@ else $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - print ''."\n"; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print ''."\n"; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; + print ''; print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); @@ -1776,23 +1804,23 @@ else print '
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; + print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).''.($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '').''; + print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); + print ''.($objp->frequency ? dol_print_date($objp->date_last_gen,'day') : '').''.($objp->frequency ? dol_print_date($objp->date_when,'day') : '').''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : ''.$langs->trans('NA').''); + print ''; + print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : ''.$langs->trans('NA').''); + print ''; + print dol_print_date($db->jdate($objp->datec),'dayhour'); + print ''; + print dol_print_date($db->jdate($objp->tms),'dayhour'); + print ''; if ($user->rights->facture->creer) { @@ -1842,7 +1911,12 @@ else $i++; } } - else print '
'.$langs->trans("NoneF").'
'.$langs->trans("NoRecordFound").'
"; print ""; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5ab62bf5337..72ea7e1a647 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -191,7 +191,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_removefilter.x','alpha')) // All tests are required to be compatible with all browsers { $search_user=''; $search_sale=''; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 13c753db464..a70066bdb5d 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -54,8 +54,9 @@ 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 { @@ -92,12 +93,9 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/* +/** * View */ - $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach($listofparams as $param) @@ -118,6 +116,7 @@ $paymentfourn_static=new PaiementFourn($db); $fsearch.=' '; $fsearch.=' '; +$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; @@ -196,9 +195,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - +$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo ''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 023f94c5eef..5d97c056560 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -319,7 +319,7 @@ llxHeader('', $langs->trans("Payment")); if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { @@ -685,7 +685,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); - print ''; + print ''; print ''; } else @@ -760,7 +760,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($totalrecudeposits) print '+'.price($totalrecudeposits); print ''; print ''; - print ''; + print ''; // Autofilled if (!empty($conf->multicurrency->enabled)) print ''; print ''; print "\n"; @@ -804,7 +804,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); + $text.='
'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index aeed72d93d1..3e2b43b7f34 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -68,7 +68,7 @@ $accountstatic=new Account($db); */ // If click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=''; $search_amount=''; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 56ed3009880..aba6eb4a67f 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -77,7 +77,7 @@ $extrafields = new ExtraFields($db); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_account=""; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 9a5585c2513..6fcbb62b5d9 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -57,7 +57,7 @@ $search_ref = GETPOST('search_ref','alpha'); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 208be88aeae..6251a6f6521 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -65,7 +65,7 @@ $ligne=new LignePrelevement($db,$user); * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_line=""; $search_bon=""; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 45bde4bcd32..2b8b6a6fe5b 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -44,7 +44,7 @@ $action=GETPOST('action','aZ09'); // Security check $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'salaries', '', '', ''); +$result = restrictedArea($user, 'salaries', '', '', 'payment'); $object = new PaymentSalary($db); diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 7a999a15ef9..5aa5d29aa54 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -79,7 +79,7 @@ else * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 2ab2cb1c172..50dd4d430ed 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -71,7 +71,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 12ed60d6d68..c3c717df2e0 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -74,7 +74,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 74ec89bf5d1..7f35c71cd11 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -122,7 +122,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index b80a300431a..3b7ce848731 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -108,7 +108,7 @@ class Contact extends CommonObject $this->db = $db; $this->statut = 1; // By default, status is enabled } - + /** * Load indicators into this->nb for board * @@ -117,10 +117,10 @@ class Contact extends CommonObject function load_state_board() { global $user; - + $this->nb=array(); $clause = "WHERE"; - + $sql = "SELECT count(sp.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->societe_id) @@ -133,7 +133,7 @@ class Contact extends CommonObject $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')'; $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; if ($user->societe_id > 0) $sql.=" AND sp.fk_soc = ".$user->societe_id; - + $resql=$this->db->query($sql); if ($resql) { @@ -410,7 +410,9 @@ class Contact extends CommonObject { global $conf,$langs; - // Object classes + $info = array(); + + // Object classes $info["objectclass"]=explode(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname=$this->getFullName($langs); @@ -486,7 +488,7 @@ class Contact extends CommonObject $result=false; $this->db->begin(); - + // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); @@ -544,7 +546,7 @@ class Contact extends CommonObject if ($result < 0) { $error++; } // End call triggers } - + if (! $error) { $this->db->commit(); @@ -659,7 +661,7 @@ class Contact extends CommonObject $this->canvas = $obj->canvas; $this->import_key = $obj->import_key; - + // Define gender according to civility $this->setGenderFromCivility(); @@ -735,7 +737,7 @@ class Contact extends CommonObject /** * Set property ->gender from property ->civility_id - * + * * @return void */ function setGenderFromCivility() @@ -746,8 +748,8 @@ class Contact extends CommonObject } else if(in_array($this->civility_id, array('MME','MLE'))) { $this->gender = 'woman'; } - } - + } + /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1007,13 +1009,13 @@ class Contact extends CommonObject if ($this->phone_perso) $phonelist[]=$this->phone_perso; $label.= '
' . $langs->trans("Phone") . ': '.join(', ',$phonelist); $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); - + $link = 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label=$langs->trans("ShowContact"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' class="classfortooltip">'; @@ -1029,15 +1031,15 @@ class Contact extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; $link.=$linkclose; - + $linkend=''; - + if ($option == 'xxx') { $link = ''; $linkend=''; } - + if ($withpicto) $result.=($link.img_object($label, 'contact', 'class="classfortooltip"').$linkend.' '); $result.=$link.($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)).$linkend; return $result; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a526a9bd78c..4b638dcfef6 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -146,7 +146,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $day=''; $month=''; diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index aea03a73df5..2fdec21f735 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -152,7 +152,7 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_name=""; $search_contract=""; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 5313b79dc04..be6f13a22c7 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2017 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 @@ -26,6 +26,7 @@ // $objectclass and $$objectlabel must be defined // $parameters, $object, $action must be defined for the hook. +// $permtoread, $permtocreate and $permtodelete may be defined // $uploaddir may be defined (example to $conf->projet->dir_output."/";) // $toselect may be defined @@ -524,6 +525,66 @@ if ($action == 'remove_file') $action=''; } +// Validate records +if (! $error && $massaction == 'validate' && $permtocreate) +{ + if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); + $error++; + } + if (! $error) + { + $db->begin(); + + $objecttmp=new $objectclass($db); + $nbok = 0; + foreach($toselect as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + //else + $result = $objecttmp->validate($user); + if ($result == 0) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); + $error++; + break; + } + elseif ($result < 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + else $nbok++; + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (! $error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + //var_dump($listofobjectthirdparties);exit; + } +} + // Delete records if (! $error && $massaction == 'delete' && $permtodelete) { diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 03b33b19eb1..b8ae96cb920 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -32,16 +32,19 @@ if ($action == 'setModuleOptions') $db->begin(); // Process common param fields - foreach($_POST as $key => $val) + if (is_array($_POST)) { - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + foreach($_POST as $key => $val) { - $param=GETPOST("param".$reg[1],'alpha'); - $value=GETPOST("value".$reg[1],'alpha'); - if ($param) + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... { - $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); - if (! $res > 0) $error++; + $param=GETPOST("param".$reg[1],'alpha'); + $value=GETPOST("value".$reg[1],'alpha'); + if ($param) + { + $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } } } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 96de26be956..ddfb2780f3f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -599,7 +599,7 @@ abstract class CommonObject } $datecreate = dol_now(); - + // Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error $TListeContacts=$this->liste_contact(-1, $source); $already_added=false; @@ -611,11 +611,11 @@ abstract class CommonObject } } } - + if(!$already_added) { - + $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -623,7 +623,7 @@ abstract class CommonObject $sql.= "'".$this->db->idate($datecreate)."'"; $sql.= ", 4, ". $id_type_contact; $sql.= ")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -636,7 +636,7 @@ abstract class CommonObject return -1; } } - + $this->db->commit(); return 1; } @@ -4169,6 +4169,9 @@ abstract class CommonObject $optionsArray = $extrafields->attributes[$this->table_element]['label']; } + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + // Request to get complementary values if (count($optionsArray) > 0) { @@ -4180,7 +4183,7 @@ abstract class CommonObject $sql.= ", ".$name; } } - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; + $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); @@ -4226,7 +4229,10 @@ abstract class CommonObject { $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); $resql=$this->db->query($sql_del); if (! $resql) @@ -4332,11 +4338,14 @@ abstract class CommonObject } $this->db->begin(); - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; + $table_element = $this->table_element; + if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility + + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object"; foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix @@ -4646,18 +4655,17 @@ abstract class CommonObject /** * Get buy price to use for margin calculation. This function is called when buy price is unknown. - * set buy price = sell price if ForceBuyingPriceIfNull configured, + * Set buy price = sell price if ForceBuyingPriceIfNull configured, * else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice * else set min buy price as buy price * - * @param float $unitPrice product unit price - * @param float $discountPercent line discount percent - * @param int $fk_product product id - * - * @return float <0 if ko, buyprice if ok + * @param float $unitPrice Product unit price + * @param float $discountPercent Line discount percent + * @param int $fk_product Product id + * @return float <0 if KO, buyprice if OK */ - public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) + public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0) { global $conf; @@ -4726,6 +4734,9 @@ abstract class CommonObject return $buyPrice; } + + + /** * Function test if type is date * @@ -4734,7 +4745,7 @@ abstract class CommonObject */ protected function isDate($info) { - if(isset($info['type']) && $info['type']=='date') return true; + if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; } @@ -4880,40 +4891,6 @@ abstract class CommonObject return $query; } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function createCommon(User $user, $notrigger = false) - { - - $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); - - foreach ($fields as $k => $v) { - - $keys[] = $k; - $values[] = $this->quote($v); - - } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' - ( '.implode( ",", $keys ).' ) - VALUES ( '.implode( ",", $values ).' ) '; - $res = $this->db->query( $sql ); - if($res===false) { - - return false; - } - - // TODO Add triggers - - return true; - - } - /** * Function to load data into current object this * @@ -4921,39 +4898,39 @@ abstract class CommonObject */ private function set_vars_by_db(&$obj) { - foreach ($this->fields as $field => $info) - { - if($this->isDate($info)) - { - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; - else $this->{$field} = strtotime($obj->{$field}); - } - elseif($this->isArray($info)) - { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); - } - elseif($this->isInt($info)) - { - $this->{$field} = (int) $obj->{$field}; - } - elseif($this->isFloat($info)) - { - $this->{$field} = (double) $obj->{$field}; - } - elseif($this->isNull($info)) - { - $val = $obj->{$field}; - // zero is not null - $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); - } - else - { - $this->{$field} = $obj->{$field}; - } + foreach ($this->fields as $field => $info) + { + if($this->isDate($info)) + { + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0; + else $this->{$field} = strtotime($obj->{$field}); + } + elseif($this->isArray($info)) + { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === FALSE) @unserialize(utf8_decode($obj->{$field})); + } + elseif($this->isInt($info)) + { + $this->{$field} = (int) $obj->{$field}; + } + elseif($this->isFloat($info)) + { + $this->{$field} = (double) $obj->{$field}; + } + elseif($this->isNull($info)) + { + $val = $obj->{$field}; + // zero is not null + $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val); + } + else + { + $this->{$field} = $obj->{$field}; + } - } + } } /** @@ -4963,21 +4940,136 @@ abstract class CommonObject */ private function get_field_list() { - $keys = array_keys($this->fields); - return implode(',', $keys); + $keys = array_keys($this->fields); + return implode(',', $keys); + } + + /** + * Add quote to field value if necessary + * + * @param string|int $value value to protect + * @return string|int + */ + protected function quote($value) { + + if(is_null($value)) return 'NULL'; + else if(is_numeric($value)) return $value; + else return "'".$this->db->escape( $value )."'"; + + } + + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function createCommon(User $user, $notrigger = false) + { + $error = 0; + + $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); + + $keys=array(); + $values = array(); + foreach ($fields as $k => $v) { + $keys[] = $k; + $values[] = $this->quote($v); + } + + $this->db->begin(); + + if (! $error) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' + ( '.implode( ",", $keys ).' ) + VALUES ( '.implode( ",", $values ).' ) '; + $res = $this->db->query( $sql ); + if ($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + if (! $error && ! $notrigger) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromCloneCommon(User $user, $fromid) + { + global $user; + + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->createCommon($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + return $object->id; + } else { + $this->db->rollback(); + return -1; + } } /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetchCommon($id, $ref = null) { - if (empty($id) && empty($ref)) return false; $sql = 'SELECT '.$this->get_field_list().', datec, tms'; @@ -4991,13 +5083,20 @@ abstract class CommonObject { if ($obj = $this->db->fetch_object($res)) { - $this->id = $id; - $this->set_vars_by_db($obj); + if ($obj) + { + $this->id = $id; + $this->set_vars_by_db($obj); - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); - return $this->id; + return $this->id; + } + else + { + return 0; + } } else { @@ -5019,15 +5118,15 @@ abstract class CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function updateCommon(User $user, $notrigger = false) { + $error = 0; + $fields = $this->set_save_query(); foreach ($fields as $k => $v) { - if (is_array($key)){ $i=array_search($k, $key); if ( $i !== false) { @@ -5040,57 +5139,93 @@ abstract class CommonObject continue; } } - $tmp[] = $k.'='.$this->quote($v); } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; - $res = $this->db->query( $sql ); - if($res===false) { - //error - return false; + $this->db->begin(); + + if (! $error) + { + $res = $this->db->query($sql); + if ($res===false) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } } - // TODO Add triggers + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } - return true; + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } } /** * Delete object in database * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK */ public function deleteCommon(User $user, $notrigger = false) { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + $error=0; - $res = $this->db->query( $sql ); - if($res===false) { - return false; + $this->db->begin(); + + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + + if (! $error) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; + + $res = $this->db->query($sql); + if($res===false) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; } - - // TODO Add triggers - - return true; } /** - * Add quote to field value if necessary + * Initialise object with example values + * Id must be 0 if object instance is a specimen * - * @param string|int $value value to protect - * @return string|int + * @return void */ - protected function quote($value) { - - if(is_null($value)) return 'NULL'; - else if(is_numeric($value)) return $value; - else return "'".$this->db->escape( $value )."'"; + public function initAsSpecimenCommon() + { + $this->id = 0; + // TODO... } } - diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4b5f151ec72..e44fa8a5aec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -197,6 +197,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname)) { @@ -350,6 +351,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; $error=0; @@ -460,6 +462,7 @@ class ExtraFields if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; + if ($elementtype == 'categorie') $table='categories_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 73005a2fee9..05d58d22bc0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -5847,11 +5847,11 @@ class Form * @param string $morehtmlright More html code to show after ref. * @return string Portion HTML with ref + navigation buttons */ - function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') - { - global $langs,$conf,$hookmanager; + function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') + { + global $langs,$conf,$hookmanager; - $ret=''; + $ret=''; if (empty($fieldid)) $fieldid='rowid'; if (empty($fieldref)) $fieldref='ref'; @@ -5882,10 +5882,10 @@ class Form // Right part of banner if ($morehtmlright) $ret.='
'.$morehtmlright.'
'; - if ($previous_ref || $next_ref || $morehtml) - { - $ret.='
'; // Ref @@ -503,27 +598,53 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; - print ''; + print ''; + // Amount print '"; - // Multicurrency - if (!empty($conf->multicurrency->enabled)) + // Multicurrency Price + if (! empty($conf->multicurrency->enabled)) { - print '"; + print ""; } print "\n"; @@ -544,8 +665,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; - print ''; - if (!empty($conf->multicurrency->enabled)) print ''; + print ''; // Autofilled + if (!empty($conf->multicurrency->enabled)) print ''; print "\n"; } print "
'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).' 
'.price($objp->am).''.price($objp->total_ttc - $objp->am).''.price($remaintopay).''; + $namef = 'amount_'.$objp->facid; - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'"); - print ''; + $nameRemain = 'remain_'.$objp->facid; + + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } print "'; + print ''; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) { - $namef = 'multicurrency_amount_'.$objp->facid; - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->multicurrency_total_ttc - $objp->multicurrency_am)."'"); - print ''; + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } } - print "
'.price($total_ttc).''.price($totalrecu).''.price($total_ttc - $totalrecu).'  
\n"; diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 00e2dbf939d..33659b87639 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -82,7 +82,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $sref = ''; $sRefSupplier = ''; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 88f3438dcaf..92f1d4cafc6 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -84,7 +84,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $search_name=''; $toselect=''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index ec881f04c57..9048ed9a8b8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -81,7 +81,7 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; $month_create=""; diff --git a/htdocs/includes/codepress/codepress.css b/htdocs/includes/codepress/codepress.css new file mode 100644 index 00000000000..3a4a00a7414 --- /dev/null +++ b/htdocs/includes/codepress/codepress.css @@ -0,0 +1,21 @@ +body { + margin-top:13px; + _margin-top:14px; + background:white; + margin-left:32px; + font-family:monospace; + font-size:13px; + white-space:pre; + background-image:url("images/line-numbers.png"); + background-repeat:repeat-y; + background-position:0 3px; + line-height:16px; + height:100%; +} +pre {margin:0;} +html>body{background-position:0 2px;} +P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;} +b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;} + +body.hide-line-numbers {background:white;margin-left:16px;} +body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;} \ No newline at end of file diff --git a/htdocs/includes/codepress/codepress.html b/htdocs/includes/codepress/codepress.html new file mode 100644 index 00000000000..d9711d69766 --- /dev/null +++ b/htdocs/includes/codepress/codepress.html @@ -0,0 +1,35 @@ + + + + CodePress - Real Time Syntax Highlighting Editor written in JavaScript + + + + + + + + + diff --git a/htdocs/includes/codepress/codepress.js b/htdocs/includes/codepress/codepress.js new file mode 100644 index 00000000000..b3f563ad411 --- /dev/null +++ b/htdocs/includes/codepress/codepress.js @@ -0,0 +1,138 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2006 Fernando M.A.d.S. + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = function(obj) { + var self = document.createElement('iframe'); + self.textarea = obj; + self.textarea.disabled = true; + self.textarea.style.overflow = 'hidden'; + self.style.height = self.textarea.clientHeight +'px'; + self.style.width = self.textarea.clientWidth +'px'; + self.textarea.style.overflow = 'auto'; + self.style.border = '1px solid gray'; + self.frameBorder = 0; // remove IE internal iframe border + self.style.visibility = 'hidden'; + self.style.position = 'absolute'; + self.options = self.textarea.className; + + self.initialize = function() { + self.editor = self.contentWindow.CodePress; + self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0]; + self.editor.setCode(self.textarea.value); + self.setOptions(); + self.editor.syntaxHighlight('init'); + self.textarea.style.display = 'none'; + self.style.position = 'static'; + self.style.visibility = 'visible'; + self.style.display = 'inline'; + } + + // obj can by a textarea id or a string (code) + self.edit = function(obj,language) { + if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj; + if(!self.textarea.disabled) return; + self.language = language ? language : self.getLanguage(); + self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime(); + if(self.attachEvent) self.attachEvent('onload',self.initialize); + else self.addEventListener('load',self.initialize,false); + } + + self.getLanguage = function() { + for (language in CodePress.languages) + if(self.options.match('\\b'+language+'\\b')) + return CodePress.languages[language] ? language : 'generic'; + } + + self.setOptions = function() { + if(self.options.match('autocomplete-off')) self.toggleAutoComplete(); + if(self.options.match('readonly-on')) self.toggleReadOnly(); + if(self.options.match('linenumbers-off')) self.toggleLineNumbers(); + } + + self.getCode = function() { + return self.textarea.disabled ? self.editor.getCode() : self.textarea.value; + } + + self.setCode = function(code) { + self.textarea.disabled ? self.editor.setCode(code) : self.textarea.value = code; + } + + self.toggleAutoComplete = function() { + self.editor.autocomplete = (self.editor.autocomplete) ? false : true; + } + + self.toggleReadOnly = function() { + self.textarea.readOnly = (self.textarea.readOnly) ? false : true; + if(self.style.display != 'none') // prevent exception on FF + iframe with display:none + self.editor.readOnly(self.textarea.readOnly ? true : false); + } + + self.toggleLineNumbers = function() { + var cn = self.editor.body.className; + self.editor.body.className = (cn==''||cn=='show-line-numbers') ? 'hide-line-numbers' : 'show-line-numbers'; + } + + self.toggleEditor = function() { + if(self.textarea.disabled) { + self.textarea.value = self.getCode(); + self.textarea.disabled = false; + self.style.display = 'none'; + self.textarea.style.display = 'inline'; + } + else { + self.textarea.disabled = true; + self.setCode(self.textarea.value); + self.editor.syntaxHighlight('init'); + self.style.display = 'inline'; + self.textarea.style.display = 'none'; + } + } + + self.edit(); + return self; +} + +CodePress.languages = { + csharp : 'C#', + css : 'CSS', + generic : 'Generic', + html : 'HTML', + java : 'Java', + javascript : 'JavaScript', + perl : 'Perl', + ruby : 'Ruby', + php : 'PHP', + text : 'Text', + sql : 'SQL', + vbscript : 'VBScript' +} + + +CodePress.run = function() { + s = document.getElementsByTagName('script'); + for(var i=0,n=s.length;i + * + * Developers: + * Fernando M.A.d.S. + * Michael Hurni + * Contributors: + * Martin D. Kirk + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + body = document.getElementsByTagName('body')[0]; + body.innerHTML = body.innerHTML.replace(/\n/g,""); + chars = '|32|46|62|8|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // carret char + editor = document.getElementsByTagName('pre')[0]; + document.designMode = 'on'; + document.addEventListener('keypress', this.keyHandler, true); + window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); + completeChars = this.getCompleteChars(); + completeEndingChars = this.getCompleteEndingChars(); + }, + + // treat key bindings + keyHandler : function(evt) { + keyCode = evt.keyCode; + charCode = evt.charCode; + fromChar = String.fromCharCode(charCode); + + if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(charCode?charCode:keyCode); + } + else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && CodePress.autocomplete) { // auto complete + if(!CodePress.completeEnding(fromChar)) + CodePress.complete(fromChar); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting + top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); + } + else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) + CodePress.snippets(evt); + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo + (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.preventDefault(); + } + else if(charCode==118 && evt.ctrlKey) { // handle paste + top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100); + } + else if(charCode==99 && evt.ctrlKey) { // handle cut + //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF')); + } + + }, + + // put cursor back to its original position after every parsing + findString : function() { + if(self.find(cc)) + window.getSelection().getRangeAt(0).deleteContents(); + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(cc); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code; + } + }, + + getEditor : function() { + if(!document.getElementsByTagName('pre')[0]) { + body = document.getElementsByTagName('body')[0]; + if(!body.innerHTML) return body; + if(body.innerHTML=="
") body.innerHTML = "
 
"; + else body.innerHTML = "
"+body.innerHTML+"
"; + } + return document.getElementsByTagName('pre')[0]; + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + //if(document.designMode=='off') document.designMode='on' + if(flag != 'init') { window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));} + editor = CodePress.getEditor(); + o = editor.innerHTML; + o = o.replace(/
/g,'\n'); + o = o.replace(/<.*?>/g,''); + x = z = this.split(o,flag); + x = x.replace(/\n/g,'
'); + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'
'); + var pattern = new RegExp(trigger+cc,'gi'); + evt.preventDefault(); // prevent the tab key from being added + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + document.designMode = (arguments[0]) ? 'off' : 'on'; + }, + + complete : function(trigger) { + window.getSelection().getRangeAt(0).deleteContents(); + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = code; + if (code == '') + document.getElementsByTagName('body')[0].innerHTML = ''; + }, + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + editor = CodePress.getEditor(); + if(editor.innerHTML.indexOf(cc)==-1){ + if(editor.innerHTML != " ") + window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); + this.history[this.pos] = editor.innerHTML; + } + this.pos --; + if(typeof(this.history[this.pos])=='undefined') this.pos ++; + editor.innerHTML = this.history[this.pos]; + if(editor.innerHTML.indexOf(cc)>-1) editor.innerHTML+=cc; + CodePress.findString(); + }, + + redo : function() { + // editor = CodePress.getEditor(); + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.addEventListener('load', function() { CodePress.initialize('new'); }, true); \ No newline at end of file diff --git a/htdocs/includes/codepress/engines/khtml.js b/htdocs/includes/codepress/engines/khtml.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/includes/codepress/engines/msie.js b/htdocs/includes/codepress/engines/msie.js new file mode 100644 index 00000000000..2558c395d39 --- /dev/null +++ b/htdocs/includes/codepress/engines/msie.js @@ -0,0 +1,304 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2007 Fernando M.A.d.S. + * + * Developers: + * Fernando M.A.d.S. + * Michael Hurni + * Contributors: + * Martin D. Kirk + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // carret char + editor = document.getElementsByTagName('pre')[0]; + editor.contentEditable = 'true'; + document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();} + document.attachEvent('onkeydown', this.metaHandler); + document.attachEvent('onkeypress', this.keyHandler); + window.attachEvent('onscroll', function() { if(!CodePress.scrolling) setTimeout(function(){CodePress.syntaxHighlight('scroll')},1)}); + completeChars = this.getCompleteChars(); + completeEndingChars = this.getCompleteEndingChars(); + setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top + }, + + // treat key bindings + keyHandler : function(evt) { + charCode = evt.keyCode; + fromChar = String.fromCharCode(charCode); + + if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1 )&& CodePress.autocomplete) { // auto complete + if(!CodePress.completeEnding(fromChar)) + CodePress.complete(fromChar); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting + CodePress.syntaxHighlight('generic'); + } + }, + + metaHandler : function(evt) { + keyCode = evt.keyCode; + + if(keyCode==9 || evt.tabKey) { + CodePress.snippets(); + } + else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo + (keyCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.returnValue = false; + } + else if(keyCode==34||keyCode==33) { // handle page up/down for IE + self.scrollBy(0, (keyCode==34) ? 200 : -200); + evt.returnValue = false; + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(keyCode); + evt.returnValue = false; + } + else if(keyCode==86 && evt.ctrlKey) { // handle paste + window.clipboardData.setData('Text',window.clipboardData.getData('Text').replace(/\t/g,'\u2008')); + top.setTimeout(function(){CodePress.syntaxHighlight('paste');},10); + } + else if(keyCode==67 && evt.ctrlKey) { // handle cut + // window.clipboardData.setData('Text',x[0]); + // code = window.clipboardData.getData('Text'); + } + }, + + // put cursor back to its original position after every parsing + + + findString : function() { + range = self.document.body.createTextRange(); + if(range.findText(cc)){ + range.select(); + range.text = ''; + } + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(cc); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code.substring(code.indexOf('

'),code.lastIndexOf('

')+4); + } + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + if(flag!='init') document.selection.createRange().text = cc; + o = editor.innerHTML; + if(flag=='paste') { // fix pasted text + o = o.replace(/
/g,'\r\n'); + o = o.replace(/\u2008/g,'\t'); + } + o = o.replace(/

/g,'\n'); + o = o.replace(/<\/P>/g,'\r'); + o = o.replace(/<.*?>/g,''); + o = o.replace(/ /g,''); + o = '

'+o+'

'; + o = o.replace(/\n\r/g,'

'); + o = o.replace(/\n/g,'

'); + o = o.replace(/\r/g,'<\/P>'); + o = o.replace(/

(

)+/,'

'); + o = o.replace(/<\/P>(<\/P>)+/,'

'); + o = o.replace(/

<\/P>/g,'


'); + x = z = this.split(o,flag); + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'

'); + var pattern = new RegExp(trigger+cc,"gi"); + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + editor.contentEditable = (arguments[0]) ? 'false' : 'true'; + }, + + complete : function(trigger) { + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/<\/p>/gi,'\r'); + code = code.replace(/

/i,''); // IE first line fix + code = code.replace(/

/gi,'\n'); + code = code.replace(/ /gi,''); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = '

'+code+'
'; + }, + + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + if(editor.innerHTML.indexOf(cc)==-1){ + document.selection.createRange().text = cc; + this.history[this.pos] = editor.innerHTML; + } + this.pos--; + if(typeof(this.history[this.pos])=='undefined') this.pos++; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + redo : function() { + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.attachEvent('onload', function() { CodePress.initialize('new');}); \ No newline at end of file diff --git a/htdocs/includes/codepress/engines/older.js b/htdocs/includes/codepress/engines/older.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/includes/codepress/engines/opera.js b/htdocs/includes/codepress/engines/opera.js new file mode 100644 index 00000000000..155bf098a32 --- /dev/null +++ b/htdocs/includes/codepress/engines/opera.js @@ -0,0 +1,260 @@ +/* + * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/ + * + * Copyright (C) 2007 Fernando M.A.d.S. + * + * Contributors : + * + * Michael Hurni + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation. + * + * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php + */ + + +CodePress = { + scrolling : false, + autocomplete : true, + + // set initial vars and start sh + initialize : function() { + if(typeof(editor)=='undefined' && !arguments[0]) return; + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting + cc = '\u2009'; // control char + editor = document.getElementsByTagName('body')[0]; + document.designMode = 'on'; + document.addEventListener('keyup', this.keyHandler, true); + window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false); + completeChars = this.getCompleteChars(); +// CodePress.syntaxHighlight('init'); + }, + + // treat key bindings + keyHandler : function(evt) { + keyCode = evt.keyCode; + charCode = evt.charCode; + + if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) + CodePress.shortcuts(charCode?charCode:keyCode); + } + else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete + CodePress.complete(String.fromCharCode(charCode)); + } + else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting + CodePress.syntaxHighlight('generic'); + } + else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) + CodePress.snippets(evt); + } + else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed + CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML; + } + else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo + (charCode==121||evt.shiftKey) ? CodePress.actions.redo() : CodePress.actions.undo(); + evt.preventDefault(); + } + else if(keyCode==86 && evt.ctrlKey) { // paste + // TODO: pasted text should be parsed and highlighted + } + }, + + // put cursor back to its original position after every parsing + findString : function() { + var sel = window.getSelection(); + var range = window.document.createRange(); + var span = window.document.getElementsByTagName('span')[0]; + + range.selectNode(span); + sel.removeAllRanges(); + sel.addRange(range); + span.parentNode.removeChild(span); + //if(self.find(cc)) + //window.getSelection().getRangeAt(0).deleteContents(); + }, + + // split big files, highlighting parts of it + split : function(code,flag) { + if(flag=='scroll') { + this.scrolling = true; + return code; + } + else { + this.scrolling = false; + mid = code.indexOf(''); + if(mid-2000<0) {ini=0;end=4000;} + else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} + else {ini=mid-2000;end=mid+2000;} + code = code.substring(ini,end); + return code; + } + }, + + // syntax highlighting parser + syntaxHighlight : function(flag) { + //if(document.designMode=='off') document.designMode='on' + if(flag!='init') { + var span = document.createElement('span'); + window.getSelection().getRangeAt(0).insertNode(span); + } + + o = editor.innerHTML; +// o = o.replace(/
/g,'\r\n'); +// o = o.replace(/<(b|i|s|u|a|em|tt|ins|big|cite|strong)?>/g,''); + //alert(o) + o = o.replace(/<(?!span|\/span|br).*?>/gi,''); +// alert(o) +// x = o; + x = z = this.split(o,flag); + //alert(z) +// x = x.replace(/\r\n/g,'
'); + x = x.replace(/\t/g, ' '); + + + if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); + + for(i=0;i/g,'>'); + if(content.indexOf('$0')<0) content += cc; + else content = content.replace(/\$0/,cc); + content = content.replace(/\n/g,'
'); + var pattern = new RegExp(trigger+cc,'gi'); + evt.preventDefault(); // prevent the tab key from being added + this.syntaxHighlight('snippets',pattern,content); + } + } + }, + + readOnly : function() { + document.designMode = (arguments[0]) ? 'off' : 'on'; + }, + + complete : function(trigger) { + window.getSelection().getRangeAt(0).deleteContents(); + var complete = Language.complete; + for (var i=0; i/g,'\n'); + code = code.replace(/\u2009/g,''); + code = code.replace(/<.*?>/g,''); + code = code.replace(/</g,'<'); + code = code.replace(/>/g,'>'); + code = code.replace(/&/gi,'&'); + return code; + }, + + // put code inside editor + setCode : function() { + var code = arguments[0]; + code = code.replace(/\u2009/gi,''); + code = code.replace(/&/gi,'&'); + code = code.replace(//g,'>'); + editor.innerHTML = code; + }, + + // undo and redo methods + actions : { + pos : -1, // actual history position + history : [], // history vector + + undo : function() { + if(editor.innerHTML.indexOf(cc)==-1){ + window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); + this.history[this.pos] = editor.innerHTML; + } + this.pos--; + if(typeof(this.history[this.pos])=='undefined') this.pos++; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + redo : function() { + this.pos++; + if(typeof(this.history[this.pos])=='undefined') this.pos--; + editor.innerHTML = this.history[this.pos]; + CodePress.findString(); + }, + + next : function() { // get next vector position and clean old ones + if(this.pos>20) this.history[this.pos-21] = undefined; + return ++this.pos; + } + } +} + +Language={}; +window.addEventListener('load', function() { CodePress.initialize('new'); }, true); diff --git a/htdocs/includes/codepress/images/line-numbers.png b/htdocs/includes/codepress/images/line-numbers.png new file mode 100644 index 00000000000..ffea4e6aa16 Binary files /dev/null and b/htdocs/includes/codepress/images/line-numbers.png differ diff --git a/htdocs/includes/codepress/index.html b/htdocs/includes/codepress/index.html new file mode 100644 index 00000000000..60fc918e89d --- /dev/null +++ b/htdocs/includes/codepress/index.html @@ -0,0 +1,443 @@ + + + + + CodePress - Real Time Syntax Highlighting Editor written in JavaScript + + + + + + +
+ + + +
+ + + + + + + + + + +

+ CodePress is web-based source code editor with syntax highlighting written in JavaScript that colors text in real time while it's being typed in the browser. +

+ +

+ Go to http://codepress.org/ for updates. +

+ +

Demo

+
+ choose example in: + + + + + + + +
+ + + +

+ + + +

+ + + + + +

+ + + +

Installation

+
    +
  1. +

    + Download and uncompress CodePress under a directory inside your webserver.
    + Example: http://yourserver/codepress/
    + Since CodePress is pure JavaScript and HTML, you can also test it without a webserver. +

    +
  2. +
  3. +

    + Insert CodePress script somewhere in your page inside the <head> or above the </body> tag. +

    + +

    + <script src="/codepress/codepress.js" type="text/javascript"></script> +

    +
  4. + +
  5. +

    + Add the <textarea> tag to the place on your page you want CodePress to appear. CodePress will inherit the width and height of your textarea. + When the page loads, it will automatically replace your textarea with a CodePress window. +

    +

    + <textarea id="myCpWindow" class="codepress javascript linenumbers-off">
    +    // your code here
    + </textarea> +

    +
      +
    • + The javascript portion of the class="" means that the language being edited is JavaScript. +
    • +
    • + The codepress portion of the class="" is mandatory and indicates a textarea to be replaced for a CodePress window. +
    • +
    • + Other class options are linenumbers-off, autocomplete-off and readonly-on. +
    • +
    • + Careful not to use the same id for two different CodePress windows (<textarea id="xx"...>) +
    • +
    + +
  6. +
+ +

You also can...

+
    +
  1. + Open/edit code from a different textarea.
    + Example: textarea_id.edit('other_textarea_id','language')
    +
  2. +
  3. + Get code from CodePress window.
    + Example: textarea_id.getCode()
    +
  4. +
  5. + Turn on/off CodePress editor and return to the regular textarea.
    + Example: textarea_id.toggleEditor()
    +
  6. +
  7. + Turn on/off line numbers.
    + Example: textarea_id.toggleLineNumbers()
    +
  8. +
  9. + Turn on/off read only.
    + Example: textarea_id.toggleReadOnly()
    +
  10. +
  11. + Turn on/off auto-complete.
    + Example: textarea_id.toggleAutoComplete()
    +
  12. + +
+ + + +

License

+

+ CodePress is distributed under the LGPL. If your software is compatible with this licence or it is under Creative Commons, you can use it as you want. Just keep the credits somewhere around. +

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/htdocs/includes/codepress/languages/asp.css b/htdocs/includes/codepress/languages/asp.css new file mode 100644 index 00000000000..9a4c505c330 --- /dev/null +++ b/htdocs/includes/codepress/languages/asp.css @@ -0,0 +1,71 @@ +/* + * CodePress color styles for ASP-VB syntax highlighting + * By Martin D. Kirk + */ +/* tags */ + +b { + color:#000080; +} +/* comments */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u { + color:gray; + font-weight:normal; +} +/* ASP comments */ +strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{ + color:gray; + font-weight:normal; +} + /* attributes */ +s, s b, span s u, span s cite, strong span s { + color:#5656fa ; + font-weight:normal; +} + /* strings */ +strong s,strong s b, strong s u, strong s cite { + color:#009900; + font-weight:normal; +} +strong ins{ + color:#000000; + font-weight:bold; +} + /* Syntax */ +strong a, strong a u { + color:#0000FF; + font-weight:; +} + /* Native Keywords */ +strong u { + color:#990099; + font-weight:bold; +} +/* Numbers */ +strong var{ + color:#FF0000; +} +/* ASP Language */ +span{ + color:#990000; + font-weight:bold; +} +strong i,strong a i, strong u i { + color:#009999; +} +/* style */ +em { + color:#800080; + font-style:normal; +} + /* script */ +ins { + color:#800000; + font-weight:bold; +} + +/* */ +cite, s cite { + color:red; + font-weight:bold; +} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/asp.js b/htdocs/includes/codepress/languages/asp.js new file mode 100644 index 00000000000..21e78dd887c --- /dev/null +++ b/htdocs/includes/codepress/languages/asp.js @@ -0,0 +1,117 @@ +/* + * CodePress regular expressions for ASP-vbscript syntax highlighting + */ + +// ASP VBScript +Language.syntax = [ +// all tags + { input : /(<[^!%|!%@]*?>)/g, output : '$1' }, +// style tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, +// script tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, +// strings "" and attributes + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, +// ASP Comment + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, +// <%.* + { input : /(<%)/g, output : '$1' }, +// .*%> + { input : /(%>)/g, output : '$1' }, +// <%@...%> + { input : /(<%@)(.+?)(%>)/gi, output : '$1$2$3' }, +//Numbers + { input : /\b([\d]+)\b/g, output : '$1' }, +// Reserved Words 1 (Blue) + { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '$1' }, + { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '$1' }, + { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '$1' }, +// Reserved Words 2 (Purple) + { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '$1' }, + { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '$1' }, + { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '$1' }, + { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '$1' }, + { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '$1' }, + { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '$1' }, + { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '$1' }, + { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '$1' }, + { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '$1' }, + { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '$1' }, + { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '$1' }, + { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '$1' }, + { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '$1' }, + { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '$1' }, + { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '$1' }, + { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '$1' }, +// Reserved Words 3 (Turquis) + { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '$1' }, + { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '$1' }, + { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '$1' }, + { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '$1' }, + { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '$1' }, + { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '$1' }, +// html comments + { input : /(<!--.*?-->.)/g, output : '$1' } +] + +Language.Functions = [ + // Output at index 0, must be the desired tagname surrounding a $1 + // Name is the index from the regex that marks the functionname + {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '$1', name : '$3'} +] + +Language.snippets = [ +//Conditional + { input : 'if', output : 'If $0 Then\n\t\nEnd If' }, + { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' }, + { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'}, +//Response + { input : 'rw', output : 'Response.Write( $0 )' }, + { input : 'resc', output : 'Response.Cookies( $0 )' }, + { input : 'resb', output : 'Response.Buffer'}, + { input : 'resflu', output : 'Response.Flush()'}, + { input : 'resend', output : 'Response.End'}, +//Request + { input : 'reqc', output : 'Request.Cookies( $0 )' }, + { input : 'rq', output : 'Request.Querystring("$0")' }, + { input : 'rf', output : 'Request.Form("$0")' }, +//FSO + { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' }, + { input : 'setfo', output : 'Set fo = fso.getFolder($0)' }, + { input : 'setfi', output : 'Set fi = fso.getFile($0)' }, + { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'}, + { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'}, +//Server + { input : 'mapp', output : 'Server.Mappath($0)' }, +//Loops + { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' }, + { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' }, + { input : 'do', output : 'Do While($0)\n\t\nLoop' }, + { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' }, +//ADO + { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' }, + { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' }, + { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' }, +//Http Request + { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' }, + { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'}, +//Functions + { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'}, + { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'} + +] + +Language.complete = [ + //{ input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/autoit.css b/htdocs/includes/codepress/languages/autoit.css new file mode 100644 index 00000000000..eb2b43b6e4a --- /dev/null +++ b/htdocs/includes/codepress/languages/autoit.css @@ -0,0 +1,13 @@ +/** + * CodePress color styles for AutoIt syntax highlighting + */ + +u {font-style:normal;color:#000090;font-weight:bold;font-family:Monospace;} +var {color:#AA0000;font-weight:bold;font-style:normal;} +em {color:#FF33FF;} +ins {color:#AC00A9;} +i {color:#F000FF;} +b {color:#FF0000;} +a {color:#0080FF;font-weight:bold;} +s, s u, s b {color:#9999CC;font-weight:normal;} +cite, cite *{color:#009933;font-weight:normal;} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/autoit.js b/htdocs/includes/codepress/languages/autoit.js new file mode 100644 index 00000000000..6f5c19d0ba2 --- /dev/null +++ b/htdocs/includes/codepress/languages/autoit.js @@ -0,0 +1,32 @@ +/** + * CodePress regular expressions for AutoIt syntax highlighting + * @author: James Brooks, Michael HURNI + */ + +// AutoIt +Language.syntax = [ + { input : /({|}|\(|\))/g, output : '$1' }, // Brackets + { input : /(\*|\+|-)/g, output : '$1' }, // Operator + { input : /\"(.*?)(\"|
|<\/P>)/g, output : "\"$1$2" }, // strings double + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single + { input : /\b([\d]+)\b/g, output : '$1' }, // Numbers + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' }, // Directives and Includes + { input : /(\$[\w\.]*)/g, output : '$1' }, // vars + { input : /(_[\w\.]*)/g, output : '$1' }, // underscored word + { input : /(\@[\w\.]*)/g, output : '$1' }, // Macros + { input : /\b(Abs|ACos|AdlibDisable|AdlibEnable|Asc|AscW|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItWinSetTitle|Beep|Binary|BinaryLen|BinaryMid|BinaryToString|BitAND|BitNOT|BitOR|BitSHIFT|BitXOR|BlockInput|Break|Call|CDTray|Ceiling|Chr|ChrW|ClipGet|ClipPut|ConsoleRead|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|ControlFocus|ControlGetFocus|ControlGetHandle|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText|ControlShow|Cos|Dec|DirCopy|DirCreate|DirGetSize|DirMove|DirRemove|DllCall|DllCall|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStructGetPtr|DllStructGetSize|DllStructSetData|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMapDel|DriveMapGet|DriveSetLabel|DriveSpaceFree|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|FileCopy|FileCreateNTFS|FileCreateShortcut|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetShortcut|FileGetShortName|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileSaveDialog|FileSelectFolder|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GuiCreate|GuiCtrlCreateAvi|GuiCtrlCreateButton|GuiCtrlCreateCheckbox|GuiCtrlCreateCombo|GuiCtrlCreateContextMenu|GuiCtrlCreateDate|GuiCtrlCreateDummy|GuiCtrlCreateEdit|GuiCtrlCreateGraphic|GuiCtrlCreateGroup|GuiCtrlCreateIcon|GuiCtrlCreateInput|GuiCtrlCreateLabel|GuiCtrlCreateList|GuiCtrlCreateListView|GuiCtrlCreateListViewItem|GuiCtrlCreateMenu|GuiCtrlCreateMenuItem|GuiCtrlCreateMonthCal|GuiCtrlCreateObj|GuiCtrlCreatePic|GuiCtrlCreateProgress|GuiCtrlCreateRadio|GuiCtrlCreateSlider|GuiCtrlCreateTab|GuiCtrlCreateTabItem|GuiCtrlCreateUpdown|GuiCtrlDelete|GuiCtrlGetHandle|GuiCtrlGetState|GuiCtrlRead|GuiCtrlRecvMsg|GuiCtrlSentMsg|GuiCtrlSendToDummy|GuiCtrlSetBkColor|GuiCtrlSetColor|GuiCtrlSetCursor|GuiCtrlSetData|GuiCtrlSetFont|GuiCtrlSetGraphic|GuiCtrlSetImage|GuiCtrlSetLimit|GuiCtrlSetOnEvent|GuiCtrlSetPos|GuiCtrlResizing|GuiCtrlSetState|GuiCtrlSetTip|GuiDelete|GuiGetCursorInfo|GuiGetMsg|GuiGetStyle|GuiRegisterMsg|GuiSetBkColor|GuiSetCoord|GuiSetCursor|GuiSetFont|GuiSetHelp|GuiSetIcon|GuiSetOnEvent|GuiSetStat|GuiSetStyle|GuiStartGroup|GuiSwitch|Hex|HotKeySet|HttpSetProxy|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|IniWrite|IniWriteSection|InputBox|Int|IsAdmin|IsArray|IsBinary|IsBool|IsDeclared|IsDllStruct|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsString|Log|MemGetStats|Mod|MouseClick|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Ping|PixelCheckSum|PixelGetColor|PixelSearch|ProcessClose|ProcessExists|ProcessList|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProcessOn|ProgressSet|Random|RegDelete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAsSet|RunWait|Send|SetError|SetExtended|ShellExecute|ShellExecuteWait|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn|SplashOff|SplashTextOn|Sqrt|SRandom|StatusbarGetText|StderrRead|StdinWrite|StdoutRead|String|StringAddCR|StringCompare|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|StringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringRegExp|StringRegExpReplace|StringReplace|StringRight|StringSplit|StringStripCR|StringStripWS|StringToBinary|StringTrimLeft|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPrecv|TCPSend|TCPShutdown|TCPStartup|TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMenu|TrayGetMsg|TrayItemDelete|TrayItemGetHandle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TraySetState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket|UDPOpen|UDPRecv|UDPSend|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGetClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/g, output : '$1' } ,// reserved words + { input : /\B;(.*?)(
|<\/P>)/g, output : ';$1$2' }, // comments + { input : /#CS(.*?)#CE/g, output : '#CS$1#CE' } // Block Comments +] + +Language.snippets = [] + +Language.complete = [ +{ input : '\'',output : '\'$0\'' }, +{ input : '"', output : '"$0"' }, +{ input : '(', output : '\($0\)' }, +{ input : '[', output : '\[$0\]' }, +{ input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/csharp.css b/htdocs/includes/codepress/languages/csharp.css new file mode 100644 index 00000000000..8464c5ddb0d --- /dev/null +++ b/htdocs/includes/codepress/languages/csharp.css @@ -0,0 +1,9 @@ +/* + * CodePress color styles for Java syntax highlighting + * By Edwin de Jonge + */ + +b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */ +a {color:#2A0088;font-weight:bold;font-style:normal;} /* types */ +i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */ +s, s b {color:#2A00FF;font-weight:normal;} /* strings */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/csharp.js b/htdocs/includes/codepress/languages/csharp.js new file mode 100644 index 00000000000..0a61fd52a92 --- /dev/null +++ b/htdocs/includes/codepress/languages/csharp.js @@ -0,0 +1,25 @@ +/* + * CodePress regular expressions for C# syntax highlighting + * By Edwin de Jonge + */ + +Language.syntax = [ // C# + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(abstract|as|base|break|case|catch|checked|continue|default|delegate|do|else|event|explicit|extern|false|finally|fixed|for|foreach|get|goto|if|implicit|in|interface|internal|is|lock|namespace|new|null|object|operator|out|override|params|partial|private|protected|public|readonly|ref|return|set|sealed|sizeof|static|stackalloc|switch|this|throw|true|try|typeof|unchecked|unsafe|using|value|virtual|while)\b/g, output : '$1' }, // reserved words + { input : /\b(bool|byte|char|class|double|float|int|interface|long|string|struct|void)\b/g, output : '$1' }, // types + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +]; + +Language.snippets = []; + +Language.complete = [ // Auto complete only for 1 character + {input : '\'',output : '\'$0\'' }, + {input : '"', output : '"$0"' }, + {input : '(', output : '\($0\)' }, + {input : '[', output : '\[$0\]' }, + {input : '{', output : '{\n\t$0\n}' } +]; + +Language.shortcuts = []; \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/css.css b/htdocs/includes/codepress/languages/css.css new file mode 100644 index 00000000000..49ba5843d73 --- /dev/null +++ b/htdocs/includes/codepress/languages/css.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for CSS syntax highlighting + */ + +b, b a, b u {color:#000080;} /* tags, ids, classes */ +i, i b, i s, i a, i u {color:gray;} /* comments */ +s, s b {color:#a0a0dd;} /* parameters */ +a {color:#0000ff;} /* keys */ +u {color:red;} /* values */ + diff --git a/htdocs/includes/codepress/languages/css.js b/htdocs/includes/codepress/languages/css.js new file mode 100644 index 00000000000..c29059b76e3 --- /dev/null +++ b/htdocs/includes/codepress/languages/css.js @@ -0,0 +1,23 @@ +/* + * CodePress regular expressions for CSS syntax highlighting + */ + +// CSS +Language.syntax = [ + { input : /(.*?){(.*?)}/g,output : '$1{$2}' }, // tags, ids, classes, values + { input : /([\w-]*?):([^\/])/g,output : '$1:$2' }, // keys + { input : /\((.*?)\)/g,output : '($1)' }, // parameters + { input : /\/\*(.*?)\*\//g,output : '/*$1*/'} // comments +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/generic.css b/htdocs/includes/codepress/languages/generic.css new file mode 100644 index 00000000000..712942f45af --- /dev/null +++ b/htdocs/includes/codepress/languages/generic.css @@ -0,0 +1,9 @@ +/* + * CodePress color styles for generic syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +u {color:darkblue;font-weight:bold;} /* special words */ +i, i b, i s, i u, i em {color:green;font-weight:normal;} /* comments */ +s, s b, s em {color:#2A00FF;font-weight:normal;} /* strings */ +em {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/generic.js b/htdocs/includes/codepress/languages/generic.js new file mode 100644 index 00000000000..4c866de9995 --- /dev/null +++ b/htdocs/includes/codepress/languages/generic.js @@ -0,0 +1,25 @@ +/* + * CodePress regular expressions for generic syntax highlighting + */ + +// generic languages +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(abstract|continue|for|new|switch|default|goto|boolean|do|if|private|this|break|double|protected|throw|byte|else|import|public|throws|case|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|const|float|while|function|label)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars; + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/html.css b/htdocs/includes/codepress/languages/html.css new file mode 100644 index 00000000000..14882e553ef --- /dev/null +++ b/htdocs/includes/codepress/languages/html.css @@ -0,0 +1,13 @@ +/* + * CodePress color styles for HTML syntax highlighting + */ + +b {color:#000080;} /* tags */ +ins, ins b, ins s, ins em {color:gray;} /* comments */ +s, s b {color:#7777e4;} /* attribute values */ +a {color:green;} /* links */ +u {color:#E67300;} /* forms */ +big {color:#db0000;} /* images */ +em, em b {color:#800080;} /* style */ +strong {color:#800000;} /* script */ +tt i {color:darkblue;font-weight:bold;} /* script reserved words */ diff --git a/htdocs/includes/codepress/languages/html.js b/htdocs/includes/codepress/languages/html.js new file mode 100644 index 00000000000..4ead0b086ba --- /dev/null +++ b/htdocs/includes/codepress/languages/html.js @@ -0,0 +1,59 @@ +/* + * CodePress regular expressions for HTML syntax highlighting + */ + +// HTML +Language.syntax = [ + { input : /(<[^!]*?>)/g, output : '$1' }, // all tags + { input : /(<a .*?>|<\/a>)/g, output : '$1' }, // links + { input : /(<img .*?>)/g, output : '$1' }, // images + { input : /(<\/?(button|textarea|form|input|select|option|label).*?>)/g, output : '$1' }, // forms + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, // style tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, // script tags + { input : /=(".*?")/g, output : '=$1' }, // atributes double quote + { input : /=('.*?')/g, output : '=$1' }, // atributes single quote + { input : /(<!--.*?-->.)/g, output : '$1' }, // comments + { input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '$1' } // script reserved words +] + +Language.snippets = [ + { input : 'aref', output : '' }, + { input : 'h1', output : '

$0

' }, + { input : 'h2', output : '

$0

' }, + { input : 'h3', output : '

$0

' }, + { input : 'h4', output : '

$0

' }, + { input : 'h5', output : '
$0
' }, + { input : 'h6', output : '
$0
' }, + { input : 'html', output : '\n\t$0\n' }, + { input : 'head', output : '\n\t\n\t$0\n\t\n' }, + { input : 'img', output : '' }, + { input : 'input', output : '' }, + { input : 'label', output : '' }, + { input : 'legend', output : '\n\t$0\n' }, + { input : 'link', output : '' }, + { input : 'base', output : '' }, + { input : 'body', output : '\n\t$0\n' }, + { input : 'css', output : '' }, + { input : 'div', output : '
\n\t$0\n
' }, + { input : 'divid', output : '
\n\t\n
' }, + { input : 'dl', output : '
\n\t
\n\t\t$0\n\t
\n\t
\n
' }, + { input : 'fieldset', output : '
\n\t$0\n
' }, + { input : 'form', output : '\n\t\n' }, + { input : 'meta', output : '' }, + { input : 'p', output : '

$0

' }, + { input : 'script', output : '' }, + { input : 'scriptsrc', output : '' }, + { input : 'span', output : '$0' }, + { input : 'table', output : '\n\t\n\t\n
' }, + { input : 'style', output : '' } +] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/java.css b/htdocs/includes/codepress/languages/java.css new file mode 100644 index 00000000000..b9c44416836 --- /dev/null +++ b/htdocs/includes/codepress/languages/java.css @@ -0,0 +1,7 @@ +/* + * CodePress color styles for Java syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */ +i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */ +s, s b {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/java.js b/htdocs/includes/codepress/languages/java.js new file mode 100644 index 00000000000..f0d620d6898 --- /dev/null +++ b/htdocs/includes/codepress/languages/java.js @@ -0,0 +1,24 @@ +/* + * CodePress regular expressions for Java syntax highlighting + */ + +// Java +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2'}, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, // strings single quote + { input : /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g, output : '$1'}, // reserved words + { input : /([^:]|^)\/\/(.*?)(//$2$3'}, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' }// comments /* */ +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/javascript.css b/htdocs/includes/codepress/languages/javascript.css new file mode 100644 index 00000000000..acbf49a916f --- /dev/null +++ b/htdocs/includes/codepress/languages/javascript.css @@ -0,0 +1,8 @@ +/* + * CodePress color styles for JavaScript syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +u {color:darkblue;font-weight:bold;} /* special words */ +i, i b, i s, i u {color:green;font-weight:normal;} /* comments */ +s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/javascript.js b/htdocs/includes/codepress/languages/javascript.js new file mode 100644 index 00000000000..66d0fc02409 --- /dev/null +++ b/htdocs/includes/codepress/languages/javascript.js @@ -0,0 +1,30 @@ +/* + * CodePress regular expressions for JavaScript syntax highlighting + */ + +// JavaScript +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '$1' }, // reserved words + { input : /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover)\b/g, output : '$1' }, // special words + { input : /([^:]|^)\/\/(.*?)(//$2$3' }, // comments // + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' } // comments /* */ +] + +Language.snippets = [ + { input : 'dw', output : 'document.write(\'$0\');' }, + { input : 'getid', output : 'document.getElementById(\'$0\')' }, + { input : 'fun', output : 'function $0(){\n\t\n}' }, + { input : 'func', output : 'function $0(){\n\t\n}' } +] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/perl.css b/htdocs/includes/codepress/languages/perl.css new file mode 100644 index 00000000000..c2d6d56d730 --- /dev/null +++ b/htdocs/includes/codepress/languages/perl.css @@ -0,0 +1,11 @@ +/* + * CodePress color styles for Perl syntax highlighting + * By J. Nick Koston + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */ +s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */ +a {color:#006700;font-weight:bold;} /* variables */ +em {color:darkblue;font-weight:bold;} /* functions */ +u {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/perl.js b/htdocs/includes/codepress/languages/perl.js new file mode 100644 index 00000000000..06c380d654a --- /dev/null +++ b/htdocs/includes/codepress/languages/perl.js @@ -0,0 +1,27 @@ +/* + * CodePress regular expressions for Perl syntax highlighting + * By J. Nick Koston + */ + +// Perl +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /([\$\@\%][\w\.]*)/g, output : '$1' }, // vars + { input : /(sub\s+)([\w\.]*)/g, output : '$1$2' }, // functions + { input : /\b(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|do|dump|each|else|elsif|endgrent|endhostent|endnetent|endprotoent|endpwent|eof|eval|exec|exists|exit|fcntl|fileno|find|flock|for|foreach|fork|format|formlinegetc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyaddr|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|hostname|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link|listen|LoadExternals|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|opendir|ordpack|package|pipe|pop|pos|print|printf|push|pwd|qq|quotemeta|qw|rand|read|readdir|readlink|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|stty|study|sub|substr|symlink|syscall|sysopen|sysread|system|syswritetell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unless|unlink|until|unpack|unshift|untie|use|utime|values|vec|waitpid|wantarray|warn|while|write)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' } // comments +] + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/php.css b/htdocs/includes/codepress/languages/php.css new file mode 100644 index 00000000000..23fca5c7f23 --- /dev/null +++ b/htdocs/includes/codepress/languages/php.css @@ -0,0 +1,12 @@ +/* + * CodePress color styles for PHP syntax highlighting + */ + +b {color:#000080;} /* tags */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {color:gray;font-weight:normal;} /* comments */ +s, s b, strong s u, strong s cite {color:#5656fa;font-weight:normal;} /* attributes and strings */ +strong a, strong a u {color:#006700;font-weight:bold;} /* variables */ +em {color:#800080;font-style:normal;} /* style */ +ins {color:#800000;} /* script */ +strong u {color:#7F0055;font-weight:bold;} /* reserved words */ +cite, s cite {color:red;font-weight:bold;} /* */ diff --git a/htdocs/includes/codepress/languages/php.js b/htdocs/includes/codepress/languages/php.js new file mode 100644 index 00000000000..1689fbae44e --- /dev/null +++ b/htdocs/includes/codepress/languages/php.js @@ -0,0 +1,61 @@ +/* + * CodePress regular expressions for PHP syntax highlighting + */ + +// PHP +Language.syntax = [ + { input : /(<[^!\?]*?>)/g, output : '$1' }, // all tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, // style tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, // script tags + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, // strings single quote + { input : /(<\?)/g, output : '$1' }, // ' }, // .*?> + { input : /(<\?php|<\?=|<\?|\?>)/g, output : '$1' }, // php tags + { input : /(\$[\w\.]*)/g, output : '$1' }, // vars + { input : /\b(false|true|and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|for|foreach|function|global|if|include|include_once|isset|list|new|print|require|require_once|return|static|switch|unset|use|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interface|implements|extends|public|private|protected|abstract|clone|try|catch|throw|this)\b/g, output : '$1' }, // reserved words + { input : /([^:])\/\/(.*?)(//$2$3' }, // php comments // + { input : /([^:])#(.*?)(#$2$3' }, // php comments # + { input : /\/\*(.*?)\*\//g, output : '/*$1*/' }, // php comments /* */ + { input : /(<!--.*?-->.)/g, output : '$1' } // html comments +] + +Language.snippets = [ + { input : 'if', output : 'if($0){\n\t\n}' }, + { input : 'ifelse', output : 'if($0){\n\t\n}\nelse{\n\t\n}' }, + { input : 'else', output : '}\nelse {\n\t' }, + { input : 'elseif', output : '}\nelseif($0) {\n\t' }, + { input : 'do', output : 'do{\n\t$0\n}\nwhile();' }, + { input : 'inc', output : 'include_once("$0");' }, + { input : 'fun', output : 'function $0(){\n\t\n}' }, + { input : 'func', output : 'function $0(){\n\t\n}' }, + { input : 'while', output : 'while($0){\n\t\n}' }, + { input : 'for', output : 'for($0,,){\n\t\n}' }, + { input : 'fore', output : 'foreach($0 as ){\n\t\n}' }, + { input : 'foreach', output : 'foreach($0 as ){\n\t\n}' }, + { input : 'echo', output : 'echo \'$0\';' }, + { input : 'switch', output : 'switch($0) {\n\tcase "": break;\n\tdefault: ;\n}' }, + { input : 'case', output : 'case "$0" : break;' }, + { input : 'ret0', output : 'return false;' }, + { input : 'retf', output : 'return false;' }, + { input : 'ret1', output : 'return true;' }, + { input : 'rett', output : 'return true;' }, + { input : 'ret', output : 'return $0;' }, + { input : 'def', output : 'define(\'$0\',\'\');' }, + { input : '' } +] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/ruby.css b/htdocs/includes/codepress/languages/ruby.css new file mode 100644 index 00000000000..edb9028dbbf --- /dev/null +++ b/htdocs/includes/codepress/languages/ruby.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for Ruby syntax highlighting + */ + +b {color:#7F0055;font-weight:bold;} /* reserved words */ +i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */ +s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */ +a {color:#006700;font-weight:bold;} /* variables */ +em {color:darkblue;font-weight:bold;} /* functions */ +u {font-weight:bold;} /* special chars */ \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/ruby.js b/htdocs/includes/codepress/languages/ruby.js new file mode 100644 index 00000000000..207f23b0043 --- /dev/null +++ b/htdocs/includes/codepress/languages/ruby.js @@ -0,0 +1,26 @@ +/* + * CodePress regular expressions for Perl syntax highlighting + */ + +// Ruby +Language.syntax = [ + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, // strings double quote + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2' }, // strings single quote + { input : /([\$\@\%]+)([\w\.]*)/g, output : '$1$2' }, // vars + { input : /(def\s+)([\w\.]*)/g, output : '$1$2' }, // functions + { input : /\b(alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b/g, output : '$1' }, // reserved words + { input : /([\(\){}])/g, output : '$1' }, // special chars + { input : /#(.*?)(
|<\/P>)/g, output : '#$1$2' } // comments +]; + +Language.snippets = [] + +Language.complete = [ + { input : '\'',output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/sql.css b/htdocs/includes/codepress/languages/sql.css new file mode 100644 index 00000000000..92c4b96dc77 --- /dev/null +++ b/htdocs/includes/codepress/languages/sql.css @@ -0,0 +1,10 @@ +/* + * CodePress color styles for SQL syntax highlighting + * By Merlin Moncure + */ + +b {color:#0000FF;font-style:normal;font-weight:bold;} /* reserved words */ +u {color:#FF0000;font-style:normal;} /* types */ +a {color:#CD6600;font-style:normal;font-weight:bold;} /* commands */ +i, i b, i u, i a, i s {color:#A9A9A9;font-weight:normal;font-style:italic;} /* comments */ +s, s b, s u, s a, s i {color:#2A00FF;font-weight:normal;} /* strings */ diff --git a/htdocs/includes/codepress/languages/sql.js b/htdocs/includes/codepress/languages/sql.js new file mode 100644 index 00000000000..1d4a21f82f9 --- /dev/null +++ b/htdocs/includes/codepress/languages/sql.js @@ -0,0 +1,30 @@ +/* + * CodePress regular expressions for SQL syntax highlighting + * By Merlin Moncure + */ + +// SQL +Language.syntax = [ + { input : /\'(.*?)(\')/g, output : '\'$1$2' }, // strings single quote + { input : /\b(add|after|aggregate|alias|all|and|as|authorization|between|by|cascade|cache|cache|called|case|check|column|comment|constraint|createdb|createuser|cycle|database|default|deferrable|deferred|diagnostics|distinct|domain|each|else|elseif|elsif|encrypted|except|exception|for|foreign|from|from|full|function|get|group|having|if|immediate|immutable|in|increment|initially|increment|index|inherits|inner|input|intersect|into|invoker|is|join|key|language|left|like|limit|local|loop|match|maxvalue|minvalue|natural|nextval|no|nocreatedb|nocreateuser|not|null|of|offset|oids|on|only|operator|or|order|outer|owner|partial|password|perform|plpgsql|primary|record|references|replace|restrict|return|returns|right|row|rule|schema|security|sequence|session|sql|stable|statistics|table|temp|temporary|then|time|to|transaction|trigger|type|unencrypted|union|unique|user|using|valid|value|values|view|volatile|when|where|with|without|zone)\b/gi, output : '$1' }, // reserved words + { input : /\b(bigint|bigserial|bit|boolean|box|bytea|char|character|cidr|circle|date|decimal|double|float4|float8|inet|int2|int4|int8|integer|interval|line|lseg|macaddr|money|numeric|oid|path|point|polygon|precision|real|refcursor|serial|serial4|serial8|smallint|text|timestamp|varbit|varchar)\b/gi, output : '$1' }, // types + { input : /\b(abort|alter|analyze|begin|checkpoint|close|cluster|comment|commit|copy|create|deallocate|declare|delete|drop|end|execute|explain|fetch|grant|insert|listen|load|lock|move|notify|prepare|reindex|reset|restart|revoke|rollback|select|set|show|start|truncate|unlisten|update)\b/gi, output : '$1' }, // commands + { input : /([^:]|^)\-\-(.*?)(--$2$3' } // comments // +] + +Language.snippets = [ + { input : 'select', output : 'select $0 from where ' } +] + +Language.complete = [ + { input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [] + + + diff --git a/htdocs/includes/codepress/languages/text.css b/htdocs/includes/codepress/languages/text.css new file mode 100644 index 00000000000..474fe60c097 --- /dev/null +++ b/htdocs/includes/codepress/languages/text.css @@ -0,0 +1,5 @@ +/* + * CodePress color styles for Text syntax highlighting + */ + +/* do nothing as expected */ diff --git a/htdocs/includes/codepress/languages/text.js b/htdocs/includes/codepress/languages/text.js new file mode 100644 index 00000000000..6534aafa588 --- /dev/null +++ b/htdocs/includes/codepress/languages/text.js @@ -0,0 +1,9 @@ +/* + * CodePress regular expressions for Text syntax highlighting + */ + +// plain text +Language.syntax = [] +Language.snippets = [] +Language.complete = [] +Language.shortcuts = [] diff --git a/htdocs/includes/codepress/languages/vbscript.css b/htdocs/includes/codepress/languages/vbscript.css new file mode 100644 index 00000000000..e1465e90fea --- /dev/null +++ b/htdocs/includes/codepress/languages/vbscript.css @@ -0,0 +1,71 @@ +/* + * CodePress color styles for ASP-VB syntax highlighting + * By Martin D. Kirk + */ + +/* tags */ +b { + color:#000080; +} +/* comments */ +big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u { + color:gray; + font-weight:normal; +} +/* ASP comments */ +strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{ + color:gray; + font-weight:normal; +} + /* attributes */ +s, s b, span s u, span s cite, strong span s { + color:#5656fa ; + font-weight:normal; +} + /* strings */ +strong s,strong s b, strong s u, strong s cite { + color:#009900; + font-weight:normal; +} +strong ins{ + color:#000000; + font-weight:bold; +} + /* Syntax */ +strong a, strong a u { + color:#0000FF; + font-weight:; +} + /* Native Keywords */ +strong u { + color:#990099; + font-weight:bold; +} +/* Numbers */ +strong var{ + color:#FF0000; +} +/* ASP Language */ +span{ + color:#990000; + font-weight:bold; +} +strong i,strong a i, strong u i { + color:#009999; +} +/* style */ +em { + color:#800080; + font-style:normal; +} + /* script */ +ins { + color:#800000; + font-weight:bold; +} + +/* */ +cite, s cite { + color:red; + font-weight:bold; +} \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/vbscript.js b/htdocs/includes/codepress/languages/vbscript.js new file mode 100644 index 00000000000..21e78dd887c --- /dev/null +++ b/htdocs/includes/codepress/languages/vbscript.js @@ -0,0 +1,117 @@ +/* + * CodePress regular expressions for ASP-vbscript syntax highlighting + */ + +// ASP VBScript +Language.syntax = [ +// all tags + { input : /(<[^!%|!%@]*?>)/g, output : '$1' }, +// style tags + { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '$1$2$3' }, +// script tags + { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '$1$2$3' }, +// strings "" and attributes + { input : /\"(.*?)(\"|
|<\/P>)/g, output : '"$1$2' }, +// ASP Comment + { input : /\'(.*?)(\'|
|<\/P>)/g, output : '\'$1$2'}, +// <%.* + { input : /(<%)/g, output : '$1' }, +// .*%> + { input : /(%>)/g, output : '$1' }, +// <%@...%> + { input : /(<%@)(.+?)(%>)/gi, output : '$1$2$3' }, +//Numbers + { input : /\b([\d]+)\b/g, output : '$1' }, +// Reserved Words 1 (Blue) + { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '$1' }, + { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '$1' }, + { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '$1' }, +// Reserved Words 2 (Purple) + { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '$1' }, + { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '$1' }, + { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '$1' }, + { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '$1' }, + { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '$1' }, + { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '$1' }, + { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '$1' }, + { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '$1' }, + { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '$1' }, + { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '$1' }, + { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '$1' }, + { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '$1' }, + { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '$1' }, + { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '$1' }, + { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '$1' }, + { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '$1' }, +// Reserved Words 3 (Turquis) + { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '$1' }, + { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '$1' }, + { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '$1' }, + { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '$1' }, + { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '$1' }, + { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '$1' }, +// html comments + { input : /(<!--.*?-->.)/g, output : '$1' } +] + +Language.Functions = [ + // Output at index 0, must be the desired tagname surrounding a $1 + // Name is the index from the regex that marks the functionname + {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '$1', name : '$3'} +] + +Language.snippets = [ +//Conditional + { input : 'if', output : 'If $0 Then\n\t\nEnd If' }, + { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' }, + { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'}, +//Response + { input : 'rw', output : 'Response.Write( $0 )' }, + { input : 'resc', output : 'Response.Cookies( $0 )' }, + { input : 'resb', output : 'Response.Buffer'}, + { input : 'resflu', output : 'Response.Flush()'}, + { input : 'resend', output : 'Response.End'}, +//Request + { input : 'reqc', output : 'Request.Cookies( $0 )' }, + { input : 'rq', output : 'Request.Querystring("$0")' }, + { input : 'rf', output : 'Request.Form("$0")' }, +//FSO + { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' }, + { input : 'setfo', output : 'Set fo = fso.getFolder($0)' }, + { input : 'setfi', output : 'Set fi = fso.getFile($0)' }, + { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'}, + { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'}, +//Server + { input : 'mapp', output : 'Server.Mappath($0)' }, +//Loops + { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' }, + { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' }, + { input : 'do', output : 'Do While($0)\n\t\nLoop' }, + { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' }, +//ADO + { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' }, + { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' }, + { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' }, +//Http Request + { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' }, + { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'}, +//Functions + { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'}, + { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'} + +] + +Language.complete = [ + //{ input : '\'', output : '\'$0\'' }, + { input : '"', output : '"$0"' }, + { input : '(', output : '\($0\)' }, + { input : '[', output : '\[$0\]' }, + { input : '{', output : '{\n\t$0\n}' } +] + +Language.shortcuts = [ + { input : '[space]', output : ' ' }, + { input : '[enter]', output : '
' } , + { input : '[j]', output : 'testing' }, + { input : '[7]', output : '&' } +] \ No newline at end of file diff --git a/htdocs/includes/codepress/languages/xsl.css b/htdocs/includes/codepress/languages/xsl.css new file mode 100644 index 00000000000..385eaaba1f9 --- /dev/null +++ b/htdocs/includes/codepress/languages/xsl.css @@ -0,0 +1,15 @@ +/* + * CodePress color styles for HTML syntax highlighting + * By RJ Bruneel + */ + +b {color:#000080;} /* tags */ +ins, ins b, ins s, ins em {color:gray;} /* comments */ +s, s b {color:#7777e4;} /* attribute values */ +a {color:#E67300;} /* links */ +u {color:#CC66CC;} /* forms */ +big {color:#db0000;} /* images */ +em, em b {color:#800080;} /* style */ +strong {color:#800000;} /* script */ +tt i {color:darkblue;font-weight:bold;} /* script reserved words */ +xsl {color:green;} /* xsl */ diff --git a/htdocs/includes/codepress/languages/xsl.js b/htdocs/includes/codepress/languages/xsl.js new file mode 100644 index 00000000000..e93932a6325 --- /dev/null +++ b/htdocs/includes/codepress/languages/xsl.js @@ -0,0 +1,103 @@ +/* + * CodePress regular expressions for XSL syntax highlighting + * By RJ Bruneel + */ + +Language.syntax = [ // XSL + { + input : /(<[^!]*?>)/g, + output : '$1' // all tags + },{ + input : /(<a.*?>|<\/a>)/g, + output : '$1' // links + },{ + input : /(<img .*?>)/g, + output : '$1' // images + },{ + input : /(<\/?(button|textarea|form|input|select|option|label).*?>)/g, + output : '$1' // forms + },{ + input : /(<style.*?>)(.*?)(<\/style>)/g, + output : '$1$2$3' // style tags + },{ + input : /(<script.*?>)(.*?)(<\/script>)/g, + output : '$1$2$3' // script tags + },{ + input : /(<xsl.*?>|<\/xsl.*?>)/g, + output : '$1' // xsl + },{ + input : /=(".*?")/g, + output : '=$1' // atributes double quote + },{ + input : /=('.*?')/g, + output : '=$1' // atributes single quote + },{ + input : /(<!--.*?-->.)/g, + output : '$1' // comments + },{ + input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, + output : '$1' // script reserved words + } +]; + +Language.snippets = [ + {input : 'aref', output : '' }, + {input : 'h1', output : '

$0

' }, + {input : 'h2', output : '

$0

' }, + {input : 'h3', output : '

$0

' }, + {input : 'h4', output : '

$0

' }, + {input : 'h5', output : '
$0
' }, + {input : 'h6', output : '
$0
' }, + {input : 'html', output : '\n\t$0\n' }, + {input : 'head', output : '\n\t\n\t$0\n\t\n' }, + {input : 'img', output : '' }, + {input : 'input', output : '' }, + {input : 'label', output : '' }, + {input : 'legend', output : '\n\t$0\n' }, + {input : 'link', output : '' }, + {input : 'base', output : '' }, + {input : 'body', output : '\n\t$0\n' }, + {input : 'css', output : '' }, + {input : 'div', output : '
\n\t$0\n
' }, + {input : 'divid', output : '
\n\t\n
' }, + {input : 'dl', output : '
\n\t
\n\t\t$0\n\t
\n\t
\n
' }, + {input : 'fieldset', output : '
\n\t$0\n
' }, + {input : 'form', output : '
\n\t\n
' }, + {input : 'meta', output : '' }, + {input : 'p', output : '

$0

' }, + {input : 'b', output : '$0' }, + {input : 'li', output : '
  • $0
  • ' }, + {input : 'ul', output : '
      $0
    ' }, + {input : 'ol', output : '
      $0
    ' }, + {input : 'strong', output : '$0' }, + {input : 'br', output : '
    ' }, + {input : 'script', output : '' }, + {input : 'scriptsrc', output : '' }, + {input : 'span', output : '$0' }, + {input : 'table', output : '\n\t\n\t\n
    ' }, + {input : 'style', output : '' }, + {input : 'xsl:stylesheet', output : '' }, + {input : 'xsl:template', output : '$0' }, + {input : 'xsl:for-each', output : '' }, + {input : 'xsl:choose', output : '$0<\xsl:choose>' }, + {input : 'xsl:param', output : '' }, + {input : 'xsl:variable', output : '' }, + {input : 'xsl:if', output : '' }, + {input : 'xsl:when', output : '' }, + {input : 'xsl:otherwise', output : '$0' }, + {input : 'xsl:attribute', output : '' }, + {input : 'xsl:value-of', output : '' }, + {input : 'xsl:with-param', output : '' }, + {input : 'xsl:call-template', output : '' } + +]; + +Language.complete = [ // Auto complete only for 1 character + {input : '\'',output : '\'$0\'' }, + {input : '"', output : '"$0"' }, + {input : '(', output : '\($0\)' }, + {input : '[', output : '\[$0\]' }, + {input : '{', output : '{\n\t$0\n}' } +]; + +Language.shortcuts = []; \ No newline at end of file diff --git a/htdocs/includes/codepress/license.txt b/htdocs/includes/codepress/license.txt new file mode 100644 index 00000000000..e80ac68d8fa --- /dev/null +++ b/htdocs/includes/codepress/license.txt @@ -0,0 +1,458 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/htdocs/index.php b/htdocs/index.php index 90c014b0e99..187273ef2b4 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -333,7 +333,7 @@ if (empty($user->societe_id)) $boxstat.=''; $boxstat.='
    '; $boxstat.=''.img_object("",$icons[$key]).' '.$text.'
    '; - $boxstat.=''.$board->nb[$val].''; + $boxstat.=''.($board->nb[$val]?$board->nb[$val]:0).''; $boxstat.='
    '; $boxstat.='
    '; } diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 1bcc6fadaff..ebf1de7f552 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -412,7 +412,8 @@ else array('from'=>'3.8.0', 'to'=>'3.9.0'), array('from'=>'3.9.0', 'to'=>'4.0.0'), array('from'=>'4.0.0', 'to'=>'5.0.0'), - array('from'=>'5.0.0', 'to'=>'6.0.0') + array('from'=>'5.0.0', 'to'=>'6.0.0'), + array('from'=>'6.0.0', 'to'=>'7.0.0') ); $count=0; diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index be358744d07..86421894fec 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -135,7 +135,7 @@ CREATE TABLE llx_product_lot_extrafields ALTER TABLE llx_product_lot_extrafields ADD INDEX idx_product_lot_extrafields (fk_object); -ALTER TABLE llx_website_page MODIFY content MEDIUMTEXT; +ALTER TABLE llx_website_page MODIFY COLUMN content MEDIUMTEXT; CREATE TABLE llx_product_warehouse_properties ( @@ -161,7 +161,7 @@ ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (accou ALTER TABLE llx_expensereport_det ADD COLUMN fk_code_ventilation integer DEFAULT 0; -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; +ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr tinyint; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; @@ -174,11 +174,10 @@ ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT ALTER TABLE llx_supplier_proposaldet ADD COLUMN fk_unit integer DEFAULT NULL; ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; +ALTER TABLE llx_c_payment_term CHANGE COLUMN fdm type_cdr TINYINT; ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT 0; - create table llx_resource_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -207,6 +206,8 @@ ALTER TABLE llx_overwrite_trans ADD COLUMN entity integer DEFAULT 1 NOT NULL AFT ALTER TABLE llx_mailing_cibles ADD COLUMN error_text varchar(255); ALTER TABLE llx_c_actioncomm MODIFY COLUMN type varchar(50) DEFAULT 'system' NOT NULL; +-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET DEFAULT 'system'; +-- VPGSQL8.2 ALTER TABLE llx_c_actioncomm ALTER COLUMN type SET NOT NULL; create table llx_user_employment ( @@ -241,12 +242,12 @@ ALTER TABLE llx_expensereport ADD INDEX idx_expensereport_fk_refuse (fk_user_app DELETE FROM llx_actioncomm_resources WHERE fk_actioncomm not in (select id from llx_actioncomm); -- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate. -drop table tmp_links_double; +DROP TABLE tmp_links_double; --select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2; -create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2); +CREATE TABLE tmp_links_double AS (SELECT objectid, label, MAX(rowid) AS max_rowid, COUNT(rowid) AS count_rowid FROM llx_links WHERE label IS NOT NULL GROUP BY objectid, label HAVING COUNT(rowid) >= 2); --select * from tmp_links_double; -delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_links_double); --update to avoid duplicate, delete to delete -drop table tmp_links_double; +DELETE FROM llx_links WHERE (rowid, label) IN (SELECT max_rowid, label FROM tmp_links_double); --update to avoid duplicate, delete to delete +DROP TABLE tmp_links_double; ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid,label); @@ -257,8 +258,7 @@ ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity); ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer; - -UPDATE llx_accounting_account set account_parent = 0 where account_parent = ''; +UPDATE llx_accounting_account SET account_parent = 0 WHERE account_parent = ''; -- VMYSQL4.3 ALTER TABLE llx_product_price MODIFY COLUMN date_price DATETIME NULL; -- VPGSQL8.2 ALTER TABLE llx_product_price ALTER COLUMN date_price DROP NOT NULL; @@ -269,10 +269,8 @@ ALTER TABLE llx_product_customer_price ADD COLUMN default_vat_code varchar(10) a ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10) after tva_tx; ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10) after tva_tx; - ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); - UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 75f4053ad42..e0e572ba4d2 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -28,6 +28,7 @@ ALTER TABLE llx_supplier_proposaldet CHANGE COLUMN fk_askpricesupplier fk_supplier_proposal integer NOT NULL; -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- -- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN datefin datetime DEFAULT '2001-01-01 00:00:00'; -- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL; -- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; -- VMYSQL4.1 update llx_adherent set datefin = NULL where DATE(STR_TO_DATE(datefin, '%Y-%m-%d')) IS NULL; @@ -74,7 +75,7 @@ ALTER TABLE llx_holiday ADD COLUMN ref varchar(30) NULL; ALTER TABLE llx_holiday ADD COLUMN ref_ext varchar(255); -create table llx_notify_def_object +CREATE TABLE llx_notify_def_object ( id integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id @@ -121,6 +122,8 @@ ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_bank ADD COLUMN numero_compte varchar(32) NULL; + -- VMYSQL4.1 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer; @@ -129,14 +132,15 @@ ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); -- VMYSQL4.1 ALTER TABLE llx_adherent MODIFY COLUMN country integer DEFAULT NULL; -- VPGSQL8.2 ALTER TABLE llx_adherent MODIFY COLUMN country integer USING country::integer; -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expense_report',201); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expense_report',202); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expense_report',203); +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expense_report',204); ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text; @@ -156,6 +160,8 @@ ALTER TABLE llx_product_price_by_qty ADD COLUMN import_key varchar(14); ALTER TABLE llx_user ADD COLUMN import_key varchar(14); +ALTER TABLE llx_facture_rec ADD COLUMN tms timestamp; +UPDATE llx_facture_rec SET tms = datec where tms < '2000-01-01'; CREATE TABLE llx_product_attribute ( @@ -196,7 +202,7 @@ CREATE TABLE llx_product_attribute_combination ); -ALTER TABLE llx_bank_account drop foreign key bank_fk_accountancy_journal; +ALTER TABLE llx_bank_account DROP FOREIGN KEY bank_fk_accountancy_journal; -- Fix missing entity column after init demo ALTER TABLE llx_accounting_journal ADD COLUMN entity integer DEFAULT 1; @@ -209,18 +215,18 @@ INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES ( INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (5,'AN', 'Has new journal', 9, 1); INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (6,'ER', 'Expense report journal', 5, 1); -- Fix old entries -UPDATE llx_accounting_journal SET nature = 1 where code = 'OD' and nature = 0; -UPDATE llx_accounting_journal SET nature = 2 where code = 'VT' and nature = 1; -UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; -UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; +UPDATE llx_accounting_journal SET nature = 1 WHERE code = 'OD' AND nature = 0; +UPDATE llx_accounting_journal SET nature = 2 WHERE code = 'VT' AND nature = 1; +UPDATE llx_accounting_journal SET nature = 3 WHERE code = 'AC' AND nature = 2; +UPDATE llx_accounting_journal SET nature = 4 WHERE (code = 'BK' OR code = 'BQ') AND nature = 3; -UPDATE llx_bank_account as ba set accountancy_journal = 'BQ' where accountancy_journal = 'BK'; -UPDATE llx_bank_account as ba set accountancy_journal = 'OD' where accountancy_journal IS NULL; +UPDATE llx_bank_account SET accountancy_journal = 'BQ' WHERE accountancy_journal = 'BK'; +UPDATE llx_bank_account SET accountancy_journal = 'OD' WHERE accountancy_journal IS NULL; ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); -UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal as aj where ba.accountancy_journal = aj.code) where accountancy_journal not in ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization @@ -233,7 +239,7 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_account varchar(32); ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN thirdparty_label subledger_label varchar(255); -- If field was already created, rename it ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_label varchar(255) AFTER subledger_account; -- If field dod not exists yet -update llx_accounting_bookkeeping set subledger_account = numero_compte where subledger_account IS NULL; +UPDATE llx_accounting_bookkeeping SET subledger_account = numero_compte WHERE subledger_account IS NULL; ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN label_compte varchar(255); ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_journal varchar(32); @@ -358,9 +364,9 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; -UPDATE llx_contrat set ref = rowid where ref is null or ref = ''; +UPDATE llx_contrat SET ref = rowid WHERE ref IS NULL OR ref = ''; -create table llx_payment_various +CREATE TABLE llx_payment_various ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -381,7 +387,7 @@ create table llx_payment_various )ENGINE=innodb; -create table llx_default_values +CREATE TABLE llx_default_values ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id @@ -441,27 +447,27 @@ ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); -insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) VALUES (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) VALUES (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) VALUES (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +INSERT INTO llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) VALUES (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer; -DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); +DELETE FROM llx_c_actioncomm WHERE code IN ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); -- Fix: delete orphelin category. -delete from llx_categorie_product where fk_categorie not in (select rowid from llx_categorie where type = 0); -delete from llx_categorie_societe where fk_categorie not in (select rowid from llx_categorie where type in (1, 2)); -delete from llx_categorie_member where fk_categorie not in (select rowid from llx_categorie where type = 3); -delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4); -delete from llx_categorie_project where fk_categorie not in (select rowid from llx_categorie where type = 5); +DELETE FROM llx_categorie_product WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 0); +DELETE FROM llx_categorie_societe WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type IN (1, 2)); +DELETE FROM llx_categorie_member WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 3); +DELETE FROM llx_categorie_contact WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 4); +DELETE FROM llx_categorie_project WHERE fk_categorie NOT IN (SELECT rowid FROM llx_categorie WHERE type = 5); ALTER TABLE llx_inventory ADD COLUMN ref varchar(48); -create table llx_loan_schedule +CREATE TABLE llx_loan_schedule ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_loan integer, @@ -495,6 +501,34 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup; ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); +-- For new module website + +CREATE TABLE llx_website_page +( + rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + fk_website integer NOT NULL, + pageurl varchar(16) NOT NULL, + title varchar(255), + description varchar(255), + keywords varchar(255), + content mediumtext, -- text is not enough in size + status integer, + fk_user_create integer, + fk_user_modif integer, + date_creation datetime, + tms timestamp +) ENGINE=innodb; + +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pageurl); + +ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); + + +UPDATE llx_extrafields set elementtype='categorie' where elementtype='categories'; + + +-- For new module blockedlog + CREATE TABLE llx_blockedlog ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -534,6 +568,9 @@ ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; +UPDATE llx_bank SET label= '(payment_salary)' WHERE label LIKE 'Règlement salaire'; + +ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(255); ALTER TABLE llx_c_paiement DROP PRIMARY KEY; ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql new file mode 100644 index 00000000000..ac0741cd80a --- /dev/null +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -0,0 +1,31 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 6.0.0 or higher. +-- +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); +-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + + +ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL; +ALTER TABLE llx_facture_fourn ADD COLUMN date_valid date; + + diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index f67869f67ba..f2e5066a066 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -330,7 +330,7 @@ drop table tmp_c_shipment_mode; -- Restore id of user on link for payment of expense report drop table tmp_bank_url_expense_user; create table tmp_bank_url_expense_user (select e.fk_user_author, bu2.fk_bank from llx_expensereport as e, llx_bank_url as bu2 where bu2.url_id = e.rowid and bu2.type = 'payment_expensereport'); -update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_url_expense_user as e where e.fk_bank = bu.fk_bank) where bu.url_id = 0 and bu.type ='user'; +update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_url_expense_user as e where e.fk_bank = bu.fk_bank) where (bu.url_id = 0 OR bu.url_id IS NULL) and bu.type ='user'; drop table tmp_bank_url_expense_user; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql index 1fc77301528..8e921a9964c 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.key.sql @@ -20,3 +20,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_doc_ ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte); ALTER TABLE llx_accounting_bookkeeping ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal); + +-- TODO Add a key for unicity \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_bank.sql b/htdocs/install/mysql/tables/llx_bank.sql index 5ea55b146bd..6c2c8d34537 100644 --- a/htdocs/install/mysql/tables/llx_bank.sql +++ b/htdocs/install/mysql/tables/llx_bank.sql @@ -32,6 +32,7 @@ create table llx_bank fk_type varchar(6), -- TIP,VIR,PRE,CB,CHQ,... (Code in llx_c_paiement) num_releve varchar(50), num_chq varchar(50), + numero_compte varchar(32) NULL, -- FEC:CompteNum | account number rappro tinyint default 0, note text, fk_bordereau integer DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index 2517f17ad96..1b7d0a11e1a 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -33,6 +33,8 @@ create table llx_facture_fourn datec datetime, -- date de creation de la facture datef date, -- date de la facture + date_pointoftax date DEFAULT NULL, -- date point of tax (for GB) + date_valid date, -- date validation tms timestamp, -- date creation/modification libelle varchar(255), paye smallint DEFAULT 0 NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index 0e25100386b..e9764e1e575 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -25,7 +25,8 @@ create table llx_facture_rec titre varchar(50) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id fk_soc integer NOT NULL, - datec datetime, -- date de creation + datec datetime, -- date de creation + tms timestamp, -- date creation/modification amount double(24,8) DEFAULT 0 NOT NULL, remise real DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.sql index f3031069220..c533eb0ff8a 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.sql @@ -30,7 +30,7 @@ create table llx_mailing_cibles other varchar(255) NULL, tag varchar(128) NULL, statut smallint NOT NULL DEFAULT 0, -- -1 = error, 0 = not sent, ... - source_url varchar(160), + source_url varchar(255), source_id integer, source_type varchar(16), date_envoi datetime, diff --git a/htdocs/install/mysql/tables/llx_website_pages.key.sql b/htdocs/install/mysql/tables/llx_website_page.key.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_website_pages.key.sql rename to htdocs/install/mysql/tables/llx_website_page.key.sql index 095dffabc95..14488e588dc 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.key.sql +++ b/htdocs/install/mysql/tables/llx_website_page.key.sql @@ -16,7 +16,7 @@ -- -- =========================================================================== -ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pageurl); +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website, pageurl); ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_page.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_website_pages.sql rename to htdocs/install/mysql/tables/llx_website_page.sql diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 1b2d184de0f..2e4125e39e4 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -102,6 +102,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_expedition FOR EACH CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_expensereport FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture_rec FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture_fourn FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_facture_fourn_det_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index a0fdc22a015..a8d17388d41 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -345,11 +345,14 @@ if (! $error && $db->connected) if (! $error && $db->connected && $action == "set") { umask(0); - foreach($_POST as $key => $value) + if (is_array($_POST)) { - if (! preg_match('/^db_pass/i', $key)) { - dolibarr_install_syslog("step1: choice for " . $key . " = " . $value); - } + foreach($_POST as $key => $value) + { + if (! preg_match('/^db_pass/i', $key)) { + dolibarr_install_syslog("step1: choice for " . $key . " = " . $value); + } + } } // Show title of step diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 859fe1cca12..e200f0ca7c0 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -28,7 +28,14 @@ OverviewOfAmountOfLinesBound=Overview of amount of lines already bound to accoun OtherInfo=Other information DeleteCptCategory=Remove accounting account from group ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group ? +JournalizationInLedgerStatus=Status of journalization AlreadyInGeneralLedger=Already journalized in ledgers +NotYetInGeneralLedger=Not yet journalized in ledgers + +MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup +MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup +MainAccountForUsersNotDefined=Main accounting account for users not defined in setup +MainAccountForVatPaymentNotDefined=Main accounting account for VAT payment not defined in setup AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: @@ -45,7 +52,7 @@ AccountancyAreaDescExpenseReport=STEP %s: Define default accounting accounts for AccountancyAreaDescSal=STEP %s: Define default accounting accounts for payment of salaries. For this, use the menu entry %s. AccountancyAreaDescContrib=STEP %s: Define default accounting accounts for special expences (miscellaneous taxes). For this, use the menu entry %s. AccountancyAreaDescDonation=STEP %s: Define default accounting accounts for donation. For this, use the menu entry %s. -AccountancyAreaDescMisc=STEP %s: Define default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. +AccountancyAreaDescMisc=STEP %s: Define mandatory default account and default accounting accounts for miscellaneous transactions. For this, use the menu entry %s. AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. For this, use the menu entry %s. AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. @@ -83,7 +90,7 @@ ValidTransaction=Validate transaction WriteBookKeeping=Journalize transactions in Ledger Bookkeeping=Ledger AccountBalance=Account balance - +ObjectsRef=Source object ref CAHTF=Total purchase supplier before tax TotalExpenseReport=Total expense report InvoiceLines=Lines of invoices to bind @@ -103,7 +110,7 @@ LineOfExpenseReport=Line of expense report NoAccountSelected=No accounting account selected VentilatedinAccount=Binded successfully to the accounting account NotVentilatedinAccount=Not bound to the accounting account -XLineSuccessfullyBinded=%s products/services successfuly bound to an accounting account +XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended : 50) @@ -154,7 +161,7 @@ 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 -DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger. +DescJournalOnlyBindedVisible=This is a view of record that are bound to accountancy account and can be recorded into the Ledger. VATAccountNotDefined=Account for VAT not defined ThirdpartyAccountNotDefined=Account for third party not defined ProductAccountNotDefined=Account for product not defined @@ -170,6 +177,8 @@ AddCompteFromBK=Add accounting accounts to the group ReportThirdParty=List third party account DescThirdPartyReport=Consult here the list of the third party customers and suppliers and their accounting accounts ListAccounts=List of the accounting accounts +UnknownAccountForThirdparty=Unknown third party account. We will use %s +UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error Pcgtype=Class of account Pcgsubtype=Subclass of account @@ -194,7 +203,7 @@ ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used -MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s +MvtNotCorrectlyBalanced=Movement not correctly balanced. Credit = %s. Debit = %s FicheVentilation=Binding card GeneralLedgerIsWritten=Transactions are written in the Ledger GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be dispatched. If there is no other error message, this is probably because they were already dispatched. diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5d25e654a06..a4de6f7470c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -140,13 +140,14 @@ SystemToolsArea=System tools area SystemToolsAreaDesc=This area provides administration features. Use the menu to choose the feature you're looking for. Purge=Purge PurgeAreaDesc=This page allows you to delete all files generated or stored by Dolibarr (temporary files or all files in %s directory). Using this feature is not necessary. It is provided as a workaround for users whose Dolibarr is hosted by a provider that does not offer permissions to delete files generated by the web server. -PurgeDeleteLogFile=Delete log file %s defined for Syslog module (no risk of losing data) +PurgeDeleteLogFile=Delete log files, including %s defined for Syslog module (no risk of losing data) PurgeDeleteTemporaryFiles=Delete all temporary files (no risk of losing data) PurgeDeleteTemporaryFilesShort=Delete temporary files PurgeDeleteAllFilesInDocumentsDir=Delete all files in directory %s. Temporary files but also database backup dumps, files attached to elements (third parties, invoices, ...) and uploaded into the ECM module will be deleted. PurgeRunNow=Purge now PurgeNothingToDelete=No directory or files to delete. PurgeNDirectoriesDeleted=%s files or directories deleted. +PurgeNDirectoriesFailed=Failed to delete %s files or directories. PurgeAuditEvents=Purge all security events ConfirmPurgeAuditEvents=Are you sure you want to purge all security events? All security logs will be deleted, no other data will be removed. GenerateBackup=Generate backup @@ -298,7 +299,7 @@ SetupIsReadyForUse=Module deployment is finished. You must however enable and se NotExistsDirect=The alternative root directory is not defined to an existing directory.
    InfDirAlt=Since version 3, it is possible to define an alternative root directory. This allows you to store, into a dedicated directory, plug-ins and custom templates.
    Just create a directory at the root of Dolibarr (eg: custom).
    InfDirExample=
    Then declare it in the file conf.php
    $dolibarr_main_url_root_alt='http://myserver/custom'
    $dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
    If these lines are commented with "#", to enable them, just uncomment by removing the "#" character. -YouCanSubmitFile=For this step, you can send package using this tool: Select module file +YouCanSubmitFile=For this step, you can submit your package file here : CurrentVersion=Dolibarr current version CallUpdatePage=Go to the page that updates the database structure and data: %s. LastStableVersion=Latest stable version @@ -583,7 +584,7 @@ Module50100Desc=Point of sales module (POS). Module50200Name=Paypal Module50200Desc=Module to offer an online payment page by credit card with Paypal Module50400Name=Accounting (advanced) -Module50400Desc=Accounting management (double entries) +Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers) Module54000Name=PrintIPP Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installe on server). Module55000Name=Poll, Survey or Vote @@ -749,8 +750,10 @@ Permission401=Read discounts Permission402=Create/modify discounts Permission403=Validate discounts Permission404=Delete discounts -Permission510=Read Salaries -Permission512=Create/modify salaries +Permission501=Read employee contracts/salaries +Permission502=Create/modify employee contracts/salaries +Permission511=Read payment of salaries +Permission512=Create/modify payment of salaries Permission514=Delete salaries Permission517=Export salaries Permission520=Read Loans diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 3c7f8b338c0..6e2f19f5f36 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -151,7 +151,7 @@ CheckRejectedAndInvoicesReopened=Check returned and invoices reopened BankAccountModelModule=Document templates for bank accounts DocumentModelSepaMandate=Template of SEPA mandate. Usefull for european countries in EEC only. DocumentModelBan=Template to print a page with BAN information. -NewVariousPayment=New various payment -VariousPayment=Various payment -VariousPayments=Various payments -ShowVariousPayment=Show various payment +NewVariousPayment=New miscellaneous payments +VariousPayment=Miscellaneous payments +VariousPayments=Miscellaneous payments +ShowVariousPayment=Show miscellaneous payments diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 6f8a1b5e301..79ad6cfd628 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -191,9 +191,9 @@ ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - V ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties -ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined +ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accouting account on third party is not defined. ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties -ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined +ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined. CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index ac982973ef3..bb6072ed295 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -194,6 +194,9 @@ ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. ErrorNoWarehouseDefined=Error, no warehouses defined. ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' for payment is defined, but value for 'ref' is not valid. ErrorTooManyErrorsProcessStopped=Too many errors. Process was stopped. +ErrorMassValidationNotAllowedWhenStockIncreaseOnAction=Mass validation is not possible when option to increase/decrease stock is set on this action (you must validate one by one so you can define the warehouse to increase/decrease) +ErrorObjectMustHaveStatusDraftToBeValidated=Object %s must have status 'Draft' to be validated. +ErrorObjectMustHaveLinesToBeValidated=Object %s must have lines to be validated. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a555478d333..f3e06a1f1a8 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -75,7 +75,8 @@ FileRenamed=The file was successfully renamed FileGenerated=The file was successfully generated FileSaved=The file was successfully saved FileUploaded=The file was successfully uploaded -FileTransferComplete=File(s) was uploaded successfuly +FileTransferComplete=File(s) was uploaded successfully +FilesDeleted=File(s) successfully deleted FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this. NbOfEntries=Nb of entries GoToWikiHelpPage=Read online help (Internet access needed) @@ -196,6 +197,7 @@ Parameter=Parameter Parameters=Parameters Value=Value PersonalValue=Personal value +NewObject=New %s NewValue=New value CurrentValue=Current value Code=Code @@ -736,6 +738,7 @@ ShowTransaction=Show entry on bank account GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. Deny=Deny Denied=Denied +ListOf=List of %s ListOfTemplates=List of templates Gender=Gender Genderman=Man diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 8fab0a7b07f..76a12a45c57 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -9,7 +9,8 @@ NewObject=New object ModuleKey=Module key ObjectKey=Object key ModuleInitialized=Module initialized -FilesForObjectInitialized=Files for new object initialized +FilesForObjectInitialized=Files for new object '%s' initialized +FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file) ModuleBuilderDescdescription=Enter here all general information that describe your module ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have on hand the rules to develop. Also this text content will be included into the generated documentation (see last tab). ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A sql file, a page to list them, to create/edit/view a card and an API will be generated. @@ -38,3 +39,9 @@ PathToModulePackage=Path to zip of module/application package PathToModuleDocumentation=Path to file of module/application documentation SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed. FileNotYetGenerated=File not yet generated +SpecificationFile=File with business rules +ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object. +NotNull=Not NULL +SearchAll=Used for 'search all' +DatabaseIndex=Database index +FileAlreadyExists=File %s already exists \ No newline at end of file diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index 222583c5516..c53c3aef460 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -4,7 +4,8 @@ ErrorAddRateFail=Error in added rate ErrorAddCurrencyFail=Error in added currency ErrorDeleteCurrencyFail=Error delete fail multicurrency_syncronize_error=Synchronisation error: %s -multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the new known rate) +MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE=Use date of document to find currency rate, instead of using latest known rate +multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the latest known rate) CurrencyLayerAccount=CurrencyLayer API CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality
    Get your API key
    If you use a free account you can't change the currency source (USD by default)
    But if your main currency isn't USD you can use the alternate currency source to force you main currency

    You are limited at 1000 synchronizations per month multicurrency_appId=API key diff --git a/htdocs/langs/en_US/salaries.lang b/htdocs/langs/en_US/salaries.lang index 522bf0a65d7..7e0c80d3380 100644 --- a/htdocs/langs/en_US/salaries.lang +++ b/htdocs/langs/en_US/salaries.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - salaries SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties -SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Dedicated accounting account defined on user card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated user accouting account on user is not defined +SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accouting account on user is not defined. SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses Salary=Salary Salaries=Salaries diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index abb7f7e56d3..cc2f31143ce 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_PAGENAME=Page name/alias +WEBSITE_HTML_HEADER=HTML Header WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content PageNameAliasHelp=Name or alias of the page.
    This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 7e22b2a3522..a477790b01b 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -2,14 +2,16 @@ WorkflowSetup=Workflow module setup WorkflowDesc=This module is designed to modify the behaviour of automatic actions into application. By default, workflow is open (you can do things in the order you want). You can activate the automatic actions you are interested in. ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules. -descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed -descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed +# Autocreate +descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a customer order after a commercial proposal is signed (new order will have same amount than proposal) +descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (new invoice will have same amount than proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated -descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a customer order is closed -descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer order is set to paid -descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid -descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated -descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated -descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source order to shipped when a shipment is validated and quantity shipped is the same as in order +descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a customer order is closed (new invoice will have same amount than order) +# Autoclassify +descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal(s) to billed when customer order is set to billed (and if amount of the order is same than total amount of signed linked proposals) +descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal(s) to billed when customer invoice is validated (and if amount of the invoice is same than total amount of signed linked proposals) +descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated (and if amount of the invoice is same than total amount of linked orders) +descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid (and if amount of the invoice is same than total amount of linked orders) +descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source order to shipped when a shipment is validated (and if quantity shipped by all shipments is the same as in the order to update) AutomaticCreation=Automatic creation AutomaticClassification=Automatic classification \ No newline at end of file diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index 3ce2c048057..0aa16b4225d 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -55,7 +55,7 @@ $filtre=GETPOST("filtre"); $optioncss = GETPOST('optioncss','alpha'); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index b5f88def445..1edc67d582f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1498,10 +1498,12 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a { $qs=dol_escape_htmltag($_SERVER["QUERY_STRING"]); - foreach($_POST as $key=>$value) { - if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value); - } - + if (is_array($_POST)) + { + foreach($_POST as $key=>$value) { + if ($key!=='action' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value); + } + } $qs.=(($qs && $morequerystring)?'&':'').$morequerystring; $text =''; //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"'); diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index ab6394eb74c..58fee8c3ea6 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -103,7 +103,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=''; $search_array_options=array(); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 2547b893055..7646aa1e3bd 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -24,6 +24,7 @@ if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); @@ -37,9 +38,10 @@ $cancel=GETPOST('cancel','alpha'); $module=GETPOST('module','alpha'); $tab=GETPOST('tab','aZ09'); $tabobj=GETPOST('tabobj','alpha'); +$propertykey=GETPOST('propertykey','alpha'); if (empty($module)) $module='initmodule'; if (empty($tab)) $tab='description'; -if (empty($tabobj)) $tabobj='newobject'; +if (empty($tabobj)) $tabobj='newobjectifnoobj'; $file=GETPOST('file','alpha'); $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha')); @@ -57,6 +59,13 @@ $dirins = $tmp[0]; $FILEFLAG='modulebuilder.txt'; $now=dol_now(); +$newmask = 0; +if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; +if (empty($newmask)) // This should no happen +{ + $newmask='0664'; +} + /* * Actions @@ -156,14 +165,6 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($module); - $arrayreplacement=array( - 'mymodule'=>strtolower($module), - 'MyModule'=>$module, - 'myobject'=>strtolower($objectname), - 'MyObject'=>$objectname - ); - - // Delete some files $filetogenerate = array( 'myobject_card.php'=>strtolower($objectname).'_card.php', @@ -180,7 +181,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) foreach($filetogenerate as $srcfile => $destfile) { - $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile); + $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); if ($result <= 0) { if ($result < 0) @@ -191,7 +192,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } else // $result == 0 { - setEventMessages($langs->trans("FileAlreadyExists", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'warnings'); + setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings'); } } else @@ -210,10 +211,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, + 'MYMODULE'=>strtoupper($module), + 'My module'=>$module, 'htdocs/modulebuilder/template/'=>'', 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname @@ -230,7 +231,36 @@ if ($dirins && $action == 'initobject' && $module && $objectname) if (! $error) { - setEventMessages('FilesForObjectInitialized', null); + // Edit the class file to write properties + rebuildObjectClass($destdir, $module, $objectname, $newmask); + + // Edit sql with new properties + rebuildObjectSql($destdir, $module, $objectname, $newmask); + } + + if (! $error) + { + setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); + } +} + +if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj)) +{ + $objectname = $tabobj; + + $destdir = $dirins.'/'.strtolower($module); + + // TODO Complete list of fields with new one + + // Edit the class file to write properties + rebuildObjectClass($destdir, $module, $objectname, $newmask); + + // Edit sql with new properties + rebuildObjectSql($destdir, $module, $objectname, $newmask); + + if (! $error) + { + setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); } } @@ -320,6 +350,29 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) $tabobj = 'deleteobject'; } +if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) +{ + if (! $error) + { + $modulelowercase=strtolower($module); + $objectlowercase=strtolower($objectname); + + // File of class + $fileforclass = $dirins.'/'.$modulelowercase.'/class/'.$objectlowercase.'.class.php'; + + // TODO + + // File of sql + $fileforsql = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.sql'; + $fileforsqlkey = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.key.sql'; + + + // TODO + } +} + + + if ($dirins && $action == 'generatepackage') { $modulelowercase=strtolower($module); @@ -401,15 +454,7 @@ if ($action == 'savefile' && empty($cancel)) $content = GETPOST('editfilecontent'); // Save file on disk - $newmask = 0; - file_put_contents($pathoffile, $content); - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - if (empty($newmask)) // This should no happen - { - $newmask='0664'; - } - @chmod($pathoffile, octdec($newmask)); setEventMessages($langs->trans("FileSaved"), null); @@ -838,9 +883,11 @@ elseif (! empty($module)) $h++; $listofobject = dol_dir_list($dir, 'files', 0, '\.txt$'); + $firstobjectname=''; foreach($listofobject as $fileobj) { $objectname = preg_replace('/\.txt$/', '', $fileobj['name']); + if (empty($firstobjectname)) $firstobjectname = $objectname; $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname; $head3[$h][1] = $objectname; @@ -853,6 +900,12 @@ elseif (! empty($module)) $head3[$h][2] = 'deleteobject'; $h++; + // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. + if ($tabobj == 'newobjectifnoobj') + { + if ($firstobjectname) $tabobj=$firstobjectname; + else $tabobj = 'newobject'; + } dol_fiche_head($head3, $tabobj, '', -1, ''); @@ -888,92 +941,186 @@ elseif (! empty($module)) } else { - try { - $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; - $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; - $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.class.php'; - $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.class.php'; - print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.'
    '; - print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'
    '; - print ' '.$langs->trans("PageForList").' : '.$pathtolist.'
    '; - print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'
    '; + if ($action == 'deleteproperty') + { + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey','alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), + $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey','alpha')), 'confirm_deleteproperty', '', 0, 1 + ); - $result = dol_include_once($pathtoclass); - $tmpobjet = new $tabobj($db); + // Print form confirm + print $formconfirm; + } - $reflector = new ReflectionClass($tabobj); - $properties = $reflector->getProperties(); // Can also use get_object_vars - $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars - //$propstat = $reflector->getStaticProperties(); + if ($action != 'editfile' || empty($file)) + { + try { + $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php'; + $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php'; + $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; + $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; + print '
    '; + print '
    '; + print ' '.$langs->trans("PageForList").' : '.$pathtolist.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; + print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
    '; - print load_fiche_titre($langs->trans("Properties"), '', ''); + print '


    '; - print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; + $result = dol_include_once($pathtoclass); + if (class_exists($tabobj)) $tmpobjet = new $tabobj($db); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - foreach($properties as $propkey => $propval) - { - if ($propval->class == $tabobj) + $reflector = new ReflectionClass($tabobj); + $properties = $reflector->getProperties(); // Can also use get_object_vars + $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars + //$propstat = $reflector->getStaticProperties(); + + print load_fiche_titre($langs->trans("Properties"), '', ''); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
    '.$langs->trans("Property"); - print ' ('.$langs->trans("Example").')'; - print ''.$langs->trans("Comment").''.$langs->trans("Type").''.$langs->trans("DefaultValue").'
    '; - print ''; - print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + + $properties = $tmpobjet->fields; + + foreach($properties as $propkey => $propval) { - $propname=$propval->getName(); + /* If from Reflection + if ($propval->class == $tabobj) + { + $propname=$propval->getName(); + $comment=$propval->getDocComment(); + $type=gettype($tmpobjet->$propname); + $default=$propdefault[$propname]; + // Discard generic properties + if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; - // Discard generic properties - if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'isnolinkedbythird', 'ismultientitymanaged'))) continue; + // Keep or not lines + if (in_array($propname, array('fk_element', 'lines'))) continue; + }*/ - // Keep or not lines - if (in_array($propname, array('fk_element', 'lines'))) continue; + $propname=$propkey; + $proplabel=$propval['label']; + $proptype=$propval['type']; + $propposition=$propval['position']; + $propnotnull=$propval['notnull']; + $propsearchall=$propval['searchall']; + //$propdefault=$propval['default']; + $propindex=$propval['index']; + $propcomment=$propval['comment']; + print ''; - print ''; print ''; print ''; + print ''; + print ''; + print ''; + /*print '';*/ + print ''; - print ''; + print ''; - print ''; print ''; } + print '
    '.$langs->trans("Property"); + print ' ('.$langs->trans("Example").')'; + print ''; + print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey")); + print ''.$langs->trans("Type").''.$langs->trans("Position").''.$langs->trans("NotNull").''.$langs->trans("SearchAll").''.$langs->trans("DefaultValue").''.$langs->trans("DatabaseIndex").''.$langs->trans("Comment").'
    '; + print ''; + print '
    '; + print ''; print $propname; print ''; - print $propval->getDocComment(); + print $proplabel; print ''; - print gettype($tmpobjet->$propname); + print $proptype; + print ''; + print $propposition; + print ''; + print $propnotnull?'X':''; + print ''; + print $propsearchall?'X':''; + print ''; + print $propdefault; + print ''; + print $propindex?'X':''; print ''; - print $propdefault[$propname]; + print $propcomment; + print ''; + print ''.img_delete().''; print ''; - - print '
    '; + + print '
    '; } - print '
    '; + catch(Exception $e) + { + print $e->getMessage(); + } + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '600', 'Full', 'In', true, false, false, 0, '99%'); + print $doleditor->Create(1, '', false); + print '
    '; + print '
    '; + print ''; + print '   '; + print ''; + print '
    '; print '
    '; } - catch(Exception $e) - { - print $e->getMessage(); - } } } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9ef593367c9..f8882b68c56 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -47,27 +47,30 @@ class MyObject extends CommonObject /** * @var array Does this field is linked to a thirdparty ? */ - protected $isnolinkedbythird=1; + protected $isnolinkedbythird = 1; /** * @var array Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ protected $ismultientitymanaged = 1; - - /** - * @var string String with name of icon for myobject - */ + * @var string String with name of icon for myobject + */ public $picto = 'myobject'; - /** - * @var int Entity Id - */ - public $entity; + // BEGIN MODULEBUILDER PROPERTIES /** * @var array Array with all fields and their property */ - public $fields; + public $fields=array( + 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'position'=>10, 'notnull'=>true, 'index'=>true, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity'=>array('type'=>'integer', 'label'=>'Entity', 'notnull'=>true, 'index'=>true), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'searchall'=>1), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'notnull'=>true, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'notnull'=>true, 'position'=>500), + 'status'=>array('type'=>'integer', 'label'=>'Status', 'index'=>true, 'position'=>1000), + ); + // END MODULEBUILDER PROPERTIES @@ -106,366 +109,6 @@ class MyObject extends CommonObject $this->db = $db; } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add control on parameters values - - // Insert request - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - $sql .= ' field1,'; - $sql .= ' field2'; - //... - $sql .= ') VALUES ('; - $sql .= ' \'' . $this->prop1 . '\','; - $sql .= ' \'' . $this->prop2 . '\''; - //... - $sql .= ')'; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return $this->id; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; - } - if (null !== $ref) { - $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; - } else { - $sql .= ' AND t.rowid = ' . $id; - } - - $resql = $this->db->query($sql); - if ($resql) { - $numrows = $this->db->num_rows($resql); - if ($numrows) { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->prop1 = $obj->field1; - $this->prop2 = $obj->field2; - //... - } - - $this->db->free($resql); - - $this->fetch_optionals(); - - // $this->fetch_lines(); - - if ($numrows) { - return 1; - } else { - return 0; - } - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - return - 1; - } - } - - /** - * Load object in memory from the database - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * - * @return int <0 if KO, >0 if OK - */ - public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= ' t.field1,'; - $sql .= ' t.field2'; - //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; - } - } - $sql.= ' WHERE 1 = 1'; - if (! empty($conf->multicompany->enabled)) { - $sql .= " AND entity IN (" . getEntity('mymoduleobject') . ")"; - } - if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); - } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield,$sortorder); - } - if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - - while ($obj = $this->db->fetch_object($resql)) { - $line = new self($this->db); - - $line->id = $obj->rowid; - $line->prop1 = $obj->field1; - $line->prop2 = $obj->field2; - //... - } - $this->db->free($resql); - - return $num; - } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - - return - 1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - // Clean parameters - if (isset($this->prop1)) { - $this->prop1 = trim($this->prop1); - } - if (isset($this->prop2)) { - $this->prop2 = trim($this->prop2); - } - //... - - // Check parameters - // Put here code to add a control on parameters values - - // Update request - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").","; - $sql .= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null").""; - //... - $sql .= ' WHERE rowid=' . $this->id; - - $this->db->begin(); - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - if (!$error && !$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - $error = 0; - - $this->db->begin(); - - if (!$error) { - if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_DELETE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers - } - } - - // If you need to delete child tables to, you can insert them here - - if (!$error) { - $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; - $sql .= ' WHERE rowid=' . $this->id; - - $resql = $this->db->query($sql); - if (!$resql) { - $error ++; - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - } - - // Commit or rollback - if ($error) { - $this->db->rollback(); - - return - 1 * $error; - } else { - $this->db->commit(); - - return 1; - } - } - - /** - * Load an object from its id and create a new one in database - * - * @param int $fromid Id of object to clone - * - * @return int New id of clone - */ - public function createFromClone($fromid) - { - dol_syslog(__METHOD__, LOG_DEBUG); - - global $user; - $error = 0; - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $object->fetch($fromid); - // Reset object - $object->id = 0; - - // Clear fields - // ... - - // Create clone - $result = $object->create($user); - - // Other options - if ($result < 0) { - $error ++; - $this->errors = $object->errors; - dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - } - - // End - if (!$error) { - $this->db->commit(); - - return $object->id; - } else { - $this->db->rollback(); - - return - 1; - } - } /** * Return a link to the object card (with optionaly the picto) @@ -589,9 +232,7 @@ class MyObject extends CommonObject */ public function initAsSpecimen() { - $this->id = 0; - $this->prop1 = 'prop1'; - $this->prop2 = 'prop2'; + $this->initAsSpecimenCommon(); } } diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 33c52d58bea..cd3fb22be80 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -99,7 +99,7 @@ class modMyModule extends DolibarrModules ); // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp"); + // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); $this->dirs = array(); // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. @@ -288,6 +288,12 @@ class modMyModule extends DolibarrModules $this->_load_tables('/mymodule/sql/'); + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'string', 1, 10, 'project'); + return $this->_init($sql, $options); } diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index 2db00687df5..3ea9ed8a090 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -97,439 +97,221 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - // Put here code you want to execute when a Dolibarr business events occurs. + if (!empty($conf->mymodule->enabled)) return 0; // Module not active, we do nothing + + // Put here code you want to execute when a Dolibarr business events occurs. // Data and type of action are stored into $object and $action - /** Users */ - if ($action == 'USER_LOGIN') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_UPDATE_SESSION') { - // Warning: To increase performances, this action is triggered only if - // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_CREATE_FROM_CONTACT') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_NEW_PASSWORD') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_ENABLEDISABLE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_LOGOUT') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_SETINGROUP') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'USER_REMOVEFROMGROUP') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + switch ($action) { - /** Groups */ - } elseif ($action == 'GROUP_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'GROUP_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'GROUP_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Users + case 'USER_CREATE': + case 'USER_MODIFY': + case 'USER_NEW_PASSWORD': + case 'USER_ENABLEDISABLE': + case 'USER_DELETE': + case 'USER_SETINGROUP': + case 'USER_REMOVEFROMGROUP': - /** Companies */ - } elseif ($action == 'COMPANY_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'COMPANY_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'COMPANY_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + case 'USER_LOGIN': + case 'USER_LOGIN_FAILED': + case 'USER_LOGOUT': + case 'USER_UPDATE_SESSION': // Warning: To increase performances, this action is triggered only if constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. - /** Contacts */ - } elseif ($action == 'CONTACT_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTACT_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTACT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - // Products - } elseif ($action == 'PRODUCT_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PRODUCT_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PRODUCT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Actions + case 'ACTION_MODIFY': + case 'ACTION_CREATE': + case 'ACTION_DELETE': - /** Customer orders */ - } elseif ($action == 'ORDER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_CLONE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_BUILDDOC') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_SENTBYMAIL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEORDER_INSERT') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEORDER_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Groups + case 'GROUP_CREATE': + case 'GROUP_MODIFY': + case 'GROUP_DELETE': - /** Supplier orders */ - } elseif ($action == 'ORDER_SUPPLIER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Companies + case 'COMPANY_CREATE': + case 'COMPANY_MODIFY': + case 'COMPANY_DELETE': - /** Proposals */ - } elseif ($action == 'PROPAL_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_CLONE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_BUILDDOC') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_SENTBYMAIL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_CLOSE_SIGNED') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_CLOSE_REFUSED') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROPAL_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEPROPAL_INSERT') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEPROPAL_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEPROPAL_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Contacts + case 'CONTACT_CREATE': + case 'CONTACT_MODIFY': + case 'CONTACT_DELETE': + case 'CONTACT_ENABLEDISABLE': - /** Contracts */ - } elseif ($action == 'CONTRACT_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTRACT_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTRACT_ACTIVATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTRACT_CANCEL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTRACT_CLOSE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CONTRACT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Products + case 'PRODUCT_CREATE': + case 'PRODUCT_MODIFY': + case 'PRODUCT_DELETE': + case 'PRODUCT_PRICE_MODIFY': + case 'PRODUCT_SET_MULTILANGS': + case 'PRODUCT_DEL_MULTILANGS': - /** Bills */ - } elseif ($action == 'BILL_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_CLONE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_BUILDDOC') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_SENTBYMAIL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_CANCEL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'BILL_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEBILL_INSERT') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'LINEBILL_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + //Stock mouvement + case 'STOCK_MOVEMENT': - /** Payments */ - } elseif ($action == 'PAYMENT_CUSTOMER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PAYMENT_ADD_TO_BANK') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PAYMENT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + //MYECMDIR + case 'MYECMDIR_DELETE': + case 'MYECMDIR_CREATE': + case 'MYECMDIR_MODIFY': - /** Interventions */ - } elseif ($action == 'FICHEINTER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'FICHEINTER_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'FICHEINTER_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'FICHEINTER_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Customer orders + case 'ORDER_CREATE': + case 'ORDER_CLONE': + case 'ORDER_VALIDATE': + case 'ORDER_DELETE': + case 'ORDER_CANCEL': + case 'ORDER_SENTBYMAIL': + case 'ORDER_CLASSIFY_BILLED': + case 'ORDER_SETDRAFT': + case 'LINEORDER_INSERT': + case 'LINEORDER_UPDATE': + case 'LINEORDER_DELETE': - /** Members */ - } elseif ($action == 'MEMBER_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_SUBSCRIPTION') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_NEW_PASSWORD') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_RESILIATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'MEMBER_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Supplier orders + case 'ORDER_SUPPLIER_CREATE': + case 'ORDER_SUPPLIER_CLONE': + case 'ORDER_SUPPLIER_VALIDATE': + case 'ORDER_SUPPLIER_DELETE': + case 'ORDER_SUPPLIER_APPROVE': + case 'ORDER_SUPPLIER_REFUSE': + case 'ORDER_SUPPLIER_CANCEL': + case 'ORDER_SUPPLIER_SENTBYMAIL': + case 'ORDER_SUPPLIER_DISPATCH': + case 'LINEORDER_SUPPLIER_DISPATCH': + case 'LINEORDER_SUPPLIER_CREATE': + case 'LINEORDER_SUPPLIER_UPDATE': - /** Categories */ - } elseif ($action == 'CATEGORY_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CATEGORY_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'CATEGORY_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Proposals + case 'PROPAL_CREATE': + case 'PROPAL_CLONE': + case 'PROPAL_MODIFY': + case 'PROPAL_VALIDATE': + case 'PROPAL_SENTBYMAIL': + case 'PROPAL_CLOSE_SIGNED': + case 'PROPAL_CLOSE_REFUSED': + case 'PROPAL_DELETE': + case 'LINEPROPAL_INSERT': + case 'LINEPROPAL_UPDATE': + case 'LINEPROPAL_DELETE': - /** Projects */ - } elseif ($action == 'PROJECT_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROJECT_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'PROJECT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - /** Project tasks */ - } elseif ($action == 'TASK_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'TASK_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'TASK_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // SupplierProposal + case 'SUPPLIER_PROPOSAL_CREATE': + case 'SUPPLIER_PROPOSAL_CLONE': + case 'SUPPLIER_PROPOSAL_MODIFY': + case 'SUPPLIER_PROPOSAL_VALIDATE': + case 'SUPPLIER_PROPOSAL_SENTBYMAIL': + case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': + case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': + case 'SUPPLIER_PROPOSAL_DELETE': + case 'LINESUPPLIER_PROPOSAL_INSERT': + case 'LINESUPPLIER_PROPOSAL_UPDATE': + case 'LINESUPPLIER_PROPOSAL_DELETE': - /** Task time spent */ - } elseif ($action == 'TASK_TIMESPENT_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'TASK_TIMESPENT_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'TASK_TIMESPENT_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Contracts + case 'CONTRACT_CREATE': + case 'CONTRACT_ACTIVATE': + case 'CONTRACT_CANCEL': + case 'CONTRACT_CLOSE': + case 'CONTRACT_DELETE': + case 'LINECONTRACT_INSERT': + case 'LINECONTRACT_UPDATE': + case 'LINECONTRACT_DELETE': - /** Shipping */ - } elseif ($action == 'SHIPPING_CREATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SHIPPING_MODIFY') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SHIPPING_VALIDATE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SHIPPING_SENTBYMAIL') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SHIPPING_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'SHIPPING_BUILDDOC') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); + // Bills + case 'BILL_CREATE': + case 'BILL_CLONE': + case 'BILL_MODIFY': + case 'BILL_VALIDATE': + case 'BILL_UNVALIDATE': + case 'BILL_SENTBYMAIL': + case 'BILL_CANCEL': + case 'BILL_DELETE': + case 'BILL_PAYED': + case 'LINEBILL_INSERT': + case 'LINEBILL_UPDATE': + case 'LINEBILL_DELETE': - /** File */ - } elseif ($action == 'FILE_UPLOAD') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } elseif ($action == 'FILE_DELETE') { - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); - } + //Supplier Bill + case 'BILL_SUPPLIER_CREATE': + case 'BILL_SUPPLIER_UPDATE': + case 'BILL_SUPPLIER_DELETE': + case 'BILL_SUPPLIER_PAYED': + case 'BILL_SUPPLIER_UNPAYED': + case 'BILL_SUPPLIER_VALIDATE': + case 'BILL_SUPPLIER_UNVALIDATE': + case 'LINEBILL_SUPPLIER_CREATE': + case 'LINEBILL_SUPPLIER_UPDATE': + case 'LINEBILL_SUPPLIER_DELETE': + + // Payments + case 'PAYMENT_CUSTOMER_CREATE': + case 'PAYMENT_SUPPLIER_CREATE': + case 'PAYMENT_ADD_TO_BANK': + case 'PAYMENT_DELETE': + + // Online + case 'PAYMENT_PAYBOX_OK': + case 'PAYMENT_PAYPAL_OK': + case 'PAYMENT_STRIPE_OK': + + // Donation + case 'DON_CREATE': + case 'DON_UPDATE': + case 'DON_DELETE': + + // Interventions + case 'FICHINTER_CREATE': + case 'FICHINTER_MODIFY': + case 'FICHINTER_VALIDATE': + case 'FICHINTER_DELETE': + case 'LINEFICHINTER_CREATE': + case 'LINEFICHINTER_UPDATE': + case 'LINEFICHINTER_DELETE': + + // Members + case 'MEMBER_CREATE': + case 'MEMBER_VALIDATE': + case 'MEMBER_SUBSCRIPTION': + case 'MEMBER_MODIFY': + case 'MEMBER_NEW_PASSWORD': + case 'MEMBER_RESILIATE': + case 'MEMBER_DELETE': + + // Categories + case 'CATEGORY_CREATE': + case 'CATEGORY_MODIFY': + case 'CATEGORY_DELETE': + case 'CATEGORY_SET_MULTILANGS': + + // Projects + case 'PROJECT_CREATE': + case 'PROJECT_MODIFY': + case 'PROJECT_DELETE': + + // Project tasks + case 'TASK_CREATE': + case 'TASK_MODIFY': + case 'TASK_DELETE': + + // Task time spent + case 'TASK_TIMESPENT_CREATE': + case 'TASK_TIMESPENT_MODIFY': + case 'TASK_TIMESPENT_DELETE': + + // Shipping + case 'SHIPPING_CREATE': + case 'SHIPPING_MODIFY': + case 'SHIPPING_VALIDATE': + case 'SHIPPING_SENTBYMAIL': + case 'SHIPPING_BILLED': + case 'SHIPPING_CLOSED': + case 'SHIPPING_REOPEN': + case 'SHIPPING_DELETE': + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + break; + + } return 0; } diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index e010bbfe920..b8b39dd6e8b 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -22,7 +22,7 @@ */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled. Language code is found on url. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); @@ -50,7 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; session_cache_limiter(FALSE); -// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) and load permission if we need to use them in CSS +// Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS /*if (empty($user->id) && ! empty($_SESSION['dol_login'])) { $user->fetch('',$_SESSION['dol_login']); diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index 122b3978631..b9ca46e652e 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -13,8 +13,22 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * Library javascript to enable Browser notifications */ +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (!defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (!defined('NOLOGIN')) define('NOLOGIN', 1); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + /** * \file htdocs/modulebuilder/template/js/mymodule.js.php * \ingroup mymodule @@ -41,4 +55,8 @@ header('Content-Type: application/javascript'); // You can use CTRL+F5 to refresh your browser cache. if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); else header('Cache-Control: no-cache'); +?> + +/* Javascript library of module MyModule */ + diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 73f00abc89f..994aca35c88 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -47,6 +47,7 @@ while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2 if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); // Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); if (! $res) die("Include of main fails"); @@ -58,14 +59,27 @@ dol_include_once('/mymodule/class/myobject.class.php'); $langs->loadLangs(array("mymodule","other")); // Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$cancel = GETPOST('cancel'); -$backtopage = GETPOST('backtopage'); -$myparam = GETPOST('myparam','alpha'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); -$search_field1=GETPOST("search_field1"); -$search_field2=GETPOST("search_field2"); +// Initialize technical objects +$object=new MyObject($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectcard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} if (empty($action) && empty($id) && empty($ref)) $action='view'; @@ -76,19 +90,12 @@ if ($user->societe_id > 0) } //$result = restrictedArea($user, 'mymodule', $id); - -$object = new MyObject_Class($db); -$extrafields = new ExtraFields($db); - // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('mymodule')); - /* @@ -107,7 +114,7 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } @@ -120,33 +127,35 @@ if (empty($reshook)) { if ($cancel) { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } $error=0; - /* object_prop_getpost_prop */ - $object->prop1=GETPOST("field1"); - $object->prop2=GETPOST("field2"); - - if (empty($object->ref)) - { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); - } + foreach ($object->fields as $key => $val) + { + $object->$key=GETPOST($key,'alpha'); + if (in_array($key, array('entity', 'datec', 'tms'))) continue; + if ($val['notnull'] && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } if (! $error) { - $result=$object->create($user); + $result=$object->createCommon($user); if ($result > 0) { // Creation OK - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); header("Location: ".$urltogo); exit; } + else { // Creation KO if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); @@ -203,7 +212,7 @@ if (empty($reshook)) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/mymodule/list.php',1)); + header("Location: ".dol_buildpath('/mymodule/myobject_list.php',1)); exit; } else @@ -225,10 +234,7 @@ if (empty($reshook)) $form=new Form($db); -llxHeader('','MyPageName',''); - - -// Put here content of your page +llxHeader('','MyObject',''); // Example : Adding jquery code print ''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); -$sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.field1,"; -$sql.= " t.field2"; +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)"; -$sql.= " WHERE 1 = 1"; -//$sql.= " WHERE u.entity IN (".getEntity('mytable').")"; -if ($search_field1) $sql.= natural_search("field1",$search_field1); -if ($search_field2) $sql.= natural_search("field2",$search_field2); -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +$sql=preg_replace('/, $/','', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX."myobject as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql.= " WHERE t.entity IN (".getEntity('myobject').")"; +foreach($search as $key => $val) +{ + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields foreach ($search_array_options as $key => $val) { @@ -275,16 +267,37 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } + +// Output page +// -------------------------------------------------------------------- + llxHeader('', $title, $help_url); +// Example : Adding jquery code +print ''; + $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_field1 != '') $param.= '&search_field1='.urlencode($search_field1); -if ($search_field2 != '') $param.= '&search_field2='.urlencode($search_field2); -if ($optioncss != '') $param.='&optioncss='.$optioncss; +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -338,17 +351,23 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
    '; print ''."\n"; // Fields title search +// -------------------------------------------------------------------- print ''; -// LIST_OF_TD_TITLE_SEARCH -//if (! empty($arrayfields['t.field1']['checked'])) print ''; -//if (! empty($arrayfields['t.field2']['checked'])) print ''; +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -376,25 +395,15 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) +// Rest of fields search +foreach($object->fields as $key => $val) { - // Date creation - print ''; + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } -if (! empty($arrayfields['t.tms']['checked'])) -{ - // Date modification - print ''; -} -/*if (! empty($arrayfields['u.statut']['checked'])) - { - // Status - print ''; - }*/ // Action column print ''; print ''."\n"; -// Fields title + +// Fields title label +// -------------------------------------------------------------------- print ''; -// LIST_OF_TD_TITLE_FIELDS -//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); -//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -417,7 +433,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; } } } @@ -425,10 +441,16 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +// Rest of fields title +foreach($object->fields as $key => $val) +{ + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; @@ -440,6 +462,8 @@ foreach ($extrafields->attribute_computed as $key => $val) } +// Loop on record +// -------------------------------------------------------------------- $i=0; $totalarray=array(); while ($i < min($num, $limit)) @@ -449,18 +473,22 @@ while ($i < min($num, $limit)) { // Show here line of result print ''; - // LIST_OF_TD_FIELDS_LIST - /* - if (! empty($arrayfields['t.field1']['checked'])) + foreach($object->fields as $key => $val) { - print ''; - if (! $i) $totalarray['nbfield']++; + if (in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'status') print ''; + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + } } - if (! empty($arrayfields['t.field2']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - }*/ // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -483,30 +511,23 @@ while ($i < min($num, $limit)) $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['t.datec']['checked'])) + // Rest of fields + foreach($object->fields as $key => $val) { - print ''; - if (! $i) $totalarray['nbfield']++; + if (! in_array($key, array('datec','tms','status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'status') print ''; + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + } } - // Date modification - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - /* - if (! empty($arrayfields['u.statut']['checked'])) - { - $userstatic->statut=$obj->statut; - print ''; - }*/ - // Action column print ''; else print ''; } - elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalhtfield'] == $i) print ''; elseif ($totalarray['totalvatfield'] == $i) print ''; elseif ($totalarray['totalttcfield'] == $i) print ''; else print ''; @@ -564,24 +585,28 @@ print ''."\n"; print ''."\n"; - -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) +if ($nbtotalofrecords === '' || $nbtotalofrecords) { - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->lire; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->read; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
    '.$langs->trans("ShowTempMassFilesArea").''; + } } -else -{ - print '
    '.$langs->trans("ShowTempMassFilesArea").''; -} - // End of page llxFooter(); diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php index f83a808a0b9..a8c280193ea 100644 --- a/htdocs/modulebuilder/template/scripts/myobject.php +++ b/htdocs/modulebuilder/template/scripts/myobject.php @@ -43,7 +43,12 @@ $error=0; define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". // Include and load Dolibarr environment variables -require_once($path."../../htdocs/master.inc.php"); +$res=0; +if (! $res && file_exists($path."master.inc.php")) $res=@include($path."master.inc.php"); +if (! $res && file_exists($path."../master.inc.php")) $res=@include($path."../master.inc.php"); +if (! $res && file_exists($path."../../master.inc.php")) $res=@include($path."../../master.inc.php"); +if (! $res && file_exists($path."../../../master.inc.php")) $res=@include($path."../../../master.inc.php"); +if (! $res) die("Include of master fails"); // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). // $user is created but empty. diff --git a/htdocs/modulebuilder/template/sql/llx_myobject.key.sql b/htdocs/modulebuilder/template/sql/llx_myobject.key.sql index 812a98090af..4822d7c3ac4 100644 --- a/htdocs/modulebuilder/template/sql/llx_myobject.key.sql +++ b/htdocs/modulebuilder/template/sql/llx_myobject.key.sql @@ -14,6 +14,9 @@ -- along with this program. If not, see . -ALTER TABLE llx_myobject ADD UNIQUE INDEX uk_fk_othertable (fk_othertable); ---ALTER TABLE llx_myobject ADD CONSTRAINT llx_mytable_field_id FOREIGN KEY (fk_field) REFERENCES llx_myOthertable(rowid); +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_myobject ADD UNIQUE INDEX idx_fieldobject (fieldobject); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_myobject ADD CONSTRAINT llx_myobject_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); diff --git a/htdocs/modulebuilder/template/sql/llx_myobject.sql b/htdocs/modulebuilder/template/sql/llx_myobject.sql index 8cba239766f..b5810f0f227 100644 --- a/htdocs/modulebuilder/template/sql/llx_myobject.sql +++ b/htdocs/modulebuilder/template/sql/llx_myobject.sql @@ -13,9 +13,14 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . + CREATE TABLE llx_myobject( rowid INTEGER AUTO_INCREMENT PRIMARY KEY, + -- BEGIN MODULEBUILDER FIELDS entity INTEGER DEFAULT 1 NOT NULL, - fk_othertable INTEGER NOT NULL, - name VARCHAR(189) -); + label VARCHAR(255), + datec DATETIME NOT NULL, + tms TIMESTAMP NOT NULL, + status INTEGER + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 3266d02f2f4..0a6c9052b91 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -561,7 +561,7 @@ if (empty($reshook)) { if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { - $result = $object->delete(DolibarrApiAccess::$user); + $result = $object->delete($user); } if ($result > 0) diff --git a/htdocs/product/inventory/listview.class.php b/htdocs/product/inventory/listview.class.php index ac5ec68f51a..3dddac44516 100644 --- a/htdocs/product/inventory/listview.class.php +++ b/htdocs/product/inventory/listview.class.php @@ -221,7 +221,7 @@ class Listview */ private function search($sql, &$TParam) { - if (empty($TParam['no-auto-sql-search']) && !GETPOST("button_removefilter_x") && !GETPOST("button_removefilter.x") && !GETPOST("button_removefilter")) + if (empty($TParam['no-auto-sql-search']) && !GETPOST('button_removefilter_x','alpha') && !GETPOST('button_removefilter.x','alpha') && !GETPOST('button_removefilter','alpha')) { foreach ($TParam['search'] as $field => $info) { @@ -331,7 +331,7 @@ class Listview if(empty($TSearch[$key]))$TSearch[$key]=''; } - $removeFilter = (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")); + $removeFilter = (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')); foreach($TParam['search'] as $key => $param_search) { if ($removeFilter) $value = ''; diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 8e4218db227..2b967e62ba5 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -203,7 +203,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $sall=""; $sref=""; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index dae7ea7d8c8..af5e500fbf5 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -206,7 +206,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $sall=""; $sref=""; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index e296d44bd33..1000388cb56 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -89,7 +89,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_soc = ''; } diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index ffa0544976b..9d58c244b2e 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -86,7 +86,7 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $sref=""; $snom=""; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index d3694e039eb..3c335ed1ad8 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -83,7 +83,7 @@ if (! empty($canvas)) * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $sref=""; $snom=""; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 5d419cc880c..1b4036af8af 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -61,7 +61,7 @@ if (! $sortfield) $sortfield="c.date_commande"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { $search_month=''; $search_year=''; } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index d63300a3a96..ad802ed36f6 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -67,7 +67,7 @@ if (! $sortfield) $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { $search_month = ''; $search_year = ''; } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 7117f0c03c0..831e7ec729c 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -62,7 +62,7 @@ if (! $sortfield) $sortfield="f.datef"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { $search_month=''; $search_year=''; } diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index e9124cd003b..514fc622cc5 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -63,7 +63,7 @@ if (! $sortfield) $sortfield = "f.datef"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { $search_month = ''; $search_year = ''; } diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index c5caf6c7c2c..3b7131245a6 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -61,7 +61,7 @@ if (! $sortfield) $sortfield = "p.datep"; $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) { $search_month = ''; $search_year = ''; } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index d3de2b6b6e5..683bb4de566 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -65,7 +65,7 @@ $fieldstosearchall = array( include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $sall=""; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 23df5282435..e12ecee2b9b 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -122,7 +122,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $year=''; $month=''; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index ef4a9bf70c9..fc60f500ba6 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -142,7 +142,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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 { $search_entity=''; $search_product=''; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 59856e35d55..a3f4cb8ecaf 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -92,7 +92,7 @@ if ($mode == 'virtual') $usevirtualstock=1; * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter") || isset($_POST['valid'])) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') || isset($_POST['valid'])) // Both test are required to be compatible with all browsers { $sref = ''; $snom = ''; diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index d190c4d704d..6ed7fc379b5 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -63,7 +63,7 @@ $offset = $limit * $page; * Actions */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $sall=""; $sref=""; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9cda69560d5..a7b243dd338 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -97,7 +97,7 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $action = ''; $search_usertoprocessid = ''; @@ -200,22 +200,25 @@ if ($action == 'addtime' && $user->rights->projet->lire) { $timespent_duration=array(); - foreach($_POST as $key => $time) + if (is_array($_POST)) { - if (intval($time) > 0) + foreach($_POST as $key => $time) { - // Hours or minutes of duration - if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches)) + if (intval($time) > 0) { - $id = $matches[1]; - if ($id > 0) - { - // We store HOURS in seconds - if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; + // Hours or minutes of duration + if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches)) + { + $id = $matches[1]; + if ($id > 0) + { + // We store HOURS in seconds + if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60; - // We store MINUTES in seconds - if($matches[2]=='min') $timespent_duration[$id] += $time*60; - } + // We store MINUTES in seconds + if($matches[2]=='min') $timespent_duration[$id] += $time*60; + } + } } } } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4a2156430af..5f3e9b1aa20 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -110,7 +110,7 @@ $object=new Task($db); */ // Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $action = ''; $search_usertoprocessid = ''; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 05c31287745..8e506b5d454 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -78,7 +78,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9c78387f95b..1bf65decd71 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -161,7 +161,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $search_all=''; $search_categ=''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 41ae6d28364..112c2697706 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -81,7 +81,7 @@ $userAccess=0; */ // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_user_id=""; $toselect=''; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 7bff02fa864..58ef76b7a91 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -151,7 +151,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $search_all=""; $search_categ=""; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f85b5071de1..a04a4573aea 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -459,7 +459,9 @@ if ($id > 0 || ! empty($ref)) // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + if (!empty($projectstatic->thirdparty)) { + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } $morehtmlref.=''; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 37331b000ab..f643b9b5ca3 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -96,7 +96,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +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 { $search_date=''; $search_datehour=''; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 53658c588c6..0564392071a 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -130,7 +130,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_ref=""; $search_label=""; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index c67fb1c4dc4..497b9593142 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -83,7 +83,7 @@ if (empty($reshook)) } // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $actioncode=''; $search_agenda_label=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1605e7281b8..2bd764c92ed 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2016 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry @@ -3346,31 +3346,36 @@ class Societe extends CommonObject */ function getOutstandingProposals($mode='customer') { - $table='propal'; - if ($mode == 'supplier') $table = 'supplier_proposal'; + $table='propal'; + if ($mode == 'supplier') $table = 'supplier_proposal'; - $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_proposal').")"; + } else { + $sql .= " AND entity IN (".getEntity('propal').")"; + } - dol_syslog("getOutstandingProposals", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingProposals", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3381,31 +3386,36 @@ class Societe extends CommonObject */ function getOutstandingOrders($mode='customer') { - $table='commande'; - if ($mode == 'supplier') $table = 'commande_fournisseur'; + $table='commande'; + if ($mode == 'supplier') $table = 'commande_fournisseur'; - $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('supplier_order').")"; + } else { + $sql .= " AND entity IN (".getEntity('commande').")"; + } - dol_syslog("getOutstandingOrders", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - while($obj=$this->db->fetch_object($resql)) { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - if ($obj->fk_statut != 0) // Not a draft - { - $outstandingOpened+=$obj->total_ttc; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - return array(); + dol_syslog("getOutstandingOrders", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + while($obj=$this->db->fetch_object($resql)) { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + if ($obj->fk_statut != 0) // Not a draft + { + $outstandingOpened+=$obj->total_ttc; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + return array(); } /** @@ -3416,64 +3426,69 @@ class Societe extends CommonObject */ function getOutstandingBills($mode='customer') { - $table='facture'; - if ($mode == 'supplier') $table = 'facture_fourn'; + $table='facture'; + if ($mode == 'supplier') $table = 'facture_fourn'; - /* Accurate value of remain to pay is to sum remaintopay for each invoice - $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); - */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; - $sql .= " WHERE fk_soc = ". $this->id; + /* Accurate value of remain to pay is to sum remaintopay for each invoice + $paiement = $invoice->getSommePaiement(); + $creditnotes=$invoice->getSumCreditNotesUsed(); + $deposits=$invoice->getSumDepositsUsed(); + $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); + $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); + */ + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + $sql .= " WHERE fk_soc = ". $this->id; + if ($mode == 'supplier') { + $sql .= " AND entity IN (".getEntity('facture_fourn').")"; + } else { + $sql .= " AND entity IN (".getEntity('facture').")"; + } - dol_syslog("getOutstandingBills", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingOpened = 0; - $outstandingTotal = 0; - $outstandingTotalIncTax = 0; - if ($mode == 'supplier') - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $tmpobject=new FactureFournisseur($this->db); - } - else - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); - } - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; - if ($obj->fk_statut != 0 // Not a draft - && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice - ) - { - $outstandingTotal+= $obj->total_ht; - $outstandingTotalIncTax+= $obj->total_ttc; - } - if ($obj->paye == 0 - && $obj->fk_statut != 0 // Not a draft - && $obj->fk_statut != 3 // Not abandonned - && $obj->fk_statut != 2) // Not classified as paid - //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason - { - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; - } - } - return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); - } - else - { - return array(); - } + dol_syslog("getOutstandingBills", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingOpened = 0; + $outstandingTotal = 0; + $outstandingTotalIncTax = 0; + if ($mode == 'supplier') + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $tmpobject=new FactureFournisseur($this->db); + } + else + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $tmpobject=new Facture($this->db); + } + while($obj=$this->db->fetch_object($resql)) { + $tmpobject->id=$obj->rowid; + if ($obj->fk_statut != 0 // Not a draft + && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice + ) + { + $outstandingTotal+= $obj->total_ht; + $outstandingTotalIncTax+= $obj->total_ttc; + } + if ($obj->paye == 0 + && $obj->fk_statut != 0 // Not a draft + && $obj->fk_statut != 3 // Not abandonned + && $obj->fk_statut != 2) // Not classified as paid + //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason + { + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; + } + } + return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); + } + else + { + return array(); + } } /** diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index d9cae2a4170..5c134aee36d 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -57,7 +57,7 @@ $month = GETPOST('month','int'); $year = GETPOST('year','int'); // Clean up on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $sref=''; $sprod_fulldescr=''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 252bfc9383c..f7a479b8ddf 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -209,7 +209,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Did we click on purge search criteria ? - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_nom=''; $search_alias=''; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 5146e3ad6a5..515aef60a6a 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -69,7 +69,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_prod = ''; } @@ -187,7 +187,7 @@ if (! empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); -dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company'); +dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -200,11 +200,11 @@ print '
    '; - print ''; - print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; $searchpicto=$form->showFilterButtons(); @@ -402,11 +411,18 @@ print $searchpicto; print '
    '.$obj->field1.''.$object->getLibStatut(3).''.$obj->field2.''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''.$object->getLibStatut(3).''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$userstatic->getLibStatut(3).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -536,7 +557,7 @@ if (isset($totalarray['totalhtfield'])) if ($num < $limit) print ''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
    '; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; } if ($object->client) { - print '
    ' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
    ' . $langs->trans('Prefix') . '' . $object->prefix_comm . '
    '; + print '
    '; print $langs->trans('CustomerCode') . ''; print $object->code_client; if ($object->check_codeclient() != 0) @@ -213,7 +213,7 @@ if ($object->client) { } if ($object->fournisseur) { - print '
    '; + print '
    '; print $langs->trans('SupplierCode') . ''; print $object->code_fournisseur; if ($object->check_codefournisseur() != 0) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e5040b3150d..5c39f910b66 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -511,7 +511,8 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; + $predef=''; + $ref_fourn = GETPOST('fourn_ref'); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -599,7 +600,7 @@ if (empty($reshook)) $price_base_type = $productsupplier->fourn_price_base_type; $type = $productsupplier->type; $label = $productsupplier->label; - $desc = $productsupplier->description; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); @@ -983,7 +984,9 @@ $now = dol_now(); // Add new askprice if ($action == 'create') { - print load_fiche_titre($langs->trans("NewAskPrice")); + $currency_code = $conf->currency; + + print load_fiche_titre($langs->trans("NewAskPrice")); $soc = new Societe($db); if ($socid > 0) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d91d7e198fb..142fcc413e5 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2563,10 +2563,9 @@ class SupplierProposal extends CommonObject /** - * \class SupplierProposalLine - * \brief Class to manage supplier_proposal lines + * Class to manage supplier_proposal lines */ -class SupplierProposalLine extends CommonObjectLine +class SupplierProposalLine extends CommonObjectLine { var $db; var $error; @@ -2798,6 +2797,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; @@ -2841,7 +2841,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; - $sql.= " ".price2num($this->subprice).","; + $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; @@ -2982,6 +2982,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; + if (empty($this->subprice)) $this->subprice=0; if (empty($this->pa_ht)) $this->pa_ht=0; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index f6d9c9510a0..23a0fae1876 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -177,7 +177,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_categ=''; $search_user=''; diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index eabd0c58bd3..cddbef17dd1 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' @@ -25,7 +26,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1136e1c1fc4..b82fd096cfe 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2607,7 +2607,7 @@ form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-ty tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { border-bottom: 0px !important; } -td.nobottom, td.nobottom { +tr.nobottom td, tr.nobottom , td.nobottom { border-bottom: 0px !important; } div.liste_titre .tagtd { diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index 6f1bbe7fb30..e0374f6b271 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -15,6 +15,7 @@ CKEDITOR.editorConfig = function( config ) //config.height = '300px'; //config.resize_dir = 'vertical'; // horizontal, vertical, both config.removePlugins = 'elementspath,save'; // config.removePlugins = 'elementspath,save,font'; + //config.extraPlugins = 'docprops,scayt,showprotected'; config.removeDialogTabs = 'flash:advanced'; // config.removeDialogTabs = 'flash:advanced;image:Link'; config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // Prevent PHP Code to be formatted //config.menu_groups = 'clipboard,table,anchor,link,image'; // for context menu 'clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea' @@ -25,7 +26,10 @@ CKEDITOR.editorConfig = function( config ) config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //config.contentsCss = '/css/mysitestyles.css'; config.image_previewText=' '; // Must no be empty - + //config.autoParagraph = false; + //config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd'; // See also rules on this.dataProcessor.writer.setRules + //config.forcePasteAsPlainText = true; + config.toolbar_Full = [ ['Templates','NewPage'], diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 978b093fc9d..fb774e8793b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2684,7 +2684,7 @@ tr.pair:last-of-type td, tr.impair:last-of-type td { tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { border-bottom: 0px !important; } -td.nobottom, td.nobottom { +tr.nobottom td, tr.nobottom , td.nobottom { border-bottom: 0px !important; } div.liste_titre .tagtd { diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 939f7c35aa7..b71a5ccdf18 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -46,8 +46,17 @@ $cancel = GETPOST('cancel','alpha'); $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); -if ($user->id == $id) $feature2=''; // A user can always read its own card -$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); +// Ok if user->rights->salaries->read or user->rights->salaries->payment->write or user->rights->hrm->read +//$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); +$ok=false; +if ($user->id == $id) $ok=true; // A user can always read its own card +if ($user->rights->salaries->read) $ok=true; +if ($user->rights->salaries->payment->write) $ok=true; +if ($user->rights->hrm->read) $ok=true; +if (! $ok) +{ + accessforbidden(); +} $object = new User($db); if ($id > 0 || ! empty($ref)) @@ -61,6 +70,42 @@ if ($id > 0 || ! empty($ref)) * Actions */ +if ($action == 'add' && ! $cancel) +{ + // Modification + $account = new UserBankAccount($db); + + $account->userid = $object->id; + + $account->bank = $_POST["bank"]; + $account->label = $_POST["label"]; + $account->courant = $_POST["courant"]; + $account->clos = $_POST["clos"]; + $account->code_banque = $_POST["code_banque"]; + $account->code_guichet = $_POST["code_guichet"]; + $account->number = $_POST["number"]; + $account->cle_rib = $_POST["cle_rib"]; + $account->bic = $_POST["bic"]; + $account->iban = $_POST["iban"]; + $account->domiciliation = $_POST["domiciliation"]; + $account->proprio = $_POST["proprio"]; + $account->owner_address = $_POST["owner_address"]; + + $result = $account->create($user); + + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + $action='edit'; // Force chargement page edition + } + else + { + $url=DOL_URL_ROOT.'/user/bank.php?id='.$object->id.'&bankid='.$bankid; + header('Location: '.$url); + exit; + } +} + if ($action == 'update' && ! $cancel) { // Modification @@ -122,7 +167,7 @@ else if (empty($account->userid)) $account->userid=$object->id; -if ($bankid && $action == 'edit' && $user->rights->user->user->creer) +if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { print '
    '; print ''; @@ -130,7 +175,7 @@ if ($bankid && $action == 'edit' && $user->rights->user->user->creer) print ''; print ''; } -if ($bankid && $action == 'create' && $user->rights->user->user->creer) +if ($id && $action == 'create' && $user->rights->user->user->creer) { print ''; print ''; @@ -140,7 +185,7 @@ if ($bankid && $action == 'create' && $user->rights->user->user->creer) // View -if ($account->id && $action != 'edit') +if ($action != 'edit' && $action != 'create') // If not bank account yet, $account may be empty { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, -1, 'user'); @@ -150,24 +195,25 @@ if ($account->id && $action != 'edit') if ($user->rights->user->user->lire || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } - + dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); - + print '
    '; print '
    '; - + print ''; - - print ''; - print ''; - + + print ''; + print ''; + print ''; + print '
    '.$langs->trans("xxx").'
    '.$langs->trans("Login").''.$object->login.'
    '; - + print '
    '; - + print load_fiche_titre($langs->trans("BAN")); - + print '
    '; print ''; @@ -237,7 +283,7 @@ if ($account->id && $action != 'edit') } print ""; - + dol_fiche_end(); /* @@ -247,24 +293,27 @@ if ($account->id && $action != 'edit') if ($user->rights->user->user->creer) { + if ($account->id > 0) print ''.$langs->trans("Edit").''; + else + print ''.$langs->trans("Create").''; } print ''; } // Edit -if ($id && $action == 'edit' && $user->rights->user->user->creer) +if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer) { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'id', $linkback,$user->rights->user->user->lire || $user->admin); - + + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + //print '
    '; - + print '
    '; print '
    '; @@ -323,7 +372,7 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer) print '
    '; //print '
    '; - + dol_fiche_end(); print '
    '; @@ -334,7 +383,9 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer) } if ($id && $action == 'edit' && $user->rights->user->user->creer) print ''; - + +if ($id && $action == 'create' && $user->rights->user->user->creer) print ''; + llxFooter(); $db->close(); diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 00d350c3b0f..77872bf8654 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -73,7 +73,8 @@ class UserBankAccount extends Account if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib"); - return 1; + + return $this->update($user); } } else diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index be9bb0e1f4c..5240605c25c 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -806,6 +806,7 @@ class UserGroup extends CommonObject function _load_ldap_info() { global $conf,$langs; + $info=array(); // Object classes diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index e53080cea73..a32db37d3fb 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -1,9 +1,9 @@ - * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2011 Herve Prot - * Copyright (C) 2012 Florian Henry +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2015 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011 Herve Prot + * Copyright (C) 2012 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +82,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -132,7 +132,7 @@ if ($action == 'add') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -165,7 +165,7 @@ if ($action == 'adduser' || $action =='removeuser') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'errors'); } } @@ -207,7 +207,7 @@ if ($action == 'update') } else { - $langs->load("errors"); + $langs->load("errors"); setEventMessages($langs->trans('ErrorForbidden'), null, 'mesgs'); } } @@ -275,7 +275,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $object->showOptionals($extrafields,'edit'); + print $object->showOptionals($extrafields,'edit'); } print "
    \n"; @@ -316,23 +316,26 @@ else if ($action != 'edit') { - dol_fiche_head($head, 'group', $title, -1, 'group'); + dol_fiche_head($head, 'group', $title, -1, 'group'); dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); print '
    '; print '
    '; - print ''; + print '
    '; - // Name - print ''; - print '\n"; + // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) + if (! empty($conf->mutlicompany->enabled)) + { + print ''; + print '\n"; + } // Multicompany if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) @@ -350,7 +353,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="2"'); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print "
    '.$langs->trans("Name").''.$object->name; - if (empty($object->entity)) - { - print img_picto($langs->trans("GlobalGroup"),'redstar'); - } - print "
    '.$langs->trans("Name").''.$object->name; + if (empty($object->entity)) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
    \n"; print '
    '; @@ -435,59 +438,57 @@ else print ''.$langs->trans("Lastname").''; print ''.$langs->trans("Firstname").''; if (! empty($conf->multicompany->enabled) && $conf->entity == 1) - { - print ''.$langs->trans("Entity").''; + { + print ''.$langs->trans("Entity").''; } print ''.$langs->trans("Status").''; print ' '; print "\n"; - if (! empty($object->members)) - { - foreach($object->members as $useringroup) - { - - - print ''; - print ''; - print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); - if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar'); - else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star'); - print ''; - print ''.$useringroup->lastname.''; - print ''.$useringroup->firstname.''; - if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print ''; - if (! empty($useringroup->usergroup_entity)) - { - $nb=0; - foreach($useringroup->usergroup_entity as $group_entity) - { - $mc->getInfo($group_entity); - print ($nb > 0 ? ', ' : '').$mc->label; - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - $nb++; - } - } - print ''; - } - print ''.$useringroup->getLibStatut(3).''; - print ''; - if (! empty($user->admin) && empty($conf->multicompany->enabled)) - { - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - } - else - { - print "-"; - } - print "\n"; - } + if (! empty($object->members)) + { + foreach($object->members as $useringroup) + { + print ''; + print ''; + print $useringroup->getNomUrl(-1, '', 0, 0, 24, 0, 'login'); + if ($useringroup->admin && ! $useringroup->entity) print img_picto($langs->trans("SuperAdministrator"),'redstar'); + else if ($useringroup->admin) print img_picto($langs->trans("Administrator"),'star'); + print ''; + print ''.$useringroup->lastname.''; + print ''.$useringroup->firstname.''; + if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print ''; + if (! empty($useringroup->usergroup_entity)) + { + $nb=0; + foreach($useringroup->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + print ($nb > 0 ? ', ' : '').$mc->label; + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + $nb++; + } + } + print ''; + } + print ''.$useringroup->getLibStatut(3).''; + print ''; + if (! empty($user->admin) && empty($conf->multicompany->enabled)) + { + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + } + else + { + print "-"; + } + print "\n"; + } } else { @@ -547,10 +548,10 @@ else print "".$mc->select_entities($object->entity); print "\n"; } - else - { - print ''; - } + else + { + print ''; + } } print ''.$langs->trans("Description").''; @@ -560,13 +561,13 @@ else $doleditor->Create(); print ''; print "\n"; - // Other attributes + // 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'); + print $object->showOptionals($extrafields,'edit'); } print "\n"; diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index e8d37801998..41eb7d0fa77 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -81,7 +81,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_label=""; $search_date_creation=""; diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 6d987be85cb..c195136863e 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; $langs->load("companies"); $langs->load("ldap"); $langs->load("users"); +$langs->load("admin"); // Users/Groups management only in master entity if transverse mode if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) @@ -110,22 +111,23 @@ print '
    '; print ''; -// Name -print ''; -print ''; + print '\n"; } -print "\n"; // Note -print ''; -print ''; +print ''; +print ''; print "\n"; -$langs->load("admin"); - // LDAP DN print '\n"; diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 94a9c9c1883..46477879b14 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -205,14 +205,17 @@ if ($object->id) print '
    '.$langs->trans("Name").''.$object->name; -if (!$object->entity) +// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) +if (! empty($conf->mutlicompany->enabled)) { - print img_picto($langs->trans("GlobalGroup"),'redstar'); + print '
    '.$langs->trans("Name").''.$object->name; + if (!$object->entity) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
    '.$langs->trans("Note").''.nl2br($object->note).' 
    '.$langs->trans("Description").''.dol_htmlentitiesbr($object->note).'
    LDAP '.$langs->trans("LDAPGroupDn").''.$conf->global->LDAP_GROUP_DN."
    '; - // Nom - print ''; - print ''; + print '\n"; } - print "\n"; // Note print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 3e82e2b6357..59798d65e1a 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -47,7 +47,7 @@ $search_statut=GETPOST('search_statut','int'); if ($search_statut == '') $search_statut='1'; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers { $search_statut=""; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 54fffcd3fb7..631a75d47c4 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -148,7 +148,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + 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 { $search_user=""; $search_login=""; diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 99fd4d64603..4f9dc58c615 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -129,7 +129,7 @@ class WebsitePage extends CommonObject $sql.= 'content,'; $sql.= 'status,'; $sql.= 'date_creation,'; - $sql.= 'date_modification'; + $sql.= 'tms'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a5c2ae4e046..2c9c364edac 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -129,6 +129,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; +$filehtmlheader=$pathofwebsite.'/header.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -240,25 +241,30 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - //$db->begin(); - $res = $object->fetch(0, $website); - /* - $res = $object->update($user); - if ($res > 0) - { - $db->commit(); - $action=''; - } - else + // Html header file + $htmlheadercontent = ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + + dol_syslog("Save file css into ".$filehtmlheader); + + dol_mkdir($pathofwebsite); + $result = file_put_contents($filehtmlheader, $htmlheadercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); + + if (! $result) { $error++; - $db->rollback(); - }*/ + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); + } + // Css file $csscontent = ''."\n"; - $csscontent.= ''."\n"; + $csscontent.= ''."\n"; $csscontent.= '"."\n"; @@ -278,6 +284,7 @@ if ($action == 'updatecss') setEventMessages('Failed to write file '.$filecss, null, 'errors'); } + if (! $error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -310,7 +317,7 @@ if ($action == 'setashome') dol_delete_file($fileindex); $indexcontent = ''."\n"; $result = file_put_contents($fileindex, $indexcontent); @@ -406,6 +413,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
    '."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -414,8 +422,10 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
    '."\n"; $tplcontent.= ''."\n"; @@ -458,7 +468,8 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage if (! is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - symlink($pathtomedias, $pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); } /*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite')) @@ -560,6 +571,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= "// END PHP ?>\n"; $tplcontent.= ''."\n"; $tplcontent.= '
    '."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -567,8 +579,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
    '."\n"; $tplcontent.= ''."\n"; @@ -939,6 +953,11 @@ if ($action == 'editcss') print '
    '; + $htmlheader = @file_get_contents($filehtmlheader); + // Clean the php css file to remove php code and get only html part + $htmlheader = preg_replace('//s', '', $htmlheader); + + $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); @@ -957,11 +976,19 @@ if ($action == 'editcss') print ''; + print ''; + /*print '
    '.$langs->trans("Name").''.$object->name.''; - if (! $object->entity) + // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) + if (! empty($conf->mutlicompany->enabled)) { - print img_picto($langs->trans("GlobalGroup"),'redstar'); + print '
    '.$langs->trans("Name").''.$object->name.''; + if (! $object->entity) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "
    '.$langs->trans("Description").'
    '; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; - print ''; print '
    '; + print $langs->trans('WEBSITE_HTML_HEADER'); + print ''; + print ''; + print '
    '; print $langs->trans('WEBSITE_CSS_URL'); print ''; @@ -1089,7 +1116,10 @@ if ($action == 'preview') $out.=$csscontent; $out.=''."\n"; - $out.=$objectpage->content."\n"; + // Replace php code + $content = preg_replace('/<\?php.*\?>/ims', '...php...', $objectpage->content); + + $out.=$content."\n"; $out.=''; diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index f8624ebc040..98a5c4d51bc 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -104,7 +104,7 @@ function migrate_product_photospath($product) global $conf; $dir = $conf->product->multidir_output[$product->entity]; - $origin = $dir .'/'. get_exdir($product->id,2) . $product->id ."/photos"; + $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; $destin = $dir.'/'.dol_sanitizeFileName($product->ref); $error = 0; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index c0a4ce845a9..feac8b212ed 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -286,11 +286,27 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $dirout=$conf->admin->dir_temp.'/test'; + $dirout2=$conf->admin->dir_temp.'/test2'; $count=0; - $result=dol_delete_dir_recursive($dirout,$count,1); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + $result=dol_delete_dir_recursive($dirout,$count); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it print __METHOD__." result=".$result."\n"; $this->assertGreaterThanOrEqual(0,$result); + + $count=0; + $countdeleted=0; + $result=dol_delete_dir_recursive($dirout,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(0,$result); + $this->assertGreaterThanOrEqual(0,$countdeleted); + + dol_mkdir($dirout2); + $count=0; + $countdeleted=0; + $result=dol_delete_dir_recursive($dirout2,$count,1,0,$countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); + $this->assertGreaterThanOrEqual(1,$countdeleted); } @@ -399,7 +415,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".join(',',$result)."\n"; $this->assertEquals(0,count($result)); } - + /** * testDolDirList * @@ -411,7 +427,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase public function testDolDirList() { global $conf,$user,$langs,$db; - + // Scan dir to guaruante we on't have library jquery twice (we accept exception of duplicte into ckeditor because all dir is removed for debian package, so there is no duplicate). $founddirs=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor')); print __METHOD__." count(founddirs)=".count($founddirs)."\n"; @@ -431,60 +447,60 @@ class FilesLibTest extends PHPUnit_Framework_TestCase $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; - - + + //$dummyuser=new User($db); //$result=restrictedArea($dummyuser,'societe'); // We save user properties $savpermlire = $user->rights->facture->lire; $savpermcreer = $user->rights->facture->creer; - - + + // Check access to SPECIMEN $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='SPECIMEN.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(1,$result['accessallowed']); - - + + // Check read permission $user->rights->facture->lire = 1; $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(1,$result['accessallowed']); - + $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read'); $this->assertEquals(0,$result['accessallowed']); - + // Check write permission $user->rights->facture->lire = 0; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(0,$result['accessallowed']); - + $user->rights->facture->lire = 1; $user->rights->facture->creer = 1; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(1,$result['accessallowed']); - + $user->rights->facture->lire = 1; $user->rights->facture->creer = 0; $filename='FA010101/FA010101.pdf'; // Filename relative to module part $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write'); $this->assertEquals(0,$result['accessallowed']); - - + + // We restore user properties $user->rights->facture->lire = $savpermlire; $user->rights->facture->creer = $savpermcreer; - } + } } diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index b60a7e9e833..7eb485ffbab 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -144,11 +144,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase echo __METHOD__.' Request POST url='.$url."\n"; - + // Send to non existant directory - + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); - + //$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }'; $data = array( 'filename'=>"mynewfile.txt", @@ -158,7 +158,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase 'filecontent'=>"content text", 'fileencoding'=>"" ); - + $result = getURLContent($url, 'POST', $data, 1); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; @@ -166,11 +166,11 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object, 'Parsing of json result must no be null'); $this->assertEquals('401', $object['error']['code']); - + // Send to existant directory - + dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2'); - + $data = array( 'filename'=>"mynewfile.txt", 'modulepart'=>"medias", @@ -187,5 +187,7 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase $this->assertNotNull($object2, 'Parsing of json result must no be null'); $this->assertEquals($result2['curl_error_no'], ''); $this->assertEquals($result2['content'], 'true'); + + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); } }